#include <iostream>
#include <stdio.h>
#include <stdlib.h>

#define BLOCK_WIDTH 256

__global__ void histogram(char *d_array_in, int *d_array_out, int n)
{
    __shared__ int shared_bin[128];

    int i, index, blocks, iterations;

    blocks = (n - 1) / BLOCK_WIDTH + 1; 
    iterations = 127 / (blocks * BLOCK_WIDTH) + 1;

    for (i = 0; i < iterations; i++) 
    {
        index = (blockIdx.x + i * blocks) * blockDim.x + threadIdx.x;

        if (index < 128)
        {
            d_array_out[index] = 0; 
        }
    }

    iterations = 127 / BLOCK_WIDTH + 1; 

    for (i = 0; i < iterations; i++)
    {
        index = i * blockDim.x + threadIdx.x;

        if (index < 128)
        {
            shared_bin[index] = 0; 
        }

        __syncthreads(); 
    }

    index = blockIdx.x * blockDim.x + threadIdx.x; 

    if (index < n)
    {
        atomicAdd(&shared_bin[d_array_in[index]], 1); 
    }

    __syncthreads();

    for (i = 0; i < iterations; i++) 
    {
        index = i * blockDim.x + threadIdx.x;

        if (index < 128)
        {
            atomicAdd(&d_array_out[index], shared_bin[index]); 
        }

        __syncthreads(); 
    }

    return;
}

int main(int argc, char *argv[])
{
    bool input_check = false;
    bool expected_check = false;
    bool output_check = false;
    bool error_present = false;
    bool expect_output = false;
    bool output_pass;

    char input_file_name[256];
    char expected_file_name[256];
    char output_file_name[256];

    FILE *input_file = NULL;
    FILE *expected_file = NULL;
    FILE *output_file = NULL;

    char *h_array_in = NULL;
    int *h_array_out = NULL;
    char *d_array_in = NULL;
    int *d_array_out = NULL;
    int *expectedOutput = NULL;

    int i, n, num_bins, dataset_no;

 

    for (i = 1; i < argc; i++)
    {
        if (strcmp(argv[i], "-i") == 0 && argc > i + 1)
        {
            if (argv[i + 1][0] != '-')
            {
                input_check = true;

                strcpy(input_file_name, argv[i + 1]);
            }
        }

        if (strcmp(argv[i], "-e") == 0 && argc > i + 1)
        {
            if (argv[i + 1][0] != '-')
            {
                expected_check = true;

                strcpy(expected_file_name, argv[i + 1]);
            }
        }

        if (strcmp(argv[i], "-o") == 0)
        {
            expect_output = true;

            if (argc > i + 1)
            {
                if (argv[i + 1][0] != '-')
                {
                    output_check = true;

                    strcpy(output_file_name, argv[i + 1]);
                }
            }
        }
    }

    if (!input_check)
    {
        std::cout << "Execution command syntax error: \"Input\" filename required" << std::endl;

        error_present = true;
    }
    else
    {
        input_file = fopen(input_file_name, "r");

        if (!input_file)
        {
            std::cout << "Error: File " << input_file_name << " does not exist" << std::endl;

            error_present = true;
        }
    }

    if (!expected_check)
    {
        std::cout << "Execution command syntax error: \"Expected Output\" filename required" << std::endl;

        error_present = true;
    }
    else
    {
        expected_file = fopen(expected_file_name, "r");

        if (!expected_file)
        {
            std::cout << "Error: File " << expected_file_name << " does not exist" << std::endl;

            error_present = true;
        }
    }

    if (!output_check && expect_output)
    {
        std::cout << "Execution Command Syntax Warning: \"Output\" filename expected" << std::endl;
    }
    else if (output_check)
    {
        output_file = fopen(output_file_name, "w");
    }

    if (error_present)
    {
        std::cout << "Use the following command to run the program:\n\n"
                     "./<program> ­-e <expected> -­i <input> ­-o <output>\n\n"
                     "Where <expected> is the expected output file, <input> is the input dataset files, and <output> is an optional path to store the results"
                  << std::endl;
    }
    else
    {
        dataset_no = 0;

        while (true)
        {
          
            h_array_in = (char *)malloc(1024 * sizeof(char));

            if (fgets(h_array_in, 1024, input_file) == NULL)
            {
                break;
            }

            for (n = 0; h_array_in[n] != '\n'; n++)
            {
                continue;
            }

            h_array_in[n] = '\0';

            if (fscanf(expected_file, "%d", &num_bins) == -1)
            {
                break;
            }

            expectedOutput = (int *)malloc(num_bins * sizeof(int));

            for (i = 0; i < num_bins; i++)
            {
                fscanf(expected_file, "%d", &expectedOutput[i]);
            }

            h_array_out = (int *)malloc(128 * sizeof(int));

            
            cudaMalloc((void **)&d_array_in, n * sizeof(char));
            cudaMalloc((void **)&d_array_out, 128 * sizeof(int));

            
            cudaMemcpy(d_array_in, h_array_in, n * sizeof(char), cudaMemcpyHostToDevice);

            
            dim3 blocks((n - 1) / BLOCK_WIDTH + 1);
            dim3 threads_per_block(BLOCK_WIDTH); 

            
            histogram<<<blocks, threads_per_block>>>(d_array_in, d_array_out, n);

           
            cudaMemcpy(h_array_out, d_array_out, 128 * sizeof(int), cudaMemcpyDeviceToHost);

            
            if (output_check)
            {
                fprintf(output_file, "%d", 128);

                for (i = 0; i < num_bins; i++)
                {
                    fprintf(output_file, "\n%d", h_array_out[i]);
                }

                fprintf(output_file, "\n");

                fflush(output_file);
            }

           
            output_pass = true;
            for (i = 0; i < 128; i++)
            {
                if (expectedOutput[i] != h_array_out[i])
                {
                    output_pass = false;
                }
            }

            if (output_pass)
            {
                std::cout << "Dataset " << dataset_no << " PASSED" << std::endl;
            }
            else
            {
                std::cout << "Dataset " << dataset_no << " FAILED" << std::endl;
            }

            dataset_no++;

          
            cudaFree(d_array_in);
            cudaFree(d_array_out);

            free(h_array_in);
            free(h_array_out);
            free(expectedOutput);
        }

        if (output_check)
        {
            std::cout << "Results stored in " << output_file_name << std::endl;
        }

        fclose(input_file);
        fclose(expected_file);

        if (output_check)
        {
            fclose(output_file);
        }
    }

    return 0;
}

	.file	"tmpxft_00355f80_00000000-6_q2.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3638:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3638:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.type	_ZNSolsEPFRSoS_E.isra.0, @function
_ZNSolsEPFRSoS_E.isra.0:
.LFB4292:
	.cfi_startproc
	jmp	*%rsi
	.cfi_endproc
.LFE4292:
	.size	_ZNSolsEPFRSoS_E.isra.0, .-_ZNSolsEPFRSoS_E.isra.0
	.globl	_Z31__device_stub__Z9histogramPcPiiPcPii
	.type	_Z31__device_stub__Z9histogramPcPiiPcPii, @function
_Z31__device_stub__Z9histogramPcPiiPcPii:
.LFB3660:
	.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	.L3
	pushq	40(%rsp)
	.cfi_def_cfa_offset 152
	leaq	_Z9histogramPcPii(%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
.L3:
	movq	120(%rsp), %rax
	subq	%fs:40, %rax
	je	.L5
	call	__stack_chk_fail@PLT
.L5:
	addq	$136, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3660:
	.size	_Z31__device_stub__Z9histogramPcPiiPcPii, .-_Z31__device_stub__Z9histogramPcPiiPcPii
	.globl	_Z9histogramPcPii
	.type	_Z9histogramPcPii, @function
_Z9histogramPcPii:
.LFB3661:
	.cfi_startproc
	endbr64
	jmp	_Z31__device_stub__Z9histogramPcPiiPcPii
	.cfi_endproc
.LFE3661:
	.size	_Z9histogramPcPii, .-_Z9histogramPcPii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"-i"
.LC1:
	.string	"-e"
.LC2:
	.string	"-o"
.LC3:
	.string	"Execution command syntax error: \"Input\" filename required"
.LC4:
	.string	"r"
.LC5:
	.string	"Error: File "
.LC6:
	.string	" does not exist"
.LC7:
	.string	"Execution command syntax error: \"Expected Output\" filename required"
.LC8:
	.string	"Execution Command Syntax Warning: \"Output\" filename expected"
.LC9:
	.string	"w"
.LC10:
	.string	"Use the following command to run the program:\n\n./<program> \302\255-e <expected> -\302\255i <input> \302\255-o <output>\n\nWhere <expected> is the expected output file, <input> is the input dataset files, and <output> is an optional path to store the results"
.LC11:
	.string	"%d"
.LC12:
	.string	"\n%d"
.LC13:
	.string	"\n"
.LC14:
	.string	"Dataset "
.LC15:
	.string	" PASSED"
.LC16:
	.string	" FAILED"
.LC17:
	.string	"Results stored in "
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3635:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%ecx, %ecx
	xorl	%r15d, %r15d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	xorl	%r14d, %r14d
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%rsi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	$2, %ebx
	subq	$872, %rsp
	.cfi_def_cfa_offset 928
	movq	%fs:40, %rax
	movq	%rax, 856(%rsp)
	xorl	%eax, %eax
	movq	%rcx, 48(%rsp)
	movq	%rcx, 56(%rsp)
	movb	$0, 12(%rsp)
.L10:
	leal	-1(%rbx), %eax
	cmpl	%eax, %r12d
	jle	.L67
	movq	-8(%r13,%rbx,8), %rax
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movq	%rax, (%rsp)
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L11
	cmpl	%ebx, %r12d
	jle	.L11
	movq	0(%r13,%rbx,8), %rsi
	cmpb	$45, (%rsi)
	je	.L11
	leaq	88(%rsp), %rdi
	movl	$256, %edx
	movb	$1, %bpl
	call	__strcpy_chk@PLT
.L11:
	movq	(%rsp), %rdi
	leaq	.LC1(%rip), %rsi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L12
	cmpl	%ebx, %r12d
	jle	.L12
	movq	0(%r13,%rbx,8), %rsi
	cmpb	$45, (%rsi)
	je	.L12
	leaq	344(%rsp), %rdi
	movl	$256, %edx
	call	__strcpy_chk@PLT
	movb	$1, 12(%rsp)
.L12:
	movq	(%rsp), %rdi
	leaq	.LC2(%rip), %rsi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L13
	movb	$1, %r14b
	cmpl	%ebx, %r12d
	jle	.L13
	movq	0(%r13,%rbx,8), %rsi
	cmpb	$45, (%rsi)
	je	.L13
	leaq	600(%rsp), %rdi
	movl	$256, %edx
	movb	$1, %r15b
	call	__strcpy_chk@PLT
.L13:
	incq	%rbx
	jmp	.L10
.L67:
	testb	%bpl, %bpl
	jne	.L15
	leaq	.LC3(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	xorl	%ebx, %ebx
	movb	$1, %bpl
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	jmp	.L16
.L15:
	leaq	88(%rsp), %r12
	leaq	.LC4(%rip), %rsi
	movq	%r12, %rdi
	call	fopen@PLT
	movq	%rax, %rbx
	testq	%rax, %rax
	jne	.L41
	leaq	.LC5(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%r12, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC6(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	jmp	.L16
.L41:
	xorl	%ebp, %ebp
.L16:
	cmpb	$0, 12(%rsp)
	jne	.L17
	leaq	.LC7(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	xorl	%r13d, %r13d
	movb	$1, %bpl
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	jmp	.L18
.L17:
	leaq	344(%rsp), %r12
	leaq	.LC4(%rip), %rsi
	movq	%r12, %rdi
	call	fopen@PLT
	movq	%rax, %r13
	testq	%rax, %rax
	jne	.L18
	leaq	.LC5(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%r12, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC6(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movb	12(%rsp), %bpl
.L18:
	testb	%r15b, %r15b
	jne	.L21
	testb	%r14b, %r14b
	je	.L19
	leaq	.LC8(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	jmp	.L20
.L19:
	testb	%r15b, %r15b
	jne	.L21
.L20:
	xorl	%edx, %edx
	movq	%rdx, (%rsp)
	jmp	.L22
.L21:
	leaq	600(%rsp), %rdi
	leaq	.LC9(%rip), %rsi
	call	fopen@PLT
	movq	%rax, (%rsp)
.L22:
	xorl	%eax, %eax
	movl	%eax, 12(%rsp)
	testb	%bpl, %bpl
	je	.L23
	leaq	.LC10(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	jmp	.L24
.L69:
	movq	(%rsp), %rdi
	leaq	.LC13(%rip), %rdx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	movq	(%rsp), %rdi
	call	fflush@PLT
.L30:
	xorl	%eax, %eax
	movb	$1, %dl
	xorl	%ecx, %ecx
.L34:
	movq	16(%rsp), %rsi
	movl	(%r14,%rax), %edi
	cmpl	%edi, (%rsi,%rax)
	cmovne	%ecx, %edx
	addq	$4, %rax
	cmpq	$512, %rax
	jne	.L34
	testb	%dl, %dl
	leaq	_ZSt4cout(%rip), %rdi
	leaq	.LC14(%rip), %rsi
	je	.L35
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	12(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC15(%rip), %rsi
	movq	%rax, %rdi
.L66:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movq	48(%rsp), %rdi
	incl	12(%rsp)
	call	cudaFree@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	%r14, %rdi
	call	free@PLT
	movq	16(%rsp), %rdi
	call	free@PLT
.L23:
	movl	$1024, %edi
	call	malloc@PLT
	movq	%rbx, %rcx
	movl	$1024, %edx
	movl	$1024, %esi
	movq	%rax, %rdi
	movq	%rax, %r12
	call	__fgets_chk@PLT
	testq	%rax, %rax
	je	.L25
	xorl	%eax, %eax
.L26:
	movq	%rax, %rbp
	leaq	1(%rax), %rax
	cmpb	$10, (%r12,%rbp)
	jne	.L26
	movb	$0, (%r12,%rbp)
	xorl	%eax, %eax
	leaq	44(%rsp), %rdx
	movq	%r13, %rdi
	leaq	.LC11(%rip), %rsi
	call	__isoc23_fscanf@PLT
	incl	%eax
	je	.L25
	movslq	44(%rsp), %rdi
	xorl	%r14d, %r14d
	salq	$2, %rdi
	call	malloc@PLT
	movq	%rax, 16(%rsp)
	movq	%rax, %rdx
.L27:
	cmpl	%r14d, 44(%rsp)
	jle	.L68
	leaq	.LC11(%rip), %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	incl	%r14d
	movq	%rdx, 24(%rsp)
	call	__isoc23_fscanf@PLT
	movq	24(%rsp), %rdx
	addq	$4, %rdx
	jmp	.L27
.L68:
	movl	$512, %edi
	movl	%ebp, 24(%rsp)
	call	malloc@PLT
	leaq	48(%rsp), %rdi
	movq	%rbp, %rsi
	movq	%rax, %r14
	call	cudaMalloc@PLT
	leaq	56(%rsp), %rdi
	movl	$512, %esi
	call	cudaMalloc@PLT
	movq	48(%rsp), %rdi
	movq	%rbp, %rdx
	movq	%r12, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	leal	-1(%rbp), %eax
	movl	$256, %ecx
	xorl	%r9d, %r9d
	cltd
	xorl	%r8d, %r8d
	idivl	%ecx
	movl	$16777217, %edx
	movl	$1, %ecx
	salq	$8, %rdx
	incl	%eax
	movl	%eax, 64(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 68(%rsp)
	movq	64(%rsp), %rdi
	movl	72(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L29
	movl	24(%rsp), %edx
	movq	56(%rsp), %rsi
	movq	48(%rsp), %rdi
	call	_Z31__device_stub__Z9histogramPcPiiPcPii
.L29:
	movq	56(%rsp), %rsi
	movl	$2, %ecx
	movl	$512, %edx
	movq	%r14, %rdi
	call	cudaMemcpy@PLT
	testb	%r15b, %r15b
	je	.L30
	movq	(%rsp), %rdi
	movl	$128, %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	leaq	.LC11(%rip), %rdx
	xorl	%ebp, %ebp
	call	__fprintf_chk@PLT
.L31:
	cmpl	%ebp, 44(%rsp)
	jle	.L69
	movl	(%r14,%rbp,4), %ecx
	movq	(%rsp), %rdi
	movl	$2, %esi
	xorl	%eax, %eax
	leaq	.LC12(%rip), %rdx
	incq	%rbp
	call	__fprintf_chk@PLT
	jmp	.L31
.L35:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movl	12(%rsp), %esi
	movq	%rax, %rdi
	call	_ZNSolsEi@PLT
	leaq	.LC16(%rip), %rsi
	movq	%rax, %rdi
	jmp	.L66
.L25:
	testb	%r15b, %r15b
	je	.L37
	leaq	.LC17(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	600(%rsp), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
.L37:
	movq	%rbx, %rdi
	call	fclose@PLT
	movq	%r13, %rdi
	call	fclose@PLT
	testb	%r15b, %r15b
	je	.L24
	movq	(%rsp), %rdi
	call	fclose@PLT
.L24:
	movq	856(%rsp), %rax
	subq	%fs:40, %rax
	je	.L38
	call	__stack_chk_fail@PLT
.L38:
	addq	$872, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3635:
	.size	main, .-main
	.section	.rodata.str1.1
.LC18:
	.string	"_Z9histogramPcPii"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3663:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC18(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z9histogramPcPii(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 48
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3663:
	.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
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

#define BLOCK_WIDTH 256

__global__ void histogram(char *d_array_in, int *d_array_out, int n)
{
    __shared__ int shared_bin[128];

    int i, index, blocks, iterations;

    blocks = (n - 1) / BLOCK_WIDTH + 1; 
    iterations = 127 / (blocks * BLOCK_WIDTH) + 1;

    for (i = 0; i < iterations; i++) 
    {
        index = (blockIdx.x + i * blocks) * blockDim.x + threadIdx.x;

        if (index < 128)
        {
            d_array_out[index] = 0; 
        }
    }

    iterations = 127 / BLOCK_WIDTH + 1; 

    for (i = 0; i < iterations; i++)
    {
        index = i * blockDim.x + threadIdx.x;

        if (index < 128)
        {
            shared_bin[index] = 0; 
        }

        __syncthreads(); 
    }

    index = blockIdx.x * blockDim.x + threadIdx.x; 

    if (index < n)
    {
        atomicAdd(&shared_bin[d_array_in[index]], 1); 
    }

    __syncthreads();

    for (i = 0; i < iterations; i++) 
    {
        index = i * blockDim.x + threadIdx.x;

        if (index < 128)
        {
            atomicAdd(&d_array_out[index], shared_bin[index]); 
        }

        __syncthreads(); 
    }

    return;
}

int main(int argc, char *argv[])
{
    bool input_check = false;
    bool expected_check = false;
    bool output_check = false;
    bool error_present = false;
    bool expect_output = false;
    bool output_pass;

    char input_file_name[256];
    char expected_file_name[256];
    char output_file_name[256];

    FILE *input_file = NULL;
    FILE *expected_file = NULL;
    FILE *output_file = NULL;

    char *h_array_in = NULL;
    int *h_array_out = NULL;
    char *d_array_in = NULL;
    int *d_array_out = NULL;
    int *expectedOutput = NULL;

    int i, n, num_bins, dataset_no;

 

    for (i = 1; i < argc; i++)
    {
        if (strcmp(argv[i], "-i") == 0 && argc > i + 1)
        {
            if (argv[i + 1][0] != '-')
            {
                input_check = true;

                strcpy(input_file_name, argv[i + 1]);
            }
        }

        if (strcmp(argv[i], "-e") == 0 && argc > i + 1)
        {
            if (argv[i + 1][0] != '-')
            {
                expected_check = true;

                strcpy(expected_file_name, argv[i + 1]);
            }
        }

        if (strcmp(argv[i], "-o") == 0)
        {
            expect_output = true;

            if (argc > i + 1)
            {
                if (argv[i + 1][0] != '-')
                {
                    output_check = true;

                    strcpy(output_file_name, argv[i + 1]);
                }
            }
        }
    }

    if (!input_check)
    {
        std::cout << "Execution command syntax error: \"Input\" filename required" << std::endl;

        error_present = true;
    }
    else
    {
        input_file = fopen(input_file_name, "r");

        if (!input_file)
        {
            std::cout << "Error: File " << input_file_name << " does not exist" << std::endl;

            error_present = true;
        }
    }

    if (!expected_check)
    {
        std::cout << "Execution command syntax error: \"Expected Output\" filename required" << std::endl;

        error_present = true;
    }
    else
    {
        expected_file = fopen(expected_file_name, "r");

        if (!expected_file)
        {
            std::cout << "Error: File " << expected_file_name << " does not exist" << std::endl;

            error_present = true;
        }
    }

    if (!output_check && expect_output)
    {
        std::cout << "Execution Command Syntax Warning: \"Output\" filename expected" << std::endl;
    }
    else if (output_check)
    {
        output_file = fopen(output_file_name, "w");
    }

    if (error_present)
    {
        std::cout << "Use the following command to run the program:\n\n"
                     "./<program> ­-e <expected> -­i <input> ­-o <output>\n\n"
                     "Where <expected> is the expected output file, <input> is the input dataset files, and <output> is an optional path to store the results"
                  << std::endl;
    }
    else
    {
        dataset_no = 0;

        while (true)
        {
          
            h_array_in = (char *)malloc(1024 * sizeof(char));

            if (fgets(h_array_in, 1024, input_file) == NULL)
            {
                break;
            }

            for (n = 0; h_array_in[n] != '\n'; n++)
            {
                continue;
            }

            h_array_in[n] = '\0';

            if (fscanf(expected_file, "%d", &num_bins) == -1)
            {
                break;
            }

            expectedOutput = (int *)malloc(num_bins * sizeof(int));

            for (i = 0; i < num_bins; i++)
            {
                fscanf(expected_file, "%d", &expectedOutput[i]);
            }

            h_array_out = (int *)malloc(128 * sizeof(int));

            
            hipMalloc((void **)&d_array_in, n * sizeof(char));
            hipMalloc((void **)&d_array_out, 128 * sizeof(int));

            
            hipMemcpy(d_array_in, h_array_in, n * sizeof(char), hipMemcpyHostToDevice);

            
            dim3 blocks((n - 1) / BLOCK_WIDTH + 1);
            dim3 threads_per_block(BLOCK_WIDTH); 

            
            histogram<<<blocks, threads_per_block>>>(d_array_in, d_array_out, n);

           
            hipMemcpy(h_array_out, d_array_out, 128 * sizeof(int), hipMemcpyDeviceToHost);

            
            if (output_check)
            {
                fprintf(output_file, "%d", 128);

                for (i = 0; i < num_bins; i++)
                {
                    fprintf(output_file, "\n%d", h_array_out[i]);
                }

                fprintf(output_file, "\n");

                fflush(output_file);
            }

           
            output_pass = true;
            for (i = 0; i < 128; i++)
            {
                if (expectedOutput[i] != h_array_out[i])
                {
                    output_pass = false;
                }
            }

            if (output_pass)
            {
                std::cout << "Dataset " << dataset_no << " PASSED" << std::endl;
            }
            else
            {
                std::cout << "Dataset " << dataset_no << " FAILED" << std::endl;
            }

            dataset_no++;

          
            hipFree(d_array_in);
            hipFree(d_array_out);

            free(h_array_in);
            free(h_array_out);
            free(expectedOutput);
        }

        if (output_check)
        {
            std::cout << "Results stored in " << output_file_name << std::endl;
        }

        fclose(input_file);
        fclose(expected_file);

        if (output_check)
        {
            fclose(output_file);
        }
    }

    return 0;
}

	.text
	.file	"q2.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	_Z24__device_stub__histogramPcPii # -- Begin function _Z24__device_stub__histogramPcPii
	.type	_Z24__device_stub__histogramPcPii,@function
_Z24__device_stub__histogramPcPii:      # @_Z24__device_stub__histogramPcPii
	.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	$_Z9histogramPcPii, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z24__device_stub__histogramPcPii, .Lfunc_end0-_Z24__device_stub__histogramPcPii
	.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	$856, %rsp                      # imm = 0x358
	.cfi_def_cfa_offset 912
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	xorl	%ecx, %ecx
	movq	%rcx, 48(%rsp)
	xorl	%eax, %eax
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	movq	%rcx, 40(%rsp)
	movb	$1, %r12b
	movb	$1, %r14b
	movb	$1, %r15b
	cmpl	$2, %edi
	jl	.LBB1_17
# %bb.1:                                # %.lr.ph.preheader
	movq	%rsi, %rbx
	movl	%edi, %r15d
	movl	$1, %r12d
	subq	%r15, %r12
	movl	$2, %r14d
	movl	$0, 16(%rsp)                    # 4-byte Folded Spill
	movl	$0, 12(%rsp)                    # 4-byte Folded Spill
	xorl	%eax, %eax
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	xorl	%ebp, %ebp
.LBB1_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	-8(%rbx,%r14,8), %r13
	movl	$.L.str, %esi
	movq	%r13, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB1_6
# %bb.3:                                #   in Loop: Header=BB1_2 Depth=1
	cmpq	%r15, %r14
	jae	.LBB1_6
# %bb.4:                                #   in Loop: Header=BB1_2 Depth=1
	movq	(%rbx,%r14,8), %rsi
	cmpb	$45, (%rsi)
	je	.LBB1_6
# %bb.5:                                #   in Loop: Header=BB1_2 Depth=1
	leaq	592(%rsp), %rdi
	callq	strcpy
	movb	$1, %al
	movl	%eax, 16(%rsp)                  # 4-byte Spill
.LBB1_6:                                #   in Loop: Header=BB1_2 Depth=1
	movl	$.L.str.1, %esi
	movq	%r13, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB1_10
# %bb.7:                                #   in Loop: Header=BB1_2 Depth=1
	cmpq	%r15, %r14
	jae	.LBB1_10
# %bb.8:                                #   in Loop: Header=BB1_2 Depth=1
	movq	(%rbx,%r14,8), %rsi
	cmpb	$45, (%rsi)
	je	.LBB1_10
# %bb.9:                                #   in Loop: Header=BB1_2 Depth=1
	leaq	336(%rsp), %rdi
	callq	strcpy
	movb	$1, %al
	movl	%eax, 12(%rsp)                  # 4-byte Spill
.LBB1_10:                               #   in Loop: Header=BB1_2 Depth=1
	movl	$.L.str.2, %esi
	movq	%r13, %rdi
	callq	strcmp
	testl	%eax, %eax
	jne	.LBB1_14
# %bb.11:                               #   in Loop: Header=BB1_2 Depth=1
	movb	$1, %bpl
	cmpq	%r15, %r14
	jae	.LBB1_14
# %bb.12:                               #   in Loop: Header=BB1_2 Depth=1
	movq	(%rbx,%r14,8), %rsi
	cmpb	$45, (%rsi)
	je	.LBB1_14
# %bb.13:                               #   in Loop: Header=BB1_2 Depth=1
	leaq	80(%rsp), %rdi
	callq	strcpy
	movb	$1, %bpl
	movb	$1, %al
	movq	%rax, 32(%rsp)                  # 8-byte Spill
.LBB1_14:                               # %._crit_edge161
                                        #   in Loop: Header=BB1_2 Depth=1
	leaq	(%r12,%r14), %rax
	incq	%rax
	incq	%r14
	cmpq	$2, %rax
	jne	.LBB1_2
# %bb.15:                               # %._crit_edge
	movl	12(%rsp), %ebx                  # 4-byte Reload
	testb	$1, %bl
	sete	%r14b
	movq	32(%rsp), %rax                  # 8-byte Reload
	andb	$1, %al
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	testb	$1, %bpl
	sete	%r15b
	testb	$1, 16(%rsp)                    # 1-byte Folded Reload
	jne	.LBB1_18
# %bb.16:
	movb	$1, %r12b
.LBB1_17:                               # %._crit_edge.thread
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
	movl	$57, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	xorl	%eax, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	testb	%r14b, %r14b
	je	.LBB1_23
.LBB1_20:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.7, %esi
	movl	$67, %edx
	jmp	.LBB1_26
.LBB1_18:
	leaq	592(%rsp), %rdi
	movl	$.L.str.4, %esi
	callq	fopen
	movq	%rax, %rcx
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	testq	%rax, %rax
	movb	$1, %r12b
	je	.LBB1_19
# %bb.21:
	testb	$1, %bl
	je	.LBB1_20
# %bb.22:
	xorl	%r12d, %r12d
	jmp	.LBB1_23
.LBB1_19:
	movl	$_ZSt4cout, %r14d
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$12, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	%ebx, %ebp
	leaq	592(%rsp), %rbx
	movq	%rbx, %rdi
	callq	strlen
	movl	$_ZSt4cout, %edi
	movq	%rbx, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	movl	$15, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	xorl	%eax, %eax
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	testb	$1, %bpl
	je	.LBB1_20
.LBB1_23:
	leaq	336(%rsp), %rdi
	movl	$.L.str.4, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB1_25
# %bb.24:
	movq	%rax, %rbp
	jmp	.LBB1_27
.LBB1_25:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.5, %esi
	movl	$12, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	leaq	336(%rsp), %rbx
	movq	%rbx, %rdi
	callq	strlen
	movl	$_ZSt4cout, %edi
	movq	%rbx, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	movl	$15, %edx
.LBB1_26:                               # %.sink.split
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movl	$_ZSt4cout, %ecx
	movq	-24(%rax), %rdi
	addq	%rcx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movb	$1, %r12b
	xorl	%ebp, %ebp
.LBB1_27:
	cmpb	$0, 32(%rsp)                    # 1-byte Folded Reload
	jne	.LBB1_30
# %bb.28:
	testb	%r15b, %r15b
	jne	.LBB1_30
# %bb.29:
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.8, %esi
	movl	$60, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	jmp	.LBB1_31
.LBB1_30:
	cmpb	$0, 32(%rsp)                    # 1-byte Folded Reload
	je	.LBB1_31
# %bb.32:
	leaq	80(%rsp), %rdi
	movl	$.L.str.9, %esi
	callq	fopen
	jmp	.LBB1_33
.LBB1_31:
	xorl	%eax, %eax
.LBB1_33:
	testb	%r12b, %r12b
	je	.LBB1_34
# %bb.57:
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.10, %esi
	movl	$238, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	jmp	.LBB1_56
.LBB1_34:                               # %.preheader125
	movq	%rax, 56(%rsp)                  # 8-byte Spill
	movl	$1024, %edi                     # imm = 0x400
	callq	malloc
	movq	%rax, %r12
	movq	%rax, %rdi
	movl	$1024, %esi                     # imm = 0x400
	movq	16(%rsp), %rdx                  # 8-byte Reload
	callq	fgets
	testq	%rax, %rax
	je	.LBB1_52
# %bb.35:                               # %.preheader.preheader
	movabsq	$4294967296, %rax               # imm = 0x100000000
	addq	$256, %rax                      # imm = 0x100
	movq	%rax, 72(%rsp)                  # 8-byte Spill
	movl	$0, 12(%rsp)                    # 4-byte Folded Spill
	movq	%rbp, 64(%rsp)                  # 8-byte Spill
.LBB1_36:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_37 Depth 2
                                        #     Child Loop BB1_41 Depth 2
                                        #     Child Loop BB1_47 Depth 2
                                        #     Child Loop BB1_50 Depth 2
	movq	$-1, %r13
.LBB1_37:                               #   Parent Loop BB1_36 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	cmpb	$10, 1(%r12,%r13)
	leaq	1(%r13), %r13
	jne	.LBB1_37
# %bb.38:                               #   in Loop: Header=BB1_36 Depth=1
	movb	$0, (%r12,%r13)
	movl	$.L.str.11, %esi
	movq	%rbp, %rdi
	leaq	28(%rsp), %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	cmpl	$-1, %eax
	je	.LBB1_52
# %bb.39:                               #   in Loop: Header=BB1_36 Depth=1
	movslq	28(%rsp), %r14
	leaq	(,%r14,4), %rdi
	callq	malloc
	movq	%rax, %rbx
	testq	%r14, %r14
	jle	.LBB1_42
# %bb.40:                               # %.lr.ph138.preheader
                                        #   in Loop: Header=BB1_36 Depth=1
	movq	%rbp, %r15
	movq	%rbx, %rbp
	xorl	%r14d, %r14d
.LBB1_41:                               # %.lr.ph138
                                        #   Parent Loop BB1_36 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	$.L.str.11, %esi
	movq	%r15, %rdi
	movq	%rbp, %rdx
	xorl	%eax, %eax
	callq	__isoc23_fscanf
	incq	%r14
	movslq	28(%rsp), %rax
	addq	$4, %rbp
	cmpq	%rax, %r14
	jl	.LBB1_41
.LBB1_42:                               # %._crit_edge139
                                        #   in Loop: Header=BB1_36 Depth=1
	movl	$512, %edi                      # imm = 0x200
	callq	malloc
	movq	%rax, %rbp
	leaq	48(%rsp), %rdi
	movq	%r13, %rsi
	callq	hipMalloc
	movl	$512, %esi                      # imm = 0x200
	leaq	40(%rsp), %rdi
	callq	hipMalloc
	movq	48(%rsp), %rdi
	movq	%r12, %rsi
	movq	%r13, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	leal	-1(%r13), %eax
	leal	254(%r13), %edi
	testl	%eax, %eax
	cmovnsl	%eax, %edi
	sarl	$8, %edi
	incl	%edi
	movabsq	$4294967296, %rax               # imm = 0x100000000
	orq	%rax, %rdi
	movl	$1, %esi
	movq	72(%rsp), %rdx                  # 8-byte Reload
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB1_44
# %bb.43:                               #   in Loop: Header=BB1_36 Depth=1
	movq	48(%rsp), %rdi
	movq	40(%rsp), %rsi
	movl	%r13d, %edx
	callq	_Z24__device_stub__histogramPcPii
.LBB1_44:                               #   in Loop: Header=BB1_36 Depth=1
	movq	40(%rsp), %rsi
	movl	$512, %edx                      # imm = 0x200
	movq	%rbp, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	cmpb	$0, 32(%rsp)                    # 1-byte Folded Reload
	je	.LBB1_49
# %bb.45:                               #   in Loop: Header=BB1_36 Depth=1
	movl	$.L.str.11, %esi
	movq	56(%rsp), %r13                  # 8-byte Reload
	movq	%r13, %rdi
	movl	$128, %edx
	xorl	%eax, %eax
	callq	fprintf
	cmpl	$0, 28(%rsp)
	jle	.LBB1_48
# %bb.46:                               # %.lr.ph142.preheader
                                        #   in Loop: Header=BB1_36 Depth=1
	xorl	%r14d, %r14d
.LBB1_47:                               # %.lr.ph142
                                        #   Parent Loop BB1_36 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%rbp,%r14,4), %edx
	movl	$.L.str.12, %esi
	movq	%r13, %rdi
	xorl	%eax, %eax
	callq	fprintf
	incq	%r14
	movslq	28(%rsp), %rax
	cmpq	%rax, %r14
	jl	.LBB1_47
.LBB1_48:                               # %._crit_edge143
                                        #   in Loop: Header=BB1_36 Depth=1
	movl	$10, %edi
	movq	%r13, %rsi
	callq	fputc@PLT
	movq	%r13, %rdi
	callq	fflush
.LBB1_49:                               # %.preheader190
                                        #   in Loop: Header=BB1_36 Depth=1
	movb	$1, %r14b
	xorl	%eax, %eax
	xorl	%edx, %edx
.LBB1_50:                               #   Parent Loop BB1_36 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	(%rbx,%rax,4), %ecx
	cmpl	(%rbp,%rax,4), %ecx
	movzbl	%r14b, %r14d
	cmovnel	%edx, %r14d
	incq	%rax
	cmpq	$128, %rax
	jne	.LBB1_50
# %bb.51:                               #   in Loop: Header=BB1_36 Depth=1
	movl	$_ZSt4cout, %edi
	movl	$.L.str.14, %esi
	movl	$8, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movl	$_ZSt4cout, %edi
	movl	12(%rsp), %r15d                 # 4-byte Reload
	movl	%r15d, %esi
	callq	_ZNSolsEi
	movq	%rax, %r13
	testb	$1, %r14b
	movl	$.L.str.15, %esi
	movl	$.L.str.16, %eax
	cmoveq	%rax, %rsi
	movl	$7, %edx
	movq	%r13, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%r13), %rax
	movq	-24(%rax), %rdi
	addq	%r13, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movq	%r13, %rdi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	incl	%r15d
	movl	%r15d, 12(%rsp)                 # 4-byte Spill
	movq	48(%rsp), %rdi
	callq	hipFree
	movq	40(%rsp), %rdi
	callq	hipFree
	movq	%r12, %rdi
	callq	free
	movq	%rbp, %rdi
	callq	free
	movq	%rbx, %rdi
	callq	free
	movl	$1024, %edi                     # imm = 0x400
	callq	malloc
	movq	%rax, %r12
	movq	%rax, %rdi
	movl	$1024, %esi                     # imm = 0x400
	movq	16(%rsp), %rdx                  # 8-byte Reload
	callq	fgets
	testq	%rax, %rax
	movq	64(%rsp), %rbp                  # 8-byte Reload
	jne	.LBB1_36
.LBB1_52:                               # %._crit_edge147
	cmpb	$0, 32(%rsp)                    # 1-byte Folded Reload
	je	.LBB1_54
# %bb.53:
	movl	$_ZSt4cout, %r14d
	movl	$_ZSt4cout, %edi
	movl	$.L.str.17, %esi
	movl	$18, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	leaq	80(%rsp), %rbx
	movq	%rbx, %rdi
	callq	strlen
	movl	$_ZSt4cout, %edi
	movq	%rbx, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movq	16(%rsp), %rdi                  # 8-byte Reload
	callq	fclose
	movq	%rbp, %rdi
	callq	fclose
	movq	56(%rsp), %rdi                  # 8-byte Reload
	jmp	.LBB1_55
.LBB1_54:                               # %.critedge
	movq	16(%rsp), %rdi                  # 8-byte Reload
	callq	fclose
	movq	%rbp, %rdi
.LBB1_55:
	callq	fclose
.LBB1_56:
	xorl	%eax, %eax
	addq	$856, %rsp                      # imm = 0x358
	.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_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB2_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB2_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z9histogramPcPii, %esi
	movl	$.L__unnamed_1, %edx
	movl	$.L__unnamed_1, %ecx
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end2:
	.size	__hip_module_ctor, .Lfunc_end2-__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	.LBB3_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
.LBB3_2:
	retq
.Lfunc_end3:
	.size	__hip_module_dtor, .Lfunc_end3-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z9histogramPcPii,@object       # @_Z9histogramPcPii
	.section	.rodata,"a",@progbits
	.globl	_Z9histogramPcPii
	.p2align	3, 0x0
_Z9histogramPcPii:
	.quad	_Z24__device_stub__histogramPcPii
	.size	_Z9histogramPcPii, 8

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

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"-e"
	.size	.L.str.1, 3

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

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"Execution command syntax error: \"Input\" filename required"
	.size	.L.str.3, 58

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

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"Error: File "
	.size	.L.str.5, 13

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	" does not exist"
	.size	.L.str.6, 16

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"Execution command syntax error: \"Expected Output\" filename required"
	.size	.L.str.7, 68

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"Execution Command Syntax Warning: \"Output\" filename expected"
	.size	.L.str.8, 61

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

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"Use the following command to run the program:\n\n./<program> \302\255-e <expected> -\302\255i <input> \302\255-o <output>\n\nWhere <expected> is the expected output file, <input> is the input dataset files, and <output> is an optional path to store the results"
	.size	.L.str.10, 239

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

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

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"Dataset "
	.size	.L.str.14, 9

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	" PASSED"
	.size	.L.str.15, 8

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	" FAILED"
	.size	.L.str.16, 8

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"Results stored in "
	.size	.L.str.17, 19

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z9histogramPcPii"
	.size	.L__unnamed_1, 18

	.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

	.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 _Z24__device_stub__histogramPcPii
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z9histogramPcPii
	.addrsig_sym _ZSt4cout
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z9histogramPcPii       ; -- Begin function _Z9histogramPcPii
	.globl	_Z9histogramPcPii
	.p2align	8
	.type	_Z9histogramPcPii,@function
_Z9histogramPcPii:                      ; @_Z9histogramPcPii
; %bb.0:                                ; %.lr.ph
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x10
	s_load_b32 s3, s[0:1], 0x24
	v_mov_b32_e32 v3, 0
	s_waitcnt lgkmcnt(0)
	s_add_i32 s4, s2, -1
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_ashr_i32 s5, s4, 31
	s_lshr_b32 s5, s5, 24
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s4, s4, s5
	s_ashr_i32 s4, s4, 8
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s8, s4, 1
	s_lshl_b32 s4, s8, 8
	s_bfe_i32 s9, s8, 0x10017
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s4, s4, s9
	s_xor_b32 s10, s4, s9
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cvt_f32_u32_e32 v1, s10
	s_sub_i32 s5, 0, s10
	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 s4, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s5, s5, s4
	s_mul_hi_u32 s5, s4, s5
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_add_i32 s4, s4, s5
	s_mul_hi_u32 s11, s4, 0x7f
	s_delay_alu instid0(SALU_CYCLE_1)
	s_mul_i32 s4, s11, s10
	s_add_i32 s13, s11, 1
	s_sub_i32 s12, 0x7f, s4
	s_load_b128 s[4:7], s[0:1], 0x0
	s_sub_i32 s14, s12, s10
	s_cmp_ge_u32 s12, s10
	s_cselect_b32 s11, s13, s11
	s_cselect_b32 s12, s14, s12
	s_add_i32 s13, s11, 1
	s_cmp_ge_u32 s12, s10
	s_cselect_b32 s10, s13, s11
	s_delay_alu instid0(SALU_CYCLE_1)
	s_xor_b32 s10, s10, s9
	s_add_u32 s0, s0, 24
	s_addc_u32 s1, s1, 0
	s_and_b32 s11, s3, 0xffff
	s_sub_i32 s3, s10, s9
	v_mad_u64_u32 v[1:2], null, s15, s11, v[0:1]
	s_add_i32 s3, s3, 1
	s_mul_i32 s8, s8, s11
.LBB0_1:                                ; =>This Inner Loop Header: Depth=1
	s_mov_b32 s9, exec_lo
	s_delay_alu instid0(VALU_DEP_1)
	v_cmpx_gt_i32_e32 0x80, v1
	s_cbranch_execz .LBB0_3
; %bb.2:                                ;   in Loop: Header=BB0_1 Depth=1
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[4:5], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v4, vcc_lo, s6, v4
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v5, vcc_lo, s7, v5, vcc_lo
	global_store_b32 v[4:5], v3, off
.LBB0_3:                                ;   in Loop: Header=BB0_1 Depth=1
	s_or_b32 exec_lo, exec_lo, s9
	v_add_nc_u32_e32 v1, s8, v1
	s_add_i32 s3, s3, -1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_cmp_lg_u32 s3, 0
	s_cbranch_scc1 .LBB0_1
; %bb.4:                                ; %._crit_edge
	s_load_b32 s0, s[0:1], 0xc
	v_cmp_gt_u32_e32 vcc_lo, 0x80, v0
	v_lshlrev_b32_e32 v3, 2, v0
	s_and_saveexec_b32 s1, vcc_lo
	s_cbranch_execz .LBB0_6
; %bb.5:
	v_mov_b32_e32 v1, 0
	ds_store_b32 v3, v1
.LBB0_6:                                ; %.critedge
	s_or_b32 exec_lo, exec_lo, s1
	s_waitcnt lgkmcnt(0)
	s_and_b32 s0, 0xffff, s0
	s_mov_b32 s1, exec_lo
	v_mad_u64_u32 v[1:2], null, s15, s0, v[0:1]
	s_delay_alu instid0(VALU_DEP_1)
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	v_cmpx_gt_i32_e64 s2, v1
	s_cbranch_execz .LBB0_8
; %bb.7:
	v_ashrrev_i32_e32 v2, 31, v1
	v_add_co_u32 v0, s0, s4, v1
	s_delay_alu instid0(VALU_DEP_1)
	v_add_co_ci_u32_e64 v1, s0, s5, v2, s0
	global_load_i8 v0, v[0:1], off
	s_waitcnt vmcnt(0)
	v_dual_mov_b32 v1, 1 :: v_dual_lshlrev_b32 v0, 2, v0
	ds_add_u32 v0, v1
.LBB0_8:                                ; %.critedge34
	s_or_b32 exec_lo, exec_lo, s1
	s_waitcnt lgkmcnt(0)
	s_barrier
	buffer_gl0_inv
	s_and_saveexec_b32 s0, vcc_lo
	s_cbranch_execz .LBB0_10
; %bb.9:
	ds_load_b32 v0, v3
	s_waitcnt lgkmcnt(0)
	global_atomic_add_u32 v3, v0, s[6:7]
.LBB0_10:
	s_or_b32 exec_lo, exec_lo, s0
	s_waitcnt_vscnt null, 0x0
	s_barrier
	buffer_gl0_inv
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z9histogramPcPii
		.amdhsa_group_segment_fixed_size 512
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 280
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 6
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z9histogramPcPii, .Lfunc_end0-_Z9histogramPcPii
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 568
; NumSgprs: 18
; NumVgprs: 6
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 512 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 6
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

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

	.end_amdgpu_metadata
