// File: /workspace/github_cpp_makefile_star2_O2/FakePsyho[P]halite2/MyBot.cpp
// Function: colonizeOrder(hlt::Ship const&, hlt::Planet const&, bool)
Order colonizeOrder(const Ship& ship, const Planet& planet, bool delay = false) {
	Order o;
	o.type = OrderType::Colonize;
	o.ship = ship.entity_id;
	o.planet = planet.entity_id;
	
	if (planetEnemyShips[planet.entity_id] > 0) return o;
	int spots_left = planet.docking_spots - planetMyShips[planet.entity_id];
	if (planetShipTurn[planet.entity_id] < (ship.location.dist(planet.location) - 4 - planet.radius) / 7.0) spots_left--;
	if (spots_left <= 0) return o;
	
	double v = 0;
	if (ship.can_dock(planet)) {
		v = 2500 + closestEnemy[ship.entity_id] + planetMyShips[planet.entity_id];
		// if (shipSafety[ship.entity_id] >= 2) v += 2000 + 100 * shipSafety[ship.entity_id];
		if (shipSafety[ship.entity_id] >= (players_no == 2 ? 2 : 1)) v += 2000;
		if (delay) v = -10000;
	} else {
		v = 2000 - ship.location.dist(planet.location) + planet.radius + planetValue[planet.entity_id] + (turn < 20 ? planetMyShips[planet.entity_id] * 2 : 0);
	}
	o.value = v;
	
	return o;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
callq 0x9c7c
movl $0x2, (%rbx)
movl (%r15), %eax
movl %eax, 0x60(%rbx)
movl (%r14), %eax
movl %eax, 0x64(%rbx)
leaq 0x18aeb(%rip), %rdi     # 0x1cfc8
movq %r14, %rsi
callq 0x9cd0
cmpl $0x0, (%rax)
jg 0x4677
movl %ebp, 0x14(%rsp)
movl 0x84(%r14), %ebp
leaq 0x18a98(%rip), %rdi     # 0x1cf98
movq %r14, %rsi
callq 0x9cd0
subl (%rax), %ebp
leaq 0x18937(%rip), %rdi     # 0x1ce48
movq %r14, %rsi
callq 0x9cd0
cvtsi2sdl (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x8(%r15), %r12
leaq 0x8(%r14), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x9ab4
addsd 0xdbc2(%rip), %xmm0     # 0x12100
subsd 0x70(%r14), %xmm0
divsd 0xdbbc(%rip), %xmm0     # 0x12108
xorl %eax, %eax
ucomisd 0x8(%rsp), %xmm0
seta %al
subl %eax, %ebp
testl %ebp, %ebp
movl 0x14(%rsp), %ebp
jle 0x4677
movq %r15, %rdi
movq %r14, %rsi
callq 0x9d1e
testb %al, %al
je 0x45e9
leaq 0x18a7d(%rip), %rdi     # 0x1cff8
movq %r15, %rsi
callq 0x9d46
movsd (%rax), %xmm0
addsd 0xdb89(%rip), %xmm0     # 0x12118
movsd %xmm0, 0x8(%rsp)
leaq 0x189fc(%rip), %rdi     # 0x1cf98
movq %r14, %rsi
callq 0x9cd0
cvtsi2sdl (%rax), %xmm0
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x1891d(%rip), %rdi     # 0x1ced8
movq %r15, %rsi
callq 0x9cd0
xorl %ecx, %ecx
cmpl $0x2, 0x17c64(%rip)     # 0x1c230
sete %cl
incl %ecx
cmpl %ecx, (%rax)
jl 0x465f
movsd 0x8(%rsp), %xmm0
addsd 0xdb29(%rip), %xmm0     # 0x12110
jmp 0x4665
movq %r12, %rdi
movq %r13, %rsi
callq 0x9ab4
movsd 0xdb14(%rip), %xmm1     # 0x12110
subsd %xmm0, %xmm1
addsd 0x70(%r14), %xmm1
movsd %xmm1, 0x8(%rsp)
leaq 0x18a45(%rip), %rdi     # 0x1d058
movq %r14, %rsi
callq 0x9d46
movsd 0x8(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
xorpd %xmm0, %xmm0
cmpl $0x13, 0x18b32(%rip)    # 0x1d168
jg 0x464f
leaq 0x18959(%rip), %rdi     # 0x1cf98
movq %r14, %rsi
callq 0x9cd0
movl (%rax), %eax
addl %eax, %eax
cvtsi2sd %eax, %xmm0
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, %xmm0
jmp 0x4672
movsd 0x8(%rsp), %xmm0
testb %bpl, %bpl
je 0x4672
movsd 0xdaae(%rip), %xmm0     # 0x12120
movsd %xmm0, 0x8(%rbx)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq