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

// CPU: marca o tempo
__host__ double wtime() {
  struct timeval t;
  gettimeofday(&t, NULL);
  return t.tv_sec + (double) t.tv_usec / 1000000;
}

// CPU: Núcleo de execução (processamento)
__host__ void fhcalc(int n)
{
   double v1=0;

    for (int j=0; j < 10000; j++) {
      for(int i=2; i < n; ++i) {
          v1=pow(v1,i);          
       }
     }
}

// GPU: Núcleo de execução (processamento)
__global__ void fdcalc(int n)
{
   double v1=0;

    for (int j=0; j < 10000; j++) {
      for(int i=2; i < n; ++i) {
          v1=pow(v1,i);          
       }
     }
}

// CPU: Função principal
int main (int argc, char ** argv) { 
	int nthreads = 400;
	int nblocos = 1;
	int ncalc = 400;
        double start_time = 0, end_time = 0;

        // Tratamento dos paramêtros
	if (argc == 4) {
		nblocos = atoi(argv[1]);
		nthreads = atoi(argv[2]);
		ncalc = atoi(argv[3]);
	} else {
                printf ("\n ############# \n");
		printf ("./05_proc <nblocos> <nthreads> <nloop>\n");
		printf ("Caso não haja passagem de parâmetros, atribuiu-se:\n(1) nblocos c/ %d, nthreads definido c/ %d e ncalc = %d \n", nblocos, nthreads, ncalc);
	}

        // Mensura o tempo de processamento do kernel em 1 bloco c/ 1 thread
        printf ("\n##### DEVICE (1,1) #####\n");
        start_time = wtime();

        // GPU: Execução do kernel em 1,1
	fdcalc<<<1,1>>>(ncalc);
        
        // CPU: Aguarda a sincronização das threads
	cudaDeviceSynchronize();
        end_time = wtime();
        printf("\n");
        printf("\tRuntime: %f\n", end_time - start_time);

       
        // Mensura o tempo de processamento do kernel c/ n blocos e m threads
        printf ("\n##### DEVICE (%d,%d) #####\n", nblocos, nthreads);
        start_time = wtime();

        // GPU: Execução do kernel em n,m
	fdcalc<<<nblocos,nthreads>>>(ncalc/nthreads);

        // CPU: Aguarda a sincronização das threads
	cudaDeviceSynchronize();
        end_time = wtime();
        printf("\n");
        printf("\tRuntime: %f\n", end_time - start_time);


        // Mensura o tempo de processamento em CPU
        printf ("\n##### HOST #####\n");
        start_time = wtime();
	fhcalc(ncalc);
	cudaDeviceSynchronize();
        end_time = wtime();
        printf("\n");
        printf("\tRuntime: %f\n", end_time - start_time);
	return 0;
}

	.file	"tmpxft_00359998_00000000-6_05_proc.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
	.globl	_Z5wtimev
	.type	_Z5wtimev, @function
_Z5wtimev:
.LFB2027:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	xorl	%esi, %esi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdi
	call	gettimeofday@PLT
	cvtsi2sdq	8(%rsp), %xmm1
	cvtsi2sdq	16(%rsp), %xmm0
	divsd	.LC0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L3
	call	__stack_chk_fail@PLT
.L3:
	addq	$40, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2027:
	.size	_Z5wtimev, .-_Z5wtimev
	.globl	_Z6fhcalci
	.type	_Z6fhcalci, @function
_Z6fhcalci:
.LFB2028:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	xorps	%xmm0, %xmm0
	movl	%edi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	$10000, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
.L7:
	movl	$2, %ebx
.L10:
	cmpl	%r12d, %ebx
	jge	.L12
	cvtsi2sdl	%ebx, %xmm1
	incl	%ebx
	call	pow@PLT
	jmp	.L10
.L12:
	decl	%ebp
	jne	.L7
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2028:
	.size	_Z6fhcalci, .-_Z6fhcalci
	.globl	_Z24__device_stub__Z6fdcalcii
	.type	_Z24__device_stub__Z6fdcalcii, @function
_Z24__device_stub__Z6fdcalcii:
.LFB2054:
	.cfi_startproc
	endbr64
	subq	$104, %rsp
	.cfi_def_cfa_offset 112
	movl	%edi, 12(%rsp)
	leaq	24(%rsp), %rcx
	leaq	16(%rsp), %rdx
	leaq	44(%rsp), %rsi
	leaq	32(%rsp), %rdi
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rax
	movl	$1, 40(%rsp)
	movq	%rax, 80(%rsp)
	movabsq	$4294967297, %rax
	movq	%rax, 32(%rsp)
	movq	%rax, 44(%rsp)
	movl	$1, 52(%rsp)
	call	__cudaPopCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L13
	pushq	24(%rsp)
	.cfi_def_cfa_offset 120
	leaq	_Z6fdcalci(%rip), %rdi
	pushq	24(%rsp)
	.cfi_def_cfa_offset 128
	movq	60(%rsp), %rcx
	movl	68(%rsp), %r8d
	movq	48(%rsp), %rsi
	movl	56(%rsp), %edx
	leaq	96(%rsp), %r9
	call	cudaLaunchKernel@PLT
	popq	%rax
	.cfi_def_cfa_offset 120
	popq	%rdx
	.cfi_def_cfa_offset 112
.L13:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	addq	$104, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2054:
	.size	_Z24__device_stub__Z6fdcalcii, .-_Z24__device_stub__Z6fdcalcii
	.globl	_Z6fdcalci
	.type	_Z6fdcalci, @function
_Z6fdcalci:
.LFB2055:
	.cfi_startproc
	endbr64
	jmp	_Z24__device_stub__Z6fdcalcii
	.cfi_endproc
.LFE2055:
	.size	_Z6fdcalci, .-_Z6fdcalci
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"\n ############# \n"
.LC3:
	.string	"./05_proc <nblocos> <nthreads> <nloop>\n"
.LC4:
	.string	"Caso n\303\243o haja passagem de par\303\242metros, atribuiu-se:\n(1) nblocos c/ %d, nthreads definido c/ %d e ncalc = %d \n"
.LC5:
	.string	"\n##### DEVICE (1,1) #####\n"
.LC6:
	.string	"\n"
.LC7:
	.string	"\tRuntime: %f\n"
.LC8:
	.string	"\n##### DEVICE (%d,%d) #####\n"
.LC9:
	.string	"\n##### HOST #####\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2029:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$48, %rsp
	.cfi_def_cfa_offset 96
	cmpl	$4, %edi
	jne	.L19
	movq	8(%rsi), %rdi
	movq	%rsi, %rbx
	call	atoi@PLT
	movq	16(%rbx), %rdi
	movl	%eax, %r14d
	call	atoi@PLT
	movq	24(%rbx), %rdi
	movl	%eax, %ebp
	call	atoi@PLT
	movl	%eax, %ebx
	jmp	.L20
.L19:
	leaq	.LC2(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	movl	$400, %ebx
	call	__printf_chk@PLT
	leaq	.LC3(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	$400, %r8d
	xorl	%eax, %eax
	movl	$400, %ecx
	movl	$1, %edx
	movl	$2, %edi
	movl	$400, %ebp
	movl	$1, %r14d
	leaq	.LC4(%rip), %rsi
	call	__printf_chk@PLT
.L20:
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	_Z5wtimev
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movl	$1, %ecx
	movabsq	$4294967297, %rdi
	movl	$1, %esi
	movl	$1, 44(%rsp)
	movq	%rdi, %rdx
	movq	%rdi, 36(%rsp)
	movq	%rdi, 24(%rsp)
	movl	$1, 32(%rsp)
	movsd	%xmm0, (%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L21
	movl	%ebx, %edi
	call	_Z24__device_stub__Z6fdcalcii
.L21:
	leaq	.LC6(%rip), %r13
	leaq	.LC7(%rip), %r12
	call	cudaDeviceSynchronize@PLT
	call	_Z5wtimev
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	movsd	%xmm0, 8(%rsp)
	call	__printf_chk@PLT
	movsd	8(%rsp), %xmm0
	movq	%r12, %rsi
	movb	$1, %al
	subsd	(%rsp), %xmm0
	movl	$2, %edi
	call	__printf_chk@PLT
	movl	%ebp, %ecx
	movl	%r14d, %edx
	movl	$2, %edi
	leaq	.LC8(%rip), %rsi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	_Z5wtimev
	movl	%ebp, 36(%rsp)
	xorl	%r9d, %r9d
	xorl	%r8d, %r8d
	movabsq	$4294967297, %rax
	movl	%r14d, 24(%rsp)
	movq	%rax, 40(%rsp)
	movl	44(%rsp), %ecx
	movq	%rax, 28(%rsp)
	movq	36(%rsp), %rdx
	movq	24(%rsp), %rdi
	movl	32(%rsp), %esi
	movsd	%xmm0, (%rsp)
	call	__cudaPushCallConfiguration@PLT
	testl	%eax, %eax
	jne	.L22
	movl	%ebx, %eax
	cltd
	idivl	%ebp
	movl	%eax, %edi
	call	_Z24__device_stub__Z6fdcalcii
.L22:
	call	cudaDeviceSynchronize@PLT
	call	_Z5wtimev
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	movsd	%xmm0, 8(%rsp)
	call	__printf_chk@PLT
	movsd	8(%rsp), %xmm0
	movq	%r12, %rsi
	movb	$1, %al
	subsd	(%rsp), %xmm0
	movl	$2, %edi
	call	__printf_chk@PLT
	leaq	.LC9(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	call	_Z5wtimev
	movl	%ebx, %edi
	movsd	%xmm0, (%rsp)
	call	_Z6fhcalci
	call	cudaDeviceSynchronize@PLT
	call	_Z5wtimev
	movq	%r13, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	movsd	%xmm0, 8(%rsp)
	call	__printf_chk@PLT
	movsd	8(%rsp), %xmm0
	movq	%r12, %rsi
	movb	$1, %al
	subsd	(%rsp), %xmm0
	movl	$2, %edi
	call	__printf_chk@PLT
	addq	$48, %rsp
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2029:
	.size	main, .-main
	.section	.rodata.str1.1
.LC10:
	.string	"_Z6fdcalci"
	.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	.LC10(%rip), %rdx
	movq	%rax, %rdi
	leaq	_Z6fdcalci(%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.cst8,"aM",@progbits,8
	.align 8
.LC0:
	.long	0
	.long	1093567616
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


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

// CPU: marca o tempo
__host__ double wtime() {
  struct timeval t;
  gettimeofday(&t, NULL);
  return t.tv_sec + (double) t.tv_usec / 1000000;
}

// CPU: Núcleo de execução (processamento)
__host__ void fhcalc(int n)
{
   double v1=0;

    for (int j=0; j < 10000; j++) {
      for(int i=2; i < n; ++i) {
          v1=pow(v1,i);          
       }
     }
}

// GPU: Núcleo de execução (processamento)
__global__ void fdcalc(int n)
{
   double v1=0;

    for (int j=0; j < 10000; j++) {
      for(int i=2; i < n; ++i) {
          v1=pow(v1,i);          
       }
     }
}

// CPU: Função principal
int main (int argc, char ** argv) { 
	int nthreads = 400;
	int nblocos = 1;
	int ncalc = 400;
        double start_time = 0, end_time = 0;

        // Tratamento dos paramêtros
	if (argc == 4) {
		nblocos = atoi(argv[1]);
		nthreads = atoi(argv[2]);
		ncalc = atoi(argv[3]);
	} else {
                printf ("\n ############# \n");
		printf ("./05_proc <nblocos> <nthreads> <nloop>\n");
		printf ("Caso não haja passagem de parâmetros, atribuiu-se:\n(1) nblocos c/ %d, nthreads definido c/ %d e ncalc = %d \n", nblocos, nthreads, ncalc);
	}

        // Mensura o tempo de processamento do kernel em 1 bloco c/ 1 thread
        printf ("\n##### DEVICE (1,1) #####\n");
        start_time = wtime();

        // GPU: Execução do kernel em 1,1
	fdcalc<<<1,1>>>(ncalc);
        
        // CPU: Aguarda a sincronização das threads
	hipDeviceSynchronize();
        end_time = wtime();
        printf("\n");
        printf("\tRuntime: %f\n", end_time - start_time);

       
        // Mensura o tempo de processamento do kernel c/ n blocos e m threads
        printf ("\n##### DEVICE (%d,%d) #####\n", nblocos, nthreads);
        start_time = wtime();

        // GPU: Execução do kernel em n,m
	fdcalc<<<nblocos,nthreads>>>(ncalc/nthreads);

        // CPU: Aguarda a sincronização das threads
	hipDeviceSynchronize();
        end_time = wtime();
        printf("\n");
        printf("\tRuntime: %f\n", end_time - start_time);


        // Mensura o tempo de processamento em CPU
        printf ("\n##### HOST #####\n");
        start_time = wtime();
	fhcalc(ncalc);
	hipDeviceSynchronize();
        end_time = wtime();
        printf("\n");
        printf("\tRuntime: %f\n", end_time - start_time);
	return 0;
}

	.text
	.file	"05_proc.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z5wtimev
.LCPI0_0:
	.quad	0x412e848000000000              # double 1.0E+6
	.text
	.globl	_Z5wtimev
	.type	_Z5wtimev,@function
_Z5wtimev:                              # @_Z5wtimev
	.cfi_startproc
# %bb.0:
	pushq	%rbx
	.cfi_def_cfa_offset 16
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	.cfi_offset %rbx, -16
	movq	%rsp, %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	cvtsi2sdq	(%rbx), %xmm1
	cvtsi2sdq	8(%rbx), %xmm0
	divsd	.LCPI0_0(%rip), %xmm0
	addsd	%xmm1, %xmm0
	addq	$16, %rsp
	.cfi_def_cfa_offset 16
	popq	%rbx
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_Z5wtimev, .Lfunc_end0-_Z5wtimev
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function _Z6fhcalci
.LCPI1_0:
	.quad	0x4000000000000000              # double 2
.LCPI1_1:
	.quad	0x3ff0000000000000              # double 1
	.text
	.globl	_Z6fhcalci
	.type	_Z6fhcalci,@function
_Z6fhcalci:                             # @_Z6fhcalci
	.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	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%edi, %ebx
	leal	-2(%rbx), %ebp
	xorps	%xmm0, %xmm0
	xorl	%r14d, %r14d
.LBB1_1:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB1_3 Depth 2
	cmpl	$3, %ebx
	jl	.LBB1_4
# %bb.2:                                # %.lr.ph.preheader
                                        #   in Loop: Header=BB1_1 Depth=1
	movl	%ebp, %r15d
	movsd	.LCPI1_0(%rip), %xmm1           # xmm1 = mem[0],zero
.LBB1_3:                                # %.lr.ph
                                        #   Parent Loop BB1_1 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	%xmm1, (%rsp)                   # 8-byte Spill
	movsd	(%rsp), %xmm1                   # 8-byte Reload
                                        # xmm1 = mem[0],zero
	callq	pow
	movsd	.LCPI1_1(%rip), %xmm1           # xmm1 = mem[0],zero
	movsd	(%rsp), %xmm2                   # 8-byte Reload
                                        # xmm2 = mem[0],zero
	addsd	%xmm1, %xmm2
	movsd	%xmm2, (%rsp)                   # 8-byte Spill
	movsd	(%rsp), %xmm1                   # 8-byte Reload
                                        # xmm1 = mem[0],zero
	decl	%r15d
	jne	.LBB1_3
.LBB1_4:                                # %._crit_edge
                                        #   in Loop: Header=BB1_1 Depth=1
	incl	%r14d
	cmpl	$10000, %r14d                   # imm = 0x2710
	jne	.LBB1_1
# %bb.5:
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r14
	.cfi_def_cfa_offset 24
	popq	%r15
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end1:
	.size	_Z6fhcalci, .Lfunc_end1-_Z6fhcalci
	.cfi_endproc
                                        # -- End function
	.globl	_Z21__device_stub__fdcalci      # -- Begin function _Z21__device_stub__fdcalci
	.type	_Z21__device_stub__fdcalci,@function
_Z21__device_stub__fdcalci:             # @_Z21__device_stub__fdcalci
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r13
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$80, %rsp
	.cfi_def_cfa_offset 128
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r13, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	leaq	12(%rsp), %rax
	movl	%edi, (%rax)
	leaq	16(%rsp), %rbx
	movq	%rax, (%rbx)
	leaq	64(%rsp), %r14
	leaq	48(%rsp), %r15
	leaq	40(%rsp), %r12
	leaq	32(%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	$_Z6fdcalci, %edi
	movq	%rbx, %r9
	pushq	(%r13)
	.cfi_adjust_cfa_offset 8
	pushq	(%r12)
	.cfi_adjust_cfa_offset 8
	callq	hipLaunchKernel
	addq	$96, %rsp
	.cfi_adjust_cfa_offset -96
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end2:
	.size	_Z21__device_stub__fdcalci, .Lfunc_end2-_Z21__device_stub__fdcalci
	.cfi_endproc
                                        # -- End function
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI3_0:
	.quad	0x412e848000000000              # double 1.0E+6
.LCPI3_1:
	.quad	0x4000000000000000              # double 2
.LCPI3_2:
	.quad	0x3ff0000000000000              # double 1
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r13
	.cfi_def_cfa_offset 40
	pushq	%r12
	.cfi_def_cfa_offset 48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	.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	$4, %edi
	jne	.LBB3_2
# %bb.1:
	movq	%rsi, %rbx
	movq	8(%rsi), %rdi
	callq	atoi
	movl	%eax, %r14d
	movq	16(%rbx), %rdi
	callq	atoi
	movl	%eax, %ebp
	movq	24(%rbx), %rdi
	callq	atoi
	movl	%eax, %ebx
	jmp	.LBB3_3
.LBB3_2:
	movl	$.Lstr, %edi
	callq	puts@PLT
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	movl	$1, %r14d
	movl	$400, %ebx                      # imm = 0x190
	movl	$.L.str.2, %edi
	movl	$1, %esi
	movl	$400, %edx                      # imm = 0x190
	movl	$400, %ecx                      # imm = 0x190
	xorl	%eax, %eax
	callq	printf
	movl	$400, %ebp                      # imm = 0x190
.LBB3_3:
	movabsq	$4294967296, %r13               # imm = 0x100000000
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	leaq	8(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	cvtsi2sdq	(%r15), %xmm0
	cvtsi2sdq	8(%r15), %xmm1
	divsd	.LCPI3_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, (%rsp)                   # 8-byte Spill
	leaq	1(%r13), %rdi
	movl	$1, %esi
	movq	%rdi, %rdx
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_5
# %bb.4:
	movl	%ebx, %edi
	callq	_Z21__device_stub__fdcalci
.LBB3_5:
	callq	hipDeviceSynchronize
	xorl	%r12d, %r12d
	leaq	8(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%r15), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%r15), %xmm1
	divsd	.LCPI3_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	subsd	(%rsp), %xmm1                   # 8-byte Folded Reload
	movsd	%xmm1, (%rsp)                   # 8-byte Spill
	movl	$10, %edi
	callq	putchar@PLT
	movl	$.L.str.5, %edi
	movsd	(%rsp), %xmm0                   # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	movl	$.L.str.6, %edi
	movl	%r14d, %esi
	movl	%ebp, %edx
	xorl	%eax, %eax
	callq	printf
	leaq	8(%rsp), %r15
	movq	%r15, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%r15), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%r15), %xmm1
	divsd	.LCPI3_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, (%rsp)                   # 8-byte Spill
	movl	%r14d, %edi
	orq	%r13, %rdi
	movl	%ebp, %edx
	orq	%r13, %rdx
	movl	$1, %esi
	movl	$1, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	callq	__hipPushCallConfiguration
	testl	%eax, %eax
	jne	.LBB3_7
# %bb.6:
	movl	%ebx, %eax
	cltd
	idivl	%ebp
	movl	%eax, %edi
	callq	_Z21__device_stub__fdcalci
.LBB3_7:
	callq	hipDeviceSynchronize
	leaq	8(%rsp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%r14), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%r14), %xmm1
	divsd	.LCPI3_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	subsd	(%rsp), %xmm1                   # 8-byte Folded Reload
	movsd	%xmm1, (%rsp)                   # 8-byte Spill
	movl	$10, %edi
	callq	putchar@PLT
	movl	$.L.str.5, %edi
	movsd	(%rsp), %xmm0                   # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	movl	$.Lstr.3, %edi
	callq	puts@PLT
	leaq	8(%rsp), %r14
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	movq	(%r14), %r15
	movq	8(%r14), %r14
	leal	-2(%rbx), %ebp
	xorps	%xmm0, %xmm0
.LBB3_8:                                # %.preheader.i
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB3_10 Depth 2
	cmpl	$3, %ebx
	jl	.LBB3_11
# %bb.9:                                # %.lr.ph.i.preheader
                                        #   in Loop: Header=BB3_8 Depth=1
	movl	%ebp, %r13d
	movsd	.LCPI3_1(%rip), %xmm1           # xmm1 = mem[0],zero
.LBB3_10:                               # %.lr.ph.i
                                        #   Parent Loop BB3_8 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movsd	%xmm1, (%rsp)                   # 8-byte Spill
	movsd	(%rsp), %xmm1                   # 8-byte Reload
                                        # xmm1 = mem[0],zero
	callq	pow
	movsd	.LCPI3_2(%rip), %xmm1           # xmm1 = mem[0],zero
	movsd	(%rsp), %xmm2                   # 8-byte Reload
                                        # xmm2 = mem[0],zero
	addsd	%xmm1, %xmm2
	movsd	%xmm2, (%rsp)                   # 8-byte Spill
	movsd	(%rsp), %xmm1                   # 8-byte Reload
                                        # xmm1 = mem[0],zero
	decl	%r13d
	jne	.LBB3_10
.LBB3_11:                               # %._crit_edge.i
                                        #   in Loop: Header=BB3_8 Depth=1
	incl	%r12d
	cmpl	$10000, %r12d                   # imm = 0x2710
	jne	.LBB3_8
# %bb.12:                               # %_Z6fhcalci.exit
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r14, %xmm0
	movsd	.LCPI3_0(%rip), %xmm1           # xmm1 = mem[0],zero
	divsd	%xmm1, %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sd	%r15, %xmm1
	addsd	%xmm0, %xmm1
	movsd	%xmm1, (%rsp)                   # 8-byte Spill
	callq	hipDeviceSynchronize
	leaq	8(%rsp), %rbx
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	gettimeofday
	xorps	%xmm0, %xmm0
	cvtsi2sdq	(%rbx), %xmm0
	xorps	%xmm1, %xmm1
	cvtsi2sdq	8(%rbx), %xmm1
	divsd	.LCPI3_0(%rip), %xmm1
	addsd	%xmm0, %xmm1
	subsd	(%rsp), %xmm1                   # 8-byte Folded Reload
	movsd	%xmm1, (%rsp)                   # 8-byte Spill
	movl	$10, %edi
	callq	putchar@PLT
	movl	$.L.str.5, %edi
	movsd	(%rsp), %xmm0                   # 8-byte Reload
                                        # xmm0 = mem[0],zero
	movb	$1, %al
	callq	printf
	xorl	%eax, %eax
	addq	$24, %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_end3:
	.size	main, .Lfunc_end3-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	.LBB4_2
# %bb.1:
	movl	$__hip_fatbin_wrapper, %edi
	callq	__hipRegisterFatBinary
	movq	%rax, %rdi
	movq	%rax, __hip_gpubin_handle(%rip)
.LBB4_2:
	xorps	%xmm0, %xmm0
	movups	%xmm0, 16(%rsp)
	movups	%xmm0, (%rsp)
	movl	$_Z6fdcalci, %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_end4:
	.size	__hip_module_ctor, .Lfunc_end4-__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	.LBB5_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
.LBB5_2:
	retq
.Lfunc_end5:
	.size	__hip_module_dtor, .Lfunc_end5-__hip_module_dtor
	.cfi_endproc
                                        # -- End function
	.type	_Z6fdcalci,@object              # @_Z6fdcalci
	.section	.rodata,"a",@progbits
	.globl	_Z6fdcalci
	.p2align	3, 0x0
_Z6fdcalci:
	.quad	_Z21__device_stub__fdcalci
	.size	_Z6fdcalci, 8

	.type	.L.str.2,@object                # @.str.2
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.2:
	.asciz	"Caso n\303\243o haja passagem de par\303\242metros, atribuiu-se:\n(1) nblocos c/ %d, nthreads definido c/ %d e ncalc = %d \n"
	.size	.L.str.2, 111

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"\tRuntime: %f\n"
	.size	.L.str.5, 14

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"\n##### DEVICE (%d,%d) #####\n"
	.size	.L.str.6, 29

	.type	.L__unnamed_1,@object           # @0
.L__unnamed_1:
	.asciz	"_Z6fdcalci"
	.size	.L__unnamed_1, 11

	.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	"\n ############# "
	.size	.Lstr, 17

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"./05_proc <nblocos> <nthreads> <nloop>"
	.size	.Lstr.1, 39

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"\n##### DEVICE (1,1) #####"
	.size	.Lstr.2, 26

	.type	.Lstr.3,@object                 # @str.3
.Lstr.3:
	.asciz	"\n##### HOST #####"
	.size	.Lstr.3, 18

	.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__fdcalci
	.addrsig_sym __hip_module_ctor
	.addrsig_sym __hip_module_dtor
	.addrsig_sym _Z6fdcalci
	.addrsig_sym __hip_fatbin
	.addrsig_sym __hip_fatbin_wrapper
	.addrsig_sym __hip_cuid_

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

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

	.end_amdgpu_metadata
