#include <cufft.h>

#include <iostream>
#include <complex>

// #define DATA_LEN 1024
// #define ITERATION 100000

int main(int argc, char **argv)
{
	if (argc != 3)
	{
		std::cout << "Usage: " << argv[0] << " [DATA_LEN] [ITERATION]" << std::endl;
		return 1;
	}
	int DATA_LEN = atoi(argv[1]);
	int ITERATION = atoi(argv[2]);
	// Siapkan memory untuk input data di Host
	// cufftComplex *t_HostInputData = (cufftComplex*)malloc(sizeof(cufftComplex)*DATA_LEN*1);
	cufftComplex *t_HostInputData;
	cudaError_t status = cudaMallocHost((void**)&t_HostInputData, sizeof(cufftComplex)*DATA_LEN*1);
	for(int i=0; i < DATA_LEN; i++)
	{
		t_HostInputData[i].x = 1.0;
		t_HostInputData[i].y = 1.0;
	}

	// for(int i=0; i < DATA_LEN; i++)
	// {
	// 	std::cout << t_HostInputData[i].x << " + i" << t_HostInputData[i].y << std::endl;
	// }
	// std::cout << std::endl;

	// Siapkan memory untuk data di GPU
	cufftComplex *t_InputData;
	cufftComplex *t_OutputData;
	cudaMalloc((void**)&t_InputData, sizeof(cufftComplex)*DATA_LEN*1);
	cudaMalloc((void**)&t_OutputData, sizeof(cufftComplex)*DATA_LEN*1);
	if (cudaGetLastError() != cudaSuccess)
	{
		std::cout << "Cuda error: Failed to allocate" << std::endl;
		return 1;
	}
	cudaMemset(t_InputData, 0, DATA_LEN);
	cudaMemcpy(t_InputData, t_HostInputData, sizeof(cufftComplex)*DATA_LEN*1, cudaMemcpyHostToDevice);
	cudaMemset(t_OutputData, 0, DATA_LEN);

	// FFT plan
	cufftHandle t_Plan;
	if (cufftPlan1d(&t_Plan, DATA_LEN, CUFFT_C2C, 1) != CUFFT_SUCCESS)
	{
			std::cout << "CUFFT error: Plan creation failed" << std::endl;
			return 1;
	}

	cudaEvent_t start, end;
	cudaEventCreate(&start);
	cudaEventCreate(&end);
	float elapsedTime;
	cudaEventRecord(start, 0);

	// Execute FFT Forward operation
	for(int i=0; i < ITERATION; i++)
	{
		if (cufftExecC2C(t_Plan, t_InputData, t_OutputData, CUFFT_FORWARD) != CUFFT_SUCCESS)
		{
			std::cout << "CUFFT error: ExecC2C Forward failed" << std::endl;
			return 1;
		}
	}

	cudaEventRecord(end, 0);
	cudaEventSynchronize(end);
	cudaEventElapsedTime(&elapsedTime, start, end);
	printf("%d times for the FFT: %fms\n", ITERATION, elapsedTime);

	// // Execute FFT Backward / IFFT operation
	// if (cufftExecC2C(t_Plan, t_OutputData, t_InputData, CUFFT_INVERSE) != CUFFT_SUCCESS)
	// {
	// 	std::cout << "CUFFT error: ExecC2C Forward failed" << std::endl;
	// 	return 1;
	// }

	// Synchro
	if (cudaDeviceSynchronize() != cudaSuccess)
	{
		std::cout << "Cuda error: Failed to synchronize" << std::endl;
		return 1;
	}

	// Siapkan host memory untuk menerima result FFT dari GPU
	cufftComplex *t_HostData = (cufftComplex*)malloc(sizeof(cufftComplex)*DATA_LEN*1);

	// Copy from GPU to host memroy
	cudaMemcpy(t_HostData, t_OutputData, sizeof(cufftComplex)*DATA_LEN*1, cudaMemcpyDeviceToHost);

	// Display data
	// for(int i=0; i < DATA_LEN; i++)
	// {
	// 	std::cout << t_HostData[i].x << " + i" << t_HostData[i].y << std::endl;
	// }

	// Cleaning stuff
	cufftDestroy(t_Plan);
	cudaFree(t_InputData);
	cudaFree(t_OutputData);
	cudaFreeHost(t_HostInputData);

	return 0;
}

	.file	"tmpxft_0034f336_00000000-6_cufftTest.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3962:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3962:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.type	_ZNSolsEPFRSoS_E.isra.0, @function
_ZNSolsEPFRSoS_E.isra.0:
.LFB4613:
	.cfi_startproc
	jmp	*%rsi
	.cfi_endproc
.LFE4613:
	.size	_ZNSolsEPFRSoS_E.isra.0, .-_ZNSolsEPFRSoS_E.isra.0
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"Usage: "
.LC1:
	.string	" [DATA_LEN] [ITERATION]"
.LC3:
	.string	"Cuda error: Failed to allocate"
.LC4:
	.string	"CUFFT error: Plan creation failed"
.LC5:
	.string	"CUFFT error: ExecC2C Forward failed"
.LC6:
	.string	"%d times for the FFT: %fms\n"
.LC7:
	.string	"Cuda error: Failed to synchronize"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB3959:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rsi, %rbx
	subq	$72, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	cmpl	$3, %edi
	je	.L4
	leaq	.LC0(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	(%rbx), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	leaq	.LC1(%rip), %rsi
	movq	%rax, %rdi
	jmp	.L17
.L4:
	movq	8(%rsi), %rdi
	call	atoi@PLT
	movq	16(%rbx), %rdi
	movslq	%eax, %r13
	call	atoi@PLT
	leaq	0(,%r13,8), %rbx
	leaq	16(%rsp), %rdi
	movq	%r13, %rbp
	movq	%rbx, %rsi
	movl	%eax, %r12d
	call	cudaMallocHost@PLT
	movq	16(%rsp), %rdx
	movss	.LC2(%rip), %xmm0
	xorl	%eax, %eax
.L6:
	cmpl	%eax, %ebp
	jle	.L20
	movss	%xmm0, (%rdx,%rax,8)
	movss	%xmm0, 4(%rdx,%rax,8)
	incq	%rax
	jmp	.L6
.L20:
	leaq	24(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	leaq	32(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	call	cudaGetLastError@PLT
	testl	%eax, %eax
	je	.L8
	leaq	.LC3(%rip), %rsi
.L18:
	leaq	_ZSt4cout(%rip), %rdi
.L17:
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@GOTPCREL(%rip), %rsi
	movq	%rax, %rdi
	call	_ZNSolsEPFRSoS_E.isra.0
	movl	$1, %eax
	jmp	.L3
.L8:
	movq	24(%rsp), %rdi
	movq	%r13, %rdx
	xorl	%esi, %esi
	call	cudaMemset@PLT
	movq	16(%rsp), %rsi
	movq	24(%rsp), %rdi
	movq	%rbx, %rdx
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	movq	32(%rsp), %rdi
	movq	%r13, %rdx
	xorl	%esi, %esi
	call	cudaMemset@PLT
	movl	%ebp, %esi
	leaq	8(%rsp), %rdi
	movl	$1, %ecx
	movl	$41, %edx
	call	cufftPlan1d@PLT
	leaq	.LC4(%rip), %rsi
	testl	%eax, %eax
	jne	.L18
	leaq	40(%rsp), %rdi
	xorl	%ebp, %ebp
	call	cudaEventCreate@PLT
	leaq	48(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	40(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
.L11:
	cmpl	%r12d, %ebp
	jge	.L21
	movq	32(%rsp), %rdx
	movq	24(%rsp), %rsi
	orl	$-1, %ecx
	movl	8(%rsp), %edi
	call	cufftExecC2C@PLT
	testl	%eax, %eax
	je	.L12
	leaq	.LC5(%rip), %rsi
	jmp	.L18
.L12:
	incl	%ebp
	jmp	.L11
.L21:
	movq	48(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	48(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	48(%rsp), %rdx
	movq	40(%rsp), %rsi
	leaq	12(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	movl	%r12d, %edx
	movl	$2, %edi
	movb	$1, %al
	leaq	.LC6(%rip), %rsi
	cvtss2sd	12(%rsp), %xmm0
	call	__printf_chk@PLT
	call	cudaDeviceSynchronize@PLT
	leaq	.LC7(%rip), %rsi
	testl	%eax, %eax
	jne	.L18
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	32(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdx
	movq	%rax, %rdi
	call	cudaMemcpy@PLT
	movl	8(%rsp), %edi
	call	cufftDestroy@PLT
	movq	24(%rsp), %rdi
	call	cudaFree@PLT
	movq	32(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFreeHost@PLT
	xorl	%eax, %eax
.L3:
	movq	56(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	addq	$72, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3959:
	.size	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3985:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	leaq	_ZL15__fatDeviceText(%rip), %rdi
	call	__cudaRegisterFatBinary@PLT
	movq	%rax, %rdi
	movq	%rax, _ZL20__cudaFatCubinHandle(%rip)
	call	__cudaRegisterFatBinaryEnd@PLT
	leaq	_ZL26__cudaUnregisterBinaryUtilv(%rip), %rdi
	popq	%rdx
	.cfi_def_cfa_offset 8
	jmp	atexit@PLT
	.cfi_endproc
.LFE3985:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst4,"aM",@progbits,4
	.align 4
.LC2:
	.long	1065353216
	.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 <hipfft/hipfft.h>

#include <iostream>
#include <complex>

// #define DATA_LEN 1024
// #define ITERATION 100000

int main(int argc, char **argv)
{
	if (argc != 3)
	{
		std::cout << "Usage: " << argv[0] << " [DATA_LEN] [ITERATION]" << std::endl;
		return 1;
	}
	int DATA_LEN = atoi(argv[1]);
	int ITERATION = atoi(argv[2]);
	// Siapkan memory untuk input data di Host
	// cufftComplex *t_HostInputData = (cufftComplex*)malloc(sizeof(cufftComplex)*DATA_LEN*1);
	hipfftComplex *t_HostInputData;
	hipError_t status = hipHostMalloc((void**)&t_HostInputData, sizeof(hipfftComplex)*DATA_LEN*1, hipHostMallocDefault);
	for(int i=0; i < DATA_LEN; i++)
	{
		t_HostInputData[i].x = 1.0;
		t_HostInputData[i].y = 1.0;
	}

	// for(int i=0; i < DATA_LEN; i++)
	// {
	// 	std::cout << t_HostInputData[i].x << " + i" << t_HostInputData[i].y << std::endl;
	// }
	// std::cout << std::endl;

	// Siapkan memory untuk data di GPU
	hipfftComplex *t_InputData;
	hipfftComplex *t_OutputData;
	hipMalloc((void**)&t_InputData, sizeof(hipfftComplex)*DATA_LEN*1);
	hipMalloc((void**)&t_OutputData, sizeof(hipfftComplex)*DATA_LEN*1);
	if (hipGetLastError() != hipSuccess)
	{
		std::cout << "Cuda error: Failed to allocate" << std::endl;
		return 1;
	}
	hipMemset(t_InputData, 0, DATA_LEN);
	hipMemcpy(t_InputData, t_HostInputData, sizeof(hipfftComplex)*DATA_LEN*1, hipMemcpyHostToDevice);
	hipMemset(t_OutputData, 0, DATA_LEN);

	// FFT plan
	hipfftHandle t_Plan;
	if (hipfftPlan1d(&t_Plan, DATA_LEN, HIPFFT_C2C, 1) != HIPFFT_SUCCESS)
	{
			std::cout << "CUFFT error: Plan creation failed" << std::endl;
			return 1;
	}

	hipEvent_t start, end;
	hipEventCreate(&start);
	hipEventCreate(&end);
	float elapsedTime;
	hipEventRecord(start, 0);

	// Execute FFT Forward operation
	for(int i=0; i < ITERATION; i++)
	{
		if (hipfftExecC2C(t_Plan, t_InputData, t_OutputData, HIPFFT_FORWARD) != HIPFFT_SUCCESS)
		{
			std::cout << "CUFFT error: ExecC2C Forward failed" << std::endl;
			return 1;
		}
	}

	hipEventRecord(end, 0);
	hipEventSynchronize(end);
	hipEventElapsedTime(&elapsedTime, start, end);
	printf("%d times for the FFT: %fms\n", ITERATION, elapsedTime);

	// // Execute FFT Backward / IFFT operation
	// if (cufftExecC2C(t_Plan, t_OutputData, t_InputData, CUFFT_INVERSE) != CUFFT_SUCCESS)
	// {
	// 	std::cout << "CUFFT error: ExecC2C Forward failed" << std::endl;
	// 	return 1;
	// }

	// Synchro
	if (hipDeviceSynchronize() != hipSuccess)
	{
		std::cout << "Cuda error: Failed to synchronize" << std::endl;
		return 1;
	}

	// Siapkan host memory untuk menerima result FFT dari GPU
	hipfftComplex *t_HostData = (hipfftComplex*)malloc(sizeof(hipfftComplex)*DATA_LEN*1);

	// Copy from GPU to host memroy
	hipMemcpy(t_HostData, t_OutputData, sizeof(hipfftComplex)*DATA_LEN*1, hipMemcpyDeviceToHost);

	// Display data
	// for(int i=0; i < DATA_LEN; i++)
	// {
	// 	std::cout << t_HostData[i].x << " + i" << t_HostData[i].y << std::endl;
	// }

	// Cleaning stuff
	hipfftDestroy(t_Plan);
	hipFree(t_InputData);
	hipFree(t_OutputData);
	hipHostFree(t_HostInputData);

	return 0;
}

	.text
	.file	"cufftTest.hip"
                                        # Start of file scope inline assembly
	.globl	_ZSt21ios_base_library_initv

                                        # End of file scope inline assembly
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movq	%rsi, %rbx
	cmpl	$3, %edi
	jne	.LBB0_1
# %bb.5:
	movq	8(%rbx), %rdi
	callq	atoi
	movl	%eax, %r14d
	movq	16(%rbx), %rdi
	callq	atoi
	movl	%eax, %ebp
	movslq	%r14d, %r15
	leaq	(,%r15,8), %rbx
	leaq	16(%rsp), %rdi
	movq	%rbx, %rsi
	xorl	%edx, %edx
	callq	hipHostMalloc
	testl	%r15d, %r15d
	jle	.LBB0_8
# %bb.6:                                # %.lr.ph.preheader
	movl	%r14d, %eax
	xorl	%ecx, %ecx
	movl	$1065353216, %edx               # imm = 0x3F800000
.LBB0_7:                                # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movq	16(%rsp), %rsi
	movl	%edx, (%rsi,%rcx,8)
	movq	16(%rsp), %rsi
	movl	%edx, 4(%rsi,%rcx,8)
	incq	%rcx
	cmpq	%rcx, %rax
	jne	.LBB0_7
.LBB0_8:                                # %._crit_edge
	leaq	8(%rsp), %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	movq	%rsp, %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	callq	hipGetLastError
	testl	%eax, %eax
	je	.LBB0_10
# %bb.9:
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$30, %edx
	jmp	.LBB0_17
.LBB0_1:
	movl	$_ZSt4cout, %edi
	movl	$.L.str, %esi
	movl	$7, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%rbx), %rbx
	testq	%rbx, %rbx
	je	.LBB0_2
# %bb.3:
	movq	%rbx, %rdi
	callq	strlen
	movl	$_ZSt4cout, %edi
	movq	%rbx, %rsi
	movq	%rax, %rdx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	jmp	.LBB0_4
.LBB0_10:
	movq	8(%rsp), %rdi
	xorl	%esi, %esi
	movq	%r15, %rdx
	callq	hipMemset
	movq	8(%rsp), %rdi
	movq	16(%rsp), %rsi
	movl	$1, %r14d
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	movq	(%rsp), %rdi
	xorl	%esi, %esi
	movq	%r15, %rdx
	callq	hipMemset
	leaq	32(%rsp), %rdi
	movl	%r15d, %esi
	movl	$41, %edx
	movl	$1, %ecx
	callq	hipfftPlan1d
	testl	%eax, %eax
	je	.LBB0_12
# %bb.11:
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.3, %esi
	movl	$33, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	jmp	.LBB0_21
.LBB0_2:
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rax
	leaq	_ZSt4cout(%rax), %rdi
	movl	32(%rdi), %esi
	orl	$1, %esi
	callq	_ZNSt9basic_iosIcSt11char_traitsIcEE5clearESt12_Ios_Iostate
.LBB0_4:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$23, %edx
.LBB0_17:
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	_ZSt4cout(%rip), %rax
	movq	-24(%rax), %rdi
	addq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
	movl	$1, %r14d
.LBB0_21:
	movl	%r14d, %eax
	addq	$56, %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
.LBB0_12:
	.cfi_def_cfa_offset 96
	leaq	40(%rsp), %r14
	movq	%r14, %rdi
	callq	hipEventCreate
	leaq	24(%rsp), %rdi
	callq	hipEventCreate
	movq	(%r14), %rdi
	xorl	%esi, %esi
	callq	hipEventRecord
	testl	%ebp, %ebp
	jle	.LBB0_18
# %bb.13:
	movl	%ebp, %r14d
.LBB0_15:                               # %.lr.ph38
                                        # =>This Inner Loop Header: Depth=1
	movq	32(%rsp), %rdi
	movq	8(%rsp), %rsi
	movq	(%rsp), %rdx
	movl	$-1, %ecx
	callq	hipfftExecC2C
	testl	%eax, %eax
	jne	.LBB0_16
# %bb.14:                               #   in Loop: Header=BB0_15 Depth=1
	decl	%r14d
	jne	.LBB0_15
.LBB0_18:                               # %._crit_edge39
	movq	24(%rsp), %rdi
	xorl	%r14d, %r14d
	xorl	%esi, %esi
	callq	hipEventRecord
	movq	24(%rsp), %rdi
	callq	hipEventSynchronize
	movq	40(%rsp), %rsi
	movq	24(%rsp), %rdx
	leaq	52(%rsp), %r15
	movq	%r15, %rdi
	callq	hipEventElapsedTime
	cvtss2sd	(%r15), %xmm0
	movl	$.L.str.5, %edi
	movl	%ebp, %esi
	movb	$1, %al
	callq	printf
	callq	hipDeviceSynchronize
	testl	%eax, %eax
	je	.LBB0_20
# %bb.19:
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.6, %esi
	movl	$33, %edx
	jmp	.LBB0_17
.LBB0_16:                               # %.thread
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.4, %esi
	movl	$35, %edx
	jmp	.LBB0_17
.LBB0_20:
	movq	%rbx, %rdi
	callq	malloc
	movq	(%rsp), %rsi
	movq	%rax, %rdi
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	movq	32(%rsp), %rdi
	callq	hipfftDestroy
	movq	8(%rsp), %rdi
	callq	hipFree
	movq	(%rsp), %rdi
	callq	hipFree
	movq	16(%rsp), %rdi
	callq	hipHostFree
	jmp	.LBB0_21
.Lfunc_end0:
	.size	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"Usage: "
	.size	.L.str, 8

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	" [DATA_LEN] [ITERATION]"
	.size	.L.str.1, 24

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"Cuda error: Failed to allocate"
	.size	.L.str.2, 31

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"CUFFT error: Plan creation failed"
	.size	.L.str.3, 34

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"CUFFT error: ExecC2C Forward failed"
	.size	.L.str.4, 36

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"%d times for the FFT: %fms\n"
	.size	.L.str.5, 28

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"Cuda error: Failed to synchronize"
	.size	.L.str.6, 34

	.type	__hip_cuid_,@object             # @__hip_cuid_
	.bss
	.globl	__hip_cuid_
__hip_cuid_:
	.byte	0                               # 0x0
	.size	__hip_cuid_, 1

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

	.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_
	.amdgcn_target "amdgcn-amd-amdhsa--gfx1100"
	.amdgpu_metadata
---
amdhsa.kernels:  []
amdhsa.target:   amdgcn-amd-amdhsa--gfx1100
amdhsa.version:
  - 1
  - 2
...

	.end_amdgpu_metadata
