
#include "cuda_runtime.h"
#include "device_launch_parameters.h"

#include <stdio.h>
#include <cmath>

#define NUM_ELEMENTS 8388608
#define PI 3.141592654
#define r 1048576


//__global__ void divideAndConquer()
//{
//	int x;
//	int y;
//
//	double d = (2 * PI) * (NUM_ELEMENTS - 1);
//
//	if (threadIdx.x == 0 && blockIdx.x == 0)
//		x = 0 + r * cos(0);
//
//	x = 0 + r * cos((threadIdx.x + (blockDim.x * blockIdx.x)) * d);
//
//	if (threadIdx.x == 0 && blockIdx.x == 0)
//		y = 0 + r * sin(0);
//
//	y = 0 + r * sin((threadIdx.x + (blockDim.x * blockIdx.x)) * d);
//
//	__syncthreads();
//
//	printf("%d %d", x, y);
//}

int main()
{
	//divideAndConquer<<<4096, 1024>>>();
	int x = 0;
	int y = 0;
	int count = 0;
	double d = (2 * PI) / (NUM_ELEMENTS - 1);
	printf("2\n6741438\n");
	for (int i=0; i<NUM_ELEMENTS; i++)
	{
		int tempx = 1048576 + r * cos(i * d);
		int tempy = 1048576 + r * sin(i * d);
		
		if (tempx != x || tempy != y)
		{
			x = tempx;
			y = tempy;

			printf("%d %d\n", x, y);
			//count++;
		}

		
	}
	//printf("%d\n", count);
	//system("PAUSE");
    return 0;
}
	.file	"tmpxft_002357fd_00000000-6_circle.cudafe1.cpp"
	.text
#APP

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB2030:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE2030:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"2\n6741438\n"
.LC3:
	.string	"%d %d\n"
	.section	.text.startup,"ax",@progbits
	.globl	main
	.type	main, @function
main:
.LFB2027:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %rsi
	movl	$2, %edi
	xorl	%eax, %eax
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	xorl	%r14d, %r14d
	xorl	%r13d, %r13d
	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
	xorl	%ebx, %ebx
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	call	__printf_chk@PLT
.L5:
	cvtsi2sdl	%ebx, %xmm0
	mulsd	.LC1(%rip), %xmm0
	leaq	8(%rsp), %rdi
	movq	%rsp, %rsi
	call	sincos@PLT
	movsd	.LC2(%rip), %xmm0
	movsd	(%rsp), %xmm1
	mulsd	%xmm0, %xmm1
	addsd	%xmm0, %xmm1
	cvttsd2sil	%xmm1, %ebp
	movsd	8(%rsp), %xmm1
	mulsd	%xmm0, %xmm1
	addsd	%xmm0, %xmm1
	cvttsd2sil	%xmm1, %r12d
	cmpl	%r13d, %ebp
	jne	.L6
	cmpl	%r14d, %r12d
	je	.L3
.L6:
	movl	%r12d, %ecx
	movl	%ebp, %edx
	leaq	.LC3(%rip), %rsi
	xorl	%eax, %eax
	movl	$2, %edi
	movl	%r12d, %r14d
	movl	%ebp, %r13d
	call	__printf_chk@PLT
.L3:
	incl	%ebx
	cmpl	$8388608, %ebx
	jne	.L5
	addq	$16, %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
.LFE2027:
	.size	main, .-main
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB2053:
	.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
.LFE2053:
	.size	_ZL24__sti____cudaRegisterAllv, .-_ZL24__sti____cudaRegisterAllv
	.section	.init_array,"aw"
	.align 8
	.quad	_ZL24__sti____cudaRegisterAllv
	.section	.nvFatBinSegment,"aw"
	.align 8
	.type	_ZL15__fatDeviceText, @object
	.size	_ZL15__fatDeviceText, 24
_ZL15__fatDeviceText:
	.long	1180844977
	.long	1
	.quad	fatbinData
	.quad	0
	.local	_ZL20__cudaFatCubinHandle
	.comm	_ZL20__cudaFatCubinHandle,8,8
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	-2036974499
	.long	1051271675
	.align 8
.LC2:
	.long	0
	.long	1093664768
	.ident	"GCC: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:


#include "hip/hip_runtime.h"


#include <stdio.h>
#include <cmath>

#define NUM_ELEMENTS 8388608
#define PI 3.141592654
#define r 1048576


//__global__ void divideAndConquer()
//{
//	int x;
//	int y;
//
//	double d = (2 * PI) * (NUM_ELEMENTS - 1);
//
//	if (threadIdx.x == 0 && blockIdx.x == 0)
//		x = 0 + r * cos(0);
//
//	x = 0 + r * cos((threadIdx.x + (blockDim.x * blockIdx.x)) * d);
//
//	if (threadIdx.x == 0 && blockIdx.x == 0)
//		y = 0 + r * sin(0);
//
//	y = 0 + r * sin((threadIdx.x + (blockDim.x * blockIdx.x)) * d);
//
//	__syncthreads();
//
//	printf("%d %d", x, y);
//}

int main()
{
	//divideAndConquer<<<4096, 1024>>>();
	int x = 0;
	int y = 0;
	int count = 0;
	double d = (2 * PI) / (NUM_ELEMENTS - 1);
	printf("2\n6741438\n");
	for (int i=0; i<NUM_ELEMENTS; i++)
	{
		int tempx = 1048576 + r * cos(i * d);
		int tempy = 1048576 + r * sin(i * d);
		
		if (tempx != x || tempy != y)
		{
			x = tempx;
			y = tempy;

			printf("%d %d\n", x, y);
			//count++;
		}

		
	}
	//printf("%d\n", count);
	//system("PAUSE");
    return 0;
}
	.text
	.file	"circle.hip"
	.section	.rodata.cst8,"aM",@progbits,8
	.p2align	3, 0x0                          # -- Begin function main
.LCPI0_0:
	.quad	0x3ea921fb86963c5d              # double 7.4901414597203088E-7
.LCPI0_1:
	.quad	0x4130000000000000              # double 1048576
.LCPI0_2:
	.quad	0x3ff0000000000000              # double 1
	.text
	.globl	main
	.type	main,@function
main:                                   # @main
	.cfi_startproc
# %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	pushq	%r15
	.cfi_def_cfa_offset 24
	pushq	%r14
	.cfi_def_cfa_offset 32
	pushq	%r12
	.cfi_def_cfa_offset 40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	subq	$16, %rsp
	.cfi_def_cfa_offset 64
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	.cfi_offset %rbp, -16
	movl	$.Lstr, %edi
	callq	puts@PLT
	xorpd	%xmm0, %xmm0
	movl	$8388608, %r14d                 # imm = 0x800000
	xorl	%r12d, %r12d
	xorl	%r15d, %r15d
.LBB0_1:                                # =>This Inner Loop Header: Depth=1
	movsd	%xmm0, 8(%rsp)                  # 8-byte Spill
	mulsd	.LCPI0_0(%rip), %xmm0
	movsd	%xmm0, (%rsp)                   # 8-byte Spill
	callq	cos
	movsd	.LCPI0_1(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	addsd	%xmm1, %xmm0
	cvttsd2si	%xmm0, %ebx
	movsd	(%rsp), %xmm0                   # 8-byte Reload
                                        # xmm0 = mem[0],zero
	callq	sin
	movsd	.LCPI0_1(%rip), %xmm1           # xmm1 = mem[0],zero
	mulsd	%xmm1, %xmm0
	addsd	%xmm1, %xmm0
	cvttsd2si	%xmm0, %ebp
	cmpl	%ebx, %r12d
	jne	.LBB0_3
# %bb.2:                                #   in Loop: Header=BB0_1 Depth=1
	cmpl	%ebp, %r15d
	je	.LBB0_4
.LBB0_3:                                #   in Loop: Header=BB0_1 Depth=1
	movl	$.L.str.1, %edi
	movl	%ebx, %esi
	movl	%ebp, %edx
	xorl	%eax, %eax
	callq	printf
	movl	%ebp, %r15d
	movl	%ebx, %r12d
.LBB0_4:                                #   in Loop: Header=BB0_1 Depth=1
	movsd	8(%rsp), %xmm0                  # 8-byte Reload
                                        # xmm0 = mem[0],zero
	addsd	.LCPI0_2(%rip), %xmm0
	decl	%r14d
	jne	.LBB0_1
# %bb.5:
	xorl	%eax, %eax
	addq	$16, %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
.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	"%d %d\n"
	.size	.L.str.1, 7

	.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	"2\n6741438"
	.size	.Lstr, 10

	.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
