// File: /workspace/github_cpp_makefile_star2_O1/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
xorl %eax, %eax
movq %rax, 0x30(%rdi)
movb %al, 0x38(%rdi)
movb %al, 0x58(%rdi)
movq %rax, 0x3c(%rdi)
movb %al, 0x44(%rdi)
movl $0x0, (%rdi)
movabsq $-0x3e32329b00000000, %rcx # imm = 0xC1CDCD6500000000
movq %rcx, 0x8(%rdi)
movb %al, 0x1b(%rsp)
movq %rax, 0x13(%rsp)
pxor %xmm0, %xmm0
movdqu %xmm0, 0x1c(%rdi)
movdqu %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)
pcmpeqd %xmm0, %xmm0
movdqu %xmm0, 0x60(%rdi)
movl $0xffffffff, 0x70(%rdi) # imm = 0xFFFFFFFF
movl $0x2, (%rdi)
movl (%rsi), %eax
movl %eax, 0x60(%rdi)
movl (%rdx), %eax
movl %eax, 0x64(%rdi)
leaq 0x17ee3(%rip), %rdi     # 0x1dfc8
movq %rdx, %rsi
callq 0xde8c
cmpl $0x0, (%rax)
jg 0x630e
movl 0x84(%r14), %r12d
leaq 0x17e94(%rip), %rdi     # 0x1df98
movq %r14, %rsi
callq 0xde8c
subl (%rax), %r12d
leaq 0x17d32(%rip), %rdi     # 0x1de48
movq %r14, %rsi
callq 0xde8c
cvtsi2sdl (%rax), %xmm2
movsd 0x8(%r15), %xmm0
movsd 0x10(%r15), %xmm1
subsd 0x8(%r14), %xmm0
subsd 0x10(%r14), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x6156
sqrtsd %xmm0, %xmm0
jmp 0x6167
movsd %xmm2, 0x8(%rsp)
callq 0x31e0
movsd 0x8(%rsp), %xmm2
addsd 0xff39(%rip), %xmm0     # 0x160a8
subsd 0x70(%r14), %xmm0
divsd 0xff8b(%rip), %xmm0     # 0x16108
xorl %eax, %eax
ucomisd %xmm2, %xmm0
seta %al
subl %eax, %r12d
testl %r12d, %r12d
jle 0x630e
movsd 0x8(%r15), %xmm0
movsd 0x10(%r15), %xmm1
subsd 0x8(%r14), %xmm0
subsd 0x10(%r14), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x61c6
sqrtsd %xmm0, %xmm0
jmp 0x61cb
callq 0x31e0
movsd 0x70(%r14), %xmm1
addsd 0xff37(%rip), %xmm1     # 0x16110
ucomisd %xmm0, %xmm1
jae 0x6213
movsd 0x8(%r15), %xmm0
movsd 0x10(%r15), %xmm1
subsd 0x8(%r14), %xmm0
subsd 0x10(%r14), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x6287
sqrtsd %xmm0, %xmm0
jmp 0x628c
leaq 0x17dde(%rip), %rdi     # 0x1dff8
movq %r15, %rsi
callq 0xdef0
movsd (%rax), %xmm0
addsd 0xfeea(%rip), %xmm0     # 0x16118
movsd %xmm0, 0x8(%rsp)
leaq 0x17d5d(%rip), %rdi     # 0x1df98
movq %r14, %rsi
callq 0xde8c
xorps %xmm0, %xmm0
cvtsi2sdl (%rax), %xmm0
addsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
leaq 0x17c7b(%rip), %rdi     # 0x1ded8
movq %r15, %rsi
callq 0xde8c
xorl %ecx, %ecx
cmpl $0x2, 0x16fba(%rip)     # 0x1d228
sete %cl
incl %ecx
cmpl %ecx, (%rax)
jl 0x62f6
movsd 0x8(%rsp), %xmm0
addsd 0xfe9b(%rip), %xmm0     # 0x16120
jmp 0x62fc
callq 0x31e0
movsd 0xfe8c(%rip), %xmm1     # 0x16120
subsd %xmm0, %xmm1
addsd 0x70(%r14), %xmm1
movsd %xmm1, 0x8(%rsp)
leaq 0x17dad(%rip), %rdi     # 0x1e058
movq %r14, %rsi
callq 0xdef0
movsd 0x8(%rsp), %xmm0
addsd (%rax), %xmm0
cmpl $0x13, 0x17ea4(%rip)    # 0x1e168
xorpd %xmm1, %xmm1
jg 0x62f0
leaq 0x17cc7(%rip), %rdi     # 0x1df98
movq %r14, %rsi
movsd %xmm0, 0x8(%rsp)
callq 0xde8c
movsd 0x8(%rsp), %xmm0
movl (%rax), %eax
addl %eax, %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
addsd %xmm1, %xmm0
jmp 0x6309
movsd 0x8(%rsp), %xmm0
testb %bpl, %bpl
je 0x6309
movsd 0xfe1f(%rip), %xmm0     # 0x16128
movsd %xmm0, 0x8(%rbx)
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq