#include "point.cuh"

Point::Point() {}

Point::Point(double x_, double y_, bool border_x, bool border_y):
	x(x_), y(y_), borderX(border_x), borderY(border_y) {}

double Point::getX() const {
	return x;
}

double Point::getY() const {
	return y;
}

bool Point::isBorderX() const {
	return borderX;
}

bool Point::isBorderY() const {
	return borderY;
}

double Point::distance(Point &other) {
	double deltaX = x - other.x;
	double deltaY = y - other.y;
	return pow(deltaX * deltaX + deltaY * deltaY, 0.5);
}

void Point::move(double deltaX, double deltaY) {
	x += deltaX;
	y += deltaY;
}

__device__ bool Point::operator==(const Point& other) const {
	return x == other.x && y == other.y;
}

__device__ bool Point::operator!=(const Point &other) const {
	return !(*this == other);
}

ostream& operator<<(ostream& os, const Point &p) {
	os << "(" << p.x << ", " << p.y << ")";
	return os;
}

	.file	"tmpxft_00267566_00000000-6_point.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3932:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3932:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.align 2
	.globl	_ZN5PointC2Ev
	.type	_ZN5PointC2Ev, @function
_ZN5PointC2Ev:
.LFB3916:
	.cfi_startproc
	endbr64
	ret
	.cfi_endproc
.LFE3916:
	.size	_ZN5PointC2Ev, .-_ZN5PointC2Ev
	.globl	_ZN5PointC1Ev
	.set	_ZN5PointC1Ev,_ZN5PointC2Ev
	.align 2
	.globl	_ZN5PointC2Eddbb
	.type	_ZN5PointC2Eddbb, @function
_ZN5PointC2Eddbb:
.LFB3919:
	.cfi_startproc
	endbr64
	movb	%sil, 16(%rdi)
	movb	%dl, 17(%rdi)
	movsd	%xmm0, (%rdi)
	movsd	%xmm1, 8(%rdi)
	ret
	.cfi_endproc
.LFE3919:
	.size	_ZN5PointC2Eddbb, .-_ZN5PointC2Eddbb
	.globl	_ZN5PointC1Eddbb
	.set	_ZN5PointC1Eddbb,_ZN5PointC2Eddbb
	.align 2
	.globl	_ZNK5Point4getXEv
	.type	_ZNK5Point4getXEv, @function
_ZNK5Point4getXEv:
.LFB3921:
	.cfi_startproc
	endbr64
	movsd	(%rdi), %xmm0
	ret
	.cfi_endproc
.LFE3921:
	.size	_ZNK5Point4getXEv, .-_ZNK5Point4getXEv
	.align 2
	.globl	_ZNK5Point4getYEv
	.type	_ZNK5Point4getYEv, @function
_ZNK5Point4getYEv:
.LFB3922:
	.cfi_startproc
	endbr64
	movsd	8(%rdi), %xmm0
	ret
	.cfi_endproc
.LFE3922:
	.size	_ZNK5Point4getYEv, .-_ZNK5Point4getYEv
	.align 2
	.globl	_ZNK5Point9isBorderXEv
	.type	_ZNK5Point9isBorderXEv, @function
_ZNK5Point9isBorderXEv:
.LFB3923:
	.cfi_startproc
	endbr64
	movb	16(%rdi), %al
	ret
	.cfi_endproc
.LFE3923:
	.size	_ZNK5Point9isBorderXEv, .-_ZNK5Point9isBorderXEv
	.align 2
	.globl	_ZNK5Point9isBorderYEv
	.type	_ZNK5Point9isBorderYEv, @function
_ZNK5Point9isBorderYEv:
.LFB3924:
	.cfi_startproc
	endbr64
	movb	17(%rdi), %al
	ret
	.cfi_endproc
.LFE3924:
	.size	_ZNK5Point9isBorderYEv, .-_ZNK5Point9isBorderYEv
	.align 2
	.globl	_ZN5Point8distanceERS_
	.type	_ZN5Point8distanceERS_, @function
_ZN5Point8distanceERS_:
.LFB3925:
	.cfi_startproc
	endbr64
	movsd	(%rdi), %xmm0
	movsd	8(%rdi), %xmm1
	subsd	(%rsi), %xmm0
	subsd	8(%rsi), %xmm1
	mulsd	%xmm0, %xmm0
	mulsd	%xmm1, %xmm1
	addsd	%xmm1, %xmm0
	movsd	.LC0(%rip), %xmm1
	jmp	pow@PLT
	.cfi_endproc
.LFE3925:
	.size	_ZN5Point8distanceERS_, .-_ZN5Point8distanceERS_
	.align 2
	.globl	_ZN5Point4moveEdd
	.type	_ZN5Point4moveEdd, @function
_ZN5Point4moveEdd:
.LFB3926:
	.cfi_startproc
	endbr64
	addsd	(%rdi), %xmm0
	addsd	8(%rdi), %xmm1
	movsd	%xmm0, (%rdi)
	movsd	%xmm1, 8(%rdi)
	ret
	.cfi_endproc
.LFE3926:
	.size	_ZN5Point4moveEdd, .-_ZN5Point4moveEdd
	.align 2
	.globl	_ZNK5PointeqERKS_
	.type	_ZNK5PointeqERKS_, @function
_ZNK5PointeqERKS_:
.LFB3927:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	movl	$1, 12(%rsp)
	movl	12(%rsp), %edi
	call	exit@PLT
	.cfi_endproc
.LFE3927:
	.size	_ZNK5PointeqERKS_, .-_ZNK5PointeqERKS_
	.align 2
	.globl	_ZNK5PointneERKS_
	.type	_ZNK5PointneERKS_, @function
_ZNK5PointneERKS_:
.LFB4593:
	.cfi_startproc
	endbr64
	pushq	%rax
	.cfi_def_cfa_offset 16
	popq	%rax
	.cfi_def_cfa_offset 8
	pushq	%rax
	.cfi_def_cfa_offset 16
	call	_ZNK5PointeqERKS_
	.cfi_endproc
.LFE4593:
	.size	_ZNK5PointneERKS_, .-_ZNK5PointneERKS_
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"("
.LC2:
	.string	", "
.LC3:
	.string	")"
	.text
	.globl	_ZlsRSoRK5Point
	.type	_ZlsRSoRK5Point, @function
_ZlsRSoRK5Point:
.LFB3929:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsi, %rbp
	leaq	.LC1(%rip), %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	pushq	%rax
	.cfi_def_cfa_offset 32
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	0(%rbp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC2(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movsd	8(%rbp), %xmm0
	movq	%rax, %rdi
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	leaq	.LC3(%rip), %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	movq	%rbx, %rax
	popq	%rdx
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE3929:
	.size	_ZlsRSoRK5Point, .-_ZlsRSoRK5Point
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3955:
	.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
.LFE3955:
	.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
.LC0:
	.long	0
	.long	1071644672
	.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:

#ifndef point_cuh
#define point_cuh

#ifdef __HIPCC__
#define CUDA_HOSTDEV __host__ __device__
#define CUDA_DEV __device__
#else
#define CUDA_HOSTDEV
#define CUDA_DEV
#endif

#include <math.h>
#include <iostream>
#include <iomanip>

using namespace std;

/**
 * represent a point (x,y) on the plane
 * mutable; allows perturbing vertices
 */

class Point {
	private:
		double x, y;
		// determine if point is on edge of image and thus cannot move
		bool borderX, borderY;
	public:
		CUDA_HOSTDEV Point();
		CUDA_HOSTDEV Point(double x, double y, bool borderX = false, bool borderY = false);
		CUDA_HOSTDEV double getX() const;
		CUDA_HOSTDEV double getY() const;
		// return true if point was constructed on a vertical image edge
		bool isBorderX() const;
		bool isBorderY() const;
		CUDA_HOSTDEV double distance(Point &other);
		void move(double deltaX, double deltaY);
		CUDA_DEV bool operator==(const Point &other) const;
		CUDA_DEV bool operator!=(const Point &other) const;

		friend ostream& operator<<(ostream& os, const Point &p);
};

#endif

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

                                        # End of file scope inline assembly
	.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
