// File: /workspace/github_cpp_makefile_star2_O3/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 %r12
pushq %rbx
subq $0x20, %rsp
movl %ecx, %ebp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movabsq $-0x3e32329b00000000, %rax # imm = 0xC1CDCD6500000000
movq %rax, 0x8(%rdi)
xorl %eax, %eax
movb %al, 0x1b(%rsp)
movq %rax, 0x13(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x1c(%rdi)
movupd %xmm0, 0x10(%rdi)
movq %rax, 0x30(%rdi)
movb %al, 0x38(%rdi)
movq 0x10(%rsp), %rcx
movq %rcx, 0x39(%rdi)
movl 0x18(%rsp), %ecx
movl %ecx, 0x41(%rdi)
movb %al, 0x58(%rdi)
movl $0xffffffff, 0x70(%rdi) # imm = 0xFFFFFFFF
movq $-0x1, 0x68(%rdi)
movl $0x2, (%rdi)
movl (%rsi), %eax
movl %eax, 0x60(%rdi)
movl (%rdx), %eax
movl %eax, 0x64(%rdi)
leaq 0x18159(%rip), %rdi     # 0x1dfc8
movq %rdx, %rsi
callq 0xd752
cmpl $0x0, (%rax)
jg 0x6010
movl 0x84(%r14), %r12d
leaq 0x1810a(%rip), %rdi     # 0x1df98
movq %r14, %rsi
callq 0xd752
subl (%rax), %r12d
leaq 0x17fa8(%rip), %rdi     # 0x1de48
movq %r14, %rsi
callq 0xd752
cvtsi2sdl (%rax), %xmm1
movsd 0x8(%r15), %xmm0
movsd 0x10(%r15), %xmm2
subsd 0x8(%r14), %xmm0
subsd 0x10(%r14), %xmm2
mulsd %xmm2, %xmm2
mulsd %xmm0, %xmm0
addsd %xmm2, %xmm0
sqrtsd %xmm0, %xmm0
movsd 0x101c4(%rip), %xmm2    # 0x160a0
addsd %xmm0, %xmm2
movsd 0x70(%r14), %xmm3
subsd %xmm3, %xmm2
divsd 0x10216(%rip), %xmm2    # 0x16108
xorl %eax, %eax
ucomisd %xmm1, %xmm2
seta %al
subl %eax, %r12d
testl %r12d, %r12d
jle 0x6010
movsd 0x10201(%rip), %xmm1    # 0x16110
addsd %xmm3, %xmm1
ucomisd %xmm0, %xmm1
jae 0x5f84
movsd 0x101ff(%rip), %xmm1    # 0x16120
subsd %xmm0, %xmm1
addsd %xmm1, %xmm3
movsd %xmm3, 0x8(%rsp)
leaq 0x18122(%rip), %rdi     # 0x1e058
movq %r14, %rsi
callq 0xd7b8
movsd 0x8(%rsp), %xmm1
addsd (%rax), %xmm1
xorpd %xmm0, %xmm0
cmpl $0x13, 0x18215(%rip)    # 0x1e168
jg 0x5f7b
leaq 0x1803c(%rip), %rdi     # 0x1df98
movq %r14, %rsi
movsd %xmm1, 0x8(%rsp)
callq 0xd752
movsd 0x8(%rsp), %xmm1
movl (%rax), %eax
addl %eax, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
addsd %xmm0, %xmm1
jmp 0x600b
leaq 0x1806d(%rip), %rdi     # 0x1dff8
movq %r15, %rsi
callq 0xd7b8
movsd (%rax), %xmm0
addsd 0x10179(%rip), %xmm0    # 0x16118
movsd %xmm0, 0x8(%rsp)
leaq 0x17fec(%rip), %rdi     # 0x1df98
movq %r14, %rsi
callq 0xd752
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x17f0a(%rip), %rdi     # 0x1ded8
movq %r15, %rsi
callq 0xd752
xorl %ecx, %ecx
cmpl $0x2, 0x17249(%rip)     # 0x1d228
sete %cl
incl %ecx
cmpl %ecx, (%rax)
jl 0x5ff8
movsd 0x8(%rsp), %xmm1
addsd 0x1012a(%rip), %xmm1    # 0x16120
jmp 0x5ffe
movsd 0x8(%rsp), %xmm1
testb %bpl, %bpl
je 0x600b
movsd 0x1011d(%rip), %xmm1    # 0x16128
movsd %xmm1, 0x8(%rbx)
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq