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

#define DCTSIZE 8
#define CENTERJSAMPLE 128
#define PASS1_BITS 2
#define CONST_BITS 13
#define ONE	((INT32) 1)

#define FIX_0_298631336  ((INT32)  2446)	/* FIX(0.298631336) */
#define FIX_0_390180644  ((INT32)  3196)	/* FIX(0.390180644) */
#define FIX_0_541196100  ((INT32)  4433)	/* FIX(0.541196100) */
#define FIX_0_765366865  ((INT32)  6270)	/* FIX(0.765366865) */
#define FIX_0_899976223  ((INT32)  7373)	/* FIX(0.899976223) */
#define FIX_1_175875602  ((INT32)  9633)	/* FIX(1.175875602) */
#define FIX_1_501321110  ((INT32)  12299)	/* FIX(1.501321110) */
#define FIX_1_847759065  ((INT32)  15137)	/* FIX(1.847759065) */
#define FIX_1_961570560  ((INT32)  16069)	/* FIX(1.961570560) */
#define FIX_2_053119869  ((INT32)  16819)	/* FIX(2.053119869) */
#define FIX_2_562915447  ((INT32)  20995)	/* FIX(2.562915447) */
#define FIX_3_072711026  ((INT32)  25172)	/* FIX(3.072711026) */

#define RIGHT_SHIFT(x,shft)	((x) >> (shft))
#define GETJSAMPLE(value)  ((int) (value))
#define MULTIPLY16C16(var,const)  ((var) * (const))
#define MULTIPLY(var,const)  MULTIPLY16C16(var,const)

typedef int DCTELEM;
typedef long INT32;


// #define TOTAL_FUNC_CALL 49761
#define TOTAL_FUNC_CALL 4969077
char *str_islow = "islow function";
int *elemd, *dataptrd;
int numOfThreads = 4;
int numOfBlocks = 2;
int batchSize = DCTSIZE*DCTSIZE*sizeof(int);

void readFile(int *elem){
    FILE *fp;
    char *line;
    size_t len = 0;
    int ctr = 0, iter = 0;
    int *elemptr;
    // fp = fopen("./data_small.txt", "r");
    fp = fopen("./data_large.txt", "r");

    printf("start reading file...\n");
    elemptr = elem;
    while(getline(&line, &len, fp) != -1){
        if(strstr(line, str_islow) != NULL){
            iter++;
            if(iter % 1000 == 0)
                printf("%s", line);
            ctr = DCTSIZE;
        }
        else{
            if(ctr != 0){
                ctr--;
                sscanf(line, "elemptr[0]=%d,elemptr[1]=%d,elemptr[2]=%d,elemptr[3]=%d,elemptr[4]=%d,elemptr[5]=%d,elemptr[6]=%d,elemptr[7]=%d\n",
                        &elemptr[0], &elemptr[1], &elemptr[2], &elemptr[3], &elemptr[4], &elemptr[5], &elemptr[6], &elemptr[7]);
                elemptr += DCTSIZE;     // jump 8 elements
            }
            else{
                continue;
            }
        }
    }
    printf("done reading file\n");
}

void printFile(int *elemptr, DCTELEM *dataptr){
    int *e_p, *d_p;
    for(int i = 0 ; i<TOTAL_FUNC_CALL ; i++){
        fprintf(stderr, "%dth islow function\n", i+1);
        int ctr;
        e_p = elemptr;
        for(ctr = 0 ; ctr<DCTSIZE ; ctr++){
            fprintf(stderr, "elemptr[0]=%d,", (int)e_p[0]);
            fprintf(stderr, "elemptr[1]=%d,", (int)e_p[1]);
            fprintf(stderr, "elemptr[2]=%d,", (int)e_p[2]);
            fprintf(stderr, "elemptr[3]=%d,", (int)e_p[3]);
            fprintf(stderr, "elemptr[4]=%d,", (int)e_p[4]);
            fprintf(stderr, "elemptr[5]=%d,", (int)e_p[5]);
            fprintf(stderr, "elemptr[6]=%d,", (int)e_p[6]);
            fprintf(stderr, "elemptr[7]=%d\n", (int)e_p[7]);

            e_p += DCTSIZE;
        }
        d_p = dataptr;
        for(ctr = 0 ; ctr<DCTSIZE ; ctr++){
            fprintf(stderr, "dataptr[0]=%d,", d_p[DCTSIZE*0]);
            fprintf(stderr, "dataptr[1]=%d,", d_p[DCTSIZE*1]);
            fprintf(stderr, "dataptr[2]=%d,", d_p[DCTSIZE*2]);
            fprintf(stderr, "dataptr[3]=%d,", d_p[DCTSIZE*3]);
            fprintf(stderr, "dataptr[4]=%d,", d_p[DCTSIZE*4]);
            fprintf(stderr, "dataptr[5]=%d,", d_p[DCTSIZE*5]);
            fprintf(stderr, "dataptr[6]=%d,", d_p[DCTSIZE*6]);
            fprintf(stderr, "dataptr[7]=%d\n", d_p[DCTSIZE*7]);

            d_p += 1;
        }
        elemptr += DCTSIZE*DCTSIZE;
        dataptr += DCTSIZE*DCTSIZE;
    }
}

__global__ void islow_cuda_1(int *elemptrd, int *dataptrd){
    INT32 tmp0, tmp1, tmp2, tmp3;
    INT32 tmp10, tmp11, tmp12, tmp13;
    INT32 z1;

    int ID = blockIdx.x * blockDim.x + threadIdx.x;
    elemptrd += ID * DCTSIZE;
    dataptrd += ID * DCTSIZE;

    tmp0 = GETJSAMPLE(elemptrd[0]) + GETJSAMPLE(elemptrd[7]);
    tmp1 = GETJSAMPLE(elemptrd[1]) + GETJSAMPLE(elemptrd[6]);
    tmp2 = GETJSAMPLE(elemptrd[2]) + GETJSAMPLE(elemptrd[5]);
    tmp3 = GETJSAMPLE(elemptrd[3]) + GETJSAMPLE(elemptrd[4]);

    tmp10 = tmp0 + tmp3;
    tmp12 = tmp0 - tmp3;
    tmp11 = tmp1 + tmp2;
    tmp13 = tmp1 - tmp2;

    tmp0 = GETJSAMPLE(elemptrd[0]) - GETJSAMPLE(elemptrd[7]);
    tmp1 = GETJSAMPLE(elemptrd[1]) - GETJSAMPLE(elemptrd[6]);
    tmp2 = GETJSAMPLE(elemptrd[2]) - GETJSAMPLE(elemptrd[5]);
    tmp3 = GETJSAMPLE(elemptrd[3]) - GETJSAMPLE(elemptrd[4]);

    dataptrd[0] = (DCTELEM) ((tmp10 + tmp11 - 8 * CENTERJSAMPLE) << PASS1_BITS);
    dataptrd[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS);

    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);       /* c6 */
    
    z1 += ONE << (CONST_BITS-PASS1_BITS-1);
    
    dataptrd[2] = (DCTELEM)
        RIGHT_SHIFT(z1 + MULTIPLY(tmp12, FIX_0_765366865), /* c2-c6 */
        CONST_BITS-PASS1_BITS);
    dataptrd[6] = (DCTELEM)
        RIGHT_SHIFT(z1 - MULTIPLY(tmp13, FIX_1_847759065), /* c2+c6 */
        CONST_BITS-PASS1_BITS);
    
    tmp12 = tmp0 + tmp2;
    tmp13 = tmp1 + tmp3;

    z1 = MULTIPLY(tmp12 + tmp13, FIX_1_175875602);       /*  c3 */
    /* Add fudge factor here for final descale. */
    z1 += ONE << (CONST_BITS-PASS1_BITS-1);

    tmp12 = MULTIPLY(tmp12, - FIX_0_390180644);          /* -c3+c5 */
    tmp13 = MULTIPLY(tmp13, - FIX_1_961570560);          /* -c3-c5 */
    tmp12 += z1;
    tmp13 += z1;

    z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223);       /* -c3+c7 */
    tmp0 = MULTIPLY(tmp0, FIX_1_501321110);              /*  c1+c3-c5-c7 */
    tmp3 = MULTIPLY(tmp3, FIX_0_298631336);              /* -c1+c3+c5-c7 */
    tmp0 += z1 + tmp12;
    tmp3 += z1 + tmp13;

    z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447);       /* -c1-c3 */
    tmp1 = MULTIPLY(tmp1, FIX_3_072711026);              /*  c1+c3+c5-c7 */
    tmp2 = MULTIPLY(tmp2, FIX_2_053119869);              /*  c1+c3-c5+c7 */
    tmp1 += z1 + tmp13;
    tmp2 += z1 + tmp12;

    dataptrd[1] = (DCTELEM) RIGHT_SHIFT(tmp0, CONST_BITS-PASS1_BITS);
    dataptrd[3] = (DCTELEM) RIGHT_SHIFT(tmp1, CONST_BITS-PASS1_BITS);
    dataptrd[5] = (DCTELEM) RIGHT_SHIFT(tmp2, CONST_BITS-PASS1_BITS);
    dataptrd[7] = (DCTELEM) RIGHT_SHIFT(tmp3, CONST_BITS-PASS1_BITS);
}

__global__ void islow_cuda_2(int *dataptrd){
    INT32 tmp0, tmp1, tmp2, tmp3;
    INT32 tmp10, tmp11, tmp12, tmp13;
    INT32 z1;

    int ID = blockIdx.x * blockDim.x + threadIdx.x;
    dataptrd += ID;

    tmp0 = dataptrd[DCTSIZE*0] + dataptrd[DCTSIZE*7];
    tmp1 = dataptrd[DCTSIZE*1] + dataptrd[DCTSIZE*6];
    tmp2 = dataptrd[DCTSIZE*2] + dataptrd[DCTSIZE*5];
    tmp3 = dataptrd[DCTSIZE*3] + dataptrd[DCTSIZE*4];

    /* Add fudge factor here for final descale. */
    tmp10 = tmp0 + tmp3 + (ONE << (PASS1_BITS-1));
    tmp12 = tmp0 - tmp3;
    tmp11 = tmp1 + tmp2;
    tmp13 = tmp1 - tmp2;

    tmp0 = dataptrd[DCTSIZE*0] - dataptrd[DCTSIZE*7];
    tmp1 = dataptrd[DCTSIZE*1] - dataptrd[DCTSIZE*6];
    tmp2 = dataptrd[DCTSIZE*2] - dataptrd[DCTSIZE*5];
    tmp3 = dataptrd[DCTSIZE*3] - dataptrd[DCTSIZE*4];

    dataptrd[DCTSIZE*0] = (DCTELEM) RIGHT_SHIFT(tmp10 + tmp11, PASS1_BITS);
    dataptrd[DCTSIZE*4] = (DCTELEM) RIGHT_SHIFT(tmp10 - tmp11, PASS1_BITS);

    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);       /* c6 */
    /* Add fudge factor here for final descale. */
    z1 += ONE << (CONST_BITS+PASS1_BITS-1);

    dataptrd[DCTSIZE*2] = (DCTELEM)
    RIGHT_SHIFT(z1 + MULTIPLY(tmp12, FIX_0_765366865), /* c2-c6 */
        CONST_BITS+PASS1_BITS);
    dataptrd[DCTSIZE*6] = (DCTELEM)
    RIGHT_SHIFT(z1 - MULTIPLY(tmp13, FIX_1_847759065), /* c2+c6 */
        CONST_BITS+PASS1_BITS);

    tmp12 = tmp0 + tmp2;
    tmp13 = tmp1 + tmp3;

    z1 = MULTIPLY(tmp12 + tmp13, FIX_1_175875602);       /*  c3 */
    /* Add fudge factor here for final descale. */
    z1 += ONE << (CONST_BITS+PASS1_BITS-1);

    tmp12 = MULTIPLY(tmp12, - FIX_0_390180644);          /* -c3+c5 */
    tmp13 = MULTIPLY(tmp13, - FIX_1_961570560);          /* -c3-c5 */
    tmp12 += z1;
    tmp13 += z1;

    z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223);       /* -c3+c7 */
    tmp0 = MULTIPLY(tmp0, FIX_1_501321110);              /*  c1+c3-c5-c7 */
    tmp3 = MULTIPLY(tmp3, FIX_0_298631336);              /* -c1+c3+c5-c7 */
    tmp0 += z1 + tmp12;
    tmp3 += z1 + tmp13;

    z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447);       /* -c1-c3 */
    tmp1 = MULTIPLY(tmp1, FIX_3_072711026);              /*  c1+c3+c5-c7 */
    tmp2 = MULTIPLY(tmp2, FIX_2_053119869);              /*  c1+c3-c5+c7 */
    tmp1 += z1 + tmp13;
    tmp2 += z1 + tmp12;

    dataptrd[DCTSIZE*1] = (DCTELEM) RIGHT_SHIFT(tmp0, CONST_BITS+PASS1_BITS);
    dataptrd[DCTSIZE*3] = (DCTELEM) RIGHT_SHIFT(tmp1, CONST_BITS+PASS1_BITS);
    dataptrd[DCTSIZE*5] = (DCTELEM) RIGHT_SHIFT(tmp2, CONST_BITS+PASS1_BITS);
    dataptrd[DCTSIZE*7] = (DCTELEM) RIGHT_SHIFT(tmp3, CONST_BITS+PASS1_BITS);
}

// feed 8*8 elements at a time
void func_islow(int *elemptr, DCTELEM * dataptr){
    cudaMemcpy(elemd, elemptr, batchSize, cudaMemcpyHostToDevice);

    islow_cuda_1<<<numOfBlocks, numOfThreads>>>(elemd, dataptrd);
    islow_cuda_2<<<numOfBlocks, numOfThreads>>>(dataptrd);

    cudaMemcpy(dataptr, dataptrd, batchSize, cudaMemcpyDeviceToHost);
}



int main(void){

    freopen("./data_self_cuda.txt", "w", stderr);
    int size = TOTAL_FUNC_CALL*DCTSIZE*DCTSIZE*(sizeof(int));
    int *elem = (int *)malloc(size);
    int *dataptr = (int *)malloc(size);
    int *elem_start, *dataptr_start;

    clock_t start, end;
    double time_used = 0;

    readFile(elem);

    cudaMalloc(&elemd, batchSize);
    cudaMalloc(&dataptrd, batchSize);

    elem_start = elem;
    dataptr_start = dataptr;
    printf("start processing data\n");
    start = clock();
    for(int i = 0 ; i<TOTAL_FUNC_CALL ; i++){
        func_islow(elem, dataptr);
        elem += DCTSIZE*DCTSIZE;
        dataptr += DCTSIZE*DCTSIZE;
    }
    end = clock();
    time_used += ((double)(end - start)) / CLOCKS_PER_SEC;
    printf("done processing data\n");
    printf("time used:%lfs\n", time_used);

    printFile(elem_start, dataptr_start);


    return 0;
}

	.file	"tmpxft_003a1d21_00000000-6_jpeg_fdct_islow_cuda_inner.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2033:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2033:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"r"
.LC1:
	.string	"./data_large.txt"
.LC2:
	.string	"start reading file...\n"
.LC3:
	.string	"%s"
.LC4:
	.string	"elemptr[0]=%d,elemptr[1]=%d,elemptr[2]=%d,elemptr[3]=%d,elemptr[4]=%d,elemptr[5]=%d,elemptr[6]=%d,elemptr[7]=%d\n"
.LC5:
	.string	"done reading file\n"
	.text
	.globl	_Z8readFilePi
	.type	_Z8readFilePi, @function
_Z8readFilePi:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rsi
	leaq	.LC4(%rip), %r15
	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
	xorl	%r12d, %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
	movq	%rdi, %rbx
	leaq	.LC1(%rip), %rdi
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	xorl	%eax, %eax
	movq	%rax, 16(%rsp)
	call	fopen@PLT
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	movq	%rax, %r13
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L3:
	leaq	16(%rsp), %rsi
	leaq	8(%rsp), %rdi
	movq	%r13, %rdx
	call	getline@PLT
	incq	%rax
	je	.L14
	movq	8(%rsp), %r14
	movq	str_islow(%rip), %rsi
	movq	%r14, %rdi
	call	strstr@PLT
	testq	%rax, %rax
	je	.L4
	incl	%r12d
	movl	$1000, %ecx
	movl	%r12d, %eax
	cltd
	idivl	%ecx
	testl	%edx, %edx
	jne	.L5
	movq	%r14, %rdx
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L5:
	movl	$8, %ebp
	jmp	.L3
.L4:
	testl	%ebp, %ebp
	je	.L3
	leaq	28(%rbx), %rax
	leaq	4(%rbx), %rcx
	movq	%rbx, %rdx
	movq	%r15, %rsi
	pushq	%rax
	.cfi_def_cfa_offset 104
	leaq	24(%rbx), %rax
	leaq	12(%rbx), %r9
	movq	%r14, %rdi
	pushq	%rax
	.cfi_def_cfa_offset 112
	leaq	20(%rbx), %rax
	leaq	8(%rbx), %r8
	decl	%ebp
	pushq	%rax
	.cfi_def_cfa_offset 120
	leaq	16(%rbx), %rax
	addq	$32, %rbx
	pushq	%rax
	.cfi_def_cfa_offset 128
	xorl	%eax, %eax
	call	__isoc23_sscanf@PLT
	addq	$32, %rsp
	.cfi_def_cfa_offset 96
	jmp	.L3
.L14:
	xorl	%eax, %eax
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	addq	$40, %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
.LFE2027:
	.size	_Z8readFilePi, .-_Z8readFilePi
	.section	.rodata.str1.1
.LC6:
	.string	"%dth islow function\n"
.LC7:
	.string	"elemptr[0]=%d,"
.LC8:
	.string	"elemptr[1]=%d,"
.LC9:
	.string	"elemptr[2]=%d,"
.LC10:
	.string	"elemptr[3]=%d,"
.LC11:
	.string	"elemptr[4]=%d,"
.LC12:
	.string	"elemptr[5]=%d,"
.LC13:
	.string	"elemptr[6]=%d,"
.LC14:
	.string	"elemptr[7]=%d\n"
.LC15:
	.string	"dataptr[0]=%d,"
.LC16:
	.string	"dataptr[1]=%d,"
.LC17:
	.string	"dataptr[2]=%d,"
.LC18:
	.string	"dataptr[3]=%d,"
.LC19:
	.string	"dataptr[4]=%d,"
.LC20:
	.string	"dataptr[5]=%d,"
.LC21:
	.string	"dataptr[6]=%d,"
.LC22:
	.string	"dataptr[7]=%d\n"
	.text
	.globl	_Z9printFilePiS_
	.type	_Z9printFilePiS_, @function
_Z9printFilePiS_:
.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
	xorl	%r13d, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	pushq	%rdx
	.cfi_def_cfa_offset 64
.L18:
	movq	stderr(%rip), %rdi
	incl	%r13d
	xorl	%eax, %eax
	movq	%r12, %rbx
	movl	%r13d, %ecx
	leaq	.LC6(%rip), %rdx
	movl	$2, %esi
	call	__fprintf_chk@PLT
	leaq	.LC7(%rip), %r15
.L16:
	movl	(%rbx), %ecx
	movq	stderr(%rip), %rdi
	movq	%r15, %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	addq	$32, %rbx
	leaq	256(%r12), %r14
	call	__fprintf_chk@PLT
	movl	-28(%rbx), %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC8(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	-24(%rbx), %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC9(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	-20(%rbx), %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC10(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	-16(%rbx), %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC11(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	-12(%rbx), %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC12(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	-8(%rbx), %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC13(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	-4(%rbx), %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC14(%rip), %rdx
	call	__fprintf_chk@PLT
	cmpq	%r14, %rbx
	jne	.L16
	movq	%rbp, %rbx
	leaq	.LC15(%rip), %r12
.L17:
	movl	(%rbx), %ecx
	movq	stderr(%rip), %rdi
	movq	%r12, %rdx
	xorl	%eax, %eax
	movl	$2, %esi
	addq	$4, %rbx
	call	__fprintf_chk@PLT
	movl	28(%rbx), %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC16(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	60(%rbx), %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC17(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	92(%rbx), %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC18(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	124(%rbx), %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC19(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	156(%rbx), %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC20(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	188(%rbx), %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC21(%rip), %rdx
	call	__fprintf_chk@PLT
	movl	220(%rbx), %ecx
	movl	$2, %esi
	xorl	%eax, %eax
	movq	stderr(%rip), %rdi
	leaq	.LC22(%rip), %rdx
	call	__fprintf_chk@PLT
	leaq	32(%rbp), %rax
	cmpq	%rax, %rbx
	jne	.L17
	movq	%r14, %r12
	addq	$256, %rbp
	cmpl	$4969077, %r13d
	jne	.L18
	popq	%rax
	.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	_Z9printFilePiS_, .-_Z9printFilePiS_
	.globl	_Z34__device_stub__Z12islow_cuda_1PiS_PiS_
	.type	_Z34__device_stub__Z12islow_cuda_1PiS_PiS_, @function
_Z34__device_stub__Z12islow_cuda_1PiS_PiS_:
.LFB2055:
	.cfi_startproc
	endbr64
	subq	$120, %rsp
	.cfi_def_cfa_offset 128
	movq	%rdi, 8(%rsp)
	leaq	32(%rsp), %rcx
	leaq	24(%rsp), %rdx
	movq	%rsi, (%rsp)
	leaq	40(%rsp), %rdi
	leaq	52(%rsp), %rsi
	movq	%fs:40, %rax
	movq	%rax, 104(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 48(%rsp)
	movq	%rax, 88(%rsp)
	movq	%rsp, %rax
	movq	%rax, 96(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 40(%rsp)
	movq	%rax, 52(%rsp)
	movl	$1, 60(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L23
	pushq	32(%rsp)
	.cfi_def_cfa_offset 136
	leaq	_Z12islow_cuda_1PiS_(%rip), %rdi
	pushq	32(%rsp)
	.cfi_def_cfa_offset 144
	movq	68(%rsp), %rcx
	movl	76(%rsp), %r8d
	movq	56(%rsp), %rsi
	movl	64(%rsp), %edx
	leaq	104(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 136
	popq	%rdx
	.cfi_def_cfa_offset 128
.L23:
	movq	104(%rsp), %rax
	subq	%fs:40, %rax
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	addq	$120, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2055:
	.size	_Z34__device_stub__Z12islow_cuda_1PiS_PiS_, .-_Z34__device_stub__Z12islow_cuda_1PiS_PiS_
	.globl	_Z12islow_cuda_1PiS_
	.type	_Z12islow_cuda_1PiS_, @function
_Z12islow_cuda_1PiS_:
.LFB2056:
	.cfi_startproc
	endbr64
	jmp	_Z34__device_stub__Z12islow_cuda_1PiS_PiS_
	.cfi_endproc
.LFE2056:
	.size	_Z12islow_cuda_1PiS_, .-_Z12islow_cuda_1PiS_
	.globl	_Z32__device_stub__Z12islow_cuda_2PiPi
	.type	_Z32__device_stub__Z12islow_cuda_2PiPi, @function
_Z32__device_stub__Z12islow_cuda_2PiPi:
.LFB2057:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movq	%rdi, 8(%rsp)
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	44(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L28
	pushq	24(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z12islow_cuda_2Pi(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 128
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L28:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L30
	call	__stack_chk_fail@PLT
.L30:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2057:
	.size	_Z32__device_stub__Z12islow_cuda_2PiPi, .-_Z32__device_stub__Z12islow_cuda_2PiPi
	.globl	_Z12islow_cuda_2Pi
	.type	_Z12islow_cuda_2Pi, @function
_Z12islow_cuda_2Pi:
.LFB2058:
	.cfi_startproc
	endbr64
	jmp	_Z32__device_stub__Z12islow_cuda_2PiPi
	.cfi_endproc
.LFE2058:
	.size	_Z12islow_cuda_2Pi, .-_Z12islow_cuda_2Pi
	.globl	_Z10func_islowPiS_
	.type	_Z10func_islowPiS_, @function
_Z10func_islowPiS_:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	%rsi, %rbx
	movq	%rdi, %rsi
	movl	$1, %ecx
	subq	$32, %rsp
	.cfi_def_cfa_offset 48
	movslq	batchSize(%rip), %rdx
	movq	elemd(%rip), %rdi
	call	cudaMemcpy@PLT
	movl	numOfThreads(%rip), %eax
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	numOfBlocks(%rip), %edx
	movl	%eax, 20(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 24(%rsp)
	movl	28(%rsp), %ecx
	movl	%edx, 8(%rsp)
	movq	20(%rsp), %rdx
	movq	%rax, 12(%rsp)
	movq	8(%rsp), %rdi
	movl	16(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L34
	movq	dataptrd(%rip), %rsi
	movq	elemd(%rip), %rdi
	call	_Z34__device_stub__Z12islow_cuda_1PiS_PiS_
.L34:
	movl	numOfThreads(%rip), %eax
	movl	numOfBlocks(%rip), %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	%eax, 20(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 24(%rsp)
	movl	28(%rsp), %ecx
	movl	%edx, 8(%rsp)
	movq	20(%rsp), %rdx
	movq	%rax, 12(%rsp)
	movq	8(%rsp), %rdi
	movl	16(%rsp), %esi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L35
	movq	dataptrd(%rip), %rdi
	call	_Z32__device_stub__Z12islow_cuda_2PiPi
.L35:
	movslq	batchSize(%rip), %rdx
	movq	dataptrd(%rip), %rsi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	movq	%rbx, %rdi
	movl	$2, %ecx
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	cudaMemcpy@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z10func_islowPiS_, .-_Z10func_islowPiS_
	.section	.rodata.str1.1
.LC23:
	.string	"w"
.LC24:
	.string	"./data_self_cuda.txt"
.LC25:
	.string	"start processing data\n"
.LC28:
	.string	"done processing data\n"
.LC29:
	.string	"time used:%lfs\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC23(%rip), %rsi
	leaq	.LC24(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	stderr(%rip), %rdx
	call	freopen@PLT
	movl	$1272083712, %edi
	call	malloc@PLT
	movl	$1272083712, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, %r12
	call	_Z8readFilePi
	movslq	batchSize(%rip), %rsi
	leaq	elemd(%rip), %rdi
	call	cudaMalloc@PLT
	movslq	batchSize(%rip), %rsi
	leaq	dataptrd(%rip), %rdi
	call	cudaMalloc@PLT
	leaq	.LC25(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	clock@PLT
	movq	%rax, %r13
.L38:
	leaq	(%r12,%rbp), %rsi
	leaq	(%rbx,%rbp), %rdi
	addq	$256, %rbp
	call	_Z10func_islowPiS_
	cmpq	$1272083712, %rbp
	jne	.L38
	call	clock@PLT
	xorps	%xmm1, %xmm1
	movl	$2, %edi
	leaq	.LC28(%rip), %rsi
	subq	%r13, %rax
	cvtsi2sdq	%rax, %xmm0
	divsd	.LC26(%rip), %xmm0
	xorl	%eax, %eax
	addsd	%xmm1, %xmm0
	movsd	%xmm0, 8(%rsp)
	call	__printf_chk@PLT
	movsd	8(%rsp), %xmm0
	leaq	.LC29(%rip), %rsi
	movb	$1, %al
	movl	$2, %edi
	call	__printf_chk@PLT
	movq	%r12, %rsi
	movq	%rbx, %rdi
	call	_Z9printFilePiS_
	addq	$24, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	main, .-main
	.section	.rodata.str1.1
.LC30:
	.string	"_Z12islow_cuda_2Pi"
.LC31:
	.string	"_Z12islow_cuda_1PiS_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2060:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	pushq	$0
	.cfi_def_cfa_offset 24
	xorl	%r9d, %r9d
	orl	$-1, %r8d
	pushq	$0
	.cfi_def_cfa_offset 32
	leaq	.LC30(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	pushq	$0
	.cfi_def_cfa_offset 40
	movq	%rdx, %rcx
	leaq	_Z12islow_cuda_2Pi(%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	.LC31(%rip), %rdx
	orl	$-1, %r8d
	leaq	_Z12islow_cuda_1PiS_(%rip), %rsi
	pushq	$0
	.cfi_def_cfa_offset 32
	movq	%rdx, %rcx
	pushq	$0
	.cfi_def_cfa_offset 40
	pushq	$0
	.cfi_def_cfa_offset 48
	call	__cudaRegisterFunction@PLT
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE2060:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.globl	batchSize
	.data
	.align 4
	.type	batchSize, @object
	.size	batchSize, 4
batchSize:
	.long	256
	.globl	numOfBlocks
	.align 4
	.type	numOfBlocks, @object
	.size	numOfBlocks, 4
numOfBlocks:
	.long	2
	.globl	numOfThreads
	.align 4
	.type	numOfThreads, @object
	.size	numOfThreads, 4
numOfThreads:
	.long	4
	.globl	dataptrd
	.bss
	.align 8
	.type	dataptrd, @object
	.size	dataptrd, 8
dataptrd:
	.zero	8
	.globl	elemd
	.align 8
	.type	elemd, @object
	.size	elemd, 8
elemd:
	.zero	8
	.globl	str_islow
	.section	.rodata.str1.1
.LC32:
	.string	"islow function"
	.section	.data.rel.local,"aw"
	.align 8
	.type	str_islow, @object
	.size	str_islow, 8
str_islow:
	.quad	.LC32
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC26:
	.long	0
	.long	1093567616
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>

#define DCTSIZE 8
#define CENTERJSAMPLE 128
#define PASS1_BITS 2
#define CONST_BITS 13
#define ONE	((INT32) 1)

#define FIX_0_298631336  ((INT32)  2446)	/* FIX(0.298631336) */
#define FIX_0_390180644  ((INT32)  3196)	/* FIX(0.390180644) */
#define FIX_0_541196100  ((INT32)  4433)	/* FIX(0.541196100) */
#define FIX_0_765366865  ((INT32)  6270)	/* FIX(0.765366865) */
#define FIX_0_899976223  ((INT32)  7373)	/* FIX(0.899976223) */
#define FIX_1_175875602  ((INT32)  9633)	/* FIX(1.175875602) */
#define FIX_1_501321110  ((INT32)  12299)	/* FIX(1.501321110) */
#define FIX_1_847759065  ((INT32)  15137)	/* FIX(1.847759065) */
#define FIX_1_961570560  ((INT32)  16069)	/* FIX(1.961570560) */
#define FIX_2_053119869  ((INT32)  16819)	/* FIX(2.053119869) */
#define FIX_2_562915447  ((INT32)  20995)	/* FIX(2.562915447) */
#define FIX_3_072711026  ((INT32)  25172)	/* FIX(3.072711026) */

#define RIGHT_SHIFT(x,shft)	((x) >> (shft))
#define GETJSAMPLE(value)  ((int) (value))
#define MULTIPLY16C16(var,const)  ((var) * (const))
#define MULTIPLY(var,const)  MULTIPLY16C16(var,const)

typedef int DCTELEM;
typedef long INT32;


// #define TOTAL_FUNC_CALL 49761
#define TOTAL_FUNC_CALL 4969077
char *str_islow = "islow function";
int *elemd, *dataptrd;
int numOfThreads = 4;
int numOfBlocks = 2;
int batchSize = DCTSIZE*DCTSIZE*sizeof(int);

void readFile(int *elem){
    FILE *fp;
    char *line;
    size_t len = 0;
    int ctr = 0, iter = 0;
    int *elemptr;
    // fp = fopen("./data_small.txt", "r");
    fp = fopen("./data_large.txt", "r");

    printf("start reading file...\n");
    elemptr = elem;
    while(getline(&line, &len, fp) != -1){
        if(strstr(line, str_islow) != NULL){
            iter++;
            if(iter % 1000 == 0)
                printf("%s", line);
            ctr = DCTSIZE;
        }
        else{
            if(ctr != 0){
                ctr--;
                sscanf(line, "elemptr[0]=%d,elemptr[1]=%d,elemptr[2]=%d,elemptr[3]=%d,elemptr[4]=%d,elemptr[5]=%d,elemptr[6]=%d,elemptr[7]=%d\n",
                        &elemptr[0], &elemptr[1], &elemptr[2], &elemptr[3], &elemptr[4], &elemptr[5], &elemptr[6], &elemptr[7]);
                elemptr += DCTSIZE;     // jump 8 elements
            }
            else{
                continue;
            }
        }
    }
    printf("done reading file\n");
}

void printFile(int *elemptr, DCTELEM *dataptr){
    int *e_p, *d_p;
    for(int i = 0 ; i<TOTAL_FUNC_CALL ; i++){
        fprintf(stderr, "%dth islow function\n", i+1);
        int ctr;
        e_p = elemptr;
        for(ctr = 0 ; ctr<DCTSIZE ; ctr++){
            fprintf(stderr, "elemptr[0]=%d,", (int)e_p[0]);
            fprintf(stderr, "elemptr[1]=%d,", (int)e_p[1]);
            fprintf(stderr, "elemptr[2]=%d,", (int)e_p[2]);
            fprintf(stderr, "elemptr[3]=%d,", (int)e_p[3]);
            fprintf(stderr, "elemptr[4]=%d,", (int)e_p[4]);
            fprintf(stderr, "elemptr[5]=%d,", (int)e_p[5]);
            fprintf(stderr, "elemptr[6]=%d,", (int)e_p[6]);
            fprintf(stderr, "elemptr[7]=%d\n", (int)e_p[7]);

            e_p += DCTSIZE;
        }
        d_p = dataptr;
        for(ctr = 0 ; ctr<DCTSIZE ; ctr++){
            fprintf(stderr, "dataptr[0]=%d,", d_p[DCTSIZE*0]);
            fprintf(stderr, "dataptr[1]=%d,", d_p[DCTSIZE*1]);
            fprintf(stderr, "dataptr[2]=%d,", d_p[DCTSIZE*2]);
            fprintf(stderr, "dataptr[3]=%d,", d_p[DCTSIZE*3]);
            fprintf(stderr, "dataptr[4]=%d,", d_p[DCTSIZE*4]);
            fprintf(stderr, "dataptr[5]=%d,", d_p[DCTSIZE*5]);
            fprintf(stderr, "dataptr[6]=%d,", d_p[DCTSIZE*6]);
            fprintf(stderr, "dataptr[7]=%d\n", d_p[DCTSIZE*7]);

            d_p += 1;
        }
        elemptr += DCTSIZE*DCTSIZE;
        dataptr += DCTSIZE*DCTSIZE;
    }
}

__global__ void islow_cuda_1(int *elemptrd, int *dataptrd){
    INT32 tmp0, tmp1, tmp2, tmp3;
    INT32 tmp10, tmp11, tmp12, tmp13;
    INT32 z1;

    int ID = blockIdx.x * blockDim.x + threadIdx.x;
    elemptrd += ID * DCTSIZE;
    dataptrd += ID * DCTSIZE;

    tmp0 = GETJSAMPLE(elemptrd[0]) + GETJSAMPLE(elemptrd[7]);
    tmp1 = GETJSAMPLE(elemptrd[1]) + GETJSAMPLE(elemptrd[6]);
    tmp2 = GETJSAMPLE(elemptrd[2]) + GETJSAMPLE(elemptrd[5]);
    tmp3 = GETJSAMPLE(elemptrd[3]) + GETJSAMPLE(elemptrd[4]);

    tmp10 = tmp0 + tmp3;
    tmp12 = tmp0 - tmp3;
    tmp11 = tmp1 + tmp2;
    tmp13 = tmp1 - tmp2;

    tmp0 = GETJSAMPLE(elemptrd[0]) - GETJSAMPLE(elemptrd[7]);
    tmp1 = GETJSAMPLE(elemptrd[1]) - GETJSAMPLE(elemptrd[6]);
    tmp2 = GETJSAMPLE(elemptrd[2]) - GETJSAMPLE(elemptrd[5]);
    tmp3 = GETJSAMPLE(elemptrd[3]) - GETJSAMPLE(elemptrd[4]);

    dataptrd[0] = (DCTELEM) ((tmp10 + tmp11 - 8 * CENTERJSAMPLE) << PASS1_BITS);
    dataptrd[4] = (DCTELEM) ((tmp10 - tmp11) << PASS1_BITS);

    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);       /* c6 */
    
    z1 += ONE << (CONST_BITS-PASS1_BITS-1);
    
    dataptrd[2] = (DCTELEM)
        RIGHT_SHIFT(z1 + MULTIPLY(tmp12, FIX_0_765366865), /* c2-c6 */
        CONST_BITS-PASS1_BITS);
    dataptrd[6] = (DCTELEM)
        RIGHT_SHIFT(z1 - MULTIPLY(tmp13, FIX_1_847759065), /* c2+c6 */
        CONST_BITS-PASS1_BITS);
    
    tmp12 = tmp0 + tmp2;
    tmp13 = tmp1 + tmp3;

    z1 = MULTIPLY(tmp12 + tmp13, FIX_1_175875602);       /*  c3 */
    /* Add fudge factor here for final descale. */
    z1 += ONE << (CONST_BITS-PASS1_BITS-1);

    tmp12 = MULTIPLY(tmp12, - FIX_0_390180644);          /* -c3+c5 */
    tmp13 = MULTIPLY(tmp13, - FIX_1_961570560);          /* -c3-c5 */
    tmp12 += z1;
    tmp13 += z1;

    z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223);       /* -c3+c7 */
    tmp0 = MULTIPLY(tmp0, FIX_1_501321110);              /*  c1+c3-c5-c7 */
    tmp3 = MULTIPLY(tmp3, FIX_0_298631336);              /* -c1+c3+c5-c7 */
    tmp0 += z1 + tmp12;
    tmp3 += z1 + tmp13;

    z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447);       /* -c1-c3 */
    tmp1 = MULTIPLY(tmp1, FIX_3_072711026);              /*  c1+c3+c5-c7 */
    tmp2 = MULTIPLY(tmp2, FIX_2_053119869);              /*  c1+c3-c5+c7 */
    tmp1 += z1 + tmp13;
    tmp2 += z1 + tmp12;

    dataptrd[1] = (DCTELEM) RIGHT_SHIFT(tmp0, CONST_BITS-PASS1_BITS);
    dataptrd[3] = (DCTELEM) RIGHT_SHIFT(tmp1, CONST_BITS-PASS1_BITS);
    dataptrd[5] = (DCTELEM) RIGHT_SHIFT(tmp2, CONST_BITS-PASS1_BITS);
    dataptrd[7] = (DCTELEM) RIGHT_SHIFT(tmp3, CONST_BITS-PASS1_BITS);
}

__global__ void islow_cuda_2(int *dataptrd){
    INT32 tmp0, tmp1, tmp2, tmp3;
    INT32 tmp10, tmp11, tmp12, tmp13;
    INT32 z1;

    int ID = blockIdx.x * blockDim.x + threadIdx.x;
    dataptrd += ID;

    tmp0 = dataptrd[DCTSIZE*0] + dataptrd[DCTSIZE*7];
    tmp1 = dataptrd[DCTSIZE*1] + dataptrd[DCTSIZE*6];
    tmp2 = dataptrd[DCTSIZE*2] + dataptrd[DCTSIZE*5];
    tmp3 = dataptrd[DCTSIZE*3] + dataptrd[DCTSIZE*4];

    /* Add fudge factor here for final descale. */
    tmp10 = tmp0 + tmp3 + (ONE << (PASS1_BITS-1));
    tmp12 = tmp0 - tmp3;
    tmp11 = tmp1 + tmp2;
    tmp13 = tmp1 - tmp2;

    tmp0 = dataptrd[DCTSIZE*0] - dataptrd[DCTSIZE*7];
    tmp1 = dataptrd[DCTSIZE*1] - dataptrd[DCTSIZE*6];
    tmp2 = dataptrd[DCTSIZE*2] - dataptrd[DCTSIZE*5];
    tmp3 = dataptrd[DCTSIZE*3] - dataptrd[DCTSIZE*4];

    dataptrd[DCTSIZE*0] = (DCTELEM) RIGHT_SHIFT(tmp10 + tmp11, PASS1_BITS);
    dataptrd[DCTSIZE*4] = (DCTELEM) RIGHT_SHIFT(tmp10 - tmp11, PASS1_BITS);

    z1 = MULTIPLY(tmp12 + tmp13, FIX_0_541196100);       /* c6 */
    /* Add fudge factor here for final descale. */
    z1 += ONE << (CONST_BITS+PASS1_BITS-1);

    dataptrd[DCTSIZE*2] = (DCTELEM)
    RIGHT_SHIFT(z1 + MULTIPLY(tmp12, FIX_0_765366865), /* c2-c6 */
        CONST_BITS+PASS1_BITS);
    dataptrd[DCTSIZE*6] = (DCTELEM)
    RIGHT_SHIFT(z1 - MULTIPLY(tmp13, FIX_1_847759065), /* c2+c6 */
        CONST_BITS+PASS1_BITS);

    tmp12 = tmp0 + tmp2;
    tmp13 = tmp1 + tmp3;

    z1 = MULTIPLY(tmp12 + tmp13, FIX_1_175875602);       /*  c3 */
    /* Add fudge factor here for final descale. */
    z1 += ONE << (CONST_BITS+PASS1_BITS-1);

    tmp12 = MULTIPLY(tmp12, - FIX_0_390180644);          /* -c3+c5 */
    tmp13 = MULTIPLY(tmp13, - FIX_1_961570560);          /* -c3-c5 */
    tmp12 += z1;
    tmp13 += z1;

    z1 = MULTIPLY(tmp0 + tmp3, - FIX_0_899976223);       /* -c3+c7 */
    tmp0 = MULTIPLY(tmp0, FIX_1_501321110);              /*  c1+c3-c5-c7 */
    tmp3 = MULTIPLY(tmp3, FIX_0_298631336);              /* -c1+c3+c5-c7 */
    tmp0 += z1 + tmp12;
    tmp3 += z1 + tmp13;

    z1 = MULTIPLY(tmp1 + tmp2, - FIX_2_562915447);       /* -c1-c3 */
    tmp1 = MULTIPLY(tmp1, FIX_3_072711026);              /*  c1+c3+c5-c7 */
    tmp2 = MULTIPLY(tmp2, FIX_2_053119869);              /*  c1+c3-c5+c7 */
    tmp1 += z1 + tmp13;
    tmp2 += z1 + tmp12;

    dataptrd[DCTSIZE*1] = (DCTELEM) RIGHT_SHIFT(tmp0, CONST_BITS+PASS1_BITS);
    dataptrd[DCTSIZE*3] = (DCTELEM) RIGHT_SHIFT(tmp1, CONST_BITS+PASS1_BITS);
    dataptrd[DCTSIZE*5] = (DCTELEM) RIGHT_SHIFT(tmp2, CONST_BITS+PASS1_BITS);
    dataptrd[DCTSIZE*7] = (DCTELEM) RIGHT_SHIFT(tmp3, CONST_BITS+PASS1_BITS);
}

// feed 8*8 elements at a time
void func_islow(int *elemptr, DCTELEM * dataptr){
    hipMemcpy(elemd, elemptr, batchSize, hipMemcpyHostToDevice);

    islow_cuda_1<<<numOfBlocks, numOfThreads>>>(elemd, dataptrd);
    islow_cuda_2<<<numOfBlocks, numOfThreads>>>(dataptrd);

    hipMemcpy(dataptr, dataptrd, batchSize, hipMemcpyDeviceToHost);
}



int main(void){

    freopen("./data_self_cuda.txt", "w", stderr);
    int size = TOTAL_FUNC_CALL*DCTSIZE*DCTSIZE*(sizeof(int));
    int *elem = (int *)malloc(size);
    int *dataptr = (int *)malloc(size);
    int *elem_start, *dataptr_start;

    clock_t start, end;
    double time_used = 0;

    readFile(elem);

    hipMalloc(&elemd, batchSize);
    hipMalloc(&dataptrd, batchSize);

    elem_start = elem;
    dataptr_start = dataptr;
    printf("start processing data\n");
    start = clock();
    for(int i = 0 ; i<TOTAL_FUNC_CALL ; i++){
        func_islow(elem, dataptr);
        elem += DCTSIZE*DCTSIZE;
        dataptr += DCTSIZE*DCTSIZE;
    }
    end = clock();
    time_used += ((double)(end - start)) / CLOCKS_PER_SEC;
    printf("done processing data\n");
    printf("time used:%lfs\n", time_used);

    printFile(elem_start, dataptr_start);


    return 0;
}

	.text
	.file	"jpeg_fdct_islow_cuda_inner.hip"
	.globl	_Z8readFilePi                   # -- Begin function _Z8readFilePi
	.type	_Z8readFilePi,@function
_Z8readFilePi:                          # @_Z8readFilePi
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rdi, 16(%rsp)                  # 8-byte Spill
	leaq	48(%rsp), %r14
	movq	$0, (%r14)
	movl	$.L.str.1, %edi
	movl	$.L.str.2, %esi
	callq	fopen
	movq	%rax, %r15
	movl	$.Lstr, %edi
	callq	puts@PLT
	leaq	40(%rsp), %r12
	xorl	%ebp, %ebp
	movl	$0, 12(%rsp)                    # 4-byte Folded Spill
.LBB0_1:                                # =>This Inner Loop Header: Depth=1
	movl	%ebp, %ebx
	movq	%r12, %rdi
	movq	%r14, %rsi
	movq	%r15, %rdx
	callq	getline
	cmpq	$-1, %rax
	je	.LBB0_7
# %bb.2:                                #   in Loop: Header=BB0_1 Depth=1
	movq	40(%rsp), %r13
	movq	str_islow(%rip), %rsi
	movq	%r13, %rdi
	callq	strstr
	testq	%rax, %rax
	jne	.LBB0_3
# %bb.5:                                #   in Loop: Header=BB0_1 Depth=1
	xorl	%ebp, %ebp
	testl	%ebx, %ebx
	je	.LBB0_1
# %bb.6:                                #   in Loop: Header=BB0_1 Depth=1
	decl	%ebx
	movq	16(%rsp), %rbp                  # 8-byte Reload
	leaq	4(%rbp), %rcx
	leaq	8(%rbp), %r8
	leaq	12(%rbp), %r9
	leaq	16(%rbp), %rax
	movq	%rax, 32(%rsp)                  # 8-byte Spill
	leaq	20(%rbp), %rax
	movq	%rax, 24(%rsp)                  # 8-byte Spill
	leaq	24(%rbp), %r11
	leaq	28(%rbp), %r10
	movl	$.L.str.5, %esi
	movq	%r13, %rdi
	movq	%rbp, %rdx
	xorl	%eax, %eax
	pushq	%r10
	.cfi_adjust_cfa_offset 8
	pushq	%r11
	.cfi_adjust_cfa_offset 8
	pushq	40(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	pushq	56(%rsp)                        # 8-byte Folded Reload
	.cfi_adjust_cfa_offset 8
	callq	__isoc23_sscanf
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
	addq	$32, %rbp
	movq	%rbp, 16(%rsp)                  # 8-byte Spill
	movl	%ebx, %ebp
	jmp	.LBB0_1
.LBB0_3:                                #   in Loop: Header=BB0_1 Depth=1
	movl	12(%rsp), %eax                  # 4-byte Reload
	incl	%eax
	movl	%eax, 12(%rsp)                  # 4-byte Spill
	imull	$652835029, %eax, %eax          # imm = 0x26E978D5
	rorl	$3, %eax
	movl	$8, %ebp
	cmpl	$4294967, %eax                  # imm = 0x418937
	ja	.LBB0_1
# %bb.4:                                #   in Loop: Header=BB0_1 Depth=1
	movl	$.L.str.4, %edi
	movq	%r13, %rsi
	xorl	%eax, %eax
	callq	printf
	jmp	.LBB0_1
.LBB0_7:
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z8readFilePi, .Lfunc_end0-_Z8readFilePi
	.cfi_endproc
                                        # -- End function
	.globl	_Z9printFilePiS_                # -- Begin function _Z9printFilePiS_
	.type	_Z9printFilePiS_,@function
_Z9printFilePiS_:                       # @_Z9printFilePiS_
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movl	$256, %r15d                     # imm = 0x100
	xorl	%ebp, %ebp
.LBB1_1:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_2 Depth 2
                                        #     Child Loop BB1_4 Depth 2
	movq	stderr(%rip), %rdi
	incl	%ebp
	movl	$.L.str.7, %esi
	movl	%ebp, %edx
	xorl	%eax, %eax
	callq	fprintf
	xorl	%r12d, %r12d
.LBB1_2:                                #   Parent Loop BB1_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	stderr(%rip), %rdi
	movl	(%r14,%r12), %edx
	movl	$.L.str.8, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	4(%r14,%r12), %edx
	movl	$.L.str.9, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	8(%r14,%r12), %edx
	movl	$.L.str.10, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	12(%r14,%r12), %edx
	movl	$.L.str.11, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	16(%r14,%r12), %edx
	movl	$.L.str.12, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	20(%r14,%r12), %edx
	movl	$.L.str.13, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	24(%r14,%r12), %edx
	movl	$.L.str.14, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	28(%r14,%r12), %edx
	movl	$.L.str.15, %esi
	xorl	%eax, %eax
	callq	fprintf
	addq	$32, %r12
	cmpl	$256, %r12d                     # imm = 0x100
	jne	.LBB1_2
# %bb.3:                                # %.preheader.preheader
                                        #   in Loop: Header=BB1_1 Depth=1
	xorl	%r12d, %r12d
.LBB1_4:                                # %.preheader
                                        #   Parent Loop BB1_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	stderr(%rip), %rdi
	movl	(%rbx,%r12,4), %edx
	movl	$.L.str.16, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	32(%rbx,%r12,4), %edx
	movl	$.L.str.17, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	64(%rbx,%r12,4), %edx
	movl	$.L.str.18, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	96(%rbx,%r12,4), %edx
	movl	$.L.str.19, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	128(%rbx,%r12,4), %edx
	movl	$.L.str.20, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	160(%rbx,%r12,4), %edx
	movl	$.L.str.21, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	192(%rbx,%r12,4), %edx
	movl	$.L.str.22, %esi
	xorl	%eax, %eax
	callq	fprintf
	movq	stderr(%rip), %rdi
	movl	224(%rbx,%r12,4), %edx
	movl	$.L.str.23, %esi
	xorl	%eax, %eax
	callq	fprintf
	incq	%r12
	cmpl	$8, %r12d
	jne	.LBB1_4
# %bb.5:                                #   in Loop: Header=BB1_1 Depth=1
	addq	%r15, %r14
	addq	%r15, %rbx
	cmpl	$4969077, %ebp                  # imm = 0x4BD275
	jne	.LBB1_1
# %bb.6:
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z9printFilePiS_, .Lfunc_end1-_Z9printFilePiS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z27__device_stub__islow_cuda_1PiS_ # -- Begin function _Z27__device_stub__islow_cuda_1PiS_
	.type	_Z27__device_stub__islow_cuda_1PiS_,@function
_Z27__device_stub__islow_cuda_1PiS_:    # @_Z27__device_stub__islow_cuda_1PiS_
	.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	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	16(%rsp), %rcx
	movq	%rsi, (%rcx)
	leaq	64(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rcx, 8(%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	8(%rsp), %r12
	movq	%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	$_Z12islow_cuda_1PiS_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	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	_Z27__device_stub__islow_cuda_1PiS_, .Lfunc_end2-_Z27__device_stub__islow_cuda_1PiS_
	.cfi_endproc
                                        # -- End function
	.globl	_Z27__device_stub__islow_cuda_2Pi # -- Begin function _Z27__device_stub__islow_cuda_2Pi
	.type	_Z27__device_stub__islow_cuda_2Pi,@function
_Z27__device_stub__islow_cuda_2Pi:      # @_Z27__device_stub__islow_cuda_2Pi
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$64, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	24(%rsp), %rax
	movq	%rdi, (%rax)
	movq	%rsp, %rbx
	movq	%rax, (%rbx)
	leaq	48(%rsp), %r14
	leaq	32(%rsp), %r15
	leaq	16(%rsp), %r12
	leaq	8(%rsp), %r13
	movq	%r14, %rdi
	movq	%r15, %rsi
	movq	%r12, %rdx
	movq	%r13, %rcx
	callq	__hipPopCallConfiguration
	movq	(%r14), %rsi
	movl	8(%r14), %edx
	movq	(%r15), %rcx
	movl	8(%r15), %r8d
	movl	$_Z12islow_cuda_2Pi, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$80, %rsp
	.cfi_adjust_cfa_offset -80
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z27__device_stub__islow_cuda_2Pi, .Lfunc_end3-_Z27__device_stub__islow_cuda_2Pi
	.cfi_endproc
                                        # -- End function
	.globl	_Z10func_islowPiS_              # -- Begin function _Z10func_islowPiS_
	.type	_Z10func_islowPiS_,@function
_Z10func_islowPiS_:                     # @_Z10func_islowPiS_
	.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, %rbx
	movq	%rdi, %rsi
	movabsq	$4294967296, %r14               # imm = 0x100000000
	movq	elemd(%rip), %rdi
	movslq	batchSize(%rip), %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movl	numOfBlocks(%rip), %edi
	movl	numOfThreads(%rip), %edx
	btsq	$32, %rdi
	btsq	$32, %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_2
# %bb.1:
	movq	elemd(%rip), %rdi
	movq	dataptrd(%rip), %rsi
	callq	_Z27__device_stub__islow_cuda_1PiS_
.LBB4_2:
	movl	numOfBlocks(%rip), %edi
	movl	numOfThreads(%rip), %edx
	orq	%r14, %rdi
	orq	%r14, %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB4_4
# %bb.3:
	movq	dataptrd(%rip), %rdi
	callq	_Z27__device_stub__islow_cuda_2Pi
.LBB4_4:
	movq	dataptrd(%rip), %rsi
	movslq	batchSize(%rip), %rdx
	movq	%rbx, %rdi
	movl	$2, %ecx
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	hipMemcpy                       # TAILCALL
.Lfunc_end4:
	.size	_Z10func_islowPiS_, .Lfunc_end4-_Z10func_islowPiS_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI5_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.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 %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	stderr(%rip), %rdx
	movl	$.L.str.24, %edi
	movl	$.L.str.25, %esi
	callq	freopen
	movl	$1272083712, %edi               # imm = 0x4BD27500
	callq	malloc
	movq	%rax, %rbx
	movl	$1272083712, %edi               # imm = 0x4BD27500
	callq	malloc
	movq	%rax, %r14
	movq	%rbx, %rdi
	callq	_Z8readFilePi
	movslq	batchSize(%rip), %rsi
	movl	$elemd, %edi
	callq	hipMalloc
	movslq	batchSize(%rip), %rsi
	movl	$dataptrd, %edi
	callq	hipMalloc
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	xorl	%r12d, %r12d
	callq	clock
	movq	%rax, %r15
.LBB5_1:                                # =>This Inner Loop Header: Depth=1
	leaq	(%rbx,%r12), %rdi
	leaq	(%r14,%r12), %rsi
	callq	_Z10func_islowPiS_
	addq	$256, %r12                      # imm = 0x100
	cmpl	$1272083712, %r12d              # imm = 0x4BD27500
	jne	.LBB5_1
# %bb.2:
	callq	clock
	subq	%r15, %rax
	cvtsi2sd	%rax, %xmm0
	divsd	.LCPI5_0(%rip), %xmm0
	xorpd	%xmm1, %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, (%rsp)                   # 8-byte Spill
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movl	$.L.str.28, %edi
	movsd	(%rsp), %xmm0                   # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	_Z9printFilePiS_
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end5:
	.size	main, .Lfunc_end5-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	.LBB6_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rbx
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB6_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z12islow_cuda_1PiS_, %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	$_Z12islow_cuda_2Pi, %esi
	movl	$.L__unnamed_2, %edx
	movl	$.L__unnamed_2, %ecx
	movq	%rbx, %rdi
	movl	$-1, %r8d
	xorl	%r9d, %r9d
	callq	__hipRegisterFunction
	movl	$__hip_module_dtor, %edi
	addq	$32, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	atexit                          # TAILCALL
.Lfunc_end6:
	.size	__hip_module_ctor, .Lfunc_end6-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB7_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB7_2:
	retq
.Lfunc_end7:
	.size	__hip_module_dtor, .Lfunc_end7-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"islow function"
	.size	.L.str, 15

	.type	str_islow,@object               # @str_islow
	.data
	.globl	str_islow
	.p2align	3, 0x0
str_islow:
	.quad	.L.str
	.size	str_islow, 8

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

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

	.type	numOfThreads,@object            # @numOfThreads
	.data
	.globl	numOfThreads
	.p2align	2, 0x0
numOfThreads:
	.long	4                               # 0x4
	.size	numOfThreads, 4

	.type	numOfBlocks,@object             # @numOfBlocks
	.globl	numOfBlocks
	.p2align	2, 0x0
numOfBlocks:
	.long	2                               # 0x2
	.size	numOfBlocks, 4

	.type	batchSize,@object               # @batchSize
	.globl	batchSize
	.p2align	2, 0x0
batchSize:
	.long	256                             # 0x100
	.size	batchSize, 4

	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"./data_large.txt"
	.size	.L.str.1, 17

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

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"%s"
	.size	.L.str.4, 3

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"elemptr[0]=%d,elemptr[1]=%d,elemptr[2]=%d,elemptr[3]=%d,elemptr[4]=%d,elemptr[5]=%d,elemptr[6]=%d,elemptr[7]=%d\n"
	.size	.L.str.5, 113

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"%dth islow function\n"
	.size	.L.str.7, 21

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"elemptr[0]=%d,"
	.size	.L.str.8, 15

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"elemptr[1]=%d,"
	.size	.L.str.9, 15

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"elemptr[2]=%d,"
	.size	.L.str.10, 15

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"elemptr[3]=%d,"
	.size	.L.str.11, 15

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"elemptr[4]=%d,"
	.size	.L.str.12, 15

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"elemptr[5]=%d,"
	.size	.L.str.13, 15

	.type	.L.str.14,@object               # @.str.14
.L.str.14:
	.asciz	"elemptr[6]=%d,"
	.size	.L.str.14, 15

	.type	.L.str.15,@object               # @.str.15
.L.str.15:
	.asciz	"elemptr[7]=%d\n"
	.size	.L.str.15, 15

	.type	.L.str.16,@object               # @.str.16
.L.str.16:
	.asciz	"dataptr[0]=%d,"
	.size	.L.str.16, 15

	.type	.L.str.17,@object               # @.str.17
.L.str.17:
	.asciz	"dataptr[1]=%d,"
	.size	.L.str.17, 15

	.type	.L.str.18,@object               # @.str.18
.L.str.18:
	.asciz	"dataptr[2]=%d,"
	.size	.L.str.18, 15

	.type	.L.str.19,@object               # @.str.19
.L.str.19:
	.asciz	"dataptr[3]=%d,"
	.size	.L.str.19, 15

	.type	.L.str.20,@object               # @.str.20
.L.str.20:
	.asciz	"dataptr[4]=%d,"
	.size	.L.str.20, 15

	.type	.L.str.21,@object               # @.str.21
.L.str.21:
	.asciz	"dataptr[5]=%d,"
	.size	.L.str.21, 15

	.type	.L.str.22,@object               # @.str.22
.L.str.22:
	.asciz	"dataptr[6]=%d,"
	.size	.L.str.22, 15

	.type	.L.str.23,@object               # @.str.23
.L.str.23:
	.asciz	"dataptr[7]=%d\n"
	.size	.L.str.23, 15

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

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

	.type	.L.str.24,@object               # @.str.24
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.24:
	.asciz	"./data_self_cuda.txt"
	.size	.L.str.24, 21

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

	.type	.L.str.28,@object               # @.str.28
.L.str.28:
	.asciz	"time used:%lfs\n"
	.size	.L.str.28, 16

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z12islow_cuda_1PiS_"
	.size	.L__unnamed_1, 21

	.type	.L__unnamed_2,@object           # @1
.L__unnamed_2:
	.asciz	"_Z12islow_cuda_2Pi"
	.size	.L__unnamed_2, 19

	.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	"start reading file..."
	.size	.Lstr, 22

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"done reading file"
	.size	.Lstr.1, 18

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"start processing data"
	.size	.Lstr.2, 22

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"done processing data"
	.size	.Lstr.3, 21

	.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 _Z27__device_stub__islow_cuda_1PiS_
	.addrsig_sym _Z27__device_stub__islow_cuda_2Pi
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym elemd
	.addrsig_sym dataptrd
	.addrsig_sym _Z12islow_cuda_1PiS_
	.addrsig_sym _Z12islow_cuda_2Pi
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z12islow_cuda_1PiS_    ; -- Begin function _Z12islow_cuda_1PiS_
	.globl	_Z12islow_cuda_1PiS_
	.p2align	8
	.type	_Z12islow_cuda_1PiS_,@function
_Z12islow_cuda_1PiS_:                   ; @_Z12islow_cuda_1PiS_
; %bb.0:
	s_clause 0x1
	s_load_b32 s4, s[0:1], 0x1c
	s_load_b128 s[0:3], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s4, s4, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_mul_i32 s15, s15, s4
	v_add_lshl_u32 v0, s15, v0, 3
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_ashrrev_i32_e32 v1, 31, v0
	v_lshlrev_b64 v[8:9], 2, v[0:1]
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v4, vcc_lo, s0, v8
	v_add_co_ci_u32_e32 v5, vcc_lo, s1, v9, vcc_lo
	v_add_co_u32 v8, vcc_lo, s2, v8
	v_add_co_ci_u32_e32 v9, vcc_lo, s3, v9, vcc_lo
	s_clause 0x1
	global_load_b128 v[0:3], v[4:5], off
	global_load_b128 v[4:7], v[4:5], off offset:16
	s_movk_i32 s0, 0x1151
	s_movk_i32 s1, 0x25a1
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v10, v7, v0
	v_add_nc_u32_e32 v13, v4, v3
	v_add_nc_u32_e32 v11, v6, v1
	v_add_nc_u32_e32 v12, v5, v2
	v_sub_nc_u32_e32 v14, v0, v7
	v_ashrrev_i32_e32 v18, 31, v10
	v_ashrrev_i32_e32 v21, 31, v13
	v_sub_nc_u32_e32 v16, v2, v5
	v_ashrrev_i32_e32 v19, 31, v11
	v_ashrrev_i32_e32 v20, 31, v12
	v_sub_co_u32 v28, vcc_lo, v10, v13
	v_sub_nc_u32_e32 v15, v1, v6
	v_sub_nc_u32_e32 v17, v3, v4
	v_add_nc_u32_e32 v22, v13, v10
	v_add_nc_u32_e32 v23, v12, v11
	v_sub_co_ci_u32_e32 v29, vcc_lo, v18, v21, vcc_lo
	v_ashrrev_i32_e32 v24, 31, v14
	v_ashrrev_i32_e32 v26, 31, v16
	v_sub_co_u32 v30, vcc_lo, v11, v12
	v_sub_co_ci_u32_e32 v18, vcc_lo, v19, v20, vcc_lo
	v_ashrrev_i32_e32 v25, 31, v15
	v_ashrrev_i32_e32 v27, 31, v17
	v_add_nc_u32_e32 v19, v22, v23
	v_sub_nc_u32_e32 v20, v22, v23
	v_add_co_u32 v23, vcc_lo, v16, v14
	v_add_co_ci_u32_e32 v31, vcc_lo, v26, v24, vcc_lo
	v_add_co_u32 v32, vcc_lo, v17, v15
	v_mad_i64_i32 v[0:1], null, 0x300b, v14, 0
	v_add_co_ci_u32_e32 v33, vcc_lo, v27, v25, vcc_lo
	v_mad_i64_i32 v[2:3], null, 0x98e, v17, 0
	v_add_co_u32 v34, vcc_lo, v17, v14
	v_mad_i64_i32 v[4:5], null, 0x6254, v15, 0
	v_add_co_ci_u32_e32 v21, vcc_lo, v27, v24, vcc_lo
	v_add_co_u32 v24, vcc_lo, v16, v15
	v_add_co_ci_u32_e32 v25, vcc_lo, v26, v25, vcc_lo
	v_mad_i64_i32 v[6:7], null, 0x41b3, v16, 0
	v_mad_u64_u32 v[10:11], null, 0xffffe333, v34, v[0:1]
	v_add_co_u32 v0, vcc_lo, v28, v30
	v_mad_u64_u32 v[12:13], null, 0xffffe333, v34, v[2:3]
	v_add_co_ci_u32_e32 v3, vcc_lo, v29, v18, vcc_lo
	v_mad_u64_u32 v[1:2], null, 0xffffadfd, v24, v[4:5]
	v_add_co_u32 v4, vcc_lo, v32, v23
	v_mad_u64_u32 v[14:15], null, 0xffffadfd, v24, v[6:7]
	v_mad_u64_u32 v[5:6], null, v0, s0, 0x400
	s_delay_alu instid0(VALU_DEP_3)
	v_mad_u64_u32 v[16:17], null, v4, s1, 0x400
	v_add_co_ci_u32_e32 v7, vcc_lo, v33, v31, vcc_lo
	v_lshl_add_u32 v0, v19, 2, 0xfffff000
	v_mul_i32_i24_e32 v26, 0xffffc4df, v18
	v_mad_i32_i24 v6, 0x1151, v3, v6
	v_mad_i32_i24 v27, 0xffffadfd, v25, v2
	v_mad_i32_i24 v17, 0x25a1, v7, v17
	v_lshlrev_b32_e32 v4, 2, v20
	v_mad_i32_i24 v11, 0xffffe333, v21, v11
	v_mad_u64_u32 v[2:3], null, 0x187e, v28, v[5:6]
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_4) | instid1(VALU_DEP_4)
	v_mad_u64_u32 v[18:19], null, 0xfffff384, v23, v[16:17]
	v_mad_i32_i24 v13, 0xffffe333, v21, v13
	v_mad_u64_u32 v[20:21], null, 0xffffc13b, v32, v[16:17]
	v_mad_i32_i24 v7, 0xffffadfd, v25, v15
	v_mad_u64_u32 v[15:16], null, 0xffffc4df, v30, v[5:6]
	v_sub_nc_u32_e32 v6, v13, v34
	v_mad_i32_i24 v3, 0x187e, v29, v3
	v_mad_i32_i24 v13, 0xfffff384, v31, v19
	v_mad_i32_i24 v17, 0xffffc13b, v33, v21
	v_sub_nc_u32_e32 v5, v11, v34
	v_sub_nc_u32_e32 v11, v27, v24
	v_alignbit_b32 v2, v3, v2, 11
	v_sub_nc_u32_e32 v3, v13, v23
	v_sub_nc_u32_e32 v13, v17, v32
	v_add_co_u32 v10, vcc_lo, v10, v18
	v_mul_lo_u32 v22, 0x7ff, v30
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_4) | instid1(VALU_DEP_4)
	v_add_co_ci_u32_e32 v5, vcc_lo, v5, v3, vcc_lo
	v_sub_nc_u32_e32 v7, v7, v24
	v_add_co_u32 v17, vcc_lo, v1, v20
	v_add_co_ci_u32_e32 v11, vcc_lo, v11, v13, vcc_lo
	v_add_co_u32 v14, vcc_lo, v14, v18
	v_add_co_ci_u32_e32 v7, vcc_lo, v7, v3, vcc_lo
	v_add_co_u32 v12, vcc_lo, v12, v20
	v_add3_u32 v16, v26, v16, v22
	v_add_co_ci_u32_e32 v13, vcc_lo, v6, v13, vcc_lo
	v_alignbit_b32 v1, v5, v10, 11
	v_alignbit_b32 v3, v11, v17, 11
	s_delay_alu instid0(VALU_DEP_4)
	v_alignbit_b32 v6, v16, v15, 11
	v_alignbit_b32 v5, v7, v14, 11
	v_alignbit_b32 v7, v13, v12, 11
	s_clause 0x1
	global_store_b128 v[8:9], v[0:3], off
	global_store_b128 v[8:9], v[4:7], off offset:16
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12islow_cuda_1PiS_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 272
		.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 35
		.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	_Z12islow_cuda_1PiS_, .Lfunc_end0-_Z12islow_cuda_1PiS_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 788
; NumSgprs: 18
; NumVgprs: 35
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 4
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 35
; 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	_Z12islow_cuda_2Pi      ; -- Begin function _Z12islow_cuda_2Pi
	.globl	_Z12islow_cuda_2Pi
	.p2align	8
	.type	_Z12islow_cuda_2Pi,@function
_Z12islow_cuda_2Pi:                     ; @_Z12islow_cuda_2Pi
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x14
	s_load_b64 s[0:1], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_movk_i32 s2, 0x25a1
	v_ashrrev_i32_e32 v2, 31, v1
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[0:1], 2, v[1:2]
	v_add_co_u32 v0, vcc_lo, s0, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s1, v1, vcc_lo
	s_movk_i32 s1, 0x1151
	s_clause 0x7
	global_load_b32 v2, v[0:1], off
	global_load_b32 v3, v[0:1], off offset:32
	global_load_b32 v4, v[0:1], off offset:64
	global_load_b32 v5, v[0:1], off offset:96
	global_load_b32 v6, v[0:1], off offset:224
	global_load_b32 v7, v[0:1], off offset:192
	global_load_b32 v8, v[0:1], off offset:160
	global_load_b32 v9, v[0:1], off offset:128
	s_waitcnt vmcnt(3)
	v_add_nc_u32_e32 v10, v6, v2
	s_waitcnt vmcnt(2)
	v_add_nc_u32_e32 v11, v7, v3
	s_waitcnt vmcnt(1)
	v_add_nc_u32_e32 v12, v8, v4
	s_waitcnt vmcnt(0)
	v_add_nc_u32_e32 v13, v9, v5
	v_sub_nc_u32_e32 v14, v2, v6
	v_ashrrev_i32_e32 v18, 31, v10
	v_sub_nc_u32_e32 v16, v4, v8
	v_ashrrev_i32_e32 v19, 31, v11
	v_ashrrev_i32_e32 v21, 31, v13
	v_add_co_u32 v27, s0, v10, v13
	v_ashrrev_i32_e32 v20, 31, v12
	v_sub_nc_u32_e32 v15, v3, v7
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_ci_u32_e64 v28, s0, v18, v21, s0
	v_sub_co_u32 v29, s0, v10, v13
	v_sub_nc_u32_e32 v17, v5, v9
	v_sub_co_ci_u32_e64 v21, s0, v18, v21, s0
	v_ashrrev_i32_e32 v23, 31, v14
	v_ashrrev_i32_e32 v25, 31, v16
	v_add_co_u32 v18, s0, v12, v11
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e64 v30, s0, v20, v19, s0
	v_ashrrev_i32_e32 v24, 31, v15
	v_ashrrev_i32_e32 v26, 31, v17
	v_add_co_u32 v31, s0, v16, v14
	v_add_co_ci_u32_e64 v32, s0, v25, v23, s0
	v_sub_co_u32 v22, vcc_lo, v11, v12
	v_add_co_u32 v33, s0, v17, v15
	v_sub_co_ci_u32_e32 v12, vcc_lo, v19, v20, vcc_lo
	v_add_co_ci_u32_e64 v34, s0, v26, v24, s0
	v_add_co_u32 v35, s0, v17, v14
	v_mad_i64_i32 v[2:3], null, 0x300b, v14, 0
	v_mad_i64_i32 v[4:5], null, 0x98e, v17, 0
	v_mad_i64_i32 v[6:7], null, 0x6254, v15, 0
	v_mad_i64_i32 v[8:9], null, 0x41b3, v16, 0
	v_add_co_u32 v13, vcc_lo, v29, v22
	v_add_co_ci_u32_e64 v14, s0, v26, v23, s0
	v_add_co_u32 v23, s0, v16, v15
	v_add_co_ci_u32_e32 v19, vcc_lo, v21, v12, vcc_lo
	v_add_co_ci_u32_e64 v15, s0, v25, v24, s0
	v_add_co_u32 v24, vcc_lo, v33, v31
	v_mad_u64_u32 v[10:11], null, 0xffffe333, v35, v[2:3]
	v_mad_u64_u32 v[2:3], null, 0xffffe333, v35, v[4:5]
	v_mad_u64_u32 v[4:5], null, 0xffffadfd, v23, v[6:7]
	v_mad_u64_u32 v[6:7], null, 0xffffadfd, v23, v[8:9]
	v_mad_u64_u32 v[8:9], null, v13, s1, 0x4000
	v_mul_i32_i24_e32 v25, 0xffffc4df, v12
	v_mad_u64_u32 v[12:13], null, v24, s2, 0x4000
	v_add_co_u32 v16, s0, v27, 2
	v_add_co_ci_u32_e32 v26, vcc_lo, v34, v32, vcc_lo
	v_add_co_ci_u32_e64 v17, s0, 0, v28, s0
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_add_co_u32 v24, vcc_lo, v16, v18
	v_mad_i32_i24 v9, 0x1151, v19, v9
	v_mad_i32_i24 v13, 0x25a1, v26, v13
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_ci_u32_e32 v27, vcc_lo, v17, v30, vcc_lo
	v_sub_co_u32 v28, vcc_lo, v16, v18
	v_sub_co_ci_u32_e32 v30, vcc_lo, v17, v30, vcc_lo
	v_mad_i32_i24 v11, 0xffffe333, v14, v11
	v_mad_i32_i24 v3, 0xffffe333, v14, v3
	v_mad_i32_i24 v5, 0xffffadfd, v15, v5
	v_mad_i32_i24 v36, 0xffffadfd, v15, v7
	v_mad_u64_u32 v[14:15], null, 0x187e, v29, v[8:9]
	v_mad_u64_u32 v[16:17], null, 0xffffc4df, v22, v[8:9]
	v_mad_u64_u32 v[7:8], null, 0xfffff384, v31, v[12:13]
	v_mad_u64_u32 v[18:19], null, 0xffffc13b, v33, v[12:13]
	v_mul_lo_u32 v20, 0x7fff, v22
	v_mad_i32_i24 v12, 0x187e, v21, v15
	v_sub_nc_u32_e32 v11, v11, v35
	v_sub_nc_u32_e32 v5, v5, v23
	v_mad_i32_i24 v8, 0xfffff384, v32, v8
	v_add_co_u32 v10, vcc_lo, v10, v7
	v_mad_i32_i24 v15, 0xffffc13b, v34, v19
	v_alignbit_b32 v12, v12, v14, 15
	s_delay_alu instid0(VALU_DEP_4)
	v_sub_nc_u32_e32 v8, v8, v31
	v_add3_u32 v13, v25, v17, v20
	v_sub_nc_u32_e32 v17, v36, v23
	v_sub_nc_u32_e32 v14, v15, v33
	v_sub_nc_u32_e32 v3, v3, v35
	v_add_co_ci_u32_e32 v11, vcc_lo, v11, v8, vcc_lo
	v_add_co_u32 v4, vcc_lo, v4, v18
	s_delay_alu instid0(VALU_DEP_4)
	v_add_co_ci_u32_e32 v5, vcc_lo, v5, v14, vcc_lo
	v_add_co_u32 v6, vcc_lo, v6, v7
	v_add_co_ci_u32_e32 v7, vcc_lo, v17, v8, vcc_lo
	v_add_co_u32 v2, vcc_lo, v2, v18
	v_alignbit_b32 v24, v27, v24, 2
	v_add_co_ci_u32_e32 v3, vcc_lo, v3, v14, vcc_lo
	v_alignbit_b32 v8, v11, v10, 15
	v_alignbit_b32 v9, v30, v28, 2
	v_alignbit_b32 v4, v5, v4, 15
	v_alignbit_b32 v5, v7, v6, 15
	v_alignbit_b32 v13, v13, v16, 15
	global_store_b32 v[0:1], v24, off
	v_alignbit_b32 v2, v3, v2, 15
	s_clause 0x6
	global_store_b32 v[0:1], v12, off offset:64
	global_store_b32 v[0:1], v8, off offset:32
	global_store_b32 v[0:1], v9, off offset:128
	global_store_b32 v[0:1], v4, off offset:96
	global_store_b32 v[0:1], v5, off offset:160
	global_store_b32 v[0:1], v13, off offset:192
	global_store_b32 v[0:1], v2, off offset:224
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z12islow_cuda_2Pi
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 264
		.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 37
		.amdhsa_next_free_sgpr 16
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end1:
	.size	_Z12islow_cuda_2Pi, .Lfunc_end1-_Z12islow_cuda_2Pi
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 964
; NumSgprs: 18
; NumVgprs: 37
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 4
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 37
; 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:     hidden_block_count_x
      - .offset:         20
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         24
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         28
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         30
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         32
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         34
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         36
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         38
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         80
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 272
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z12islow_cuda_1PiS_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z12islow_cuda_1PiS_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     35
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
      - .offset:         8
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         12
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         16
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         20
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         22
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         24
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         26
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         28
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         30
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         48
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         56
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         64
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         72
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 264
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z12islow_cuda_2Pi
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z12islow_cuda_2Pi.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     37
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
