// File: /workspace/github_cpp_makefile_star2_O1/FakePsyho[P]halite2/MyBot.cpp
// Function: execOrder(Order&)
Move execOrder(Order &o) {
	const Ship& ship = m.get_ship(player_id, o.ship);
	
	if (o.type == OrderType::Colonize) {
		Planet& planet = m.planets[o.planet];
		if (ship.can_dock(planet)) {
			Move mv = Move::dock(ship.entity_id, planet.entity_id);
			mv.evasion = Evasion::None;
			return mv;
		} else {
			Move mv = move_to(ship, planet.location);
			mv.evasion = Evasion::None;
			return mv;
		}
		
	} else if (o.type == OrderType::AttackShip) {
		Ship eship = *enemyShips[o.target];
		double dist = ship.location.get_distance_to(eship.location);
		Location loc;
		loc = ship.location + (eship.location - ship.location).normalize() * max(MAX_SPEED, eship.location.dist(ship.location));
		if (!m.in_ex_bounds(loc, 4)) loc = ship.location + (eship.location - ship.location).normalize() * 1000;
		if (shipTarget[eship.entity_id] != eship.location)
			loc = shipTarget[eship.entity_id];
		double aces = 1e9;
		for (auto &e : findCloseEntities(ship.location, 10.0, MASK_ALLIES, ship.entity_id)) aces = min(aces, closestEnemyShip[e.entity_id]);
		double ces = closestEnemyShip[ship.entity_id];
		double maxSpeed = MAX_SPEED;
		if (maxFollowers[eship.entity_id] > 2 && ces < 20.0 && aces < 25.0 && ces < aces) maxSpeed = max(3.0, min(MAX_SPEED, 7.0 - (aces - ces) / 3));
		Move mv = move_to(ship, loc, maxSpeed);
		// Move mv = move_to(ship, eship.location, MAX_SPEED);
		mv.evasion = Evasion::Small;
		return mv;
		
	} else if (o.type == OrderType::AttackMiner) {
		Ship eship = *enemyShips[o.target];
		double dist = ship.location.get_distance_to(eship.location);
		
		double aces = 1e9;
		for (auto &e : findCloseEntities(ship.location, 10.0, MASK_ALLIES, ship.entity_id)) aces = min(aces, closestEnemyShip[e.entity_id]);
		double ces = closestEnemyShip[ship.entity_id];
		double maxSpeed = MAX_SPEED;
		if (maxFollowers[eship.entity_id] > 2 && ces < 20.0 && aces < 25.0 && ces < aces) maxSpeed = max(3.0, min(MAX_SPEED, 7.0 - (aces - ces) / 3));
		
		Move mv = move_to(ship, eship.location, maxSpeed, 5.05);
		mv.evasion = Evasion::Medium;
		return mv;
		
	} else if (o.type == OrderType::HitAndRun) {
		Ship eship = *enemyShips[o.target];
		double dist = ship.location.get_distance_to(eship.location);
		Move mv = move_to(ship, eship.location, MAX_SPEED, 5.05, true);
		mv.evasion = Evasion::None;
		return mv;
		
	// } else if (o.type == OrderType::DefendMiner) {
		// Ship aship = m.get_ship(player_id, aggressiveShips[o.target]);
		// double dist = ship.location.get_distance_to(aship.location);
		// Move mv = Move::stop(ship.entity_id);
		// REP(tries, 10) {
			// auto nav = move_to(ship, aship.location + Location(rng.nextDouble(-2, 2), rng.nextDouble(-2, 2)), max(0.0, min(dist + 1.25, MAX_SPEED)));
			// if (nav.Y) {
				// mv = nav.X;
				// break;
			// }
		// }
		// mv.evasion = Evasion::None;
		// return mv;		
		
	} else if (o.type == OrderType::Hide) {
		Location loc = Location(o.cornerx == 0 ? 1 : m.map_width - 1, o.cornery == 0 ? 1 : m.map_height - 1);
		double dist = ship.location.get_distance_to(loc);
		Move mv = move_to(ship, loc, min(dist, MAX_SPEED), 0.0, true);
		mv.evasion = Evasion::None;
		return mv;
		
	} else if (o.type == OrderType::Undock) {
		Move mv = Move::undock(ship.entity_id);
		return mv;
		
	} else {
		assert(false);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd0, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movl 0x174f9(%rip), %esi     # 0x1dcdc
movl 0x60(%r15), %edx
leaq 0x174fa(%rip), %rdi     # 0x1dce8
callq 0xddfc
movq %rax, %r14
movl (%r15), %eax
addl $-0x2, %eax
cmpl $0x6, %eax
ja 0x6fdd
leaq 0xfac4(%rip), %rcx      # 0x162d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x64(%r15), %eax
movq 0x17548(%rip), %r15     # 0x1dd68
leaq (%rax,%rax,4), %r12
shlq $0x5, %r12
leaq (%r15,%r12), %r13
movsd 0x8(%r14), %xmm0
movsd 0x10(%r14), %xmm1
subsd 0x8(%r15,%r12), %xmm0
subsd 0x10(%r15,%r12), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x6d57
sqrtsd %xmm0, %xmm0
jmp 0x6d5c
movq 0x6c(%r15), %xmm0
pxor %xmm1, %xmm1
pcmpeqd %xmm0, %xmm1
movq 0x17469(%rip), %xmm0    # 0x1dce8
pcmpeqd %xmm2, %xmm2
paddd %xmm0, %xmm2
movdqa %xmm1, %xmm0
pandn %xmm2, %xmm0
psrld $0x1f, %xmm1
por %xmm0, %xmm1
cvtdq2pd %xmm1, %xmm1
movapd %xmm1, 0x40(%rsp)
movsd 0x8(%r14), %xmm0
movsd 0x10(%r14), %xmm2
subsd %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
subsd %xmm1, %xmm2
mulsd %xmm2, %xmm2
mulsd %xmm0, %xmm0
addsd %xmm2, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x6bf7
sqrtsd %xmm0, %xmm0
jmp 0x6bfc
movl 0x68(%r15), %eax
leaq 0x10(%rsp), %rsi
movl %eax, (%rsi)
leaq 0x17831(%rip), %rdi     # 0x1e120
callq 0xdfb8
movq (%rax), %rsi
leaq 0x40(%rsp), %r15
movl $0x88, %edx
movq %r15, %rdi
callq 0x31f0
movsd 0x8(%r14), %xmm0
movsd 0x10(%r14), %xmm1
subsd 0x8(%r15), %xmm0
subsd 0x10(%r15), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm0
jae 0x6940
callq 0x31e0
xorpd %xmm2, %xmm2
movupd 0x8(%r14), %xmm0
movupd 0x48(%rsp), %xmm4
subpd %xmm0, %xmm4
movapd %xmm4, %xmm1
mulpd %xmm4, %xmm1
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
movapd %xmm4, %xmm0
mulsd %xmm4, %xmm0
addsd %xmm1, %xmm0
ucomisd %xmm2, %xmm0
jb 0x6c28
sqrtsd %xmm0, %xmm0
jmp 0x6c37
movl (%r14), %eax
xorl %ecx, %ecx
movq %rcx, 0x20(%rbx)
movb %cl, 0x28(%rbx)
movb %cl, 0x48(%rbx)
movq %rcx, 0x2c(%rbx)
movb %cl, 0x34(%rbx)
movl $0x3, (%rbx)
movl %eax, 0x4(%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rbx)
movl $0x0, 0x18(%rbx)
jmp 0x6fc9
movl 0x68(%r15), %eax
leaq 0x10(%rsp), %rsi
movl %eax, (%rsi)
leaq 0x1775f(%rip), %rdi     # 0x1e120
callq 0xdfb8
movq (%rax), %rsi
leaq 0x40(%rsp), %r15
movl $0x88, %edx
movq %r15, %rdi
callq 0x31f0
movsd 0x8(%r14), %xmm0
movsd 0x10(%r14), %xmm1
subsd 0x8(%r15), %xmm0
subsd 0x10(%r15), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jae 0x6a0e
callq 0x31e0
movsd 0x8(%r14), %xmm0
movsd 0x10(%r14), %xmm1
movl (%r14), %edx
leaq 0x10(%rsp), %r12
movsd 0xf5fe(%rip), %xmm2     # 0x16028
movq %r12, %rdi
movl $0x2, %esi
callq 0x3ff2
movq (%r12), %r15
movq 0x8(%r12), %r13
movsd 0xf640(%rip), %xmm0     # 0x16088
cmpq %r13, %r15
je 0x6a7b
movsd %xmm0, (%rsp)
leaq 0x1744f(%rip), %r12     # 0x1dea8
movq %r12, %rdi
movq %r15, %rsi
callq 0xdef0
movsd (%rax), %xmm0
minsd (%rsp), %xmm0
addq $0x78, %r15
movsd %xmm0, (%rsp)
cmpq %r13, %r15
jne 0x6a59
movsd %xmm0, 0x28(%rsp)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x6a98
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3240
leaq 0x48(%rsp), %r15
leaq 0x17404(%rip), %rdi     # 0x1dea8
movq %r14, %rsi
callq 0xdef0
movsd (%rax), %xmm0
movsd %xmm0, (%rsp)
leaq 0x1744c(%rip), %rdi     # 0x1df08
leaq 0x40(%rsp), %rsi
callq 0xde8c
cmpl $0x3, (%rax)
movsd 0xf637(%rip), %xmm0     # 0x16108
jl 0x6b28
movsd 0xf68d(%rip), %xmm1     # 0x16168
movsd (%rsp), %xmm2
ucomisd %xmm2, %xmm1
jbe 0x6b28
movsd 0xf56a(%rip), %xmm1     # 0x16058
movsd 0x28(%rsp), %xmm3
ucomisd %xmm3, %xmm1
jbe 0x6b28
ucomisd %xmm2, %xmm3
jbe 0x6b28
subsd %xmm2, %xmm3
movsd 0xf664(%rip), %xmm1     # 0x16170
divsd %xmm1, %xmm3
movsd 0xf5f0(%rip), %xmm2     # 0x16108
movapd %xmm2, %xmm0
subsd %xmm3, %xmm0
minsd %xmm2, %xmm0
maxsd %xmm1, %xmm0
movsd 0xf630(%rip), %xmm1     # 0x16160
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq $0x0
pushq $-0x1
callq 0x4c6b
addq $0x10, %rsp
movl $0x2, 0x30(%rbx)
jmp 0x6fc9
movl 0x68(%r15), %eax
leaq 0x10(%rsp), %rsi
movl %eax, (%rsi)
leaq 0x175b4(%rip), %rdi     # 0x1e120
callq 0xdfb8
movq (%rax), %rsi
leaq 0x40(%rsp), %rdi
movl $0x88, %edx
callq 0x31f0
leaq 0x48(%rsp), %r15
movsd 0x8(%r14), %xmm0
movsd 0x10(%r14), %xmm1
subsd (%r15), %xmm0
subsd 0x8(%r15), %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm0, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jae 0x6bba
callq 0x31e0
xorl %r12d, %r12d
movsd 0xf543(%rip), %xmm0     # 0x16108
movsd 0xf593(%rip), %xmm1     # 0x16160
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movl $0x1, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %r12
pushq $-0x1
callq 0x4c6b
addq $0x10, %rsp
movl %r12d, 0x30(%rbx)
jmp 0x6fc9
callq 0x31e0
movsd 0xf504(%rip), %xmm2     # 0x16108
minsd %xmm0, %xmm2
xorl %r15d, %r15d
leaq 0x40(%rsp), %rdx
xorpd %xmm1, %xmm1
movq %rbx, %rdi
movq %r14, %rsi
movapd %xmm2, %xmm0
movl $0x1, %ecx
jmp 0x6d8f
movapd %xmm4, (%rsp)
callq 0x31e0
movapd (%rsp), %xmm4
xorpd %xmm1, %xmm1
movapd %xmm0, %xmm2
cmpneqsd %xmm1, %xmm2
movq %xmm2, %rax
andl $0x1, %eax
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm4
movd %eax, %xmm0
pshufd $0x0, %xmm0, %xmm3      # xmm3 = xmm0[0,0,0,0]
pslld $0x1f, %xmm3
psrad $0x1f, %xmm3
pand %xmm4, %xmm3
movsd 0x48(%rsp), %xmm0
subsd 0x8(%r14), %xmm0
movsd 0x50(%rsp), %xmm2
subsd 0x10(%r14), %xmm2
mulsd %xmm2, %xmm2
mulsd %xmm0, %xmm0
addsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jb 0x6c9b
sqrtsd %xmm0, %xmm0
jmp 0x6caa
movdqa %xmm3, (%rsp)
callq 0x31e0
movdqa (%rsp), %xmm3
maxsd 0xf456(%rip), %xmm0     # 0x16108
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
mulpd %xmm0, %xmm3
movupd 0x8(%r14), %xmm0
addpd %xmm0, %xmm3
movapd %xmm3, 0x30(%rsp)
ucomisd 0xf3ce(%rip), %xmm3     # 0x160a0
jbe 0x6d18
xorps %xmm1, %xmm1
cvtsi2sdl 0x17009(%rip), %xmm1 # 0x1dce8
addsd 0xf3c1(%rip), %xmm1     # 0x160a8
ucomisd %xmm3, %xmm1
jbe 0x6d18
unpckhpd %xmm3, %xmm3            # xmm3 = xmm3[1,1]
ucomisd 0xf3a7(%rip), %xmm3     # 0x160a0
jbe 0x6d18
xorps %xmm1, %xmm1
cvtsi2sdl 0x16fe6(%rip), %xmm1 # 0x1dcec
addsd 0xf39a(%rip), %xmm1     # 0x160a8
ucomisd %xmm3, %xmm1
ja 0x6e3d
movupd 0x48(%rsp), %xmm2
movhpd 0x10(%r14), %xmm0       # xmm0 = xmm0[0],mem[0]
subpd %xmm0, %xmm2
movapd %xmm2, %xmm1
mulpd %xmm2, %xmm1
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
movapd %xmm2, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x6de6
sqrtsd %xmm0, %xmm0
jmp 0x6df9
callq 0x31e0
movsd 0x70(%r13), %xmm1
addsd 0xf3a6(%rip), %xmm1     # 0x16110
ucomisd %xmm0, %xmm1
jae 0x6dab
leaq (%r15,%r12), %rdx
addq $0x8, %rdx
xorl %r15d, %r15d
movsd 0xf385(%rip), %xmm0     # 0x16108
xorpd %xmm1, %xmm1
movq %rbx, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %r15
pushq $-0x1
callq 0x4c6b
addq $0x10, %rsp
movl %r15d, 0x30(%rbx)
jmp 0x6fc9
movl (%r14), %eax
movl (%r13), %ecx
xorl %edx, %edx
movq %rdx, 0x20(%rbx)
movb %dl, 0x28(%rbx)
movb %dl, 0x48(%rbx)
movq %rdx, 0x2c(%rbx)
movb %dl, 0x34(%rbx)
movl $0x2, (%rbx)
movl %eax, 0x4(%rbx)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%rbx)
movl %ecx, 0x18(%rbx)
movl $0x0, 0x30(%rbx)
jmp 0x6fc9
movapd %xmm2, (%rsp)
callq 0x31e0
xorpd %xmm1, %xmm1
movapd (%rsp), %xmm2
cmpneqsd %xmm0, %xmm1
movq %xmm1, %rax
andl $0x1, %eax
unpcklpd %xmm0, %xmm0            # xmm0 = xmm0[0,0]
divpd %xmm0, %xmm2
mulpd 0xf46a(%rip), %xmm2     # 0x16280
movd %eax, %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
pslld $0x1f, %xmm0
psrad $0x1f, %xmm0
pand %xmm2, %xmm0
movupd 0x8(%r14), %xmm1
addpd %xmm0, %xmm1
movapd %xmm1, 0x30(%rsp)
leaq 0x16f74(%rip), %rdi     # 0x1ddb8
leaq 0x40(%rsp), %r15
movq %r15, %rsi
callq 0xe01c
movsd (%rax), %xmm0
ucomisd 0x8(%r15), %xmm0
jne 0x6e6e
jp 0x6e6e
movsd 0x8(%rax), %xmm0
ucomisd 0x50(%rsp), %xmm0
jne 0x6e6e
jnp 0x6e89
leaq 0x16f43(%rip), %rdi     # 0x1ddb8
leaq 0x40(%rsp), %rsi
callq 0xe01c
movupd (%rax), %xmm0
movapd %xmm0, 0x30(%rsp)
movsd 0x8(%r14), %xmm0
movsd 0x10(%r14), %xmm1
movl (%r14), %edx
leaq 0x10(%rsp), %r12
movsd 0xf183(%rip), %xmm2     # 0x16028
movq %r12, %rdi
movl $0x2, %esi
callq 0x3ff2
movq (%r12), %r15
movq 0x8(%r12), %r13
movsd 0xf1c5(%rip), %xmm0     # 0x16088
cmpq %r13, %r15
je 0x6ef6
movsd %xmm0, (%rsp)
leaq 0x16fd4(%rip), %r12     # 0x1dea8
movq %r12, %rdi
movq %r15, %rsi
callq 0xdef0
movsd (%rax), %xmm0
minsd (%rsp), %xmm0
addq $0x78, %r15
movsd %xmm0, (%rsp)
cmpq %r13, %r15
jne 0x6ed4
movsd %xmm0, 0x28(%rsp)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x6f13
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3240
leaq 0x16f8e(%rip), %rdi     # 0x1dea8
movq %r14, %rsi
callq 0xdef0
movsd (%rax), %xmm0
movsd %xmm0, (%rsp)
leaq 0x16fd6(%rip), %rdi     # 0x1df08
leaq 0x40(%rsp), %rsi
callq 0xde8c
cmpl $0x3, (%rax)
movsd 0xf1c1(%rip), %xmm0     # 0x16108
jl 0x6f9e
movsd 0xf217(%rip), %xmm1     # 0x16168
movsd (%rsp), %xmm2
ucomisd %xmm2, %xmm1
jbe 0x6f9e
movsd 0xf0f4(%rip), %xmm1     # 0x16058
movsd 0x28(%rsp), %xmm3
ucomisd %xmm3, %xmm1
jbe 0x6f9e
ucomisd %xmm2, %xmm3
jbe 0x6f9e
subsd %xmm2, %xmm3
movsd 0xf1ee(%rip), %xmm1     # 0x16170
divsd %xmm1, %xmm3
movsd 0xf17a(%rip), %xmm2     # 0x16108
movapd %xmm2, %xmm0
subsd %xmm3, %xmm0
minsd %xmm2, %xmm0
maxsd %xmm1, %xmm0
leaq 0x30(%rsp), %rdx
xorpd %xmm1, %xmm1
movq %rbx, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq $0x0
pushq $-0x1
callq 0x4c6b
addq $0x10, %rsp
movl $0x1, 0x30(%rbx)
movq %rbx, %rax
addq $0xd0, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0xf309(%rip), %rdi      # 0x162ed
leaq 0xf308(%rip), %rsi      # 0x162f3
leaq 0xf325(%rip), %rcx      # 0x16317
movl $0x2de, %edx            # imm = 0x2DE
callq 0x3160
jmp 0x6ffe
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x7018
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x3240
movq %rbx, %rdi
callq 0x33d0