#include <cuda.h>
#include <cufft.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

#define FFTSIZE 8
#define BATCH 2

/********************/
/* CUDA ERROR CHECK */
/********************/
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line, bool abort=true)
{
	if (code != cudaSuccess) 
	{
		fprintf(stderr,"GPUassert: %s %s %d\n", cudaGetErrorString(code), file, line);
		if (abort) exit(code);
	}
}

/********/
/* MAIN */
/********/
int main (int argc, char* argv[])
{
	if(argc != 2) {
		printf("Please specify 1 (plan1d) or 2 (planmany).\n");	
		return -1;
	};

	int N = FFTSIZE;
	N = N + 2;

	// --- Host side input data allocation and initialization
	cufftReal *hostInputData = (cufftReal*)malloc(N*BATCH*sizeof(cufftReal));
	for (int i=0; i<BATCH; i++) {
		for (int j=0; j<N; j++){
			//hostInputData[i*FFTSIZE + j] = (cufftReal)(j + 1);
			//hostInputData[i*FFTSIZE + j] = 100.f; 
			hostInputData[i*N+ j] = (float)(j % 10); 
			printf("%f ", hostInputData[i*N + j]);
		}
		printf("\n");
	}
	printf("\n");

	// --- Device side input data allocation and initialization
	cufftReal *deviceInputData;
	gpuErrchk(cudaMalloc((void**)&deviceInputData, N * BATCH * sizeof(cufftReal)));
	cudaMemcpy(deviceInputData, hostInputData, N * BATCH * sizeof(cufftReal), cudaMemcpyHostToDevice);

	// --- Host side output data allocation
	cufftComplex *hostOutputData = (cufftComplex*)malloc((FFTSIZE / 2 + 1) * BATCH * sizeof(cufftComplex));

	// --- Device side output data allocation
	cufftComplex *deviceOutputData; gpuErrchk(cudaMalloc((void**)&deviceOutputData, (FFTSIZE / 2 + 1) * BATCH * sizeof(cufftComplex)));

	// --- Batched 1D FFTs
	cufftHandle handle;
	int rank = 1;                           // --- 1D FFTs
	int n[] = { FFTSIZE };                 // --- Size of the Fourier transform
	int istride = 1, ostride = 1;           // --- Distance between two successive input/output elements
	int idist = FFTSIZE, odist = (FFTSIZE / 2 + 1); // --- Distance between batches
	int inembed[] = { 0 };                  // --- Input size with pitch (ignored for 1D transforms)
	int onembed[] = { 0 };                  // --- Output size with pitch (ignored for 1D transforms)
	int batch = BATCH;                      // --- Number of batched executions


	int plantype = atoi(argv[1]);

	if(plantype == 1) {
		printf("cufftplan1d\n");
		cufftPlan1d(&handle, FFTSIZE, CUFFT_R2C, BATCH);
	}

	if(plantype == 2) {
		printf("cufftplan2d\n");
		cufftPlanMany(&handle, rank, n, 
				inembed, istride, idist,
				onembed, ostride, odist, CUFFT_R2C, batch);
	}


	cufftExecR2C(handle,  deviceInputData, deviceOutputData);

	// --- Device->Host copy of the results
	gpuErrchk(cudaMemcpy(hostOutputData, deviceOutputData, (FFTSIZE / 2 + 1) * BATCH * sizeof(cufftComplex), cudaMemcpyDeviceToHost));

	for (int i=0; i<BATCH; i++)
		for (int j=0; j<(FFTSIZE / 2 + 1); j++)
			printf("%i %i %f %f\n", i, j, hostOutputData[i*(FFTSIZE / 2 + 1) + j].x, hostOutputData[i*(FFTSIZE / 2 + 1) + j].y);

	cufftDestroy(handle);
	gpuErrchk(cudaFree(deviceOutputData));
	gpuErrchk(cudaFree(deviceInputData));

}

	.file	"tmpxft_00241a02_00000000-6_test1_planmany.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2054:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2054:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata._Z9gpuAssert9cudaErrorPKcib.str1.1,"aMS",@progbits,1
.LC0:
	.string	"GPUassert: %s %s %d\n"
	.section	.text._Z9gpuAssert9cudaErrorPKcib,"axG",@progbits,_Z9gpuAssert9cudaErrorPKcib,comdat
	.weak	_Z9gpuAssert9cudaErrorPKcib
	.type	_Z9gpuAssert9cudaErrorPKcib, @function
_Z9gpuAssert9cudaErrorPKcib:
.LFB2050:
	.cfi_startproc
	endbr64
	testl	%edi, %edi
	je	.L8
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	%ecx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movl	%edi, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	movl	%edx, 12(%rsp)
	movq	%rsi, (%rsp)
	call	cudaGetErrorString@PLT
	movl	12(%rsp), %r9d
	movq	(%rsp), %r8
	leaq	.LC0(%rip), %rdx
	movq	stderr(%rip), %rdi
	movq	%rax, %rcx
	movl	$2, %esi
	xorl	%eax, %eax
	call	__fprintf_chk@PLT
	testb	%bpl, %bpl
	je	.L2
	movl	%ebx, %edi
	call	exit@PLT
.L2:
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L8:
	.cfi_restore 3
	.cfi_restore 6
	ret
	.cfi_endproc
.LFE2050:
	.size	_Z9gpuAssert9cudaErrorPKcib, .-_Z9gpuAssert9cudaErrorPKcib
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"Please specify 1 (plan1d) or 2 (planmany).\n"
.LC2:
	.string	"%f "
.LC3:
	.string	"\n"
.LC4:
	.string	"/home/ubuntu/Datasets/stackv2/train-structured/leimingyu/cuda_fft/master/cufft/tests/test1_planmany.cu"
.LC5:
	.string	"cufftplan1d\n"
.LC6:
	.string	"cufftplan2d\n"
.LC7:
	.string	"%i %i %f %f\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2051:
	.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
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	cmpl	$2, %edi
	je	.L13
	leaq	.LC1(%rip), %rsi
	movl	$2, %edi
	call	__printf_chk@PLT
	orl	$-1, %eax
	jmp	.L12
.L13:
	movl	$80, %edi
	movq	%rsi, %r13
	xorl	%ebp, %ebp
	call	malloc@PLT
	leaq	.LC2(%rip), %r12
	movq	%rax, %rbx
.L15:
	cvtsi2ssl	%ebp, %xmm0
	movq	%r12, %rsi
	movl	$2, %edi
	movb	$1, %al
	movss	%xmm0, (%rbx,%rbp,4)
	incq	%rbp
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	cmpq	$10, %rbp
	jne	.L15
	leaq	.LC3(%rip), %r14
	movl	$2, %edi
	xorl	%eax, %eax
	xorl	%ebp, %ebp
	movq	%r14, %rsi
	call	__printf_chk@PLT
.L16:
	cvtsi2ssl	%ebp, %xmm0
	movq	%r12, %rsi
	movl	$2, %edi
	movb	$1, %al
	movss	%xmm0, 40(%rbx,%rbp,4)
	incq	%rbp
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	cmpq	$10, %rbp
	jne	.L16
	movq	%r14, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	%r14, %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	8(%rsp), %rdi
	movl	$80, %esi
	leaq	.LC4(%rip), %r12
	call	cudaMalloc@PLT
	movl	$1, %ecx
	movl	$51, %edx
	movq	%r12, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	8(%rsp), %rdi
	movl	$1, %ecx
	movq	%rbx, %rsi
	movl	$80, %edx
	call	cudaMemcpy@PLT
	movl	$80, %edi
	call	malloc@PLT
	leaq	16(%rsp), %rdi
	movl	$80, %esi
	movq	%rax, %rbx
	call	cudaMalloc@PLT
	movl	$58, %edx
	movl	$1, %ecx
	movq	%r12, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	8(%r13), %rdi
	xorl	%edx, %edx
	movl	$8, 28(%rsp)
	movl	%edx, 32(%rsp)
	movl	%edx, 36(%rsp)
	call	atoi@PLT
	cmpl	$1, %eax
	jne	.L17
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	4(%rsp), %rdi
	movl	$2, %ecx
	movl	$42, %edx
	movl	$8, %esi
	call	cufftPlan1d@PLT
	jmp	.L18
.L17:
	cmpl	$2, %eax
	jne	.L18
	leaq	.LC6(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	leaq	32(%rsp), %rcx
	leaq	28(%rsp), %rdx
	movl	$8, %r9d
	leaq	4(%rsp), %rdi
	pushq	%rax
	.cfi_def_cfa_offset 104
	movl	$1, %r8d
	movl	$1, %esi
	pushq	$2
	.cfi_def_cfa_offset 112
	pushq	$42
	.cfi_def_cfa_offset 120
	pushq	$5
	.cfi_def_cfa_offset 128
	pushq	$1
	.cfi_def_cfa_offset 136
	leaq	76(%rsp), %rax
	pushq	%rax
	.cfi_def_cfa_offset 144
	call	cufftPlanMany@PLT
	addq	$48, %rsp
	.cfi_def_cfa_offset 96
.L18:
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rsi
	xorl	%ebp, %ebp
	leaq	.LC7(%rip), %r13
	movl	4(%rsp), %edi
	call	cufftExecR2C@PLT
	movq	16(%rsp), %rsi
	movl	$2, %ecx
	movq	%rbx, %rdi
	movl	$80, %edx
	call	cudaMemcpy@PLT
	movl	$1, %ecx
	movl	$89, %edx
	movq	%r12, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
.L19:
	movl	%ebp, %ecx
	cvtss2sd	(%rbx,%rbp,8), %xmm0
	xorl	%edx, %edx
	movq	%r13, %rsi
	cvtss2sd	4(%rbx,%rbp,8), %xmm1
	movl	$2, %edi
	movb	$2, %al
	incq	%rbp
	call	__printf_chk@PLT
	cmpq	$5, %rbp
	jne	.L19
	xorl	%ebp, %ebp
.L20:
	movl	%ebp, %ecx
	cvtss2sd	40(%rbx,%rbp,8), %xmm0
	cvtss2sd	44(%rbx,%rbp,8), %xmm1
	movq	%r13, %rsi
	movl	$1, %edx
	movl	$2, %edi
	movb	$2, %al
	incq	%rbp
	call	__printf_chk@PLT
	cmpq	$5, %rbp
	jne	.L20
	movl	4(%rsp), %edi
	call	cufftDestroy@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movl	$1, %ecx
	movl	$96, %edx
	movq	%r12, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movl	$1, %ecx
	movl	$97, %edx
	movq	%r12, %rsi
	movl	%eax, %edi
	call	_Z9gpuAssert9cudaErrorPKcib
	xorl	%eax, %eax
.L12:
	movq	40(%rsp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	addq	$48, %rsp
	.cfi_def_cfa_offset 48
	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
.LFE2051:
	.size	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2077:
	.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
.LFE2077:
	.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
	.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 <stdio.h>
#include <math.h>
#include <stdlib.h>

#define FFTSIZE 8
#define BATCH 2

/********************/
/* CUDA ERROR CHECK */
/********************/
#define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(hipError_t code, const char *file, int line, bool abort=true)
{
	if (code != hipSuccess) 
	{
		fprintf(stderr,"GPUassert: %s %s %d\n", hipGetErrorString(code), file, line);
		if (abort) exit(code);
	}
}

/********/
/* MAIN */
/********/
int main (int argc, char* argv[])
{
	if(argc != 2) {
		printf("Please specify 1 (plan1d) or 2 (planmany).\n");	
		return -1;
	};

	int N = FFTSIZE;
	N = N + 2;

	// --- Host side input data allocation and initialization
	hipfftReal *hostInputData = (hipfftReal*)malloc(N*BATCH*sizeof(hipfftReal));
	for (int i=0; i<BATCH; i++) {
		for (int j=0; j<N; j++){
			//hostInputData[i*FFTSIZE + j] = (cufftReal)(j + 1);
			//hostInputData[i*FFTSIZE + j] = 100.f; 
			hostInputData[i*N+ j] = (float)(j % 10); 
			printf("%f ", hostInputData[i*N + j]);
		}
		printf("\n");
	}
	printf("\n");

	// --- Device side input data allocation and initialization
	hipfftReal *deviceInputData;
	gpuErrchk(hipMalloc((void**)&deviceInputData, N * BATCH * sizeof(hipfftReal)));
	hipMemcpy(deviceInputData, hostInputData, N * BATCH * sizeof(hipfftReal), hipMemcpyHostToDevice);

	// --- Host side output data allocation
	hipfftComplex *hostOutputData = (hipfftComplex*)malloc((FFTSIZE / 2 + 1) * BATCH * sizeof(hipfftComplex));

	// --- Device side output data allocation
	hipfftComplex *deviceOutputData; gpuErrchk(hipMalloc((void**)&deviceOutputData, (FFTSIZE / 2 + 1) * BATCH * sizeof(hipfftComplex)));

	// --- Batched 1D FFTs
	hipfftHandle handle;
	int rank = 1;                           // --- 1D FFTs
	int n[] = { FFTSIZE };                 // --- Size of the Fourier transform
	int istride = 1, ostride = 1;           // --- Distance between two successive input/output elements
	int idist = FFTSIZE, odist = (FFTSIZE / 2 + 1); // --- Distance between batches
	int inembed[] = { 0 };                  // --- Input size with pitch (ignored for 1D transforms)
	int onembed[] = { 0 };                  // --- Output size with pitch (ignored for 1D transforms)
	int batch = BATCH;                      // --- Number of batched executions


	int plantype = atoi(argv[1]);

	if(plantype == 1) {
		printf("cufftplan1d\n");
		hipfftPlan1d(&handle, FFTSIZE, HIPFFT_R2C, BATCH);
	}

	if(plantype == 2) {
		printf("cufftplan2d\n");
		hipfftPlanMany(&handle, rank, n, 
				inembed, istride, idist,
				onembed, ostride, odist, HIPFFT_R2C, batch);
	}


	hipfftExecR2C(handle,  deviceInputData, deviceOutputData);

	// --- Device->Host copy of the results
	gpuErrchk(hipMemcpy(hostOutputData, deviceOutputData, (FFTSIZE / 2 + 1) * BATCH * sizeof(hipfftComplex), hipMemcpyDeviceToHost));

	for (int i=0; i<BATCH; i++)
		for (int j=0; j<(FFTSIZE / 2 + 1); j++)
			printf("%i %i %f %f\n", i, j, hostOutputData[i*(FFTSIZE / 2 + 1) + j].x, hostOutputData[i*(FFTSIZE / 2 + 1) + j].y);

	hipfftDestroy(handle);
	gpuErrchk(hipFree(deviceOutputData));
	gpuErrchk(hipFree(deviceInputData));

}

	.text
	.file	"test1_planmany.hip"
	.globl	main                            # -- Begin function main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$48, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	cmpl	$2, %edi
	jne	.LBB0_1
# %bb.2:
	movq	%rsi, %r14
	movl	$80, %edi
	callq	malloc
	movq	%rax, %rbx
	movb	$1, %bpl
	xorl	%eax, %eax
.LBB0_3:                                # %.preheader57
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_4 Depth 2
	leaq	(%rbx,%rax,4), %r15
	xorl	%r12d, %r12d
.LBB0_4:                                #   Parent Loop BB0_3 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtsi2ss	%r12d, %xmm0
	movss	%xmm0, (%r15,%r12,4)
	xorps	%xmm0, %xmm0
	cvtsi2sd	%r12d, %xmm0
	movl	$.L.str.1, %edi
	movb	$1, %al
	callq	printf
	incq	%r12
	cmpq	$10, %r12
	jne	.LBB0_4
# %bb.5:                                #   in Loop: Header=BB0_3 Depth=1
	movl	$10, %edi
	callq	putchar@PLT
	movl	$10, %eax
	testb	$1, %bpl
	movl	$0, %ebp
	jne	.LBB0_3
# %bb.6:
	movl	$10, %edi
	callq	putchar@PLT
	leaq	24(%rsp), %rdi
	movl	$80, %esi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB0_7
# %bb.9:                                # %_Z9gpuAssert10hipError_tPKcib.exit
	movq	24(%rsp), %rdi
	movl	$80, %edx
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
	movl	$80, %edi
	callq	malloc
	movq	%rax, %rbx
	leaq	16(%rsp), %rdi
	movl	$80, %esi
	callq	hipMalloc
	testl	%eax, %eax
	jne	.LBB0_10
# %bb.11:                               # %_Z9gpuAssert10hipError_tPKcib.exit50
	movl	$8, 44(%rsp)
	xorl	%eax, %eax
	movl	%eax, 40(%rsp)
	movl	%eax, 36(%rsp)
	movq	8(%r14), %rdi
	callq	atoi
	cmpl	$1, %eax
	je	.LBB0_26
# %bb.12:                               # %_Z9gpuAssert10hipError_tPKcib.exit50
	cmpl	$2, %eax
	jne	.LBB0_14
# %bb.13:
	movl	$.Lstr.1, %edi
	callq	puts@PLT
	subq	$8, %rsp
	.cfi_adjust_cfa_offset 8
	leaq	44(%rsp), %rax
	leaq	16(%rsp), %rdi
	leaq	52(%rsp), %rdx
	leaq	48(%rsp), %rcx
	movl	$1, %esi
	movl	$1, %r8d
	movl	$8, %r9d
	pushq	$2
	.cfi_adjust_cfa_offset 8
	pushq	$42
	.cfi_adjust_cfa_offset 8
	pushq	$5
	.cfi_adjust_cfa_offset 8
	pushq	$1
	.cfi_adjust_cfa_offset 8
	pushq	%rax
	.cfi_adjust_cfa_offset 8
	callq	hipfftPlanMany
	addq	$48, %rsp
	.cfi_adjust_cfa_offset -48
	jmp	.LBB0_14
.LBB0_1:
	movl	$.Lstr.2, %edi
	callq	puts@PLT
	movl	$-1, %eax
	jmp	.LBB0_25
.LBB0_26:
	movl	$.Lstr, %edi
	callq	puts@PLT
	leaq	8(%rsp), %rdi
	movl	$8, %esi
	movl	$42, %edx
	movl	$2, %ecx
	callq	hipfftPlan1d
.LBB0_14:
	movq	8(%rsp), %rdi
	movq	24(%rsp), %rsi
	movq	16(%rsp), %rdx
	callq	hipfftExecR2C
	movq	16(%rsp), %rsi
	movl	$80, %edx
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
	testl	%eax, %eax
	jne	.LBB0_27
# %bb.15:                               # %.preheader.preheader
	addq	$4, %rbx
	movb	$1, %bpl
	xorl	%r14d, %r14d
.LBB0_16:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_17 Depth 2
	leaq	(%r14,%r14,4), %rax
	leaq	(%rbx,%rax,8), %r12
	xorl	%r15d, %r15d
.LBB0_17:                               #   Parent Loop BB0_16 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	-4(%r12,%r15,8), %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	(%r12,%r15,8), %xmm1
	movl	$.L.str.6, %edi
	movl	%r14d, %esi
	movl	%r15d, %edx
	movb	$2, %al
	callq	printf
	incq	%r15
	cmpq	$5, %r15
	jne	.LBB0_17
# %bb.18:                               # %_Z9gpuAssert10hipError_tPKcib.exit52
                                        #   in Loop: Header=BB0_16 Depth=1
	movl	$1, %r14d
	testb	$1, %bpl
	movl	$0, %ebp
	jne	.LBB0_16
# %bb.19:
	movq	8(%rsp), %rdi
	callq	hipfftDestroy
	movq	16(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB0_20
# %bb.22:                               # %_Z9gpuAssert10hipError_tPKcib.exit54
	movq	24(%rsp), %rdi
	callq	hipFree
	testl	%eax, %eax
	jne	.LBB0_23
# %bb.24:                               # %_Z9gpuAssert10hipError_tPKcib.exit56
	xorl	%eax, %eax
.LBB0_25:
	addq	$48, %rsp
	.cfi_def_cfa_offset 48
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%r12
	.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_7:
	.cfi_def_cfa_offset 96
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.7, %esi
	movl	$.L.str.3, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$51, %r8d
	jmp	.LBB0_8
.LBB0_10:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.7, %esi
	movl	$.L.str.3, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$58, %r8d
	jmp	.LBB0_8
.LBB0_27:
	movl	%eax, %ebp
	movq	stderr(%rip), %rbx
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.7, %esi
	movl	$.L.str.3, %ecx
	movq	%rbx, %rdi
	movq	%rax, %rdx
	movl	$89, %r8d
.LBB0_8:
	xorl	%eax, %eax
	callq	fprintf
	movl	%ebp, %edi
	callq	exit
.LBB0_20:
	movl	%eax, %ebx
	movq	stderr(%rip), %r14
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.7, %esi
	movl	$.L.str.3, %ecx
	movq	%r14, %rdi
	movq	%rax, %rdx
	movl	$96, %r8d
	jmp	.LBB0_21
.LBB0_23:
	movl	%eax, %ebx
	movq	stderr(%rip), %r14
	movl	%eax, %edi
	callq	hipGetErrorString
	movl	$.L.str.7, %esi
	movl	$.L.str.3, %ecx
	movq	%r14, %rdi
	movq	%rax, %rdx
	movl	$97, %r8d
.LBB0_21:
	xorl	%eax, %eax
	callq	fprintf
	movl	%ebx, %edi
	callq	exit
.Lfunc_end0:
	.size	main, .Lfunc_end0-main
	.cfi_endproc
                                        # -- End function
	.type	.L.str.1,@object                # @.str.1
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str.1:
	.asciz	"%f "
	.size	.L.str.1, 4

	.type	.L.str.3,@object                # @.str.3
.L.str.3:
	.asciz	"/home/ubuntu/Datasets/stackv2/train-structured-repos-hip-sm89/leimingyu/cuda_fft/master/cufft/tests/test1_planmany.hip"
	.size	.L.str.3, 119

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	"%i %i %f %f\n"
	.size	.L.str.6, 13

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"GPUassert: %s %s %d\n"
	.size	.L.str.7, 21

	.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	"cufftplan1d"
	.size	.Lstr, 12

	.type	.Lstr.1,@object                 # @str.1
.Lstr.1:
	.asciz	"cufftplan2d"
	.size	.Lstr.1, 12

	.type	.Lstr.2,@object                 # @str.2
.Lstr.2:
	.asciz	"Please specify 1 (plan1d) or 2 (planmany)."
	.size	.Lstr.2, 43

	.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_

	.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
