// Given a list (lst) of length n
// Output its sum = lst[0] + lst[1] + ... + lst[n-1];
#include<stdio.h>
#include "cuda.h"
#include<string.h>
#include<stdlib.h>

#define BLOCK_SIZE 512

char *inputFile,*outputFile;
void _errorCheck(cudaError_t e) {
    if(e != cudaSuccess) {
        printf("Failed to run statement \n");
    }
}

// ==================================================================
__global__ void total_sequential(float *input, float *output, int len) {
    if (threadIdx.x == 0) {
        int i;
        int sum = 0;
        int block = blockIdx.x;

        int elems = (len + gridDim.x - 1) / gridDim.x;
        int start = block * elems;
        int stop = min(start + elems, len);

        // One thread computes sum
        for (i = start; i < stop; i++) {
            sum += input[i];
        }
        output[block] = sum;
    }
}

__global__ void total_sequential_coalesced(float *input, float *output, int len) {
    if (threadIdx.x == 0) {
        int i;
        int sum = 0;

        int start = blockIdx.x;
        int step = gridDim.x;

        // One thread computes sum
        for (i = start; i < len; i += step) {
            sum += input[i];
        }
        output[start] = sum;
    }
}

__global__ void total_atomic(float *input, float *output, int len) {
    int i;
    int block = blockIdx.x;
    int thread = threadIdx.x;

    int elems = (len + gridDim.x - 1) / gridDim.x;
    int start = block * elems;
    int stop = min(start + elems, len);

    // Thread computes adjacent elements
    int elems_per_thread = (elems + BLOCK_SIZE - 1) / BLOCK_SIZE;
    start = start + thread * elems_per_thread;
    stop = min(stop, start + elems_per_thread);

    for (i = start; i < stop; i++) {
        // Every thread atomically updates the sum
        atomicAdd(output + block, input[i]);
    }
}

__global__ void total_atomic_coalesced(float *input, float *output, int len) {
    int i;
    int block = blockIdx.x;
    int thread = threadIdx.x;

    int start = block * BLOCK_SIZE + thread;
    int step = gridDim.x * BLOCK_SIZE;

    for (i = start; i < len; i+= step) {
        // Every thread atomically updates the sum
        atomicAdd(output + block, input[i]);
    }
}

__global__ void total_partial_reduction(float *input, float *output, int len) {
    __shared__ float shared[BLOCK_SIZE];

    int i;
    int block = blockIdx.x;
    int thread = threadIdx.x;

    int start = block * BLOCK_SIZE + thread;
    int step = gridDim.x * BLOCK_SIZE;

    // Each thread computes a sum in shared memory
    shared[thread] = 0;
    for (i = start; i < len; i += step) {
        shared[thread] += input[i];
    }
    __syncthreads();

    // Compute sum for blocks on thread 0
    if (thread == 0) {
        int sum = 0;
        for (i = 0; i < BLOCK_SIZE; i++) {
            sum += shared[i];
        }
        output[block] = sum;
    }
}

__global__ void total_reduction(float *input, float *output, int len) {
    __shared__ float shared[BLOCK_SIZE];

    int i;
    int block = blockIdx.x;
    int thread = threadIdx.x;

    int start = block * 2 * BLOCK_SIZE + thread;
    int step = gridDim.x * 2 * BLOCK_SIZE;

    // Many elements per thread
    shared[thread] = 0;
    for (i = start; i < len; i += step) {
        shared[thread] += input[i] + input[i + BLOCK_SIZE];
    }
    __syncthreads();

    // Recursively reduce down to 1 element
    for (i = BLOCK_SIZE >> 1; i > 0; i >>= 1) {
        if (thread < i) {
            shared[thread] += shared[thread + i];
        }
        __syncthreads();
    }

    if (thread == 0) {
        output[block] = shared[0];
    }
}
// ==================================================================

void parseInput(int argc, char **argv) {
    if(argc < 2) {
        printf("Not enough arguments\n");
        printf("Usage: reduction -i inputFile -o outputFile\n");
        exit(1);
    }
    int i=1;
    while(i<argc) {
        if(!strcmp(argv[i],"-i")) {
            ++i;
            inputFile = argv[i];
        } else if(!strcmp(argv[i],"-o")) {
            ++i;
            outputFile = argv[i];
        } else {
            printf("Wrong input");
            exit(1);
        }
        i++;
    }
}
void getSize(int &size, char *file) {
    FILE *fp;
    fp = fopen(file,"r");
    if(fp == NULL) {
        perror("Error opening File\n");
        exit(1);
    }

    if(fscanf(fp,"%d",&size)==EOF) {
        printf("Error reading file\n");
        exit(1);
    }
    fclose(fp);
}
void readFromFile(int &size,float *v, char *file) {
    FILE *fp;
    fp = fopen(file,"r");
    if(fp == NULL) {
        printf("Error opening File %s\n",file);
        exit(1);
    }

    if(fscanf(fp,"%d",&size)==EOF) {
        printf("Error reading file\n");
        exit(1);
    }
    int i=0;
    float t;
    while(i < size) {
        if(fscanf(fp,"%f",&t)==EOF) {
            printf("Error reading file\n");
            exit(1);
        }
        v[i++]=t;
    }
    fclose(fp);
}

int main(int argc, char **argv) {
    int ii;
    float *hostInput;      // input list
    float *hostOutput;     // output list
    float *deviceInput;
    float *deviceOutput;
    int numInputElements;  // number of elements in the input list
    int numOutputElements; // number of elements in the output list
    float *solution;

    // Read arguments and input files
    parseInput(argc,argv);

    // Read input from data
    getSize(numInputElements,inputFile);
    //numInputElements <<= 10;
    hostInput = (float*) calloc(numInputElements, sizeof(float));
    //numInputElements >>= 10;
    readFromFile(numInputElements,hostInput,inputFile);
    //numInputElements <<= 10;

    int opsz;
    getSize(opsz,outputFile);
    solution = (float*) calloc(opsz, sizeof(float));

    readFromFile(opsz,solution,outputFile);

    // ============== Assumes output element per block ==============
    numOutputElements = numInputElements / (BLOCK_SIZE << 1);
    if (numInputElements % (BLOCK_SIZE << 1)) {
        numOutputElements++;
    }
    hostOutput = (float *)calloc(numOutputElements, sizeof(float));

    if (numOutputElements > 512) {
        numOutputElements = 512;
    }
    // ==============================================================

    // Allocate GPU memory here
    cudaMalloc((float **) &deviceInput, numInputElements*sizeof(float));
    cudaMalloc((float **) &deviceOutput, numOutputElements*sizeof(float));
    cudaMemcpy(deviceInput, hostInput, numInputElements*sizeof(float), cudaMemcpyHostToDevice);

    // ====================== Initialize timer ======================
    cudaEvent_t start,stop;
    float elapsed_time;
    cudaEventCreate(&start);
    cudaEventCreate(&stop);
    cudaEventRecord(start,0);

    // Launch the GPU Kernel here, you may want multiple implementations to compare
    total_reduction<<<numOutputElements, BLOCK_SIZE>>>(deviceInput, deviceOutput, numInputElements);
    cudaDeviceSynchronize();

    // Copy the GPU memory back to the CPU here
    cudaMemcpy(hostOutput, deviceOutput, numOutputElements*sizeof(float), cudaMemcpyDeviceToHost);

    // Reduce any remaining output on host
    for (ii = 1; ii < numOutputElements; ii++) {
        hostOutput[0] += hostOutput[ii];
    }

    cudaEventRecord(stop);
    cudaEventSynchronize(stop);
    cudaEventElapsedTime(&elapsed_time,start, stop);
    // ==============================================================

    // Free the GPU memory here
    cudaFree(deviceInput);
    cudaFree(deviceOutput);

    // Check solution
    if(solution[0] == hostOutput[0]) {
        printf("The operation was successful \n");
        printf("Time:                      %2.6f \n",elapsed_time);
    } else {
        printf("The operation failed \n");
    }
    printf("Expected sum:              %0.0f \n", solution[0]);
    printf("Computed sum:              %0.0f \n", hostOutput[0]);
    printf("Number of input elements:  %i \n", numInputElements);
    printf("Number of output elements: %i \n \n", numOutputElements);

    free(hostInput);
    free(hostOutput);

    return 0;
}

	.file	"tmpxft_003ab7d0_00000000-6_driver.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2034:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2034:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Failed to run statement \n"
	.text
	.globl	_Z11_errorCheck9cudaError
	.type	_Z11_errorCheck9cudaError, @function
_Z11_errorCheck9cudaError:
.LFB2027:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L2
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	jmp	__printf_chk@PLT
.L2:
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z11_errorCheck9cudaError, .-_Z11_errorCheck9cudaError
	.section	.rodata.str1.1
.LC1:
	.string	"Not enough arguments\n"
.LC2:
	.string	"Usage: reduction -i inputFile -o outputFile\n"
.LC3:
	.string	"-i"
.LC4:
	.string	"-o"
.LC5:
	.string	"Wrong input"
	.text
	.globl	_Z10parseInputiPPc
	.type	_Z10parseInputiPPc, @function
_Z10parseInputiPPc:
.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	$24, %rsp
	.cfi_def_cfa_offset 80
	cmpl	$1, %edi
	jg	.L13
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC2(%rip), %rsi
	jmp	.L15
.L13:
	movl	%edi, %ebp
	movq	%rsi, %r15
	movl	$1, %r14d
	leaq	.LC3(%rip), %r12
	leaq	.LC4(%rip), %r13
.L6:
	movq	(%r15,%r14,8), %rdi
	movq	%r12, %rsi
	leal	1(%r14), %ebx
	movq	%rdi, 8(%rsp)
	call	strcmp@PLT
	movq	8(%rsp), %rdi
	testl	%eax, %eax
	jne	.L7
	movq	(%r15,%rbx,8), %rax
	movq	%rax, inputFile(%rip)
	jmp	.L8
.L7:
	movq	%r13, %rsi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L9
	movq	(%r15,%rbx,8), %rax
	movq	%rax, outputFile(%rip)
	jmp	.L8
.L9:
	leaq	.LC5(%rip), %rsi
.L15:
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$1, %edi
	call	exit@PLT
.L8:
	addq	$2, %r14
	cmpl	%r14d, %ebp
	jg	.L6
	addq	$24, %rsp
	.cfi_def_cfa_offset 56
	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	_Z10parseInputiPPc, .-_Z10parseInputiPPc
	.section	.rodata.str1.1
.LC6:
	.string	"r"
.LC7:
	.string	"Error opening File\n"
.LC8:
	.string	"%d"
.LC9:
	.string	"Error reading file\n"
	.text
	.globl	_Z7getSizeRiPc
	.type	_Z7getSizeRiPc, @function
_Z7getSizeRiPc:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rdi, %rbp
	movq	%rsi, %rdi
	leaq	.LC6(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	pushq	%rdx
	.cfi_def_cfa_offset 32
	call	fopen@PLT
	testq	%rax, %rax
	jne	.L17
	leaq	.LC7(%rip), %rdi
	call	perror@PLT
	jmp	.L20
.L17:
	movq	%rax, %rdi
	movq	%rax, %rbx
	movq	%rbp, %rdx
	xorl	%eax, %eax
	leaq	.LC8(%rip), %rsi
	call	__isoc23_fscanf@PLT
	incl	%eax
	jne	.L18
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L20:
	movl	$1, %edi
	call	exit@PLT
.L18:
	popq	%rax
	.cfi_def_cfa_offset 24
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	fclose@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z7getSizeRiPc, .-_Z7getSizeRiPc
	.section	.rodata.str1.1
.LC10:
	.string	"Error opening File %s\n"
.LC11:
	.string	"%f"
	.text
	.globl	_Z12readFromFileRiPfPc
	.type	_Z12readFromFileRiPfPc, @function
_Z12readFromFileRiPfPc:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rsi, %r13
	leaq	.LC6(%rip), %rsi
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movq	%rdi, %r12
	movq	%rdx, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	movq	%rdx, 8(%rsp)
	call	fopen@PLT
	movq	8(%rsp), %rdx
	testq	%rax, %rax
	jne	.L22
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L33
.L22:
	movq	%rax, %rdi
	movq	%rax, %rbx
	movq	%r12, %rdx
	xorl	%eax, %eax
	leaq	.LC8(%rip), %rsi
	xorl	%ebp, %ebp
	leaq	.LC11(%rip), %r14
	call	__isoc23_fscanf@PLT
	incl	%eax
	jne	.L23
.L24:
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L33:
	movl	$1, %edi
	call	exit@PLT
.L25:
	xorl	%eax, %eax
	leaq	20(%rsp), %rdx
	movq	%r14, %rsi
	movq	%rbx, %rdi
	call	__isoc23_fscanf@PLT
	incl	%eax
	je	.L24
	movss	20(%rsp), %xmm0
	movss	%xmm0, 0(%r13,%rbp,4)
	incq	%rbp
.L23:
	cmpl	%ebp, (%r12)
	jg	.L25
	movq	%rbx, %rdi
	call	fclose@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L26
	call	__stack_chk_fail@PLT
.L26:
	addq	$32, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z12readFromFileRiPfPc, .-_Z12readFromFileRiPfPc
	.globl	_Z39__device_stub__Z16total_sequentialPfS_iPfS_i
	.type	_Z39__device_stub__Z16total_sequentialPfS_iPfS_i, @function
_Z39__device_stub__Z16total_sequentialPfS_iPfS_i:
.LFB2056:
	.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	.L34
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z16total_sequentialPfS_i(%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
.L34:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L36
	call	__stack_chk_fail@PLT
.L36:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2056:
	.size	_Z39__device_stub__Z16total_sequentialPfS_iPfS_i, .-_Z39__device_stub__Z16total_sequentialPfS_iPfS_i
	.globl	_Z16total_sequentialPfS_i
	.type	_Z16total_sequentialPfS_i, @function
_Z16total_sequentialPfS_i:
.LFB2057:
	.cfi_startproc
	endbr64
	jmp	_Z39__device_stub__Z16total_sequentialPfS_iPfS_i
	.cfi_endproc
.LFE2057:
	.size	_Z16total_sequentialPfS_i, .-_Z16total_sequentialPfS_i
	.globl	_Z49__device_stub__Z26total_sequential_coalescedPfS_iPfS_i
	.type	_Z49__device_stub__Z26total_sequential_coalescedPfS_iPfS_i, @function
_Z49__device_stub__Z26total_sequential_coalescedPfS_iPfS_i:
.LFB2058:
	.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	.L39
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z26total_sequential_coalescedPfS_i(%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
.L39:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L41
	call	__stack_chk_fail@PLT
.L41:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2058:
	.size	_Z49__device_stub__Z26total_sequential_coalescedPfS_iPfS_i, .-_Z49__device_stub__Z26total_sequential_coalescedPfS_iPfS_i
	.globl	_Z26total_sequential_coalescedPfS_i
	.type	_Z26total_sequential_coalescedPfS_i, @function
_Z26total_sequential_coalescedPfS_i:
.LFB2059:
	.cfi_startproc
	endbr64
	jmp	_Z49__device_stub__Z26total_sequential_coalescedPfS_iPfS_i
	.cfi_endproc
.LFE2059:
	.size	_Z26total_sequential_coalescedPfS_i, .-_Z26total_sequential_coalescedPfS_i
	.globl	_Z35__device_stub__Z12total_atomicPfS_iPfS_i
	.type	_Z35__device_stub__Z12total_atomicPfS_iPfS_i, @function
_Z35__device_stub__Z12total_atomicPfS_iPfS_i:
.LFB2060:
	.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	.L44
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z12total_atomicPfS_i(%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
.L44:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L46
	call	__stack_chk_fail@PLT
.L46:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2060:
	.size	_Z35__device_stub__Z12total_atomicPfS_iPfS_i, .-_Z35__device_stub__Z12total_atomicPfS_iPfS_i
	.globl	_Z12total_atomicPfS_i
	.type	_Z12total_atomicPfS_i, @function
_Z12total_atomicPfS_i:
.LFB2061:
	.cfi_startproc
	endbr64
	jmp	_Z35__device_stub__Z12total_atomicPfS_iPfS_i
	.cfi_endproc
.LFE2061:
	.size	_Z12total_atomicPfS_i, .-_Z12total_atomicPfS_i
	.globl	_Z45__device_stub__Z22total_atomic_coalescedPfS_iPfS_i
	.type	_Z45__device_stub__Z22total_atomic_coalescedPfS_iPfS_i, @function
_Z45__device_stub__Z22total_atomic_coalescedPfS_iPfS_i:
.LFB2062:
	.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	.L49
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z22total_atomic_coalescedPfS_i(%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
.L49:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L51
	call	__stack_chk_fail@PLT
.L51:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2062:
	.size	_Z45__device_stub__Z22total_atomic_coalescedPfS_iPfS_i, .-_Z45__device_stub__Z22total_atomic_coalescedPfS_iPfS_i
	.globl	_Z22total_atomic_coalescedPfS_i
	.type	_Z22total_atomic_coalescedPfS_i, @function
_Z22total_atomic_coalescedPfS_i:
.LFB2063:
	.cfi_startproc
	endbr64
	jmp	_Z45__device_stub__Z22total_atomic_coalescedPfS_iPfS_i
	.cfi_endproc
.LFE2063:
	.size	_Z22total_atomic_coalescedPfS_i, .-_Z22total_atomic_coalescedPfS_i
	.globl	_Z46__device_stub__Z23total_partial_reductionPfS_iPfS_i
	.type	_Z46__device_stub__Z23total_partial_reductionPfS_iPfS_i, @function
_Z46__device_stub__Z23total_partial_reductionPfS_iPfS_i:
.LFB2064:
	.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	.L54
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z23total_partial_reductionPfS_i(%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
.L54:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L56
	call	__stack_chk_fail@PLT
.L56:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2064:
	.size	_Z46__device_stub__Z23total_partial_reductionPfS_iPfS_i, .-_Z46__device_stub__Z23total_partial_reductionPfS_iPfS_i
	.globl	_Z23total_partial_reductionPfS_i
	.type	_Z23total_partial_reductionPfS_i, @function
_Z23total_partial_reductionPfS_i:
.LFB2065:
	.cfi_startproc
	endbr64
	jmp	_Z46__device_stub__Z23total_partial_reductionPfS_iPfS_i
	.cfi_endproc
.LFE2065:
	.size	_Z23total_partial_reductionPfS_i, .-_Z23total_partial_reductionPfS_i
	.globl	_Z38__device_stub__Z15total_reductionPfS_iPfS_i
	.type	_Z38__device_stub__Z15total_reductionPfS_iPfS_i, @function
_Z38__device_stub__Z15total_reductionPfS_iPfS_i:
.LFB2066:
	.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	.L59
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z15total_reductionPfS_i(%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
.L59:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L61
	call	__stack_chk_fail@PLT
.L61:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2066:
	.size	_Z38__device_stub__Z15total_reductionPfS_iPfS_i, .-_Z38__device_stub__Z15total_reductionPfS_iPfS_i
	.globl	_Z15total_reductionPfS_i
	.type	_Z15total_reductionPfS_i, @function
_Z15total_reductionPfS_i:
.LFB2067:
	.cfi_startproc
	endbr64
	jmp	_Z38__device_stub__Z15total_reductionPfS_iPfS_i
	.cfi_endproc
.LFE2067:
	.size	_Z15total_reductionPfS_i, .-_Z15total_reductionPfS_i
	.section	.rodata.str1.1
.LC12:
	.string	"The operation was successful \n"
.LC13:
	.string	"Time:                      %2.6f \n"
.LC14:
	.string	"The operation failed \n"
.LC15:
	.string	"Expected sum:              %0.0f \n"
.LC16:
	.string	"Computed sum:              %0.0f \n"
.LC17:
	.string	"Number of input elements:  %i \n"
.LC18:
	.string	"Number of output elements: %i \n \n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rbx
	call	_Z10parseInputiPPc
	movq	inputFile(%rip), %rsi
	movq	%rbx, %rdi
	call	_Z7getSizeRiPc
	movslq	8(%rsp), %rdi
	movl	$4, %esi
	call	calloc@PLT
	movq	inputFile(%rip), %rdx
	movq	%rbx, %rdi
	leaq	12(%rsp), %rbx
	movq	%rax, %rsi
	movq	%rax, %r13
	call	_Z12readFromFileRiPfPc
	movq	outputFile(%rip), %rsi
	movq	%rbx, %rdi
	call	_Z7getSizeRiPc
	movslq	12(%rsp), %rdi
	movl	$4, %esi
	call	calloc@PLT
	movq	outputFile(%rip), %rdx
	movq	%rbx, %rdi
	movq	%rax, %rsi
	movq	%rax, %r14
	call	_Z12readFromFileRiPfPc
	movl	8(%rsp), %r12d
	movl	$1024, %ecx
	movl	$4, %esi
	movl	%r12d, %eax
	cltd
	idivl	%ecx
	movl	%eax, %ebx
	movl	%r12d, %eax
	andl	$1023, %eax
	cmpl	$1, %eax
	sbbl	$-1, %ebx
	movslq	%ebx, %rdi
	call	calloc@PLT
	movslq	%r12d, %rsi
	leaq	16(%rsp), %rdi
	movq	%rax, %rbp
	movl	$512, %eax
	cmpl	%eax, %ebx
	cmovg	%eax, %ebx
	salq	$2, %rsi
	call	cudaMalloc@PLT
	leaq	24(%rsp), %rdi
	movslq	%ebx, %r12
	salq	$2, %r12
	movq	%r12, %rsi
	call	cudaMalloc@PLT
	movslq	8(%rsp), %rdx
	movq	16(%rsp), %rdi
	movq	%r13, %rsi
	movl	$1, %ecx
	salq	$2, %rdx
	call	cudaMemcpy@PLT
	leaq	32(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	40(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	32(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movl	%ebx, 48(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rax
	movl	$8388609, %edx
	movl	$1, %ecx
	movl	$1, 68(%rsp)
	movq	%rax, 52(%rsp)
	movq	48(%rsp), %rdi
	salq	$9, %rdx
	movl	56(%rsp), %esi
	movq	%rdx, 60(%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L66
	movl	8(%rsp), %edx
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdi
	call	_Z38__device_stub__Z15total_reductionPfS_iPfS_i
.L66:
	call	cudaDeviceSynchronize@PLT
	movq	24(%rsp), %rsi
	movq	%r12, %rdx
	movq	%rbp, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	xorl	%eax, %eax
.L67:
	incq	%rax
	cmpl	%eax, %ebx
	jle	.L77
	movss	0(%rbp), %xmm0
	addss	0(%rbp,%rax,4), %xmm0
	movss	%xmm0, 0(%rbp)
	jmp	.L67
.L77:
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	40(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	40(%rsp), %rdx
	movq	32(%rsp), %rsi
	leaq	60(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movl	(%r14), %r12d
	movd	%r12d, %xmm1
	ucomiss	0(%rbp), %xmm1
	jp	.L69
	jne	.L69
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	60(%rsp), %xmm0
	call	__printf_chk@PLT
	jmp	.L71
.L69:
	leaq	.LC14(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L71:
	movd	%r12d, %xmm2
	leaq	.LC15(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	%xmm2, %xmm0
	call	__printf_chk@PLT
	movl	$2, %edi
	movb	$1, %al
	leaq	.LC16(%rip), %rsi
	cvtss2sd	0(%rbp), %xmm0
	call	__printf_chk@PLT
	movl	8(%rsp), %edx
	movl	$2, %edi
	xorl	%eax, %eax
	leaq	.LC17(%rip), %rsi
	call	__printf_chk@PLT
	movl	%ebx, %edx
	leaq	.LC18(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L72
	call	__stack_chk_fail@PLT
.L72:
	addq	$80, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2031:
	.size	main, .-main
	.section	.rodata.str1.1
.LC19:
	.string	"_Z15total_reductionPfS_i"
.LC20:
	.string	"_Z23total_partial_reductionPfS_i"
.LC21:
	.string	"_Z22total_atomic_coalescedPfS_i"
.LC22:
	.string	"_Z12total_atomicPfS_i"
.LC23:
	.string	"_Z26total_sequential_coalescedPfS_i"
.LC24:
	.string	"_Z16total_sequentialPfS_i"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2069:
	.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	.LC19(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z15total_reductionPfS_i(%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	.LC20(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z23total_partial_reductionPfS_i(%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
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC21(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z22total_atomic_coalescedPfS_i(%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
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC22(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z12total_atomicPfS_i(%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
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC23(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z26total_sequential_coalescedPfS_i(%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
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	xorl	%r9d, %r9d
	pushq	$0
	.cfi_def_cfa_offset 24
	leaq	.LC24(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z16total_sequentialPfS_i(%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
.LFE2069:
	.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
	.globl	outputFile
	.bss
	.align 8
	.type	outputFile, @object
	.size	outputFile, 8
outputFile:
	.zero	8
	.globl	inputFile
	.align 8
	.type	inputFile, @object
	.size	inputFile, 8
inputFile:
	.zero	8
	.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:

// Given a list (lst) of length n
// Output its sum = lst[0] + lst[1] + ... + lst[n-1];
#include<stdio.h>
#include "hip/hip_runtime.h"
#include<string.h>
#include<stdlib.h>

#define BLOCK_SIZE 512

char *inputFile,*outputFile;
void _errorCheck(hipError_t e) {
    if(e != hipSuccess) {
        printf("Failed to run statement \n");
    }
}

// ==================================================================
__global__ void total_sequential(float *input, float *output, int len) {
    if (threadIdx.x == 0) {
        int i;
        int sum = 0;
        int block = blockIdx.x;

        int elems = (len + gridDim.x - 1) / gridDim.x;
        int start = block * elems;
        int stop = min(start + elems, len);

        // One thread computes sum
        for (i = start; i < stop; i++) {
            sum += input[i];
        }
        output[block] = sum;
    }
}

__global__ void total_sequential_coalesced(float *input, float *output, int len) {
    if (threadIdx.x == 0) {
        int i;
        int sum = 0;

        int start = blockIdx.x;
        int step = gridDim.x;

        // One thread computes sum
        for (i = start; i < len; i += step) {
            sum += input[i];
        }
        output[start] = sum;
    }
}

__global__ void total_atomic(float *input, float *output, int len) {
    int i;
    int block = blockIdx.x;
    int thread = threadIdx.x;

    int elems = (len + gridDim.x - 1) / gridDim.x;
    int start = block * elems;
    int stop = min(start + elems, len);

    // Thread computes adjacent elements
    int elems_per_thread = (elems + BLOCK_SIZE - 1) / BLOCK_SIZE;
    start = start + thread * elems_per_thread;
    stop = min(stop, start + elems_per_thread);

    for (i = start; i < stop; i++) {
        // Every thread atomically updates the sum
        atomicAdd(output + block, input[i]);
    }
}

__global__ void total_atomic_coalesced(float *input, float *output, int len) {
    int i;
    int block = blockIdx.x;
    int thread = threadIdx.x;

    int start = block * BLOCK_SIZE + thread;
    int step = gridDim.x * BLOCK_SIZE;

    for (i = start; i < len; i+= step) {
        // Every thread atomically updates the sum
        atomicAdd(output + block, input[i]);
    }
}

__global__ void total_partial_reduction(float *input, float *output, int len) {
    __shared__ float shared[BLOCK_SIZE];

    int i;
    int block = blockIdx.x;
    int thread = threadIdx.x;

    int start = block * BLOCK_SIZE + thread;
    int step = gridDim.x * BLOCK_SIZE;

    // Each thread computes a sum in shared memory
    shared[thread] = 0;
    for (i = start; i < len; i += step) {
        shared[thread] += input[i];
    }
    __syncthreads();

    // Compute sum for blocks on thread 0
    if (thread == 0) {
        int sum = 0;
        for (i = 0; i < BLOCK_SIZE; i++) {
            sum += shared[i];
        }
        output[block] = sum;
    }
}

__global__ void total_reduction(float *input, float *output, int len) {
    __shared__ float shared[BLOCK_SIZE];

    int i;
    int block = blockIdx.x;
    int thread = threadIdx.x;

    int start = block * 2 * BLOCK_SIZE + thread;
    int step = gridDim.x * 2 * BLOCK_SIZE;

    // Many elements per thread
    shared[thread] = 0;
    for (i = start; i < len; i += step) {
        shared[thread] += input[i] + input[i + BLOCK_SIZE];
    }
    __syncthreads();

    // Recursively reduce down to 1 element
    for (i = BLOCK_SIZE >> 1; i > 0; i >>= 1) {
        if (thread < i) {
            shared[thread] += shared[thread + i];
        }
        __syncthreads();
    }

    if (thread == 0) {
        output[block] = shared[0];
    }
}
// ==================================================================

void parseInput(int argc, char **argv) {
    if(argc < 2) {
        printf("Not enough arguments\n");
        printf("Usage: reduction -i inputFile -o outputFile\n");
        exit(1);
    }
    int i=1;
    while(i<argc) {
        if(!strcmp(argv[i],"-i")) {
            ++i;
            inputFile = argv[i];
        } else if(!strcmp(argv[i],"-o")) {
            ++i;
            outputFile = argv[i];
        } else {
            printf("Wrong input");
            exit(1);
        }
        i++;
    }
}
void getSize(int &size, char *file) {
    FILE *fp;
    fp = fopen(file,"r");
    if(fp == NULL) {
        perror("Error opening File\n");
        exit(1);
    }

    if(fscanf(fp,"%d",&size)==EOF) {
        printf("Error reading file\n");
        exit(1);
    }
    fclose(fp);
}
void readFromFile(int &size,float *v, char *file) {
    FILE *fp;
    fp = fopen(file,"r");
    if(fp == NULL) {
        printf("Error opening File %s\n",file);
        exit(1);
    }

    if(fscanf(fp,"%d",&size)==EOF) {
        printf("Error reading file\n");
        exit(1);
    }
    int i=0;
    float t;
    while(i < size) {
        if(fscanf(fp,"%f",&t)==EOF) {
            printf("Error reading file\n");
            exit(1);
        }
        v[i++]=t;
    }
    fclose(fp);
}

int main(int argc, char **argv) {
    int ii;
    float *hostInput;      // input list
    float *hostOutput;     // output list
    float *deviceInput;
    float *deviceOutput;
    int numInputElements;  // number of elements in the input list
    int numOutputElements; // number of elements in the output list
    float *solution;

    // Read arguments and input files
    parseInput(argc,argv);

    // Read input from data
    getSize(numInputElements,inputFile);
    //numInputElements <<= 10;
    hostInput = (float*) calloc(numInputElements, sizeof(float));
    //numInputElements >>= 10;
    readFromFile(numInputElements,hostInput,inputFile);
    //numInputElements <<= 10;

    int opsz;
    getSize(opsz,outputFile);
    solution = (float*) calloc(opsz, sizeof(float));

    readFromFile(opsz,solution,outputFile);

    // ============== Assumes output element per block ==============
    numOutputElements = numInputElements / (BLOCK_SIZE << 1);
    if (numInputElements % (BLOCK_SIZE << 1)) {
        numOutputElements++;
    }
    hostOutput = (float *)calloc(numOutputElements, sizeof(float));

    if (numOutputElements > 512) {
        numOutputElements = 512;
    }
    // ==============================================================

    // Allocate GPU memory here
    hipMalloc((float **) &deviceInput, numInputElements*sizeof(float));
    hipMalloc((float **) &deviceOutput, numOutputElements*sizeof(float));
    hipMemcpy(deviceInput, hostInput, numInputElements*sizeof(float), hipMemcpyHostToDevice);

    // ====================== Initialize timer ======================
    hipEvent_t start,stop;
    float elapsed_time;
    hipEventCreate(&start);
    hipEventCreate(&stop);
    hipEventRecord(start,0);

    // Launch the GPU Kernel here, you may want multiple implementations to compare
    total_reduction<<<numOutputElements, BLOCK_SIZE>>>(deviceInput, deviceOutput, numInputElements);
    hipDeviceSynchronize();

    // Copy the GPU memory back to the CPU here
    hipMemcpy(hostOutput, deviceOutput, numOutputElements*sizeof(float), hipMemcpyDeviceToHost);

    // Reduce any remaining output on host
    for (ii = 1; ii < numOutputElements; ii++) {
        hostOutput[0] += hostOutput[ii];
    }

    hipEventRecord(stop);
    hipEventSynchronize(stop);
    hipEventElapsedTime(&elapsed_time,start, stop);
    // ==============================================================

    // Free the GPU memory here
    hipFree(deviceInput);
    hipFree(deviceOutput);

    // Check solution
    if(solution[0] == hostOutput[0]) {
        printf("The operation was successful \n");
        printf("Time:                      %2.6f \n",elapsed_time);
    } else {
        printf("The operation failed \n");
    }
    printf("Expected sum:              %0.0f \n", solution[0]);
    printf("Computed sum:              %0.0f \n", hostOutput[0]);
    printf("Number of input elements:  %i \n", numInputElements);
    printf("Number of output elements: %i \n \n", numOutputElements);

    free(hostInput);
    free(hostOutput);

    return 0;
}

	.text
	.file	"driver.hip"
	.globl	_Z11_errorCheck10hipError_t     # -- Begin function _Z11_errorCheck10hipError_t
	.type	_Z11_errorCheck10hipError_t,@function
_Z11_errorCheck10hipError_t:            # @_Z11_errorCheck10hipError_t
	.cfi_startproc
# %bb.0:
	testl	%edi, %edi
	je	.LBB0_1
# %bb.2:
	movl	$.Lstr, %edi
	jmp	puts@PLT                        # TAILCALL
.LBB0_1:
	retq
.Lfunc_end0:
	.size	_Z11_errorCheck10hipError_t, .Lfunc_end0-_Z11_errorCheck10hipError_t
	.cfi_endproc
                                        # -- End function
	.globl	_Z31__device_stub__total_sequentialPfS_i # -- Begin function _Z31__device_stub__total_sequentialPfS_i
	.type	_Z31__device_stub__total_sequentialPfS_i,@function
_Z31__device_stub__total_sequentialPfS_i: # @_Z31__device_stub__total_sequentialPfS_i
	.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	$_Z16total_sequentialPfS_i, %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_end1:
	.size	_Z31__device_stub__total_sequentialPfS_i, .Lfunc_end1-_Z31__device_stub__total_sequentialPfS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z41__device_stub__total_sequential_coalescedPfS_i # -- Begin function _Z41__device_stub__total_sequential_coalescedPfS_i
	.type	_Z41__device_stub__total_sequential_coalescedPfS_i,@function
_Z41__device_stub__total_sequential_coalescedPfS_i: # @_Z41__device_stub__total_sequential_coalescedPfS_i
	.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	$_Z26total_sequential_coalescedPfS_i, %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_end2:
	.size	_Z41__device_stub__total_sequential_coalescedPfS_i, .Lfunc_end2-_Z41__device_stub__total_sequential_coalescedPfS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z27__device_stub__total_atomicPfS_i # -- Begin function _Z27__device_stub__total_atomicPfS_i
	.type	_Z27__device_stub__total_atomicPfS_i,@function
_Z27__device_stub__total_atomicPfS_i:   # @_Z27__device_stub__total_atomicPfS_i
	.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	$_Z12total_atomicPfS_i, %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	_Z27__device_stub__total_atomicPfS_i, .Lfunc_end3-_Z27__device_stub__total_atomicPfS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z37__device_stub__total_atomic_coalescedPfS_i # -- Begin function _Z37__device_stub__total_atomic_coalescedPfS_i
	.type	_Z37__device_stub__total_atomic_coalescedPfS_i,@function
_Z37__device_stub__total_atomic_coalescedPfS_i: # @_Z37__device_stub__total_atomic_coalescedPfS_i
	.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	$_Z22total_atomic_coalescedPfS_i, %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_end4:
	.size	_Z37__device_stub__total_atomic_coalescedPfS_i, .Lfunc_end4-_Z37__device_stub__total_atomic_coalescedPfS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z38__device_stub__total_partial_reductionPfS_i # -- Begin function _Z38__device_stub__total_partial_reductionPfS_i
	.type	_Z38__device_stub__total_partial_reductionPfS_i,@function
_Z38__device_stub__total_partial_reductionPfS_i: # @_Z38__device_stub__total_partial_reductionPfS_i
	.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	$_Z23total_partial_reductionPfS_i, %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_end5:
	.size	_Z38__device_stub__total_partial_reductionPfS_i, .Lfunc_end5-_Z38__device_stub__total_partial_reductionPfS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z30__device_stub__total_reductionPfS_i # -- Begin function _Z30__device_stub__total_reductionPfS_i
	.type	_Z30__device_stub__total_reductionPfS_i,@function
_Z30__device_stub__total_reductionPfS_i: # @_Z30__device_stub__total_reductionPfS_i
	.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	$_Z15total_reductionPfS_i, %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_end6:
	.size	_Z30__device_stub__total_reductionPfS_i, .Lfunc_end6-_Z30__device_stub__total_reductionPfS_i
	.cfi_endproc
                                        # -- End function
	.globl	_Z10parseInputiPPc              # -- Begin function _Z10parseInputiPPc
	.type	_Z10parseInputiPPc,@function
_Z10parseInputiPPc:                     # @_Z10parseInputiPPc
	.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	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$2, %edi
	jl	.LBB7_9
# %bb.1:                                # %.preheader.preheader
	movq	%rsi, %rbx
	movl	%edi, %ebp
	movl	$1, %r15d
.LBB7_2:                                # %.preheader
                                        # =>This Inner Loop Header: Depth=1
	movq	(%rbx,%r15,8), %r14
	movl	$.L.str.3, %esi
	movq	%r14, %rdi
	callq	strcmp
	testl	%eax, %eax
	je	.LBB7_4
# %bb.3:                                #   in Loop: Header=BB7_2 Depth=1
	movl	$.L.str.4, %esi
	movq	%r14, %rdi
	callq	strcmp
	movl	$outputFile, %ecx
	testl	%eax, %eax
	je	.LBB7_5
	jmp	.LBB7_7
.LBB7_4:                                #   in Loop: Header=BB7_2 Depth=1
	movl	$inputFile, %ecx
.LBB7_5:                                #   in Loop: Header=BB7_2 Depth=1
	movq	8(%rbx,%r15,8), %rax
	movq	%rax, (%rcx)
	addq	$2, %r15
	cmpl	%ebp, %r15d
	jl	.LBB7_2
# %bb.6:
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.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
.LBB7_7:
	.cfi_def_cfa_offset 48
	movl	$.L.str.5, %edi
	xorl	%eax, %eax
	callq	printf
.LBB7_8:
	movl	$1, %edi
	callq	exit
.LBB7_9:
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	jmp	.LBB7_8
.Lfunc_end7:
	.size	_Z10parseInputiPPc, .Lfunc_end7-_Z10parseInputiPPc
	.cfi_endproc
                                        # -- End function
	.globl	_Z7getSizeRiPc                  # -- Begin function _Z7getSizeRiPc
	.type	_Z7getSizeRiPc,@function
_Z7getSizeRiPc:                         # @_Z7getSizeRiPc
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movq	%rsi, %rax
	movq	%rdi, %r14
	movl	$.L.str.6, %esi
	movq	%rax, %rdi
	callq	fopen
	testq	%rax, %rax
	je	.LBB8_3
# %bb.1:
	movq	%rax, %rbx
	movl	$.L.str.8, %esi
	movq	%rax, %rdi
	movq	%r14, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	cmpl	$-1, %eax
	je	.LBB8_5
# %bb.2:
	movq	%rbx, %rdi
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	fclose                          # TAILCALL
.LBB8_3:
	.cfi_def_cfa_offset 32
	movl	$.L.str.7, %edi
	callq	perror
	jmp	.LBB8_4
.LBB8_5:
	movl	$.Lstr.5, %edi
	callq	puts@PLT
.LBB8_4:
	movl	$1, %edi
	callq	exit
.Lfunc_end8:
	.size	_Z7getSizeRiPc, .Lfunc_end8-_Z7getSizeRiPc
	.cfi_endproc
                                        # -- End function
	.globl	_Z12readFromFileRiPfPc          # -- Begin function _Z12readFromFileRiPfPc
	.type	_Z12readFromFileRiPfPc,@function
_Z12readFromFileRiPfPc:                 # @_Z12readFromFileRiPfPc
	.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	$16, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rdx, %r12
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movl	$.L.str.6, %esi
	movq	%rdx, %rdi
	callq	fopen
	testq	%rax, %rax
	je	.LBB9_9
# %bb.1:
	movq	%rax, %r15
	movl	$.L.str.8, %esi
	movq	%rax, %rdi
	movq	%r14, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	cmpl	$-1, %eax
	je	.LBB9_7
# %bb.2:
	cmpl	$0, (%r14)
	jle	.LBB9_6
# %bb.3:                                # %.lr.ph.preheader
	leaq	12(%rsp), %r12
	xorl	%r13d, %r13d
.LBB9_4:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	$.L.str.11, %esi
	movq	%r15, %rdi
	movq	%r12, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	cmpl	$-1, %eax
	je	.LBB9_7
# %bb.5:                                #   in Loop: Header=BB9_4 Depth=1
	movss	12(%rsp), %xmm0                 # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rbx,%r13,4)
	incq	%r13
	movslq	(%r14), %rax
	cmpq	%rax, %r13
	jl	.LBB9_4
.LBB9_6:                                # %._crit_edge
	movq	%r15, %rdi
	callq	fclose
	addq	$16, %rsp
	.cfi_def_cfa_offset 48
	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
.LBB9_7:
	.cfi_def_cfa_offset 64
	movl	$.Lstr.5, %edi
	callq	puts@PLT
.LBB9_8:
	movl	$1, %edi
	callq	exit
.LBB9_9:
	movl	$.L.str.10, %edi
	movq	%r12, %rsi
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB9_8
.Lfunc_end9:
	.size	_Z12readFromFileRiPfPc, .Lfunc_end9-_Z12readFromFileRiPfPc
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function 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	$72, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	callq	_Z10parseInputiPPc
	movq	inputFile(%rip), %rsi
	leaq	12(%rsp), %rbx
	movq	%rbx, %rdi
	callq	_Z7getSizeRiPc
	movslq	(%rbx), %rdi
	movl	$4, %esi
	callq	calloc
	movq	%rax, %r13
	movq	inputFile(%rip), %rdx
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_Z12readFromFileRiPfPc
	movq	outputFile(%rip), %rsi
	leaq	68(%rsp), %r14
	movq	%r14, %rdi
	callq	_Z7getSizeRiPc
	movslq	(%r14), %rdi
	movl	$4, %esi
	callq	calloc
	movq	outputFile(%rip), %rdx
	movq	%r14, %rdi
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	movq	%rax, %rsi
	callq	_Z12readFromFileRiPfPc
	movslq	(%rbx), %rbp
	movl	$1023, %eax                     # imm = 0x3FF
	leal	(%rax,%rbp), %r12d
	testl	%ebp, %ebp
	cmovnsl	%ebp, %r12d
	sarl	$10, %r12d
	andl	%ebp, %eax
	cmpl	$1, %eax
	sbbl	$-1, %r12d
	movslq	%r12d, %rbx
	movl	$4, %esi
	movq	%rbx, %rdi
	callq	calloc
	movq	%rax, %r14
	movl	$512, %r15d                     # imm = 0x200
	cmpl	%r15d, %ebx
	cmovll	%r12d, %r15d
	shlq	$2, %rbp
	leaq	48(%rsp), %rbx
	movq	%rbx, %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	movslq	%r15d, %rbp
	shlq	$2, %rbp
	leaq	32(%rsp), %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	movq	(%rbx), %rdi
	leaq	12(%rsp), %rax
	movslq	(%rax), %rdx
	shlq	$2, %rdx
	movq	%r13, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	leaq	56(%rsp), %rbx
	movq	%rbx, %rdi
	callq	hipEventCreate
	leaq	24(%rsp), %rdi
	callq	hipEventCreate
	movq	(%rbx), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	%r15, %rdi
	btsq	$32, %rdi
	movabsq	$4294967296, %rdx               # imm = 0x100000000
	orq	$512, %rdx                      # imm = 0x200
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB10_2
# %bb.1:
	movq	48(%rsp), %rdi
	movq	32(%rsp), %rsi
	movl	12(%rsp), %edx
	callq	_Z30__device_stub__total_reductionPfS_i
.LBB10_2:
	callq	hipDeviceSynchronize
	movq	32(%rsp), %rsi
	movl	$2, %ebx
	movq	%r14, %rdi
	movq	%rbp, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	cmpl	$2, %r12d
	jl	.LBB10_6
# %bb.3:                                # %.lr.ph
	movss	(%r14), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	cmpl	$3, %r15d
	cmovgel	%r15d, %ebx
	movl	$1, %eax
.LBB10_4:                               # =>This Inner Loop Header: Depth=1
	addss	(%r14,%rax,4), %xmm0
	incq	%rax
	cmpq	%rax, %rbx
	jne	.LBB10_4
# %bb.5:                                # %._crit_edge
	movss	%xmm0, (%r14)
.LBB10_6:
	movq	24(%rsp), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	24(%rsp), %rdi
	callq	hipEventSynchronize
	movq	56(%rsp), %rsi
	movq	24(%rsp), %rdx
	leaq	44(%rsp), %rdi
	callq	hipEventElapsedTime
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	32(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rax                  # 8-byte Reload
	movss	(%rax), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 16(%rsp)                 # 4-byte Spill
	ucomiss	(%r14), %xmm0
	jne	.LBB10_8
	jp	.LBB10_8
# %bb.7:
	movl	$.Lstr.7, %edi
	callq	puts@PLT
	xorps	%xmm0, %xmm0
	cvtss2sd	44(%rsp), %xmm0
	movl	$.L.str.13, %edi
	movb	$1, %al
	callq	printf
	jmp	.LBB10_9
.LBB10_8:
	movl	$.Lstr.6, %edi
	callq	puts@PLT
.LBB10_9:
	xorps	%xmm0, %xmm0
	cvtss2sd	16(%rsp), %xmm0                 # 4-byte Folded Reload
	movl	$.L.str.15, %edi
	movb	$1, %al
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	(%r14), %xmm0
	movl	$.L.str.16, %edi
	movb	$1, %al
	callq	printf
	movl	12(%rsp), %esi
	movl	$.L.str.17, %edi
	xorl	%eax, %eax
	callq	printf
	movl	$.L.str.18, %edi
	movl	%r15d, %esi
	xorl	%eax, %eax
	callq	printf
	movq	%r13, %rdi
	callq	free
	movq	%r14, %rdi
	callq	free
	xorl	%eax, %eax
	addq	$72, %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_end10:
	.size	main, .Lfunc_end10-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:
	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	.LBB11_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB11_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z16total_sequentialPfS_i, %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	$_Z26total_sequential_coalescedPfS_i, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z12total_atomicPfS_i, %esi
	movl	$.L__unnamed_3, %edx
	movl	$.L__unnamed_3, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z22total_atomic_coalescedPfS_i, %esi
	movl	$.L__unnamed_4, %edx
	movl	$.L__unnamed_4, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z23total_partial_reductionPfS_i, %esi
	movl	$.L__unnamed_5, %edx
	movl	$.L__unnamed_5, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z15total_reductionPfS_i, %esi
	movl	$.L__unnamed_6, %edx
	movl	$.L__unnamed_6, %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_end11:
	.size	__hip_module_ctor, .Lfunc_end11-__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	.LBB12_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
.LBB12_2:
	retq
.Lfunc_end12:
	.size	__hip_module_dtor, .Lfunc_end12-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	inputFile,@object               # @inputFile
	.bss
	.globl	inputFile
	.p2align	3, 0x0
inputFile:
	.quad	0
	.size	inputFile, 8

	.type	outputFile,@object              # @outputFile
	.globl	outputFile
	.p2align	3, 0x0
outputFile:
	.quad	0
	.size	outputFile, 8

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

	.type	_Z26total_sequential_coalescedPfS_i,@object # @_Z26total_sequential_coalescedPfS_i
	.globl	_Z26total_sequential_coalescedPfS_i
	.p2align	3, 0x0
_Z26total_sequential_coalescedPfS_i:
	.quad	_Z41__device_stub__total_sequential_coalescedPfS_i
	.size	_Z26total_sequential_coalescedPfS_i, 8

	.type	_Z12total_atomicPfS_i,@object   # @_Z12total_atomicPfS_i
	.globl	_Z12total_atomicPfS_i
	.p2align	3, 0x0
_Z12total_atomicPfS_i:
	.quad	_Z27__device_stub__total_atomicPfS_i
	.size	_Z12total_atomicPfS_i, 8

	.type	_Z22total_atomic_coalescedPfS_i,@object # @_Z22total_atomic_coalescedPfS_i
	.globl	_Z22total_atomic_coalescedPfS_i
	.p2align	3, 0x0
_Z22total_atomic_coalescedPfS_i:
	.quad	_Z37__device_stub__total_atomic_coalescedPfS_i
	.size	_Z22total_atomic_coalescedPfS_i, 8

	.type	_Z23total_partial_reductionPfS_i,@object # @_Z23total_partial_reductionPfS_i
	.globl	_Z23total_partial_reductionPfS_i
	.p2align	3, 0x0
_Z23total_partial_reductionPfS_i:
	.quad	_Z38__device_stub__total_partial_reductionPfS_i
	.size	_Z23total_partial_reductionPfS_i, 8

	.type	_Z15total_reductionPfS_i,@object # @_Z15total_reductionPfS_i
	.globl	_Z15total_reductionPfS_i
	.p2align	3, 0x0
_Z15total_reductionPfS_i:
	.quad	_Z30__device_stub__total_reductionPfS_i
	.size	_Z15total_reductionPfS_i, 8

	.type	.L.str.3,@object                # @.str.3
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.3:
	.asciz	"-i"
	.size	.L.str.3, 3

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"-o"
	.size	.L.str.4, 3

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Wrong input"
	.size	.L.str.5, 12

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

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Error opening File\n"
	.size	.L.str.7, 20

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"%d"
	.size	.L.str.8, 3

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Error opening File %s\n"
	.size	.L.str.10, 23

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"%f"
	.size	.L.str.11, 3

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"Time:                      %2.6f \n"
	.size	.L.str.13, 35

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"Expected sum:              %0.0f \n"
	.size	.L.str.15, 35

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"Computed sum:              %0.0f \n"
	.size	.L.str.16, 35

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"Number of input elements:  %i \n"
	.size	.L.str.17, 32

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"Number of output elements: %i \n \n"
	.size	.L.str.18, 34

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z16total_sequentialPfS_i"
	.size	.L__unnamed_1, 26

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z26total_sequential_coalescedPfS_i"
	.size	.L__unnamed_2, 36

	.type	.L__unnamed_3,@object           # @2
.L__unnamed_3:
	.asciz	"_Z12total_atomicPfS_i"
	.size	.L__unnamed_3, 22

	.type	.L__unnamed_4,@object           # @3
.L__unnamed_4:
	.asciz	"_Z22total_atomic_coalescedPfS_i"
	.size	.L__unnamed_4, 32

	.type	.L__unnamed_5,@object           # @4
.L__unnamed_5:
	.asciz	"_Z23total_partial_reductionPfS_i"
	.size	.L__unnamed_5, 33

	.type	.L__unnamed_6,@object           # @5
.L__unnamed_6:
	.asciz	"_Z15total_reductionPfS_i"
	.size	.L__unnamed_6, 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	"Failed to run statement "
	.size	.Lstr, 25

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Not enough arguments"
	.size	.Lstr.1, 21

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Usage: reduction -i inputFile -o outputFile"
	.size	.Lstr.2, 44

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"Error reading file"
	.size	.Lstr.5, 19

	.type	.Lstr.6,@object                 # @str.6
.Lstr.6:
	.asciz	"The operation failed "
	.size	.Lstr.6, 22

	.type	.Lstr.7,@object                 # @str.7
.Lstr.7:
	.asciz	"The operation was successful "
	.size	.Lstr.7, 30

	.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 _Z31__device_stub__total_sequentialPfS_i
	.addrsig_sym _Z41__device_stub__total_sequential_coalescedPfS_i
	.addrsig_sym _Z27__device_stub__total_atomicPfS_i
	.addrsig_sym _Z37__device_stub__total_atomic_coalescedPfS_i
	.addrsig_sym _Z38__device_stub__total_partial_reductionPfS_i
	.addrsig_sym _Z30__device_stub__total_reductionPfS_i
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z16total_sequentialPfS_i
	.addrsig_sym _Z26total_sequential_coalescedPfS_i
	.addrsig_sym _Z12total_atomicPfS_i
	.addrsig_sym _Z22total_atomic_coalescedPfS_i
	.addrsig_sym _Z23total_partial_reductionPfS_i
	.addrsig_sym _Z15total_reductionPfS_i
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z16total_sequentialPfS_i ; -- Begin function _Z16total_sequentialPfS_i
	.globl	_Z16total_sequentialPfS_i
	.p2align	8
	.type	_Z16total_sequentialPfS_i,@function
_Z16total_sequentialPfS_i:              ; @_Z16total_sequentialPfS_i
; %bb.0:
	s_mov_b32 s2, exec_lo
	v_cmpx_eq_u32_e32 0, v0
	s_cbranch_execz .LBB0_6
; %bb.1:
	s_clause 0x1
	s_load_b32 s5, s[0:1], 0x18
	s_load_b32 s7, s[0:1], 0x10
	s_mov_b32 s4, s15
	s_waitcnt lgkmcnt(0)
	v_cvt_f32_u32_e32 v0, s5
	s_sub_i32 s3, 0, s5
	s_add_i32 s6, s7, s5
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_add_i32 s6, s6, -1
	v_rcp_iflag_f32_e32 v0, v0
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v0, 0x4f7ffffe, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_u32_f32_e32 v0, v0
	v_readfirstlane_b32 s2, v0
	v_mov_b32_e32 v0, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s3, s3, s2
	s_mul_hi_u32 s3, s2, s3
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s2, s2, s3
	s_mul_hi_u32 s8, s6, s2
	s_load_b128 s[0:3], s[0:1], 0x0
	s_mul_i32 s9, s8, s5
	s_delay_alu instid0(SALU_CYCLE_1)
	s_sub_i32 s6, s6, s9
	s_add_i32 s9, s8, 1
	s_sub_i32 s10, s6, s5
	s_cmp_ge_u32 s6, s5
	s_cselect_b32 s8, s9, s8
	s_cselect_b32 s6, s10, s6
	s_add_i32 s9, s8, 1
	s_cmp_ge_u32 s6, s5
	s_cselect_b32 s5, s9, s8
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s6, s5, s15
	s_add_i32 s5, s6, s5
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_min_i32 s5, s5, s7
	s_cmp_ge_i32 s6, s5
	s_cbranch_scc1 .LBB0_5
; %bb.2:                                ; %.lr.ph.preheader
	s_ashr_i32 s7, s6, 31
	v_mov_b32_e32 v0, 0
	s_lshl_b64 s[8:9], s[6:7], 2
	s_waitcnt lgkmcnt(0)
	s_add_u32 s0, s0, s8
	s_addc_u32 s1, s1, s9
.LBB0_3:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_load_b32 s7, s[0:1], 0x0
	s_delay_alu instid0(VALU_DEP_1)
	v_cvt_f32_i32_e32 v0, v0
	s_add_i32 s6, s6, 1
	s_add_u32 s0, s0, 4
	s_addc_u32 s1, s1, 0
	s_cmp_lt_i32 s6, s5
	s_waitcnt lgkmcnt(0)
	v_add_f32_e32 v0, s7, v0
	s_delay_alu instid0(VALU_DEP_1)
	v_cvt_i32_f32_e32 v0, v0
	s_cbranch_scc1 .LBB0_3
; %bb.4:                                ; %._crit_edge.loopexit
	s_delay_alu instid0(VALU_DEP_1)
	v_cvt_f32_i32_e32 v0, v0
.LBB0_5:                                ; %._crit_edge
	s_ashr_i32 s5, s4, 31
	v_mov_b32_e32 v1, 0
	s_waitcnt lgkmcnt(0)
	s_lshl_b64 s[0:1], s[4:5], 2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_u32 s0, s2, s0
	s_addc_u32 s1, s3, s1
	global_store_b32 v1, v0, s[0:1]
.LBB0_6:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z16total_sequentialPfS_i
		.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 2
		.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	_Z16total_sequentialPfS_i, .Lfunc_end0-_Z16total_sequentialPfS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 328
; NumSgprs: 16
; NumVgprs: 2
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 16
; NumVGPRsForWavesPerEU: 2
; 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	_Z26total_sequential_coalescedPfS_i ; -- Begin function _Z26total_sequential_coalescedPfS_i
	.globl	_Z26total_sequential_coalescedPfS_i
	.p2align	8
	.type	_Z26total_sequential_coalescedPfS_i,@function
_Z26total_sequential_coalescedPfS_i:    ; @_Z26total_sequential_coalescedPfS_i
; %bb.0:
	s_mov_b32 s3, exec_lo
	v_cmpx_eq_u32_e32 0, v0
	s_cbranch_execz .LBB1_6
; %bb.1:
	s_clause 0x1
	s_load_b32 s10, s[0:1], 0x10
	s_load_b128 s[4:7], s[0:1], 0x0
	v_mov_b32_e32 v0, 0
	s_mov_b32 s2, s15
	s_waitcnt lgkmcnt(0)
	s_cmp_ge_i32 s15, s10
	s_cbranch_scc1 .LBB1_5
; %bb.2:                                ; %.lr.ph.preheader
	s_load_b32 s0, s[0:1], 0x18
	s_ashr_i32 s3, s2, 31
	v_mov_b32_e32 v0, 0
	s_lshl_b64 s[8:9], s[2:3], 2
	s_waitcnt lgkmcnt(0)
	s_ashr_i32 s1, s0, 31
	s_add_u32 s4, s4, s8
	s_addc_u32 s5, s5, s9
	s_lshl_b64 s[8:9], s[0:1], 2
	s_mov_b32 s1, s2
.LBB1_3:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_load_b32 s3, s[4:5], 0x0
	s_delay_alu instid0(VALU_DEP_1)
	v_cvt_f32_i32_e32 v0, v0
	s_add_i32 s1, s1, s0
	s_add_u32 s4, s4, s8
	s_addc_u32 s5, s5, s9
	s_cmp_lt_i32 s1, s10
	s_waitcnt lgkmcnt(0)
	v_add_f32_e32 v0, s3, v0
	s_delay_alu instid0(VALU_DEP_1)
	v_cvt_i32_f32_e32 v0, v0
	s_cbranch_scc1 .LBB1_3
; %bb.4:                                ; %._crit_edge.loopexit
	s_delay_alu instid0(VALU_DEP_1)
	v_cvt_f32_i32_e32 v0, v0
.LBB1_5:                                ; %._crit_edge
	s_ashr_i32 s3, s2, 31
	v_mov_b32_e32 v1, 0
	s_lshl_b64 s[0:1], s[2:3], 2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_add_u32 s0, s6, s0
	s_addc_u32 s1, s7, s1
	global_store_b32 v1, v0, s[0:1]
.LBB1_6:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z26total_sequential_coalescedPfS_i
		.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 2
		.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_end1:
	.size	_Z26total_sequential_coalescedPfS_i, .Lfunc_end1-_Z26total_sequential_coalescedPfS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 200
; NumSgprs: 16
; NumVgprs: 2
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 1
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 16
; NumVGPRsForWavesPerEU: 2
; 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	_Z12total_atomicPfS_i   ; -- Begin function _Z12total_atomicPfS_i
	.globl	_Z12total_atomicPfS_i
	.p2align	8
	.type	_Z12total_atomicPfS_i,@function
_Z12total_atomicPfS_i:                  ; @_Z12total_atomicPfS_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x18
	s_load_b32 s3, s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	v_cvt_f32_u32_e32 v1, s2
	s_sub_i32 s6, 0, s2
	s_add_i32 s7, s3, s2
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	s_add_i32 s7, s7, -1
	v_rcp_iflag_f32_e32 v1, v1
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v1, 0x4f7ffffe, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_u32_f32_e32 v1, v1
	v_readfirstlane_b32 s5, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s6, s6, s5
	s_mul_hi_u32 s6, s5, s6
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s5, s5, s6
	s_mul_hi_u32 s5, s7, s5
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s6, s5, s2
	s_sub_i32 s6, s7, s6
	s_add_i32 s7, s5, 1
	s_sub_i32 s8, s6, s2
	s_cmp_ge_u32 s6, s2
	s_cselect_b32 s5, s7, s5
	s_cselect_b32 s6, s8, s6
	s_add_i32 s7, s5, 1
	s_cmp_ge_u32 s6, s2
	s_cselect_b32 s2, s7, s5
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s5, s2, 0x1ff
	s_ashr_i32 s6, s5, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshr_b32 s6, s6, 23
	s_add_i32 s5, s5, s6
	s_mul_i32 s6, s2, s15
	s_ashr_i32 s5, s5, 9
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_mad_i32_i24 v0, s5, v0, s6
	s_add_i32 s6, s6, s2
	s_mov_b32 s2, exec_lo
	v_add_nc_u32_e32 v1, s5, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_min3_i32 v3, s6, s3, v1
	s_mov_b32 s6, 0
	v_cmpx_lt_i32_e64 v0, v3
	s_cbranch_execz .LBB2_9
; %bb.1:                                ; %.lr.ph
	s_load_b128 s[0:3], s[0:1], 0x0
	s_mov_b32 s4, s15
	s_ashr_i32 s5, s15, 31
	v_mov_b32_e32 v4, 0
	s_lshl_b64 s[4:5], s[4:5], 2
	s_waitcnt lgkmcnt(0)
	s_add_u32 s2, s2, s4
	s_addc_u32 s3, s3, s5
.LBB2_2:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB2_3 Depth 2
                                        ;     Child Loop BB2_6 Depth 2
	v_ashrrev_i32_e32 v1, 31, v0
	v_bfrev_b32_e32 v5, 1
	s_mov_b32 s4, exec_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[1:2], 2, v[0:1]
	v_add_co_u32 v1, vcc_lo, s0, v1
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v2, vcc_lo, s1, v2, vcc_lo
	global_load_b32 v1, v[1:2], off
.LBB2_3:                                ; %ComputeLoop
                                        ;   Parent Loop BB2_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_ctz_i32_b32 s5, s4
	s_waitcnt vmcnt(0)
	v_readlane_b32 s7, v1, s5
	s_lshl_b32 s5, 1, s5
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_not1_b32 s4, s4, s5
	s_cmp_lg_u32 s4, 0
	s_delay_alu instid0(VALU_DEP_1)
	v_add_f32_e32 v5, s7, v5
	s_cbranch_scc1 .LBB2_3
; %bb.4:                                ; %ComputeEnd
                                        ;   in Loop: Header=BB2_2 Depth=1
	v_mbcnt_lo_u32_b32 v1, exec_lo, 0
	s_mov_b32 s4, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_eq_u32_e32 0, v1
	s_xor_b32 s4, exec_lo, s4
	s_cbranch_execz .LBB2_8
; %bb.5:                                ;   in Loop: Header=BB2_2 Depth=1
	global_load_b32 v2, v4, s[2:3]
	s_mov_b32 s5, 0
.LBB2_6:                                ; %atomicrmw.start
                                        ;   Parent Loop BB2_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v1, v2, v5
	global_atomic_cmpswap_b32 v1, v4, v[1:2], s[2:3] glc
	s_waitcnt vmcnt(0)
	v_cmp_eq_u32_e32 vcc_lo, v1, v2
	v_mov_b32_e32 v2, v1
	s_or_b32 s5, vcc_lo, s5
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s5
	s_cbranch_execnz .LBB2_6
; %bb.7:                                ; %Flow
                                        ;   in Loop: Header=BB2_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s5
.LBB2_8:                                ; %Flow30
                                        ;   in Loop: Header=BB2_2 Depth=1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	s_or_b32 exec_lo, exec_lo, s4
	v_add_nc_u32_e32 v0, 1, v0
	v_cmp_ge_i32_e32 vcc_lo, v0, v3
	s_or_b32 s6, vcc_lo, s6
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s6
	s_cbranch_execnz .LBB2_2
.LBB2_9:                                ; %._crit_edge
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12total_atomicPfS_i
		.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_end2:
	.size	_Z12total_atomicPfS_i, .Lfunc_end2-_Z12total_atomicPfS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 480
; 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
	.protected	_Z22total_atomic_coalescedPfS_i ; -- Begin function _Z22total_atomic_coalescedPfS_i
	.globl	_Z22total_atomic_coalescedPfS_i
	.p2align	8
	.type	_Z22total_atomic_coalescedPfS_i,@function
_Z22total_atomic_coalescedPfS_i:        ; @_Z22total_atomic_coalescedPfS_i
; %bb.0:
	s_load_b32 s6, s[0:1], 0x10
	s_mov_b32 s4, s15
	s_mov_b32 s2, exec_lo
	v_lshl_add_u32 v0, s4, 9, v0
	s_waitcnt lgkmcnt(0)
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e64 s6, v0
	s_cbranch_execz .LBB3_9
; %bb.1:                                ; %.lr.ph
	s_clause 0x1
	s_load_b32 s7, s[0:1], 0x18
	s_load_b128 s[0:3], s[0:1], 0x0
	s_ashr_i32 s5, s4, 31
	v_mov_b32_e32 v3, 0
	s_lshl_b64 s[8:9], s[4:5], 2
	s_mov_b32 s5, 0
	s_waitcnt lgkmcnt(0)
	s_lshl_b32 s4, s7, 9
	s_add_u32 s2, s2, s8
	s_addc_u32 s3, s3, s9
.LBB3_2:                                ; =>This Loop Header: Depth=1
                                        ;     Child Loop BB3_3 Depth 2
                                        ;     Child Loop BB3_6 Depth 2
	v_ashrrev_i32_e32 v1, 31, v0
	v_bfrev_b32_e32 v4, 1
	s_mov_b32 s7, exec_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[1:2], 2, v[0:1]
	v_add_co_u32 v1, vcc_lo, s0, v1
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v2, vcc_lo, s1, v2, vcc_lo
	global_load_b32 v1, v[1:2], off
.LBB3_3:                                ; %ComputeLoop
                                        ;   Parent Loop BB3_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_ctz_i32_b32 s8, s7
	s_waitcnt vmcnt(0)
	v_readlane_b32 s9, v1, s8
	s_lshl_b32 s8, 1, s8
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_not1_b32 s7, s7, s8
	s_cmp_lg_u32 s7, 0
	s_delay_alu instid0(VALU_DEP_1)
	v_add_f32_e32 v4, s9, v4
	s_cbranch_scc1 .LBB3_3
; %bb.4:                                ; %ComputeEnd
                                        ;   in Loop: Header=BB3_2 Depth=1
	v_mbcnt_lo_u32_b32 v1, exec_lo, 0
	s_mov_b32 s7, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_eq_u32_e32 0, v1
	s_xor_b32 s7, exec_lo, s7
	s_cbranch_execz .LBB3_8
; %bb.5:                                ;   in Loop: Header=BB3_2 Depth=1
	global_load_b32 v2, v3, s[2:3]
	s_mov_b32 s8, 0
.LBB3_6:                                ; %atomicrmw.start
                                        ;   Parent Loop BB3_2 Depth=1
                                        ; =>  This Inner Loop Header: Depth=2
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v1, v2, v4
	global_atomic_cmpswap_b32 v1, v3, v[1:2], s[2:3] glc
	s_waitcnt vmcnt(0)
	v_cmp_eq_u32_e32 vcc_lo, v1, v2
	v_mov_b32_e32 v2, v1
	s_or_b32 s8, vcc_lo, s8
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s8
	s_cbranch_execnz .LBB3_6
; %bb.7:                                ; %Flow
                                        ;   in Loop: Header=BB3_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s8
.LBB3_8:                                ; %Flow20
                                        ;   in Loop: Header=BB3_2 Depth=1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	s_or_b32 exec_lo, exec_lo, s7
	v_add_nc_u32_e32 v0, s4, v0
	v_cmp_le_i32_e32 vcc_lo, s6, v0
	s_or_b32 s5, vcc_lo, s5
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s5
	s_cbranch_execnz .LBB3_2
.LBB3_9:                                ; %._crit_edge
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z22total_atomic_coalescedPfS_i
		.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 5
		.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_end3:
	.size	_Z22total_atomic_coalescedPfS_i, .Lfunc_end3-_Z22total_atomic_coalescedPfS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 312
; NumSgprs: 18
; NumVgprs: 5
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 5
; 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	_Z23total_partial_reductionPfS_i ; -- Begin function _Z23total_partial_reductionPfS_i
	.globl	_Z23total_partial_reductionPfS_i
	.p2align	8
	.type	_Z23total_partial_reductionPfS_i,@function
_Z23total_partial_reductionPfS_i:       ; @_Z23total_partial_reductionPfS_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s3, s[0:1], 0x10
	s_load_b128 s[4:7], s[0:1], 0x0
	s_lshl_b32 s8, s15, 9
	v_lshlrev_b32_e32 v3, 2, v0
	v_dual_mov_b32 v4, 0 :: v_dual_add_nc_u32 v5, s8, v0
	s_mov_b32 s2, s15
	s_mov_b32 s10, exec_lo
	ds_store_b32 v3, v4
	s_waitcnt lgkmcnt(0)
	v_cmpx_gt_i32_e64 s3, v5
	s_cbranch_execz .LBB4_4
; %bb.1:                                ; %.lr.ph.preheader
	s_load_b32 s0, s[0:1], 0x18
	s_ashr_i32 s1, s8, 31
	v_add_co_u32 v1, s8, s8, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e64 v2, null, s1, 0, s8
	s_mov_b32 s1, 0
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v1, vcc_lo, s4, v1
	v_add_co_ci_u32_e32 v2, vcc_lo, s5, v2, vcc_lo
	s_waitcnt lgkmcnt(0)
	s_lshl_b32 s8, s0, 9
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_ashr_i32 s9, s8, 31
	s_lshl_b64 s[4:5], s[8:9], 2
.LBB4_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	global_load_b32 v6, v[1:2], off
	v_add_nc_u32_e32 v5, s8, v5
	v_add_co_u32 v1, vcc_lo, v1, s4
	v_add_co_ci_u32_e32 v2, vcc_lo, s5, v2, vcc_lo
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v4, v6, v4
	v_cmp_le_i32_e64 s0, s3, v5
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_or_b32 s1, s0, s1
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB4_2
; %bb.3:                                ; %._crit_edge
	s_or_b32 exec_lo, exec_lo, s1
	ds_store_b32 v3, v4
.LBB4_4:                                ; %Flow40
	s_or_b32 exec_lo, exec_lo, s10
	s_mov_b32 s0, 0
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_mov_b32 s1, exec_lo
	v_cmpx_eq_u32_e32 0, v0
	s_cbranch_execz .LBB4_8
; %bb.5:                                ; %.preheader.preheader
	v_mov_b32_e32 v0, 0
.LBB4_6:                                ; %.preheader
                                        ; =>This Inner Loop Header: Depth=1
	v_mov_b32_e32 v1, s0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_cvt_f32_i32_e32 v0, v0
	s_add_i32 s0, s0, 4
	s_cmpk_lg_i32 s0, 0x800
	ds_load_b32 v1, v1
	s_waitcnt lgkmcnt(0)
	v_add_f32_e32 v0, v1, v0
	s_delay_alu instid0(VALU_DEP_1)
	v_cvt_i32_f32_e32 v0, v0
	s_cbranch_scc1 .LBB4_6
; %bb.7:
	s_ashr_i32 s3, s2, 31
	s_delay_alu instid0(VALU_DEP_1)
	v_cvt_f32_i32_e32 v0, v0
	s_lshl_b64 s[0:1], s[2:3], 2
	v_mov_b32_e32 v1, 0
	s_add_u32 s0, s6, s0
	s_addc_u32 s1, s7, s1
	global_store_b32 v1, v0, s[0:1]
.LBB4_8:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z23total_partial_reductionPfS_i
		.amdhsa_group_segment_fixed_size 2048
		.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 7
		.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_end4:
	.size	_Z23total_partial_reductionPfS_i, .Lfunc_end4-_Z23total_partial_reductionPfS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 352
; NumSgprs: 18
; NumVgprs: 7
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 2048 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 7
; 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	_Z15total_reductionPfS_i ; -- Begin function _Z15total_reductionPfS_i
	.globl	_Z15total_reductionPfS_i
	.p2align	8
	.type	_Z15total_reductionPfS_i,@function
_Z15total_reductionPfS_i:               ; @_Z15total_reductionPfS_i
; %bb.0:
	s_clause 0x1
	s_load_b32 s3, s[0:1], 0x10
	s_load_b128 s[4:7], s[0:1], 0x0
	s_mov_b32 s2, s15
	v_dual_mov_b32 v5, 0 :: v_dual_lshlrev_b32 v4, 2, v0
	v_lshl_or_b32 v1, s2, 10, v0
	s_mov_b32 s10, exec_lo
	ds_store_b32 v4, v5
	s_waitcnt lgkmcnt(0)
	v_cmpx_gt_i32_e64 s3, v1
	s_cbranch_execz .LBB5_4
; %bb.1:                                ; %.lr.ph.preheader
	s_load_b32 s0, s[0:1], 0x18
	v_ashrrev_i32_e32 v2, 31, v1
	s_mov_b32 s1, 0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[2:3], 2, v[1:2]
	v_add_co_u32 v2, vcc_lo, v2, s4
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_ci_u32_e32 v3, vcc_lo, s5, v3, vcc_lo
	v_add_co_u32 v2, vcc_lo, 0x800, v2
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	v_add_co_ci_u32_e32 v3, vcc_lo, 0, v3, vcc_lo
	s_waitcnt lgkmcnt(0)
	s_lshl_b32 s4, s0, 10
	s_ashr_i32 s5, s4, 31
	s_delay_alu instid0(SALU_CYCLE_1)
	s_lshl_b64 s[8:9], s[4:5], 2
.LBB5_2:                                ; %.lr.ph
                                        ; =>This Inner Loop Header: Depth=1
	s_clause 0x1
	global_load_b32 v6, v[2:3], off offset:-2048
	global_load_b32 v7, v[2:3], off
	v_add_nc_u32_e32 v1, s4, v1
	v_add_co_u32 v2, vcc_lo, v2, s8
	v_add_co_ci_u32_e32 v3, vcc_lo, s9, v3, vcc_lo
	s_waitcnt vmcnt(0)
	v_add_f32_e32 v6, v6, v7
	v_cmp_le_i32_e64 s0, s3, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_f32_e32 v5, v5, v6
	s_or_b32 s1, s0, s1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB5_2
; %bb.3:                                ; %._crit_edge
	s_or_b32 exec_lo, exec_lo, s1
	ds_store_b32 v4, v5
.LBB5_4:                                ; %Flow
	s_or_b32 exec_lo, exec_lo, s10
	s_movk_i32 s0, 0x100
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
.LBB5_5:                                ; =>This Inner Loop Header: Depth=1
	s_mov_b32 s1, exec_lo
	v_cmpx_gt_u32_e64 s0, v0
	s_cbranch_execz .LBB5_7
; %bb.6:                                ;   in Loop: Header=BB5_5 Depth=1
	v_lshl_add_u32 v1, s0, 2, v4
	ds_load_b32 v1, v1
	ds_load_b32 v2, v4
	s_waitcnt lgkmcnt(0)
	v_add_f32_e32 v1, v1, v2
	ds_store_b32 v4, v1
.LBB5_7:                                ;   in Loop: Header=BB5_5 Depth=1
	s_or_b32 exec_lo, exec_lo, s1
	s_lshr_b32 s1, s0, 1
	s_cmp_gt_u32 s0, 1
	s_mov_b32 s0, s1
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_cbranch_scc1 .LBB5_5
; %bb.8:
	s_mov_b32 s0, exec_lo
	v_cmpx_eq_u32_e32 0, v0
	s_cbranch_execz .LBB5_10
; %bb.9:
	v_mov_b32_e32 v0, 0
	s_ashr_i32 s3, s2, 31
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_lshl_b64 s[0:1], s[2:3], 2
	s_add_u32 s0, s6, s0
	ds_load_b32 v1, v0
	s_addc_u32 s1, s7, s1
	s_waitcnt lgkmcnt(0)
	global_store_b32 v0, v1, s[0:1]
.LBB5_10:
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z15total_reductionPfS_i
		.amdhsa_group_segment_fixed_size 2048
		.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 8
		.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_end5:
	.size	_Z15total_reductionPfS_i, .Lfunc_end5-_Z15total_reductionPfS_i
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 424
; NumSgprs: 18
; NumVgprs: 8
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 2048 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 8
; 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
      - .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:           _Z16total_sequentialPfS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     16
    .sgpr_spill_count: 0
    .symbol:         _Z16total_sequentialPfS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     2
    .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
      - .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:           _Z26total_sequential_coalescedPfS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     16
    .sgpr_spill_count: 0
    .symbol:         _Z26total_sequential_coalescedPfS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     2
    .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
      - .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:           _Z12total_atomicPfS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z12total_atomicPfS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     6
    .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
      - .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:           _Z22total_atomic_coalescedPfS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z22total_atomic_coalescedPfS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     5
    .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
      - .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: 2048
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z23total_partial_reductionPfS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z23total_partial_reductionPfS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     7
    .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
      - .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: 2048
    .kernarg_segment_align: 8
    .kernarg_segment_size: 280
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z15total_reductionPfS_i
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z15total_reductionPfS_i.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     8
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
