#include <stdio.h>
#include <math.h>
#include <png.h>
#include <string.h>
#include <stdlib.h>
#define MAX_ITERATION 100
#define CEIL(a, b) (((a) + (b) - 1)/(b)) 

__global__ void kernel(int width, int height, float min_real, float min_imag, float max_real, float max_imag, int iteration, float *buffer);

int writeImage(const char* filename, int width, int height, float *buffer, const char* title);

static void setRGB(png_byte *ptr, float val);

#define CEIL(a, b) (((a) + (b) - 1)/(b)) 

/* ./exec <min_real> <min_imag> <max_real> <max_imag> <W> <H> <CPU/GPU> <Treadhs> <Saida> */
int main(int argc, char *argv[]){

	if(argc != 10){
		printf("Please specify output file\n");
		return 1;
	}

	/* Set variables */
	float min_real = atof(argv[1]);
	float min_imag = atof(argv[2]);
	float max_real = atof(argv[3]);
	float max_imag = atof(argv[4]);
	int width = atoi(argv[5]);
	int height = atoi(argv[6]);
	char accelerator[50];
	strcpy(accelerator, argv[7]);
	int threads = atoi(argv[8]);
	char file_name[50];
	strcpy(file_name, argv[9]);
	int iteration = MAX_ITERATION;
	float *buffer;
	float *d_buffer;


	/* Aloco no PC */
	buffer = (float*)malloc(width*height*sizeof(float));
	
	/* Aloco na placa de video */
	cudaMalloc(&d_buffer, width*height*sizeof(float));
	
	/* Setar os bocos para trabalhar na placa de video */
	int threads_per_block = threads;
	int num_blocks = CEIL((width*height), threads_per_block);
		
    	/* Se eu chamar a funcao em cuda */
	kernel<<<num_blocks, threads_per_block>>>(width, height, min_real, min_imag, max_imag, max_real, iteration, d_buffer);
	/* Passei N blocos, sendo uma x threads por bloco */
	
	cudaDeviceSynchronize();

	/* Pego o buffer da Placa de video e trago para o PC */
	cudaMemcpy(buffer, d_buffer, width*height*sizeof(float), cudaMemcpyDeviceToHost);
	
	/* So printa a imagem */
	printf("Saving PNG\n");
	int result = writeImage(file_name, width, height, buffer, "MANDELBROT");
	

	/* Free no buffer na placa de video */
	cudaFree(buffer);
	/* Free no buffer no PC */
	free(buffer);

	return 0;
}

__global__ void kernel(int width, int height, float min_real, float min_imag, float max_real, float max_imag, int iteration_max, float *buffer){

	int index_vector = (blockIdx.x * blockDim.x) + threadIdx.x;
	int i = index_vector / width;
	int j = index_vector % width;
	float del_x = (max_real - min_real)/width;
	float del_y= (max_imag - min_imag)/height;
	float z_y = 0.0;
	float z_x = 0.0; 
	int iteration = 0;
	float xtemp;
	float x_point = min_real + del_x * j;
	float y_point = max_imag - del_y * i;
	
	while((((z_x * z_x) + (z_y * z_y)) <= 4) && (iteration < iteration_max)){
		xtemp = ((z_x * z_x) - (z_y * z_y)+x_point);
		z_y = (2.0 * z_x * z_y)+ y_point;
		z_x = xtemp;
		iteration++;
	}
	
	buffer[index_vector] = iteration;
};

__host__ static void setRGB(png_byte *ptr, float val){

	int v = 255 - (int)(val/MAX_ITERATION) * 255;
	if(v == 0){
		ptr[0] = v;
		ptr[1] = v;
		ptr[2] = v;
	}else{
		if(val < 10){
			ptr[0] = 192;
			ptr[1] = 217;
			ptr[2] = 217;
		}else if(val < 15){
			ptr[0] = 95;
			ptr[1] = 159;
			ptr[2] = 159;
		}else if(val < 25){
			ptr[0] = 0;
			ptr[1] = 255;
			ptr[2] = 255;
		}else if(val < 50){
			ptr[0] = 255;
			ptr[1] = 0;
			ptr[2] = 255;
		}else if(val < 75){
			ptr[0] = 234;
			ptr[1] = 173;
			ptr[2] = 234;
		}else{
			ptr[0] = 79;
			ptr[1] = 47;
			ptr[2] = 79;
		}
	}
}; 


__host__ int writeImage(const char* filename, int width, int height, float *buffer, const char* title){
	int code = 0;
	FILE *fp = NULL;
	png_structp png_ptr = NULL;
	png_infop info_ptr = NULL;
	png_bytep row = NULL;

	// Open file for writing (binary mode)
	fp = fopen(filename, "wb");
	if (fp == NULL) {
		printf( "Could not open file %s for writing\n", filename);
		code = 1;
		goto finalise;
	}

	// Initialize write structure
	png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
	if (png_ptr == NULL) {
		printf( "Could not allocate write struct\n");
		code = 1;
		goto finalise;
	}

	// Initialize info structure
	info_ptr = png_create_info_struct(png_ptr);
	if (info_ptr == NULL) {
		printf( "Could not allocate info struct\n");
		code = 1;
		goto finalise;
	}

	// Setup Exception handling
	if (setjmp(png_jmpbuf(png_ptr))) {
		printf( "Error during png creation\n");
		code = 1;
		goto finalise;
	}

	png_init_io(png_ptr, fp);

	// Write header (8 bit colour depth)
	png_set_IHDR(png_ptr, info_ptr, width, height,
			8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
			PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);


	png_write_info(png_ptr, info_ptr);

	// Allocate memory for one row (3 bytes per pixel - RGB)
	row = (png_bytep) malloc(3 * width * sizeof(png_byte));

	// Write image data
	int x, y;
	for (y=0 ; y<height ; y++) {
		for (x=0 ; x<width ; x++) {
			setRGB(&(row[x*3]), buffer[y*width + x]);
		}
		png_write_row(png_ptr, row);
	}

	// End write
	png_write_end(png_ptr, NULL);

	finalise:
	if (fp != NULL) fclose(fp);
	if (info_ptr != NULL) png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
	if (png_ptr != NULL) png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
	if (row != NULL) free(row);

	return code;
};

	.file	"tmpxft_00369ba2_00000000-6_mandelbrot_cuda.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2032:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2032:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"wb"
.LC1:
	.string	"Could not open file %s for writing\n"
.LC2:
	.string	"1.6.43"
.LC3:
	.string	"Could not allocate write struct\n"
.LC4:
	.string	"Could not allocate info struct\n"
.LC5:
	.string	"Error during png creation\n"
	.text
	.globl	_Z10writeImagePKciiPfS0_
	.type	_Z10writeImagePKciiPfS0_, @function
_Z10writeImagePKciiPfS0_:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	xorl	%r8d, %r8d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rdi, %rbx
	subq	$88, %rsp
	.cfi_def_cfa_offset 128
	movl	%esi, 48(%rsp)
	leaq	.LC0(%rip), %rsi
	movl	%edx, 52(%rsp)
	movq	%rcx, 56(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	movq	%r8, 64(%rsp)
	call	fopen@PLT
	movq	%rax, 32(%rsp)
	testq	%rax, %rax
	jne	.L3
	movl	$2, %edi
	movq	%rbx, %rdx
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	xorl	%edi, %edi
	movq	%rdi, (%rsp)
	movq	%rdi, 16(%rsp)
	movq	%rdi, 8(%rsp)
	jmp	.L35
.L3:
	leaq	.LC2(%rip), %rdi
	xorl	%ecx, %ecx
	xorl	%edx, %edx
	xorl	%esi, %esi
	call	png_create_write_struct@PLT
	movq	%rax, 64(%rsp)
	movq	%rax, %rdi
	testq	%rax, %rax
	jne	.L5
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
.L36:
	call	__printf_chk@PLT
	movq	32(%rsp), %rax
	xorl	%esi, %esi
	movq	%rsi, (%rsp)
	movq	%rsi, 16(%rsp)
	movq	%rax, 8(%rsp)
.L35:
	movl	$1, 28(%rsp)
	jmp	.L4
.L5:
	call	png_create_info_struct@PLT
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	movq	%rax, 40(%rsp)
	testq	%rax, %rax
	je	.L36
	movq	64(%rsp), %rdi
	movq	__longjmp_chk@GOTPCREL(%rip), %rsi
	movl	$200, %edx
	call	png_set_longjmp_fn@PLT
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	movq	%rax, %rdi
	movq	40(%rsp), %rax
	movq	%rdx, (%rsp)
	movl	%ecx, 28(%rsp)
	movq	%rax, 16(%rsp)
	movq	32(%rsp), %rax
	movq	%rax, 8(%rsp)
	call	_setjmp@PLT
	endbr64
	movl	%eax, %ebx
	testl	%eax, %eax
	je	.L8
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L35
.L8:
	movq	32(%rsp), %rsi
	movq	64(%rsp), %rdi
	xorl	%ebp, %ebp
	call	png_init_io@PLT
	movl	$2, %r9d
	movl	$8, %r8d
	pushq	%rax
	.cfi_def_cfa_offset 136
	pushq	$0
	.cfi_def_cfa_offset 144
	pushq	$0
	.cfi_def_cfa_offset 152
	pushq	$0
	.cfi_def_cfa_offset 160
	movl	84(%rsp), %ecx
	movl	80(%rsp), %edx
	movq	72(%rsp), %rsi
	movq	96(%rsp), %rdi
	call	png_set_IHDR@PLT
	movq	72(%rsp), %rsi
	movq	96(%rsp), %rdi
	addq	$32, %rsp
	.cfi_def_cfa_offset 128
	call	png_write_info@PLT
	imull	$3, 48(%rsp), %edi
	movslq	%edi, %rdi
	call	malloc@PLT
	movq	%rax, (%rsp)
.L9:
	movl	52(%rsp), %eax
	cmpl	%eax, %ebx
	jge	.L12
	movslq	%ebp, %rax
	movss	.LC7(%rip), %xmm4
	xorl	%esi, %esi
	xorl	%r8d, %r8d
	movq	56(%rsp), %rcx
	movb	$-64, %r12b
	movb	$-39, %r10b
	movb	$95, %r11b
	movss	.LC8(%rip), %xmm3
	movss	.LC9(%rip), %xmm2
	movb	$-97, %r9b
	movss	.LC10(%rip), %xmm1
	leaq	(%rcx,%rax,4), %r13
.L13:
	cmpl	%esi, 48(%rsp)
	jle	.L38
	movq	(%rsp), %rax
	movss	0(%r13,%rsi,4), %xmm0
	leaq	(%rsi,%rsi,2), %rdi
	addq	%rax, %rdi
	movaps	%xmm0, %xmm5
	divss	.LC6(%rip), %xmm5
	cvttss2sil	%xmm5, %eax
	decl	%eax
	je	.L27
	comiss	%xmm0, %xmm4
	ja	.L28
	comiss	%xmm0, %xmm3
	ja	.L29
	comiss	%xmm0, %xmm2
	ja	.L30
	comiss	%xmm0, %xmm1
	ja	.L31
	movss	.LC11(%rip), %xmm5
	movb	$79, %dl
	movb	$-22, %al
	movb	$47, %cl
	comiss	%xmm0, %xmm5
	cmovbe	%edx, %eax
	movb	$-83, %dl
	cmovbe	%ecx, %edx
	movl	%eax, %ecx
	jmp	.L10
.L27:
	movl	%r8d, %eax
	movl	%r8d, %edx
	movl	%r8d, %ecx
	jmp	.L10
.L28:
	movl	%r12d, %eax
	movl	%r10d, %edx
	movl	%r10d, %ecx
	jmp	.L10
.L29:
	movl	%r11d, %eax
	movl	%r9d, %edx
	movl	%r9d, %ecx
	jmp	.L10
.L30:
	movl	%r8d, %eax
	movb	$-1, %dl
	jmp	.L34
.L31:
	movb	$-1, %al
	xorl	%edx, %edx
.L34:
	movb	$-1, %cl
.L10:
	movb	%al, (%rdi)
	incq	%rsi
	movb	%dl, 1(%rdi)
	movb	%cl, 2(%rdi)
	jmp	.L13
.L38:
	movq	(%rsp), %rsi
	movq	64(%rsp), %rdi
	incl	%ebx
	call	png_write_row@PLT
	movl	48(%rsp), %eax
	addl	%eax, %ebp
	jmp	.L9
.L12:
	movq	64(%rsp), %rdi
	xorl	%esi, %esi
	call	png_write_end@PLT
.L4:
	cmpq	$0, 8(%rsp)
	jne	.L14
.L17:
	cmpq	$0, 16(%rsp)
	movq	64(%rsp), %rdi
	jne	.L15
	jmp	.L16
.L14:
	movq	8(%rsp), %rdi
	call	fclose@PLT
	jmp	.L17
.L15:
	movq	16(%rsp), %rsi
	orl	$-1, %ecx
	movl	$65535, %edx
	call	png_free_data@PLT
.L16:
	cmpq	$0, 64(%rsp)
	je	.L19
	leaq	64(%rsp), %rdi
	xorl	%esi, %esi
	call	png_destroy_write_struct@PLT
.L19:
	cmpq	$0, (%rsp)
	je	.L2
	movq	(%rsp), %rdi
	call	free@PLT
.L2:
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	movl	28(%rsp), %eax
	addq	$88, %rsp
	.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
.LFE2029:
	.size	_Z10writeImagePKciiPfS0_, .-_Z10writeImagePKciiPfS0_
	.globl	_Z32__device_stub__Z6kerneliiffffiPfiiffffiPf
	.type	_Z32__device_stub__Z6kerneliiffffiPfiiffffiPf, @function
_Z32__device_stub__Z6kerneliiffffiPfiiffffiPf:
.LFB2054:
	.cfi_startproc
	endbr64
	subq	$200, %rsp
	.cfi_def_cfa_offset 208
	movl	%edi, 44(%rsp)
	leaq	72(%rsp), %rdi
	movl	%esi, 40(%rsp)
	leaq	84(%rsp), %rsi
	movl	%edx, 20(%rsp)
	leaq	56(%rsp), %rdx
	movq	%rcx, 8(%rsp)
	leaq	64(%rsp), %rcx
	movss	%xmm0, 36(%rsp)
	movss	%xmm1, 32(%rsp)
	movss	%xmm2, 28(%rsp)
	movss	%xmm3, 24(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	leaq	44(%rsp), %rax
	movl	$1, 80(%rsp)
	movq	%rax, 120(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 128(%rsp)
	leaq	36(%rsp), %rax
	movq	%rax, 136(%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 144(%rsp)
	leaq	28(%rsp), %rax
	movq	%rax, 152(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 160(%rsp)
	leaq	20(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 176(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 72(%rsp)
	movq	%rax, 84(%rsp)
	movl	$1, 92(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L39
	pushq	64(%rsp)
	.cfi_def_cfa_offset 216
	leaq	_Z6kerneliiffffiPf(%rip), %rdi
	pushq	64(%rsp)
	.cfi_def_cfa_offset 224
	movq	100(%rsp), %rcx
	movl	108(%rsp), %r8d
	movq	88(%rsp), %rsi
	movl	96(%rsp), %edx
	leaq	136(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 216
	popq	%rdx
	.cfi_def_cfa_offset 208
.L39:
	movq	184(%rsp), %rax
	subq	%fs:40, %rax
	je	.L41
	call	__stack_chk_fail@PLT
.L41:
	addq	$200, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2054:
	.size	_Z32__device_stub__Z6kerneliiffffiPfiiffffiPf, .-_Z32__device_stub__Z6kerneliiffffiPfiiffffiPf
	.globl	_Z6kerneliiffffiPf
	.type	_Z6kerneliiffffiPf, @function
_Z6kerneliiffffiPf:
.LFB2055:
	.cfi_startproc
	endbr64
	jmp	_Z32__device_stub__Z6kerneliiffffiPfiiffffiPf
	.cfi_endproc
.LFE2055:
	.size	_Z6kerneliiffffiPf, .-_Z6kerneliiffffiPf
	.section	.rodata.str1.1
.LC12:
	.string	"Please specify output file\n"
.LC13:
	.string	"Saving PNG\n"
.LC14:
	.string	"MANDELBROT"
	.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
	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	$200, %rsp
	.cfi_def_cfa_offset 256
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	cmpl	$10, %edi
	je	.L45
	leaq	.LC12(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	$1, %eax
	jmp	.L44
.L45:
	movq	8(%rsi), %rdi
	movq	%rsi, %rbx
	leaq	134(%rsp), %r15
	call	atof@PLT
	movq	16(%rbx), %rdi
	movsd	%xmm0, 40(%rsp)
	call	atof@PLT
	movq	24(%rbx), %rdi
	movsd	%xmm0, 32(%rsp)
	call	atof@PLT
	movq	32(%rbx), %rdi
	movsd	%xmm0, 24(%rsp)
	call	atof@PLT
	movq	40(%rbx), %rdi
	movsd	%xmm0, 16(%rsp)
	call	atoi@PLT
	movq	48(%rbx), %rdi
	movl	%eax, %r12d
	call	atoi@PLT
	movq	56(%rbx), %rsi
	movl	$50, %edx
	leaq	84(%rsp), %rdi
	movl	%eax, %r13d
	call	__strcpy_chk@PLT
	movq	64(%rbx), %rdi
	call	atoi@PLT
	movq	72(%rbx), %rsi
	movl	%r12d, %ebx
	movl	$50, %edx
	imull	%r13d, %ebx
	movq	%r15, %rdi
	movl	%eax, %ebp
	call	__strcpy_chk@PLT
	movslq	%ebx, %r14
	salq	$2, %r14
	movq	%r14, %rdi
	call	malloc@PLT
	leaq	48(%rsp), %rdi
	movq	%r14, %rsi
	movq	%rax, 8(%rsp)
	call	cudaMalloc@PLT
	leal	-1(%rbx,%rbp), %eax
	movl	%ebp, 72(%rsp)
	xorl	%r9d, %r9d
	movabsq	$4294967297, %rcx
	cltd
	xorl	%r8d, %r8d
	idivl	%ebp
	movq	%rcx, 64(%rsp)
	movl	68(%rsp), %esi
	movq	%rcx, 76(%rsp)
	movl	80(%rsp), %ecx
	movq	72(%rsp), %rdx
	movl	%eax, 60(%rsp)
	movq	60(%rsp), %rdi
	call	__cudaPushCallConfiguration@PLT
	movsd	16(%rsp), %xmm2
	movsd	24(%rsp), %xmm3
	testl	%eax, %eax
	movsd	32(%rsp), %xmm1
	movsd	40(%rsp), %xmm4
	jne	.L47
	movq	48(%rsp), %rcx
	movl	$100, %edx
	movl	%r13d, %esi
	movl	%r12d, %edi
	cvtsd2ss	%xmm4, %xmm0
	cvtsd2ss	%xmm3, %xmm3
	cvtsd2ss	%xmm2, %xmm2
	cvtsd2ss	%xmm1, %xmm1
	call	_Z32__device_stub__Z6kerneliiffffiPfiiffffiPf
.L47:
	call	cudaDeviceSynchronize@PLT
	movq	48(%rsp), %rsi
	movq	8(%rsp), %rdi
	movq	%r14, %rdx
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	leaq	.LC13(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rsp), %rcx
	movl	%r13d, %edx
	movl	%r12d, %esi
	leaq	.LC14(%rip), %r8
	movq	%r15, %rdi
	call	_Z10writeImagePKciiPfS0_
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	8(%rsp), %rdi
	call	free@PLT
	xorl	%eax, %eax
.L44:
	movq	184(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L48
	call	__stack_chk_fail@PLT
.L48:
	addq	$200, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	main, .-main
	.section	.rodata.str1.1
.LC15:
	.string	"_Z6kerneliiffffiPf"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2057:
	.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	_Z6kerneliiffffiPf(%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
.LFE2057:
	.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
.LC6:
	.long	1120403456
	.align 4
.LC7:
	.long	1092616192
	.align 4
.LC8:
	.long	1097859072
	.align 4
.LC9:
	.long	1103626240
	.align 4
.LC10:
	.long	1112014848
	.align 4
.LC11:
	.long	1117126656
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include <hip/hip_runtime.h>
#include <stdio.h>
#include <math.h>
#include <png.h>
#include <string.h>
#include <stdlib.h>
#define MAX_ITERATION 100
#define CEIL(a, b) (((a) + (b) - 1)/(b)) 

__global__ void kernel(int width, int height, float min_real, float min_imag, float max_real, float max_imag, int iteration, float *buffer);

int writeImage(const char* filename, int width, int height, float *buffer, const char* title);

static void setRGB(png_byte *ptr, float val);

#define CEIL(a, b) (((a) + (b) - 1)/(b)) 

/* ./exec <min_real> <min_imag> <max_real> <max_imag> <W> <H> <CPU/GPU> <Treadhs> <Saida> */
int main(int argc, char *argv[]){

	if(argc != 10){
		printf("Please specify output file\n");
		return 1;
	}

	/* Set variables */
	float min_real = atof(argv[1]);
	float min_imag = atof(argv[2]);
	float max_real = atof(argv[3]);
	float max_imag = atof(argv[4]);
	int width = atoi(argv[5]);
	int height = atoi(argv[6]);
	char accelerator[50];
	strcpy(accelerator, argv[7]);
	int threads = atoi(argv[8]);
	char file_name[50];
	strcpy(file_name, argv[9]);
	int iteration = MAX_ITERATION;
	float *buffer;
	float *d_buffer;


	/* Aloco no PC */
	buffer = (float*)malloc(width*height*sizeof(float));
	
	/* Aloco na placa de video */
	hipMalloc(&d_buffer, width*height*sizeof(float));
	
	/* Setar os bocos para trabalhar na placa de video */
	int threads_per_block = threads;
	int num_blocks = CEIL((width*height), threads_per_block);
		
    	/* Se eu chamar a funcao em cuda */
	kernel<<<num_blocks, threads_per_block>>>(width, height, min_real, min_imag, max_imag, max_real, iteration, d_buffer);
	/* Passei N blocos, sendo uma x threads por bloco */
	
	hipDeviceSynchronize();

	/* Pego o buffer da Placa de video e trago para o PC */
	hipMemcpy(buffer, d_buffer, width*height*sizeof(float), hipMemcpyDeviceToHost);
	
	/* So printa a imagem */
	printf("Saving PNG\n");
	int result = writeImage(file_name, width, height, buffer, "MANDELBROT");
	

	/* Free no buffer na placa de video */
	hipFree(buffer);
	/* Free no buffer no PC */
	free(buffer);

	return 0;
}

__global__ void kernel(int width, int height, float min_real, float min_imag, float max_real, float max_imag, int iteration_max, float *buffer){

	int index_vector = (blockIdx.x * blockDim.x) + threadIdx.x;
	int i = index_vector / width;
	int j = index_vector % width;
	float del_x = (max_real - min_real)/width;
	float del_y= (max_imag - min_imag)/height;
	float z_y = 0.0;
	float z_x = 0.0; 
	int iteration = 0;
	float xtemp;
	float x_point = min_real + del_x * j;
	float y_point = max_imag - del_y * i;
	
	while((((z_x * z_x) + (z_y * z_y)) <= 4) && (iteration < iteration_max)){
		xtemp = ((z_x * z_x) - (z_y * z_y)+x_point);
		z_y = (2.0 * z_x * z_y)+ y_point;
		z_x = xtemp;
		iteration++;
	}
	
	buffer[index_vector] = iteration;
};

__host__ static void setRGB(png_byte *ptr, float val){

	int v = 255 - (int)(val/MAX_ITERATION) * 255;
	if(v == 0){
		ptr[0] = v;
		ptr[1] = v;
		ptr[2] = v;
	}else{
		if(val < 10){
			ptr[0] = 192;
			ptr[1] = 217;
			ptr[2] = 217;
		}else if(val < 15){
			ptr[0] = 95;
			ptr[1] = 159;
			ptr[2] = 159;
		}else if(val < 25){
			ptr[0] = 0;
			ptr[1] = 255;
			ptr[2] = 255;
		}else if(val < 50){
			ptr[0] = 255;
			ptr[1] = 0;
			ptr[2] = 255;
		}else if(val < 75){
			ptr[0] = 234;
			ptr[1] = 173;
			ptr[2] = 234;
		}else{
			ptr[0] = 79;
			ptr[1] = 47;
			ptr[2] = 79;
		}
	}
}; 


__host__ int writeImage(const char* filename, int width, int height, float *buffer, const char* title){
	int code = 0;
	FILE *fp = NULL;
	png_structp png_ptr = NULL;
	png_infop info_ptr = NULL;
	png_bytep row = NULL;

	// Open file for writing (binary mode)
	fp = fopen(filename, "wb");
	if (fp == NULL) {
		printf( "Could not open file %s for writing\n", filename);
		code = 1;
		goto finalise;
	}

	// Initialize write structure
	png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
	if (png_ptr == NULL) {
		printf( "Could not allocate write struct\n");
		code = 1;
		goto finalise;
	}

	// Initialize info structure
	info_ptr = png_create_info_struct(png_ptr);
	if (info_ptr == NULL) {
		printf( "Could not allocate info struct\n");
		code = 1;
		goto finalise;
	}

	// Setup Exception handling
	if (setjmp(png_jmpbuf(png_ptr))) {
		printf( "Error during png creation\n");
		code = 1;
		goto finalise;
	}

	png_init_io(png_ptr, fp);

	// Write header (8 bit colour depth)
	png_set_IHDR(png_ptr, info_ptr, width, height,
			8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE,
			PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);


	png_write_info(png_ptr, info_ptr);

	// Allocate memory for one row (3 bytes per pixel - RGB)
	row = (png_bytep) malloc(3 * width * sizeof(png_byte));

	// Write image data
	int x, y;
	for (y=0 ; y<height ; y++) {
		for (x=0 ; x<width ; x++) {
			setRGB(&(row[x*3]), buffer[y*width + x]);
		}
		png_write_row(png_ptr, row);
	}

	// End write
	png_write_end(png_ptr, NULL);

	finalise:
	if (fp != NULL) fclose(fp);
	if (info_ptr != NULL) png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
	if (png_ptr != NULL) png_destroy_write_struct(&png_ptr, (png_infopp)NULL);
	if (row != NULL) free(row);

	return code;
};

	.text
	.file	"mandelbrot_cuda.hip"
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$10, %edi
	jne	.LBB0_1
# %bb.2:
	movq	%rsi, %r14
	movq	8(%rsi), %rdi
	callq	atof
	movsd	%xmm0, 40(%rsp)                 # 8-byte Spill
	movq	16(%r14), %rdi
	callq	atof
	movsd	%xmm0, 32(%rsp)                 # 8-byte Spill
	movq	24(%r14), %rdi
	callq	atof
	movsd	%xmm0, 24(%rsp)                 # 8-byte Spill
	movq	32(%r14), %rdi
	callq	atof
	movsd	%xmm0, 16(%rsp)                 # 8-byte Spill
	movq	40(%r14), %rdi
	callq	atoi
	movl	%eax, %ebx
	movq	48(%r14), %rdi
	callq	atoi
	movl	%eax, %ebp
	movq	64(%r14), %rdi
	callq	atoi
	movl	%eax, %r15d
	movq	72(%r14), %rsi
	leaq	48(%rsp), %rdi
	callq	strcpy
	movl	%ebp, %eax
	imull	%ebx, %eax
	movslq	%eax, %r13
	leaq	(,%r13,4), %r12
	movq	%r12, %rdi
	callq	malloc
	movq	%rax, %r14
	leaq	8(%rsp), %rdi
	movq	%r12, %rsi
	callq	hipMalloc
	leal	(%r15,%r13), %eax
	decl	%eax
	cltd
	idivl	%r15d
                                        # kill: def $eax killed $eax def $rax
	btsq	$32, %rax
	movl	%r15d, %edx
	btsq	$32, %rdx
	xorl	%r15d, %r15d
	movq	%rax, %rdi
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB0_4
# %bb.3:
	cvtsd2ss	16(%rsp), %xmm2                 # 8-byte Folded Reload
	cvtsd2ss	24(%rsp), %xmm3                 # 8-byte Folded Reload
	cvtsd2ss	32(%rsp), %xmm1                 # 8-byte Folded Reload
	xorps	%xmm0, %xmm0
	cvtsd2ss	40(%rsp), %xmm0                 # 8-byte Folded Reload
	movq	8(%rsp), %rcx
	movl	%ebx, %edi
	movl	%ebp, %esi
	movl	$100, %edx
	callq	_Z21__device_stub__kerneliiffffiPf
.LBB0_4:
	callq	hipDeviceSynchronize
	movq	8(%rsp), %rsi
	movq	%r14, %rdi
	movq	%r12, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movl	$.Lstr, %edi
	callq	puts@PLT
	leaq	48(%rsp), %rdi
	movl	%ebx, %esi
	movl	%ebp, %edx
	movq	%r14, %rcx
	callq	_Z10writeImagePKciiPfS0_
	movq	%r14, %rdi
	callq	hipFree
	movq	%r14, %rdi
	callq	free
	jmp	.LBB0_5
.LBB0_1:
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$1, %r15d
.LBB0_5:
	movl	%r15d, %eax
	addq	$104, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.globl	_Z21__device_stub__kerneliiffffiPf # -- Begin function _Z21__device_stub__kerneliiffffiPf
	.type	_Z21__device_stub__kerneliiffffiPf,@function
_Z21__device_stub__kerneliiffffiPf:     # @_Z21__device_stub__kerneliiffffiPf
	.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	$160, %rsp
	.cfi_def_cfa_offset 208
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	36(%rsp), %rax
	movl	%edi, (%rax)
	leaq	32(%rsp), %rdi
	movl	%esi, (%rdi)
	leaq	28(%rsp), %rsi
	movss	%xmm0, (%rsi)
	leaq	24(%rsp), %r8
	movss	%xmm1, (%r8)
	leaq	20(%rsp), %r9
	movss	%xmm2, (%r9)
	leaq	16(%rsp), %r10
	movss	%xmm3, (%r10)
	leaq	12(%rsp), %r11
	movl	%edx, (%r11)
	leaq	56(%rsp), %rdx
	movq	%rcx, (%rdx)
	leaq	96(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%r8, 24(%rbx)
	movq	%r9, 32(%rbx)
	movq	%r10, 40(%rbx)
	movq	%r11, 48(%rbx)
	movq	%rdx, 56(%rbx)
	leaq	80(%rsp), %r14
	leaq	64(%rsp), %r15
	leaq	48(%rsp), %r12
	leaq	40(%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	$_Z6kerneliiffffiPf, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$176, %rsp
	.cfi_adjust_cfa_offset -176
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z21__device_stub__kerneliiffffiPf, .Lfunc_end1-_Z21__device_stub__kerneliiffffiPf
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function _Z10writeImagePKciiPfS0_
.LCPI2_0:
	.long	0x42c80000                      # float 100
.LCPI2_1:
	.long	0x41200000                      # float 10
.LCPI2_2:
	.long	0x41700000                      # float 15
.LCPI2_3:
	.long	0x41c80000                      # float 25
.LCPI2_4:
	.long	0x42480000                      # float 50
.LCPI2_5:
	.long	0x42960000                      # float 75
	.text
	.globl	_Z10writeImagePKciiPfS0_
	.type	_Z10writeImagePKciiPfS0_,@function
_Z10writeImagePKciiPfS0_:               # @_Z10writeImagePKciiPfS0_
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rcx, 24(%rsp)                  # 8-byte Spill
	movl	%edx, %r14d
	movl	%esi, %ebp
	movq	%rdi, %rbx
	movl	$.L.str.3, %esi
	callq	fopen
	testq	%rax, %rax
	je	.LBB2_5
# %bb.1:
	movq	%rax, %r13
	movl	$.L.str.5, %edi
	xorl	%eax, %eax
	movl	%eax, %ecx
	movq	%rcx, %rsi
	movq	%rcx, %rdx
	callq	png_create_write_struct
	movq	%rax, %r15
	movq	%rax, 48(%rsp)
	testq	%rax, %rax
	je	.LBB2_6
# %bb.2:
	movq	%r15, %r12
	movq	%r15, %rdi
	callq	png_create_info_struct
	testq	%rax, %rax
	je	.LBB2_7
# %bb.3:
	movq	%rax, %rbx
	movl	$longjmp, %esi
	movl	$200, %edx
	movq	%r12, %rdi
	callq	png_set_longjmp_fn
	movq	%rax, %rdi
	callq	_setjmp
	testl	%eax, %eax
	movq	%rbx, 16(%rsp)                  # 8-byte Spill
	je	.LBB2_9
# %bb.4:                                # %.thread.thread77
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	$1, %eax
	xorl	%ecx, %ecx
	movl	%ecx, %r14d
	jmp	.LBB2_30
.LBB2_5:                                # %.thread91
	movl	$.L.str.4, %edi
	xorl	%eax, %eax
                                        # kill: def $al killed $al killed $eax
	movq	%rbx, %rsi
	callq	printf
	movl	$1, %eax
	jmp	.LBB2_36
.LBB2_6:
	movl	$.Lstr.4, %edi
	jmp	.LBB2_8
.LBB2_7:
	movl	$.Lstr.3, %edi
.LBB2_8:                                # %.thread.thread
	callq	puts@PLT
	movq	%r13, %rdi
	callq	fclose
	movl	$1, %ebx
	xorl	%eax, %eax
	movl	%eax, %r14d
	jmp	.LBB2_31
.LBB2_9:
	movq	%r15, 40(%rsp)                  # 8-byte Spill
	movq	%r12, %rdi
	movq	%r13, 32(%rsp)                  # 8-byte Spill
	movq	%r13, %rsi
	callq	png_init_io
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	xorl	%r10d, %r10d
	movl	%r10d, %eax
	movq	%r12, %rdi
	movq	%rbx, %rsi
	movl	%ebp, %edx
	movl	%r14d, %ecx
	movl	$8, %r8d
	movl	$2, %r9d
	pushq	%rax
	.cfi_adjust_cfa_offset 8
	pushq	%rax
	.cfi_adjust_cfa_offset 8
	pushq	%rax
	.cfi_adjust_cfa_offset 8
	callq	png_set_IHDR
	addq	$32, %rsp
	.cfi_adjust_cfa_offset -32
	movq	%r12, %rdi
	movq	%rbx, %rsi
	callq	png_write_info
	movl	%ebp, %eax
	leal	(%rax,%rax,2), %eax
	movslq	%eax, %rdi
	callq	malloc
	movq	%rax, (%rsp)                    # 8-byte Spill
	testl	%r14d, %r14d
	jle	.LBB2_29
# %bb.10:                               # %.preheader.lr.ph
	movl	%r14d, %r14d
                                        # kill: def $r14 killed $r14d
	movl	%ebp, %ecx
	movl	%ecx, %r15d
	addq	$2, %rax
	movq	%rax, 8(%rsp)                   # 8-byte Spill
	xorl	%ebx, %ebx
	movl	%ebx, %r13d
	movss	.LCPI2_0(%rip), %xmm2           # xmm2 = mem[0],zero,zero,zero
	movss	.LCPI2_1(%rip), %xmm3           # xmm3 = mem[0],zero,zero,zero
	movss	.LCPI2_2(%rip), %xmm4           # xmm4 = mem[0],zero,zero,zero
	movss	.LCPI2_3(%rip), %xmm5           # xmm5 = mem[0],zero,zero,zero
.LBB2_11:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB2_13 Depth 2
	testl	%ebp, %ebp
	jle	.LBB2_28
# %bb.12:                               # %.lr.ph
                                        #   in Loop: Header=BB2_11 Depth=1
	movl	%ebx, %eax
                                        # kill: def $rax killed $eax
	movq	24(%rsp), %rcx                  # 8-byte Reload
	leaq	(%rcx,%rax,4), %rax
	xorl	%ecx, %ecx
	movl	%ecx, %edx
	movq	8(%rsp), %rcx                   # 8-byte Reload
.LBB2_13:                               #   Parent Loop BB2_11 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%rax,%rdx,4), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movaps	%xmm0, %xmm1
	divss	%xmm2, %xmm1
	cvttss2si	%xmm1, %esi
	cmpl	$1, %esi
	jne	.LBB2_15
# %bb.14:                               #   in Loop: Header=BB2_13 Depth=2
	movw	$0, -2(%rcx)
	movb	$0, (%rcx)
	jmp	.LBB2_27
.LBB2_15:                               #   in Loop: Header=BB2_13 Depth=2
	ucomiss	%xmm0, %xmm3
	jbe	.LBB2_17
# %bb.16:                               #   in Loop: Header=BB2_13 Depth=2
	movw	$-9792, -2(%rcx)                # imm = 0xD9C0
	movb	$-39, (%rcx)
	jmp	.LBB2_27
.LBB2_17:                               #   in Loop: Header=BB2_13 Depth=2
	ucomiss	%xmm0, %xmm4
	jbe	.LBB2_19
# %bb.18:                               #   in Loop: Header=BB2_13 Depth=2
	movw	$-24737, -2(%rcx)               # imm = 0x9F5F
	movb	$-97, (%rcx)
	jmp	.LBB2_27
.LBB2_19:                               #   in Loop: Header=BB2_13 Depth=2
	ucomiss	%xmm0, %xmm5
	jbe	.LBB2_22
# %bb.20:                               #   in Loop: Header=BB2_13 Depth=2
	movw	$-256, -2(%rcx)
	jmp	.LBB2_21
.LBB2_22:                               #   in Loop: Header=BB2_13 Depth=2
	movss	.LCPI2_4(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	ucomiss	%xmm0, %xmm1
	jbe	.LBB2_24
# %bb.23:                               #   in Loop: Header=BB2_13 Depth=2
	movw	$255, -2(%rcx)
.LBB2_21:                               # %_ZL6setRGBPhf.exit
                                        #   in Loop: Header=BB2_13 Depth=2
	movb	$-1, (%rcx)
.LBB2_27:                               # %_ZL6setRGBPhf.exit
                                        #   in Loop: Header=BB2_13 Depth=2
	movq	%rdx, %rsi
	incq	%rsi
	addq	$3, %rcx
	movq	%rsi, %rdx
	cmpq	%rsi, %r15
	jne	.LBB2_13
	jmp	.LBB2_28
.LBB2_24:                               #   in Loop: Header=BB2_13 Depth=2
	movss	.LCPI2_5(%rip), %xmm1           # xmm1 = mem[0],zero,zero,zero
	ucomiss	%xmm0, %xmm1
	jbe	.LBB2_26
# %bb.25:                               #   in Loop: Header=BB2_13 Depth=2
	movw	$-21014, -2(%rcx)               # imm = 0xADEA
	movb	$-22, (%rcx)
	jmp	.LBB2_27
.LBB2_26:                               #   in Loop: Header=BB2_13 Depth=2
	movw	$12111, -2(%rcx)                # imm = 0x2F4F
	movb	$79, (%rcx)
	jmp	.LBB2_27
.LBB2_28:                               # %._crit_edge
                                        #   in Loop: Header=BB2_11 Depth=1
	movq	%r12, %rdi
	movq	(%rsp), %rsi                    # 8-byte Reload
	callq	png_write_row
	movss	.LCPI2_3(%rip), %xmm5           # xmm5 = mem[0],zero,zero,zero
	movss	.LCPI2_2(%rip), %xmm4           # xmm4 = mem[0],zero,zero,zero
	movss	.LCPI2_1(%rip), %xmm3           # xmm3 = mem[0],zero,zero,zero
	movss	.LCPI2_0(%rip), %xmm2           # xmm2 = mem[0],zero,zero,zero
	movq	%r13, %rax
	incq	%rax
	addl	%ebp, %ebx
	movq	%rax, %r13
	cmpq	%r14, %rax
	jne	.LBB2_11
.LBB2_29:                               # %.thread
	xorl	%ebx, %ebx
	movl	%ebx, %esi
	movq	%r12, %rdi
	callq	png_write_end
	movl	%ebx, %eax
	movq	(%rsp), %r14                    # 8-byte Reload
	movq	40(%rsp), %r15                  # 8-byte Reload
	movq	32(%rsp), %r13                  # 8-byte Reload
.LBB2_30:
	movl	%eax, %ebx
	movq	%r13, %rdi
	callq	fclose
	movq	%r12, %rdi
	movq	16(%rsp), %rsi                  # 8-byte Reload
	movl	$65535, %edx                    # imm = 0xFFFF
	movl	$-1, %ecx
	callq	png_free_data
.LBB2_31:
	testq	%r15, %r15
	je	.LBB2_33
# %bb.32:
	xorl	%eax, %eax
	movl	%eax, %esi
	leaq	48(%rsp), %rdi
	callq	png_destroy_write_struct
.LBB2_33:
	testq	%r14, %r14
	je	.LBB2_35
# %bb.34:
	movq	%r14, %rdi
	callq	free
.LBB2_35:
	movl	%ebx, %eax
.LBB2_36:
	addq	$56, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%r12
	.cfi_def_cfa_offset 40
	popq	%r13
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z10writeImagePKciiPfS0_, .Lfunc_end2-_Z10writeImagePKciiPfS0_
	.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	.LBB3_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB3_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z6kerneliiffffiPf, %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_end3:
	.size	__hip_module_ctor, .Lfunc_end3-__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	.LBB4_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
.LBB4_2:
	retq
.Lfunc_end4:
	.size	__hip_module_dtor, .Lfunc_end4-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z6kerneliiffffiPf,@object      # @_Z6kerneliiffffiPf
	.section	.rodata,"a",@progbits
	.globl	_Z6kerneliiffffiPf
	.p2align	3, 0x0
_Z6kerneliiffffiPf:
	.quad	_Z21__device_stub__kerneliiffffiPf
	.size	_Z6kerneliiffffiPf, 8

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

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"Could not open file %s for writing\n"
	.size	.L.str.4, 36

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"1.6.43"
	.size	.L.str.5, 7

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z6kerneliiffffiPf"
	.size	.L__unnamed_1, 19

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

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

	.type	.Lstr,@object                   # @str
	.section	.rodata.str1.1,"aMS",@progbits,1
.Lstr:
	.asciz	"Saving PNG"
	.size	.Lstr, 11

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"Please specify output file"
	.size	.Lstr.1, 27

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Error during png creation"
	.size	.Lstr.2, 26

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"Could not allocate info struct"
	.size	.Lstr.3, 31

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"Could not allocate write struct"
	.size	.Lstr.4, 32

	.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__kerneliiffffiPf
	.addrsig_sym longjmp
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z6kerneliiffffiPf
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z6kerneliiffffiPf      ; -- Begin function _Z6kerneliiffffiPf
	.globl	_Z6kerneliiffffiPf
	.p2align	8
	.type	_Z6kerneliiffffiPf,@function
_Z6kerneliiffffiPf:                     ; @_Z6kerneliiffffiPf
; %bb.0:
	s_clause 0x1
	s_load_b32 s2, s[0:1], 0x34
	s_load_b128 s[4:7], s[0:1], 0x10
	s_waitcnt lgkmcnt(0)
	s_and_b32 s2, s2, 0xffff
	s_cmp_lt_i32 s6, 1
	v_mad_u64_u32 v[1:2], null, s15, s2, v[0:1]
	s_delay_alu instid0(VALU_DEP_1)
	v_ashrrev_i32_e32 v2, 31, v1
	s_cbranch_scc1 .LBB0_4
; %bb.1:                                ; %.lr.ph
	s_load_b128 s[8:11], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_ashr_i32 s7, s8, 31
	v_sub_f32_e64 v7, s5, s11
	s_add_i32 s2, s8, s7
	v_cvt_f32_i32_e32 v8, s9
	s_xor_b32 s12, s2, s7
	v_sub_f32_e64 v5, s4, s10
	v_cvt_f32_u32_e32 v0, s12
	s_sub_i32 s2, 0, s12
	v_div_scale_f32 v10, null, v8, v8, v7
	v_cvt_f32_i32_e32 v6, s8
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(VALU_DEP_3)
	v_rcp_iflag_f32_e32 v0, v0
	v_xor_b32_e32 v19, s7, v2
	v_rcp_f32_e32 v11, v10
	s_delay_alu instid0(VALU_DEP_2)
	v_div_scale_f32 v9, null, v6, v6, v5
	v_div_scale_f32 v15, vcc_lo, v5, v6, v5
	s_waitcnt_depctr 0xfff
	v_mul_f32_e32 v0, 0x4f7ffffe, v0
	v_fma_f32 v14, -v10, v11, 1.0
	v_add_nc_u32_e32 v4, v1, v2
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_cvt_u32_f32_e32 v0, v0
	v_fmac_f32_e32 v11, v14, v11
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_xor_b32_e32 v4, v4, v2
	v_mul_lo_u32 v3, s2, v0
	v_div_scale_f32 v16, s2, v7, v8, v7
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_hi_u32 v3, v0, v3
	v_add_nc_u32_e32 v0, v0, v3
	v_rcp_f32_e32 v3, v9
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_3) | instid1(VALU_DEP_2)
	v_mul_hi_u32 v0, v4, v0
	s_waitcnt_depctr 0xfff
	v_fma_f32 v12, -v9, v3, 1.0
	v_mul_lo_u32 v13, v0, s12
	v_dual_fmac_f32 v3, v12, v3 :: v_dual_add_nc_u32 v12, 1, v0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_sub_nc_u32_e32 v4, v4, v13
	v_mul_f32_e32 v13, v15, v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_subrev_nc_u32_e32 v17, s12, v4
	v_cmp_le_u32_e64 s3, s12, v4
	v_cndmask_b32_e64 v0, v0, v12, s3
	v_mul_f32_e32 v14, v16, v11
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_1) | instid1(VALU_DEP_4)
	v_cndmask_b32_e64 v4, v4, v17, s3
	v_fma_f32 v12, -v9, v13, v15
	v_add_nc_u32_e32 v17, 1, v0
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_4)
	v_fma_f32 v18, -v10, v14, v16
	v_cmp_le_u32_e64 s3, s12, v4
	s_delay_alu instid0(VALU_DEP_4) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_fmac_f32_e32 v13, v12, v3
	v_fmac_f32_e32 v14, v18, v11
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_cndmask_b32_e64 v0, v0, v17, s3
	v_fma_f32 v4, -v9, v13, v15
	s_mov_b32 s3, 0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_fma_f32 v9, -v10, v14, v16
	v_xor_b32_e32 v0, v0, v19
	s_delay_alu instid0(VALU_DEP_3)
	v_div_fmas_f32 v10, v4, v3, v13
	s_mov_b32 vcc_lo, s2
	s_mov_b32 s2, 0
	v_div_fmas_f32 v3, v9, v11, v14
	v_sub_nc_u32_e32 v0, v0, v19
	v_div_fixup_f32 v5, v10, v6, v5
	v_mov_b32_e32 v6, 0
	s_delay_alu instid0(VALU_DEP_4) | instskip(SKIP_4) | instid1(VALU_DEP_3)
	v_div_fixup_f32 v3, v3, v8, v7
	v_mov_b32_e32 v7, 0
	v_cvt_f32_i32_e32 v4, v0
	v_mul_lo_u32 v0, v0, s8
	v_mov_b32_e32 v8, 0
	v_fma_f32 v3, -v3, v4, s5
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_2)
	v_sub_nc_u32_e32 v0, v1, v0
	v_cvt_f64_f32_e32 v[3:4], v3
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_f32_i32_e32 v0, v0
	v_fma_f32 v0, v5, v0, s10
	v_mov_b32_e32 v5, 0
.LBB0_2:                                ; =>This Inner Loop Header: Depth=1
	v_cvt_f64_f32_e32 v[8:9], v8
	v_cvt_f64_f32_e32 v[10:11], v6
	s_delay_alu instid0(VALU_DEP_3) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
	v_sub_f32_e32 v5, v7, v5
	s_add_i32 s3, s3, 1
	s_cmp_ge_i32 s3, s6
	s_cselect_b32 s4, -1, 0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_add_f64 v[8:9], v[8:9], v[8:9]
	v_fma_f64 v[8:9], v[8:9], v[10:11], v[3:4]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_cvt_f32_f64_e32 v6, v[8:9]
	v_dual_add_f32 v8, v0, v5 :: v_dual_mov_b32 v9, s3
	v_mul_f32_e32 v5, v6, v6
	s_delay_alu instid0(VALU_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_fma_f32 v7, v8, v8, v5
	v_cmp_nge_f32_e32 vcc_lo, 4.0, v7
	v_mul_f32_e32 v7, v8, v8
	s_or_b32 s4, vcc_lo, s4
	s_delay_alu instid0(SALU_CYCLE_1) | instskip(NEXT) | instid1(SALU_CYCLE_1)
	s_and_b32 s4, exec_lo, s4
	s_or_b32 s2, s4, s2
	s_delay_alu instid0(SALU_CYCLE_1)
	s_and_not1_b32 exec_lo, exec_lo, s2
	s_cbranch_execnz .LBB0_2
; %bb.3:                                ; %._crit_edge.loopexit
	s_or_b32 exec_lo, exec_lo, s2
	v_cvt_f32_i32_e32 v0, v9
	s_branch .LBB0_5
.LBB0_4:
	v_mov_b32_e32 v0, 0
.LBB0_5:                                ; %._crit_edge
	s_load_b64 s[0:1], s[0:1], 0x20
	s_delay_alu instid0(VALU_DEP_2) | instskip(SKIP_1) | instid1(VALU_DEP_1)
	v_lshlrev_b64 v[1:2], 2, v[1:2]
	s_waitcnt lgkmcnt(0)
	v_add_co_u32 v1, vcc_lo, s0, v1
	s_delay_alu instid0(VALU_DEP_2)
	v_add_co_ci_u32_e32 v2, vcc_lo, s1, v2, vcc_lo
	global_store_b32 v[1:2], v0, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z6kerneliiffffiPf
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 296
		.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 20
		.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	_Z6kerneliiffffiPf, .Lfunc_end0-_Z6kerneliiffffiPf
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 720
; NumSgprs: 18
; NumVgprs: 20
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 2
; VGPRBlocks: 2
; NumSGPRsForWavesPerEU: 18
; NumVGPRsForWavesPerEU: 20
; 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:
      - .offset:         0
        .size:           4
        .value_kind:     by_value
      - .offset:         4
        .size:           4
        .value_kind:     by_value
      - .offset:         8
        .size:           4
        .value_kind:     by_value
      - .offset:         12
        .size:           4
        .value_kind:     by_value
      - .offset:         16
        .size:           4
        .value_kind:     by_value
      - .offset:         20
        .size:           4
        .value_kind:     by_value
      - .offset:         24
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         32
        .size:           8
        .value_kind:     global_buffer
      - .offset:         40
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         44
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         48
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         52
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         54
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         56
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         58
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         60
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         62
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         80
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         88
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         96
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         104
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 296
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z6kerneliiffffiPf
    .private_segment_fixed_size: 0
    .sgpr_count:     18
    .sgpr_spill_count: 0
    .symbol:         _Z6kerneliiffffiPf.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     20
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
