#include <stdio.h>

#define DIM 1000


struct cppComplex {
	float r; 
	float i;
	cppComplex( float a, float b ) : r(a), i(b) {}
	float magnitude2( void ) {
		return r * r + i * i;
	}
	cppComplex operator*(const cppComplex& a) {
		return cppComplex(r*a.r - i*a.i, i*a.r + r*a.i);
	}
	cppComplex operator+(const cppComplex& a) {
		return cppComplex(r+a.r, i+a.i);
	}
};

int julia_cpu( int x, int y ) {
	const float scale = 1.5;
	float jx = scale * (float)(DIM/2 - x)/(DIM/2);
	float jy = scale * (float)(DIM/2 - y)/(DIM/2);
	
	cppComplex c(-0.8, 0.156);
	cppComplex a(jx, jy);

	int i = 0;
	for(i=0; i<200; i++){
		a = a * a + c;
		if (a.magnitude2() > 1000)
			return 0;
	}

	return 1;
}

void julia_set_cpu() {

	unsigned char *pixels = new unsigned char[DIM * DIM]; 

	for (int x = 0; x < DIM; ++x) {
		for (int y = 0; y < DIM; ++y) {
			pixels[x + y * DIM] = 255 * julia_cpu(x, y);
		}
	}

	FILE *f = fopen("julia_cpu.ppm", "wb");

    fprintf(f, "P6\n%i %i 255\n", DIM, DIM);
    
    for (int y = 0; y < DIM; y++) {
        for (int x = 0; x < DIM; x++) {
            fputc(pixels[(y * DIM + x)], f);
            fputc(0, f);
            fputc(0, f);
      }
    }
    fclose(f);

    delete [] pixels;
}

///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
/*Begin the GPU part*/
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////



__global__ void kernel( unsigned char *ptr ) {
	/*
		wirte your kernel code here
	*/
}

void julia_set_gpu() {

	unsigned char *pixels = new unsigned char[DIM * DIM]; 

	/*
		wirte the host code here
	*/
	
	//kernel<<<1,1>>>(dev_bitmap);

	/*
		write the code to copy the data back
	*/

	FILE *f = fopen("julia_gpu.ppm", "wb");
    fprintf(f, "P6\n%i %i 255\n", DIM, DIM);
    for (int y = 0; y < DIM; y++) {
        for (int x = 0; x < DIM; x++) {
            fputc(pixels[(y * DIM + x)], f);   // 0 .. 255
            fputc(0, f);
            fputc(0, f);
      }
    }


    fclose(f);

	delete [] pixels; 

}



int main( void ) {
	
	julia_set_cpu();
	julia_set_gpu();

}

	.file	"tmpxft_00234efa_00000000-6_julia.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	_Z9julia_cpuii
	.type	_Z9julia_cpuii, @function
_Z9julia_cpuii:
.LFB2033:
	.cfi_startproc
	endbr64
	movl	$500, %eax
	movss	.LC0(%rip), %xmm3
	movss	.LC1(%rip), %xmm2
	movl	%eax, %edx
	subl	%esi, %eax
	movss	.LC3(%rip), %xmm4
	subl	%edi, %edx
	cvtsi2ssl	%eax, %xmm0
	movl	$200, %eax
	cvtsi2ssl	%edx, %xmm1
	mulss	%xmm3, %xmm0
	mulss	%xmm3, %xmm1
	movss	.LC2(%rip), %xmm3
	divss	%xmm2, %xmm0
	divss	%xmm2, %xmm1
.L4:
	movaps	%xmm1, %xmm2
	movaps	%xmm0, %xmm5
	mulss	%xmm0, %xmm5
	mulss	%xmm1, %xmm2
	mulss	%xmm1, %xmm0
	subss	%xmm5, %xmm2
	addss	%xmm0, %xmm0
	movaps	%xmm2, %xmm1
	addss	%xmm3, %xmm0
	subss	%xmm4, %xmm1
	movaps	%xmm0, %xmm5
	movaps	%xmm1, %xmm2
	mulss	%xmm1, %xmm2
	mulss	%xmm0, %xmm5
	addss	%xmm5, %xmm2
	comiss	.LC4(%rip), %xmm2
	ja	.L5
	decl	%eax
	jne	.L4
	movl	$1, %eax
	ret
.L5:
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE2033:
	.size	_Z9julia_cpuii, .-_Z9julia_cpuii
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC5:
	.string	"wb"
.LC6:
	.string	"julia_cpu.ppm"
.LC7:
	.string	"P6\n%i %i 255\n"
	.text
	.globl	_Z13julia_set_cpuv
	.type	_Z13julia_set_cpuv, @function
_Z13julia_set_cpuv:
.LFB2034:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$1000000, %edi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	call	_Znam@PLT
	xorl	%ecx, %ecx
	movq	%rax, %rbp
.L9:
	movl	%ecx, %edi
	movq	%rbp, %r13
	leaq	(%rcx,%rbp), %r8
	xorl	%esi, %esi
.L10:
	call	_Z9julia_cpuii
	incl	%esi
	addq	$1000, %r8
	negl	%eax
	movb	%al, -1000(%r8)
	cmpl	$1000, %esi
	jne	.L10
	incq	%rcx
	cmpq	$1000, %rcx
	jne	.L9
	leaq	.LC5(%rip), %rsi
	leaq	.LC6(%rip), %rdi
	call	fopen@PLT
	movl	$1000, %r8d
	movl	$1000, %ecx
	leaq	.LC7(%rip), %rdx
	movq	%rax, %rdi
	movq	%rax, %rbx
	xorl	%eax, %eax
	movl	$2, %esi
	call	__fprintf_chk@PLT
	leaq	1000000(%rbp), %r14
.L12:
	xorl	%r12d, %r12d
.L13:
	movzbl	0(%r13,%r12), %edi
	movq	%rbx, %rsi
	incq	%r12
	call	fputc@PLT
	movq	%rbx, %rsi
	xorl	%edi, %edi
	call	fputc@PLT
	movq	%rbx, %rsi
	xorl	%edi, %edi
	call	fputc@PLT
	cmpq	$1000, %r12
	jne	.L13
	addq	$1000, %r13
	cmpq	%r13, %r14
	jne	.L12
	movq	%rbx, %rdi
	call	fclose@PLT
	popq	%rbx
	.cfi_def_cfa_offset 40
	movq	%rbp, %rdi
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	_ZdaPv@PLT
	.cfi_endproc
.LFE2034:
	.size	_Z13julia_set_cpuv, .-_Z13julia_set_cpuv
	.section	.rodata.str1.1
.LC8:
	.string	"julia_gpu.ppm"
	.text
	.globl	_Z13julia_set_gpuv
	.type	_Z13julia_set_gpuv, @function
_Z13julia_set_gpuv:
.LFB2035:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$1000000, %edi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	call	_Znam@PLT
	leaq	.LC5(%rip), %rsi
	leaq	.LC8(%rip), %rdi
	movq	%rax, %rbp
	call	fopen@PLT
	movl	$1000, %r8d
	movl	$1000, %ecx
	movq	%rbp, %r13
	movq	%rax, %rdi
	movq	%rax, %rbx
	xorl	%eax, %eax
	movl	$2, %esi
	leaq	.LC7(%rip), %rdx
	leaq	1000000(%rbp), %r14
	call	__fprintf_chk@PLT
.L19:
	xorl	%r12d, %r12d
.L20:
	movzbl	0(%r13,%r12), %edi
	movq	%rbx, %rsi
	incq	%r12
	call	fputc@PLT
	movq	%rbx, %rsi
	xorl	%edi, %edi
	call	fputc@PLT
	movq	%rbx, %rsi
	xorl	%edi, %edi
	call	fputc@PLT
	cmpq	$1000, %r12
	jne	.L20
	addq	$1000, %r13
	cmpq	%r14, %r13
	jne	.L19
	movq	%rbx, %rdi
	call	fclose@PLT
	popq	%rbx
	.cfi_def_cfa_offset 40
	movq	%rbp, %rdi
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	_ZdaPv@PLT
	.cfi_endproc
.LFE2035:
	.size	_Z13julia_set_gpuv, .-_Z13julia_set_gpuv
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2036:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_Z13julia_set_cpuv
	call	_Z13julia_set_gpuv
	xorl	%eax, %eax
	popq	%rdx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2036:
	.size	main, .-main
	.text
	.globl	_Z25__device_stub__Z6kernelPhPh
	.type	_Z25__device_stub__Z6kernelPhPh, @function
_Z25__device_stub__Z6kernelPhPh:
.LFB2061:
	.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	.L26
	pushq	24(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z6kernelPh(%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
.L26:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L28
	call	__stack_chk_fail@PLT
.L28:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2061:
	.size	_Z25__device_stub__Z6kernelPhPh, .-_Z25__device_stub__Z6kernelPhPh
	.globl	_Z6kernelPh
	.type	_Z6kernelPh, @function
_Z6kernelPh:
.LFB2062:
	.cfi_startproc
	endbr64
	jmp	_Z25__device_stub__Z6kernelPhPh
	.cfi_endproc
.LFE2062:
	.size	_Z6kernelPh, .-_Z6kernelPh
	.section	.rodata.str1.1
.LC9:
	.string	"_Z6kernelPh"
	.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	.LC9(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z6kernelPh(%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.cst4,"aM",@progbits,4
	.align 4
.LC0:
	.long	1069547520
	.align 4
.LC1:
	.long	1140457472
	.align 4
.LC2:
	.long	1042267767
	.align 4
.LC3:
	.long	1061997773
	.align 4
.LC4:
	.long	1148846080
	.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>

#define DIM 1000


struct cppComplex {
	float r; 
	float i;
	cppComplex( float a, float b ) : r(a), i(b) {}
	float magnitude2( void ) {
		return r * r + i * i;
	}
	cppComplex operator*(const cppComplex& a) {
		return cppComplex(r*a.r - i*a.i, i*a.r + r*a.i);
	}
	cppComplex operator+(const cppComplex& a) {
		return cppComplex(r+a.r, i+a.i);
	}
};

int julia_cpu( int x, int y ) {
	const float scale = 1.5;
	float jx = scale * (float)(DIM/2 - x)/(DIM/2);
	float jy = scale * (float)(DIM/2 - y)/(DIM/2);
	
	cppComplex c(-0.8, 0.156);
	cppComplex a(jx, jy);

	int i = 0;
	for(i=0; i<200; i++){
		a = a * a + c;
		if (a.magnitude2() > 1000)
			return 0;
	}

	return 1;
}

void julia_set_cpu() {

	unsigned char *pixels = new unsigned char[DIM * DIM]; 

	for (int x = 0; x < DIM; ++x) {
		for (int y = 0; y < DIM; ++y) {
			pixels[x + y * DIM] = 255 * julia_cpu(x, y);
		}
	}

	FILE *f = fopen("julia_cpu.ppm", "wb");

    fprintf(f, "P6\n%i %i 255\n", DIM, DIM);
    
    for (int y = 0; y < DIM; y++) {
        for (int x = 0; x < DIM; x++) {
            fputc(pixels[(y * DIM + x)], f);
            fputc(0, f);
            fputc(0, f);
      }
    }
    fclose(f);

    delete [] pixels;
}

///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
/*Begin the GPU part*/
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////



__global__ void kernel( unsigned char *ptr ) {
	/*
		wirte your kernel code here
	*/
}

void julia_set_gpu() {

	unsigned char *pixels = new unsigned char[DIM * DIM]; 

	/*
		wirte the host code here
	*/
	
	//kernel<<<1,1>>>(dev_bitmap);

	/*
		write the code to copy the data back
	*/

	FILE *f = fopen("julia_gpu.ppm", "wb");
    fprintf(f, "P6\n%i %i 255\n", DIM, DIM);
    for (int y = 0; y < DIM; y++) {
        for (int x = 0; x < DIM; x++) {
            fputc(pixels[(y * DIM + x)], f);   // 0 .. 255
            fputc(0, f);
            fputc(0, f);
      }
    }


    fclose(f);

	delete [] pixels; 

}



int main( void ) {
	
	julia_set_cpu();
	julia_set_gpu();

}

	.text
	.file	"julia.hip"
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z9julia_cpuii
.LCPI0_0:
	.long	0x3fc00000                      # float 1.5
.LCPI0_1:
	.long	0x43fa0000                      # float 500
.LCPI0_2:
	.long	0xbf4ccccd                      # float -0.800000011
.LCPI0_3:
	.long	0x3e1fbe77                      # float 0.156000003
.LCPI0_4:
	.long	0x447a0000                      # float 1000
	.text
	.globl	_Z9julia_cpuii
	.type	_Z9julia_cpuii,@function
_Z9julia_cpuii:                         # @_Z9julia_cpuii
	.cfi_startproc
# %bb.0:
	movl	$500, %eax                      # imm = 0x1F4
	movl	$500, %ecx                      # imm = 0x1F4
	subl	%edi, %ecx
	cvtsi2ss	%ecx, %xmm0
	movss	.LCPI0_0(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	mulss	%xmm1, %xmm0
	movss	.LCPI0_1(%rip), %xmm2           # xmm2 = mem[0],zero,zero,zero
	divss	%xmm2, %xmm0
	subl	%esi, %eax
	cvtsi2ss	%eax, %xmm3
	mulss	%xmm1, %xmm3
	divss	%xmm2, %xmm3
	unpcklps	%xmm3, %xmm0                    # xmm0 = xmm0[0],xmm3[0],xmm0[1],xmm3[1]
	movl	$200, %eax
	movss	.LCPI0_2(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	movss	.LCPI0_3(%rip), %xmm2           # xmm2 = mem[0],zero,zero,zero
	movss	.LCPI0_4(%rip), %xmm3           # xmm3 = mem[0],zero,zero,zero
	movaps	%xmm0, %xmm4
.LBB0_1:                                # =>This Inner Loop Header: Depth=1
	mulss	%xmm4, %xmm4
	movaps	%xmm0, %xmm5
	shufps	$85, %xmm0, %xmm5               # xmm5 = xmm5[1,1],xmm0[1,1]
	mulss	%xmm5, %xmm0
	mulss	%xmm5, %xmm5
	subss	%xmm5, %xmm4
	addss	%xmm0, %xmm0
	addss	%xmm1, %xmm4
	addss	%xmm2, %xmm0
	movaps	%xmm4, %xmm5
	mulss	%xmm4, %xmm5
	movaps	%xmm0, %xmm6
	mulss	%xmm0, %xmm6
	addss	%xmm5, %xmm6
	ucomiss	%xmm3, %xmm6
	ja	.LBB0_2
# %bb.3:                                #   in Loop: Header=BB0_1 Depth=1
	unpcklps	%xmm0, %xmm4                    # xmm4 = xmm4[0],xmm0[0],xmm4[1],xmm0[1]
	movaps	%xmm4, %xmm0
	decl	%eax
	jne	.LBB0_1
# %bb.4:
	movl	$1, %eax
	retq
.LBB0_2:
	xorl	%eax, %eax
	retq
.Lfunc_end0:
	.size	_Z9julia_cpuii, .Lfunc_end0-_Z9julia_cpuii
	.cfi_endproc
                                        # -- End function
	.globl	_Z13julia_set_cpuv              # -- Begin function _Z13julia_set_cpuv
	.type	_Z13julia_set_cpuv,@function
_Z13julia_set_cpuv:                     # @_Z13julia_set_cpuv
	.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
	pushq	%rax
	.cfi_def_cfa_offset 64
	.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	$1000000, %edi                  # imm = 0xF4240
	callq	_Znam
	movq	%rax, %rbx
	xorl	%r14d, %r14d
	movl	$1000, %r12d                    # imm = 0x3E8
	movq	%rax, %r13
.LBB1_1:                                # %.preheader24
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_2 Depth 2
	movq	%r13, %rbp
	xorl	%r15d, %r15d
.LBB1_2:                                #   Parent Loop BB1_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%r14d, %edi
	movl	%r15d, %esi
	callq	_Z9julia_cpuii
	negb	%al
	movb	%al, (%rbp)
	incq	%r15
	addq	%r12, %rbp
	cmpq	%r12, %r15
	jne	.LBB1_2
# %bb.3:                                #   in Loop: Header=BB1_1 Depth=1
	incq	%r14
	incq	%r13
	cmpq	$1000, %r14                     # imm = 0x3E8
	jne	.LBB1_1
# %bb.4:
	movl	$.L.str, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, %r14
	xorl	%r15d, %r15d
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	movl	$1000, %edx                     # imm = 0x3E8
	movl	$1000, %ecx                     # imm = 0x3E8
	xorl	%eax, %eax
	callq	fprintf
	movl	$1000, %r12d                    # imm = 0x3E8
	movq	%rbx, %r13
.LBB1_5:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_6 Depth 2
	movq	$-1000, %rbp                    # imm = 0xFC18
.LBB1_6:                                #   Parent Loop BB1_5 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movzbl	1000(%r13,%rbp), %edi
	movq	%r14, %rsi
	callq	fputc
	xorl	%edi, %edi
	movq	%r14, %rsi
	callq	fputc
	xorl	%edi, %edi
	movq	%r14, %rsi
	callq	fputc
	incq	%rbp
	jne	.LBB1_6
# %bb.7:                                #   in Loop: Header=BB1_5 Depth=1
	incq	%r15
	addq	%r12, %r13
	cmpq	%r12, %r15
	jne	.LBB1_5
# %bb.8:
	movq	%r14, %rdi
	callq	fclose
	movq	%rbx, %rdi
	addq	$8, %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
	jmp	_ZdaPv                          # TAILCALL
.Lfunc_end1:
	.size	_Z13julia_set_cpuv, .Lfunc_end1-_Z13julia_set_cpuv
	.cfi_endproc
                                        # -- End function
	.globl	_Z21__device_stub__kernelPh     # -- Begin function _Z21__device_stub__kernelPh
	.type	_Z21__device_stub__kernelPh,@function
_Z21__device_stub__kernelPh:            # @_Z21__device_stub__kernelPh
	.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	$_Z6kernelPh, %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_end2:
	.size	_Z21__device_stub__kernelPh, .Lfunc_end2-_Z21__device_stub__kernelPh
	.cfi_endproc
                                        # -- End function
	.globl	_Z13julia_set_gpuv              # -- Begin function _Z13julia_set_gpuv
	.type	_Z13julia_set_gpuv,@function
_Z13julia_set_gpuv:                     # @_Z13julia_set_gpuv
	.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
	pushq	%rax
	.cfi_def_cfa_offset 64
	.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	$1000000, %edi                  # imm = 0xF4240
	callq	_Znam
	movq	%rax, %rbx
	movl	$.L.str.3, %edi
	movl	$.L.str.1, %esi
	callq	fopen
	movq	%rax, %r14
	xorl	%r15d, %r15d
	movl	$.L.str.2, %esi
	movq	%rax, %rdi
	movl	$1000, %edx                     # imm = 0x3E8
	movl	$1000, %ecx                     # imm = 0x3E8
	xorl	%eax, %eax
	callq	fprintf
	movl	$1000, %r12d                    # imm = 0x3E8
	movq	%rbx, %r13
.LBB3_1:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_2 Depth 2
	movq	$-1000, %rbp                    # imm = 0xFC18
.LBB3_2:                                #   Parent Loop BB3_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movzbl	1000(%r13,%rbp), %edi
	movq	%r14, %rsi
	callq	fputc
	xorl	%edi, %edi
	movq	%r14, %rsi
	callq	fputc
	xorl	%edi, %edi
	movq	%r14, %rsi
	callq	fputc
	incq	%rbp
	jne	.LBB3_2
# %bb.3:                                #   in Loop: Header=BB3_1 Depth=1
	incq	%r15
	addq	%r12, %r13
	cmpq	%r12, %r15
	jne	.LBB3_1
# %bb.4:
	movq	%r14, %rdi
	callq	fclose
	movq	%rbx, %rdi
	addq	$8, %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
	jmp	_ZdaPv                          # TAILCALL
.Lfunc_end3:
	.size	_Z13julia_set_gpuv, .Lfunc_end3-_Z13julia_set_gpuv
	.cfi_endproc
                                        # -- End function
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	callq	_Z13julia_set_cpuv
	callq	_Z13julia_set_gpuv
	xorl	%eax, %eax
	popq	%rcx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end4:
	.size	main, .Lfunc_end4-main
	.cfi_endproc
                                        # -- End function
	.p2align	4, 0x90                         # -- Begin function __hip_module_ctor
	.type	__hip_module_ctor,@function
__hip_module_ctor:                      # @__hip_module_ctor
	.cfi_startproc
# %bb.0:
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	movq	__hip_gpubin_handle(%rip), %rdi
	testq	%rdi, %rdi
	jne	.LBB5_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB5_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z6kernelPh, %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_end5:
	.size	__hip_module_ctor, .Lfunc_end5-__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	.LBB6_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
.LBB6_2:
	retq
.Lfunc_end6:
	.size	__hip_module_dtor, .Lfunc_end6-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"julia_cpu.ppm"
	.size	.L.str, 14

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

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"P6\n%i %i 255\n"
	.size	.L.str.2, 14

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

	.type	.L.str.3,@object                # @.str.3
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.3:
	.asciz	"julia_gpu.ppm"
	.size	.L.str.3, 14

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z6kernelPh"
	.size	.L__unnamed_1, 12

	.type	__hip_fatbin_wrapper,@object    # @__hip_fatbin_wrapper
	.section	.hipFatBinSegment,"a",@progbits
	.p2align	3, 0x0
__hip_fatbin_wrapper:
	.long	1212764230                      # 0x48495046
	.long	1                               # 0x1
	.quad	__hip_fatbin
	.quad	0
	.size	__hip_fatbin_wrapper, 24

	.type	__hip_gpubin_handle,@object     # @__hip_gpubin_handle
	.local	__hip_gpubin_handle
	.comm	__hip_gpubin_handle,8,8
	.section	.init_array,"aw",@init_array
	.p2align	3, 0x0
	.quad	__hip_module_ctor
	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

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

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z6kernelPh             ; -- Begin function _Z6kernelPh
	.globl	_Z6kernelPh
	.p2align	8
	.type	_Z6kernelPh,@function
_Z6kernelPh:                            ; @_Z6kernelPh
; %bb.0:
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z6kernelPh
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 8
		.amdhsa_user_sgpr_count 15
		.amdhsa_user_sgpr_dispatch_ptr 0
		.amdhsa_user_sgpr_queue_ptr 0
		.amdhsa_user_sgpr_kernarg_segment_ptr 1
		.amdhsa_user_sgpr_dispatch_id 0
		.amdhsa_user_sgpr_private_segment_size 0
		.amdhsa_wavefront_size32 1
		.amdhsa_uses_dynamic_stack 0
		.amdhsa_enable_private_segment 0
		.amdhsa_system_sgpr_workgroup_id_x 1
		.amdhsa_system_sgpr_workgroup_id_y 0
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 0
		.amdhsa_next_free_vgpr 1
		.amdhsa_next_free_sgpr 1
		.amdhsa_reserve_vcc 0
		.amdhsa_float_round_mode_32 0
		.amdhsa_float_round_mode_16_64 0
		.amdhsa_float_denorm_mode_32 3
		.amdhsa_float_denorm_mode_16_64 3
		.amdhsa_dx10_clamp 1
		.amdhsa_ieee_mode 1
		.amdhsa_fp16_overflow 0
		.amdhsa_workgroup_processor_mode 1
		.amdhsa_memory_ordered 1
		.amdhsa_forward_progress 0
		.amdhsa_shared_vgpr_count 0
		.amdhsa_exception_fp_ieee_invalid_op 0
		.amdhsa_exception_fp_denorm_src 0
		.amdhsa_exception_fp_ieee_div_zero 0
		.amdhsa_exception_fp_ieee_overflow 0
		.amdhsa_exception_fp_ieee_underflow 0
		.amdhsa_exception_fp_ieee_inexact 0
		.amdhsa_exception_int_div_zero 0
	.end_amdhsa_kernel
	.text
.Lfunc_end0:
	.size	_Z6kernelPh, .Lfunc_end0-_Z6kernelPh
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 4
; NumSgprs: 0
; NumVgprs: 0
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 0
; VGPRBlocks: 0
; NumSGPRsForWavesPerEU: 1
; NumVGPRsForWavesPerEU: 1
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 15
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 0
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 0
	.text
	.p2alignl 7, 3214868480
	.fill 96, 4, 3214868480
	.type	__hip_cuid_,@object             ; @__hip_cuid_
	.section	.bss,"aw",@nobits
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               ; 0x0
	.size	__hip_cuid_, 1

	.ident	"AMD clang version 18.0.0git (https://github.com/RadeonOpenCompute/llvm-project roc-6.3.2 25012 e5bf7e55c91490b07c49d8960fa7983d864936c4)"
	.section	".note.GNU-stack","",@progbits
	.addrsig
	.addrsig_sym __hip_cuid_
	.amdgpu_metadata
---
amdhsa.kernels:
  - .args:
      - .address_space:  global
        .offset:         0
        .size:           8
        .value_kind:     global_buffer
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 8
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z6kernelPh
    .private_segment_fixed_size: 0
    .sgpr_count:     0
    .sgpr_spill_count: 0
    .symbol:         _Z6kernelPh.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     0
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
