//
// Created by David Matthews on 5/21/20.
//

#include "../include/BoundingBox.cuh"
#include <iomanip>

std::ostream &operator<<(std::ostream &out, const BoundingBox &bb) {
    return out << "((" << std::setprecision(3) << std::setw(8) << bb.x_min << " <-> " << std::setprecision(3)
               << std::setw(8) << bb.x_max << "), (" << std::setprecision(3) << std::setw(8) << bb.y_min << " <-> "
               << std::setprecision(3) << std::setw(8) << bb.y_max << "), (" << std::setprecision(3) << std::setw(8)
               << bb.z_min << " <-> " << std::setprecision(3) << std::setw(8) << bb.z_max << "))";
}

__device__ __host__
bool overlap(BoundingBox *a, BoundingBox *b) {

    return !((a->x_min > b->x_max || b->x_min > a->x_max) || // do a and b not overlap in X
             (a->y_min > b->y_max || b->y_min > a->y_max) || // do a and b not overlap in y
             (a->z_min > b->z_max || b->z_min > a->z_max)); // do a and b not overlap in z
}

	.file	"tmpxft_00350dc7_00000000-6_BoundingBox.cudafe1.cpp"
	.text
#APP
	.globl _ZSt21ios_base_library_initv

#NO_APP
	.type	_ZL26__cudaUnregisterBinaryUtilv, @function
_ZL26__cudaUnregisterBinaryUtilv:
.LFB3925:
	.cfi_startproc
	endbr64
	movq	_ZL20__cudaFatCubinHandle(%rip), %rdi
	jmp	__cudaUnregisterFatBinary@PLT
	.cfi_endproc
.LFE3925:
	.size	_ZL26__cudaUnregisterBinaryUtilv, .-_ZL26__cudaUnregisterBinaryUtilv
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"(("
.LC1:
	.string	" <-> "
.LC2:
	.string	"), ("
.LC3:
	.string	"))"
	.text
	.globl	_ZlsRSoRK11BoundingBox
	.type	_ZlsRSoRK11BoundingBox, @function
_ZlsRSoRK11BoundingBox:
.LFB3921:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC2(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leaq	.LC1(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	%rsi, %rbx
	leaq	.LC0(%rip), %rsi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	(%rbx), %xmm0
	movq	%rax, %rdi
	movq	(%rax), %rax
	movq	-24(%rax), %rdx
	movq	$3, 8(%rdi,%rdx)
	movq	-24(%rax), %rax
	movq	$8, 16(%rdi,%rax)
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rbp, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	4(%rbx), %xmm0
	movq	%rax, %rdi
	movq	(%rax), %rax
	movq	-24(%rax), %rdx
	movq	$3, 8(%rdi,%rdx)
	movq	-24(%rax), %rax
	movq	$8, 16(%rdi,%rax)
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%r12, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	8(%rbx), %xmm0
	movq	%rax, %rdi
	movq	(%rax), %rax
	movq	-24(%rax), %rdx
	movq	$3, 8(%rdi,%rdx)
	movq	-24(%rax), %rax
	movq	$8, 16(%rdi,%rax)
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rbp, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	12(%rbx), %xmm0
	movq	%rax, %rdi
	movq	(%rax), %rax
	movq	-24(%rax), %rdx
	movq	$3, 8(%rdi,%rdx)
	movq	-24(%rax), %rax
	movq	$8, 16(%rdi,%rax)
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%r12, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	16(%rbx), %xmm0
	movq	%rax, %rdi
	movq	(%rax), %rax
	movq	-24(%rax), %rdx
	movq	$3, 8(%rdi,%rdx)
	movq	-24(%rax), %rax
	movq	$8, 16(%rdi,%rax)
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	movq	%rbp, %rsi
	movq	%rax, %rdi
	call	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	cvtss2sd	20(%rbx), %xmm0
	movq	%rax, %rdi
	movq	(%rax), %rax
	movq	-24(%rax), %rdx
	movq	$3, 8(%rdi,%rdx)
	movq	-24(%rax), %rax
	movq	$8, 16(%rdi,%rax)
	call	_ZNSo9_M_insertIdEERSoT_@PLT
	popq	%rbx
	.cfi_def_cfa_offset 24
	leaq	.LC3(%rip), %rsi
	popq	%rbp
	.cfi_def_cfa_offset 16
	movq	%rax, %rdi
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@PLT
	.cfi_endproc
.LFE3921:
	.size	_ZlsRSoRK11BoundingBox, .-_ZlsRSoRK11BoundingBox
	.globl	_Z7overlapP11BoundingBoxS0_
	.type	_Z7overlapP11BoundingBoxS0_, @function
_Z7overlapP11BoundingBoxS0_:
.LFB3922:
	.cfi_startproc
	endbr64
	movss	(%rdi), %xmm0
	xorl	%eax, %eax
	comiss	4(%rsi), %xmm0
	ja	.L4
	movss	(%rsi), %xmm0
	comiss	4(%rdi), %xmm0
	ja	.L4
	movss	8(%rdi), %xmm0
	comiss	12(%rsi), %xmm0
	ja	.L4
	movss	8(%rsi), %xmm0
	comiss	12(%rdi), %xmm0
	ja	.L4
	movss	16(%rdi), %xmm0
	comiss	20(%rsi), %xmm0
	ja	.L4
	movss	16(%rsi), %xmm0
	comiss	20(%rdi), %xmm0
	setbe	%al
.L4:
	ret
	.cfi_endproc
.LFE3922:
	.size	_Z7overlapP11BoundingBoxS0_, .-_Z7overlapP11BoundingBoxS0_
	.section	.text.startup,"ax",@progbits
	.type	_ZL24__sti____cudaRegisterAllv, @function
_ZL24__sti____cudaRegisterAllv:
.LFB3948:
	.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
.LFE3948:
	.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:

//
// Created by David Matthews on 5/21/20.
//


#include <hip/hip_runtime.h>
#include "../include/BoundingBox.cuh"
#include <iomanip>

std::ostream &operator<<(std::ostream &out, const BoundingBox &bb) {
    return out << "((" << std::setprecision(3) << std::setw(8) << bb.x_min << " <-> " << std::setprecision(3)
               << std::setw(8) << bb.x_max << "), (" << std::setprecision(3) << std::setw(8) << bb.y_min << " <-> "
               << std::setprecision(3) << std::setw(8) << bb.y_max << "), (" << std::setprecision(3) << std::setw(8)
               << bb.z_min << " <-> " << std::setprecision(3) << std::setw(8) << bb.z_max << "))";
}

__device__ __host__
bool overlap(BoundingBox *a, BoundingBox *b) {

    return !((a->x_min > b->x_max || b->x_min > a->x_max) || // do a and b not overlap in X
             (a->y_min > b->y_max || b->y_min > a->y_max) || // do a and b not overlap in y
             (a->z_min > b->z_max || b->z_min > a->z_max)); // do a and b not overlap in z
}

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

                                        # End of file scope inline assembly
	.globl	_ZlsRSoRK11BoundingBox          # -- Begin function _ZlsRSoRK11BoundingBox
	.type	_ZlsRSoRK11BoundingBox,@function
_ZlsRSoRK11BoundingBox:                 # @_ZlsRSoRK11BoundingBox
	.cfi_startproc
# %bb.0:
	pushq	%r15
	.cfi_def_cfa_offset 16
	pushq	%r14
	.cfi_def_cfa_offset 24
	pushq	%r12
	.cfi_def_cfa_offset 32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	pushq	%rax
	.cfi_def_cfa_offset 48
	.cfi_offset %rbx, -40
	.cfi_offset %r12, -32
	.cfi_offset %r14, -24
	.cfi_offset %r15, -16
	movq	%rsi, %rbx
	movq	%rdi, %r14
	movl	$.L.str, %esi
	movl	$2, %edx
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%r14), %rax
	movq	-24(%rax), %rcx
	movl	$3, %r15d
	movq	%r15, 8(%r14,%rcx)
	movq	-24(%rax), %rax
	movl	$8, %r12d
	movq	%r12, 16(%r14,%rax)
	cvtss2sd	(%rbx), %xmm0
	movq	%r14, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r14
	movl	$.L.str.1, %esi
	movl	$5, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%r14), %rax
	movq	-24(%rax), %rcx
	movq	%r15, 8(%r14,%rcx)
	movq	-24(%rax), %rax
	movq	%r12, 16(%r14,%rax)
	xorps	%xmm0, %xmm0
	cvtss2sd	4(%rbx), %xmm0
	movq	%r14, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r14
	movl	$.L.str.2, %esi
	movl	$4, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%r14), %rax
	movq	-24(%rax), %rcx
	movq	%r15, 8(%r14,%rcx)
	movq	-24(%rax), %rax
	movq	%r12, 16(%r14,%rax)
	xorps	%xmm0, %xmm0
	cvtss2sd	8(%rbx), %xmm0
	movq	%r14, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r14
	movl	$.L.str.1, %esi
	movl	$5, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%r14), %rax
	movq	-24(%rax), %rcx
	movq	%r15, 8(%r14,%rcx)
	movq	-24(%rax), %rax
	movq	%r12, 16(%r14,%rax)
	xorps	%xmm0, %xmm0
	cvtss2sd	12(%rbx), %xmm0
	movq	%r14, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r14
	movl	$.L.str.2, %esi
	movl	$4, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%r14), %rax
	movq	-24(%rax), %rcx
	movq	%r15, 8(%r14,%rcx)
	movq	-24(%rax), %rax
	movq	%r12, 16(%r14,%rax)
	xorps	%xmm0, %xmm0
	cvtss2sd	16(%rbx), %xmm0
	movq	%r14, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %r14
	movl	$.L.str.1, %esi
	movl	$5, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	(%r14), %rax
	movq	-24(%rax), %rcx
	movq	%r15, 8(%r14,%rcx)
	movq	-24(%rax), %rax
	movq	%r12, 16(%r14,%rax)
	xorps	%xmm0, %xmm0
	cvtss2sd	20(%rbx), %xmm0
	movq	%r14, %rdi
	callq	_ZNSo9_M_insertIdEERSoT_
	movq	%rax, %rbx
	movl	$.L.str.3, %esi
	movl	$2, %edx
	movq	%rax, %rdi
	callq	_ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
	movq	%rbx, %rax
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	retq
.Lfunc_end0:
	.size	_ZlsRSoRK11BoundingBox, .Lfunc_end0-_ZlsRSoRK11BoundingBox
	.cfi_endproc
                                        # -- End function
	.globl	_Z7overlapP11BoundingBoxS0_     # -- Begin function _Z7overlapP11BoundingBoxS0_
	.type	_Z7overlapP11BoundingBoxS0_,@function
_Z7overlapP11BoundingBoxS0_:            # @_Z7overlapP11BoundingBoxS0_
	.cfi_startproc
# %bb.0:
	movss	(%rdi), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	ucomiss	4(%rsi), %xmm0
	ja	.LBB1_5
# %bb.1:
	movss	(%rsi), %xmm0                   # xmm0 = mem[0],zero,zero,zero
	ucomiss	4(%rdi), %xmm0
	ja	.LBB1_5
# %bb.2:
	movss	8(%rdi), %xmm0                  # xmm0 = mem[0],zero,zero,zero
	ucomiss	12(%rsi), %xmm0
	ja	.LBB1_5
# %bb.3:
	movss	8(%rsi), %xmm0                  # xmm0 = mem[0],zero,zero,zero
	ucomiss	12(%rdi), %xmm0
	ja	.LBB1_5
# %bb.4:
	movss	16(%rdi), %xmm0                 # xmm0 = mem[0],zero,zero,zero
	ucomiss	20(%rsi), %xmm0
	jbe	.LBB1_7
.LBB1_5:
	xorl	%eax, %eax
                                        # kill: def $al killed $al killed $eax
	retq
.LBB1_7:
	movss	16(%rsi), %xmm0                 # xmm0 = mem[0],zero,zero,zero
	ucomiss	20(%rdi), %xmm0
	setbe	%al
                                        # kill: def $al killed $al killed $eax
	retq
.Lfunc_end1:
	.size	_Z7overlapP11BoundingBoxS0_, .Lfunc_end1-_Z7overlapP11BoundingBoxS0_
	.cfi_endproc
                                        # -- End function
	.type	.L.str,@object                  # @.str
	.section	.rodata.str1.1,"aMS",@progbits,1
.L.str:
	.asciz	"(("
	.size	.L.str, 3

	.type	.L.str.1,@object                # @.str.1
.L.str.1:
	.asciz	" <-> "
	.size	.L.str.1, 6

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

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

	.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
