#include <stdio.h>
#include <ctype.h> // isalnum()
#include <string.h> // stricmp()
#include <stdlib.h> // exit()
#include <sys/time.h>
#define N 26
#define BLOCK 32
#define LINE_SIZE 1024

__global__ void countAlphaOnGPU (char *idata, int *sum, int size) {
  int idx = blockIdx.x * blockDim.x + threadIdx.x;

  // printf("%d", ('a'-'A'));
  // printf("%c", idata[idx]);
  // printf("%d ", idata[idx]-'a');
  // printf("%d ", ('a'-'A'));
  // sum[idata[idx]-'a'] += 1;
  // printf("%d ", sum[idata[idx]-'a']);
  // printf("%d ", sum[idx]);


    // if ((idata[idx] >= 'A') && (idata[idx] <= 'Z')) {
    //   atomicAdd(&sum[idata[idx]-'A'],1);
    // } else if ((idata[idx] >= 'a') && (idata[idx] <= 'z')) {
    //   atomicAdd(&sum[idata[idx]-'a'],1);
    // }
  
  for (int i = 0; i < size; i++) {
    if ((idata[size*idx+i] >= 'A') && (idata[size*idx+i] <= 'Z')) {
      atomicAdd(&sum[idata[size*idx+i]-'A'],1);
    } else if ((idata[size*idx+i] >= 'a') && (idata[size*idx+i] <= 'z')) {
      atomicAdd(&sum[idata[size*idx+i]-'a'],1);
    }
  }

}
/*
__global__ void reduction0(int *idata, int *sum) {
  int idx = blockIdx.x * blockDim.x + threadIdx.x;
  atomicAdd(sum,idata[idx]);
}

void init(int *idata) {
  for (int i = 0; i < N; i++) {
    idata[i] = 1;
  }
}
*/

double cpuSecond() {
  struct timeval tp;
  gettimeofday(&tp, NULL);
  return ((double)tp.tv_sec + (double)tp.tv_usec*1.e-6);
}


int main(void){
  FILE *fp;
  char *fp2, *idata;
  int *odata, *sum; 
  long sz;
  char *fp3;

  double iStart_cpu, iElaps_cpu;
  double iStart_cpu2, iElaps_cpu2;
  double iStart_cpu3, iElaps_cpu3;

  double iStart_cpu4, iElaps_cpu4, iStart_cpu5, iElaps_cpu5;

  iStart_cpu = cpuSecond();

	if ( (fp=fopen("book4.txt","r"))==NULL ) {
		printf("File not open...\n");
		exit(1);
  }

  // fseek(fp, 0, SEEK_SET);
  // // printf("%c", fp->_IO_read_ptr[0]);
  // for (int j = 0; j < 1000; j++) {
  //   printf("%c", fp->_IO_read_ptr[j]);
  // }
  

  fseek(fp, 0, SEEK_END);
  sz = ftell(fp);
  printf("ファイルのサイズ : %ldバイト\n", sz);
  fseek(fp, 0, SEEK_SET);

  // for (int j = 0; j < 1000; j++) {
  //   printf("%c", fp->_IO_read_ptr[j]);
  // }
  // printf("\n");

  fp2 = (char *)malloc(sz);
  // fp2 = (char *)malloc(1024*sizeof(char));
  // fp3 = (char *)malloc(sz);
  iStart_cpu4 = cpuSecond();
  int z = 0;
  while ((fp2[z] = fgetc(fp)) != EOF) { // ラインでとる or 全て一気にとる方法を考える
      z++;
  }
  iElaps_cpu4 = cpuSecond() - iStart_cpu4;

  iStart_cpu5 = cpuSecond();
  // while ( fgets(fp2, 1024, fp) != NULL ) {
  //   strcat(fp3,fp2);
  //   // for (int i = 0; fp2[i] != '\0'; i++)
  //   //   printf("%c", fp2[i]);
  // }
  iElaps_cpu5 = cpuSecond() - iStart_cpu5;
  // for (int i = 0; fp3[i] != '\0'; i++) {
  //   printf("%c", fp3[i]);
  // }

  fseek(fp, 0, SEEK_SET);

  iStart_cpu3 = cpuSecond();
  cudaMalloc((void**)&idata, sz);
  cudaMalloc((void**)&odata, N*sizeof(int));
  iElaps_cpu3 = cpuSecond() - iStart_cpu3;
  // // host_idata = (char *)malloc(N*sizeof(char));
  sum = (int *)malloc(N*sizeof(int));
  // init(host_idata);
  
  // cudaMemcpy(idata, fp2, sz, cudaMemcpyHostToDevice);
  cudaMemcpy(idata, fp2, sz, cudaMemcpyHostToDevice);

  // free(host_idata);
  memset(sum, 0, N*sizeof(int));
  // memset(sum, 0, sizeof(int));
  // sum = 0;
  cudaMemcpy(odata, sum, N*sizeof(int), cudaMemcpyHostToDevice);
  // cudaMemcpy(odata, &sum, sizeof(int), cudaMemcpyHostToDevice);

  // dim3 block(BLOCK, BLOCK);
  // dim3 grid(sz/100*BLOCK,1);
  
  iStart_cpu2 = cpuSecond();
  // countAlphaOnGPU<<<grid,block>>>(idata, odata);
  // countAlphaOnGPU<<<4048,1024>>>(idata, odata);
  countAlphaOnGPU<<<sz/(LINE_SIZE*BLOCK)+1,BLOCK>>>(idata, odata, LINE_SIZE);
  iElaps_cpu2 = cpuSecond() - iStart_cpu2;
  // reduction0<<<2,256>>>(idata, odata);

  cudaMemcpy(sum, odata, N*sizeof(int), cudaMemcpyDeviceToHost);
  // cudaMemcpy(&sum, odata, sizeof(int), cudaMemcpyDeviceToHost);

  int i = 0;
  for (char c = 'a'; c <= 'z'; c++, i++) {
    printf("%c, %d\n", c ,sum[i]);
  }

  cudaFree(idata);
  cudaFree(odata);
  free(sum);
  free(fp2);
  fclose(fp);

  iElaps_cpu = cpuSecond() - iStart_cpu;
  printf("Time elapsed %f sec\n", iElaps_cpu);
  printf("Time elapsed %f sec (計算部分のみ)\n", iElaps_cpu2);
  printf("Time elapsed %f sec (cudaMalloc)\n", iElaps_cpu3);
  printf("Time elapsed %f sec (1charずつ)\n", iElaps_cpu4);
  printf("Time elapsed %f sec (1行ずつ)\n", iElaps_cpu5);

  return 0;
}
	.file	"tmpxft_0036cc7c_00000000-6_histAlphabet.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2031:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2031:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z9cpuSecondv
	.type	_Z9cpuSecondv, @function
_Z9cpuSecondv:
.LFB2027:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	xorl	%esi, %esi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	call	gettimeofday@PLT
	cvtsi2sdq	16(%rsp), %xmm0
	mulsd	.LC0(%rip), %xmm0
	cvtsi2sdq	8(%rsp), %xmm1
	addsd	%xmm1, %xmm0
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L3
	call	__stack_chk_fail@PLT
.L3:
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z9cpuSecondv, .-_Z9cpuSecondv
	.globl	_Z38__device_stub__Z15countAlphaOnGPUPcPiiPcPii
	.type	_Z38__device_stub__Z15countAlphaOnGPUPcPiiPcPii, @function
_Z38__device_stub__Z15countAlphaOnGPUPcPiiPcPii:
.LFB2053:
	.cfi_startproc
	endbr64
	subq	$136, %rsp
	.cfi_def_cfa_offset 144
	movq	%rdi, 24(%rsp)
	leaq	40(%rsp), %rcx
	leaq	48(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	60(%rsp), %rsi
	movl	%edx, 12(%rsp)
	leaq	32(%rsp), %rdx
	movq	%fs:40, %rax
	movq	%rax, 120(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 56(%rsp)
	movq	%rax, 96(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 104(%rsp)
	leaq	12(%rsp), %rax
	movq	%rax, 112(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 48(%rsp)
	movq	%rax, 60(%rsp)
	movl	$1, 68(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L6
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z15countAlphaOnGPUPcPii(%rip), %rdi
	pushq	40(%rsp)
	.cfi_def_cfa_offset 160
	movq	76(%rsp), %rcx
	movl	84(%rsp), %r8d
	movq	64(%rsp), %rsi
	movl	72(%rsp), %edx
	leaq	112(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 152
	popq	%rdx
	.cfi_def_cfa_offset 144
.L6:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2053:
	.size	_Z38__device_stub__Z15countAlphaOnGPUPcPiiPcPii, .-_Z38__device_stub__Z15countAlphaOnGPUPcPiiPcPii
	.globl	_Z15countAlphaOnGPUPcPii
	.type	_Z15countAlphaOnGPUPcPii, @function
_Z15countAlphaOnGPUPcPii:
.LFB2054:
	.cfi_startproc
	endbr64
	jmp	_Z38__device_stub__Z15countAlphaOnGPUPcPiiPcPii
	.cfi_endproc
.LFE2054:
	.size	_Z15countAlphaOnGPUPcPii, .-_Z15countAlphaOnGPUPcPii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"r"
.LC2:
	.string	"book4.txt"
.LC3:
	.string	"File not open...\n"
.LC4:
	.string	"\343\203\225\343\202\241\343\202\244\343\203\253\343\201\256\343\202\265\343\202\244\343\202\272 : %ld\343\203\220\343\202\244\343\203\210\n"
.LC5:
	.string	"%c, %d\n"
.LC6:
	.string	"Time elapsed %f sec\n"
.LC7:
	.string	"Time elapsed %f sec (\350\250\210\347\256\227\351\203\250\345\210\206\343\201\256\343\201\277)\n"
.LC8:
	.string	"Time elapsed %f sec (cudaMalloc)\n"
.LC9:
	.string	"Time elapsed %f sec (1char\343\201\232\343\201\244)\n"
.LC10:
	.string	"Time elapsed %f sec (1\350\241\214\343\201\232\343\201\244)\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$88, %rsp
	.cfi_def_cfa_offset 144
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	call	_Z9cpuSecondv
	leaq	.LC1(%rip), %rsi
	leaq	.LC2(%rip), %rdi
	movsd	%xmm0, (%rsp)
	call	fopen@PLT
	testq	%rax, %rax
	jne	.L12
	movl	$2, %edi
	leaq	.LC3(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L12:
	movq	%rax, %rbx
	movl	$2, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	fseek@PLT
	movq	%rbx, %rdi
	call	ftell@PLT
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %rdx
	movq	%rax, %r13
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%edx, %edx
	xorl	%esi, %esi
	movq	%rbx, %rdi
	call	fseek@PLT
	movq	%r13, %rdi
	call	malloc@PLT
	movq	%rax, %r12
	call	_Z9cpuSecondv
	movq	%r12, %rbp
	movsd	%xmm0, 8(%rsp)
.L13:
	movq	%rbx, %rdi
	incq	%rbp
	call	fgetc@PLT
	movb	%al, -1(%rbp)
	incb	%al
	jne	.L13
	call	_Z9cpuSecondv
	subsd	8(%rsp), %xmm0
	movq	%xmm0, %r15
	call	_Z9cpuSecondv
	movsd	%xmm0, 8(%rsp)
	call	_Z9cpuSecondv
	subsd	8(%rsp), %xmm0
	xorl	%edx, %edx
	xorl	%esi, %esi
	movq	%rbx, %rdi
	movsd	%xmm0, 8(%rsp)
	call	fseek@PLT
	call	_Z9cpuSecondv
	leaq	32(%rsp), %rdi
	movq	%r13, %rsi
	movsd	%xmm0, 16(%rsp)
	call	cudaMalloc@PLT
	movl	$104, %esi
	leaq	40(%rsp), %rdi
	call	cudaMalloc@PLT
	call	_Z9cpuSecondv
	subsd	16(%rsp), %xmm0
	movl	$104, %edi
	movsd	%xmm0, 16(%rsp)
	call	malloc@PLT
	movq	32(%rsp), %rdi
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rax, %rbp
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	xorl	%eax, %eax
	movl	$26, %ecx
	movq	%rbp, %rdi
	rep stosl
	movq	40(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	movl	$104, %edx
	call	cudaMemcpy@PLT
	call	_Z9cpuSecondv
	movq	%r13, %rax
	movl	$32768, %ecx
	xorl	%r9d, %r9d
	cqto
	xorl	%r8d, %r8d
	movsd	%xmm0, 24(%rsp)
	idivq	%rcx
	movl	$134217729, %edx
	movl	$1, %ecx
	salq	$5, %rdx
	incl	%eax
	movl	%eax, 48(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 52(%rsp)
	movq	48(%rsp), %rdi
	movl	56(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L14
	movq	40(%rsp), %rsi
	movq	32(%rsp), %rdi
	movl	$1024, %edx
	call	_Z38__device_stub__Z15countAlphaOnGPUPcPiiPcPii
.L14:
	call	_Z9cpuSecondv
	movq	40(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%r14d, %r14d
	subsd	24(%rsp), %xmm0
	movl	$2, %ecx
	movl	$104, %edx
	leaq	.LC5(%rip), %r13
	movsd	%xmm0, 24(%rsp)
	call	cudaMemcpy@PLT
.L15:
	movl	0(%rbp,%r14,4), %ecx
	leal	97(%r14), %edx
	movq	%r13, %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	incq	%r14
	call	__printf_chk@PLT
	cmpq	$26, %r14
	jne	.L15
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	40(%rsp), %rdi
	call	cudaFree@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	%rbx, %rdi
	call	fclose@PLT
	call	_Z9cpuSecondv
	subsd	(%rsp), %xmm0
	leaq	.LC6(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	movsd	24(%rsp), %xmm0
	leaq	.LC7(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	movsd	16(%rsp), %xmm0
	leaq	.LC8(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	%r15, %xmm0
	leaq	.LC9(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	movsd	8(%rsp), %xmm0
	leaq	.LC10(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	addq	$88, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	main, .-main
	.section	.rodata.str1.1
.LC11:
	.string	"_Z15countAlphaOnGPUPcPii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2056:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC11(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z15countAlphaOnGPUPcPii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2056:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	-1598689907
	.long	1051772663
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <ctype.h> // isalnum()
#include <string.h> // stricmp()
#include <stdlib.h> // exit()
#include <sys/time.h>
#define N 26
#define BLOCK 32
#define LINE_SIZE 1024

__global__ void countAlphaOnGPU (char *idata, int *sum, int size) {
  int idx = blockIdx.x * blockDim.x + threadIdx.x;

  // printf("%d", ('a'-'A'));
  // printf("%c", idata[idx]);
  // printf("%d ", idata[idx]-'a');
  // printf("%d ", ('a'-'A'));
  // sum[idata[idx]-'a'] += 1;
  // printf("%d ", sum[idata[idx]-'a']);
  // printf("%d ", sum[idx]);


    // if ((idata[idx] >= 'A') && (idata[idx] <= 'Z')) {
    //   atomicAdd(&sum[idata[idx]-'A'],1);
    // } else if ((idata[idx] >= 'a') && (idata[idx] <= 'z')) {
    //   atomicAdd(&sum[idata[idx]-'a'],1);
    // }
  
  for (int i = 0; i < size; i++) {
    if ((idata[size*idx+i] >= 'A') && (idata[size*idx+i] <= 'Z')) {
      atomicAdd(&sum[idata[size*idx+i]-'A'],1);
    } else if ((idata[size*idx+i] >= 'a') && (idata[size*idx+i] <= 'z')) {
      atomicAdd(&sum[idata[size*idx+i]-'a'],1);
    }
  }

}
/*
__global__ void reduction0(int *idata, int *sum) {
  int idx = blockIdx.x * blockDim.x + threadIdx.x;
  atomicAdd(sum,idata[idx]);
}

void init(int *idata) {
  for (int i = 0; i < N; i++) {
    idata[i] = 1;
  }
}
*/

double cpuSecond() {
  struct timeval tp;
  gettimeofday(&tp, NULL);
  return ((double)tp.tv_sec + (double)tp.tv_usec*1.e-6);
}


int main(void){
  FILE *fp;
  char *fp2, *idata;
  int *odata, *sum; 
  long sz;
  char *fp3;

  double iStart_cpu, iElaps_cpu;
  double iStart_cpu2, iElaps_cpu2;
  double iStart_cpu3, iElaps_cpu3;

  double iStart_cpu4, iElaps_cpu4, iStart_cpu5, iElaps_cpu5;

  iStart_cpu = cpuSecond();

	if ( (fp=fopen("book4.txt","r"))==NULL ) {
		printf("File not open...\n");
		exit(1);
  }

  // fseek(fp, 0, SEEK_SET);
  // // printf("%c", fp->_IO_read_ptr[0]);
  // for (int j = 0; j < 1000; j++) {
  //   printf("%c", fp->_IO_read_ptr[j]);
  // }
  

  fseek(fp, 0, SEEK_END);
  sz = ftell(fp);
  printf("ファイルのサイズ : %ldバイト\n", sz);
  fseek(fp, 0, SEEK_SET);

  // for (int j = 0; j < 1000; j++) {
  //   printf("%c", fp->_IO_read_ptr[j]);
  // }
  // printf("\n");

  fp2 = (char *)malloc(sz);
  // fp2 = (char *)malloc(1024*sizeof(char));
  // fp3 = (char *)malloc(sz);
  iStart_cpu4 = cpuSecond();
  int z = 0;
  while ((fp2[z] = fgetc(fp)) != EOF) { // ラインでとる or 全て一気にとる方法を考える
      z++;
  }
  iElaps_cpu4 = cpuSecond() - iStart_cpu4;

  iStart_cpu5 = cpuSecond();
  // while ( fgets(fp2, 1024, fp) != NULL ) {
  //   strcat(fp3,fp2);
  //   // for (int i = 0; fp2[i] != '\0'; i++)
  //   //   printf("%c", fp2[i]);
  // }
  iElaps_cpu5 = cpuSecond() - iStart_cpu5;
  // for (int i = 0; fp3[i] != '\0'; i++) {
  //   printf("%c", fp3[i]);
  // }

  fseek(fp, 0, SEEK_SET);

  iStart_cpu3 = cpuSecond();
  hipMalloc((void**)&idata, sz);
  hipMalloc((void**)&odata, N*sizeof(int));
  iElaps_cpu3 = cpuSecond() - iStart_cpu3;
  // // host_idata = (char *)malloc(N*sizeof(char));
  sum = (int *)malloc(N*sizeof(int));
  // init(host_idata);
  
  // cudaMemcpy(idata, fp2, sz, cudaMemcpyHostToDevice);
  hipMemcpy(idata, fp2, sz, hipMemcpyHostToDevice);

  // free(host_idata);
  memset(sum, 0, N*sizeof(int));
  // memset(sum, 0, sizeof(int));
  // sum = 0;
  hipMemcpy(odata, sum, N*sizeof(int), hipMemcpyHostToDevice);
  // cudaMemcpy(odata, &sum, sizeof(int), cudaMemcpyHostToDevice);

  // dim3 block(BLOCK, BLOCK);
  // dim3 grid(sz/100*BLOCK,1);
  
  iStart_cpu2 = cpuSecond();
  // countAlphaOnGPU<<<grid,block>>>(idata, odata);
  // countAlphaOnGPU<<<4048,1024>>>(idata, odata);
  countAlphaOnGPU<<<sz/(LINE_SIZE*BLOCK)+1,BLOCK>>>(idata, odata, LINE_SIZE);
  iElaps_cpu2 = cpuSecond() - iStart_cpu2;
  // reduction0<<<2,256>>>(idata, odata);

  hipMemcpy(sum, odata, N*sizeof(int), hipMemcpyDeviceToHost);
  // cudaMemcpy(&sum, odata, sizeof(int), cudaMemcpyDeviceToHost);

  int i = 0;
  for (char c = 'a'; c <= 'z'; c++, i++) {
    printf("%c, %d\n", c ,sum[i]);
  }

  hipFree(idata);
  hipFree(odata);
  free(sum);
  free(fp2);
  fclose(fp);

  iElaps_cpu = cpuSecond() - iStart_cpu;
  printf("Time elapsed %f sec\n", iElaps_cpu);
  printf("Time elapsed %f sec (計算部分のみ)\n", iElaps_cpu2);
  printf("Time elapsed %f sec (cudaMalloc)\n", iElaps_cpu3);
  printf("Time elapsed %f sec (1charずつ)\n", iElaps_cpu4);
  printf("Time elapsed %f sec (1行ずつ)\n", iElaps_cpu5);

  return 0;
}
	.text
	.file	"histAlphabet.hip"
	.globl	_Z30__device_stub__countAlphaOnGPUPcPii # -- Begin function _Z30__device_stub__countAlphaOnGPUPcPii
	.type	_Z30__device_stub__countAlphaOnGPUPcPii,@function
_Z30__device_stub__countAlphaOnGPUPcPii: # @_Z30__device_stub__countAlphaOnGPUPcPii
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$112, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	40(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	32(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	12(%rsp), %rsi
	movl	%edx, (%rsi)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	movq	%rsi, 16(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	24(%rsp), %r12
	leaq	16(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z15countAlphaOnGPUPcPii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z30__device_stub__countAlphaOnGPUPcPii, .Lfunc_end0-_Z30__device_stub__countAlphaOnGPUPcPii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z9cpuSecondv
.LCPI1_0:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.text
	.globl	_Z9cpuSecondv
	.type	_Z9cpuSecondv,@function
_Z9cpuSecondv:                          # @_Z9cpuSecondv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	movq	%rsp, %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	cvtsi2sdq	(%rbx), %xmm1
	cvtsi2sdq	8(%rbx), %xmm0
	mulsd	.LCPI1_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z9cpuSecondv, .Lfunc_end1-_Z9cpuSecondv
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI2_0:
	.quad	0x3eb0c6f7a0b5ed8d              # double 9.9999999999999995E-7
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$168, %rsp
	.cfi_def_cfa_offset 224
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	leaq	8(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%rbx), %r14
	movq	8(%rbx), %r15
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB2_8
# %bb.1:
	movq	%rax, %rbx
	movq	%r15, 48(%rsp)                  # 8-byte Spill
	movq	%r14, 56(%rsp)                  # 8-byte Spill
	movq	%rax, %rdi
	xorl	%esi, %esi
	movl	$2, %edx
	callq	fseek
	movq	%rbx, %rdi
	callq	ftell
	movq	%rax, %r12
	movl	$.L.str.3, %edi
	movq	%rax, %rsi
	xorl	%eax, %eax
	callq	printf
	movq	%rbx, %rdi
	xorl	%esi, %esi
	xorl	%edx, %edx
	callq	fseek
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %r14
	leaq	8(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r15), %rax
	movq	%rax, 40(%rsp)                  # 8-byte Spill
	movq	8(%r15), %rax
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	movq	%r14, 72(%rsp)                  # 8-byte Spill
.LBB2_2:                                # =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	callq	fgetc
	movb	%al, (%r14)
	incq	%r14
	cmpb	$-1, %al
	jne	.LBB2_2
# %bb.3:
	leaq	8(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r15), %rax
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	movq	8(%r15), %rax
	movq	%rax, 160(%rsp)                 # 8-byte Spill
	leaq	8(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r15), %rax
	movq	%rax, 152(%rsp)                 # 8-byte Spill
	movq	8(%r15), %rax
	movq	%rax, 144(%rsp)                 # 8-byte Spill
	leaq	8(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r15), %rax
	movq	%rax, 136(%rsp)                 # 8-byte Spill
	movq	8(%r15), %rax
	movq	%rax, 128(%rsp)                 # 8-byte Spill
	movq	%rbx, %rdi
	xorl	%esi, %esi
	xorl	%edx, %edx
	callq	fseek
	leaq	8(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r15), %rax
	movq	%rax, 120(%rsp)                 # 8-byte Spill
	movq	8(%r15), %rax
	movq	%rax, 112(%rsp)                 # 8-byte Spill
	leaq	80(%rsp), %rbp
	movq	%rbp, %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	leaq	64(%rsp), %r13
	movl	$104, %esi
	movq	%r13, %rdi
	callq	hipMalloc
	leaq	8(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r15), %rax
	movq	%rax, 104(%rsp)                 # 8-byte Spill
	movq	8(%r15), %rax
	movq	%rax, 96(%rsp)                  # 8-byte Spill
	movl	$1, %edi
	movl	$104, %esi
	callq	calloc@PLT
	movq	%rax, %r15
	movq	(%rbp), %rdi
	movq	72(%rsp), %rsi                  # 8-byte Reload
	movq	%r12, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%r13), %rdi
	movl	$104, %edx
	movq	%r15, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	8(%rsp), %r13
	movq	%r13, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r13), %rax
	movq	%rax, 88(%rsp)                  # 8-byte Spill
	movq	8(%r13), %r13
	leaq	32767(%r12), %rdi
	testq	%r12, %r12
	cmovnsq	%r12, %rdi
	shrq	$15, %rdi
	incl	%edi
	btsq	$32, %rdi
	movabsq	$4294967296, %rdx               # imm = 0x100000000
	orq	$32, %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_5
# %bb.4:
	movq	80(%rsp), %rdi
	movq	64(%rsp), %rsi
	movl	$1024, %edx                     # imm = 0x400
	callq	_Z30__device_stub__countAlphaOnGPUPcPii
.LBB2_5:
	leaq	8(%rsp), %r12
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r12), %r14
	movq	8(%r12), %r12
	movq	64(%rsp), %rsi
	movl	$104, %edx
	movq	%r15, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	xorl	%ebp, %ebp
.LBB2_6:                                # =>This Inner Loop Header: Depth=1
	leal	97(%rbp), %esi
	movl	(%r15,%rbp,4), %edx
	movl	$.L.str.4, %edi
	xorl	%eax, %eax
	callq	printf
	incq	%rbp
	cmpq	$26, %rbp
	jne	.LBB2_6
# %bb.7:
	cvtsi2sd	%r12, %xmm1
	cvtsi2sd	%r14, %xmm11
	cvtsi2sd	%r13, %xmm2
	cvtsi2sdq	88(%rsp), %xmm0         # 8-byte Folded Reload
	cvtsi2sdq	96(%rsp), %xmm3         # 8-byte Folded Reload
	cvtsi2sdq	104(%rsp), %xmm12       # 8-byte Folded Reload
	cvtsi2sdq	112(%rsp), %xmm4        # 8-byte Folded Reload
	cvtsi2sdq	120(%rsp), %xmm5        # 8-byte Folded Reload
	cvtsi2sdq	128(%rsp), %xmm6        # 8-byte Folded Reload
	cvtsi2sdq	136(%rsp), %xmm13       # 8-byte Folded Reload
	cvtsi2sdq	144(%rsp), %xmm7        # 8-byte Folded Reload
	cvtsi2sdq	152(%rsp), %xmm8        # 8-byte Folded Reload
	cvtsi2sdq	160(%rsp), %xmm9        # 8-byte Folded Reload
	cvtsi2sdq	24(%rsp), %xmm14        # 8-byte Folded Reload
	cvtsi2sdq	32(%rsp), %xmm10        # 8-byte Folded Reload
	movsd	.LCPI2_0(%rip), %xmm15          # xmm15 = mem[0],zero
	mulsd	%xmm15, %xmm1
	addsd	%xmm1, %xmm11
	xorps	%xmm1, %xmm1
	cvtsi2sdq	40(%rsp), %xmm1         # 8-byte Folded Reload
	mulsd	%xmm15, %xmm2
	addsd	%xmm2, %xmm0
	xorps	%xmm2, %xmm2
	cvtsi2sdq	48(%rsp), %xmm2         # 8-byte Folded Reload
	subsd	%xmm0, %xmm11
	movsd	%xmm11, 32(%rsp)                # 8-byte Spill
	mulsd	%xmm15, %xmm3
	addsd	%xmm3, %xmm12
	mulsd	%xmm15, %xmm4
	addsd	%xmm4, %xmm5
	subsd	%xmm5, %xmm12
	movsd	%xmm12, 40(%rsp)                # 8-byte Spill
	mulsd	%xmm15, %xmm6
	addsd	%xmm6, %xmm13
	mulsd	%xmm15, %xmm7
	addsd	%xmm7, %xmm8
	subsd	%xmm8, %xmm13
	movsd	%xmm13, 48(%rsp)                # 8-byte Spill
	mulsd	%xmm15, %xmm9
	addsd	%xmm9, %xmm14
	mulsd	%xmm15, %xmm10
	addsd	%xmm10, %xmm1
	subsd	%xmm1, %xmm14
	movsd	%xmm14, 24(%rsp)                # 8-byte Spill
	mulsd	%xmm15, %xmm2
	xorps	%xmm0, %xmm0
	cvtsi2sdq	56(%rsp), %xmm0         # 8-byte Folded Reload
	addsd	%xmm2, %xmm0
	movsd	%xmm0, 56(%rsp)                 # 8-byte Spill
	movq	80(%rsp), %rdi
	callq	hipFree
	movq	64(%rsp), %rdi
	callq	hipFree
	movq	%r15, %rdi
	callq	free
	movq	72(%rsp), %rdi                  # 8-byte Reload
	callq	free
	movq	%rbx, %rdi
	callq	fclose
	leaq	8(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm1, %xmm1
	cvtsi2sdq	(%rbx), %xmm1
	xorps	%xmm0, %xmm0
	cvtsi2sdq	8(%rbx), %xmm0
	mulsd	.LCPI2_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	subsd	56(%rsp), %xmm0                 # 8-byte Folded Reload
	movl	$.L.str.5, %edi
	movb	$1, %al
	callq	printf
	movl	$.L.str.6, %edi
	movsd	32(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	movl	$.L.str.7, %edi
	movsd	40(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	movl	$.L.str.8, %edi
	movsd	24(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	movl	$.L.str.9, %edi
	movsd	48(%rsp), %xmm0                 # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	xorl	%eax, %eax
	addq	$168, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB2_8:
	.cfi_def_cfa_offset 224
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$1, %edi
	callq	exit
.Lfunc_end2:
	.size	main, .Lfunc_end2-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB3_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB3_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z15countAlphaOnGPUPcPii, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end3:
	.size	__hip_module_ctor, .Lfunc_end3-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB4_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB4_2:
	retq
.Lfunc_end4:
	.size	__hip_module_dtor, .Lfunc_end4-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z15countAlphaOnGPUPcPii,@object # @_Z15countAlphaOnGPUPcPii
	.section	.rodata,"a",@progbits
	.globl	_Z15countAlphaOnGPUPcPii
	.p2align	3, 0x0
_Z15countAlphaOnGPUPcPii:
	.quad	_Z30__device_stub__countAlphaOnGPUPcPii
	.size	_Z15countAlphaOnGPUPcPii, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"book4.txt"
	.size	.L.str, 10

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"r"
	.size	.L.str.1, 2

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"\343\203\225\343\202\241\343\202\244\343\203\253\343\201\256\343\202\265\343\202\244\343\202\272 : %ld\343\203\220\343\202\244\343\203\210\n"
	.size	.L.str.3, 41

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"%c, %d\n"
	.size	.L.str.4, 8

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Time elapsed %f sec\n"
	.size	.L.str.5, 21

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Time elapsed %f sec (\350\250\210\347\256\227\351\203\250\345\210\206\343\201\256\343\201\277)\n"
	.size	.L.str.6, 42

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Time elapsed %f sec (cudaMalloc)\n"
	.size	.L.str.7, 34

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Time elapsed %f sec (1char\343\201\232\343\201\244)\n"
	.size	.L.str.8, 35

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"Time elapsed %f sec (1\350\241\214\343\201\232\343\201\244)\n"
	.size	.L.str.9, 34

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z15countAlphaOnGPUPcPii"
	.size	.L__unnamed_1, 25

	.type	__hip_fatbin_wrapper,@object    # @__hip_fatbin_wrapper
	.section	.hipFatBinSegment,"a",@progbits
	.p2align	3, 0x0
__hip_fatbin_wrapper:
	.long	1212764230                      # 0x48495046
	.long	1                               # 0x1
	.quad	__hip_fatbin
	.quad	0
	.size	__hip_fatbin_wrapper, 24

	.type	__hip_gpubin_handle,@object     # @__hip_gpubin_handle
	.local	__hip_gpubin_handle
	.comm	__hip_gpubin_handle,8,8
	.section	.init_array,"aw",@init_array
	.p2align	3, 0x0
	.quad	__hip_module_ctor
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"File not open..."
	.size	.Lstr, 17

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym _Z30__device_stub__countAlphaOnGPUPcPii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z15countAlphaOnGPUPcPii
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z15countAlphaOnGPUPcPii ; -- Begin function _Z15countAlphaOnGPUPcPii
	.globl	_Z15countAlphaOnGPUPcPii
	.p2align	8
	.type	_Z15countAlphaOnGPUPcPii,@function
_Z15countAlphaOnGPUPcPii:               ; @_Z15countAlphaOnGPUPcPii
; %bb.0:
	s_load_b32 s2, s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_cmp_lt_i32 s2, 1
	s_cbranch_scc1 .LBB0_7
; %bb.1:                                ; %.lr.ph
	s_clause 0x1
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b32 s3, s[0:1], 0x24
	v_mov_b32_e32 v4, 1
	s_waitcnt lgkmcnt(0)
	s_add_u32 s0, s6, 0xfffffefc
	s_addc_u32 s1, s7, -1
	s_and_b32 s3, s3, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s3, v[0:1]
	v_mul_lo_u32 v0, v1, s2
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v1, 31, v0
	v_add_co_u32 v0, vcc_lo, s4, v0
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v1, vcc_lo
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	global_load_u8 v5, v[0:1], off
	s_waitcnt vmcnt(0)
	v_add_nc_u16 v2, v5, 0xffbf
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_and_b32_e32 v2, 0xff, v2
	v_cmp_gt_u16_e64 s3, 26, v2
	v_cmp_lt_u16_e32 vcc_lo, 25, v2
	v_dual_mov_b32 v3, s1 :: v_dual_mov_b32 v2, s0
	s_and_saveexec_b32 s4, vcc_lo
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	v_add_nc_u16 v5, v5, 0xff9f
	s_and_not1_b32 s3, s3, exec_lo
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_and_b32_e32 v2, 0xff, v5
	v_cmp_gt_u16_e32 vcc_lo, 26, v2
	v_dual_mov_b32 v2, s6 :: v_dual_mov_b32 v3, s7
	s_and_b32 s5, vcc_lo, exec_lo
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s3, s3, s5
; %bb.4:                                ; %Flow
                                        ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s4
	s_and_saveexec_b32 s4, s3
	s_cbranch_execz .LBB0_6
; %bb.5:                                ; %.sink.split
                                        ;   in Loop: Header=BB0_2 Depth=1
	v_and_b32_e32 v5, 0xff, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b32_e32 v5, 2, v5
	v_add_co_u32 v2, vcc_lo, v2, v5
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v3, vcc_lo
	global_atomic_add_u32 v[2:3], v4, off
.LBB0_6:                                ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s4
	v_add_co_u32 v0, vcc_lo, v0, 1
	v_add_co_ci_u32_e32 v1, vcc_lo, 0, v1, vcc_lo
	s_add_i32 s2, s2, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_eq_u32 s2, 0
	s_cbranch_scc0 .LBB0_2
.LBB0_7:                                ; %._crit_edge
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z15countAlphaOnGPUPcPii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 6
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z15countAlphaOnGPUPcPii, .Lfunc_end0-_Z15countAlphaOnGPUPcPii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 312
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         8
        .size:           8
        .value_kind:     global_buffer
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         28
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         36
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         38
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         40
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         42
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         44
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         46
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         88
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z15countAlphaOnGPUPcPii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z15countAlphaOnGPUPcPii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
