#include <stdio.h>
#include <stdlib.h>

#include <inttypes.h>
#include <math.h>

#include <cuda.h>
#include <cuComplex.h>
#include <cufft.h>

extern "C" int fftshift(cuComplex *target, unsigned int width, unsigned int height){
	unsigned int halfw, halfh;
	unsigned int x,y, offset, tmpoffset;
	cuComplex tmp13, tmp24;

	halfw = width / 2;
	halfh = height / 2;
	
	//printf("Break up the image into 4 quadrants and rearranging them\n");

	//printf("Quadrants 1 & 3\n");
	for( x = 0; x < halfw; x++){
		for(y = 0; y < halfh; y++){
			offset = y * width + x;

			tmp13.x = target[offset].x;
			tmp13.y = target[offset].y;

			tmpoffset = (y + halfh)* width + (x + halfw);

			target[offset].x = target[tmpoffset].x;
			target[offset].y = target[tmpoffset].y;

			target[tmpoffset].x = tmp13.x;
			target[tmpoffset].y = tmp13.y;
		}
	}
//	printf("Quadrants 2 & 4\n");
        for( x = 0; x < halfw; x++){
                for(y = 0; y < halfh; y++){
                        offset = (y+halfh) * width + x;
                        tmp24.x = target[offset].x;
			tmp24.y = target[offset].y;

                        tmpoffset = y * width + (x + halfw);

                        target[offset].x = target[tmpoffset].x;
			target[offset].y = target[tmpoffset].y;

                        target[tmpoffset].x = tmp24.x;
			target[tmpoffset].y = tmp24.y;
                }
        }
return(0);
}
extern "C" int gpufouriertransform(cuComplex *original, cuComplex *transform, unsigned int width, unsigned int height){

	dim3 threadsPerBlock(1,1);
	dim3 numBlock(width/threadsPerBlock.x, height/threadsPerBlock.y);
	cufftHandle plan;
	cufftPlan2d(&plan,height, width, CUFFT_C2C);

	cuComplex *gpuoriginal, *gputransform;

	//printf("Starting the gpu FFT\n");

	cudaMalloc(&gpuoriginal, sizeof(cuComplex) * width * height);
	cudaMalloc(&gputransform, sizeof(cuComplex) * width * height);

	cudaDeviceSynchronize();
        //printf("Allocating Memory errors (?): %s\n", cudaGetErrorString(cudaGetLastError()));

	cudaMemcpy(gpuoriginal, original, sizeof(cuComplex) * width * height, cudaMemcpyHostToDevice);

	cudaDeviceSynchronize();
        //printf("Copying Memory errors (?): %s\n", cudaGetErrorString(cudaGetLastError()));
	
	cufftExecC2C(plan,gpuoriginal,gputransform, -1);

	cudaMemcpy(transform, gputransform, sizeof(cuComplex) * width * height, cudaMemcpyDeviceToHost);		
	cudaDeviceSynchronize();
        //printf("Copying back, Memory errors (?): %s\n", cudaGetErrorString(cudaGetLastError()));

	//printf("Performing the FFT Shift\n");
	
	fftshift(transform, width, height); 
/*
	for(offset = 0; offset < (width * height); offset ++){
		printf("%g%+g\n", transform[offset].x, transform[offset].y);
	}

*/
	cudaFree(gpuoriginal);
	cudaFree(gputransform);
	cufftDestroy(plan);

	return(0);
}

extern "C" int gpuifouriertransform(cuComplex *original, cuComplex *transform, unsigned int width, unsigned int height){

        dim3 threadsPerBlock(1,1);
        dim3 numBlock(width/threadsPerBlock.x, height/threadsPerBlock.y);
        cufftHandle plan;
        cufftPlan2d(&plan,height, width, CUFFT_C2C);

        cuComplex *gpuoriginal, *gputransform;

        //printf("Starting the gpu FFT\n");

        cudaMalloc(&gpuoriginal, sizeof(cuComplex) * width * height);
        cudaMalloc(&gputransform, sizeof(cuComplex) * width * height);

        cudaDeviceSynchronize();
        //printf("Allocating Memory errors (?): %s\n", cudaGetErrorString(cudaGetLastError()));

        cudaMemcpy(gpuoriginal, original, sizeof(cuComplex) * width * height, cudaMemcpyHostToDevice);

        cudaDeviceSynchronize();
        //printf("Copying Memory errors (?): %s\n", cudaGetErrorString(cudaGetLastError()));

        cufftExecC2C(plan,gpuoriginal,gputransform, 1);

        cudaMemcpy(transform, gputransform, sizeof(cuComplex) * width * height, cudaMemcpyDeviceToHost);
        cudaDeviceSynchronize();
        //printf("Copying back, Memory errors (?): %s\n", cudaGetErrorString(cudaGetLastError()));


/*
        for(offset = 0; offset < (width * height); offset ++){
                printf("%g%+g\n", transform[offset].x, transform[offset].y);
        }

*/

        cudaFree(gpuoriginal);
        cudaFree(gputransform);
        cufftDestroy(plan);



        return(0);
}


	.file	"tmpxft_0025d4ad_00000000-6_gpufouriertransform.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2055:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2055:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.globl	fftshift
	.type	fftshift, @function
fftshift:
.LFB2050:
	.cfi_startproc
	endbr64
	movl	%esi, %ecx
	movl	%edx, %esi
	movq	%rdi, %rax
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	shrl	%esi
	movl	%ecx, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%ecx, %edx
	imull	%esi, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	shrl	%edx
	xorl	%r8d, %r8d
	leal	(%rdx,%rdi), %ebp
.L3:
	cmpl	%edx, %r8d
	je	.L13
	movl	%r8d, %r9d
	xorl	%r10d, %r10d
.L5:
	cmpl	%esi, %r10d
	je	.L14
	movl	%r9d, %r11d
	incl	%r10d
	leaq	(%rax,%r11,8), %rbx
	leal	(%r9,%rbp), %r11d
	addl	%ecx, %r9d
	leaq	(%rax,%r11,8), %r11
	movq	(%rbx), %r12
	movss	(%r11), %xmm0
	movss	%xmm0, (%rbx)
	movss	4(%r11), %xmm0
	movss	%xmm0, 4(%rbx)
	movq	%r12, (%r11)
	jmp	.L5
.L14:
	incl	%r8d
	jmp	.L3
.L13:
	subl	%edx, %edi
	xorl	%r8d, %r8d
	movl	%edi, %r9d
.L6:
	cmpl	%edx, %r8d
	je	.L8
	leal	(%r8,%rdx), %edi
	xorl	%r10d, %r10d
.L9:
	cmpl	%esi, %r10d
	je	.L15
	leal	(%rdi,%r9), %r11d
	incl	%r10d
	leaq	(%rax,%r11,8), %rbx
	movl	%edi, %r11d
	addl	%ecx, %edi
	leaq	(%rax,%r11,8), %r11
	movq	(%rbx), %rbp
	movss	(%r11), %xmm0
	movss	%xmm0, (%rbx)
	movss	4(%r11), %xmm0
	movss	%xmm0, 4(%rbx)
	movq	%rbp, (%r11)
	jmp	.L9
.L15:
	incl	%r8d
	jmp	.L6
.L8:
	popq	%rbx
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE2050:
	.size	fftshift, .-fftshift
	.globl	gpufouriertransform
	.type	gpufouriertransform, @function
gpufouriertransform:
.LFB2051:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movq	%rdi, %r14
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	movq	%rsi, %r13
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	movl	%ecx, %r12d
	movl	$41, %ecx
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	movl	%r12d, %esi
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	movl	%edx, %ebx
	movl	%ebx, %edx
	movq	%rbx, %rbp
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rdi
	call	cufftPlan2d@PLT
	movl	%r12d, %eax
	leaq	8(%rsp), %rdi
	imulq	%rax, %rbx
	salq	$3, %rbx
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	leaq	16(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	call	cudaDeviceSynchronize@PLT
	movq	8(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r14, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	call	cudaDeviceSynchronize@PLT
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rsi
	orl	$-1, %ecx
	movl	4(%rsp), %edi
	call	cufftExecC2C@PLT
	movq	16(%rsp), %rsi
	movq	%rbx, %rdx
	movq	%r13, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	call	cudaDeviceSynchronize@PLT
	movl	%r12d, %edx
	movl	%ebp, %esi
	movq	%r13, %rdi
	call	fftshift
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movl	4(%rsp), %edi
	call	cufftDestroy@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	addq	$32, %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
.LFE2051:
	.size	gpufouriertransform, .-gpufouriertransform
	.globl	gpuifouriertransform
	.type	gpuifouriertransform, @function
gpuifouriertransform:
.LFB2052:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%ecx, %r13d
	movl	$41, %ecx
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movq	%rsi, %rbp
	movl	%r13d, %esi
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movl	%edx, %ebx
	movl	%ebx, %edx
	imulq	%r13, %rbx
	subq	$40, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	salq	$3, %rbx
	leaq	4(%rsp), %rdi
	call	cufftPlan2d@PLT
	leaq	8(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	leaq	16(%rsp), %rdi
	movq	%rbx, %rsi
	call	cudaMalloc@PLT
	call	cudaDeviceSynchronize@PLT
	movq	8(%rsp), %rdi
	movq	%rbx, %rdx
	movq	%r12, %rsi
	movl	$1, %ecx
	call	cudaMemcpy@PLT
	call	cudaDeviceSynchronize@PLT
	movq	16(%rsp), %rdx
	movq	8(%rsp), %rsi
	movl	$1, %ecx
	movl	4(%rsp), %edi
	call	cufftExecC2C@PLT
	movq	16(%rsp), %rsi
	movq	%rbx, %rdx
	movq	%rbp, %rdi
	movl	$2, %ecx
	call	cudaMemcpy@PLT
	call	cudaDeviceSynchronize@PLT
	movq	8(%rsp), %rdi
	call	cudaFree@PLT
	movq	16(%rsp), %rdi
	call	cudaFree@PLT
	movl	4(%rsp), %edi
	call	cufftDestroy@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	addq	$40, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	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
.LFE2052:
	.size	gpuifouriertransform, .-gpuifouriertransform
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2078:
	.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
.LFE2078:
	.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 <stdio.h>
#include <stdlib.h>

#include <inttypes.h>
#include <math.h>

#include <hip/hip_runtime.h>
#include <hip/hip_complex.h>
#include <hipfft/hipfft.h>

extern "C" int fftshift(hipComplex *target, unsigned int width, unsigned int height){
	unsigned int halfw, halfh;
	unsigned int x,y, offset, tmpoffset;
	hipComplex tmp13, tmp24;

	halfw = width / 2;
	halfh = height / 2;
	
	//printf("Break up the image into 4 quadrants and rearranging them\n");

	//printf("Quadrants 1 & 3\n");
	for( x = 0; x < halfw; x++){
		for(y = 0; y < halfh; y++){
			offset = y * width + x;

			tmp13.x = target[offset].x;
			tmp13.y = target[offset].y;

			tmpoffset = (y + halfh)* width + (x + halfw);

			target[offset].x = target[tmpoffset].x;
			target[offset].y = target[tmpoffset].y;

			target[tmpoffset].x = tmp13.x;
			target[tmpoffset].y = tmp13.y;
		}
	}
//	printf("Quadrants 2 & 4\n");
        for( x = 0; x < halfw; x++){
                for(y = 0; y < halfh; y++){
                        offset = (y+halfh) * width + x;
                        tmp24.x = target[offset].x;
			tmp24.y = target[offset].y;

                        tmpoffset = y * width + (x + halfw);

                        target[offset].x = target[tmpoffset].x;
			target[offset].y = target[tmpoffset].y;

                        target[tmpoffset].x = tmp24.x;
			target[tmpoffset].y = tmp24.y;
                }
        }
return(0);
}
extern "C" int gpufouriertransform(hipComplex *original, hipComplex *transform, unsigned int width, unsigned int height){

	dim3 threadsPerBlock(1,1);
	dim3 numBlock(width/threadsPerBlock.x, height/threadsPerBlock.y);
	hipfftHandle plan;
	hipfftPlan2d(&plan,height, width, HIPFFT_C2C);

	hipComplex *gpuoriginal, *gputransform;

	//printf("Starting the gpu FFT\n");

	hipMalloc(&gpuoriginal, sizeof(hipComplex) * width * height);
	hipMalloc(&gputransform, sizeof(hipComplex) * width * height);

	hipDeviceSynchronize();
        //printf("Allocating Memory errors (?): %s\n", cudaGetErrorString(cudaGetLastError()));

	hipMemcpy(gpuoriginal, original, sizeof(hipComplex) * width * height, hipMemcpyHostToDevice);

	hipDeviceSynchronize();
        //printf("Copying Memory errors (?): %s\n", cudaGetErrorString(cudaGetLastError()));
	
	hipfftExecC2C(plan,gpuoriginal,gputransform, -1);

	hipMemcpy(transform, gputransform, sizeof(hipComplex) * width * height, hipMemcpyDeviceToHost);		
	hipDeviceSynchronize();
        //printf("Copying back, Memory errors (?): %s\n", cudaGetErrorString(cudaGetLastError()));

	//printf("Performing the FFT Shift\n");
	
	fftshift(transform, width, height); 
/*
	for(offset = 0; offset < (width * height); offset ++){
		printf("%g%+g\n", transform[offset].x, transform[offset].y);
	}

*/
	hipFree(gpuoriginal);
	hipFree(gputransform);
	hipfftDestroy(plan);

	return(0);
}

extern "C" int gpuifouriertransform(hipComplex *original, hipComplex *transform, unsigned int width, unsigned int height){

        dim3 threadsPerBlock(1,1);
        dim3 numBlock(width/threadsPerBlock.x, height/threadsPerBlock.y);
        hipfftHandle plan;
        hipfftPlan2d(&plan,height, width, HIPFFT_C2C);

        hipComplex *gpuoriginal, *gputransform;

        //printf("Starting the gpu FFT\n");

        hipMalloc(&gpuoriginal, sizeof(hipComplex) * width * height);
        hipMalloc(&gputransform, sizeof(hipComplex) * width * height);

        hipDeviceSynchronize();
        //printf("Allocating Memory errors (?): %s\n", cudaGetErrorString(cudaGetLastError()));

        hipMemcpy(gpuoriginal, original, sizeof(hipComplex) * width * height, hipMemcpyHostToDevice);

        hipDeviceSynchronize();
        //printf("Copying Memory errors (?): %s\n", cudaGetErrorString(cudaGetLastError()));

        hipfftExecC2C(plan,gpuoriginal,gputransform, 1);

        hipMemcpy(transform, gputransform, sizeof(hipComplex) * width * height, hipMemcpyDeviceToHost);
        hipDeviceSynchronize();
        //printf("Copying back, Memory errors (?): %s\n", cudaGetErrorString(cudaGetLastError()));


/*
        for(offset = 0; offset < (width * height); offset ++){
                printf("%g%+g\n", transform[offset].x, transform[offset].y);
        }

*/

        hipFree(gpuoriginal);
        hipFree(gputransform);
        hipfftDestroy(plan);



        return(0);
}


	.text
	.file	"gpufouriertransform.hip"
	.globl	fftshift                        # -- Begin function fftshift
	.type	fftshift,@function
fftshift:                               # @fftshift
	.cfi_startproc
# %bb.0:
	cmpl	$2, %esi
	jb	.LBB0_12
# %bb.1:                                # %.preheader70.lr.ph
	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
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%esi, %eax
	shrl	%eax
	movl	%edx, %ecx
	shrl	%ecx
	movl	%ecx, %r8d
	imull	%esi, %ecx
	leal	(%rax,%rcx), %r9d
	xorl	%r10d, %r10d
.LBB0_2:                                # %.preheader70
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_3 Depth 2
	movq	%r8, %r11
	movl	%r10d, %ebx
	cmpl	$2, %edx
	jb	.LBB0_4
.LBB0_3:                                #   Parent Loop BB0_2 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%ebx, %r14d
	movq	(%rdi,%r14,8), %r15
	leal	(%r9,%rbx), %r12d
	movss	(%rdi,%r12,8), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rdi,%r14,8)
	movss	4(%rdi,%r12,8), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 4(%rdi,%r14,8)
	movq	%r15, (%rdi,%r12,8)
	addl	%esi, %ebx
	decq	%r11
	jne	.LBB0_3
.LBB0_4:                                # %._crit_edge
                                        #   in Loop: Header=BB0_2 Depth=1
	incl	%r10d
	cmpl	%eax, %r10d
	jne	.LBB0_2
# %bb.5:                                # %.preheader69
	cmpl	$2, %esi
	jb	.LBB0_11
# %bb.6:                                # %.preheader.lr.ph
	xorl	%r9d, %r9d
	movl	%eax, %r10d
.LBB0_7:                                # %.preheader
                                        # =>This Loop Header: Depth=1
                                        #     Child Loop BB0_9 Depth 2
	cmpl	$2, %edx
	jb	.LBB0_10
# %bb.8:                                # %.lr.ph74
                                        #   in Loop: Header=BB0_7 Depth=1
	movq	%r8, %r11
	movl	%r10d, %ebx
	movl	%ecx, %ebp
.LBB0_9:                                #   Parent Loop BB0_7 Depth=1
                                        # =>  This Inner Loop Header: Depth=2
	movl	%ebp, %r14d
	movq	(%rdi,%r14,8), %r15
	movl	%ebx, %r12d
	movss	(%rdi,%r12,8), %xmm0            # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, (%rdi,%r14,8)
	movss	4(%rdi,%r12,8), %xmm0           # xmm0 = mem[0],zero,zero,zero
	movss	%xmm0, 4(%rdi,%r14,8)
	movq	%r15, (%rdi,%r12,8)
	addl	%esi, %ebp
	addl	%esi, %ebx
	decq	%r11
	jne	.LBB0_9
.LBB0_10:                               # %._crit_edge75
                                        #   in Loop: Header=BB0_7 Depth=1
	incl	%r9d
	incl	%ecx
	incl	%r10d
	cmpl	%eax, %r9d
	jne	.LBB0_7
.LBB0_11:
	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
	.cfi_restore %rbx
	.cfi_restore %r12
	.cfi_restore %r14
	.cfi_restore %r15
	.cfi_restore %rbp
.LBB0_12:                               # %._crit_edge77
	xorl	%eax, %eax
	retq
.Lfunc_end0:
	.size	fftshift, .Lfunc_end0-fftshift
	.cfi_endproc
                                        # -- End function
	.globl	gpufouriertransform             # -- Begin function gpufouriertransform
	.type	gpufouriertransform,@function
gpufouriertransform:                    # @gpufouriertransform
	.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	$40, %rsp
	.cfi_def_cfa_offset 96
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	%ecx, %ebp
	movl	%edx, %r14d
	movq	%rsi, 16(%rsp)                  # 8-byte Spill
	movq	%rdi, %r12
	leaq	8(%rsp), %rdi
	movl	%ecx, %esi
	movl	$41, %ecx
	callq	hipfftPlan2d
	movl	%r14d, %eax
	movl	%ebp, %ebx
	imulq	%rax, %rbx
	shlq	$3, %rbx
	leaq	32(%rsp), %r13
	movq	%r13, %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	leaq	24(%rsp), %r15
	movq	%r15, %rdi
	movq	%rbx, %rsi
	callq	hipMalloc
	callq	hipDeviceSynchronize
	movq	(%r13), %rdi
	movq	%r12, %rsi
	movq	%rbx, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	callq	hipDeviceSynchronize
	leaq	8(%rsp), %rax
	movq	(%rax), %rdi
	movq	(%r13), %rsi
	movq	(%r15), %rdx
	movl	$-1, %ecx
	callq	hipfftExecC2C
	movq	(%r15), %rsi
	movq	16(%rsp), %r12                  # 8-byte Reload
	movq	%r12, %rdi
	movq	%rbx, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	callq	hipDeviceSynchronize
	movq	%r12, %rdi
	movl	%r14d, %esi
	movl	%ebp, %edx
	callq	fftshift
	movq	(%r13), %rdi
	callq	hipFree
	movq	(%r15), %rdi
	callq	hipFree
	leaq	8(%rsp), %rax
	movq	(%rax), %rdi
	callq	hipfftDestroy
	xorl	%eax, %eax
	addq	$40, %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_end1:
	.size	gpufouriertransform, .Lfunc_end1-gpufouriertransform
	.cfi_endproc
                                        # -- End function
	.globl	gpuifouriertransform            # -- Begin function gpuifouriertransform
	.type	gpuifouriertransform,@function
gpuifouriertransform:                   # @gpuifouriertransform
	.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
	movl	%ecx, %r15d
	movl	%edx, %r12d
	movq	%rsi, %r14
	movq	%rdi, %rbp
	leaq	16(%rsp), %rbx
	movq	%rbx, %rdi
	movl	%ecx, %esi
	movl	$41, %ecx
	callq	hipfftPlan2d
	movl	%r12d, %eax
	movl	%r15d, %r15d
	imulq	%rax, %r15
	shlq	$3, %r15
	leaq	8(%rsp), %r12
	movq	%r12, %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	movq	%rsp, %r13
	movq	%r13, %rdi
	movq	%r15, %rsi
	callq	hipMalloc
	callq	hipDeviceSynchronize
	movq	(%r12), %rdi
	movq	%rbp, %rsi
	movq	%r15, %rdx
	movl	$1, %ecx
	callq	hipMemcpy
	callq	hipDeviceSynchronize
	movq	(%rbx), %rdi
	movq	(%r12), %rsi
	movq	(%r13), %rdx
	movl	$1, %ecx
	callq	hipfftExecC2C
	movq	(%r13), %rsi
	movq	%r14, %rdi
	movq	%r15, %rdx
	movl	$2, %ecx
	callq	hipMemcpy
	callq	hipDeviceSynchronize
	movq	(%r12), %rdi
	callq	hipFree
	movq	(%r13), %rdi
	callq	hipFree
	movq	(%rbx), %rdi
	callq	hipfftDestroy
	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_end2:
	.size	gpuifouriertransform, .Lfunc_end2-gpuifouriertransform
	.cfi_endproc
                                        # -- End function
	.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 __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
