//Compilar com: nvcc -gencode arch=compute_50,code=[sm_50,compute_50] mandelbrot_cuda.cu -o mandelbrot -Wno-deprecated-gpu-targets

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>

struct timer_info {
    clock_t c_start;
    clock_t c_end;
    struct timespec t_start;
    struct timespec t_end;
    struct timeval v_start;
    struct timeval v_end;
};

struct timer_info timer;


double c_x_min;
double c_x_max;
double c_y_min;
double c_y_max;

double pixel_width;
double pixel_height;

int iteration_max = 200;

int image_size;
unsigned char *image_buffer_red;
unsigned char *image_buffer_green;
unsigned char *image_buffer_blue;
unsigned char *dev_image_buffer_red;
unsigned char *dev_image_buffer_blue;
unsigned char *dev_image_buffer_green;

unsigned char **pixels;

int block_dim_x;
int block_dim_y;

int i_x_max;
int i_y_max;
int image_buffer_size;

int gradient_size = 16;
int color_red[17]   = {66, 25, 9, 4, 0, 12, 24, 57, 134, 211, 241, 248, 255, 204, 153, 106, 16};
int color_green[17] = {30, 7, 1, 4, 7, 44, 82, 125, 181, 236, 233, 201, 170, 128, 87, 52, 16};
int color_blue[17]  = {15, 26, 47, 73, 100, 138, 177, 209, 229, 248, 191, 95, 0, 0, 0, 3, 16};
int *dev_color_red;
int *dev_color_green;
int *dev_color_blue;

void allocate_image_buffer()
{
	//int rgb_size = 3;
    image_buffer_red = (unsigned char *)malloc(sizeof(unsigned char) * image_buffer_size);
    cudaMalloc((void**)&dev_image_buffer_red, image_buffer_size * sizeof(unsigned char));

    image_buffer_green = (unsigned char *)malloc(sizeof(unsigned char) * image_buffer_size);
    cudaMalloc((void**)&dev_image_buffer_green, image_buffer_size * sizeof(unsigned char));

    image_buffer_blue = (unsigned char *)malloc(sizeof(unsigned char) * image_buffer_size);
    cudaMalloc((void**)&dev_image_buffer_blue, image_buffer_size * sizeof(unsigned char));
};

void init(int argc, char *argv[])
{
    if (argc < 8)
    {
        printf("usage: ./mandelbrot_seq c_x_min c_x_max c_y_min c_y_max image_size dimX dimY\n");
        printf("examples with image_size = 11500:\n");
        printf("    Full Picture:         ./mandelbrot_seq -2.5 1.5 -2.0 2.0 4096 8 64\n");
        printf("    Seahorse Valley:      ./mandelbrot_seq -0.8 -0.7 0.05 0.15 4096 32 32\n");
        printf("    Elephant Valley:      ./mandelbrot_seq 0.175 0.375 -0.1 0.1 4096 16 64\n");
        printf("    Triple Spiral Valley: ./mandelbrot_seq -0.188 -0.012 0.554 0.754 4096 1 32\n");
        exit(0);
    }
    else
    {
        sscanf(argv[1], "%lf", &c_x_min);
        sscanf(argv[2], "%lf", &c_x_max);
        sscanf(argv[3], "%lf", &c_y_min);
        sscanf(argv[4], "%lf", &c_y_max);
        sscanf(argv[5], "%d", &image_size);
        sscanf(argv[6], "%d", &block_dim_x);
        sscanf(argv[7], "%d", &block_dim_y);

        i_x_max = image_size;
        i_y_max = image_size;
        image_buffer_size = image_size * image_size;

        pixel_width = (c_x_max - c_x_min) / i_x_max;
        pixel_height = (c_y_max - c_y_min) / i_y_max;
    };
};

void init_colors(){

    int color_size = 17 * sizeof(int);
    cudaMalloc((void**)&dev_color_red, color_size);
    cudaMalloc((void**)&dev_color_green, color_size);
    cudaMalloc((void**)&dev_color_blue, color_size);

    cudaMemcpy(dev_color_red, color_red, color_size, cudaMemcpyHostToDevice);
    cudaMemcpy(dev_color_green, color_green, color_size, cudaMemcpyHostToDevice);
    cudaMemcpy(dev_color_blue, color_blue, color_size, cudaMemcpyHostToDevice);
}

void allocate_pixels(){
    int rgb_size = 3;
    pixels = (unsigned char **) malloc(sizeof(unsigned char *) * image_buffer_size);

    for(int i = 0; i < image_buffer_size; i++){
        pixels[i] = (unsigned char *) malloc(sizeof(unsigned char) * rgb_size);
    };
}

void set_pixels(){
    for(int i = 0; i < image_buffer_size; i++){
        pixels[i][0] = image_buffer_red[i];
        pixels[i][1] = image_buffer_green[i];
        pixels[i][2] = image_buffer_blue[i];
    }
}

void write_to_file()
{
    FILE *file;
    const char *filename = "output.ppm";
    const char *comment = "# ";

    int max_color_component_value = 255;

    file = fopen(filename, "wb");

    fprintf(file, "P6\n %s\n %d\n %d\n %d\n", comment,
            i_x_max, i_y_max, max_color_component_value);


    for(int i = 0; i < image_buffer_size; i++){
        fwrite(pixels[i], 1 , 3, file);
    };

    fclose(file);
};

__device__ void update_rgb_buffer(int iteration, int x, int y, int image_size, 
                                  unsigned char *image_buffer_red, unsigned char *image_buffer_green, unsigned char *image_buffer_blue,
                                  int *color_red, int *color_green, int *color_blue)
{

    int gradient_size = 16;
    int iteration_max = 200;
    int color;

    if (iteration == iteration_max)
    {
        image_buffer_red[(image_size * y) + x] = color_red[gradient_size];
        image_buffer_green[(image_size * y) + x] = color_green[gradient_size];
        image_buffer_blue[(image_size * y) + x] = color_blue[gradient_size];
    }

    else
    {
        color = iteration % gradient_size;

        image_buffer_red[(image_size * y) + x] = color_red[color];
        image_buffer_green[(image_size * y) + x] = color_green[color];
        image_buffer_blue[(image_size * y) + x] = color_blue[color];
    };
};


__device__ int mandelbrot(double c_x, double c_y) {
    double z_x = 0;
    double z_y = 0;
    double z_x_squared = 0;
    double z_y_squared = 0;
    double escape_radius_squared = 4;
    int iteration_max = 200;

    int iteration;

    for (iteration = 0;
         iteration < iteration_max &&
         ((z_x_squared + z_y_squared) < escape_radius_squared);
         iteration++) {
                z_y = 2 * z_x * z_y + c_y;
                z_x = z_x_squared - z_y_squared + c_x;

                z_x_squared = z_x * z_x;
                z_y_squared = z_y * z_y;
    };

    return iteration;
}



__global__ void compute_mandelbrot(unsigned char *image_buffer_red, unsigned char *image_buffer_green, unsigned char *image_buffer_blue, 
                                    double c_x_min, double c_y_min, double pixel_width, double pixel_height, int image_size,
                                    int *color_red, int *color_green, int *color_blue){

    int i_x;
    int i_y;
    int iteration;


    i_x = blockIdx.x*blockDim.x+threadIdx.x;
    i_y = blockIdx.y*blockDim.y+threadIdx.y;


    double c_y = c_y_min + i_y * pixel_height;

    if(fabs(c_y) < pixel_height / 2){
                c_y = 0.0;
    };

    double c_x = c_x_min + i_x * pixel_width;

    iteration = mandelbrot(c_x, c_y);
    update_rgb_buffer(iteration, i_x, i_y, image_size, image_buffer_red, image_buffer_green, image_buffer_blue, color_red, color_green, color_blue);
}

int main(int argc, char *argv[])
{
    init(argc, argv);

    allocate_image_buffer();

    init_colors();

    int time;


    dim3 dimBlock(block_dim_x, block_dim_y);
	dim3 dimGrid((int)ceil(image_size/dimBlock.x),(int)ceil(image_size/dimBlock.y));

	//MEDICAO DE TEMPO
	timer.c_start = clock();
    clock_gettime(CLOCK_MONOTONIC, &timer.t_start);
    gettimeofday(&timer.v_start, NULL);

    compute_mandelbrot <<<dimGrid, dimBlock>>>(dev_image_buffer_red, dev_image_buffer_green, dev_image_buffer_blue, 
                                                    c_x_min, c_y_min, pixel_width, pixel_height, image_size,
                                                    dev_color_red, dev_color_green, dev_color_blue);

    cudaMemcpy(image_buffer_red, dev_image_buffer_red, sizeof(unsigned char) * image_buffer_size, cudaMemcpyDeviceToHost);
    cudaMemcpy(image_buffer_green, dev_image_buffer_green, sizeof(unsigned char) * image_buffer_size, cudaMemcpyDeviceToHost);
    cudaMemcpy(image_buffer_blue, dev_image_buffer_blue, sizeof(unsigned char) * image_buffer_size, cudaMemcpyDeviceToHost);

    timer.c_end = clock();
    clock_gettime(CLOCK_MONOTONIC, &timer.t_end);
    gettimeofday(&timer.v_end, NULL);
    //FIM DA MEDICAO

    cudaFree(dev_color_red);
    cudaFree(dev_color_green);
    cudaFree(dev_color_blue);

    allocate_pixels();
    set_pixels();

    cudaFree(dev_image_buffer_red);
    cudaFree(dev_image_buffer_green);
    cudaFree(dev_image_buffer_blue);

    write_to_file();

    printf("%f\n",
    (double) (timer.t_end.tv_sec - timer.t_start.tv_sec) +
    (double) (timer.t_end.tv_nsec - timer.t_start.tv_nsec) / 1000000000.0);

    time = (double) (timer.t_end.tv_sec - timer.t_start.tv_sec) +
    (double) (timer.t_end.tv_nsec - timer.t_start.tv_nsec) / 1000000000.0;

    return time;
};

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

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2038:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2038:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	_Z21allocate_image_bufferv
	.type	_Z21allocate_image_bufferv, @function
_Z21allocate_image_bufferv:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movslq	image_buffer_size(%rip), %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rsi
	leaq	dev_image_buffer_red(%rip), %rdi
	movq	%rax, image_buffer_red(%rip)
	call	cudaMalloc@PLT
	movslq	image_buffer_size(%rip), %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rsi
	leaq	dev_image_buffer_green(%rip), %rdi
	movq	%rax, image_buffer_green(%rip)
	call	cudaMalloc@PLT
	movslq	image_buffer_size(%rip), %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rsi
	leaq	dev_image_buffer_blue(%rip), %rdi
	popq	%rbx
	.cfi_def_cfa_offset 8
	movq	%rax, image_buffer_blue(%rip)
	jmp	cudaMalloc@PLT
	.cfi_endproc
.LFE2027:
	.size	_Z21allocate_image_bufferv, .-_Z21allocate_image_bufferv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"usage: ./mandelbrot_seq c_x_min c_x_max c_y_min c_y_max image_size dimX dimY\n"
.LC1:
	.string	"examples with image_size = 11500:\n"
.LC2:
	.string	"    Full Picture:         ./mandelbrot_seq -2.5 1.5 -2.0 2.0 4096 8 64\n"
.LC3:
	.string	"    Seahorse Valley:      ./mandelbrot_seq -0.8 -0.7 0.05 0.15 4096 32 32\n"
.LC4:
	.string	"    Elephant Valley:      ./mandelbrot_seq 0.175 0.375 -0.1 0.1 4096 16 64\n"
.LC5:
	.string	"    Triple Spiral Valley: ./mandelbrot_seq -0.188 -0.012 0.554 0.754 4096 1 32\n"
.LC6:
	.string	"%lf"
.LC7:
	.string	"%d"
	.text
	.globl	_Z4initiPPc
	.type	_Z4initiPPc, @function
_Z4initiPPc:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	pushq	%rdx
	.cfi_def_cfa_offset 32
	cmpl	$7, %edi
	jg	.L5
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	.LC4(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$2, %edi
	leaq	.LC5(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%edi, %edi
	call	exit@PLT
.L5:
	leaq	.LC6(%rip), %rbp
	movq	8(%rsi), %rdi
	movq	%rsi, %rbx
	xorl	%eax, %eax
	movq	%rbp, %rsi
	leaq	c_x_min(%rip), %rdx
	call	__isoc23_sscanf@PLT
	movq	16(%rbx), %rdi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	leaq	c_x_max(%rip), %rdx
	call	__isoc23_sscanf@PLT
	movq	24(%rbx), %rdi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	leaq	c_y_min(%rip), %rdx
	call	__isoc23_sscanf@PLT
	movq	32(%rbx), %rdi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	leaq	c_y_max(%rip), %rdx
	leaq	.LC7(%rip), %rbp
	call	__isoc23_sscanf@PLT
	movq	40(%rbx), %rdi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	leaq	image_size(%rip), %rdx
	call	__isoc23_sscanf@PLT
	movq	48(%rbx), %rdi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	leaq	block_dim_x(%rip), %rdx
	call	__isoc23_sscanf@PLT
	movq	56(%rbx), %rdi
	movq	%rbp, %rsi
	xorl	%eax, %eax
	leaq	block_dim_y(%rip), %rdx
	call	__isoc23_sscanf@PLT
	movl	image_size(%rip), %eax
	movsd	c_x_max(%rip), %xmm0
	subsd	c_x_min(%rip), %xmm0
	cvtsi2sdl	%eax, %xmm1
	movl	%eax, %edx
	movl	%eax, i_x_max(%rip)
	imull	%eax, %edx
	movl	%eax, i_y_max(%rip)
	divsd	%xmm1, %xmm0
	movl	%edx, image_buffer_size(%rip)
	movsd	%xmm0, pixel_width(%rip)
	movsd	c_y_max(%rip), %xmm0
	subsd	c_y_min(%rip), %xmm0
	divsd	%xmm1, %xmm0
	movsd	%xmm0, pixel_height(%rip)
	popq	%rax
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z4initiPPc, .-_Z4initiPPc
	.globl	_Z11init_colorsv
	.type	_Z11init_colorsv, @function
_Z11init_colorsv:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	$68, %esi
	leaq	dev_color_red(%rip), %rdi
	call	cudaMalloc@PLT
	movl	$68, %esi
	leaq	dev_color_green(%rip), %rdi
	call	cudaMalloc@PLT
	movl	$68, %esi
	leaq	dev_color_blue(%rip), %rdi
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movq	dev_color_red(%rip), %rdi
	movl	$68, %edx
	leaq	color_red(%rip), %rsi
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movq	dev_color_green(%rip), %rdi
	movl	$68, %edx
	leaq	color_green(%rip), %rsi
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movq	dev_color_blue(%rip), %rdi
	popq	%r8
	.cfi_def_cfa_offset 8
	movl	$68, %edx
	leaq	color_blue(%rip), %rsi
	jmp	cudaMemcpy@PLT
	.cfi_endproc
.LFE2029:
	.size	_Z11init_colorsv, .-_Z11init_colorsv
	.globl	_Z15allocate_pixelsv
	.type	_Z15allocate_pixelsv, @function
_Z15allocate_pixelsv:
.LFB2030:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movslq	image_buffer_size(%rip), %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rdi, %r12
	salq	$3, %rdi
	xorl	%ebx, %ebx
	call	malloc@PLT
	movq	%rax, pixels(%rip)
	movq	%rax, %rbp
.L11:
	cmpl	%ebx, %r12d
	jle	.L14
	movl	$3, %edi
	call	malloc@PLT
	movq	%rax, 0(%rbp,%rbx,8)
	incq	%rbx
	jmp	.L11
.L14:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2030:
	.size	_Z15allocate_pixelsv, .-_Z15allocate_pixelsv
	.globl	_Z10set_pixelsv
	.type	_Z10set_pixelsv, @function
_Z10set_pixelsv:
.LFB2031:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
.L16:
	cmpl	%eax, image_buffer_size(%rip)
	jle	.L18
	movq	pixels(%rip), %rdx
	movq	image_buffer_red(%rip), %rcx
	movq	(%rdx,%rax,8), %rdx
	movb	(%rcx,%rax), %cl
	movb	%cl, (%rdx)
	movq	pixels(%rip), %rdx
	movq	image_buffer_green(%rip), %rcx
	movq	(%rdx,%rax,8), %rdx
	movb	(%rcx,%rax), %cl
	movb	%cl, 1(%rdx)
	movq	pixels(%rip), %rdx
	movq	image_buffer_blue(%rip), %rcx
	movq	(%rdx,%rax,8), %rdx
	movb	(%rcx,%rax), %cl
	incq	%rax
	movb	%cl, 2(%rdx)
	jmp	.L16
.L18:
	ret
	.cfi_endproc
.LFE2031:
	.size	_Z10set_pixelsv, .-_Z10set_pixelsv
	.section	.rodata.str1.1
.LC8:
	.string	"wb"
.LC9:
	.string	"output.ppm"
.LC10:
	.string	"# "
.LC11:
	.string	"P6\n %s\n %d\n %d\n %d\n"
	.text
	.globl	_Z13write_to_filev
	.type	_Z13write_to_filev, @function
_Z13write_to_filev:
.LFB2032:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC8(%rip), %rsi
	leaq	.LC9(%rip), %rdi
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	pushq	%rdx
	.cfi_def_cfa_offset 32
	call	fopen@PLT
	movl	i_y_max(%rip), %r9d
	movl	i_x_max(%rip), %r8d
	movl	$2, %esi
	pushq	%rcx
	.cfi_def_cfa_offset 40
	movq	%rax, %rdi
	movq	%rax, %rbx
	leaq	.LC10(%rip), %rcx
	pushq	$255
	.cfi_def_cfa_offset 48
	leaq	.LC11(%rip), %rdx
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	popq	%rsi
	.cfi_def_cfa_offset 40
	popq	%rdi
	.cfi_def_cfa_offset 32
.L20:
	cmpl	%ebp, image_buffer_size(%rip)
	jle	.L23
	movq	pixels(%rip), %rax
	movq	%rbx, %rcx
	movl	$3, %edx
	movl	$1, %esi
	movq	(%rax,%rbp,8), %rdi
	incq	%rbp
	call	fwrite@PLT
	jmp	.L20
.L23:
	popq	%rax
	.cfi_def_cfa_offset 24
	movq	%rbx, %rdi
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	fclose@PLT
	.cfi_endproc
.LFE2032:
	.size	_Z13write_to_filev, .-_Z13write_to_filev
	.globl	_Z17update_rgb_bufferiiiiPhS_S_PiS0_S0_
	.type	_Z17update_rgb_bufferiiiiPhS_S_PiS0_S0_, @function
_Z17update_rgb_bufferiiiiPhS_S_PiS0_S0_:
.LFB2033:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2033:
	.size	_Z17update_rgb_bufferiiiiPhS_S_PiS0_S0_, .-_Z17update_rgb_bufferiiiiPhS_S_PiS0_S0_
	.globl	_Z10mandelbrotdd
	.type	_Z10mandelbrotdd, @function
_Z10mandelbrotdd:
.LFB2034:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE2034:
	.size	_Z10mandelbrotdd, .-_Z10mandelbrotdd
	.globl	_Z55__device_stub__Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_PhS_S_ddddiPiS0_S0_
	.type	_Z55__device_stub__Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_PhS_S_ddddiPiS0_S0_, @function
_Z55__device_stub__Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_PhS_S_ddddiPiS0_S0_:
.LFB2060:
	.cfi_startproc
	endbr64
	subq	$264, %rsp
	.cfi_def_cfa_offset 272
	movq	272(%rsp), %rax
	movq	%rdi, 88(%rsp)
	leaq	112(%rsp), %rdi
	movq	%rsi, 80(%rsp)
	leaq	124(%rsp), %rsi
	movq	%rdx, 72(%rsp)
	leaq	96(%rsp), %rdx
	movl	%ecx, 36(%rsp)
	leaq	104(%rsp), %rcx
	movq	%r8, 24(%rsp)
	movq	%r9, 16(%rsp)
	movq	%rax, 8(%rsp)
	movsd	%xmm0, 64(%rsp)
	movsd	%xmm1, 56(%rsp)
	movsd	%xmm2, 48(%rsp)
	movsd	%xmm3, 40(%rsp)
	movq	%fs:40, %rax
	movq	%rax, 248(%rsp)
	xorl	%eax, %eax
	leaq	88(%rsp), %rax
	movl	$1, 120(%rsp)
	movq	%rax, 160(%rsp)
	leaq	80(%rsp), %rax
	movq	%rax, 168(%rsp)
	leaq	72(%rsp), %rax
	movq	%rax, 176(%rsp)
	leaq	64(%rsp), %rax
	movq	%rax, 184(%rsp)
	leaq	56(%rsp), %rax
	movq	%rax, 192(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 200(%rsp)
	leaq	40(%rsp), %rax
	movq	%rax, 208(%rsp)
	leaq	36(%rsp), %rax
	movq	%rax, 216(%rsp)
	leaq	24(%rsp), %rax
	movq	%rax, 224(%rsp)
	leaq	16(%rsp), %rax
	movq	%rax, 232(%rsp)
	leaq	8(%rsp), %rax
	movq	%rax, 240(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 112(%rsp)
	movq	%rax, 124(%rsp)
	movl	$1, 132(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L28
	pushq	104(%rsp)
	.cfi_def_cfa_offset 280
	leaq	_Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_(%rip), %rdi
	pushq	104(%rsp)
	.cfi_def_cfa_offset 288
	movq	140(%rsp), %rcx
	movl	148(%rsp), %r8d
	movq	128(%rsp), %rsi
	movl	136(%rsp), %edx
	leaq	176(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 280
	popq	%rdx
	.cfi_def_cfa_offset 272
.L28:
	movq	248(%rsp), %rax
	subq	%fs:40, %rax
	je	.L30
	call	__stack_chk_fail@PLT
.L30:
	addq	$264, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2060:
	.size	_Z55__device_stub__Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_PhS_S_ddddiPiS0_S0_, .-_Z55__device_stub__Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_PhS_S_ddddiPiS0_S0_
	.globl	_Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_
	.type	_Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_, @function
_Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_:
.LFB2061:
	.cfi_startproc
	endbr64
	jmp	_Z55__device_stub__Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_PhS_S_ddddiPiS0_S0_
	.cfi_endproc
.LFE2061:
	.size	_Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_, .-_Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_
	.section	.rodata.str1.1
.LC13:
	.string	"%f\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2035:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$40, %rsp
	.cfi_def_cfa_offset 64
	call	_Z4initiPPc
	call	_Z21allocate_image_bufferv
	call	_Z11init_colorsv
	movl	block_dim_x(%rip), %ebp
	xorl	%edx, %edx
	movl	image_size(%rip), %eax
	movl	block_dim_y(%rip), %ebx
	movl	$1, 16(%rsp)
	divl	%ebp
	movl	$1, 28(%rsp)
	xorl	%edx, %edx
	movl	%eax, 20(%rsp)
	movl	image_size(%rip), %eax
	divl	%ebx
	movl	%eax, 24(%rsp)
	call	clock@PLT
	leaq	16+timer(%rip), %rsi
	movl	$1, %edi
	movq	%rax, timer(%rip)
	call	clock_gettime@PLT
	xorl	%esi, %esi
	leaq	48+timer(%rip), %rdi
	call	gettimeofday@PLT
	movl	%ebp, 8(%rsp)
	movl	16(%rsp), %ecx
	xorl	%r9d, %r9d
	movq	20(%rsp), %rdi
	movl	28(%rsp), %esi
	movl	%ebx, 12(%rsp)
	xorl	%r8d, %r8d
	movq	8(%rsp), %rdx
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L34
	movl	image_size(%rip), %ecx
	movq	dev_image_buffer_blue(%rip), %rdx
	pushq	%rax
	.cfi_def_cfa_offset 72
	pushq	dev_color_blue(%rip)
	.cfi_def_cfa_offset 80
	movq	dev_color_green(%rip), %r9
	movq	dev_color_red(%rip), %r8
	movsd	pixel_height(%rip), %xmm3
	movsd	pixel_width(%rip), %xmm2
	movsd	c_y_min(%rip), %xmm1
	movsd	c_x_min(%rip), %xmm0
	movq	dev_image_buffer_green(%rip), %rsi
	movq	dev_image_buffer_red(%rip), %rdi
	call	_Z55__device_stub__Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_PhS_S_ddddiPiS0_S0_
	popq	%rdx
	.cfi_def_cfa_offset 72
	popq	%rcx
	.cfi_def_cfa_offset 64
.L34:
	movslq	image_buffer_size(%rip), %rdx
	movq	dev_image_buffer_red(%rip), %rsi
	movl	$2, %ecx
	movq	image_buffer_red(%rip), %rdi
	call	cudaMemcpy@PLT
	movslq	image_buffer_size(%rip), %rdx
	movl	$2, %ecx
	movq	dev_image_buffer_green(%rip), %rsi
	movq	image_buffer_green(%rip), %rdi
	call	cudaMemcpy@PLT
	movslq	image_buffer_size(%rip), %rdx
	movl	$2, %ecx
	movq	dev_image_buffer_blue(%rip), %rsi
	movq	image_buffer_blue(%rip), %rdi
	call	cudaMemcpy@PLT
	call	clock@PLT
	leaq	32+timer(%rip), %rsi
	movl	$1, %edi
	movq	%rax, 8+timer(%rip)
	call	clock_gettime@PLT
	xorl	%esi, %esi
	leaq	64+timer(%rip), %rdi
	call	gettimeofday@PLT
	movq	dev_color_red(%rip), %rdi
	call	cudaFree@PLT
	movq	dev_color_green(%rip), %rdi
	call	cudaFree@PLT
	movq	dev_color_blue(%rip), %rdi
	call	cudaFree@PLT
	call	_Z15allocate_pixelsv
	call	_Z10set_pixelsv
	movq	dev_image_buffer_red(%rip), %rdi
	call	cudaFree@PLT
	movq	dev_image_buffer_green(%rip), %rdi
	call	cudaFree@PLT
	movq	dev_image_buffer_blue(%rip), %rdi
	call	cudaFree@PLT
	call	_Z13write_to_filev
	movq	40+timer(%rip), %rax
	movl	$2, %edi
	subq	24+timer(%rip), %rax
	cvtsi2sdq	%rax, %xmm0
	movq	32+timer(%rip), %rax
	subq	16+timer(%rip), %rax
	divsd	.LC12(%rip), %xmm0
	cvtsi2sdq	%rax, %xmm1
	leaq	.LC13(%rip), %rsi
	movb	$1, %al
	addsd	%xmm1, %xmm0
	call	__printf_chk@PLT
	movq	40+timer(%rip), %rax
	subq	24+timer(%rip), %rax
	cvtsi2sdq	%rax, %xmm0
	movq	32+timer(%rip), %rax
	subq	16+timer(%rip), %rax
	divsd	.LC12(%rip), %xmm0
	cvtsi2sdq	%rax, %xmm1
	addq	$40, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	addsd	%xmm1, %xmm0
	cvttsd2sil	%xmm0, %eax
	ret
	.cfi_endproc
.LFE2035:
	.size	main, .-main
	.section	.rodata.str1.1
.LC14:
	.string	"_Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_"
	.section	.text.startup
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2063:
	.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	.LC14(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_(%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
.LFE2063:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.globl	dev_color_blue
	.bss
	.align 8
	.type	dev_color_blue, @object
	.size	dev_color_blue, 8
dev_color_blue:
	.zero	8
	.globl	dev_color_green
	.align 8
	.type	dev_color_green, @object
	.size	dev_color_green, 8
dev_color_green:
	.zero	8
	.globl	dev_color_red
	.align 8
	.type	dev_color_red, @object
	.size	dev_color_red, 8
dev_color_red:
	.zero	8
	.globl	color_blue
	.data
	.align 32
	.type	color_blue, @object
	.size	color_blue, 68
color_blue:
	.long	15
	.long	26
	.long	47
	.long	73
	.long	100
	.long	138
	.long	177
	.long	209
	.long	229
	.long	248
	.long	191
	.long	95
	.long	0
	.long	0
	.long	0
	.long	3
	.long	16
	.globl	color_green
	.align 32
	.type	color_green, @object
	.size	color_green, 68
color_green:
	.long	30
	.long	7
	.long	1
	.long	4
	.long	7
	.long	44
	.long	82
	.long	125
	.long	181
	.long	236
	.long	233
	.long	201
	.long	170
	.long	128
	.long	87
	.long	52
	.long	16
	.globl	color_red
	.align 32
	.type	color_red, @object
	.size	color_red, 68
color_red:
	.long	66
	.long	25
	.long	9
	.long	4
	.long	0
	.long	12
	.long	24
	.long	57
	.long	134
	.long	211
	.long	241
	.long	248
	.long	255
	.long	204
	.long	153
	.long	106
	.long	16
	.globl	gradient_size
	.align 4
	.type	gradient_size, @object
	.size	gradient_size, 4
gradient_size:
	.long	16
	.globl	image_buffer_size
	.bss
	.align 4
	.type	image_buffer_size, @object
	.size	image_buffer_size, 4
image_buffer_size:
	.zero	4
	.globl	i_y_max
	.align 4
	.type	i_y_max, @object
	.size	i_y_max, 4
i_y_max:
	.zero	4
	.globl	i_x_max
	.align 4
	.type	i_x_max, @object
	.size	i_x_max, 4
i_x_max:
	.zero	4
	.globl	block_dim_y
	.align 4
	.type	block_dim_y, @object
	.size	block_dim_y, 4
block_dim_y:
	.zero	4
	.globl	block_dim_x
	.align 4
	.type	block_dim_x, @object
	.size	block_dim_x, 4
block_dim_x:
	.zero	4
	.globl	pixels
	.align 8
	.type	pixels, @object
	.size	pixels, 8
pixels:
	.zero	8
	.globl	dev_image_buffer_green
	.align 8
	.type	dev_image_buffer_green, @object
	.size	dev_image_buffer_green, 8
dev_image_buffer_green:
	.zero	8
	.globl	dev_image_buffer_blue
	.align 8
	.type	dev_image_buffer_blue, @object
	.size	dev_image_buffer_blue, 8
dev_image_buffer_blue:
	.zero	8
	.globl	dev_image_buffer_red
	.align 8
	.type	dev_image_buffer_red, @object
	.size	dev_image_buffer_red, 8
dev_image_buffer_red:
	.zero	8
	.globl	image_buffer_blue
	.align 8
	.type	image_buffer_blue, @object
	.size	image_buffer_blue, 8
image_buffer_blue:
	.zero	8
	.globl	image_buffer_green
	.align 8
	.type	image_buffer_green, @object
	.size	image_buffer_green, 8
image_buffer_green:
	.zero	8
	.globl	image_buffer_red
	.align 8
	.type	image_buffer_red, @object
	.size	image_buffer_red, 8
image_buffer_red:
	.zero	8
	.globl	image_size
	.align 4
	.type	image_size, @object
	.size	image_size, 4
image_size:
	.zero	4
	.globl	iteration_max
	.data
	.align 4
	.type	iteration_max, @object
	.size	iteration_max, 4
iteration_max:
	.long	200
	.globl	pixel_height
	.bss
	.align 8
	.type	pixel_height, @object
	.size	pixel_height, 8
pixel_height:
	.zero	8
	.globl	pixel_width
	.align 8
	.type	pixel_width, @object
	.size	pixel_width, 8
pixel_width:
	.zero	8
	.globl	c_y_max
	.align 8
	.type	c_y_max, @object
	.size	c_y_max, 8
c_y_max:
	.zero	8
	.globl	c_y_min
	.align 8
	.type	c_y_min, @object
	.size	c_y_min, 8
c_y_min:
	.zero	8
	.globl	c_x_max
	.align 8
	.type	c_x_max, @object
	.size	c_x_max, 8
c_x_max:
	.zero	8
	.globl	c_x_min
	.align 8
	.type	c_x_min, @object
	.size	c_x_min, 8
c_x_min:
	.zero	8
	.globl	timer
	.align 32
	.type	timer, @object
	.size	timer, 80
timer:
	.zero	80
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC12:
	.long	0
	.long	1104006501
	.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:

//Compilar com: nvcc -gencode arch=compute_50,code=[sm_50,compute_50] mandelbrot_cuda.cu -o mandelbrot -Wno-deprecated-gpu-targets


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

struct timer_info {
    clock_t c_start;
    clock_t c_end;
    struct timespec t_start;
    struct timespec t_end;
    struct timeval v_start;
    struct timeval v_end;
};

struct timer_info timer;


double c_x_min;
double c_x_max;
double c_y_min;
double c_y_max;

double pixel_width;
double pixel_height;

int iteration_max = 200;

int image_size;
unsigned char *image_buffer_red;
unsigned char *image_buffer_green;
unsigned char *image_buffer_blue;
unsigned char *dev_image_buffer_red;
unsigned char *dev_image_buffer_blue;
unsigned char *dev_image_buffer_green;

unsigned char **pixels;

int block_dim_x;
int block_dim_y;

int i_x_max;
int i_y_max;
int image_buffer_size;

int gradient_size = 16;
int color_red[17]   = {66, 25, 9, 4, 0, 12, 24, 57, 134, 211, 241, 248, 255, 204, 153, 106, 16};
int color_green[17] = {30, 7, 1, 4, 7, 44, 82, 125, 181, 236, 233, 201, 170, 128, 87, 52, 16};
int color_blue[17]  = {15, 26, 47, 73, 100, 138, 177, 209, 229, 248, 191, 95, 0, 0, 0, 3, 16};
int *dev_color_red;
int *dev_color_green;
int *dev_color_blue;

void allocate_image_buffer()
{
	//int rgb_size = 3;
    image_buffer_red = (unsigned char *)malloc(sizeof(unsigned char) * image_buffer_size);
    hipMalloc((void**)&dev_image_buffer_red, image_buffer_size * sizeof(unsigned char));

    image_buffer_green = (unsigned char *)malloc(sizeof(unsigned char) * image_buffer_size);
    hipMalloc((void**)&dev_image_buffer_green, image_buffer_size * sizeof(unsigned char));

    image_buffer_blue = (unsigned char *)malloc(sizeof(unsigned char) * image_buffer_size);
    hipMalloc((void**)&dev_image_buffer_blue, image_buffer_size * sizeof(unsigned char));
};

void init(int argc, char *argv[])
{
    if (argc < 8)
    {
        printf("usage: ./mandelbrot_seq c_x_min c_x_max c_y_min c_y_max image_size dimX dimY\n");
        printf("examples with image_size = 11500:\n");
        printf("    Full Picture:         ./mandelbrot_seq -2.5 1.5 -2.0 2.0 4096 8 64\n");
        printf("    Seahorse Valley:      ./mandelbrot_seq -0.8 -0.7 0.05 0.15 4096 32 32\n");
        printf("    Elephant Valley:      ./mandelbrot_seq 0.175 0.375 -0.1 0.1 4096 16 64\n");
        printf("    Triple Spiral Valley: ./mandelbrot_seq -0.188 -0.012 0.554 0.754 4096 1 32\n");
        exit(0);
    }
    else
    {
        sscanf(argv[1], "%lf", &c_x_min);
        sscanf(argv[2], "%lf", &c_x_max);
        sscanf(argv[3], "%lf", &c_y_min);
        sscanf(argv[4], "%lf", &c_y_max);
        sscanf(argv[5], "%d", &image_size);
        sscanf(argv[6], "%d", &block_dim_x);
        sscanf(argv[7], "%d", &block_dim_y);

        i_x_max = image_size;
        i_y_max = image_size;
        image_buffer_size = image_size * image_size;

        pixel_width = (c_x_max - c_x_min) / i_x_max;
        pixel_height = (c_y_max - c_y_min) / i_y_max;
    };
};

void init_colors(){

    int color_size = 17 * sizeof(int);
    hipMalloc((void**)&dev_color_red, color_size);
    hipMalloc((void**)&dev_color_green, color_size);
    hipMalloc((void**)&dev_color_blue, color_size);

    hipMemcpy(dev_color_red, color_red, color_size, hipMemcpyHostToDevice);
    hipMemcpy(dev_color_green, color_green, color_size, hipMemcpyHostToDevice);
    hipMemcpy(dev_color_blue, color_blue, color_size, hipMemcpyHostToDevice);
}

void allocate_pixels(){
    int rgb_size = 3;
    pixels = (unsigned char **) malloc(sizeof(unsigned char *) * image_buffer_size);

    for(int i = 0; i < image_buffer_size; i++){
        pixels[i] = (unsigned char *) malloc(sizeof(unsigned char) * rgb_size);
    };
}

void set_pixels(){
    for(int i = 0; i < image_buffer_size; i++){
        pixels[i][0] = image_buffer_red[i];
        pixels[i][1] = image_buffer_green[i];
        pixels[i][2] = image_buffer_blue[i];
    }
}

void write_to_file()
{
    FILE *file;
    const char *filename = "output.ppm";
    const char *comment = "# ";

    int max_color_component_value = 255;

    file = fopen(filename, "wb");

    fprintf(file, "P6\n %s\n %d\n %d\n %d\n", comment,
            i_x_max, i_y_max, max_color_component_value);


    for(int i = 0; i < image_buffer_size; i++){
        fwrite(pixels[i], 1 , 3, file);
    };

    fclose(file);
};

__device__ void update_rgb_buffer(int iteration, int x, int y, int image_size, 
                                  unsigned char *image_buffer_red, unsigned char *image_buffer_green, unsigned char *image_buffer_blue,
                                  int *color_red, int *color_green, int *color_blue)
{

    int gradient_size = 16;
    int iteration_max = 200;
    int color;

    if (iteration == iteration_max)
    {
        image_buffer_red[(image_size * y) + x] = color_red[gradient_size];
        image_buffer_green[(image_size * y) + x] = color_green[gradient_size];
        image_buffer_blue[(image_size * y) + x] = color_blue[gradient_size];
    }

    else
    {
        color = iteration % gradient_size;

        image_buffer_red[(image_size * y) + x] = color_red[color];
        image_buffer_green[(image_size * y) + x] = color_green[color];
        image_buffer_blue[(image_size * y) + x] = color_blue[color];
    };
};


__device__ int mandelbrot(double c_x, double c_y) {
    double z_x = 0;
    double z_y = 0;
    double z_x_squared = 0;
    double z_y_squared = 0;
    double escape_radius_squared = 4;
    int iteration_max = 200;

    int iteration;

    for (iteration = 0;
         iteration < iteration_max &&
         ((z_x_squared + z_y_squared) < escape_radius_squared);
         iteration++) {
                z_y = 2 * z_x * z_y + c_y;
                z_x = z_x_squared - z_y_squared + c_x;

                z_x_squared = z_x * z_x;
                z_y_squared = z_y * z_y;
    };

    return iteration;
}



__global__ void compute_mandelbrot(unsigned char *image_buffer_red, unsigned char *image_buffer_green, unsigned char *image_buffer_blue, 
                                    double c_x_min, double c_y_min, double pixel_width, double pixel_height, int image_size,
                                    int *color_red, int *color_green, int *color_blue){

    int i_x;
    int i_y;
    int iteration;


    i_x = blockIdx.x*blockDim.x+threadIdx.x;
    i_y = blockIdx.y*blockDim.y+threadIdx.y;


    double c_y = c_y_min + i_y * pixel_height;

    if(fabs(c_y) < pixel_height / 2){
                c_y = 0.0;
    };

    double c_x = c_x_min + i_x * pixel_width;

    iteration = mandelbrot(c_x, c_y);
    update_rgb_buffer(iteration, i_x, i_y, image_size, image_buffer_red, image_buffer_green, image_buffer_blue, color_red, color_green, color_blue);
}

int main(int argc, char *argv[])
{
    init(argc, argv);

    allocate_image_buffer();

    init_colors();

    int time;


    dim3 dimBlock(block_dim_x, block_dim_y);
	dim3 dimGrid((int)ceil(image_size/dimBlock.x),(int)ceil(image_size/dimBlock.y));

	//MEDICAO DE TEMPO
	timer.c_start = clock();
    clock_gettime(CLOCK_MONOTONIC, &timer.t_start);
    gettimeofday(&timer.v_start, NULL);

    compute_mandelbrot <<<dimGrid, dimBlock>>>(dev_image_buffer_red, dev_image_buffer_green, dev_image_buffer_blue, 
                                                    c_x_min, c_y_min, pixel_width, pixel_height, image_size,
                                                    dev_color_red, dev_color_green, dev_color_blue);

    hipMemcpy(image_buffer_red, dev_image_buffer_red, sizeof(unsigned char) * image_buffer_size, hipMemcpyDeviceToHost);
    hipMemcpy(image_buffer_green, dev_image_buffer_green, sizeof(unsigned char) * image_buffer_size, hipMemcpyDeviceToHost);
    hipMemcpy(image_buffer_blue, dev_image_buffer_blue, sizeof(unsigned char) * image_buffer_size, hipMemcpyDeviceToHost);

    timer.c_end = clock();
    clock_gettime(CLOCK_MONOTONIC, &timer.t_end);
    gettimeofday(&timer.v_end, NULL);
    //FIM DA MEDICAO

    hipFree(dev_color_red);
    hipFree(dev_color_green);
    hipFree(dev_color_blue);

    allocate_pixels();
    set_pixels();

    hipFree(dev_image_buffer_red);
    hipFree(dev_image_buffer_green);
    hipFree(dev_image_buffer_blue);

    write_to_file();

    printf("%f\n",
    (double) (timer.t_end.tv_sec - timer.t_start.tv_sec) +
    (double) (timer.t_end.tv_nsec - timer.t_start.tv_nsec) / 1000000000.0);

    time = (double) (timer.t_end.tv_sec - timer.t_start.tv_sec) +
    (double) (timer.t_end.tv_nsec - timer.t_start.tv_nsec) / 1000000000.0;

    return time;
};

	.text
	.file	"mandelbrot_cuda.hip"
	.globl	_Z21allocate_image_bufferv      # -- Begin function _Z21allocate_image_bufferv
	.type	_Z21allocate_image_bufferv,@function
_Z21allocate_image_bufferv:             # @_Z21allocate_image_bufferv
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	movslq	image_buffer_size(%rip), %rbx
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, image_buffer_red(%rip)
	movl	$dev_image_buffer_red, %edi
	movq	%rbx, %rsi
	callq	hipMalloc
	movslq	image_buffer_size(%rip), %rbx
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, image_buffer_green(%rip)
	movl	$dev_image_buffer_green, %edi
	movq	%rbx, %rsi
	callq	hipMalloc
	movslq	image_buffer_size(%rip), %rbx
	movq	%rbx, %rdi
	callq	malloc
	movq	%rax, image_buffer_blue(%rip)
	movl	$dev_image_buffer_blue, %edi
	movq	%rbx, %rsi
	popq	%rbx
	.cfi_def_cfa_offset 8
	jmp	hipMalloc                       # TAILCALL
.Lfunc_end0:
	.size	_Z21allocate_image_bufferv, .Lfunc_end0-_Z21allocate_image_bufferv
	.cfi_endproc
                                        # -- End function
	.globl	_Z4initiPPc                     # -- Begin function _Z4initiPPc
	.type	_Z4initiPPc,@function
_Z4initiPPc:                            # @_Z4initiPPc
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset %rbx, -16
	cmpl	$7, %edi
	jle	.LBB1_2
# %bb.1:
	movq	%rsi, %rbx
	movq	8(%rsi), %rdi
	movl	$.L.str.6, %esi
	movl	$c_x_min, %edx
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	movq	16(%rbx), %rdi
	movl	$.L.str.6, %esi
	movl	$c_x_max, %edx
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	movq	24(%rbx), %rdi
	movl	$.L.str.6, %esi
	movl	$c_y_min, %edx
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	movq	32(%rbx), %rdi
	movl	$.L.str.6, %esi
	movl	$c_y_max, %edx
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	movq	40(%rbx), %rdi
	movl	$.L.str.7, %esi
	movl	$image_size, %edx
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	movq	48(%rbx), %rdi
	movl	$.L.str.7, %esi
	movl	$block_dim_x, %edx
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	movq	56(%rbx), %rdi
	movl	$.L.str.7, %esi
	movl	$block_dim_y, %edx
	xorl	%eax, %eax
	callq	__isoc23_sscanf
	movl	image_size(%rip), %eax
	movl	%eax, i_x_max(%rip)
	movl	%eax, i_y_max(%rip)
	cvtsi2sd	%eax, %xmm0
	imull	%eax, %eax
	movsd	c_x_max(%rip), %xmm1            # xmm1 = mem[0],zero
	subsd	c_x_min(%rip), %xmm1
	movl	%eax, image_buffer_size(%rip)
	divsd	%xmm0, %xmm1
	movsd	%xmm1, pixel_width(%rip)
	movsd	c_y_max(%rip), %xmm1            # xmm1 = mem[0],zero
	subsd	c_y_min(%rip), %xmm1
	divsd	%xmm0, %xmm1
	movsd	%xmm1, pixel_height(%rip)
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.LBB1_2:
	.cfi_def_cfa_offset 16
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	movl	$.Lstr.4, %edi
	callq	puts@PLT
	movl	$.Lstr.5, %edi
	callq	puts@PLT
	xorl	%edi, %edi
	callq	exit
.Lfunc_end1:
	.size	_Z4initiPPc, .Lfunc_end1-_Z4initiPPc
	.cfi_endproc
                                        # -- End function
	.globl	_Z11init_colorsv                # -- Begin function _Z11init_colorsv
	.type	_Z11init_colorsv,@function
_Z11init_colorsv:                       # @_Z11init_colorsv
	.cfi_startproc
# %bb.0:
	pushq	%rax
	.cfi_def_cfa_offset 16
	movl	$dev_color_red, %edi
	movl	$68, %esi
	callq	hipMalloc
	movl	$dev_color_green, %edi
	movl	$68, %esi
	callq	hipMalloc
	movl	$dev_color_blue, %edi
	movl	$68, %esi
	callq	hipMalloc
	movq	dev_color_red(%rip), %rdi
	movl	$color_red, %esi
	movl	$68, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	dev_color_green(%rip), %rdi
	movl	$color_green, %esi
	movl	$68, %edx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	dev_color_blue(%rip), %rdi
	movl	$color_blue, %esi
	movl	$68, %edx
	movl	$1, %ecx
	popq	%rax
	.cfi_def_cfa_offset 8
	jmp	hipMemcpy                       # TAILCALL
.Lfunc_end2:
	.size	_Z11init_colorsv, .Lfunc_end2-_Z11init_colorsv
	.cfi_endproc
                                        # -- End function
	.globl	_Z15allocate_pixelsv            # -- Begin function _Z15allocate_pixelsv
	.type	_Z15allocate_pixelsv,@function
_Z15allocate_pixelsv:                   # @_Z15allocate_pixelsv
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movslq	image_buffer_size(%rip), %rbx
	leaq	(,%rbx,8), %rdi
	callq	malloc
	movq	%rax, pixels(%rip)
	testq	%rbx, %rbx
	jle	.LBB3_3
# %bb.1:                                # %.lr.ph.preheader
	movl	%ebx, %ebx
	xorl	%r14d, %r14d
.LBB3_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	$3, %edi
	callq	malloc
	movq	pixels(%rip), %rcx
	movq	%rax, (%rcx,%r14,8)
	incq	%r14
	cmpq	%r14, %rbx
	jne	.LBB3_2
.LBB3_3:                                # %._crit_edge
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end3:
	.size	_Z15allocate_pixelsv, .Lfunc_end3-_Z15allocate_pixelsv
	.cfi_endproc
                                        # -- End function
	.globl	_Z10set_pixelsv                 # -- Begin function _Z10set_pixelsv
	.type	_Z10set_pixelsv,@function
_Z10set_pixelsv:                        # @_Z10set_pixelsv
	.cfi_startproc
# %bb.0:
	cmpl	$0, image_buffer_size(%rip)
	jle	.LBB4_3
# %bb.1:                                # %.lr.ph.preheader
	xorl	%eax, %eax
.LBB4_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	image_buffer_red(%rip), %rcx
	movb	(%rcx,%rax), %cl
	movq	pixels(%rip), %rdx
	movq	(%rdx,%rax,8), %rdx
	movb	%cl, (%rdx)
	movq	image_buffer_green(%rip), %rcx
	movb	(%rcx,%rax), %cl
	movq	pixels(%rip), %rdx
	movq	(%rdx,%rax,8), %rdx
	movb	%cl, 1(%rdx)
	movq	image_buffer_blue(%rip), %rcx
	movb	(%rcx,%rax), %cl
	movq	pixels(%rip), %rdx
	movq	(%rdx,%rax,8), %rdx
	movb	%cl, 2(%rdx)
	incq	%rax
	movslq	image_buffer_size(%rip), %rcx
	cmpq	%rcx, %rax
	jl	.LBB4_2
.LBB4_3:                                # %._crit_edge
	retq
.Lfunc_end4:
	.size	_Z10set_pixelsv, .Lfunc_end4-_Z10set_pixelsv
	.cfi_endproc
                                        # -- End function
	.globl	_Z13write_to_filev              # -- Begin function _Z13write_to_filev
	.type	_Z13write_to_filev,@function
_Z13write_to_filev:                     # @_Z13write_to_filev
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	movl	$.L.str.8, %edi
	movl	$.L.str.10, %esi
	callq	fopen
	movq	%rax, %rbx
	movl	i_x_max(%rip), %ecx
	movl	i_y_max(%rip), %r8d
	movl	$.L.str.11, %esi
	movl	$.L.str.9, %edx
	movq	%rax, %rdi
	movl	$255, %r9d
	xorl	%eax, %eax
	callq	fprintf
	cmpl	$0, image_buffer_size(%rip)
	jle	.LBB5_3
# %bb.1:                                # %.lr.ph.preheader
	xorl	%r14d, %r14d
.LBB5_2:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	pixels(%rip), %rax
	movq	(%rax,%r14,8), %rdi
	movl	$1, %esi
	movl	$3, %edx
	movq	%rbx, %rcx
	callq	fwrite
	incq	%r14
	movslq	image_buffer_size(%rip), %rax
	cmpq	%rax, %r14
	jl	.LBB5_2
.LBB5_3:                                # %._crit_edge
	movq	%rbx, %rdi
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	jmp	fclose                          # TAILCALL
.Lfunc_end5:
	.size	_Z13write_to_filev, .Lfunc_end5-_Z13write_to_filev
	.cfi_endproc
                                        # -- End function
	.globl	_Z33__device_stub__compute_mandelbrotPhS_S_ddddiPiS0_S0_ # -- Begin function _Z33__device_stub__compute_mandelbrotPhS_S_ddddiPiS0_S0_
	.type	_Z33__device_stub__compute_mandelbrotPhS_S_ddddiPiS0_S0_,@function
_Z33__device_stub__compute_mandelbrotPhS_S_ddddiPiS0_S0_: # @_Z33__device_stub__compute_mandelbrotPhS_S_ddddiPiS0_S0_
	.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	$224, %rsp
	.cfi_def_cfa_offset 272
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	88(%rsp), %rax
	movq	%rdi, (%rax)
	leaq	80(%rsp), %rdi
	movq	%rsi, (%rdi)
	leaq	72(%rsp), %rsi
	movq	%rdx, (%rsi)
	leaq	64(%rsp), %rdx
	movsd	%xmm0, (%rdx)
	leaq	56(%rsp), %r10
	movsd	%xmm1, (%r10)
	leaq	48(%rsp), %r11
	movsd	%xmm2, (%r11)
	leaq	40(%rsp), %r14
	movsd	%xmm3, (%r14)
	leaq	4(%rsp), %r15
	movl	%ecx, (%r15)
	leaq	32(%rsp), %rcx
	movq	%r8, (%rcx)
	leaq	24(%rsp), %r8
	movq	%r9, (%r8)
	leaq	128(%rsp), %rbx
	movq	%rax, (%rbx)
	movq	%rdi, 8(%rbx)
	movq	%rsi, 16(%rbx)
	movq	%rdx, 24(%rbx)
	movq	%r10, 32(%rbx)
	movq	%r11, 40(%rbx)
	movq	%r14, 48(%rbx)
	movq	%r15, 56(%rbx)
	movq	%rcx, 64(%rbx)
	movq	%r8, 72(%rbx)
	leaq	272(%rsp), %rax
	movq	%rax, 80(%rbx)
	leaq	112(%rsp), %r14
	leaq	96(%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	$_Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$240, %rsp
	.cfi_adjust_cfa_offset -240
	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_end6:
	.size	_Z33__device_stub__compute_mandelbrotPhS_S_ddddiPiS0_S0_, .Lfunc_end6-_Z33__device_stub__compute_mandelbrotPhS_S_ddddiPiS0_S0_
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI7_0:
	.quad	0x41cdcd6500000000              # double 1.0E+9
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%r14
	.cfi_def_cfa_offset 16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	pushq	%rax
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -24
	.cfi_offset %r14, -16
	callq	_Z4initiPPc
	callq	_Z21allocate_image_bufferv
	callq	_Z11init_colorsv
	movl	block_dim_x(%rip), %esi
	movl	block_dim_y(%rip), %r14d
	movl	image_size(%rip), %ecx
	movl	%ecx, %eax
	xorl	%edx, %edx
	divl	%esi
	movl	%eax, %ebx
	movl	%ecx, %eax
	xorl	%edx, %edx
	divl	%r14d
                                        # kill: def $eax killed $eax def $rax
	shlq	$32, %r14
	orq	%rsi, %r14
	shlq	$32, %rax
	orq	%rax, %rbx
	callq	clock
	movq	%rax, timer(%rip)
	movl	$timer+16, %esi
	movl	$1, %edi
	callq	clock_gettime
	movl	$timer+48, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	%rbx, %rdi
	movl	$1, %esi
	movq	%r14, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB7_2
# %bb.1:
	movq	dev_image_buffer_red(%rip), %rdi
	movq	dev_image_buffer_green(%rip), %rsi
	movq	dev_image_buffer_blue(%rip), %rdx
	movsd	c_x_min(%rip), %xmm0            # xmm0 = mem[0],zero
	movsd	c_y_min(%rip), %xmm1            # xmm1 = mem[0],zero
	movsd	pixel_width(%rip), %xmm2        # xmm2 = mem[0],zero
	movsd	pixel_height(%rip), %xmm3       # xmm3 = mem[0],zero
	movl	image_size(%rip), %ecx
	movq	dev_color_red(%rip), %r8
	movq	dev_color_green(%rip), %r9
	movq	dev_color_blue(%rip), %rax
	movq	%rax, (%rsp)
	callq	_Z33__device_stub__compute_mandelbrotPhS_S_ddddiPiS0_S0_
.LBB7_2:
	movq	image_buffer_red(%rip), %rdi
	movq	dev_image_buffer_red(%rip), %rsi
	movslq	image_buffer_size(%rip), %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	image_buffer_green(%rip), %rdi
	movq	dev_image_buffer_green(%rip), %rsi
	movslq	image_buffer_size(%rip), %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	image_buffer_blue(%rip), %rdi
	movq	dev_image_buffer_blue(%rip), %rsi
	movslq	image_buffer_size(%rip), %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	callq	clock
	movq	%rax, timer+8(%rip)
	movl	$timer+32, %esi
	movl	$1, %edi
	callq	clock_gettime
	movl	$timer+64, %edi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	dev_color_red(%rip), %rdi
	callq	hipFree
	movq	dev_color_green(%rip), %rdi
	callq	hipFree
	movq	dev_color_blue(%rip), %rdi
	callq	hipFree
	callq	_Z15allocate_pixelsv
	callq	_Z10set_pixelsv
	movq	dev_image_buffer_red(%rip), %rdi
	callq	hipFree
	movq	dev_image_buffer_green(%rip), %rdi
	callq	hipFree
	movq	dev_image_buffer_blue(%rip), %rdi
	callq	hipFree
	callq	_Z13write_to_filev
	movq	timer+32(%rip), %rax
	subq	timer+16(%rip), %rax
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rax, %xmm1
	movq	timer+40(%rip), %rax
	subq	timer+24(%rip), %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	divsd	.LCPI7_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	movl	$.L.str.12, %edi
	movb	$1, %al
	callq	printf
	movq	timer+32(%rip), %rax
	subq	timer+16(%rip), %rax
	xorps	%xmm0, %xmm0
	cvtsi2sd	%rax, %xmm0
	movq	timer+40(%rip), %rax
	subq	timer+24(%rip), %rax
	xorps	%xmm1, %xmm1
	cvtsi2sd	%rax, %xmm1
	divsd	.LCPI7_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	cvttsd2si	%xmm1, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end7:
	.size	main, .Lfunc_end7-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	.LBB8_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB8_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_, %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_end8:
	.size	__hip_module_ctor, .Lfunc_end8-__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	.LBB9_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
.LBB9_2:
	retq
.Lfunc_end9:
	.size	__hip_module_dtor, .Lfunc_end9-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	timer,@object                   # @timer
	.bss
	.globl	timer
	.p2align	3, 0x0
timer:
	.zero	80
	.size	timer, 80

	.type	c_x_min,@object                 # @c_x_min
	.globl	c_x_min
	.p2align	3, 0x0
c_x_min:
	.quad	0x0000000000000000              # double 0
	.size	c_x_min, 8

	.type	c_x_max,@object                 # @c_x_max
	.globl	c_x_max
	.p2align	3, 0x0
c_x_max:
	.quad	0x0000000000000000              # double 0
	.size	c_x_max, 8

	.type	c_y_min,@object                 # @c_y_min
	.globl	c_y_min
	.p2align	3, 0x0
c_y_min:
	.quad	0x0000000000000000              # double 0
	.size	c_y_min, 8

	.type	c_y_max,@object                 # @c_y_max
	.globl	c_y_max
	.p2align	3, 0x0
c_y_max:
	.quad	0x0000000000000000              # double 0
	.size	c_y_max, 8

	.type	pixel_width,@object             # @pixel_width
	.globl	pixel_width
	.p2align	3, 0x0
pixel_width:
	.quad	0x0000000000000000              # double 0
	.size	pixel_width, 8

	.type	pixel_height,@object            # @pixel_height
	.globl	pixel_height
	.p2align	3, 0x0
pixel_height:
	.quad	0x0000000000000000              # double 0
	.size	pixel_height, 8

	.type	iteration_max,@object           # @iteration_max
	.data
	.globl	iteration_max
	.p2align	2, 0x0
iteration_max:
	.long	200                             # 0xc8
	.size	iteration_max, 4

	.type	image_size,@object              # @image_size
	.bss
	.globl	image_size
	.p2align	2, 0x0
image_size:
	.long	0                               # 0x0
	.size	image_size, 4

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

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

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

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

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

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

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

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

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

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

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

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

	.type	gradient_size,@object           # @gradient_size
	.data
	.globl	gradient_size
	.p2align	2, 0x0
gradient_size:
	.long	16                              # 0x10
	.size	gradient_size, 4

	.type	color_red,@object               # @color_red
	.globl	color_red
	.p2align	4, 0x0
color_red:
	.long	66                              # 0x42
	.long	25                              # 0x19
	.long	9                               # 0x9
	.long	4                               # 0x4
	.long	0                               # 0x0
	.long	12                              # 0xc
	.long	24                              # 0x18
	.long	57                              # 0x39
	.long	134                             # 0x86
	.long	211                             # 0xd3
	.long	241                             # 0xf1
	.long	248                             # 0xf8
	.long	255                             # 0xff
	.long	204                             # 0xcc
	.long	153                             # 0x99
	.long	106                             # 0x6a
	.long	16                              # 0x10
	.size	color_red, 68

	.type	color_green,@object             # @color_green
	.globl	color_green
	.p2align	4, 0x0
color_green:
	.long	30                              # 0x1e
	.long	7                               # 0x7
	.long	1                               # 0x1
	.long	4                               # 0x4
	.long	7                               # 0x7
	.long	44                              # 0x2c
	.long	82                              # 0x52
	.long	125                             # 0x7d
	.long	181                             # 0xb5
	.long	236                             # 0xec
	.long	233                             # 0xe9
	.long	201                             # 0xc9
	.long	170                             # 0xaa
	.long	128                             # 0x80
	.long	87                              # 0x57
	.long	52                              # 0x34
	.long	16                              # 0x10
	.size	color_green, 68

	.type	color_blue,@object              # @color_blue
	.globl	color_blue
	.p2align	4, 0x0
color_blue:
	.long	15                              # 0xf
	.long	26                              # 0x1a
	.long	47                              # 0x2f
	.long	73                              # 0x49
	.long	100                             # 0x64
	.long	138                             # 0x8a
	.long	177                             # 0xb1
	.long	209                             # 0xd1
	.long	229                             # 0xe5
	.long	248                             # 0xf8
	.long	191                             # 0xbf
	.long	95                              # 0x5f
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	0                               # 0x0
	.long	3                               # 0x3
	.long	16                              # 0x10
	.size	color_blue, 68

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

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

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

	.type	.L.str.6,@object                # @.str.6
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.6:
	.asciz	"%lf"
	.size	.L.str.6, 4

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

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"output.ppm"
	.size	.L.str.8, 11

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

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

	.type	.L.str.11,@object               # @.str.11
.L.str.11:
	.asciz	"P6\n %s\n %d\n %d\n %d\n"
	.size	.L.str.11, 20

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

	.type	.L.str.12,@object               # @.str.12
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.12:
	.asciz	"%f\n"
	.size	.L.str.12, 4

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_"
	.size	.L__unnamed_1, 42

	.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	"usage: ./mandelbrot_seq c_x_min c_x_max c_y_min c_y_max image_size dimX dimY"
	.size	.Lstr, 77

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"examples with image_size = 11500:"
	.size	.Lstr.1, 34

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"    Full Picture:         ./mandelbrot_seq -2.5 1.5 -2.0 2.0 4096 8 64"
	.size	.Lstr.2, 71

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"    Seahorse Valley:      ./mandelbrot_seq -0.8 -0.7 0.05 0.15 4096 32 32"
	.size	.Lstr.3, 74

	.type	.Lstr.4,@object                 # @str.4
.Lstr.4:
	.asciz	"    Elephant Valley:      ./mandelbrot_seq 0.175 0.375 -0.1 0.1 4096 16 64"
	.size	.Lstr.4, 75

	.type	.Lstr.5,@object                 # @str.5
.Lstr.5:
	.asciz	"    Triple Spiral Valley: ./mandelbrot_seq -0.188 -0.012 0.554 0.754 4096 1 32"
	.size	.Lstr.5, 79

	.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 _Z33__device_stub__compute_mandelbrotPhS_S_ddddiPiS0_S0_
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym timer
	.addrsig_sym c_x_min
	.addrsig_sym c_x_max
	.addrsig_sym c_y_min
	.addrsig_sym c_y_max
	.addrsig_sym image_size
	.addrsig_sym dev_image_buffer_red
	.addrsig_sym dev_image_buffer_blue
	.addrsig_sym dev_image_buffer_green
	.addrsig_sym block_dim_x
	.addrsig_sym block_dim_y
	.addrsig_sym color_red
	.addrsig_sym color_green
	.addrsig_sym color_blue
	.addrsig_sym dev_color_red
	.addrsig_sym dev_color_green
	.addrsig_sym dev_color_blue
	.addrsig_sym _Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

	.text
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.protected	_Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_ ; -- Begin function _Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_
	.globl	_Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_
	.p2align	8
	.type	_Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_,@function
_Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_: ; @_Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_
; %bb.0:
	s_load_b32 s2, s[0:1], 0x64
	v_bfe_u32 v3, v0, 10, 10
	s_load_b256 s[16:23], s[0:1], 0x20
	v_and_b32_e32 v0, 0x3ff, v0
	s_load_b256 s[4:11], s[0:1], 0x0
	s_waitcnt lgkmcnt(0)
	s_lshr_b32 s3, s2, 16
	s_and_b32 s2, s2, 0xffff
	v_mad_u64_u32 v[1:2], null, s15, s3, v[3:4]
	v_mul_f64 v[6:7], s[20:21], 0.5
	s_mov_b32 s3, 0
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cvt_f64_i32_e32 v[4:5], v1
	v_fma_f64 v[9:10], v[4:5], s[20:21], s[16:17]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_4) | instid1(VALU_DEP_2)
	v_cmp_nlt_f64_e64 vcc_lo, |v[9:10]|, v[6:7]
	v_mov_b32_e32 v5, 0
	v_mad_u64_u32 v[2:3], null, s14, s2, v[0:1]
	v_mov_b32_e32 v6, 0
	s_mov_b32 s2, 0
	v_cvt_f64_i32_e32 v[3:4], v2
	s_delay_alu instid0(VALU_DEP_2)
	v_dual_cndmask_b32 v9, 0, v9 :: v_dual_mov_b32 v12, v6
	v_dual_mov_b32 v8, v6 :: v_dual_mov_b32 v7, v5
	v_dual_mov_b32 v14, v6 :: v_dual_mov_b32 v13, v5
	v_dual_cndmask_b32 v10, 0, v10 :: v_dual_mov_b32 v11, v5
	v_fma_f64 v[3:4], v[3:4], s[18:19], s[10:11]
.LBB0_1:                                ; =>This Inner Loop Header: Depth=1
	s_delay_alu instid0(VALU_DEP_1)
	v_add_f64 v[11:12], v[11:12], -v[13:14]
	v_add_f64 v[13:14], v[5:6], v[5:6]
	s_add_i32 s10, s3, 1
	s_cmpk_gt_u32 s3, 0xc6
	v_mov_b32_e32 v0, s10
	s_cselect_b32 s3, -1, 0
	s_delay_alu instid0(VALU_DEP_3) | instskip(NEXT) | instid1(VALU_DEP_3)
	v_add_f64 v[5:6], v[3:4], v[11:12]
	v_fma_f64 v[7:8], v[7:8], v[13:14], v[9:10]
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_mul_f64 v[11:12], v[5:6], v[5:6]
	v_fma_f64 v[13:14], v[7:8], v[7:8], v[11:12]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_2) | instid1(SALU_CYCLE_1)
	v_cmp_ngt_f64_e32 vcc_lo, 4.0, v[13:14]
	v_mul_f64 v[13:14], v[7:8], v[7:8]
	s_or_b32 s3, s3, vcc_lo
	s_and_b32 s3, exec_lo, s3
	s_delay_alu instid0(SALU_CYCLE_1)
	s_or_b32 s2, s3, s2
	s_mov_b32 s3, s10
	s_and_not1_b32 exec_lo, exec_lo, s2
	s_cbranch_execnz .LBB0_1
; %bb.2:                                ; %_Z10mandelbrotdd.exit
	s_or_b32 exec_lo, exec_lo, s2
	s_clause 0x1
	s_load_b128 s[12:15], s[0:1], 0x40
	s_load_b32 s2, s[0:1], 0x38
	v_and_b32_e32 v3, 15, v0
	v_cmp_ne_u32_e32 vcc_lo, 0xc8, v0
	s_load_b64 s[0:1], s[0:1], 0x50
	s_delay_alu instid0(VALU_DEP_2) | instskip(NEXT) | instid1(VALU_DEP_1)
	v_cndmask_b32_e32 v0, 16, v3, vcc_lo
	v_lshlrev_b32_e32 v5, 2, v0
	s_waitcnt lgkmcnt(0)
	global_load_b32 v6, v5, s[12:13]
	v_mad_u64_u32 v[3:4], null, v1, s2, v[2:3]
	s_delay_alu instid0(VALU_DEP_1) | instskip(SKIP_1) | instid1(VALU_DEP_2)
	v_ashrrev_i32_e32 v2, 31, v3
	v_add_co_u32 v0, vcc_lo, s4, v3
	v_add_co_ci_u32_e32 v1, vcc_lo, s5, v2, vcc_lo
	s_waitcnt vmcnt(0)
	global_store_b8 v[0:1], v6, off
	global_load_b32 v4, v5, s[14:15]
	v_add_co_u32 v0, vcc_lo, s6, v3
	v_add_co_ci_u32_e32 v1, vcc_lo, s7, v2, vcc_lo
	s_waitcnt vmcnt(0)
	global_store_b8 v[0:1], v4, off
	global_load_b32 v4, v5, s[0:1]
	v_add_co_u32 v0, vcc_lo, s8, v3
	v_add_co_ci_u32_e32 v1, vcc_lo, s9, v2, vcc_lo
	s_waitcnt vmcnt(0)
	global_store_b8 v[0:1], v4, off
	s_nop 0
	s_sendmsg sendmsg(MSG_DEALLOC_VGPRS)
	s_endpgm
	.section	.rodata,"a",@progbits
	.p2align	6, 0x0
	.amdhsa_kernel _Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_
		.amdhsa_group_segment_fixed_size 0
		.amdhsa_private_segment_fixed_size 0
		.amdhsa_kernarg_size 344
		.amdhsa_user_sgpr_count 14
		.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 1
		.amdhsa_system_sgpr_workgroup_id_z 0
		.amdhsa_system_sgpr_workgroup_info 0
		.amdhsa_system_vgpr_workitem_id 1
		.amdhsa_next_free_vgpr 15
		.amdhsa_next_free_sgpr 24
		.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	_Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_, .Lfunc_end0-_Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_
                                        ; -- End function
	.section	.AMDGPU.csdata,"",@progbits
; Kernel info:
; codeLenInByte = 476
; NumSgprs: 26
; NumVgprs: 15
; ScratchSize: 0
; MemoryBound: 0
; FloatMode: 240
; IeeeMode: 1
; LDSByteSize: 0 bytes/workgroup (compile time only)
; SGPRBlocks: 3
; VGPRBlocks: 1
; NumSGPRsForWavesPerEU: 26
; NumVGPRsForWavesPerEU: 15
; Occupancy: 16
; WaveLimiterHint : 0
; COMPUTE_PGM_RSRC2:SCRATCH_EN: 0
; COMPUTE_PGM_RSRC2:USER_SGPR: 14
; COMPUTE_PGM_RSRC2:TRAP_HANDLER: 0
; COMPUTE_PGM_RSRC2:TGID_X_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Y_EN: 1
; COMPUTE_PGM_RSRC2:TGID_Z_EN: 0
; COMPUTE_PGM_RSRC2:TIDIG_COMP_CNT: 1
	.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
      - .offset:         24
        .size:           8
        .value_kind:     by_value
      - .offset:         32
        .size:           8
        .value_kind:     by_value
      - .offset:         40
        .size:           8
        .value_kind:     by_value
      - .offset:         48
        .size:           8
        .value_kind:     by_value
      - .offset:         56
        .size:           4
        .value_kind:     by_value
      - .address_space:  global
        .offset:         64
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         72
        .size:           8
        .value_kind:     global_buffer
      - .address_space:  global
        .offset:         80
        .size:           8
        .value_kind:     global_buffer
      - .offset:         88
        .size:           4
        .value_kind:     hidden_block_count_x
      - .offset:         92
        .size:           4
        .value_kind:     hidden_block_count_y
      - .offset:         96
        .size:           4
        .value_kind:     hidden_block_count_z
      - .offset:         100
        .size:           2
        .value_kind:     hidden_group_size_x
      - .offset:         102
        .size:           2
        .value_kind:     hidden_group_size_y
      - .offset:         104
        .size:           2
        .value_kind:     hidden_group_size_z
      - .offset:         106
        .size:           2
        .value_kind:     hidden_remainder_x
      - .offset:         108
        .size:           2
        .value_kind:     hidden_remainder_y
      - .offset:         110
        .size:           2
        .value_kind:     hidden_remainder_z
      - .offset:         128
        .size:           8
        .value_kind:     hidden_global_offset_x
      - .offset:         136
        .size:           8
        .value_kind:     hidden_global_offset_y
      - .offset:         144
        .size:           8
        .value_kind:     hidden_global_offset_z
      - .offset:         152
        .size:           2
        .value_kind:     hidden_grid_dims
    .group_segment_fixed_size: 0
    .kernarg_segment_align: 8
    .kernarg_segment_size: 344
    .language:       OpenCL C
    .language_version:
      - 2
      - 0
    .max_flat_workgroup_size: 1024
    .name:           _Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_
    .private_segment_fixed_size: 0
    .sgpr_count:     26
    .sgpr_spill_count: 0
    .symbol:         _Z18compute_mandelbrotPhS_S_ddddiPiS0_S0_.kd
    .uniform_work_group_size: 1
    .uses_dynamic_stack: false
    .vgpr_count:     15
    .vgpr_spill_count: 0
    .wavefront_size: 32
    .workgroup_processor_mode: 1
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
