// File: /workspace/github_cpp_makefile_star2_O3/FakePsyho[P]halite2/MyBot.cpp
// Function: getSpawningPoint(hlt::Planet&)
Location getSpawningPoint(Planet& p) {
	Location bloc(-1e9, -1e9);
	Location origin(m.map_width / 2.0, m.map_height / 2.0);
	VC<Entity> entities = findCloseEntities(p.location, p.radius + 10, MASK_ALL);
	FOR(dx, -SPAWN_RADIUS, +SPAWN_RADIUS + 1) FOR(dy, -SPAWN_RADIUS, +SPAWN_RADIUS + 1) {
		double offset_angle = atan2(dy, dx);
		double offset_x = dx + p.radius * cos(offset_angle);
		double offset_y = dy + p.radius * sin(offset_angle);
		auto loc = p.location + Location(offset_x, offset_y);
		
		bool collision = false;
		for (Entity& e : entities) if (loc.dist(e.location) < SHIP_RADIUS * 4) {
			collision = true;
			break;
		}
		if (collision) continue;
		if (origin.dist_sq(loc) < origin.dist_sq(bloc)) bloc = loc;
	}
	return bloc;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x90, %rsp
movq %rdi, %rbx
cvtsi2sdl 0x1945a(%rip), %xmm1 # 0x1dce8
movsd 0x11782(%rip), %xmm0    # 0x16018
mulsd %xmm0, %xmm1
movapd %xmm1, 0x20(%rsp)
xorps %xmm1, %xmm1
cvtsi2sdl 0x19441(%rip), %xmm1 # 0x1dcec
mulsd %xmm0, %xmm1
movapd %xmm1, 0x10(%rsp)
movsd 0x8(%rdi), %xmm0
movsd 0x10(%rdi), %xmm1
movsd 0x70(%rdi), %xmm2
addsd 0x11754(%rip), %xmm2    # 0x16020
leaq 0x58(%rsp), %rdi
movl $0x1f, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3ff2
movaps 0x20(%rsp), %xmm0
movlhps %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movaps %xmm0, 0x20(%rsp)
movaps 0x10(%rsp), %xmm0
movlhps %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movaps %xmm0, 0x10(%rsp)
movaps 0x1193f(%rip), %xmm0    # 0x16240
movaps %xmm0, 0x30(%rsp)
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
movsd 0x11715(%rip), %xmm0    # 0x16028
movapd %xmm0, (%rsp)
movsd 0x11708(%rip), %xmm5    # 0x16028
movl $0xfffffffe, %r14d      # imm = 0xFFFFFFFE
movaps %xmm5, 0x80(%rsp)
movaps %xmm5, %xmm0
movaps (%rsp), %xmm1
callq 0x3050
movaps %xmm0, %xmm1
movsd %xmm0, 0x50(%rsp)
movups 0x70(%rbx), %xmm0
movaps %xmm0, 0x40(%rsp)
movaps %xmm1, %xmm0
callq 0x3410
movaps %xmm0, 0x70(%rsp)
movaps 0x40(%rsp), %xmm0
movhps 0x70(%rbx), %xmm0       # xmm0 = xmm0[0,1],mem[0,1]
movaps %xmm0, 0x40(%rsp)
movsd 0x50(%rsp), %xmm0
callq 0x3070
movapd 0x80(%rsp), %xmm5
movapd 0x70(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
mulpd 0x40(%rsp), %xmm1
movapd %xmm1, %xmm0
movapd (%rsp), %xmm1
unpcklpd %xmm5, %xmm1            # xmm1 = xmm1[0],xmm5[0]
addpd %xmm0, %xmm1
movupd 0x8(%rbx), %xmm0
addpd %xmm1, %xmm0
movq 0x58(%rsp), %rdi
movq 0x60(%rsp), %rax
cmpq %rax, %rdi
movsd 0x11676(%rip), %xmm4    # 0x16030
je 0x49f8
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
movq %rdi, %rcx
movapd %xmm0, %xmm2
subsd 0x8(%rcx), %xmm2
movapd %xmm1, %xmm3
subsd 0x10(%rcx), %xmm3
mulsd %xmm3, %xmm3
mulsd %xmm2, %xmm2
addsd %xmm3, %xmm2
sqrtsd %xmm2, %xmm2
ucomisd %xmm2, %xmm4
ja 0x4a42
addq $0x78, %rcx
cmpq %rax, %rcx
jne 0x49c7
movapd %xmm0, %xmm1
movapd 0x30(%rsp), %xmm3
unpcklpd %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0]
movapd 0x20(%rsp), %xmm2
subpd %xmm1, %xmm2
movapd %xmm0, %xmm1
unpckhpd %xmm3, %xmm1            # xmm1 = xmm1[1],xmm3[1]
movapd 0x10(%rsp), %xmm3
subpd %xmm1, %xmm3
mulpd %xmm3, %xmm3
mulpd %xmm2, %xmm2
addpd %xmm3, %xmm2
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
ucomisd %xmm2, %xmm1
jbe 0x4a42
movapd %xmm0, 0x30(%rsp)
addsd 0x115c6(%rip), %xmm5    # 0x16010
incl %r14d
cmpl $0x3, %r14d
jne 0x4926
movapd (%rsp), %xmm0
addsd 0x115ac(%rip), %xmm0    # 0x16010
movapd %xmm0, (%rsp)
incl %ebp
cmpl $0x3, %ebp
jne 0x4918
testq %rdi, %rdi
je 0x4a86
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x3240
movaps 0x30(%rsp), %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addq $0x90, %rsp
popq %rbx
popq %r14
popq %rbp
retq