// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
cvtsi2sdl 0x19409(%rip), %xmm1 # 0x1dce8
movsd 0x11739(%rip), %xmm0    # 0x16020
mulsd %xmm0, %xmm1
movapd %xmm1, 0x30(%rsp)
xorps %xmm1, %xmm1
cvtsi2sdl 0x193f0(%rip), %xmm1 # 0x1dcec
mulsd %xmm0, %xmm1
movapd %xmm1, 0x20(%rsp)
movsd 0x8(%rdi), %xmm0
movsd 0x10(%rdi), %xmm1
movsd 0x70(%rdi), %xmm2
addsd 0x1170b(%rip), %xmm2    # 0x16028
leaq 0x68(%rsp), %rdi
movl $0x1f, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3ff2
movaps 0x30(%rsp), %xmm0
movlhps %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movaps %xmm0, 0x30(%rsp)
movaps 0x20(%rsp), %xmm0
movlhps %xmm0, %xmm0            # xmm0 = xmm0[0,0]
movaps %xmm0, 0x20(%rsp)
movaps 0x118ee(%rip), %xmm0    # 0x16240
movaps %xmm0, 0x40(%rsp)
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
movsd 0x116cc(%rip), %xmm0    # 0x16030
movapd %xmm0, 0x10(%rsp)
movsd 0x116be(%rip), %xmm0    # 0x16030
movl $0xfffffffe, %r14d      # imm = 0xFFFFFFFE
movaps %xmm0, 0x80(%rsp)
movaps 0x10(%rsp), %xmm1
callq 0x3050
movaps %xmm0, %xmm1
movsd %xmm0, 0x60(%rsp)
movups 0x70(%rbx), %xmm0
movaps %xmm0, (%rsp)
movaps %xmm1, %xmm0
callq 0x3410
movaps %xmm0, 0x50(%rsp)
movaps (%rsp), %xmm0
movhps 0x70(%rbx), %xmm0       # xmm0 = xmm0[0,1],mem[0,1]
movaps %xmm0, (%rsp)
movsd 0x60(%rsp), %xmm0
callq 0x3070
movapd 0x50(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
mulpd (%rsp), %xmm1
movapd 0x10(%rsp), %xmm0
unpcklpd 0x80(%rsp), %xmm0       # xmm0 = xmm0[0],mem[0]
addpd %xmm1, %xmm0
movupd 0x8(%rbx), %xmm3
addpd %xmm0, %xmm3
movq 0x68(%rsp), %r12
movq 0x70(%rsp), %r15
cmpq %r15, %r12
je 0x4a88
movapd %xmm3, %xmm2
unpckhpd %xmm3, %xmm2            # xmm2 = xmm2[1],xmm3[1]
addq $0x78, %r12
xorl %r13d, %r13d
movapd %xmm3, (%rsp)
movapd %xmm2, 0x50(%rsp)
movapd %xmm3, %xmm0
subsd -0x70(%r12), %xmm0
movapd %xmm2, %xmm1
subsd -0x68(%r12), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x115cf(%rip), %xmm0    # 0x16010
jb 0x4a49
sqrtsd %xmm0, %xmm0
jmp 0x4a59
callq 0x31e0
movapd 0x50(%rsp), %xmm2
movapd (%rsp), %xmm3
leaq 0x78(%r12), %rax
movsd 0x115d2(%rip), %xmm1    # 0x16038
ucomisd %xmm0, %xmm1
movl $0x1, %ecx
ja 0x4a75
movzbl %r13b, %ecx
movl %ecx, %r13d
ja 0x4a82
cmpq %r15, %r12
movq %rax, %r12
jne 0x4a17
testb $0x1, %r13b
jne 0x4ad2
movapd %xmm3, %xmm0
movapd 0x40(%rsp), %xmm2
unpcklpd %xmm2, %xmm0            # xmm0 = xmm0[0],xmm2[0]
movapd 0x30(%rsp), %xmm1
subpd %xmm0, %xmm1
movapd %xmm3, %xmm0
unpckhpd %xmm2, %xmm0            # xmm0 = xmm0[1],xmm2[1]
movapd 0x20(%rsp), %xmm2
subpd %xmm0, %xmm2
mulpd %xmm2, %xmm2
mulpd %xmm1, %xmm1
addpd %xmm2, %xmm1
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
ucomisd %xmm1, %xmm0
jbe 0x4ad2
movapd %xmm3, 0x40(%rsp)
movapd 0x80(%rsp), %xmm0
addsd 0x11535(%rip), %xmm0    # 0x16018
incl %r14d
cmpl $0x3, %r14d
jne 0x4978
movapd 0x10(%rsp), %xmm0
addsd 0x1151a(%rip), %xmm0    # 0x16018
movapd %xmm0, 0x10(%rsp)
incl %ebp
cmpl $0x3, %ebp
jne 0x496a
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x4b26
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x3240
movaps 0x40(%rsp), %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq