// nvcc fft_cuda_2d.cu -lcublas -lcufft -arch=compute_52 -o fft_cuda_2d
//https://www.researchgate.net/figure/Computing-2D-FFT-of-size-NX-NY-using-CUDAs-cuFFT-library-49-FFT-fast-Fourier_fig3_324060154
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include "cuda.h"
#include <cufft.h>
 
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>

#define DIM 4*65536//65536 = 256 * 256
#define NX 220
#define NY 220
using namespace std;



int main()
{
    int n = 0; //n is the number of the integers in the file ==> 12
    int data[220*220];
    int x;

    ifstream File;
    File.open("lenna_grayscale.txt");
    if(!File.is_open()){
        cout<<"It failed"<<endl;
        return 0;
    }

    while(File>>x){
        data[n] = x; 
        n++;
    }

    File.close();
    cout<<"n : "<<n<<endl;
    for(int i=0;i<n;i++){
        cout << data[i] << " ";
    }




    float elapsedTime = 0;
    cufftHandle plan;
    cufftComplex *host_data = (cufftComplex*)malloc(NX*NY*sizeof(cufftComplex));
    cufftComplex *fft_data = (cufftComplex*)malloc(NX*NY*sizeof(cufftComplex));
    cufftComplex *dev_data;
    cudaEvent_t start,stop;
    
    //FEED INPUT
    srand(time(NULL));
    for(int i = 0;i<NX;i++){
        for(int j = 0;j<NY;j++){
            host_data[i*NY+j].x = (float)data[i*NY+j];  //rand()/(float)RAND_MAX;
            host_data[i*NY+j].y = 0.0;        
        }
    }

    //SHOW HOST DATA
    for(int i = 0;i<16;i++){
        printf("DATA: %3.1f %3.1f \n",host_data[i*NY+1].x,host_data[i*NY+1].y);
    }

    //ALLOCATE GPU MEMORY
    cudaMalloc((void**)&dev_data,sizeof(cufftComplex)*NX*NY);
    cudaEventCreate(&start);
    cudaEventCreate(&stop);
    cudaEventRecord(start,0);
    
    //COPY INPUT
    cudaMemcpy(dev_data,host_data,NX*NY*sizeof(cufftComplex),cudaMemcpyHostToDevice);
    
    //CREATE CUFFT PLAN
    cufftPlan2d(&plan,NX,NY,CUFFT_C2C);
    
    //PERFORM COMPUTATION(fft and ifft)
    cufftExecC2C(plan,dev_data,dev_data,CUFFT_FORWARD);
    //COPY BACK RESULTS
    cudaMemcpy(fft_data,dev_data,sizeof(cufftComplex)*NX*NY,cudaMemcpyDeviceToHost);
    ofstream outfile2;
    outfile2.open("fft_data.txt");
    // int data2[220*220] = {0};
    for(int i = 0;i<NX;i++){
        for(int j = 0;j<NY;j++){
            if(j == NY - 1){
                outfile2<<fft_data[i*NY+j].x<<endl;
            }else{
                outfile2<<fft_data[i*NY+j].x<<","; 
            }     
        }
    }
    outfile2.close(); 
    


    cufftExecC2C(plan,dev_data,dev_data,CUFFT_INVERSE);//https://stackoverflow.com/questions/46562575/how-to-cuda-ifft
    
    //COPY BACK RESULTS
    cudaMemcpy(host_data,dev_data,sizeof(cufftComplex)*NX*NY,cudaMemcpyDeviceToHost);
    
    //GET CALCULATION TIME
    cudaEventRecord(stop,0);
    cudaEventSynchronize(stop);
    cudaEventElapsedTime(&elapsedTime,start,stop);
    
    //SHOW RESULTS
    for(int i = 0;i<16;i++){
        printf("DATA: %3.1f %3.1f \n",host_data[i*NY+1].x/(NX*NY),host_data[i*NY+1].y/(NX*NY));
    }
    ofstream outfile;
    outfile.open("output_data.txt");
    // int data2[220*220] = {0};
    for(int i = 0;i<NX;i++){
        for(int j = 0;j<NY;j++){
            // data2[i*NY+j] = host_data[i*NY+3].x/(NX*NY)
            if(j == NY - 1){
                outfile<<host_data[i*NY+j].x/(NX*NY)<<endl;
            }else{
                outfile<<host_data[i*NY+j].x/(NX*NY)<<","; 
            }
              
        }
    }
    outfile.close();
    //FREEE MEMORY
    cufftDestroy(plan);
    cudaFree(dev_data);
    free(host_data);
    printf("elapsed time %f\n",elapsedTime);
    printf("CUFFT Calculation COMPLETED IN : % 5.3f ms \n",elapsedTime);  
}

	.file	"tmpxft_0023ee01_00000000-6_fft_cuda_2d.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB4212:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE4212:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB4235:
	.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
.LFE4235:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"lenna_grayscale.txt"
.LC1:
	.string	"It failed"
.LC2:
	.string	"n : "
.LC3:
	.string	" "
.LC5:
	.string	"DATA: %3.1f %3.1f \n"
.LC6:
	.string	"fft_data.txt"
.LC7:
	.string	","
.LC9:
	.string	"output_data.txt"
.LC10:
	.string	"elapsed time %f\n"
.LC11:
	.string	"CUFFT Calculation COMPLETED IN : % 5.3f ms \n"
	.section	.text.startup
	.globl	main
	.type	main, @function
main:
.LFB4209:
	.cfi_startproc
	.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
	.cfi_lsda 0x1b,.LLSDA4209
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-192512(%rsp), %r11
	.cfi_def_cfa 11, 192568
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$2728, %rsp
	.cfi_def_cfa_offset 195296
	movq	%fs:40, %rax
	movq	%rax, 195224(%rsp)
	xorl	%eax, %eax
	leaq	1104(%rsp), %rax
	movq	%rax, %rdi
	movq	%rax, 24(%rsp)
.LEHB0:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE0:
	movq	24(%rsp), %rdi
	movl	$8, %edx
	leaq	.LC0(%rip), %rsi
.LEHB1:
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT
	leaq	1224(%rsp), %rdi
	xorl	%ebx, %ebx
	leaq	44(%rsp), %r12
	call	_ZNKSt12__basic_fileIcE7is_openEv@PLT
	testb	%al, %al
	jne	.L5
	leaq	.LC1(%rip), %rsi
	leaq	_ZSt4cout(%rip), %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	jmp	.L6
.L54:
	movq	(%rax), %rdx
	leaq	1624(%rsp), %rbp
	movq	-24(%rdx), %rdx
	testb	$5, 32(%rax,%rdx)
	jne	.L53
	movl	44(%rsp), %eax
	movl	%eax, 0(%rbp,%rbx,4)
	incq	%rbx
.L5:
	movq	24(%rsp), %rdi
	movq	%r12, %rsi
	call	_ZNSirsERi@PLT
	jmp	.L54
.L53:
	movq	24(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE5closeEv@PLT
	leaq	_ZSt4cout(%rip), %r13
	leaq	.LC2(%rip), %rsi
	movq	%r13, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rax, %rdi
	movl	%ebx, %esi
	movl	%ebx, %r12d
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	xorl	%ebx, %ebx
	leaq	.LC3(%rip), %r14
.L8:
	cmpl	%ebx, %r12d
	jle	.L55
	movl	0(%rbp,%rbx,4), %esi
	movq	%r13, %rdi
	call	_ZNSolsEi@PLT
	movq	%rax, %rdi
	movq	%r14, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	incq	%rbx
	jmp	.L8
.L55:
	movl	$387200, %edi
	movl	$0x00000000, 48(%rsp)
	call	malloc@PLT
	movl	$387200, %edi
	movq	%rax, %rbx
	call	malloc@PLT
	xorl	%edi, %edi
	movq	%rax, %r12
	call	time@PLT
	movl	%eax, %edi
	call	srand@PLT
	movq	%rbx, %rcx
	xorl	%esi, %esi
.L10:
	movq	%rcx, %rdx
	xorl	%eax, %eax
.L11:
	cvtsi2ssl	0(%rbp,%rax,4), %xmm0
	incq	%rax
	movl	$0x00000000, 4(%rdx)
	addq	$8, %rdx
	movss	%xmm0, -8(%rdx)
	cmpq	$220, %rax
	jne	.L11
	addl	$220, %esi
	addq	$1760, %rcx
	addq	$880, %rbp
	cmpl	$48400, %esi
	jne	.L10
	xorl	%ebp, %ebp
.L12:
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	movb	$2, %al
	cvtss2sd	8(%rbx,%rbp), %xmm0
	cvtss2sd	12(%rbx,%rbp), %xmm1
	call	__printf_chk@PLT
	addq	$1760, %rbp
	cmpq	$28160, %rbp
	jne	.L12
	leaq	56(%rsp), %rdi
	movl	$387200, %esi
	call	cudaMalloc@PLT
	leaq	64(%rsp), %rdi
	call	cudaEventCreate@PLT
	leaq	72(%rsp), %rdi
	call	cudaEventCreate@PLT
	movq	64(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	56(%rsp), %rdi
	movl	$1, %ecx
	movl	$387200, %edx
	movq	%rbx, %rsi
	call	cudaMemcpy@PLT
	leaq	52(%rsp), %rdi
	movl	$41, %ecx
	movl	$220, %edx
	movl	$220, %esi
	call	cufftPlan2d@PLT
	movq	56(%rsp), %rsi
	movl	52(%rsp), %edi
	orl	$-1, %ecx
	movq	%rsi, %rdx
	call	cufftExecC2C@PLT
	movq	56(%rsp), %rsi
	movl	$2, %ecx
	movl	$387200, %edx
	movq	%r12, %rdi
	call	cudaMemcpy@PLT
	leaq	80(%rsp), %rax
	movq	%rax, %rdi
	movq	%rax, 8(%rsp)
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE1:
	movq	8(%rsp), %rdi
	movl	$16, %edx
	leaq	.LC6(%rip), %rsi
.LEHB2:
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT
	xorl	%ebp, %ebp
.L13:
	imull	$220, %ebp, %r15d
	xorl	%r13d, %r13d
	imulq	$1760, %rbp, %r14
.L18:
	cmpl	$219, %r13d
	jne	.L14
	cvtss2sd	1752(%r12,%r14), %xmm0
	movq	8(%rsp), %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	jmp	.L56
.L14:
	movq	8(%rsp), %rdi
	leal	0(%r13,%r15), %eax
	cvtss2sd	(%r12,%rax,8), %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	leaq	.LC7(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	incl	%r13d
	jmp	.L18
.L56:
	incq	%rbp
	cmpq	$220, %rbp
	jne	.L13
	movq	8(%rsp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv@PLT
	movq	56(%rsp), %rsi
	movl	52(%rsp), %edi
	movl	$1, %ecx
	movq	%rsi, %rdx
	call	cufftExecC2C@PLT
	movq	56(%rsp), %rsi
	movl	$2, %ecx
	movl	$387200, %edx
	movq	%rbx, %rdi
	call	cudaMemcpy@PLT
	movq	72(%rsp), %rdi
	xorl	%esi, %esi
	call	cudaEventRecord@PLT
	movq	72(%rsp), %rdi
	call	cudaEventSynchronize@PLT
	movq	72(%rsp), %rdx
	movq	64(%rsp), %rsi
	leaq	48(%rsp), %rdi
	call	cudaEventElapsedTime@PLT
	xorl	%ebp, %ebp
.L19:
	leaq	.LC5(%rip), %rsi
	movl	$2, %edi
	movb	$2, %al
	movss	12(%rbx,%rbp), %xmm1
	movss	8(%rbx,%rbp), %xmm0
	divss	.LC8(%rip), %xmm1
	divss	.LC8(%rip), %xmm0
	cvtss2sd	%xmm1, %xmm1
	cvtss2sd	%xmm0, %xmm0
	call	__printf_chk@PLT
	addq	$1760, %rbp
	cmpq	$28160, %rbp
	jne	.L19
	leaq	592(%rsp), %rax
	movq	%rax, %rdi
	movq	%rax, 16(%rsp)
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev@PLT
.LEHE2:
	movq	16(%rsp), %rdi
	movl	$16, %edx
	leaq	.LC9(%rip), %rsi
.LEHB3:
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode@PLT
	xorl	%ebp, %ebp
	leaq	.LC7(%rip), %r15
.L20:
	imull	$220, %ebp, %r14d
	xorl	%r12d, %r12d
	imulq	$1760, %rbp, %r13
.L23:
	cmpl	$219, %r12d
	jne	.L21
	movss	1752(%rbx,%r13), %xmm0
	movq	16(%rsp), %rdi
	divss	.LC8(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	call	_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@PLT
	jmp	.L57
.L21:
	movq	16(%rsp), %rdi
	leal	(%r12,%r14), %eax
	movss	(%rbx,%rax,8), %xmm0
	divss	.LC8(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rax, %rdi
	movq	%r15, %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	incl	%r12d
	jmp	.L23
.L57:
	incq	%rbp
	cmpq	$220, %rbp
	jne	.L20
	movq	16(%rsp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv@PLT
	movl	52(%rsp), %edi
	call	cufftDestroy@PLT
	movq	56(%rsp), %rdi
	call	cudaFree@PLT
	movq	%rbx, %rdi
	call	free@PLT
	leaq	.LC10(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	48(%rsp), %xmm0
	call	__printf_chk@PLT
	leaq	.LC11(%rip), %rsi
	movl	$2, %edi
	movb	$1, %al
	cvtss2sd	48(%rsp), %xmm0
	call	__printf_chk@PLT
.LEHE3:
	movq	16(%rsp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	8(%rsp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
.L6:
	movq	24(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	195224(%rsp), %rax
	subq	%fs:40, %rax
	je	.L29
	jmp	.L50
.L37:
	endbr64
	movq	%rax, %rbx
.L25:
	movq	16(%rsp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	jmp	.L26
.L36:
	endbr64
	movq	%rax, %rbx
.L26:
	movq	8(%rsp), %rdi
	call	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev@PLT
	jmp	.L27
.L35:
	endbr64
	movq	%rax, %rbx
.L27:
	movq	24(%rsp), %rdi
	call	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@PLT
	movq	195224(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L50
	movq	%rbx, %rdi
.LEHB4:
	call	_Unwind_Resume@PLT
.LEHE4:
.L50:
	call	__stack_chk_fail@PLT
.L29:
	addq	$195240, %rsp
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE4209:
	.globl	__gxx_personality_v0
	.section	.gcc_except_table,"a",@progbits
.LLSDA4209:
	.byte	0xff
	.byte	0xff
	.byte	0x1
	.uleb128 .LLSDACSE4209-.LLSDACSB4209
.LLSDACSB4209:
	.uleb128 .LEHB0-.LFB4209
	.uleb128 .LEHE0-.LEHB0
	.uleb128 0
	.uleb128 0
	.uleb128 .LEHB1-.LFB4209
	.uleb128 .LEHE1-.LEHB1
	.uleb128 .L35-.LFB4209
	.uleb128 0
	.uleb128 .LEHB2-.LFB4209
	.uleb128 .LEHE2-.LEHB2
	.uleb128 .L36-.LFB4209
	.uleb128 0
	.uleb128 .LEHB3-.LFB4209
	.uleb128 .LEHE3-.LEHB3
	.uleb128 .L37-.LFB4209
	.uleb128 0
	.uleb128 .LEHB4-.LFB4209
	.uleb128 .LEHE4-.LEHB4
	.uleb128 0
	.uleb128 0
.LLSDACSE4209:
	.section	.text.startup
	.size	main, .-main
	.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
.LC8:
	.long	1195184128
	.hidden	DW.ref.__gxx_personality_v0
	.weak	DW.ref.__gxx_personality_v0
	.section	.data.rel.local.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
	.align 8
	.type	DW.ref.__gxx_personality_v0, @object
	.size	DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
	.quad	__gxx_personality_v0
	.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:

// nvcc fft_cuda_2d.cu -lcublas -lcufft -arch=compute_52 -o fft_cuda_2d
//https://www.researchgate.net/figure/Computing-2D-FFT-of-size-NX-NY-using-CUDAs-cuFFT-library-49-FFT-fast-Fourier_fig3_324060154
#include "hip/hip_runtime.h"


#include <hipfft/hipfft.h>
 
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>

#define DIM 4*65536//65536 = 256 * 256
#define NX 220
#define NY 220
using namespace std;



int main()
{
    int n = 0; //n is the number of the integers in the file ==> 12
    int data[220*220];
    int x;

    ifstream File;
    File.open("lenna_grayscale.txt");
    if(!File.is_open()){
        cout<<"It failed"<<endl;
        return 0;
    }

    while(File>>x){
        data[n] = x; 
        n++;
    }

    File.close();
    cout<<"n : "<<n<<endl;
    for(int i=0;i<n;i++){
        cout << data[i] << " ";
    }




    float elapsedTime = 0;
    hipfftHandle plan;
    hipfftComplex *host_data = (hipfftComplex*)malloc(NX*NY*sizeof(hipfftComplex));
    hipfftComplex *fft_data = (hipfftComplex*)malloc(NX*NY*sizeof(hipfftComplex));
    hipfftComplex *dev_data;
    hipEvent_t start,stop;
    
    //FEED INPUT
    srand(time(NULL));
    for(int i = 0;i<NX;i++){
        for(int j = 0;j<NY;j++){
            host_data[i*NY+j].x = (float)data[i*NY+j];  //rand()/(float)RAND_MAX;
            host_data[i*NY+j].y = 0.0;        
        }
    }

    //SHOW HOST DATA
    for(int i = 0;i<16;i++){
        printf("DATA: %3.1f %3.1f \n",host_data[i*NY+1].x,host_data[i*NY+1].y);
    }

    //ALLOCATE GPU MEMORY
    hipMalloc((void**)&dev_data,sizeof(hipfftComplex)*NX*NY);
    hipEventCreate(&start);
    hipEventCreate(&stop);
    hipEventRecord(start,0);
    
    //COPY INPUT
    hipMemcpy(dev_data,host_data,NX*NY*sizeof(hipfftComplex),hipMemcpyHostToDevice);
    
    //CREATE CUFFT PLAN
    hipfftPlan2d(&plan,NX,NY,HIPFFT_C2C);
    
    //PERFORM COMPUTATION(fft and ifft)
    hipfftExecC2C(plan,dev_data,dev_data,HIPFFT_FORWARD);
    //COPY BACK RESULTS
    hipMemcpy(fft_data,dev_data,sizeof(hipfftComplex)*NX*NY,hipMemcpyDeviceToHost);
    ofstream outfile2;
    outfile2.open("fft_data.txt");
    // int data2[220*220] = {0};
    for(int i = 0;i<NX;i++){
        for(int j = 0;j<NY;j++){
            if(j == NY - 1){
                outfile2<<fft_data[i*NY+j].x<<endl;
            }else{
                outfile2<<fft_data[i*NY+j].x<<","; 
            }     
        }
    }
    outfile2.close(); 
    


    hipfftExecC2C(plan,dev_data,dev_data,HIPFFT_BACKWARD);//https://stackoverflow.com/questions/46562575/how-to-cuda-ifft
    
    //COPY BACK RESULTS
    hipMemcpy(host_data,dev_data,sizeof(hipfftComplex)*NX*NY,hipMemcpyDeviceToHost);
    
    //GET CALCULATION TIME
    hipEventRecord(stop,0);
    hipEventSynchronize(stop);
    hipEventElapsedTime(&elapsedTime,start,stop);
    
    //SHOW RESULTS
    for(int i = 0;i<16;i++){
        printf("DATA: %3.1f %3.1f \n",host_data[i*NY+1].x/(NX*NY),host_data[i*NY+1].y/(NX*NY));
    }
    ofstream outfile;
    outfile.open("output_data.txt");
    // int data2[220*220] = {0};
    for(int i = 0;i<NX;i++){
        for(int j = 0;j<NY;j++){
            // data2[i*NY+j] = host_data[i*NY+3].x/(NX*NY)
            if(j == NY - 1){
                outfile<<host_data[i*NY+j].x/(NX*NY)<<endl;
            }else{
                outfile<<host_data[i*NY+j].x/(NX*NY)<<","; 
            }
              
        }
    }
    outfile.close();
    //FREEE MEMORY
    hipfftDestroy(plan);
    hipFree(dev_data);
    free(host_data);
    printf("elapsed time %f\n",elapsedTime);
    printf("CUFFT Calculation COMPLETED IN : % 5.3f ms \n",elapsedTime);  
}

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

                                        # End of file scope inline assembly
	.section	.rodata.cst4,"aM",@progbits,4
	.p2align	2, 0x0                          # -- Begin function main
.LCPI0_0:
	.long	0x473d1000                      # float 48400
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
.Lfunc_begin0:
	.cfi_startproc
	.cfi_personality 3, __gxx_personality_v0
	.cfi_lsda 3, .Lexception0
# %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	$195208, %rsp                   # imm = 0x2FA88
	.cfi_def_cfa_offset 195264
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	leaq	1080(%rsp), %rbx
	movq	%rbx, %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1Ev
.Ltmp0:
	movl	$.L.str, %esi
	movq	%rbx, %rdi
	movl	$8, %edx
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode
.Ltmp1:
# %bb.1:
	leaq	1200(%rsp), %rdi
	callq	_ZNKSt12__basic_fileIcE7is_openEv
	testb	%al, %al
	je	.LBB0_6
# %bb.2:                                # %.preheader114.preheader
	xorl	%ebx, %ebx
	leaq	1080(%rsp), %r14
	leaq	44(%rsp), %r15
.LBB0_3:                                # %.preheader114
                                        # =>This Inner Loop Header: Depth=1
.Ltmp10:
	movq	%r14, %rdi
	movq	%r15, %rsi
	callq	_ZNSirsERi
.Ltmp11:
# %bb.4:                                #   in Loop: Header=BB0_3 Depth=1
	movq	(%rax), %rcx
	movq	-24(%rcx), %rcx
	testb	$5, 32(%rax,%rcx)
	jne	.LBB0_10
# %bb.5:                                #   in Loop: Header=BB0_3 Depth=1
	movl	44(%rsp), %eax
	movl	%eax, 1600(%rsp,%rbx,4)
	incq	%rbx
	jmp	.LBB0_3
.LBB0_6:
.Ltmp2:
	movl	$_ZSt4cout, %ebx
	movl	$_ZSt4cout, %edi
	movl	$.L.str.1, %esi
	movl	$9, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp3:
# %bb.7:                                # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit
	movq	_ZSt4cout(%rip), %rax
	addq	-24(%rax), %rbx
.Ltmp4:
	movq	%rbx, %rdi
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp5:
# %bb.8:                                # %.noexc
.Ltmp6:
	movsbl	%al, %esi
	movl	$_ZSt4cout, %edi
	callq	_ZNSo3putEc
.Ltmp7:
# %bb.9:                                # %.noexc94
.Ltmp8:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp9:
	jmp	.LBB0_71
.LBB0_10:
.Ltmp13:
	leaq	1080(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEE5closeEv
.Ltmp14:
# %bb.11:
.Ltmp15:
	movl	$_ZSt4cout, %edi
	movl	$.L.str.2, %esi
	movl	$4, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp16:
# %bb.12:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit84
.Ltmp17:
	movl	$_ZSt4cout, %edi
	movl	%ebx, %esi
	callq	_ZNSolsEi
.Ltmp18:
# %bb.13:
	movq	%rax, %r14
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r14, %rdi
.Ltmp19:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp20:
# %bb.14:                               # %.noexc96
.Ltmp21:
	movsbl	%al, %esi
	movq	%r14, %rdi
	callq	_ZNSo3putEc
.Ltmp22:
# %bb.15:                               # %.noexc97
.Ltmp23:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp24:
# %bb.16:                               # %_ZNSolsEPFRSoS_E.exit85.preheader
	testl	%ebx, %ebx
	je	.LBB0_21
# %bb.17:                               # %.lr.ph.preheader
	xorl	%r14d, %r14d
.LBB0_18:                               # %.lr.ph
                                        # =>This Inner Loop Header: Depth=1
	movl	1600(%rsp,%r14,4), %esi
.Ltmp26:
	movl	$_ZSt4cout, %edi
	callq	_ZNSolsEi
.Ltmp27:
# %bb.19:                               #   in Loop: Header=BB0_18 Depth=1
.Ltmp28:
	movl	$.L.str.3, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp29:
# %bb.20:                               # %_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc.exit86
                                        #   in Loop: Header=BB0_18 Depth=1
	incq	%r14
	cmpq	%r14, %rbx
	jne	.LBB0_18
.LBB0_21:                               # %_ZNSolsEPFRSoS_E.exit85._crit_edge
	movl	$0, 4(%rsp)
	movl	$387200, %edi                   # imm = 0x5E880
	callq	malloc
	movq	%rax, %rbx
	movl	$387200, %edi                   # imm = 0x5E880
	callq	malloc
	movq	%rax, 16(%rsp)                  # 8-byte Spill
	xorl	%r15d, %r15d
	xorl	%edi, %edi
	callq	time
	movl	%eax, %edi
	callq	srand
	movq	%rbx, %rax
	addq	$4, %rax
	leaq	1600(%rsp), %rcx
.LBB0_22:                               # %.preheader113
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_23 Depth 2
	xorl	%edx, %edx
.LBB0_23:                               #   Parent Loop BB0_22 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtsi2ssl	(%rcx,%rdx,4), %xmm0
	movss	%xmm0, -4(%rax,%rdx,8)
	movl	$0, (%rax,%rdx,8)
	incq	%rdx
	cmpq	$220, %rdx
	jne	.LBB0_23
# %bb.24:                               #   in Loop: Header=BB0_22 Depth=1
	incq	%r15
	addq	$1760, %rax                     # imm = 0x6E0
	addq	$880, %rcx                      # imm = 0x370
	cmpq	$220, %r15
	jne	.LBB0_22
# %bb.25:                               # %.preheader112.preheader
	movl	$12, %r14d
.LBB0_26:                               # %.preheader112
                                        # =>This Inner Loop Header: Depth=1
	xorps	%xmm0, %xmm0
	cvtss2sd	-4(%rbx,%r14), %xmm0
	xorps	%xmm1, %xmm1
	cvtss2sd	(%rbx,%r14), %xmm1
	movl	$.L.str.4, %edi
	movb	$2, %al
	callq	printf
	addq	$1760, %r14                     # imm = 0x6E0
	cmpq	$28172, %r14                    # imm = 0x6E0C
	jne	.LBB0_26
# %bb.27:
.Ltmp31:
	leaq	8(%rsp), %rdi
	movl	$387200, %esi                   # imm = 0x5E880
	callq	hipMalloc
.Ltmp32:
# %bb.28:
.Ltmp33:
	leaq	48(%rsp), %rdi
	callq	hipEventCreate
.Ltmp34:
# %bb.29:
.Ltmp35:
	leaq	24(%rsp), %rdi
	callq	hipEventCreate
.Ltmp36:
# %bb.30:
	movq	48(%rsp), %rdi
.Ltmp37:
	xorl	%esi, %esi
	callq	hipEventRecord
.Ltmp38:
# %bb.31:
	movq	8(%rsp), %rdi
.Ltmp39:
	movl	$387200, %edx                   # imm = 0x5E880
	movq	%rbx, %rsi
	movl	$1, %ecx
	callq	hipMemcpy
.Ltmp40:
# %bb.32:
.Ltmp41:
	leaq	32(%rsp), %rdi
	movl	$220, %esi
	movl	$220, %edx
	movl	$41, %ecx
	callq	hipfftPlan2d
.Ltmp42:
# %bb.33:
	movq	32(%rsp), %rdi
	movq	8(%rsp), %rdx
.Ltmp43:
	movq	%rdx, %rsi
	movl	$-1, %ecx
	callq	hipfftExecC2C
.Ltmp44:
# %bb.34:
	movq	8(%rsp), %rsi
.Ltmp45:
	movl	$387200, %edx                   # imm = 0x5E880
	movq	16(%rsp), %rdi                  # 8-byte Reload
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp46:
# %bb.35:
.Ltmp48:
	leaq	56(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev
.Ltmp49:
# %bb.36:
.Ltmp51:
	leaq	56(%rsp), %rdi
	movl	$.L.str.5, %esi
	movl	$16, %edx
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode
.Ltmp52:
# %bb.37:                               # %.preheader111
	xorl	%r13d, %r13d
	leaq	56(%rsp), %r15
	movq	16(%rsp), %rbp                  # 8-byte Reload
.LBB0_38:                               # %.preheader110
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_39 Depth 2
	imulq	$220, %r13, %r12
	xorl	%r14d, %r14d
.LBB0_39:                               #   Parent Loop BB0_38 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	xorps	%xmm0, %xmm0
	cvtss2sd	(%rbp,%r14,8), %xmm0
.Ltmp53:
	movq	%r15, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
.Ltmp54:
# %bb.40:                               # %_ZNSolsEf.exit88
                                        #   in Loop: Header=BB0_39 Depth=2
.Ltmp55:
	movl	$.L.str.6, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp56:
# %bb.41:                               # %_ZNSolsEPFRSoS_E.exit87
                                        #   in Loop: Header=BB0_39 Depth=2
	incq	%r14
	cmpq	$219, %r14
	jne	.LBB0_39
# %bb.42:                               #   in Loop: Header=BB0_38 Depth=1
	movq	16(%rsp), %rax                  # 8-byte Reload
	xorps	%xmm0, %xmm0
	cvtss2sd	1752(%rax,%r12,8), %xmm0
.Ltmp58:
	movq	%r15, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
.Ltmp59:
# %bb.43:                               # %_ZNSolsEf.exit
                                        #   in Loop: Header=BB0_38 Depth=1
	movq	%rax, %r12
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
.Ltmp60:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp61:
# %bb.44:                               # %.noexc100
                                        #   in Loop: Header=BB0_38 Depth=1
.Ltmp62:
	movsbl	%al, %esi
	movq	%r12, %rdi
	callq	_ZNSo3putEc
.Ltmp63:
# %bb.45:                               # %.noexc101
                                        #   in Loop: Header=BB0_38 Depth=1
.Ltmp64:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp65:
# %bb.46:                               #   in Loop: Header=BB0_38 Depth=1
	incq	%r13
	addq	$1760, %rbp                     # imm = 0x6E0
	cmpq	$220, %r13
	jne	.LBB0_38
# %bb.47:
.Ltmp67:
	leaq	56(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv
.Ltmp68:
# %bb.48:
	movq	32(%rsp), %rdi
	movq	8(%rsp), %rdx
.Ltmp69:
	movq	%rdx, %rsi
	movl	$1, %ecx
	callq	hipfftExecC2C
.Ltmp70:
# %bb.49:
	movq	8(%rsp), %rsi
.Ltmp71:
	movl	$387200, %edx                   # imm = 0x5E880
	movq	%rbx, %rdi
	movl	$2, %ecx
	callq	hipMemcpy
.Ltmp72:
# %bb.50:
	movq	24(%rsp), %rdi
.Ltmp73:
	xorl	%esi, %esi
	callq	hipEventRecord
.Ltmp74:
# %bb.51:
	movq	24(%rsp), %rdi
.Ltmp75:
	callq	hipEventSynchronize
.Ltmp76:
# %bb.52:
	movq	48(%rsp), %rsi
	movq	24(%rsp), %rdx
.Ltmp77:
	leaq	4(%rsp), %rdi
	callq	hipEventElapsedTime
.Ltmp78:
# %bb.53:                               # %.preheader109.preheader
	movl	$12, %r14d
.LBB0_54:                               # %.preheader109
                                        # =>This Inner Loop Header: Depth=1
	movss	-4(%rbx,%r14), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	(%rbx,%r14), %xmm1              # xmm1 = mem[0],zero,zero,zero
	movss	.LCPI0_0(%rip), %xmm2           # xmm2 = mem[0],zero,zero,zero
	divss	%xmm2, %xmm0
	cvtss2sd	%xmm0, %xmm0
	divss	%xmm2, %xmm1
	cvtss2sd	%xmm1, %xmm1
	movl	$.L.str.4, %edi
	movb	$2, %al
	callq	printf
	addq	$1760, %r14                     # imm = 0x6E0
	cmpq	$28172, %r14                    # imm = 0x6E0C
	jne	.LBB0_54
# %bb.55:
.Ltmp80:
	leaq	568(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEEC1Ev
.Ltmp81:
# %bb.56:
.Ltmp83:
	leaq	568(%rsp), %rdi
	movl	$.L.str.7, %esi
	movl	$16, %edx
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE4openEPKcSt13_Ios_Openmode
.Ltmp84:
# %bb.57:                               # %.preheader108
	xorl	%r13d, %r13d
	leaq	568(%rsp), %r15
	movq	%rbx, %rbp
.LBB0_58:                               # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_59 Depth 2
	imulq	$220, %r13, %r12
	xorl	%r14d, %r14d
.LBB0_59:                               #   Parent Loop BB0_58 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movss	(%rbp,%r14,8), %xmm0            # xmm0 = mem[0],zero,zero,zero
	divss	.LCPI0_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
.Ltmp85:
	movq	%r15, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
.Ltmp86:
# %bb.60:                               # %_ZNSolsEf.exit92
                                        #   in Loop: Header=BB0_59 Depth=2
.Ltmp87:
	movl	$.L.str.6, %esi
	movl	$1, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.Ltmp88:
# %bb.61:                               # %_ZNSolsEPFRSoS_E.exit91
                                        #   in Loop: Header=BB0_59 Depth=2
	incq	%r14
	cmpq	$219, %r14
	jne	.LBB0_59
# %bb.62:                               #   in Loop: Header=BB0_58 Depth=1
	movss	1752(%rbx,%r12,8), %xmm0        # xmm0 = mem[0],zero,zero,zero
	divss	.LCPI0_0(%rip), %xmm0
	cvtss2sd	%xmm0, %xmm0
.Ltmp90:
	movq	%r15, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
.Ltmp91:
# %bb.63:                               # %_ZNSolsEf.exit90
                                        #   in Loop: Header=BB0_58 Depth=1
	movq	%rax, %r12
	movq	(%rax), %rax
	movq	-24(%rax), %rdi
	addq	%r12, %rdi
.Ltmp92:
	movl	$10, %esi
	callq	_ZNKSt9basic_iosIcSt11char_traitsIcEE5widenEc
.Ltmp93:
# %bb.64:                               # %.noexc104
                                        #   in Loop: Header=BB0_58 Depth=1
.Ltmp94:
	movsbl	%al, %esi
	movq	%r12, %rdi
	callq	_ZNSo3putEc
.Ltmp95:
# %bb.65:                               # %.noexc105
                                        #   in Loop: Header=BB0_58 Depth=1
.Ltmp96:
	movq	%rax, %rdi
	callq	_ZNSo5flushEv
.Ltmp97:
# %bb.66:                               #   in Loop: Header=BB0_58 Depth=1
	incq	%r13
	addq	$1760, %rbp                     # imm = 0x6E0
	cmpq	$220, %r13
	jne	.LBB0_58
# %bb.67:
.Ltmp99:
	leaq	568(%rsp), %r15
	movq	%r15, %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEE5closeEv
.Ltmp100:
# %bb.68:
	movq	32(%rsp), %rdi
.Ltmp101:
	callq	hipfftDestroy
.Ltmp102:
# %bb.69:
	movq	8(%rsp), %rdi
.Ltmp103:
	callq	hipFree
.Ltmp104:
# %bb.70:
	movq	%rbx, %rdi
	callq	free
	xorps	%xmm0, %xmm0
	cvtss2sd	4(%rsp), %xmm0
	movl	$.L.str.8, %edi
	movb	$1, %al
	callq	printf
	xorps	%xmm0, %xmm0
	cvtss2sd	4(%rsp), %xmm0
	movl	$.L.str.9, %edi
	movb	$1, %al
	callq	printf
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE(%rip), %rbx
	leaq	576(%rsp), %rdi
	movq	%rbx, -8(%rdi)
	movq	_ZTTSt14basic_ofstreamIcSt11char_traitsIcEE+24(%rip), %r14
	movq	-24(%rbx), %rax
	movq	%r14, 568(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	movl	$248, %r12d
	addq	%r12, %r15
	movq	%r15, %rdi
	callq	_ZNSt8ios_baseD2Ev
	leaq	64(%rsp), %rdi
	movq	%rbx, -8(%rdi)
	movq	-24(%rbx), %rax
	movq	%r14, 56(%rsp,%rax)
	callq	_ZNSt13basic_filebufIcSt11char_traitsIcEED2Ev
	leaq	56(%rsp), %rdi
	addq	%r12, %rdi
	callq	_ZNSt8ios_baseD2Ev
.LBB0_71:                               # %_ZNSolsEPFRSoS_E.exit
	leaq	1080(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	xorl	%eax, %eax
	addq	$195208, %rsp                   # imm = 0x2FA88
	.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
.LBB0_72:
	.cfi_def_cfa_offset 195264
.Ltmp82:
	jmp	.LBB0_86
.LBB0_73:
.Ltmp50:
	jmp	.LBB0_79
.LBB0_74:
.Ltmp105:
	jmp	.LBB0_84
.LBB0_75:
.Ltmp79:
	jmp	.LBB0_86
.LBB0_76:
.Ltmp47:
	jmp	.LBB0_79
.LBB0_77:                               # %.loopexit.split-lp
.Ltmp25:
	jmp	.LBB0_79
.LBB0_78:                               # %.loopexit
.Ltmp12:
	jmp	.LBB0_79
.LBB0_80:
.Ltmp30:
.LBB0_79:
	movq	%rax, %rbx
	jmp	.LBB0_88
.LBB0_81:                               # %.loopexit.split-lp172
.Ltmp98:
	jmp	.LBB0_84
.LBB0_82:                               # %.loopexit.split-lp176
.Ltmp66:
	jmp	.LBB0_86
.LBB0_83:                               # %.loopexit171
.Ltmp89:
.LBB0_84:
	movq	%rax, %rbx
	leaq	568(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev
	jmp	.LBB0_87
.LBB0_85:                               # %.loopexit175
.Ltmp57:
.LBB0_86:
	movq	%rax, %rbx
.LBB0_87:
	leaq	56(%rsp), %rdi
	callq	_ZNSt14basic_ofstreamIcSt11char_traitsIcEED1Ev
.LBB0_88:
	leaq	1080(%rsp), %rdi
	callq	_ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev
	movq	%rbx, %rdi
	callq	_Unwind_Resume@PLT
.Lfunc_end0:
	.size	main, .Lfunc_end0-main
	.cfi_endproc
	.section	.gcc_except_table,"a",@progbits
	.p2align	2, 0x0
GCC_except_table0:
.Lexception0:
	.byte	255                             # @LPStart Encoding = omit
	.byte	255                             # @TType Encoding = omit
	.byte	1                               # Call site Encoding = uleb128
	.uleb128 .Lcst_end0-.Lcst_begin0
.Lcst_begin0:
	.uleb128 .Lfunc_begin0-.Lfunc_begin0    # >> Call Site 1 <<
	.uleb128 .Ltmp0-.Lfunc_begin0           #   Call between .Lfunc_begin0 and .Ltmp0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp0-.Lfunc_begin0           # >> Call Site 2 <<
	.uleb128 .Ltmp1-.Ltmp0                  #   Call between .Ltmp0 and .Ltmp1
	.uleb128 .Ltmp25-.Lfunc_begin0          #     jumps to .Ltmp25
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp10-.Lfunc_begin0          # >> Call Site 3 <<
	.uleb128 .Ltmp11-.Ltmp10                #   Call between .Ltmp10 and .Ltmp11
	.uleb128 .Ltmp12-.Lfunc_begin0          #     jumps to .Ltmp12
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp2-.Lfunc_begin0           # >> Call Site 4 <<
	.uleb128 .Ltmp24-.Ltmp2                 #   Call between .Ltmp2 and .Ltmp24
	.uleb128 .Ltmp25-.Lfunc_begin0          #     jumps to .Ltmp25
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp26-.Lfunc_begin0          # >> Call Site 5 <<
	.uleb128 .Ltmp29-.Ltmp26                #   Call between .Ltmp26 and .Ltmp29
	.uleb128 .Ltmp30-.Lfunc_begin0          #     jumps to .Ltmp30
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp31-.Lfunc_begin0          # >> Call Site 6 <<
	.uleb128 .Ltmp46-.Ltmp31                #   Call between .Ltmp31 and .Ltmp46
	.uleb128 .Ltmp47-.Lfunc_begin0          #     jumps to .Ltmp47
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp48-.Lfunc_begin0          # >> Call Site 7 <<
	.uleb128 .Ltmp49-.Ltmp48                #   Call between .Ltmp48 and .Ltmp49
	.uleb128 .Ltmp50-.Lfunc_begin0          #     jumps to .Ltmp50
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp51-.Lfunc_begin0          # >> Call Site 8 <<
	.uleb128 .Ltmp52-.Ltmp51                #   Call between .Ltmp51 and .Ltmp52
	.uleb128 .Ltmp79-.Lfunc_begin0          #     jumps to .Ltmp79
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp53-.Lfunc_begin0          # >> Call Site 9 <<
	.uleb128 .Ltmp56-.Ltmp53                #   Call between .Ltmp53 and .Ltmp56
	.uleb128 .Ltmp57-.Lfunc_begin0          #     jumps to .Ltmp57
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp58-.Lfunc_begin0          # >> Call Site 10 <<
	.uleb128 .Ltmp65-.Ltmp58                #   Call between .Ltmp58 and .Ltmp65
	.uleb128 .Ltmp66-.Lfunc_begin0          #     jumps to .Ltmp66
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp67-.Lfunc_begin0          # >> Call Site 11 <<
	.uleb128 .Ltmp78-.Ltmp67                #   Call between .Ltmp67 and .Ltmp78
	.uleb128 .Ltmp79-.Lfunc_begin0          #     jumps to .Ltmp79
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp80-.Lfunc_begin0          # >> Call Site 12 <<
	.uleb128 .Ltmp81-.Ltmp80                #   Call between .Ltmp80 and .Ltmp81
	.uleb128 .Ltmp82-.Lfunc_begin0          #     jumps to .Ltmp82
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp83-.Lfunc_begin0          # >> Call Site 13 <<
	.uleb128 .Ltmp84-.Ltmp83                #   Call between .Ltmp83 and .Ltmp84
	.uleb128 .Ltmp105-.Lfunc_begin0         #     jumps to .Ltmp105
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp85-.Lfunc_begin0          # >> Call Site 14 <<
	.uleb128 .Ltmp88-.Ltmp85                #   Call between .Ltmp85 and .Ltmp88
	.uleb128 .Ltmp89-.Lfunc_begin0          #     jumps to .Ltmp89
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp90-.Lfunc_begin0          # >> Call Site 15 <<
	.uleb128 .Ltmp97-.Ltmp90                #   Call between .Ltmp90 and .Ltmp97
	.uleb128 .Ltmp98-.Lfunc_begin0          #     jumps to .Ltmp98
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp99-.Lfunc_begin0          # >> Call Site 16 <<
	.uleb128 .Ltmp104-.Ltmp99               #   Call between .Ltmp99 and .Ltmp104
	.uleb128 .Ltmp105-.Lfunc_begin0         #     jumps to .Ltmp105
	.byte	0                               #   On action: cleanup
	.uleb128 .Ltmp104-.Lfunc_begin0         # >> Call Site 17 <<
	.uleb128 .Lfunc_end0-.Ltmp104           #   Call between .Ltmp104 and .Lfunc_end0
	.byte	0                               #     has no landing pad
	.byte	0                               #   On action: cleanup
.Lcst_end0:
	.p2align	2, 0x0
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"lenna_grayscale.txt"
	.size	.L.str, 20

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	"It failed"
	.size	.L.str.1, 10

	.type	.L.str.2,@object                # @.str.2
.L.str.2:
	.asciz	"n : "
	.size	.L.str.2, 5

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

	.type	.L.str.4,@object                # @.str.4
.L.str.4:
	.asciz	"DATA: %3.1f %3.1f \n"
	.size	.L.str.4, 20

	.type	.L.str.5,@object                # @.str.5
.L.str.5:
	.asciz	"fft_data.txt"
	.size	.L.str.5, 13

	.type	.L.str.6,@object                # @.str.6
.L.str.6:
	.asciz	","
	.size	.L.str.6, 2

	.type	.L.str.7,@object                # @.str.7
.L.str.7:
	.asciz	"output_data.txt"
	.size	.L.str.7, 16

	.type	.L.str.8,@object                # @.str.8
.L.str.8:
	.asciz	"elapsed time %f\n"
	.size	.L.str.8, 17

	.type	.L.str.9,@object                # @.str.9
.L.str.9:
	.asciz	"CUFFT Calculation COMPLETED IN : % 5.3f ms \n"
	.size	.L.str.9, 45

	.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 __gxx_personality_v0
	.addrsig_sym _Unwind_Resume
	.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
