#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<cuda.h>
#define INPUT_SIZE 100000000
#define PRIME_RANGE 1000000
#define BLOCK_SIZE 32
typedef unsigned long long int uint64_c;

void initializeInput(char* , int );
int generate_seed_primes(char*, int*, uint64_c);
void copy_seed_primes(uint64_c *,int *,int);
void print_primelist(uint64_c *, uint64_c);
void print_inputlist(uint64_c *input_list,uint64_c range);
void initializing_inputlist(uint64_c *input_list, uint64_c start,uint64_c range);
void calculatePrime(uint64_c* , uint64_c* , uint64_c ,uint64_c);
void appending_prime(uint64_c* input_list, uint64_c* prime_list, uint64_c range, uint64_c prev_number_of_primes, uint64_c number_of_primes);
uint64_c counting_primes(uint64_c*, uint64_c, uint64_c);

//KERNAL CODE GOES HERE!!


__global__ void prime_generator(uint64_c* d_input_list, uint64_c* d_prime_list, uint64_c* d_range,uint64_c* d_number_of_primes)
{


    int p= blockIdx.x * blockDim.x + threadIdx.x;
    int prime = d_prime_list[p];

        for(uint64_c i=0;i<d_range[0];i++){


                        if(d_input_list[i] % prime ==0)
                        {
                                d_input_list[i]=0;
                                
                               
                        }
                
        }



}


//KERNAL CODE ENDS HERE!!!


int main()
{


 cudaSetDevice(1);

// This code is just to generate the seed prime numbers
        int input_size=100;
        char *input;
        uint64_c n= 10 ;// seed prime list.
        int *seed_primelist;
        input=(char *)malloc(input_size*sizeof(char));
        initializeInput(input, input_size);
        seed_primelist=(int *)malloc(input_size*sizeof(int));
        int num_of_seed = generate_seed_primes(input,seed_primelist,n);
    
        uint64_c* input_list;
        uint64_c* prime_list;
        uint64_c number_of_primes= num_of_seed; 
        prime_list=(uint64_c *)malloc(number_of_primes*sizeof(uint64_c));
        copy_seed_primes(prime_list,seed_primelist,num_of_seed);

        uint64_c* d_input_list;
        uint64_c* d_prime_list;
        uint64_c* d_number_of_primes;
	uint64_c* d_range;

       
            for(int i=0;i<3;i++){


                uint64_c start=n;
                uint64_c end=pow(n,2);
                printf("CALCULATING PRIMES FROM 0 - %llu\n",end);
                uint64_c range=end-start;
                input_list=(uint64_c *)malloc(range*sizeof(uint64_c));
                initializing_inputlist(input_list,start,range);
		

		if(cudaMalloc((void **)&d_input_list,range*sizeof(uint64_c))!=cudaSuccess)
                {
                    printf("Error:  1\n");
                }
                
                if(cudaMemcpy(d_input_list,input_list,range*sizeof(uint64_c),cudaMemcpyHostToDevice)!=cudaSuccess)
                {
                    printf("copy Error:  1\n");
                }

                if(cudaMalloc((void **)&d_prime_list,number_of_primes*sizeof(uint64_c))!=cudaSuccess)
                {
                    printf("Error:  2\n");
                }

                if(cudaMemcpy(d_prime_list,prime_list,number_of_primes*sizeof(uint64_c),cudaMemcpyHostToDevice)!=cudaSuccess)
                {
                    printf("copy Error:  2\n");
                }

                if(cudaMalloc((void **)&d_range,sizeof(uint64_c))!=cudaSuccess)
                {
                    printf("Error:  3\n");
                }
                
                if(cudaMemcpy(d_range,&range,sizeof(uint64_c),cudaMemcpyHostToDevice)!=cudaSuccess)
                {
                    printf("copy Error:  3\n");
                }

                if(cudaMalloc((void **)&d_number_of_primes,sizeof(uint64_c))!=cudaSuccess)
                {
                    printf("Error:  4\n");
                }
                
                if(cudaMemcpy(d_number_of_primes,&number_of_primes,sizeof(uint64_c),cudaMemcpyHostToDevice)!=cudaSuccess)
                {
                    printf("copy Error:  4\n");
                }







              
             //   calculatePrime(input_list,prime_list,range,number_of_primes);

		prime_generator<<<43,32>>>(d_input_list,d_prime_list,d_range,d_number_of_primes);

		if(cudaMemcpy(input_list,d_input_list,range*sizeof(uint64_c),cudaMemcpyDeviceToHost)!=cudaSuccess)
                {
                    printf("copy Host Error:  1\n");
			exit(0);
                }





                
                //print_inputlist(input_list,range);
                uint64_c previous_number_of_primes= number_of_primes;
                number_of_primes = counting_primes(input_list, range, number_of_primes)+previous_number_of_primes;
                printf("THE NUMBER OF PRIMES ARE: %llu\n",number_of_primes);
                prime_list=(uint64_c *)realloc(prime_list,number_of_primes*sizeof(uint64_c));
                appending_prime(input_list, prime_list,  range, previous_number_of_primes, number_of_primes);
                print_primelist(prime_list,number_of_primes);
                n=pow(n,2);
                printf("******************************************\n\n");

            }







    
        return 0;

 }



int generate_seed_primes(char *input,int *primelist, uint64_c n)
{
    for (int p=2; p*p<=n; p++)
    {
         if (input[p] == 'P')
        {
            for (int i=p*2; i<=n; i += p)
                input[i] = 'N';
        }
    }




int i=0;
    for (int p=2; p<=n; p++){


       if (input[p]=='P')
       {

          primelist[i]=p;
          i++;
       }



   }

   return i;

}

void initializeInput(char *input, int input_size)
{

    for(int i=0;i<input_size;i++)
    {
        input[i]='P';
    }

}

void initializing_inputlist(uint64_c *input_list, uint64_c start,uint64_c range){

        for(uint64_c i=0;i<range;i++)
        {
                input_list[i]=start+i;

        }


}

void print_inputlist(uint64_c *input_list,uint64_c range)
{

        for(uint64_c i=0;i<range;i++)
        {
                printf("%llu\t--->\t%llu\n", i,input_list[i]);
        }


}

void print_primelist(uint64_c *prime_list,uint64_c number_of_primes)
{

        for(uint64_c i=0;i<number_of_primes;i++)
        {
                printf("%llu\n",prime_list[i]);
        }


}


void copy_seed_primes(uint64_c *prime_list,int * seed_primelist,int num_of_seed)
{
        

        for(int i=0;i<num_of_seed;i++)
        {
                prime_list[i]=seed_primelist[i];
                
        }

}



void calculatePrime(uint64_c* input_list, uint64_c* prime_list, uint64_c range,uint64_c number_of_primes)
{
        
       // print_primelist(prime_list,number_of_primes);
            for(uint64_c i=0;i<range;i++)
        {
                for(uint64_c j=0;j<number_of_primes;j++){


                

                        if(input_list[i] % prime_list[j]==0)
                        {
                                input_list[i]=0;
                                
                               
                        }



                }
        }
        

}

void appending_prime(uint64_c* input_list, uint64_c* prime_list, uint64_c range, uint64_c prev_number_of_primes, uint64_c number_of_primes)
 {

                for(uint64_c i=0;i<range;i++)
                {
                        if(input_list[i]>0){
                            //printf("XXXXXXXXX>>> %llu\n", input_list[i]);
                            prime_list[prev_number_of_primes]=input_list[i];
                            prev_number_of_primes++;
                        }

                }
               // printf("the number he he ha ha... %llu\n",prev_number_of_primes);

                //exit(0);
                

 }

uint64_c counting_primes(uint64_c* input_list,uint64_c range,uint64_c number_of_primes)
{  
    
    int prime=0;

    for(uint64_c i=0;i<range;i++)
    {
        if(input_list[i]>0)
        {
            prime++;
        }
    }

    return prime;

}


	.file	"tmpxft_0020a317_00000000-6_primegpu.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2039:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2039:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z20generate_seed_primesPcPiy
	.type	_Z20generate_seed_primesPcPiy, @function
_Z20generate_seed_primesPcPiy:
.LFB2028:
	.cfi_startproc
	endbr64
	movl	$2, %eax
.L3:
	movl	%eax, %ecx
	imull	%eax, %ecx
	movslq	%ecx, %rcx
	cmpq	%rcx, %rdx
	jb	.L13
	cmpb	$80, (%rdi,%rax)
	je	.L4
.L7:
	incq	%rax
	jmp	.L3
.L4:
	leal	(%rax,%rax), %ecx
	movslq	%ecx, %rcx
.L5:
	cmpq	%rcx, %rdx
	jb	.L7
	movb	$78, (%rdi,%rcx)
	addq	%rax, %rcx
	jmp	.L5
.L13:
	movl	$2, %eax
	xorl	%ecx, %ecx
.L9:
	cmpq	%rax, %rdx
	jb	.L14
	cmpb	$80, (%rdi,%rax)
	jne	.L10
	movslq	%ecx, %r8
	incl	%ecx
	movl	%eax, (%rsi,%r8,4)
.L10:
	incq	%rax
	jmp	.L9
.L14:
	movl	%ecx, %eax
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z20generate_seed_primesPcPiy, .-_Z20generate_seed_primesPcPiy
	.globl	_Z15initializeInputPci
	.type	_Z15initializeInputPci, @function
_Z15initializeInputPci:
.LFB2029:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L16:
	cmpl	%eax, %esi
	jle	.L18
	movb	$80, (%rdi,%rax)
	incq	%rax
	jmp	.L16
.L18:
	ret
	.cfi_endproc
.LFE2029:
	.size	_Z15initializeInputPci, .-_Z15initializeInputPci
	.globl	_Z22initializing_inputlistPyyy
	.type	_Z22initializing_inputlistPyyy, @function
_Z22initializing_inputlistPyyy:
.LFB2030:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L20:
	cmpq	%rdx, %rax
	je	.L22
	leaq	(%rax,%rsi), %rcx
	movq	%rcx, (%rdi,%rax,8)
	incq	%rax
	jmp	.L20
.L22:
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z22initializing_inputlistPyyy, .-_Z22initializing_inputlistPyyy
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%llu\t--->\t%llu\n"
	.text
	.globl	_Z15print_inputlistPyy
	.type	_Z15print_inputlistPyy, @function
_Z15print_inputlistPyy:
.LFB2031:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	xorl	%ebx, %ebx
	pushq	%rdx
	.cfi_def_cfa_offset 48
.L24:
	cmpq	%rbp, %rbx
	je	.L27
	movq	(%r12,%rbx,8), %rcx
	movq	%rbx, %rdx
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%rbx
	call	__printf_chk@PLT
	jmp	.L24
.L27:
	popq	%rax
	.cfi_def_cfa_offset 40
	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
.LFE2031:
	.size	_Z15print_inputlistPyy, .-_Z15print_inputlistPyy
	.section	.rodata.str1.1
.LC1:
	.string	"%llu\n"
	.text
	.globl	_Z15print_primelistPyy
	.type	_Z15print_primelistPyy, @function
_Z15print_primelistPyy:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rsi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	xorl	%ebx, %ebx
	pushq	%rdx
	.cfi_def_cfa_offset 48
.L29:
	cmpq	%rbp, %rbx
	je	.L32
	movq	(%r12,%rbx,8), %rdx
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	incq	%rbx
	call	__printf_chk@PLT
	jmp	.L29
.L32:
	popq	%rax
	.cfi_def_cfa_offset 40
	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
.LFE2032:
	.size	_Z15print_primelistPyy, .-_Z15print_primelistPyy
	.globl	_Z16copy_seed_primesPyPii
	.type	_Z16copy_seed_primesPyPii, @function
_Z16copy_seed_primesPyPii:
.LFB2033:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L34:
	cmpl	%eax, %edx
	jle	.L36
	movslq	(%rsi,%rax,4), %rcx
	movq	%rcx, (%rdi,%rax,8)
	incq	%rax
	jmp	.L34
.L36:
	ret
	.cfi_endproc
.LFE2033:
	.size	_Z16copy_seed_primesPyPii, .-_Z16copy_seed_primesPyPii
	.globl	_Z14calculatePrimePyS_yy
	.type	_Z14calculatePrimePyS_yy, @function
_Z14calculatePrimePyS_yy:
.LFB2034:
	.cfi_startproc
	endbr64
	movq	%rdx, %r10
	xorl	%r8d, %r8d
.L38:
	cmpq	%r10, %r8
	je	.L43
	xorl	%r9d, %r9d
.L41:
	cmpq	%rcx, %r9
	je	.L44
	movq	(%rdi,%r8,8), %rax
	xorl	%edx, %edx
	divq	(%rsi,%r9,8)
	testq	%rdx, %rdx
	jne	.L39
	xorl	%eax, %eax
	movq	%rax, (%rdi,%r8,8)
.L39:
	incq	%r9
	jmp	.L41
.L44:
	incq	%r8
	jmp	.L38
.L43:
	ret
	.cfi_endproc
.LFE2034:
	.size	_Z14calculatePrimePyS_yy, .-_Z14calculatePrimePyS_yy
	.globl	_Z15appending_primePyS_yyy
	.type	_Z15appending_primePyS_yyy, @function
_Z15appending_primePyS_yyy:
.LFB2035:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L46:
	cmpq	%rdx, %rax
	je	.L52
	movq	(%rdi,%rax,8), %r8
	testq	%r8, %r8
	je	.L47
	movq	%r8, (%rsi,%rcx,8)
	incq	%rcx
.L47:
	incq	%rax
	jmp	.L46
.L52:
	ret
	.cfi_endproc
.LFE2035:
	.size	_Z15appending_primePyS_yyy, .-_Z15appending_primePyS_yyy
	.globl	_Z15counting_primesPyyy
	.type	_Z15counting_primesPyyy, @function
_Z15counting_primesPyyy:
.LFB2036:
	.cfi_startproc
	endbr64
	xorl	%edx, %edx
	xorl	%eax, %eax
.L54:
	cmpq	%rsi, %rdx
	je	.L57
	cmpq	$0, (%rdi,%rdx,8)
	je	.L55
	incl	%eax
.L55:
	incq	%rdx
	jmp	.L54
.L57:
	cltq
	ret
	.cfi_endproc
.LFE2036:
	.size	_Z15counting_primesPyyy, .-_Z15counting_primesPyyy
	.globl	_Z41__device_stub__Z15prime_generatorPyS_S_S_PyS_S_S_
	.type	_Z41__device_stub__Z15prime_generatorPyS_S_S_PyS_S_S_, @function
_Z41__device_stub__Z15prime_generatorPyS_S_S_PyS_S_S_:
.LFB2061:
	.cfi_startproc
	endbr64
	subq	$152, %rsp
	.cfi_def_cfa_offset 160
	movq	%rdi, 24(%rsp)
	leaq	56(%rsp), %rdi
	movq	%rsi, 16(%rsp)
	leaq	68(%rsp), %rsi
	movq	%rdx, 8(%rsp)
	leaq	40(%rsp), %rdx
	movq	%rcx, (%rsp)
	leaq	48(%rsp), %rcx
	movq	%fs:40, %rax
	movq	%rax, 136(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rax
	movl	$1, 64(%rsp)
	movq	%rax, 104(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 112(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 120(%rsp)
	movq	%rsp, %rax
	movq	%rax, 128(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 56(%rsp)
	movq	%rax, 68(%rsp)
	movl	$1, 76(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L58
	pushq	48(%rsp)
	.cfi_def_cfa_offset 168
	leaq	_Z15prime_generatorPyS_S_S_(%rip), %rdi
	pushq	48(%rsp)
	.cfi_def_cfa_offset 176
	movq	84(%rsp), %rcx
	movl	92(%rsp), %r8d
	movq	72(%rsp), %rsi
	movl	80(%rsp), %edx
	leaq	120(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 168
	popq	%rdx
	.cfi_def_cfa_offset 160
.L58:
	movq	136(%rsp), %rax
	subq	%fs:40, %rax
	je	.L60
	call	__stack_chk_fail@PLT
.L60:
	addq	$152, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2061:
	.size	_Z41__device_stub__Z15prime_generatorPyS_S_S_PyS_S_S_, .-_Z41__device_stub__Z15prime_generatorPyS_S_S_PyS_S_S_
	.globl	_Z15prime_generatorPyS_S_S_
	.type	_Z15prime_generatorPyS_S_S_, @function
_Z15prime_generatorPyS_S_S_:
.LFB2062:
	.cfi_startproc
	endbr64
	jmp	_Z41__device_stub__Z15prime_generatorPyS_S_S_PyS_S_S_
	.cfi_endproc
.LFE2062:
	.size	_Z15prime_generatorPyS_S_S_, .-_Z15prime_generatorPyS_S_S_
	.section	.rodata.str1.1
.LC3:
	.string	"CALCULATING PRIMES FROM 0 - %llu\n"
.LC4:
	.string	"Error:  1\n"
.LC5:
	.string	"copy Error:  1\n"
.LC6:
	.string	"Error:  2\n"
.LC7:
	.string	"copy Error:  2\n"
.LC8:
	.string	"Error:  3\n"
.LC9:
	.string	"copy Error:  3\n"
.LC10:
	.string	"Error:  4\n"
.LC11:
	.string	"copy Error:  4\n"
.LC12:
	.string	"copy Host Error:  1\n"
.LC13:
	.string	"THE NUMBER OF PRIMES ARE: %llu\n"
.LC14:
	.string	"******************************************\n\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$1, %edi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	call	cudaSetDevice@PLT
	movl	$100, %edi
	call	malloc@PLT
	movl	$100, %esi
	movq	%rax, %rdi
	movq	%rax, %rbp
	call	_Z15initializeInputPci
	movl	$400, %edi
	call	malloc@PLT
	movl	$10, %edx
	movq	%rbp, %rdi
	movq	%rax, %rsi
	movq	%rax, %rbx
	call	_Z20generate_seed_primesPcPiy
	movslq	%eax, %rdi
	movq	%rdi, %r12
	movq	%rdi, 16(%rsp)
	salq	$3, %rdi
	call	malloc@PLT
	movl	%r12d, %edx
	movq	%rbx, %rsi
	movl	$3, %r12d
	movq	%rax, %rdi
	movq	%rax, %rbp
	movl	$10, %ebx
	call	_Z16copy_seed_primesPyPii
.L78:
	testq	%rbx, %rbx
	js	.L64
	cvtsi2sdq	%rbx, %xmm0
	jmp	.L65
.L64:
	movq	%rbx, %rax
	movq	%rbx, %rdx
	shrq	%rax
	andl	$1, %edx
	orq	%rdx, %rax
	cvtsi2sdq	%rax, %xmm0
	addsd	%xmm0, %xmm0
.L65:
	mulsd	%xmm0, %xmm0
	movq	%rbx, %r13
	comisd	.LC2(%rip), %xmm0
	jnb	.L66
	cvttsd2siq	%xmm0, %rbx
	jmp	.L67
.L66:
	subsd	.LC2(%rip), %xmm0
	cvttsd2siq	%xmm0, %rbx
	btcq	$63, %rbx
.L67:
	leaq	.LC3(%rip), %rsi
	movq	%rbx, %rdx
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%rbx, %rdx
	subq	%r13, %rdx
	leaq	0(,%rdx,8), %r15
	movq	%rdx, 56(%rsp)
	movq	%r15, %rdi
	movq	%rdx, 8(%rsp)
	call	malloc@PLT
	movq	8(%rsp), %rdx
	movq	%r13, %rsi
	movq	%rax, %rdi
	movq	%rax, %r14
	call	_Z22initializing_inputlistPyyy
	leaq	24(%rsp), %rdi
	movq	%r15, %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L68
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L68:
	movq	56(%rsp), %rax
	movq	24(%rsp), %rdi
	movl	$1, %ecx
	movq	%r14, %rsi
	leaq	0(,%rax,8), %rdx
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L69
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L69:
	movq	16(%rsp), %rax
	leaq	32(%rsp), %rdi
	leaq	0(,%rax,8), %rsi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L70
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L70:
	movq	16(%rsp), %rax
	movq	32(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbp, %rsi
	leaq	0(,%rax,8), %rdx
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L71
	leaq	.LC7(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L71:
	leaq	48(%rsp), %rdi
	movl	$8, %esi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L72
	leaq	.LC8(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L72:
	movq	48(%rsp), %rdi
	leaq	56(%rsp), %rsi
	movl	$1, %ecx
	movl	$8, %edx
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L73
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L73:
	leaq	40(%rsp), %rdi
	movl	$8, %esi
	call	cudaMalloc@PLT
	testl	%eax, %eax
	je	.L74
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L74:
	movq	40(%rsp), %rdi
	leaq	16(%rsp), %rsi
	movl	$1, %ecx
	movl	$8, %edx
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L75
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L75:
	movl	$134217729, %edx
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	salq	$5, %rdx
	movl	$1, %esi
	movabsq	$4294967339, %rdi
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L76
	movq	40(%rsp), %rcx
	movq	48(%rsp), %rdx
	movq	32(%rsp), %rsi
	movq	24(%rsp), %rdi
	call	_Z41__device_stub__Z15prime_generatorPyS_S_S_PyS_S_S_
.L76:
	movq	56(%rsp), %rax
	movq	24(%rsp), %rsi
	movl	$2, %ecx
	movq	%r14, %rdi
	leaq	0(,%rax,8), %rdx
	call	cudaMemcpy@PLT
	testl	%eax, %eax
	je	.L77
	movl	$2, %edi
	leaq	.LC12(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%edi, %edi
	call	exit@PLT
.L77:
	movq	16(%rsp), %r13
	movq	56(%rsp), %rsi
	movq	%r14, %rdi
	movq	%r13, %rdx
	call	_Z15counting_primesPyyy
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	leaq	(%rax,%r13), %rdx
	xorl	%eax, %eax
	movq	%rdx, 16(%rsp)
	call	__printf_chk@PLT
	movq	16(%rsp), %r15
	movq	%rbp, %rdi
	leaq	0(,%r15,8), %rsi
	call	realloc@PLT
	movq	56(%rsp), %rdx
	movq	%r15, %r8
	movq	%r13, %rcx
	movq	%rax, %rbp
	movq	%rax, %rsi
	movq	%r14, %rdi
	call	_Z15appending_primePyS_yyy
	movq	%r15, %rsi
	movq	%rbp, %rdi
	call	_Z15print_primelistPyy
	xorl	%eax, %eax
	movl	$2, %edi
	leaq	.LC14(%rip), %rsi
	call	__printf_chk@PLT
	decl	%r12d
	jne	.L78
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L79
	call	__stack_chk_fail@PLT
.L79:
	addq	$104, %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
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC15:
	.string	"_Z15prime_generatorPyS_S_S_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2064:
	.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	.LC15(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z15prime_generatorPyS_S_S_(%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
.LFE2064:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC2:
	.long	0
	.long	1138753536
	.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<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<hip/hip_runtime.h>
#define INPUT_SIZE 100000000
#define PRIME_RANGE 1000000
#define BLOCK_SIZE 32
typedef unsigned long long int uint64_c;

void initializeInput(char* , int );
int generate_seed_primes(char*, int*, uint64_c);
void copy_seed_primes(uint64_c *,int *,int);
void print_primelist(uint64_c *, uint64_c);
void print_inputlist(uint64_c *input_list,uint64_c range);
void initializing_inputlist(uint64_c *input_list, uint64_c start,uint64_c range);
void calculatePrime(uint64_c* , uint64_c* , uint64_c ,uint64_c);
void appending_prime(uint64_c* input_list, uint64_c* prime_list, uint64_c range, uint64_c prev_number_of_primes, uint64_c number_of_primes);
uint64_c counting_primes(uint64_c*, uint64_c, uint64_c);

//KERNAL CODE GOES HERE!!


__global__ void prime_generator(uint64_c* d_input_list, uint64_c* d_prime_list, uint64_c* d_range,uint64_c* d_number_of_primes)
{


    int p= blockIdx.x * blockDim.x + threadIdx.x;
    int prime = d_prime_list[p];

        for(uint64_c i=0;i<d_range[0];i++){


                        if(d_input_list[i] % prime ==0)
                        {
                                d_input_list[i]=0;
                                
                               
                        }
                
        }



}


//KERNAL CODE ENDS HERE!!!


int main()
{


 hipSetDevice(1);

// This code is just to generate the seed prime numbers
        int input_size=100;
        char *input;
        uint64_c n= 10 ;// seed prime list.
        int *seed_primelist;
        input=(char *)malloc(input_size*sizeof(char));
        initializeInput(input, input_size);
        seed_primelist=(int *)malloc(input_size*sizeof(int));
        int num_of_seed = generate_seed_primes(input,seed_primelist,n);
    
        uint64_c* input_list;
        uint64_c* prime_list;
        uint64_c number_of_primes= num_of_seed; 
        prime_list=(uint64_c *)malloc(number_of_primes*sizeof(uint64_c));
        copy_seed_primes(prime_list,seed_primelist,num_of_seed);

        uint64_c* d_input_list;
        uint64_c* d_prime_list;
        uint64_c* d_number_of_primes;
	uint64_c* d_range;

       
            for(int i=0;i<3;i++){


                uint64_c start=n;
                uint64_c end=pow(n,2);
                printf("CALCULATING PRIMES FROM 0 - %llu\n",end);
                uint64_c range=end-start;
                input_list=(uint64_c *)malloc(range*sizeof(uint64_c));
                initializing_inputlist(input_list,start,range);
		

		if(hipMalloc((void **)&d_input_list,range*sizeof(uint64_c))!=hipSuccess)
                {
                    printf("Error:  1\n");
                }
                
                if(hipMemcpy(d_input_list,input_list,range*sizeof(uint64_c),hipMemcpyHostToDevice)!=hipSuccess)
                {
                    printf("copy Error:  1\n");
                }

                if(hipMalloc((void **)&d_prime_list,number_of_primes*sizeof(uint64_c))!=hipSuccess)
                {
                    printf("Error:  2\n");
                }

                if(hipMemcpy(d_prime_list,prime_list,number_of_primes*sizeof(uint64_c),hipMemcpyHostToDevice)!=hipSuccess)
                {
                    printf("copy Error:  2\n");
                }

                if(hipMalloc((void **)&d_range,sizeof(uint64_c))!=hipSuccess)
                {
                    printf("Error:  3\n");
                }
                
                if(hipMemcpy(d_range,&range,sizeof(uint64_c),hipMemcpyHostToDevice)!=hipSuccess)
                {
                    printf("copy Error:  3\n");
                }

                if(hipMalloc((void **)&d_number_of_primes,sizeof(uint64_c))!=hipSuccess)
                {
                    printf("Error:  4\n");
                }
                
                if(hipMemcpy(d_number_of_primes,&number_of_primes,sizeof(uint64_c),hipMemcpyHostToDevice)!=hipSuccess)
                {
                    printf("copy Error:  4\n");
                }







              
             //   calculatePrime(input_list,prime_list,range,number_of_primes);

		prime_generator<<<43,32>>>(d_input_list,d_prime_list,d_range,d_number_of_primes);

		if(hipMemcpy(input_list,d_input_list,range*sizeof(uint64_c),hipMemcpyDeviceToHost)!=hipSuccess)
                {
                    printf("copy Host Error:  1\n");
			exit(0);
                }





                
                //print_inputlist(input_list,range);
                uint64_c previous_number_of_primes= number_of_primes;
                number_of_primes = counting_primes(input_list, range, number_of_primes)+previous_number_of_primes;
                printf("THE NUMBER OF PRIMES ARE: %llu\n",number_of_primes);
                prime_list=(uint64_c *)realloc(prime_list,number_of_primes*sizeof(uint64_c));
                appending_prime(input_list, prime_list,  range, previous_number_of_primes, number_of_primes);
                print_primelist(prime_list,number_of_primes);
                n=pow(n,2);
                printf("******************************************\n\n");

            }







    
        return 0;

 }



int generate_seed_primes(char *input,int *primelist, uint64_c n)
{
    for (int p=2; p*p<=n; p++)
    {
         if (input[p] == 'P')
        {
            for (int i=p*2; i<=n; i += p)
                input[i] = 'N';
        }
    }




int i=0;
    for (int p=2; p<=n; p++){


       if (input[p]=='P')
       {

          primelist[i]=p;
          i++;
       }



   }

   return i;

}

void initializeInput(char *input, int input_size)
{

    for(int i=0;i<input_size;i++)
    {
        input[i]='P';
    }

}

void initializing_inputlist(uint64_c *input_list, uint64_c start,uint64_c range){

        for(uint64_c i=0;i<range;i++)
        {
                input_list[i]=start+i;

        }


}

void print_inputlist(uint64_c *input_list,uint64_c range)
{

        for(uint64_c i=0;i<range;i++)
        {
                printf("%llu\t--->\t%llu\n", i,input_list[i]);
        }


}

void print_primelist(uint64_c *prime_list,uint64_c number_of_primes)
{

        for(uint64_c i=0;i<number_of_primes;i++)
        {
                printf("%llu\n",prime_list[i]);
        }


}


void copy_seed_primes(uint64_c *prime_list,int * seed_primelist,int num_of_seed)
{
        

        for(int i=0;i<num_of_seed;i++)
        {
                prime_list[i]=seed_primelist[i];
                
        }

}



void calculatePrime(uint64_c* input_list, uint64_c* prime_list, uint64_c range,uint64_c number_of_primes)
{
        
       // print_primelist(prime_list,number_of_primes);
            for(uint64_c i=0;i<range;i++)
        {
                for(uint64_c j=0;j<number_of_primes;j++){


                

                        if(input_list[i] % prime_list[j]==0)
                        {
                                input_list[i]=0;
                                
                               
                        }



                }
        }
        

}

void appending_prime(uint64_c* input_list, uint64_c* prime_list, uint64_c range, uint64_c prev_number_of_primes, uint64_c number_of_primes)
 {

                for(uint64_c i=0;i<range;i++)
                {
                        if(input_list[i]>0){
                            //printf("XXXXXXXXX>>> %llu\n", input_list[i]);
                            prime_list[prev_number_of_primes]=input_list[i];
                            prev_number_of_primes++;
                        }

                }
               // printf("the number he he ha ha... %llu\n",prev_number_of_primes);

                //exit(0);
                

 }

uint64_c counting_primes(uint64_c* input_list,uint64_c range,uint64_c number_of_primes)
{  
    
    int prime=0;

    for(uint64_c i=0;i<range;i++)
    {
        if(input_list[i]>0)
        {
            prime++;
        }
    }

    return prime;

}


	.text
	.file	"primegpu.hip"
	.globl	_Z30__device_stub__prime_generatorPyS_S_S_ # -- Begin function _Z30__device_stub__prime_generatorPyS_S_S_
	.type	_Z30__device_stub__prime_generatorPyS_S_S_,@function
_Z30__device_stub__prime_generatorPyS_S_S_: # @_Z30__device_stub__prime_generatorPyS_S_S_
	.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), %rdi
	movq	%rsi, (%rdi)
	leaq	24(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	16(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	80(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%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	$_Z15prime_generatorPyS_S_S_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$128, %rsp
	.cfi_adjust_cfa_offset -128
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z30__device_stub__prime_generatorPyS_S_S_, .Lfunc_end0-_Z30__device_stub__prime_generatorPyS_S_S_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst16,"aM",@progbits,16
	.p2align	4, 0x0                          # -- Begin function main
.LCPI1_0:
	.zero	16,80
.LCPI1_1:
	.long	1127219200                      # 0x43300000
	.long	1160773632                      # 0x45300000
	.long	0                               # 0x0
	.long	0                               # 0x0
.LCPI1_2:
	.quad	0x4330000000000000              # double 4503599627370496
	.quad	0x4530000000000000              # double 1.9342813113834067E+25
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0
.LCPI1_3:
	.quad	0x43e0000000000000              # double 9.2233720368547758E+18
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$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
	movl	$1, %edi
	callq	hipSetDevice
	movl	$100, %edi
	callq	malloc
	movq	%rax, %rbx
	movapd	.LCPI1_0(%rip), %xmm0           # xmm0 = [80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80]
	movupd	%xmm0, (%rax)
	movupd	%xmm0, 16(%rax)
	movupd	%xmm0, 32(%rax)
	movupd	%xmm0, 48(%rax)
	movupd	%xmm0, 64(%rax)
	movupd	%xmm0, 80(%rax)
	movl	$1347440720, 96(%rax)           # imm = 0x50505050
	movl	$400, %edi                      # imm = 0x190
	callq	malloc
	movq	%rax, %r14
	movl	$10, %r15d
	movl	$10, %edx
	movq	%rbx, %rdi
	movq	%rax, %rsi
	callq	_Z20generate_seed_primesPcPiy
	movl	%eax, %ebp
	movslq	%eax, %r12
	movq	%r12, (%rsp)
	leaq	(,%r12,8), %rdi
	callq	malloc
	movq	%rax, %rbx
	testl	%r12d, %r12d
	jle	.LBB1_3
# %bb.1:                                # %.lr.ph.preheader.i
	movl	%ebp, %eax
	xorl	%ecx, %ecx
.LBB1_2:                                # %.lr.ph.i
                                        # =>This Inner Loop Header: Depth=1
	movslq	(%r14,%rcx,4), %rdx
	movq	%rdx, (%rbx,%rcx,8)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB1_2
.LBB1_3:                                # %_Z16copy_seed_primesPyPii.exit
	movabsq	$4294967328, %rax               # imm = 0x100000020
	addq	$11, %rax
	movq	%rax, 48(%rsp)                  # 8-byte Spill
	xorl	%r12d, %r12d
.LBB1_4:                                # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_6 Depth 2
                                        #     Child Loop BB1_29 Depth 2
                                        #     Child Loop BB1_33 Depth 2
                                        #     Child Loop BB1_38 Depth 2
	movq	%r15, %xmm0
	punpckldq	.LCPI1_1(%rip), %xmm0   # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
	subpd	.LCPI1_2(%rip), %xmm0
	movapd	%xmm0, %xmm1
	unpckhpd	%xmm0, %xmm1                    # xmm1 = xmm1[1],xmm0[1]
	addsd	%xmm0, %xmm1
	mulsd	%xmm1, %xmm1
	cvttsd2si	%xmm1, %rax
	movq	%rax, %rcx
	sarq	$63, %rcx
	subsd	.LCPI1_3(%rip), %xmm1
	cvttsd2si	%xmm1, %r13
	andq	%rcx, %r13
	orq	%rax, %r13
	movl	$.L.str, %edi
	movq	%r13, %rsi
	xorl	%eax, %eax
	callq	printf
	movq	%r13, %rbp
	subq	%r15, %rbp
	movq	%rbp, 8(%rsp)
	shlq	$3, %rbp
	movq	%rbp, %rdi
	callq	malloc
	movq	%rax, %r14
	cmpq	%r15, %r13
	je	.LBB1_7
# %bb.5:                                # %.lr.ph.i52.preheader
                                        #   in Loop: Header=BB1_4 Depth=1
	movq	%r14, %rax
.LBB1_6:                                # %.lr.ph.i52
                                        #   Parent Loop BB1_4 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%r15, (%rax)
	incq	%r15
	addq	$8, %rax
	cmpq	%r15, %r13
	jne	.LBB1_6
.LBB1_7:                                # %_Z22initializing_inputlistPyyy.exit
                                        #   in Loop: Header=BB1_4 Depth=1
	leaq	16(%rsp), %rdi
	movq	%rbp, %rsi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB1_9
# %bb.8:                                #   in Loop: Header=BB1_4 Depth=1
	movl	$.Lstr, %edi
	callq	puts@PLT
.LBB1_9:                                #   in Loop: Header=BB1_4 Depth=1
	movq	16(%rsp), %rdi
	movq	8(%rsp), %rdx
	shlq	$3, %rdx
	movq	%r14, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	je	.LBB1_11
# %bb.10:                               #   in Loop: Header=BB1_4 Depth=1
	movl	$.Lstr.1, %edi
	callq	puts@PLT
.LBB1_11:                               #   in Loop: Header=BB1_4 Depth=1
	movq	(%rsp), %rsi
	shlq	$3, %rsi
	leaq	40(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB1_13
# %bb.12:                               #   in Loop: Header=BB1_4 Depth=1
	movl	$.Lstr.2, %edi
	callq	puts@PLT
.LBB1_13:                               #   in Loop: Header=BB1_4 Depth=1
	movq	40(%rsp), %rdi
	movq	(%rsp), %rdx
	shlq	$3, %rdx
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	je	.LBB1_15
# %bb.14:                               #   in Loop: Header=BB1_4 Depth=1
	movl	$.Lstr.3, %edi
	callq	puts@PLT
.LBB1_15:                               #   in Loop: Header=BB1_4 Depth=1
	movl	$8, %esi
	leaq	24(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB1_17
# %bb.16:                               #   in Loop: Header=BB1_4 Depth=1
	movl	$.Lstr.4, %edi
	callq	puts@PLT
.LBB1_17:                               #   in Loop: Header=BB1_4 Depth=1
	movq	24(%rsp), %rdi
	movl	$8, %edx
	leaq	8(%rsp), %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	je	.LBB1_19
# %bb.18:                               #   in Loop: Header=BB1_4 Depth=1
	movl	$.Lstr.5, %edi
	callq	puts@PLT
.LBB1_19:                               #   in Loop: Header=BB1_4 Depth=1
	movl	$8, %esi
	leaq	32(%rsp), %rdi
	callq	hipMalloc
	testl	%eax, %eax
	je	.LBB1_21
# %bb.20:                               #   in Loop: Header=BB1_4 Depth=1
	movl	$.Lstr.6, %edi
	callq	puts@PLT
.LBB1_21:                               #   in Loop: Header=BB1_4 Depth=1
	movq	32(%rsp), %rdi
	movl	$8, %edx
	movq	%rsp, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	je	.LBB1_23
# %bb.22:                               #   in Loop: Header=BB1_4 Depth=1
	movl	$.Lstr.7, %edi
	callq	puts@PLT
.LBB1_23:                               #   in Loop: Header=BB1_4 Depth=1
	movq	48(%rsp), %rdi                  # 8-byte Reload
	movl	$1, %esi
	movabsq	$4294967328, %rdx               # imm = 0x100000020
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB1_25
# %bb.24:                               #   in Loop: Header=BB1_4 Depth=1
	movq	16(%rsp), %rdi
	movq	40(%rsp), %rsi
	movq	24(%rsp), %rdx
	movq	32(%rsp), %rcx
	callq	_Z30__device_stub__prime_generatorPyS_S_S_
.LBB1_25:                               #   in Loop: Header=BB1_4 Depth=1
	movq	16(%rsp), %rsi
	movq	8(%rsp), %rdx
	shlq	$3, %rdx
	movq	%r14, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB1_41
# %bb.26:                               #   in Loop: Header=BB1_4 Depth=1
	movq	8(%rsp), %rax
	testq	%rax, %rax
	je	.LBB1_27
# %bb.28:                               # %.lr.ph.i54.preheader
                                        #   in Loop: Header=BB1_4 Depth=1
	xorl	%ecx, %ecx
	xorl	%edx, %edx
.LBB1_29:                               # %.lr.ph.i54
                                        #   Parent Loop BB1_4 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	cmpq	$1, (%r14,%rcx,8)
	sbbl	$-1, %edx
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB1_29
# %bb.30:                               # %._crit_edge.loopexit.i
                                        #   in Loop: Header=BB1_4 Depth=1
	movl	%edx, %esi
	jmp	.LBB1_31
.LBB1_27:                               #   in Loop: Header=BB1_4 Depth=1
	xorl	%esi, %esi
.LBB1_31:                               # %_Z15counting_primesPyyy.exit
                                        #   in Loop: Header=BB1_4 Depth=1
	movq	(%rsp), %rbp
	addq	%rbp, %rsi
	movq	%rsi, (%rsp)
	movl	$.L.str.10, %edi
	xorl	%eax, %eax
	callq	printf
	movq	(%rsp), %r15
	leaq	(,%r15,8), %rsi
	movq	%rbx, %rdi
	callq	realloc
	movq	%rax, %rbx
	movq	8(%rsp), %rax
	testq	%rax, %rax
	je	.LBB1_36
# %bb.32:                               # %.lr.ph.i57.preheader
                                        #   in Loop: Header=BB1_4 Depth=1
	xorl	%ecx, %ecx
.LBB1_33:                               # %.lr.ph.i57
                                        #   Parent Loop BB1_4 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%r14,%rcx,8), %rdx
	testq	%rdx, %rdx
	je	.LBB1_35
# %bb.34:                               #   in Loop: Header=BB1_33 Depth=2
	movq	%rdx, (%rbx,%rbp,8)
	incq	%rbp
.LBB1_35:                               #   in Loop: Header=BB1_33 Depth=2
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB1_33
.LBB1_36:                               # %_Z15appending_primePyS_yyy.exit
                                        #   in Loop: Header=BB1_4 Depth=1
	testq	%r15, %r15
	je	.LBB1_39
# %bb.37:                               # %.lr.ph.i61.preheader
                                        #   in Loop: Header=BB1_4 Depth=1
	xorl	%r14d, %r14d
.LBB1_38:                               # %.lr.ph.i61
                                        #   Parent Loop BB1_4 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	(%rbx,%r14,8), %rsi
	movl	$.L.str.13, %edi
	xorl	%eax, %eax
	callq	printf
	incq	%r14
	cmpq	%r14, %r15
	jne	.LBB1_38
.LBB1_39:                               # %_Z15print_primelistPyy.exit
                                        #   in Loop: Header=BB1_4 Depth=1
	movl	$.Lstr.8, %edi
	callq	puts@PLT
	incl	%r12d
	movq	%r13, %r15
	cmpl	$3, %r12d
	jne	.LBB1_4
# %bb.40:
	xorl	%eax, %eax
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.LBB1_41:
	.cfi_def_cfa_offset 112
	movl	$.Lstr.9, %edi
	callq	puts@PLT
	xorl	%edi, %edi
	callq	exit
.Lfunc_end1:
	.size	main, .Lfunc_end1-main
	.cfi_endproc
                                        # -- End function
	.globl	_Z15initializeInputPci          # -- Begin function _Z15initializeInputPci
	.type	_Z15initializeInputPci,@function
_Z15initializeInputPci:                 # @_Z15initializeInputPci
	.cfi_startproc
# %bb.0:
	testl	%esi, %esi
	jle	.LBB2_1
# %bb.2:                                # %.lr.ph.preheader
	movl	%esi, %edx
	movl	$80, %esi
	jmp	memset@PLT                      # TAILCALL
.LBB2_1:                                # %._crit_edge
	retq
.Lfunc_end2:
	.size	_Z15initializeInputPci, .Lfunc_end2-_Z15initializeInputPci
	.cfi_endproc
                                        # -- End function
	.globl	_Z20generate_seed_primesPcPiy   # -- Begin function _Z20generate_seed_primesPcPiy
	.type	_Z20generate_seed_primesPcPiy,@function
_Z20generate_seed_primesPcPiy:          # @_Z20generate_seed_primesPcPiy
	.cfi_startproc
# %bb.0:
	cmpq	$4, %rdx
	jb	.LBB3_7
# %bb.1:                                # %.lr.ph35.preheader
	movl	$4, %eax
	movl	$2, %ecx
.LBB3_2:                                # %.lr.ph35
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_5 Depth 2
	cmpb	$80, (%rdi,%rcx)
	jne	.LBB3_6
# %bb.3:                                # %.lr.ph35
                                        #   in Loop: Header=BB3_2 Depth=1
	leaq	(%rcx,%rcx), %r8
	cmpq	%rdx, %r8
	ja	.LBB3_6
# %bb.4:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB3_2 Depth=1
	movq	%rax, %r8
.LBB3_5:                                # %.lr.ph
                                        #   Parent Loop BB3_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movb	$78, (%rdi,%r8)
	addq	%rcx, %r8
	cmpq	%rdx, %r8
	jbe	.LBB3_5
.LBB3_6:                                # %.loopexit
                                        #   in Loop: Header=BB3_2 Depth=1
	incq	%rcx
	movq	%rcx, %r8
	imulq	%rcx, %r8
	addq	$2, %rax
	cmpq	%rdx, %r8
	jbe	.LBB3_2
.LBB3_7:                                # %.preheader
	xorl	%eax, %eax
	cmpq	$2, %rdx
	jb	.LBB3_12
# %bb.8:                                # %.lr.ph39.preheader
	movl	$1, %ecx
	subq	%rdx, %rcx
	xorl	%eax, %eax
	movl	$2, %edx
.LBB3_9:                                # %.lr.ph39
                                        # =>This Inner Loop Header: Depth=1
	cmpb	$80, (%rdi,%rdx)
	jne	.LBB3_11
# %bb.10:                               #   in Loop: Header=BB3_9 Depth=1
	cltq
	movl	%edx, (%rsi,%rax,4)
	incl	%eax
.LBB3_11:                               #   in Loop: Header=BB3_9 Depth=1
	leaq	(%rcx,%rdx), %r8
	incq	%r8
	incq	%rdx
	cmpq	$2, %r8
	jne	.LBB3_9
.LBB3_12:                               # %._crit_edge
                                        # kill: def $eax killed $eax killed $rax
	retq
.Lfunc_end3:
	.size	_Z20generate_seed_primesPcPiy, .Lfunc_end3-_Z20generate_seed_primesPcPiy
	.cfi_endproc
                                        # -- End function
	.globl	_Z16copy_seed_primesPyPii       # -- Begin function _Z16copy_seed_primesPyPii
	.type	_Z16copy_seed_primesPyPii,@function
_Z16copy_seed_primesPyPii:              # @_Z16copy_seed_primesPyPii
	.cfi_startproc
# %bb.0:
	testl	%edx, %edx
	jle	.LBB4_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%edx, %eax
	xorl	%ecx, %ecx
.LBB4_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movslq	(%rsi,%rcx,4), %rdx
	movq	%rdx, (%rdi,%rcx,8)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB4_2
.LBB4_3:                                # %._crit_edge
	retq
.Lfunc_end4:
	.size	_Z16copy_seed_primesPyPii, .Lfunc_end4-_Z16copy_seed_primesPyPii
	.cfi_endproc
                                        # -- End function
	.globl	_Z22initializing_inputlistPyyy  # -- Begin function _Z22initializing_inputlistPyyy
	.type	_Z22initializing_inputlistPyyy,@function
_Z22initializing_inputlistPyyy:         # @_Z22initializing_inputlistPyyy
	.cfi_startproc
# %bb.0:
	testq	%rdx, %rdx
	je	.LBB5_3
# %bb.1:                                # %.lr.ph.preheader
	xorl	%eax, %eax
.LBB5_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	leaq	(%rsi,%rax), %rcx
	movq	%rcx, (%rdi,%rax,8)
	incq	%rax
	cmpq	%rax, %rdx
	jne	.LBB5_2
.LBB5_3:                                # %._crit_edge
	retq
.Lfunc_end5:
	.size	_Z22initializing_inputlistPyyy, .Lfunc_end5-_Z22initializing_inputlistPyyy
	.cfi_endproc
                                        # -- End function
	.globl	_Z15counting_primesPyyy         # -- Begin function _Z15counting_primesPyyy
	.type	_Z15counting_primesPyyy,@function
_Z15counting_primesPyyy:                # @_Z15counting_primesPyyy
	.cfi_startproc
# %bb.0:
	xorl	%eax, %eax
	testq	%rsi, %rsi
	je	.LBB6_4
# %bb.1:                                # %.lr.ph.preheader
	xorl	%ecx, %ecx
.LBB6_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	cmpq	$1, (%rdi,%rcx,8)
	sbbl	$-1, %eax
	incq	%rcx
	cmpq	%rcx, %rsi
	jne	.LBB6_2
# %bb.3:                                # %._crit_edge.loopexit
	movl	%eax, %eax
.LBB6_4:                                # %._crit_edge
	retq
.Lfunc_end6:
	.size	_Z15counting_primesPyyy, .Lfunc_end6-_Z15counting_primesPyyy
	.cfi_endproc
                                        # -- End function
	.globl	_Z15appending_primePyS_yyy      # -- Begin function _Z15appending_primePyS_yyy
	.type	_Z15appending_primePyS_yyy,@function
_Z15appending_primePyS_yyy:             # @_Z15appending_primePyS_yyy
	.cfi_startproc
# %bb.0:
	testq	%rdx, %rdx
	je	.LBB7_5
# %bb.1:                                # %.lr.ph.preheader
	xorl	%eax, %eax
.LBB7_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	(%rdi,%rax,8), %r8
	testq	%r8, %r8
	je	.LBB7_4
# %bb.3:                                #   in Loop: Header=BB7_2 Depth=1
	movq	%r8, (%rsi,%rcx,8)
	incq	%rcx
.LBB7_4:                                #   in Loop: Header=BB7_2 Depth=1
	incq	%rax
	cmpq	%rax, %rdx
	jne	.LBB7_2
.LBB7_5:                                # %._crit_edge
	retq
.Lfunc_end7:
	.size	_Z15appending_primePyS_yyy, .Lfunc_end7-_Z15appending_primePyS_yyy
	.cfi_endproc
                                        # -- End function
	.globl	_Z15print_primelistPyy          # -- Begin function _Z15print_primelistPyy
	.type	_Z15print_primelistPyy,@function
_Z15print_primelistPyy:                 # @_Z15print_primelistPyy
	.cfi_startproc
# %bb.0:
	testq	%rsi, %rsi
	je	.LBB8_4
# %bb.1:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	xorl	%r15d, %r15d
.LBB8_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	(%r14,%r15,8), %rsi
	movl	$.L.str.13, %edi
	xorl	%eax, %eax
	callq	printf
	incq	%r15
	cmpq	%r15, %rbx
	jne	.LBB8_2
# %bb.3:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB8_4:                                # %._crit_edge
	retq
.Lfunc_end8:
	.size	_Z15print_primelistPyy, .Lfunc_end8-_Z15print_primelistPyy
	.cfi_endproc
                                        # -- End function
	.globl	_Z15print_inputlistPyy          # -- Begin function _Z15print_inputlistPyy
	.type	_Z15print_inputlistPyy,@function
_Z15print_inputlistPyy:                 # @_Z15print_inputlistPyy
	.cfi_startproc
# %bb.0:
	testq	%rsi, %rsi
	je	.LBB9_4
# %bb.1:                                # %.lr.ph.preheader
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	xorl	%r15d, %r15d
.LBB9_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	(%r14,%r15,8), %rdx
	movl	$.L.str.12, %edi
	movq	%r15, %rsi
	xorl	%eax, %eax
	callq	printf
	incq	%r15
	cmpq	%r15, %rbx
	jne	.LBB9_2
# %bb.3:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	.cfi_restore %rbx
	.cfi_restore %r14
	.cfi_restore %r15
.LBB9_4:                                # %._crit_edge
	retq
.Lfunc_end9:
	.size	_Z15print_inputlistPyy, .Lfunc_end9-_Z15print_inputlistPyy
	.cfi_endproc
                                        # -- End function
	.globl	_Z14calculatePrimePyS_yy        # -- Begin function _Z14calculatePrimePyS_yy
	.type	_Z14calculatePrimePyS_yy,@function
_Z14calculatePrimePyS_yy:               # @_Z14calculatePrimePyS_yy
	.cfi_startproc
# %bb.0:
	testq	%rdx, %rdx
	je	.LBB10_8
# %bb.1:                                # %.preheader.lr.ph
	movq	%rdx, %r8
	xorl	%r10d, %r10d
.LBB10_2:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB10_4 Depth 2
	testq	%rcx, %rcx
	je	.LBB10_7
# %bb.3:                                # %.lr.ph
                                        #   in Loop: Header=BB10_2 Depth=1
	movq	(%rdi,%r10,8), %r9
	xorl	%r11d, %r11d
.LBB10_4:                               #   Parent Loop BB10_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movq	%r9, %rax
	xorl	%edx, %edx
	divq	(%rsi,%r11,8)
	testq	%rdx, %rdx
	jne	.LBB10_6
# %bb.5:                                #   in Loop: Header=BB10_4 Depth=2
	movq	$0, (%rdi,%r10,8)
	xorl	%r9d, %r9d
.LBB10_6:                               #   in Loop: Header=BB10_4 Depth=2
	incq	%r11
	cmpq	%r11, %rcx
	jne	.LBB10_4
.LBB10_7:                               # %._crit_edge
                                        #   in Loop: Header=BB10_2 Depth=1
	incq	%r10
	cmpq	%r8, %r10
	jne	.LBB10_2
.LBB10_8:                               # %._crit_edge14
	retq
.Lfunc_end10:
	.size	_Z14calculatePrimePyS_yy, .Lfunc_end10-_Z14calculatePrimePyS_yy
	.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	.LBB11_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB11_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z15prime_generatorPyS_S_S_, %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_end11:
	.size	__hip_module_ctor, .Lfunc_end11-__hip_module_ctor
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_dtor
	.type	__hip_module_dtor,@function
__hip_module_dtor:                      # @__hip_module_dtor
	.cfi_startproc
# %bb.0:
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	je	.LBB12_2
# %bb.1:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	__hipUnregisterFatBinary
	movq	$0, __hip_gpubin_handle(%rip)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
.LBB12_2:
	retq
.Lfunc_end12:
	.size	__hip_module_dtor, .Lfunc_end12-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z15prime_generatorPyS_S_S_,@object # @_Z15prime_generatorPyS_S_S_
	.section	.rodata,"a",@progbits
	.globl	_Z15prime_generatorPyS_S_S_
	.p2align	3, 0x0
_Z15prime_generatorPyS_S_S_:
	.quad	_Z30__device_stub__prime_generatorPyS_S_S_
	.size	_Z15prime_generatorPyS_S_S_, 8

	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"CALCULATING PRIMES FROM 0 - %llu\n"
	.size	.L.str, 34

	.type	.L.str.10,@object               # @.str.10
.L.str.10:
	.asciz	"THE NUMBER OF PRIMES ARE: %llu\n"
	.size	.L.str.10, 32

	.type	.L.str.12,@object               # @.str.12
.L.str.12:
	.asciz	"%llu\t--->\t%llu\n"
	.size	.L.str.12, 16

	.type	.L.str.13,@object               # @.str.13
.L.str.13:
	.asciz	"%llu\n"
	.size	.L.str.13, 6

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z15prime_generatorPyS_S_S_"
	.size	.L__unnamed_1, 28

	.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	"Error:  1"
	.size	.Lstr, 10

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"copy Error:  1"
	.size	.Lstr.1, 15

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Error:  2"
	.size	.Lstr.2, 10

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"copy Error:  2"
	.size	.Lstr.3, 15

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"Error:  3"
	.size	.Lstr.4, 10

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"copy Error:  3"
	.size	.Lstr.5, 15

	.type	.Lstr.6,@object                 # @str.6
.Lstr.6:
	.asciz	"Error:  4"
	.size	.Lstr.6, 10

	.type	.Lstr.7,@object                 # @str.7
.Lstr.7:
	.asciz	"copy Error:  4"
	.size	.Lstr.7, 15

	.type	.Lstr.8,@object                 # @str.8
.Lstr.8:
	.asciz	"******************************************\n"
	.size	.Lstr.8, 44

	.type	.Lstr.9,@object                 # @str.9
.Lstr.9:
	.asciz	"copy Host Error:  1"
	.size	.Lstr.9, 20

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

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z15prime_generatorPyS_S_S_ ; -- Begin function _Z15prime_generatorPyS_S_S_
	.globl	_Z15prime_generatorPyS_S_S_
	.p2align	8
	.type	_Z15prime_generatorPyS_S_S_,@function
_Z15prime_generatorPyS_S_S_:            ; @_Z15prime_generatorPyS_S_S_
; %bb.0:
	s_load_b64 s[2:3], s[0:1], 0x10
	s_mov_b64 s[8:9], 0
	s_waitcnt lgkmcnt(0)
	s_load_b64 s[10:11], s[2:3], 0x0
	s_waitcnt lgkmcnt(0)
	s_cmp_eq_u64 s[10:11], 0
	s_cbranch_scc1 .LBB0_5
; %bb.1:                                ; %.lr.ph
	s_clause 0x1
	s_load_b32 s12, s[0:1], 0x2c
	s_load_b128 s[4:7], s[0:1], 0x0
	s_mov_b32 s1, 0
	s_waitcnt lgkmcnt(0)
	s_and_b32 s0, s12, 0xffff
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mad_u64_u32 v[1:2], null, s15, s0, v[0:1]
	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], 3, v[1:2]
	v_add_co_u32 v0, vcc_lo, s6, v0
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v1, vcc_lo
	global_load_b32 v9, v[0:1], off
	s_waitcnt vmcnt(0)
	v_ashrrev_i32_e32 v10, 31, v9
	v_cvt_f32_u32_e32 v0, v9
	v_sub_co_u32 v11, vcc_lo, 0, v9
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cvt_f32_u32_e32 v1, v10
	v_sub_co_ci_u32_e32 v12, vcc_lo, 0, v10, vcc_lo
	v_fmamk_f32 v0, v1, 0x4f800000, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(VALU_DEP_1)
	v_rcp_f32_e32 v0, v0
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v0, 0x5f7ffffc, v0
	v_mul_f32_e32 v1, 0x2f800000, v0
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_trunc_f32_e32 v1, v1
	v_fmamk_f32 v0, v1, 0xcf800000, v0
	v_cvt_u32_f32_e32 v13, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_cvt_u32_f32_e32 v14, v0
	v_mul_lo_u32 v0, v11, v13
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_mul_lo_u32 v1, v12, v14
	v_mad_u64_u32 v[6:7], null, v11, v14, 0
	v_add3_u32 v4, v7, v0, v1
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_mul_hi_u32 v15, v14, v6
	v_dual_mov_b32 v7, s10 :: v_dual_mov_b32 v8, s11
	v_mad_u64_u32 v[0:1], null, v14, v4, 0
	v_mad_u64_u32 v[2:3], null, v13, v4, 0
	v_mad_u64_u32 v[4:5], null, v13, v6, 0
	v_mov_b32_e32 v6, 0
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	global_load_b64 v[16:17], v6, s[4:5]
	v_add_co_u32 v18, vcc_lo, v15, v0
	v_add_co_ci_u32_e32 v19, vcc_lo, 0, v1, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v18, vcc_lo, v18, v4
	v_add_co_ci_u32_e32 v18, vcc_lo, v19, v5, vcc_lo
	v_add_co_ci_u32_e32 v19, vcc_lo, 0, v3, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v18, vcc_lo, v18, v2
	v_add_co_ci_u32_e32 v19, vcc_lo, 0, v19, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v25, vcc_lo, v14, v18
	v_add_co_ci_u32_e32 v26, vcc_lo, v13, v19, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_mul_lo_u32 v20, v12, v25
	v_mad_u64_u32 v[18:19], null, v11, v25, 0
	v_mul_lo_u32 v21, v11, v26
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_mul_hi_u32 v28, v25, v18
	v_add3_u32 v27, v19, v21, v20
	v_mad_u64_u32 v[21:22], null, v26, v18, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_mad_u64_u32 v[19:20], null, v25, v27, 0
	v_mad_u64_u32 v[23:24], null, v26, v27, 0
	v_add_co_u32 v18, vcc_lo, v28, v19
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_ci_u32_e32 v19, vcc_lo, 0, v20, vcc_lo
	v_add_co_u32 v18, vcc_lo, v18, v21
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_add_co_ci_u32_e32 v18, vcc_lo, v19, v22, vcc_lo
	v_add_co_ci_u32_e32 v19, vcc_lo, 0, v24, vcc_lo
	v_add_co_u32 v18, vcc_lo, v18, v23
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_ci_u32_e32 v19, vcc_lo, 0, v19, vcc_lo
	v_add_co_u32 v22, vcc_lo, v25, v18
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_add_co_ci_u32_e32 v24, vcc_lo, v26, v19, vcc_lo
	s_waitcnt vmcnt(0)
	v_mad_u64_u32 v[18:19], null, v16, v24, 0
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_mul_hi_u32 v25, v16, v22
	v_mad_u64_u32 v[20:21], null, v17, v22, 0
	v_mad_u64_u32 v[22:23], null, v17, v24, 0
	v_add_co_u32 v18, vcc_lo, v25, v18
	v_add_co_ci_u32_e32 v19, vcc_lo, 0, v19, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v18, vcc_lo, v18, v20
	v_add_co_ci_u32_e32 v18, vcc_lo, v19, v21, vcc_lo
	v_add_co_ci_u32_e32 v19, vcc_lo, 0, v23, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_add_co_u32 v20, vcc_lo, v18, v22
	v_add_co_ci_u32_e32 v21, vcc_lo, 0, v19, vcc_lo
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_mul_lo_u32 v22, v10, v20
	v_mad_u64_u32 v[18:19], null, v9, v20, 0
	v_mul_lo_u32 v20, v9, v21
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_sub_co_u32 v16, vcc_lo, v16, v18
	v_add3_u32 v19, v19, v20, v22
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_sub_nc_u32_e32 v20, v17, v19
	v_sub_co_ci_u32_e64 v18, s0, v20, v10, vcc_lo
	v_sub_co_ci_u32_e32 v17, vcc_lo, v17, v19, vcc_lo
	v_sub_co_u32 v19, vcc_lo, v16, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_3)
	v_subrev_co_ci_u32_e64 v20, s0, 0, v18, vcc_lo
	v_cmp_ge_u32_e64 s0, v16, v9
	v_sub_co_ci_u32_e32 v18, vcc_lo, v18, v10, vcc_lo
	v_cmp_ge_u32_e32 vcc_lo, v17, v10
	v_cndmask_b32_e64 v21, 0, -1, s0
	v_cmp_ge_u32_e64 s0, v19, v9
	v_cndmask_b32_e64 v24, 0, -1, vcc_lo
	v_cmp_eq_u32_e32 vcc_lo, v20, v10
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_cndmask_b32_e64 v22, 0, -1, s0
	v_cmp_ge_u32_e64 s0, v20, v10
	v_cndmask_b32_e64 v23, 0, -1, s0
	v_cmp_eq_u32_e64 s0, v17, v10
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_2) | instid1(VALU_DEP_3)
	v_cndmask_b32_e32 v22, v23, v22, vcc_lo
	v_sub_co_u32 v23, vcc_lo, v19, v9
	v_subrev_co_ci_u32_e32 v18, vcc_lo, 0, v18, vcc_lo
	v_cmp_ne_u32_e32 vcc_lo, 0, v22
	v_cndmask_b32_e64 v21, v24, v21, s0
	s_mov_b32 s0, exec_lo
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_dual_cndmask_b32 v18, v20, v18 :: v_dual_cndmask_b32 v19, v19, v23
	v_cmp_ne_u32_e32 vcc_lo, 0, v21
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_dual_cndmask_b32 v17, v17, v18 :: v_dual_cndmask_b32 v16, v16, v19
	v_cmpx_eq_u64_e32 0, v[16:17]
	s_cbranch_execz .LBB0_4
; %bb.3:                                ;   in Loop: Header=BB0_2 Depth=1
	v_mov_b32_e32 v7, v6
	global_store_b64 v6, v[6:7], s[4:5]
	global_load_b64 v[7:8], v6, s[2:3]
.LBB0_4:                                ;   in Loop: Header=BB0_2 Depth=1
	s_or_b32 exec_lo, exec_lo, s0
	s_add_u32 s8, s8, 1
	s_addc_u32 s9, s9, 0
	s_add_u32 s4, s4, 8
	s_waitcnt vmcnt(0)
	v_cmp_ge_u64_e32 vcc_lo, s[8:9], v[7:8]
	s_addc_u32 s5, s5, 0
	s_or_b32 s1, vcc_lo, s1
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s1
	s_cbranch_execnz .LBB0_2
.LBB0_5:                                ; %._crit_edge
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z15prime_generatorPyS_S_S_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 288
		.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 29
		.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	_Z15prime_generatorPyS_S_S_, .Lfunc_end0-_Z15prime_generatorPyS_S_S_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 924
; NumSgprs: 18
; NumVgprs: 29
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 3
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 29
; 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
      - .address_space:  global
        .offset:         16
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         24
        .size:           8
        .value_kind:     global_buffer
      - .offset:         32
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         36
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         44
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         46
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         48
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         50
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         52
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         54
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         72
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         96
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 288
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z15prime_generatorPyS_S_S_
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z15prime_generatorPyS_S_S_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     29
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
