// File: 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:
subq $0x128, %rsp            # imm = 0x128
movq %rdi, 0x110(%rsp)
leaq 0x118(%rsp), %rdi
movsd 0x36481(%rip), %xmm1    # 0x3b020
movaps %xmm1, %xmm0
callq 0x13380
cvtsi2sdl 0x4d179(%rip), %xmm0 # 0x51d28
movsd 0x36461(%rip), %xmm1    # 0x3b018
divsd %xmm1, %xmm0
cvtsi2sdl 0x4d169(%rip), %xmm1 # 0x51d2c
movsd 0x3644d(%rip), %xmm2    # 0x3b018
divsd %xmm2, %xmm1
leaq 0x100(%rsp), %rdi
callq 0x13380
movq 0x110(%rsp), %rax
movq 0x8(%rax), %rcx
movq %rcx, 0xd8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0xe0(%rsp)
movq 0x110(%rsp), %rax
movsd 0x36404(%rip), %xmm2    # 0x3b010
addsd 0x70(%rax), %xmm2
movsd 0xd8(%rsp), %xmm0
movsd 0xe0(%rsp), %xmm1
leaq 0xe8(%rsp), %rdi
movl $0x1f, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3f40
movl $0xfffffffe, 0xd4(%rsp) # imm = 0xFFFFFFFE
cmpl $0x3, 0xd4(%rsp)
jge 0x4f25
movl $0xfffffffe, 0xd0(%rsp) # imm = 0xFFFFFFFE
cmpl $0x3, 0xd0(%rsp)
jge 0x4f0d
movl 0xd0(%rsp), %edi
movl 0xd4(%rsp), %esi
callq 0x133b0
movsd %xmm0, 0x58(%rsp)
jmp 0x4c87
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0xc8(%rsp)
cvtsi2sdl 0xd4(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movq 0x110(%rsp), %rax
movsd 0x70(%rax), %xmm0
movsd %xmm0, 0x38(%rsp)
movsd 0xc8(%rsp), %xmm0
callq 0x3470
movsd 0x30(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x38(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0xb0(%rsp)
cvtsi2sdl 0xd0(%rsp), %xmm0
movsd %xmm0, 0x40(%rsp)
movq 0x110(%rsp), %rax
movsd 0x70(%rax), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0xc8(%rsp), %xmm0
callq 0x30a0
movsd 0x40(%rsp), %xmm1
movaps %xmm0, %xmm2
movsd 0x48(%rsp), %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0xa8(%rsp)
movq 0x110(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x50(%rsp)
movsd 0xb0(%rsp), %xmm0
movsd 0xa8(%rsp), %xmm1
leaq 0x88(%rsp), %rdi
callq 0x13380
jmp 0x4d68
movq 0x50(%rsp), %rdi
movsd 0x88(%rsp), %xmm0
movsd 0x90(%rsp), %xmm1
callq 0x12fa0
movsd %xmm1, 0x20(%rsp)
movsd %xmm0, 0x28(%rsp)
jmp 0x4d92
movsd 0x20(%rsp), %xmm0
movsd 0x28(%rsp), %xmm1
movsd %xmm1, 0x98(%rsp)
movsd %xmm0, 0xa0(%rsp)
movb $0x0, 0x87(%rsp)
leaq 0xe8(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rdi
callq 0x12ed0
movq %rax, 0x70(%rsp)
movq 0x78(%rsp), %rdi
callq 0x12f00
movq %rax, 0x68(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x12f30
testb $0x1, %al
jne 0x4dfb
jmp 0x4e7d
leaq 0x70(%rsp), %rdi
callq 0x12f70
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rsi
addq $0x8, %rsi
leaq 0x98(%rsp), %rdi
callq 0x12ac0
movsd %xmm0, 0x18(%rsp)
jmp 0x4e28
movsd 0x18(%rsp), %xmm1
movsd 0x361e2(%rip), %xmm0    # 0x3b018
ucomisd %xmm1, %xmm0
jbe 0x4e6c
movb $0x1, 0x87(%rsp)
jmp 0x4e7d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xc0(%rsp)
movl %eax, 0xbc(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0x12de0
jmp 0x4f4c
jmp 0x4e6e
leaq 0x70(%rsp), %rdi
callq 0x12f80
jmp 0x4de3
testb $0x1, 0x87(%rsp)
je 0x4e89
jmp 0x4ef7
leaq 0x100(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x133d0
movsd %xmm0, 0x10(%rsp)
jmp 0x4ea6
leaq 0x100(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x133d0
movsd %xmm0, 0x8(%rsp)
jmp 0x4ec3
movsd 0x8(%rsp), %xmm0
movsd 0x10(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x4ef5
movq 0x98(%rsp), %rax
movq %rax, 0x118(%rsp)
movq 0xa0(%rsp), %rax
movq %rax, 0x120(%rsp)
jmp 0x4ef7
movl 0xd0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xd0(%rsp)
jmp 0x4c5e
jmp 0x4f0f
movl 0xd4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xd4(%rsp)
jmp 0x4c45
leaq 0xe8(%rsp), %rdi
callq 0x12de0
movsd 0x118(%rsp), %xmm0
movsd 0x120(%rsp), %xmm1
addq $0x128, %rsp            # imm = 0x128
retq
movq 0xc0(%rsp), %rdi
callq 0x3440
nopl (%rax)