#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <time.h>

#define BLOCK_SIZE 32768
#define STREAMS_IN_GPU 4

__global__ void countDigits (char *digits, int *count, int maxIndex);
__global__ void initCount (int *count);

//-------- Save values to dat file --------//
void saveFrequenciesToFile(int** array0, int** array1, int total){
  FILE *filePointer = fopen("freq.dat", "w");
    for(int k = 0; k < 10; k++) {
			int sum = 0;
      for(int i = 0; i < STREAMS_IN_GPU; i++) {
				sum += array0[i][k] + array1[i][k];
      }
			fprintf(filePointer, "%d, %f\n", k, ((float)sum/(float)total));
    }
	fclose(filePointer);
}

void printDigits(char *digits, int size){
	for(int i = 0; i < size; i++){
		if ('0' <= digits[i] && digits[i] <= '9')
			printf("%c", digits[i]);
	}
	printf("\n");
}

//-------- Count method --------//
int countInGPU(cudaStream_t* streams, int fileLength, int fileRead, char* digits, int **dev_count, char **dev_digits, FILE *inputFile, int **counts) {
  int sizeToRead[STREAMS_IN_GPU];
  for(int i = 0; i < STREAMS_IN_GPU; i++) {
		sizeToRead[i] = (fileLength - (fileRead + BLOCK_SIZE)) < 0 ? fileLength - fileRead : BLOCK_SIZE;
    fread(&digits[fileRead], sizeToRead[i], 1, inputFile);
    cudaMemcpyAsync(dev_digits[i], digits+fileRead, sizeToRead[i]*sizeof(char), cudaMemcpyHostToDevice, streams[i]);
    fileRead += sizeToRead[i];
  }
  for(int i = 0; i < STREAMS_IN_GPU; i++) {
    countDigits<<<sizeToRead[i], 1, 0, streams[i]>>>(dev_digits[i], dev_count[i], sizeToRead[i]);
  }
  for(int i = 0; i < STREAMS_IN_GPU; i++) {
    cudaMemcpyAsync(counts[i], dev_count[i], 10*sizeof(int), cudaMemcpyDeviceToHost, streams[i]);
  }
  return fileRead;
}

//-------- Main --------//
int main(int argc, char **argv) {

  //--- Testing parameters
  if (argc != 2){
      printf("Incorrect number of parameters :(\n");
      printf("Try: \"./Multi-Pi <filename>\"\n");
      exit(0);
  }

//--- Reading file
  FILE *inputFile = fopen(argv[1], "r");

  if (inputFile == NULL) {
    fprintf(stderr, "File could not be opened :P\n");
    printf("Make sure you spelled the name of your file correctly.\n");
    exit(0);
  }

//--- Calculating size of file
  fseek(inputFile, 0, SEEK_END);
  int fileLength = ftell(inputFile);
  fseek(inputFile, 0, SEEK_SET);
	int memorySize = fileLength * sizeof(char);
	printf("File length:%d memorySize:%d\n", fileLength, memorySize);

//--- Declaring CUDA and host variables
	cudaStream_t* streams0 = (cudaStream_t*) malloc(STREAMS_IN_GPU*sizeof(cudaStream_t));
  cudaStream_t* streams1 = (cudaStream_t*) malloc(STREAMS_IN_GPU*sizeof(cudaStream_t));
  int **counts0 = (int**) malloc(STREAMS_IN_GPU*sizeof(int*));
	for(int i = 0; i < STREAMS_IN_GPU; i++) {
    counts0[i] = (int*) malloc(sizeof(int)*10);
	}
  int **counts1 = (int**) malloc(STREAMS_IN_GPU*sizeof(int*));
	for(int i = 0; i < STREAMS_IN_GPU; i++) {
    counts1[i] = (int*) malloc(sizeof(int)*10);
	}
  int **dev_count0 = (int **)malloc(STREAMS_IN_GPU*sizeof(int*));
  int **dev_count1 = (int **)malloc(STREAMS_IN_GPU*sizeof(int*));
	char **dev_digits0 = (char **)malloc(STREAMS_IN_GPU*sizeof(char*));
  char **dev_digits1 = (char **)malloc(STREAMS_IN_GPU*sizeof(char*));
	char *digits0, *digits1;
	
	//--- Initializing GPU 0
	cudaSetDevice(0);
  for(int j = 0; j < STREAMS_IN_GPU; j++) {
    cudaStreamCreate(&streams0[j]);
    cudaMalloc((void**)&dev_digits0[j], BLOCK_SIZE*sizeof(char));
    cudaMalloc((void**)&dev_count0[j], 10*sizeof(int));
    initCount<<<10, 1, 0, streams0[j]>>>(dev_count0[j]);
  }

	//--- Initializing GPU 1
	cudaSetDevice(1);
  for(int j = 0; j < STREAMS_IN_GPU; j++) {
    cudaStreamCreate(&streams1[j]);
    cudaMalloc((void**)&dev_digits1[j], BLOCK_SIZE*sizeof(char));
    cudaMalloc((void**)&dev_count1[j], 10*sizeof(int));
    initCount<<<10, 1, 0, streams1[j]>>>(dev_count1[j]);
  }

	//--- Executing CUDA code
  clock_t start = clock();

	cudaSetDevice(0);
  for(int j = 0; j < STREAMS_IN_GPU; j++) {
    initCount<<<10, 1, 0, streams0[j]>>>(dev_count0[j]);
  }
	cudaSetDevice(1);
  for(int j = 0; j < STREAMS_IN_GPU; j++) {
    initCount<<<10, 1, 0, streams1[j]>>>(dev_count1[j]);
  }

	//--- Initializing GPU 1
	cudaSetDevice(1);
  for(int j = 0; j < STREAMS_IN_GPU; j++) {
    cudaStreamCreate(&streams1[j]);
    cudaMalloc((void**)&dev_digits1[j], BLOCK_SIZE*sizeof(char));
    cudaMalloc((void**)&dev_count1[j], 10*sizeof(int));
    initCount<<<10, 1, 0, streams1[j]>>>(dev_count1[j]);
  }

	cudaSetDevice(0);
  cudaDeviceSynchronize();
	cudaHostAlloc((void **)&digits0, fileLength*sizeof(char), cudaHostAllocDefault);
	cudaSetDevice(1);
  cudaDeviceSynchronize();
  cudaHostAlloc((void **)&digits1, fileLength*sizeof(char), cudaHostAllocDefault);

  int GPU = 0;
	int i = 0;

  while(i < fileLength) {
    GPU %= 2;
		cudaSetDevice(GPU);
    if(GPU == 0) {
      i = countInGPU(streams0, fileLength, i, digits0, dev_count0, dev_digits0, inputFile, counts0);
    } else {
      i = countInGPU(streams1, fileLength, i, digits1, dev_count1, dev_digits1, inputFile, counts1);
    }
    GPU++;
	}

  cudaSetDevice(0);
	cudaDeviceSynchronize();
	cudaSetDevice(1);
  cudaDeviceSynchronize();


  printf("Devices were synchronized\n");
	fclose(inputFile);
  saveFrequenciesToFile(counts0, counts1, fileLength);

  cudaSetDevice(0);
  for(int i = 0; i < STREAMS_IN_GPU; i++) {
		cudaFreeHost(digits0);
    cudaFree(dev_digits0[i]);
    cudaFree(dev_count0[i]);
    cudaStreamDestroy(streams0[i]);
  }
  cudaFree(digits0);

  cudaSetDevice(1);
	for(int i = 0; i < STREAMS_IN_GPU; i++) {
		cudaFreeHost(digits1);
    cudaFree(dev_digits1[i]);
    cudaFree(dev_count1[i]);
    cudaStreamDestroy(streams1[i]);
  }
  cudaFree(digits1);

	clock_t stop = clock();
  double time = (double)(stop - start) / CLOCKS_PER_SEC;
  printf("Operation time:%f\n", time);

  exit(0);
}

__global__ void initCount (int *count) {
  int index = blockIdx.x;
  count[index]=0;
}

__global__ void countDigits (char *digits, int *count, int maxIndex) {
  int index = blockIdx.x;
	int number = digits[index] - '0'; 
  if(number >= 0 && number < 10 && index < maxIndex){
      atomicAdd(&count[number], 1);
  }
}


	.file	"tmpxft_00205880_00000000-6_Multi-Pi.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2033:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"w"
.LC1:
	.string	"freq.dat"
.LC2:
	.string	"%d, %f\n"
	.text
	.globl	_Z21saveFrequenciesToFilePPiS0_i
	.type	_Z21saveFrequenciesToFilePPiS0_i, @function
_Z21saveFrequenciesToFilePPiS0_i:
.LFB2027:
	.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
	leaq	.LC2(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movl	%edx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rsi, %r12
	leaq	.LC0(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	leaq	.LC1(%rip), %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	xorl	%ebx, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 64
	call	fopen@PLT
	movq	%rax, %r15
.L3:
	movl	%ebx, %edi
	leaq	0(,%rbx,4), %rsi
	xorl	%eax, %eax
	xorl	%edx, %edx
.L4:
	movq	0(%rbp,%rax), %r8
	movq	(%r12,%rax), %rcx
	addq	$8, %rax
	movl	(%rcx,%rsi), %ecx
	addl	(%r8,%rsi), %ecx
	addl	%ecx, %edx
	cmpq	$32, %rax
	jne	.L4
	cvtsi2ssl	%edx, %xmm0
	movl	%edi, %ecx
	movq	%r14, %rdx
	movl	$2, %esi
	cvtsi2ssl	%r13d, %xmm1
	movq	%r15, %rdi
	movb	$1, %al
	incq	%rbx
	divss	%xmm1, %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	__fprintf_chk@PLT
	cmpq	$10, %rbx
	jne	.L3
	popq	%rax
	.cfi_def_cfa_offset 56
	movq	%r15, %rdi
	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
	jmp	fclose@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z21saveFrequenciesToFilePPiS0_i, .-_Z21saveFrequenciesToFilePPiS0_i
	.section	.rodata.str1.1
.LC3:
	.string	"%c"
.LC4:
	.string	"\n"
	.text
	.globl	_Z11printDigitsPci
	.type	_Z11printDigitsPci, @function
_Z11printDigitsPci:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC3(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	xorl	%ebx, %ebx
	pushq	%rcx
	.cfi_def_cfa_offset 48
.L10:
	cmpl	%ebx, %ebp
	jle	.L14
	movsbl	(%r12,%rbx), %edx
	leal	-48(%rdx), %eax
	cmpb	$9, %al
	ja	.L11
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L11:
	incq	%rbx
	jmp	.L10
.L14:
	popq	%rdx
	.cfi_def_cfa_offset 40
	leaq	.LC4(%rip), %rsi
	popq	%rbx
	.cfi_def_cfa_offset 32
	movl	$2, %edi
	popq	%rbp
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	jmp	__printf_chk@PLT
	.cfi_endproc
.LFE2028:
	.size	_Z11printDigitsPci, .-_Z11printDigitsPci
	.globl	_Z28__device_stub__Z9initCountPiPi
	.type	_Z28__device_stub__Z9initCountPiPi, @function
_Z28__device_stub__Z9initCountPiPi:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	44(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L15
	pushq	24(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z9initCountPi(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 128
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L15:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z28__device_stub__Z9initCountPiPi, .-_Z28__device_stub__Z9initCountPiPi
	.globl	_Z9initCountPi
	.type	_Z9initCountPi, @function
_Z9initCountPi:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z28__device_stub__Z9initCountPiPi
	.cfi_endproc
.LFE2056:
	.size	_Z9initCountPi, .-_Z9initCountPi
	.globl	_Z34__device_stub__Z11countDigitsPcPiiPcPii
	.type	_Z34__device_stub__Z11countDigitsPcPiiPcPii, @function
_Z34__device_stub__Z11countDigitsPcPiiPcPii:
.LFB2057:
	.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	.L20
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z11countDigitsPcPii(%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
.L20:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z34__device_stub__Z11countDigitsPcPiiPcPii, .-_Z34__device_stub__Z11countDigitsPcPiiPcPii
	.globl	_Z11countDigitsPcPii
	.type	_Z11countDigitsPcPii, @function
_Z11countDigitsPcPii:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z34__device_stub__Z11countDigitsPcPiiPcPii
	.cfi_endproc
.LFE2058:
	.size	_Z11countDigitsPcPii, .-_Z11countDigitsPcPii
	.globl	_Z10countInGPUPP11CUstream_stiiPcPPiPS2_P8_IO_FILES4_
	.type	_Z10countInGPUPP11CUstream_stiiPcPPiPS2_P8_IO_FILES4_, @function
_Z10countInGPUPP11CUstream_stiiPcPPiPS2_P8_IO_FILES4_:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%esi, %r10d
	movq	%rcx, %r11
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	xorl	%r14d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r9, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r8, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	%edx, %ebx
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	160(%rsp), %rax
	movq	%rax, 8(%rsp)
	movq	168(%rsp), %rax
	movq	%rax, 16(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
.L27:
	leal	32768(%rbx), %eax
	movl	$32768, %r9d
	cmpl	%eax, %r10d
	jge	.L26
	movl	%r10d, %r9d
	subl	%ebx, %r9d
.L26:
	movslq	%ebx, %rax
	movq	8(%rsp), %r8
	movslq	%r9d, %rdx
	orq	$-1, %rsi
	addq	%r11, %rax
	movl	$1, %ecx
	leaq	72(%rsp), %r15
	movl	%r10d, 44(%rsp)
	movq	%rax, %rdi
	movl	%r9d, (%r15,%r14,4)
	movl	%r9d, 40(%rsp)
	movq	%r11, 32(%rsp)
	movq	%rdx, 24(%rsp)
	movq	%rax, (%rsp)
	call	__fread_chk@PLT
	movq	0(%r13,%r14,8), %rdi
	movq	0(%rbp,%r14,8), %r8
	movl	$1, %ecx
	movq	24(%rsp), %rdx
	movq	(%rsp), %rsi
	incq	%r14
	call	cudaMemcpyAsync@PLT
	movl	40(%rsp), %r9d
	movq	32(%rsp), %r11
	movl	44(%rsp), %r10d
	addl	%r9d, %ebx
	cmpq	$4, %r14
	jne	.L27
	xorl	%r14d, %r14d
.L29:
	movl	(%r15,%r14,4), %r11d
	movq	0(%rbp,%r14,8), %r9
	xorl	%r8d, %r8d
	movl	$1, %ecx
	movabsq	$4294967297, %rax
	movl	$1, 68(%rsp)
	movl	%r11d, 48(%rsp)
	movq	%rax, %rdx
	movq	%rax, 52(%rsp)
	movq	48(%rsp), %rdi
	movl	56(%rsp), %esi
	movl	%r11d, (%rsp)
	movq	%rax, 60(%rsp)
	call	__cudaPushCallConfiguration@PLT
	movl	(%rsp), %r11d
	testl	%eax, %eax
	jne	.L28
	movq	(%r12,%r14,8), %rsi
	movq	0(%r13,%r14,8), %rdi
	movl	%r11d, %edx
	call	_Z34__device_stub__Z11countDigitsPcPiiPcPii
.L28:
	incq	%r14
	cmpq	$4, %r14
	jne	.L29
	xorl	%r13d, %r13d
.L30:
	movq	16(%rsp), %rax
	movq	(%r12,%r13), %rsi
	movl	$2, %ecx
	movl	$40, %edx
	movq	0(%rbp,%r13), %r8
	movq	(%rax,%r13), %rdi
	addq	$8, %r13
	call	cudaMemcpyAsync@PLT
	cmpq	$32, %r13
	jne	.L30
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L31
	call	__stack_chk_fail@PLT
.L31:
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	movl	%ebx, %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
.LFE2029:
	.size	_Z10countInGPUPP11CUstream_stiiPcPPiPS2_P8_IO_FILES4_, .-_Z10countInGPUPP11CUstream_stiiPcPPiPS2_P8_IO_FILES4_
	.section	.rodata.str1.1
.LC5:
	.string	"Incorrect number of parameters :(\n"
.LC6:
	.string	"Try: \"./Multi-Pi <filename>\"\n"
.LC7:
	.string	"r"
.LC8:
	.string	"File could not be opened :P\n"
.LC9:
	.string	"Make sure you spelled the name of your file correctly.\n"
.LC10:
	.string	"File length:%d memorySize:%d\n"
.LC11:
	.string	"Devices were synchronized\n"
.LC13:
	.string	"Operation time:%f\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2030:
	.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	$120, %rsp
	.cfi_def_cfa_offset 176
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	cmpl	$2, %edi
	je	.L38
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	leaq	.LC6(%rip), %rsi
	jmp	.L70
.L38:
	movq	8(%rsi), %rdi
	leaq	.LC7(%rip), %rsi
	call	fopen@PLT
	movq	%rax, (%rsp)
	testq	%rax, %rax
	jne	.L39
	movq	stderr(%rip), %rdi
	movl	$2, %esi
	leaq	.LC8(%rip), %rdx
	call	__fprintf_chk@PLT
	leaq	.LC9(%rip), %rsi
.L70:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L71:
	xorl	%edi, %edi
	call	exit@PLT
.L39:
	movq	(%rsp), %rdi
	movl	$2, %edx
	xorl	%esi, %esi
	xorl	%ebp, %ebp
	call	fseek@PLT
	movq	(%rsp), %rdi
	call	ftell@PLT
	movq	(%rsp), %rdi
	xorl	%edx, %edx
	xorl	%esi, %esi
	movq	%rax, 48(%rsp)
	movl	48(%rsp), %eax
	movl	%eax, 12(%rsp)
	call	fseek@PLT
	movl	12(%rsp), %ecx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC10(%rip), %rsi
	movl	%ecx, %edx
	call	__printf_chk@PLT
	movl	$32, %edi
	call	malloc@PLT
	movl	$32, %edi
	movq	%rax, %r13
	call	malloc@PLT
	movl	$32, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	movq	%rax, 24(%rsp)
.L40:
	movl	$40, %edi
	call	malloc@PLT
	movq	24(%rsp), %rcx
	movq	%rax, (%rcx,%rbp,8)
	incq	%rbp
	cmpq	$4, %rbp
	jne	.L40
	movl	$32, %edi
	xorl	%ebp, %ebp
	call	malloc@PLT
	movq	%rax, 32(%rsp)
.L41:
	movl	$40, %edi
	call	malloc@PLT
	movq	32(%rsp), %rcx
	movq	%rax, (%rcx,%rbp,8)
	incq	%rbp
	cmpq	$4, %rbp
	jne	.L41
	movl	$32, %edi
	xorl	%r12d, %r12d
	movabsq	$4294967297, %r15
	call	malloc@PLT
	movl	$32, %edi
	movq	%rax, %r14
	call	malloc@PLT
	movl	$32, %edi
	movq	%rax, %rbp
	call	malloc@PLT
	movl	$32, %edi
	movq	%rax, 40(%rsp)
	call	malloc@PLT
	xorl	%edi, %edi
	movq	%rax, 16(%rsp)
	call	cudaSetDevice@PLT
.L43:
	leaq	0(%r13,%r12), %rdi
	call	cudaStreamCreate@PLT
	movq	40(%rsp), %rax
	movl	$32768, %esi
	leaq	(%rax,%r12), %rdi
	call	cudaMalloc@PLT
	leaq	(%r14,%r12), %rdi
	movl	$40, %esi
	call	cudaMalloc@PLT
	movl	$2147483653, %edi
	xorl	%r8d, %r8d
	movq	%r15, %rdx
	movq	0(%r13,%r12), %r9
	addq	%rdi, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movq	%r15, 88(%rsp)
	movl	$1, 96(%rsp)
	movq	%rdi, 72(%rsp)
	movl	$1, 80(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L42
	movq	(%r14,%r12), %rdi
	call	_Z28__device_stub__Z9initCountPiPi
.L42:
	addq	$8, %r12
	cmpq	$32, %r12
	jne	.L43
	movl	$1, %edi
	xorl	%r12d, %r12d
	movabsq	$4294967297, %r15
	call	cudaSetDevice@PLT
.L45:
	leaq	(%r12,%rbx), %rdi
	call	cudaStreamCreate@PLT
	movq	16(%rsp), %rax
	movl	$32768, %esi
	leaq	(%r12,%rax), %rdi
	call	cudaMalloc@PLT
	leaq	(%r12,%rbp), %rdi
	movl	$40, %esi
	call	cudaMalloc@PLT
	movl	$2147483653, %edi
	xorl	%r8d, %r8d
	movq	%r15, %rdx
	movq	(%rbx,%r12), %r9
	addq	%rdi, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movq	%r15, 88(%rsp)
	movl	$1, 96(%rsp)
	movq	%rdi, 72(%rsp)
	movl	$1, 80(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L44
	movq	0(%rbp,%r12), %rdi
	call	_Z28__device_stub__Z9initCountPiPi
.L44:
	addq	$8, %r12
	cmpq	$32, %r12
	jne	.L45
	call	clock@PLT
	xorl	%edi, %edi
	xorl	%r15d, %r15d
	movabsq	$4294967297, %r12
	movq	%rax, 56(%rsp)
	call	cudaSetDevice@PLT
.L47:
	movl	$2147483653, %edi
	movq	0(%r13,%r15), %r9
	xorl	%r8d, %r8d
	movq	%r12, %rdx
	addq	%rdi, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movq	%r12, 88(%rsp)
	movl	$1, 96(%rsp)
	movq	%rdi, 72(%rsp)
	movl	$1, 80(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L46
	movq	(%r14,%r15), %rdi
	call	_Z28__device_stub__Z9initCountPiPi
.L46:
	addq	$8, %r15
	cmpq	$32, %r15
	jne	.L47
	movl	$1, %edi
	xorl	%r15d, %r15d
	movabsq	$4294967297, %r12
	call	cudaSetDevice@PLT
.L49:
	movl	$2147483653, %edi
	movq	(%rbx,%r15), %r9
	xorl	%r8d, %r8d
	movq	%r12, %rdx
	addq	%rdi, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movq	%r12, 88(%rsp)
	movl	$1, 96(%rsp)
	movq	%rdi, 72(%rsp)
	movl	$1, 80(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L48
	movq	0(%rbp,%r15), %rdi
	call	_Z28__device_stub__Z9initCountPiPi
.L48:
	addq	$8, %r15
	cmpq	$32, %r15
	jne	.L49
	movl	$1, %edi
	xorl	%r12d, %r12d
	movabsq	$4294967297, %r15
	call	cudaSetDevice@PLT
.L51:
	leaq	(%rbx,%r12), %rdi
	call	cudaStreamCreate@PLT
	movq	16(%rsp), %rax
	movl	$32768, %esi
	leaq	(%rax,%r12), %rdi
	call	cudaMalloc@PLT
	leaq	0(%rbp,%r12), %rdi
	movl	$40, %esi
	call	cudaMalloc@PLT
	movl	$2147483653, %edi
	xorl	%r8d, %r8d
	movq	%r15, %rdx
	movq	(%rbx,%r12), %r9
	addq	%rdi, %rdi
	movl	$1, %ecx
	movl	$1, %esi
	movq	%r15, 88(%rsp)
	movl	$1, 96(%rsp)
	movq	%rdi, 72(%rsp)
	movl	$1, 80(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L50
	movq	0(%rbp,%r12), %rdi
	call	_Z28__device_stub__Z9initCountPiPi
.L50:
	addq	$8, %r12
	cmpq	$32, %r12
	jne	.L51
	xorl	%edi, %edi
	call	cudaSetDevice@PLT
	call	cudaDeviceSynchronize@PLT
	movslq	48(%rsp), %r12
	xorl	%edx, %edx
	leaq	72(%rsp), %rdi
	movq	%r12, %rsi
	call	cudaHostAlloc@PLT
	movl	$1, %edi
	call	cudaSetDevice@PLT
	call	cudaDeviceSynchronize@PLT
	xorl	%edx, %edx
	movq	%r12, %rsi
	leaq	88(%rsp), %rdi
	call	cudaHostAlloc@PLT
	xorl	%r12d, %r12d
	xorl	%edx, %edx
.L52:
	movl	12(%rsp), %eax
	cmpl	%eax, %edx
	jge	.L72
	andl	$1, %r12d
	movl	%edx, 48(%rsp)
	movl	%r12d, %edi
	call	cudaSetDevice@PLT
	testl	%r12d, %r12d
	movl	48(%rsp), %edx
	jne	.L53
	pushq	24(%rsp)
	.cfi_remember_state
	.cfi_def_cfa_offset 184
	movq	%r14, %r8
	movq	%r13, %rdi
	pushq	8(%rsp)
	.cfi_def_cfa_offset 192
	movq	56(%rsp), %r9
	movq	88(%rsp), %rcx
	movl	28(%rsp), %esi
	jmp	.L69
.L53:
	.cfi_restore_state
	pushq	32(%rsp)
	.cfi_def_cfa_offset 184
	movq	%rbp, %r8
	movq	%rbx, %rdi
	pushq	8(%rsp)
	.cfi_def_cfa_offset 192
	movq	32(%rsp), %r9
	movq	104(%rsp), %rcx
	movl	28(%rsp), %esi
.L69:
	call	_Z10countInGPUPP11CUstream_stiiPcPPiPS2_P8_IO_FILES4_
	incl	%r12d
	movl	%eax, %edx
	popq	%rax
	.cfi_def_cfa_offset 184
	popq	%rcx
	.cfi_def_cfa_offset 176
	jmp	.L52
.L72:
	xorl	%edi, %edi
	xorl	%r12d, %r12d
	call	cudaSetDevice@PLT
	call	cudaDeviceSynchronize@PLT
	movl	$1, %edi
	call	cudaSetDevice@PLT
	call	cudaDeviceSynchronize@PLT
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	(%rsp), %rdi
	call	fclose@PLT
	movl	12(%rsp), %edx
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdi
	call	_Z21saveFrequenciesToFilePPiS0_i
	xorl	%edi, %edi
	call	cudaSetDevice@PLT
.L56:
	movq	72(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	40(%rsp), %rax
	movq	(%rax,%r12), %rdi
	call	cudaFree@PLT
	movq	(%r14,%r12), %rdi
	call	cudaFree@PLT
	movq	0(%r13,%r12), %rdi
	addq	$8, %r12
	call	cudaStreamDestroy@PLT
	cmpq	$32, %r12
	jne	.L56
	movq	72(%rsp), %rdi
	xorl	%r12d, %r12d
	call	cudaFree@PLT
	movl	$1, %edi
	call	cudaSetDevice@PLT
.L57:
	movq	88(%rsp), %rdi
	call	cudaFreeHost@PLT
	movq	16(%rsp), %rax
	movq	(%rax,%r12), %rdi
	call	cudaFree@PLT
	movq	0(%rbp,%r12), %rdi
	call	cudaFree@PLT
	movq	(%rbx,%r12), %rdi
	addq	$8, %r12
	call	cudaStreamDestroy@PLT
	cmpq	$32, %r12
	jne	.L57
	movq	88(%rsp), %rdi
	call	cudaFree@PLT
	call	clock@PLT
	movq	56(%rsp), %rbx
	movl	$2, %edi
	leaq	.LC13(%rip), %rsi
	subq	%rbx, %rax
	cvtsi2sdq	%rax, %xmm0
	movb	$1, %al
	divsd	.LC12(%rip), %xmm0
	call	__printf_chk@PLT
	jmp	.L71
	.cfi_endproc
.LFE2030:
	.size	main, .-main
	.section	.rodata.str1.1
.LC14:
	.string	"_Z11countDigitsPcPii"
.LC15:
	.string	"_Z9initCountPi"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2060:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -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	.LC14(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z11countDigitsPcPii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC15(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z9initCountPi(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	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	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2060:
	.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
.LC12:
	.long	0
	.long	1093567616
	.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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <time.h>

#define BLOCK_SIZE 32768
#define STREAMS_IN_GPU 4

__global__ void countDigits (char *digits, int *count, int maxIndex);
__global__ void initCount (int *count);

//-------- Save values to dat file --------//
void saveFrequenciesToFile(int** array0, int** array1, int total){
  FILE *filePointer = fopen("freq.dat", "w");
    for(int k = 0; k < 10; k++) {
			int sum = 0;
      for(int i = 0; i < STREAMS_IN_GPU; i++) {
				sum += array0[i][k] + array1[i][k];
      }
			fprintf(filePointer, "%d, %f\n", k, ((float)sum/(float)total));
    }
	fclose(filePointer);
}

void printDigits(char *digits, int size){
	for(int i = 0; i < size; i++){
		if ('0' <= digits[i] && digits[i] <= '9')
			printf("%c", digits[i]);
	}
	printf("\n");
}

//-------- Count method --------//
int countInGPU(hipStream_t* streams, int fileLength, int fileRead, char* digits, int **dev_count, char **dev_digits, FILE *inputFile, int **counts) {
  int sizeToRead[STREAMS_IN_GPU];
  for(int i = 0; i < STREAMS_IN_GPU; i++) {
		sizeToRead[i] = (fileLength - (fileRead + BLOCK_SIZE)) < 0 ? fileLength - fileRead : BLOCK_SIZE;
    fread(&digits[fileRead], sizeToRead[i], 1, inputFile);
    hipMemcpyAsync(dev_digits[i], digits+fileRead, sizeToRead[i]*sizeof(char), hipMemcpyHostToDevice, streams[i]);
    fileRead += sizeToRead[i];
  }
  for(int i = 0; i < STREAMS_IN_GPU; i++) {
    countDigits<<<sizeToRead[i], 1, 0, streams[i]>>>(dev_digits[i], dev_count[i], sizeToRead[i]);
  }
  for(int i = 0; i < STREAMS_IN_GPU; i++) {
    hipMemcpyAsync(counts[i], dev_count[i], 10*sizeof(int), hipMemcpyDeviceToHost, streams[i]);
  }
  return fileRead;
}

//-------- Main --------//
int main(int argc, char **argv) {

  //--- Testing parameters
  if (argc != 2){
      printf("Incorrect number of parameters :(\n");
      printf("Try: \"./Multi-Pi <filename>\"\n");
      exit(0);
  }

//--- Reading file
  FILE *inputFile = fopen(argv[1], "r");

  if (inputFile == NULL) {
    fprintf(stderr, "File could not be opened :P\n");
    printf("Make sure you spelled the name of your file correctly.\n");
    exit(0);
  }

//--- Calculating size of file
  fseek(inputFile, 0, SEEK_END);
  int fileLength = ftell(inputFile);
  fseek(inputFile, 0, SEEK_SET);
	int memorySize = fileLength * sizeof(char);
	printf("File length:%d memorySize:%d\n", fileLength, memorySize);

//--- Declaring CUDA and host variables
	hipStream_t* streams0 = (hipStream_t*) malloc(STREAMS_IN_GPU*sizeof(hipStream_t));
  hipStream_t* streams1 = (hipStream_t*) malloc(STREAMS_IN_GPU*sizeof(hipStream_t));
  int **counts0 = (int**) malloc(STREAMS_IN_GPU*sizeof(int*));
	for(int i = 0; i < STREAMS_IN_GPU; i++) {
    counts0[i] = (int*) malloc(sizeof(int)*10);
	}
  int **counts1 = (int**) malloc(STREAMS_IN_GPU*sizeof(int*));
	for(int i = 0; i < STREAMS_IN_GPU; i++) {
    counts1[i] = (int*) malloc(sizeof(int)*10);
	}
  int **dev_count0 = (int **)malloc(STREAMS_IN_GPU*sizeof(int*));
  int **dev_count1 = (int **)malloc(STREAMS_IN_GPU*sizeof(int*));
	char **dev_digits0 = (char **)malloc(STREAMS_IN_GPU*sizeof(char*));
  char **dev_digits1 = (char **)malloc(STREAMS_IN_GPU*sizeof(char*));
	char *digits0, *digits1;
	
	//--- Initializing GPU 0
	hipSetDevice(0);
  for(int j = 0; j < STREAMS_IN_GPU; j++) {
    hipStreamCreate(&streams0[j]);
    hipMalloc((void**)&dev_digits0[j], BLOCK_SIZE*sizeof(char));
    hipMalloc((void**)&dev_count0[j], 10*sizeof(int));
    initCount<<<10, 1, 0, streams0[j]>>>(dev_count0[j]);
  }

	//--- Initializing GPU 1
	hipSetDevice(1);
  for(int j = 0; j < STREAMS_IN_GPU; j++) {
    hipStreamCreate(&streams1[j]);
    hipMalloc((void**)&dev_digits1[j], BLOCK_SIZE*sizeof(char));
    hipMalloc((void**)&dev_count1[j], 10*sizeof(int));
    initCount<<<10, 1, 0, streams1[j]>>>(dev_count1[j]);
  }

	//--- Executing CUDA code
  clock_t start = clock();

	hipSetDevice(0);
  for(int j = 0; j < STREAMS_IN_GPU; j++) {
    initCount<<<10, 1, 0, streams0[j]>>>(dev_count0[j]);
  }
	hipSetDevice(1);
  for(int j = 0; j < STREAMS_IN_GPU; j++) {
    initCount<<<10, 1, 0, streams1[j]>>>(dev_count1[j]);
  }

	//--- Initializing GPU 1
	hipSetDevice(1);
  for(int j = 0; j < STREAMS_IN_GPU; j++) {
    hipStreamCreate(&streams1[j]);
    hipMalloc((void**)&dev_digits1[j], BLOCK_SIZE*sizeof(char));
    hipMalloc((void**)&dev_count1[j], 10*sizeof(int));
    initCount<<<10, 1, 0, streams1[j]>>>(dev_count1[j]);
  }

	hipSetDevice(0);
  hipDeviceSynchronize();
	hipHostAlloc((void **)&digits0, fileLength*sizeof(char), hipHostMallocDefault);
	hipSetDevice(1);
  hipDeviceSynchronize();
  hipHostAlloc((void **)&digits1, fileLength*sizeof(char), hipHostMallocDefault);

  int GPU = 0;
	int i = 0;

  while(i < fileLength) {
    GPU %= 2;
		hipSetDevice(GPU);
    if(GPU == 0) {
      i = countInGPU(streams0, fileLength, i, digits0, dev_count0, dev_digits0, inputFile, counts0);
    } else {
      i = countInGPU(streams1, fileLength, i, digits1, dev_count1, dev_digits1, inputFile, counts1);
    }
    GPU++;
	}

  hipSetDevice(0);
	hipDeviceSynchronize();
	hipSetDevice(1);
  hipDeviceSynchronize();


  printf("Devices were synchronized\n");
	fclose(inputFile);
  saveFrequenciesToFile(counts0, counts1, fileLength);

  hipSetDevice(0);
  for(int i = 0; i < STREAMS_IN_GPU; i++) {
		hipHostFree(digits0);
    hipFree(dev_digits0[i]);
    hipFree(dev_count0[i]);
    hipStreamDestroy(streams0[i]);
  }
  hipFree(digits0);

  hipSetDevice(1);
	for(int i = 0; i < STREAMS_IN_GPU; i++) {
		hipHostFree(digits1);
    hipFree(dev_digits1[i]);
    hipFree(dev_count1[i]);
    hipStreamDestroy(streams1[i]);
  }
  hipFree(digits1);

	clock_t stop = clock();
  double time = (double)(stop - start) / CLOCKS_PER_SEC;
  printf("Operation time:%f\n", time);

  exit(0);
}

__global__ void initCount (int *count) {
  int index = blockIdx.x;
  count[index]=0;
}

__global__ void countDigits (char *digits, int *count, int maxIndex) {
  int index = blockIdx.x;
	int number = digits[index] - '0'; 
  if(number >= 0 && number < 10 && index < maxIndex){
      atomicAdd(&count[number], 1);
  }
}


	.text
	.file	"Multi-Pi.hip"
	.globl	_Z21saveFrequenciesToFilePPiS0_i # -- Begin function _Z21saveFrequenciesToFilePPiS0_i
	.type	_Z21saveFrequenciesToFilePPiS0_i,@function
_Z21saveFrequenciesToFilePPiS0_i:       # @_Z21saveFrequenciesToFilePPiS0_i
	.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	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edx, %ebp
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, %r15
	cvtsi2ss	%ebp, %xmm0
	movss	%xmm0, 12(%rsp)                 # 4-byte Spill
	xorl	%r12d, %r12d
.LBB0_1:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_2 Depth 2
	xorl	%ecx, %ecx
	xorl	%eax, %eax
.LBB0_2:                                #   Parent Loop BB0_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%r14,%rcx,8), %rdx
	movq	(%rbx,%rcx,8), %rsi
	addl	(%rdx,%r12,4), %eax
	addl	(%rsi,%r12,4), %eax
	incq	%rcx
	cmpq	$4, %rcx
	jne	.LBB0_2
# %bb.3:                                #   in Loop: Header=BB0_1 Depth=1
	xorps	%xmm0, %xmm0
	cvtsi2ss	%eax, %xmm0
	divss	12(%rsp), %xmm0                 # 4-byte Folded Reload
	cvtss2sd	%xmm0, %xmm0
	movl	$.L.str.2, %esi
	movq	%r15, %rdi
	movl	%r12d, %edx
	movb	$1, %al
	callq	fprintf
	incq	%r12
	cmpq	$10, %r12
	jne	.LBB0_1
# %bb.4:
	movq	%r15, %rdi
	addq	$16, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.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
	jmp	fclose                          # TAILCALL
.Lfunc_end0:
	.size	_Z21saveFrequenciesToFilePPiS0_i, .Lfunc_end0-_Z21saveFrequenciesToFilePPiS0_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z11printDigitsPci              # -- Begin function _Z11printDigitsPci
	.type	_Z11printDigitsPci,@function
_Z11printDigitsPci:                     # @_Z11printDigitsPci
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB1_6
# %bb.1:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdi, %rbx
	movl	%esi, %r14d
	xorl	%r15d, %r15d
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movzbl	(%rbx,%r15), %edi
	leal	-48(%rdi), %eax
	cmpb	$9, %al
	ja	.LBB1_4
# %bb.3:                                #   in Loop: Header=BB1_2 Depth=1
                                        # kill: def $edi killed $edi killed $rdi
	callq	putchar@PLT
.LBB1_4:                                #   in Loop: Header=BB1_2 Depth=1
	incq	%r15
	cmpq	%r15, %r14
	jne	.LBB1_2
# %bb.5:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB1_6:                                # %._crit_edge
	movl	$10, %edi
	jmp	putchar@PLT                     # TAILCALL
.Lfunc_end1:
	.size	_Z11printDigitsPci, .Lfunc_end1-_Z11printDigitsPci
	.cfi_endproc
                                        # -- End function
	.globl	_Z10countInGPUPP12ihipStream_tiiPcPPiPS2_P8_IO_FILES4_ # -- Begin function _Z10countInGPUPP12ihipStream_tiiPcPPiPS2_P8_IO_FILES4_
	.type	_Z10countInGPUPP12ihipStream_tiiPcPPiPS2_P8_IO_FILES4_,@function
_Z10countInGPUPP12ihipStream_tiiPcPPiPS2_P8_IO_FILES4_: # @_Z10countInGPUPP12ihipStream_tiiPcPPiPS2_P8_IO_FILES4_
	.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	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%r9, 16(%rsp)                   # 8-byte Spill
	movq	%r8, 8(%rsp)                    # 8-byte Spill
	movq	%rcx, 24(%rsp)                  # 8-byte Spill
	movl	%edx, %r14d
	movl	%esi, %ebp
	movq	%rdi, %r15
	xorl	%r12d, %r12d
.LBB2_1:                                # =>This Inner Loop Header: Depth=1
	movl	$32768, %edx                    # imm = 0x8000
	leal	(%r14,%rdx), %eax
	movl	%ebp, %ecx
	subl	%r14d, %ecx
	cmpl	%ebp, %eax
	cmovlel	%edx, %ecx
	movl	%ecx, 32(%rsp,%r12,4)
	movslq	%r14d, %r13
	movq	24(%rsp), %rax                  # 8-byte Reload
	leaq	(%rax,%r13), %rbx
	movslq	%ecx, %r14
	movl	$1, %edx
	movq	%rbx, %rdi
	movq	%r14, %rsi
	movq	112(%rsp), %rcx
	callq	fread
	movq	16(%rsp), %rax                  # 8-byte Reload
	movq	(%rax,%r12,8), %rdi
	movq	(%r15,%r12,8), %r8
	movq	%rbx, %rsi
	movq	%r14, %rdx
	movl	$1, %ecx
	callq	hipMemcpyAsync
	addl	%r13d, %r14d
	incq	%r12
	cmpq	$4, %r12
	jne	.LBB2_1
# %bb.2:                                # %.preheader46.preheader
	movabsq	$4294967296, %rbx               # imm = 0x100000000
	xorl	%r12d, %r12d
	leaq	1(%rbx), %r13
.LBB2_3:                                # %.preheader46
                                        # =>This Inner Loop Header: Depth=1
	movl	32(%rsp,%r12,4), %ebp
	movq	(%r15,%r12,8), %r9
	movq	%rbp, %rdi
	orq	%rbx, %rdi
	movl	$1, %esi
	movq	%r13, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB2_5
# %bb.4:                                #   in Loop: Header=BB2_3 Depth=1
	movq	16(%rsp), %rax                  # 8-byte Reload
	movq	(%rax,%r12,8), %rdi
	movq	8(%rsp), %rax                   # 8-byte Reload
	movq	(%rax,%r12,8), %rsi
	movl	%ebp, %edx
	callq	_Z26__device_stub__countDigitsPcPii
.LBB2_5:                                #   in Loop: Header=BB2_3 Depth=1
	incq	%r12
	cmpq	$4, %r12
	jne	.LBB2_3
# %bb.6:                                # %.preheader.preheader
	xorl	%ebx, %ebx
	movq	8(%rsp), %r12                   # 8-byte Reload
	movq	120(%rsp), %r13
.LBB2_7:                                # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movq	(%r13,%rbx,8), %rdi
	movq	(%r12,%rbx,8), %rsi
	movq	(%r15,%rbx,8), %r8
	movl	$40, %edx
	movl	$2, %ecx
	callq	hipMemcpyAsync
	incq	%rbx
	cmpq	$4, %rbx
	jne	.LBB2_7
# %bb.8:
	movl	%r14d, %eax
	addq	$56, %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
.Lfunc_end2:
	.size	_Z10countInGPUPP12ihipStream_tiiPcPPiPS2_P8_IO_FILES4_, .Lfunc_end2-_Z10countInGPUPP12ihipStream_tiiPcPPiPS2_P8_IO_FILES4_
	.cfi_endproc
                                        # -- End function
	.globl	_Z26__device_stub__countDigitsPcPii # -- Begin function _Z26__device_stub__countDigitsPcPii
	.type	_Z26__device_stub__countDigitsPcPii,@function
_Z26__device_stub__countDigitsPcPii:    # @_Z26__device_stub__countDigitsPcPii
	.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	$_Z11countDigitsPcPii, %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_end3:
	.size	_Z26__device_stub__countDigitsPcPii, .Lfunc_end3-_Z26__device_stub__countDigitsPcPii
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI4_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.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	$104, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$2, %edi
	jne	.LBB4_3
# %bb.1:
	movq	8(%rsi), %rdi
	movl	$.L.str.7, %esi
	callq	fopen
	testq	%rax, %rax
	jne	.LBB4_6
# %bb.2:
	movq	stderr(%rip), %rcx
	movl	$.L.str.8, %edi
	movl	$28, %esi
	movl	$1, %edx
	callq	fwrite@PLT
	movl	$.Lstr.1, %edi
	jmp	.LBB4_4
.LBB4_3:
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	$.Lstr.3, %edi
.LBB4_4:
	callq	puts@PLT
	jmp	.LBB4_5
.LBB4_6:
	movq	%rax, %r12
	xorl	%r15d, %r15d
	movq	%rax, %rdi
	xorl	%esi, %esi
	movl	$2, %edx
	callq	fseek
	movq	%r12, %rdi
	callq	ftell
	movq	%rax, %r13
	movq	%r12, %rdi
	xorl	%esi, %esi
	xorl	%edx, %edx
	callq	fseek
	movq	%r13, %rax
	shlq	$32, %rax
	movq	%rax, 96(%rsp)                  # 8-byte Spill
	movl	$.L.str.10, %edi
	movl	%r13d, %esi
	movl	%r13d, %edx
	xorl	%eax, %eax
	callq	printf
	movl	$32, %edi
	callq	malloc
	movq	%rax, %r14
	movl	$32, %edi
	callq	malloc
	movq	%rax, %rbx
	movl	$32, %edi
	callq	malloc
	movq	%rax, %rbp
.LBB4_7:                                # =>This Inner Loop Header: Depth=1
	movl	$40, %edi
	callq	malloc
	movq	%rax, (%rbp,%r15,8)
	incq	%r15
	cmpq	$4, %r15
	jne	.LBB4_7
# %bb.8:
	movq	%rbp, 80(%rsp)                  # 8-byte Spill
	movq	%r13, 16(%rsp)                  # 8-byte Spill
	movq	%r12, 40(%rsp)                  # 8-byte Spill
	movl	$32, %edi
	callq	malloc
	movq	%rax, %r12
	xorl	%r15d, %r15d
.LBB4_9:                                # =>This Inner Loop Header: Depth=1
	movl	$40, %edi
	callq	malloc
	movq	%rax, (%r12,%r15,8)
	incq	%r15
	cmpq	$4, %r15
	jne	.LBB4_9
# %bb.10:
	movq	%r12, 72(%rsp)                  # 8-byte Spill
	movabsq	$4294967297, %r15               # imm = 0x100000001
	movl	$32, %edi
	callq	malloc
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	movl	$32, %edi
	callq	malloc
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	movl	$32, %edi
	callq	malloc
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	movl	$32, %edi
	callq	malloc
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	xorl	%r13d, %r13d
	xorl	%edi, %edi
	callq	hipSetDevice
	leaq	9(%r15), %r12
.LBB4_11:                               # =>This Inner Loop Header: Depth=1
	leaq	(%r14,%r13), %rdi
	callq	hipStreamCreate
	movq	48(%rsp), %rax                  # 8-byte Reload
	leaq	(%rax,%r13), %rdi
	movl	$32768, %esi                    # imm = 0x8000
	callq	hipMalloc
	movq	24(%rsp), %rax                  # 8-byte Reload
	leaq	(%rax,%r13), %rbp
	movl	$40, %esi
	movq	%rbp, %rdi
	callq	hipMalloc
	movq	(%r14,%r13), %r9
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_13
# %bb.12:                               #   in Loop: Header=BB4_11 Depth=1
	movq	(%rbp), %rdi
	callq	_Z24__device_stub__initCountPi
.LBB4_13:                               #   in Loop: Header=BB4_11 Depth=1
	addq	$8, %r13
	cmpq	$32, %r13
	jne	.LBB4_11
# %bb.14:
	movl	$1, %edi
	callq	hipSetDevice
	xorl	%r13d, %r13d
.LBB4_15:                               # =>This Inner Loop Header: Depth=1
	leaq	(%rbx,%r13), %rdi
	callq	hipStreamCreate
	movq	32(%rsp), %rax                  # 8-byte Reload
	leaq	(%rax,%r13), %rdi
	movl	$32768, %esi                    # imm = 0x8000
	callq	hipMalloc
	movq	8(%rsp), %rax                   # 8-byte Reload
	leaq	(%rax,%r13), %rbp
	movl	$40, %esi
	movq	%rbp, %rdi
	callq	hipMalloc
	movq	(%rbx,%r13), %r9
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_17
# %bb.16:                               #   in Loop: Header=BB4_15 Depth=1
	movq	(%rbp), %rdi
	callq	_Z24__device_stub__initCountPi
.LBB4_17:                               #   in Loop: Header=BB4_15 Depth=1
	addq	$8, %r13
	cmpq	$32, %r13
	jne	.LBB4_15
# %bb.18:
	callq	clock
	movq	%rax, 88(%rsp)                  # 8-byte Spill
	xorl	%r13d, %r13d
	xorl	%edi, %edi
	callq	hipSetDevice
	movq	8(%rsp), %rbp                   # 8-byte Reload
.LBB4_19:                               # =>This Inner Loop Header: Depth=1
	movq	(%r14,%r13,8), %r9
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_21
# %bb.20:                               #   in Loop: Header=BB4_19 Depth=1
	movq	24(%rsp), %rax                  # 8-byte Reload
	movq	(%rax,%r13,8), %rdi
	callq	_Z24__device_stub__initCountPi
.LBB4_21:                               #   in Loop: Header=BB4_19 Depth=1
	incq	%r13
	cmpq	$4, %r13
	jne	.LBB4_19
# %bb.22:
	movl	$1, %edi
	callq	hipSetDevice
	xorl	%r13d, %r13d
.LBB4_23:                               # =>This Inner Loop Header: Depth=1
	movq	(%rbx,%r13,8), %r9
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_25
# %bb.24:                               #   in Loop: Header=BB4_23 Depth=1
	movq	(%rbp,%r13,8), %rdi
	callq	_Z24__device_stub__initCountPi
.LBB4_25:                               #   in Loop: Header=BB4_23 Depth=1
	incq	%r13
	cmpq	$4, %r13
	jne	.LBB4_23
# %bb.26:
	movl	$1, %edi
	callq	hipSetDevice
	xorl	%r13d, %r13d
.LBB4_27:                               # =>This Inner Loop Header: Depth=1
	leaq	(%rbx,%r13), %rdi
	callq	hipStreamCreate
	movq	32(%rsp), %rax                  # 8-byte Reload
	leaq	(%rax,%r13), %rdi
	movl	$32768, %esi                    # imm = 0x8000
	callq	hipMalloc
	movq	8(%rsp), %rax                   # 8-byte Reload
	leaq	(%rax,%r13), %rbp
	movl	$40, %esi
	movq	%rbp, %rdi
	callq	hipMalloc
	movq	(%rbx,%r13), %r9
	movq	%r12, %rdi
	movl	$1, %esi
	movq	%r15, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_29
# %bb.28:                               #   in Loop: Header=BB4_27 Depth=1
	movq	(%rbp), %rdi
	callq	_Z24__device_stub__initCountPi
.LBB4_29:                               #   in Loop: Header=BB4_27 Depth=1
	addq	$8, %r13
	cmpq	$32, %r13
	jne	.LBB4_27
# %bb.30:
	movq	96(%rsp), %r12                  # 8-byte Reload
	sarq	$32, %r12
	xorl	%r15d, %r15d
	xorl	%edi, %edi
	callq	hipSetDevice
	callq	hipDeviceSynchronize
	leaq	64(%rsp), %rdi
	movq	%r12, %rsi
	xorl	%edx, %edx
	callq	hipHostAlloc
	movl	$1, %edi
	callq	hipSetDevice
	callq	hipDeviceSynchronize
	leaq	56(%rsp), %rdi
	movq	%r12, %rsi
	xorl	%edx, %edx
	callq	hipHostAlloc
	cmpl	$0, 16(%rsp)                    # 4-byte Folded Reload
	jle	.LBB4_36
# %bb.31:                               # %.lr.ph.preheader
	xorl	%ebp, %ebp
	movl	%ebp, %r12d
.LBB4_32:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	andl	$1, %r12d
	movl	%r12d, %edi
	callq	hipSetDevice
	testb	$1, %bpl
	jne	.LBB4_34
# %bb.33:                               #   in Loop: Header=BB4_32 Depth=1
	movq	64(%rsp), %rcx
	movq	%r14, %rdi
	movq	16(%rsp), %r13                  # 8-byte Reload
	movl	%r13d, %esi
	movl	%r15d, %edx
	movq	24(%rsp), %r8                   # 8-byte Reload
	movq	48(%rsp), %r9                   # 8-byte Reload
	pushq	80(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	jmp	.LBB4_35
.LBB4_34:                               #   in Loop: Header=BB4_32 Depth=1
	.cfi_def_cfa_offset 160
	movq	56(%rsp), %rcx
	movq	%rbx, %rdi
	movq	16(%rsp), %r13                  # 8-byte Reload
	movl	%r13d, %esi
	movl	%r15d, %edx
	movq	8(%rsp), %r8                    # 8-byte Reload
	movq	32(%rsp), %r9                   # 8-byte Reload
	pushq	72(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
.LBB4_35:                               #   in Loop: Header=BB4_32 Depth=1
	pushq	48(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	callq	_Z10countInGPUPP12ihipStream_tiiPcPPiPS2_P8_IO_FILES4_
	addq	$16, %rsp
	.cfi_adjust_cfa_offset -16
	movl	%eax, %r15d
	incl	%r12d
	movl	%r12d, %ebp
	cmpl	%r13d, %eax
	jl	.LBB4_32
.LBB4_36:                               # %._crit_edge
	xorl	%r15d, %r15d
	xorl	%edi, %edi
	callq	hipSetDevice
	callq	hipDeviceSynchronize
	movl	$1, %edi
	callq	hipSetDevice
	callq	hipDeviceSynchronize
	movl	$.Lstr, %edi
	callq	puts@PLT
	movq	40(%rsp), %rdi                  # 8-byte Reload
	callq	fclose
	movq	80(%rsp), %rdi                  # 8-byte Reload
	movq	72(%rsp), %rsi                  # 8-byte Reload
	movq	16(%rsp), %rdx                  # 8-byte Reload
                                        # kill: def $edx killed $edx killed $rdx
	callq	_Z21saveFrequenciesToFilePPiS0_i
	xorl	%edi, %edi
	callq	hipSetDevice
	movq	24(%rsp), %r12                  # 8-byte Reload
	movq	48(%rsp), %r13                  # 8-byte Reload
.LBB4_37:                               # =>This Inner Loop Header: Depth=1
	movq	64(%rsp), %rdi
	callq	hipHostFree
	movq	(%r13,%r15,8), %rdi
	callq	hipFree
	movq	(%r12,%r15,8), %rdi
	callq	hipFree
	movq	(%r14,%r15,8), %rdi
	callq	hipStreamDestroy
	incq	%r15
	cmpq	$4, %r15
	jne	.LBB4_37
# %bb.38:
	movq	64(%rsp), %rdi
	callq	hipFree
	movl	$1, %edi
	callq	hipSetDevice
	xorl	%r14d, %r14d
	movq	8(%rsp), %r15                   # 8-byte Reload
	movq	32(%rsp), %r12                  # 8-byte Reload
.LBB4_39:                               # =>This Inner Loop Header: Depth=1
	movq	56(%rsp), %rdi
	callq	hipHostFree
	movq	(%r12,%r14,8), %rdi
	callq	hipFree
	movq	(%r15,%r14,8), %rdi
	callq	hipFree
	movq	(%rbx,%r14,8), %rdi
	callq	hipStreamDestroy
	incq	%r14
	cmpq	$4, %r14
	jne	.LBB4_39
# %bb.40:
	movq	56(%rsp), %rdi
	callq	hipFree
	callq	clock
	subq	88(%rsp), %rax                  # 8-byte Folded Reload
	cvtsi2sd	%rax, %xmm0
	divsd	.LCPI4_0(%rip), %xmm0
	movl	$.L.str.12, %edi
	movb	$1, %al
	callq	printf
.LBB4_5:
	xorl	%edi, %edi
	callq	exit
.Lfunc_end4:
	.size	main, .Lfunc_end4-main
	.cfi_endproc
                                        # -- End function
	.globl	_Z24__device_stub__initCountPi  # -- Begin function _Z24__device_stub__initCountPi
	.type	_Z24__device_stub__initCountPi,@function
_Z24__device_stub__initCountPi:         # @_Z24__device_stub__initCountPi
	.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	$64, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	movq	%rsp, %rbx
	movq	%rax, (%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%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	$_Z9initCountPi, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$80, %rsp
	.cfi_adjust_cfa_offset -80
	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_end5:
	.size	_Z24__device_stub__initCountPi, .Lfunc_end5-_Z24__device_stub__initCountPi
	.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:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -16
	movq	__hip_gpubin_handle(%rip), %rbx
	testq	%rbx, %rbx
	jne	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z9initCountPi, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z11countDigitsPcPii, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__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	.LBB7_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
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"freq.dat"
	.size	.L.str, 9

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

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

	.type	_Z11countDigitsPcPii,@object    # @_Z11countDigitsPcPii
	.section	.rodata,"a",@progbits
	.globl	_Z11countDigitsPcPii
	.p2align	3, 0x0
_Z11countDigitsPcPii:
	.quad	_Z26__device_stub__countDigitsPcPii
	.size	_Z11countDigitsPcPii, 8

	.type	.L.str.7,@object                # @.str.7
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.7:
	.asciz	"r"
	.size	.L.str.7, 2

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"File could not be opened :P\n"
	.size	.L.str.8, 29

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"File length:%d memorySize:%d\n"
	.size	.L.str.10, 30

	.type	_Z9initCountPi,@object          # @_Z9initCountPi
	.section	.rodata,"a",@progbits
	.globl	_Z9initCountPi
	.p2align	3, 0x0
_Z9initCountPi:
	.quad	_Z24__device_stub__initCountPi
	.size	_Z9initCountPi, 8

	.type	.L.str.12,@object               # @.str.12
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.12:
	.asciz	"Operation time:%f\n"
	.size	.L.str.12, 19

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z9initCountPi"
	.size	.L__unnamed_1, 15

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z11countDigitsPcPii"
	.size	.L__unnamed_2, 21

	.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	"Devices were synchronized"
	.size	.Lstr, 26

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Make sure you spelled the name of your file correctly."
	.size	.Lstr.1, 55

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Incorrect number of parameters :("
	.size	.Lstr.2, 34

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"Try: \"./Multi-Pi <filename>\""
	.size	.Lstr.3, 29

	.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 _Z26__device_stub__countDigitsPcPii
	.addrsig_sym _Z24__device_stub__initCountPi
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z11countDigitsPcPii
	.addrsig_sym _Z9initCountPi
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z9initCountPi          ; -- Begin function _Z9initCountPi
	.globl	_Z9initCountPi
	.p2align	8
	.type	_Z9initCountPi,@function
_Z9initCountPi:                         ; @_Z9initCountPi
; %bb.0:
	s_load_b64 s[0:1], s[0:1], 0x0
	s_mov_b32 s2, s15
	s_ashr_i32 s3, s15, 31
	v_mov_b32_e32 v0, 0
	s_lshl_b64 s[2:3], s[2:3], 2
	s_waitcnt lgkmcnt(0)
	s_add_u32 s0, s0, s2
	s_addc_u32 s1, s1, s3
	global_store_b32 v0, v0, s[0:1]
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z9initCountPi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 8
		.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 1
		.amdhsa_next_free_sgpr 16
		.amdhsa_reserve_vcc 0
		.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	_Z9initCountPi, .Lfunc_end0-_Z9initCountPi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 56
; NumSgprs: 16
; NumVgprs: 1
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 16
; NumVGPRsForWavesPerEU: 1
; 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
	.protected	_Z11countDigitsPcPii    ; -- Begin function _Z11countDigitsPcPii
	.globl	_Z11countDigitsPcPii
	.p2align	8
	.type	_Z11countDigitsPcPii,@function
_Z11countDigitsPcPii:                   ; @_Z11countDigitsPcPii
; %bb.0:
	s_clause 0x1
	s_load_b128 s[4:7], s[0:1], 0x0
	s_load_b32 s2, s[0:1], 0x10
	v_mov_b32_e32 v0, 0
	s_ashr_i32 s1, s15, 31
	s_waitcnt lgkmcnt(0)
	s_add_u32 s0, s4, s15
	s_addc_u32 s1, s5, s1
	s_cmp_ge_i32 s15, s2
	global_load_u8 v0, v0, s[0:1]
	s_cselect_b32 s0, -1, 0
	s_waitcnt vmcnt(0)
	v_sub_nc_u16 v1, v0, 48
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_and_b32_e32 v1, 0xff, v1
	v_cmp_lt_u16_e32 vcc_lo, 9, v1
	s_or_b32 s1, s0, vcc_lo
	v_readfirstlane_b32 s0, v0
	s_and_b32 vcc_lo, exec_lo, s1
	s_cbranch_vccnz .LBB1_3
; %bb.1:
	s_mov_b32 s2, exec_lo
	s_mov_b32 s1, 0
	v_mbcnt_lo_u32_b32 v0, s2, 0
	s_mov_b32 s3, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_eq_u32_e32 0, v0
	s_cbranch_execz .LBB1_3
; %bb.2:
	s_and_b32 s0, s0, 0xff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_sub_i32 s0, s0, 48
	s_lshl_b64 s[0:1], s[0:1], 2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	s_add_u32 s0, s6, s0
	s_addc_u32 s1, s7, s1
	s_bcnt1_i32_b32 s2, s2
	v_dual_mov_b32 v0, 0 :: v_dual_mov_b32 v1, s2
	global_atomic_add_u32 v0, v1, s[0:1]
.LBB1_3:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z11countDigitsPcPii
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 20
		.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 2
		.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_end1:
	.size	_Z11countDigitsPcPii, .Lfunc_end1-_Z11countDigitsPcPii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 196
; NumSgprs: 18
; NumVgprs: 2
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 2
; Occupancy: 16
; WaveLimiterHint : 1
; 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
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 8
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z9initCountPi
    .private_segment_fixed_size: 0
    .sgpr_count:     16
    .sgpr_spill_count: 0
    .symbol:         _Z9initCountPi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     1
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .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
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 20
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z11countDigitsPcPii
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z11countDigitsPcPii.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     2
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
