// File: /workspace/github_cpp_makefile_star2_O2/FakePsyho[P]halite2/MyBot.cpp
// Function: move_to(hlt::Ship const&, hlt::Location const&, double, double, bool, bool, bool, int, bool)
Move move_to(const Ship& ship, const Location& target, double maxSpeed = MAX_SPEED, double radius = 0, bool avoidEnemies = false, bool cluster = false, bool avoidEdges = false, int baitTarget = -1, bool reversePlayers = false) {
	radius *= radius;
	VC<Entity> planets = findCloseEntities(ship.location, 10.0, MASK_PLANETS);
	VC<Entity> docked = findCloseEntities(ship.location, 10.0, MASK_ALLIES_DOCKED);
	VC<Entity> entities = findCloseEntities(ship.location, 16.0, MASK_PLANETS | MASK_ALLIES | MASK_ALLIES_DOCKED | MASK_ENEMIES_DOCKED, ship.entity_id);
	VC<Entity> enemies = avoidEnemies ? findCloseEntities(ship.location, 25.0, MASK_ENEMIES) : VC<Entity>();
	VC<Entity> miners = findCloseEntities(ship.location, 13.0, MASK_ENEMIES_DOCKED);
	// VC<Entity> allies = cluster || reversePlayers ? findCloseEntities(ship.location, 30.0, MASK_ALLIES | MASK_ALLIES_DOCKED, ship.entity_id) : VC<Entity>();
	VC<Entity> allies = cluster ? findCloseEntities(ship.location, 30.0, MASK_ALLIES | MASK_ALLIES_DOCKED) : VC<Entity>();
	VC<Location> spawnedEnemies;
	Entity baitEnemy;
	if (reversePlayers) {
		allies = VC<Entity>();
		docked = VC<Entity>();
		miners = findCloseEntities(ship.location, 13.0, MASK_ALLIES_DOCKED);
		enemies = findCloseEntities(ship.location, 25.0, MASK_ALLIES);
		for (auto& e : entities) e.move.move_thrust = 0;
	}
	if (avoidEnemies) {
		for (Entity& enemy : enemies) {
			enemy.move.move_thrust = MAX_SPEED;
			enemy.move.move_angle_deg = util::angle_rad_to_deg_clipped(enemy.location.orient_towards_in_rad(ship.location));
		}
		if (!reversePlayers) {
			for (auto& spawn : spawnedShips) {
				if (spawn.Y != player_id && ship.location.dist(spawn.X) < 25.0) spawnedEnemies.PB(spawn.X);
			}
		}
		
		if (baitTarget != -1) {
			for (auto& e : enemies) if (e.entity_id == baitTarget) baitEnemy = e;
			if (baitEnemy.entity_id != baitTarget) baitTarget = -1;
		}
	}
	
	double ang = ship.location.get_angle(target);
	
	int TOTAL_ANG_STEPS = 360;
	
	double bv = 1e9;
	double bang = 0;
	double bd2 = 0;
	double bthrust = -1;
	int battackers = 0;
	bool bbait = false;
	
	// if (radius == 0 && !avoidEnemies && !detectCollisions(ship.location, round_angle(ang), (int)maxSpeed, entities)) return Move::thrust_rad(ship.entity_id, (int)maxSpeed, round_angle(ang));
	
	const double DANGER_DIST = baitTarget == -1 ? 6.25 : 6.25;
	int angoff = angle_rad_to_deg_clipped(ang);
	
	for (int xang = 0; xang < 360; xang += 360 / TOTAL_ANG_STEPS) {
		int nang = (xang + angoff) % 360;
		REP(nthrust, maxSpeed + 1e-9) {
			if (nthrust == 0 && xang) continue;
			Location end = ship.location + velocity[nang][nthrust];
			double d2 = target.dist_sq(end);
			double av = d2;
			if (radius) av = av < radius ? radius - av : 10000 + av;
			
			if (enemies.S == 0 && allies.S == 0 && av >= bv) continue;
			
			if (detectCollisions(ship.location, end, entities)) continue;
			
			bool closeToPlanet = false;
			for (auto& p : planets) {
				if (end.dist_sq(p.location) < (p.radius + 1) * (p.radius + 1)) {
					closeToPlanet = true;
					break;
				}
			}
			if (closeToPlanet) continue;
			
			if (!avoidEnemies && !m.in_ex_bounds(end, 4)) continue;
			
			bool abait = false;
			int aattackers = 0;
			
			if (avoidEnemies) {
				double minDist = 1e9;
				int closeEnemies = 0;
				if (true || baitTarget == -1) {
					if (enemies.S) {
						for (Entity& e : enemies) {
							if (e.entity_id == baitTarget) continue;
							double d = segment_circle_dist(ship.location, end, e);
							minDist = min(minDist, d);
							closeEnemies += d < DANGER_DIST;
						}
						for (auto& loc : spawnedEnemies) {
							minDist = min(minDist, end.dist(loc));
							closeEnemies += end.dist(loc) < DANGER_DIST;
						}
					}
				} else {
					for (Entity& e : enemies) {
						if (e.entity_id == baitTarget) continue;
						double d = end.dist(e.location) - MAX_SPEED;
						minDist = min(minDist, d);
						closeEnemies += d < DANGER_DIST;
					}
					for (auto& loc : spawnedEnemies) {
						minDist = min(minDist, end.dist(loc));
						closeEnemies += end.dist(loc) < DANGER_DIST;
					}
				}
				aattackers = closeEnemies;
				
				if (minDist < 1e5) {
					av = 10000;
					if (d2 >= radius) {
						av += 10000;
						av += sqrt(d2);
					} else {
						// if (minDist < 6.25) av += 10000;
						av += sqrt(radius) - sqrt(d2);
					}
					if (minDist < DANGER_DIST) {
						double dockDist = 1e9;
						for (auto& e : docked) dockDist = min(dockDist, end.dist_sq(e.location));
						if (dockDist > 4 * 4)
							av += closeEnemies * 20000;
					}
					double maxDist = 9.0 + (4 - ship.health / 64.0) * 1.0;
					av -= min(maxDist, minDist) * 4;
				}
				
				if (true || avoidEdges) {
					double edgeXDist = min(end.pos_x, m.map_width - end.pos_x);
					double edgeYDist = min(end.pos_y, m.map_height - end.pos_y);
					av += max(0.0, 12 - edgeXDist);
					av += max(0.0, 12 - edgeYDist);
				}
				
				if (baitTarget != -1 && segment_circle_dist(ship.location, end, baitEnemy) < 5.5) {
					av -= 1000;
					abait = true;
				}
				
				if (allies.S) {
					av -= sqrt(d2);
					for (Entity& e : allies) {
						av += 17.5 * sqrt(max(1.0, end.dist(e.destination()) + 0.0));
					}
				}
			}
			
			if (radius || avoidEnemies) {
				for (Entity& e : miners)
					if (end.dist_sq(e.location) < 6 * 6) {
						av -= 2;
						// break;
					}
			}
			
			if (avoidEnemies && earlyPhase && players_no == 4) {
				av += (leftSide ? max(0.0, end.pos_x - 50) : max(0.0, m.map_width - end.pos_x - 50)) * 0.025;
			}
			
			if (av < bv) {
				bd2 = d2;
				bbait = abait;
				battackers = aattackers;
				
				bv = av;
				bang = nang;
				bthrust = nthrust;
			}
		}
	}
	
	// if (reversePlayers) {
		// log("Ang: " + i2s(bang) + " Thrust: " + i2s(bthrust));
		// Location end = ship.location + Move::get_velocity_deg(bang, bthrust);
		// log("Vel: " + Move::get_velocity_deg(bang, bthrust).tostring());
		// log("End: " + end.tostring());
		// log("BV: " + i2s(bv) + " BD2: " + i2s(bd2));
		// for (Entity& entity : entities) {
			// log("Rad: " + i2s(entity.radius) + " Pos: " + entity.location.tostring() + " DistS: " + i2s(entity.location.dist(ship.location)) + " DistE: " + i2s(entity.location.dist(end)) + " Close: " + i2s(segment_circle_dist(ship.location, end, entity.location)));
		// }
		// for (auto& e : enemies) {
			// log("Enemy: " + i2s((int)e.entity_id) + " Pos: " + e.location.tostring() + " DistSO: " + i2s(ship.location.dist(e.location)) + " Close: " + i2s(segment_circle_dist(ship.location, end, e)));
		// }
	// }
	
	Move mv = Move::thrust(ship.entity_id, bthrust, bang);
	mv.value = bv;
	mv.bait = bbait;
	mv.attackers = battackers;
	return mv;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movl %r8d, %ebx
movl %ecx, 0x18(%rsp)
movsd %xmm1, 0x48(%rsp)
movsd %xmm0, 0x78(%rsp)
movq %rdx, 0xd0(%rsp)
movq %rsi, %r12
movq %rdi, %r14
movsd 0x8(%rsi), %xmm0
movsd 0x10(%rsi), %xmm1
leaq 0x178(%rsp), %rdi
movsd 0xe8d4(%rip), %xmm2     # 0x12020
pushq $0x1
popq %rsi
pushq $-0x1
popq %rbp
movl %ebp, %edx
callq 0x2d33
movsd 0x8(%r12), %xmm0
movsd 0x10(%r12), %xmm1
leaq 0x160(%rsp), %rdi
pushq $0x4
popq %rsi
movsd 0xe8a6(%rip), %xmm2     # 0x12020
movl %ebp, %edx
callq 0x2d33
movsd 0x8(%r12), %xmm0
movsd 0x10(%r12), %xmm1
movl (%r12), %edx
leaq 0x148(%rsp), %rdi
movsd 0xe8a5(%rip), %xmm2     # 0x12048
pushq $0x17
popq %rsi
callq 0x2d33
cmpb $0x0, 0x18(%rsp)
je 0x37da
movsd 0x8(%r12), %xmm0
movsd 0x10(%r12), %xmm1
leaq 0x60(%rsp), %rdi
movsd 0xe883(%rip), %xmm2     # 0x12050
pushq $0x8
popq %rsi
pushq $-0x1
popq %rdx
callq 0x2d33
jmp 0x37ea
xorpd %xmm0, %xmm0
movapd %xmm0, 0x60(%rsp)
andq $0x0, 0x70(%rsp)
movsd 0x8(%r12), %xmm0
movsd 0x10(%r12), %xmm1
leaq 0x130(%rsp), %rdi
movsd 0xe850(%rip), %xmm2     # 0x12058
pushq $0x10
popq %rsi
pushq $-0x1
popq %rdx
movl %edx, 0x1c(%rsp)
callq 0x2d33
testb %bl, %bl
je 0x3846
movsd 0x8(%r12), %xmm0
movsd 0x10(%r12), %xmm1
leaq 0x90(%rsp), %rdi
movsd 0xe827(%rip), %xmm2     # 0x12060
pushq $0x6
popq %rsi
pushq $-0x1
popq %rdx
callq 0x2d33
jmp 0x385c
xorpd %xmm0, %xmm0
movapd %xmm0, 0x90(%rsp)
andq $0x0, 0xa0(%rsp)
andq $0x0, 0xf0(%rsp)
movb 0x248(%rsp), %bpl
andq $0x0, 0x1c8(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0xe0(%rsp)
xorl %eax, %eax
movb %al, 0x1d0(%rsp)
movb %al, 0x1f0(%rsp)
andq $0x0, 0x1d4(%rsp)
movb %al, 0x1dc(%rsp)
movupd %xmm0, 0x1a8(%rsp)
movupd %xmm0, 0x1b4(%rsp)
testb %bpl, %bpl
je 0x39b1
leaq 0x30(%rsp), %rbx
movapd %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
leaq 0x90(%rsp), %rdi
movq %rbx, %rsi
callq 0xdc2c
movq %rbx, %rdi
callq 0xd7f8
xorpd %xmm0, %xmm0
movapd %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
leaq 0x160(%rsp), %rdi
leaq 0x30(%rsp), %rbx
movq %rbx, %rsi
callq 0xdc2c
movq %rbx, %rdi
callq 0xd7f8
movsd 0x8(%r12), %xmm0
movsd 0x10(%r12), %xmm1
leaq 0x30(%rsp), %rdi
movsd 0xe72f(%rip), %xmm2     # 0x12058
pushq $0x4
popq %rsi
pushq $-0x1
popq %rdx
callq 0x2d33
leaq 0x130(%rsp), %rdi
leaq 0x30(%rsp), %rbx
movq %rbx, %rsi
callq 0xdc2c
movq %rbx, %rdi
callq 0xd7f8
movsd 0x8(%r12), %xmm0
movsd 0x10(%r12), %xmm1
leaq 0x30(%rsp), %rdi
movsd 0xe6e4(%rip), %xmm2     # 0x12050
pushq $0x2
popq %rsi
pushq $-0x1
popq %rdx
callq 0x2d33
leaq 0x60(%rsp), %rdi
leaq 0x30(%rsp), %rbx
movq %rbx, %rsi
callq 0xdc2c
movq %rbx, %rdi
callq 0xd7f8
movq 0x148(%rsp), %rax
movq 0x150(%rsp), %rcx
cmpq %rcx, %rax
je 0x39b1
andq $0x0, 0x20(%rax)
addq $0x78, %rax
jmp 0x39a1
movq %r14, 0x100(%rsp)
movl 0x240(%rsp), %r15d
movq %r12, 0xb0(%rsp)
leaq 0x8(%r12), %r13
cmpb $0x0, 0x18(%rsp)
je 0x3a0e
movq 0x60(%rsp), %rbx
movq 0x68(%rsp), %r14
movabsq $0x401c000000000000, %r12 # imm = 0x401C000000000000
cmpq %r14, %rbx
je 0x3a15
movq %r12, 0x20(%rbx)
leaq 0x8(%rbx), %rdi
movq %r13, %rsi
callq 0x9bdc
callq 0x3615
movsd %xmm0, 0x28(%rbx)
addq $0x78, %rbx
jmp 0x39e9
movl %r15d, 0x1c(%rsp)
jmp 0x3a68
testb %bpl, %bpl
je 0x4292
cmpl $-0x1, %r15d
je 0x3a68
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %r9
pushq $0xf
popq %rdx
leaq 0x190(%rsp), %r8
cmpq %r9, %rax
je 0x3a55
cmpl %r15d, (%rax)
jne 0x3a4f
movq %rdx, %rcx
movq %r8, %rdi
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
addq $0x78, %rax
jmp 0x3a39
cmpl %r15d, 0x190(%rsp)
pushq $-0x1
popq %rax
cmovel %r15d, %eax
movl %eax, 0x1c(%rsp)
movsd 0x48(%rsp), %xmm0
mulsd %xmm0, %xmm0
movsd %xmm0, 0x48(%rsp)
movq %r13, %rdi
movq 0xd0(%rsp), %rsi
callq 0x9bdc
callq 0x3615
cvttsd2si %xmm0, %eax
movq %rax, 0x110(%rsp)
movsd 0x78(%rsp), %xmm0
addsd 0xe5c1(%rip), %xmm0     # 0x12068
movsd %xmm0, 0x78(%rsp)
xorpd %xmm0, %xmm0
movsd 0x48(%rsp), %xmm1
ucomisd %xmm0, %xmm1
setp %al
setne %cl
orb %al, %cl
sqrtsd %xmm1, %xmm0
movsd %xmm0, 0x108(%rsp)
orb 0x18(%rsp), %cl
movb %cl, 0xf(%rsp)
movsd 0xe590(%rip), %xmm1     # 0x12070
movsd 0xe590(%rip), %xmm0     # 0x12078
movsd %xmm0, 0xc8(%rsp)
xorl %ebp, %ebp
movq $0x0, 0xc0(%rsp)
movl $0x0, 0x54(%rsp)
xorpd %xmm0, %xmm0
movsd %xmm0, 0xb8(%rsp)
movsd %xmm1, 0x58(%rsp)
cmpl $0x168, %ebp            # imm = 0x168
je 0x41bf
movq 0x110(%rsp), %rax
addl %ebp, %eax
cltd
movl $0x168, %ecx            # imm = 0x168
idivl %ecx
movslq %edx, %rcx
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0x118(%rsp)
shlq $0x7, %rcx
leaq 0x1961d(%rip), %rax     # 0x1d170
addq %rax, %rcx
movq %rcx, 0x120(%rsp)
xorl %r12d, %r12d
cvtsi2sd %r12d, %xmm1
movsd 0x78(%rsp), %xmm0
movsd %xmm1, 0x128(%rsp)
ucomisd %xmm1, %xmm0
jbe 0x41b8
testl %ebp, %ebp
setne %al
testq %r12, %r12
sete %cl
testb %cl, %al
jne 0x41b0
movq %r12, %rax
shlq $0x4, %rax
movsd 0x48(%rsp), %xmm2
ucomisd 0xe549(%rip), %xmm2     # 0x120f0
movupd (%r13), %xmm0
movq 0x120(%rsp), %rcx
addpd (%rax,%rcx), %xmm0
movapd %xmm0, 0x30(%rsp)
movq 0xd0(%rsp), %rax
movsd (%rax), %xmm4
movsd 0x8(%rax), %xmm1
subsd %xmm0, %xmm4
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
subsd %xmm0, %xmm1
mulsd %xmm1, %xmm1
mulsd %xmm4, %xmm4
addsd %xmm1, %xmm4
movapd %xmm4, 0x20(%rsp)
jne 0x3bf3
jnp 0x3c22
movapd %xmm2, %xmm0
subsd %xmm4, %xmm0
movapd %xmm4, %xmm1
addsd 0xe479(%rip), %xmm1     # 0x12080
movapd %xmm4, %xmm3
cmpltsd %xmm2, %xmm3
andpd %xmm3, %xmm0
andnpd %xmm1, %xmm3
orpd %xmm0, %xmm3
movapd %xmm3, 0x20(%rsp)
movsd %xmm4, 0xd8(%rsp)
movq 0x68(%rsp), %rax
cmpq 0x60(%rsp), %rax
je 0x3cc4
movq %r13, %rdi
leaq 0x30(%rsp), %rsi
leaq 0x148(%rsp), %rdx
movsd 0xe435(%rip), %xmm0     # 0x12088
pushq $0x1
popq %rcx
callq 0x301c
testl %eax, %eax
jne 0x41b0
movq 0x178(%rsp), %rax
movq 0x180(%rsp), %rcx
movapd 0x30(%rsp), %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
cmpq %rcx, %rax
je 0x3cf1
movapd %xmm0, %xmm2
subsd 0x8(%rax), %xmm2
movapd %xmm1, %xmm3
subsd 0x10(%rax), %xmm3
mulsd %xmm3, %xmm3
mulsd %xmm2, %xmm2
addsd %xmm3, %xmm2
movsd 0x70(%rax), %xmm3
addsd 0xe35f(%rip), %xmm3     # 0x12010
mulsd %xmm3, %xmm3
addq $0x78, %rax
ucomisd %xmm2, %xmm3
jbe 0x3c81
jmp 0x41b0
movq 0x98(%rsp), %rax
cmpq 0x90(%rsp), %rax
jne 0x3c3b
movapd 0x20(%rsp), %xmm0
ucomisd 0x58(%rsp), %xmm0
jae 0x41b0
jmp 0x3c3b
cmpb $0x0, 0x18(%rsp)
je 0x3d60
movq 0x60(%rsp), %r14
movq 0x68(%rsp), %rbx
xorl %r15d, %r15d
cmpq %r14, %rbx
je 0x3f1f
movsd 0xe35a(%rip), %xmm0     # 0x12070
movsd %xmm0, 0x10(%rsp)
cmpq %rbx, %r14
je 0x3d94
movl 0x1c(%rsp), %eax
cmpl %eax, (%r14)
je 0x3d5a
movq %r13, %rdi
leaq 0x30(%rsp), %rsi
movq %r14, %rdx
callq 0x436e
xorl %eax, %eax
movsd 0xe354(%rip), %xmm1     # 0x12098
ucomisd %xmm0, %xmm1
minsd 0x10(%rsp), %xmm0
seta %al
addl %eax, %r15d
movsd %xmm0, 0x10(%rsp)
addq $0x78, %r14
jmp 0x3d1c
leaq 0x18f81(%rip), %rdi     # 0x1cce8
leaq 0x30(%rsp), %rsi
movsd 0xe31c(%rip), %xmm0     # 0x12090
callq 0x9c1c
movl $0x0, 0x10(%rsp)
movl $0x0, %r15d
testb %al, %al
jne 0x404f
jmp 0x41b0
movq 0xe0(%rsp), %rax
movq 0xe8(%rsp), %rcx
movapd 0x30(%rsp), %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
cmpq %rcx, %rax
je 0x3dfe
movapd %xmm0, %xmm2
subsd (%rax), %xmm2
movapd %xmm1, %xmm3
subsd 0x8(%rax), %xmm3
mulsd %xmm3, %xmm3
mulsd %xmm2, %xmm2
addsd %xmm3, %xmm2
sqrtsd %xmm2, %xmm2
xorl %edx, %edx
movsd 0xe2b6(%rip), %xmm3     # 0x12098
ucomisd %xmm2, %xmm3
seta %dl
minsd 0x10(%rsp), %xmm2
addl %edx, %r15d
addq $0x10, %rax
movsd %xmm2, 0x10(%rsp)
jmp 0x3db2
movsd 0xe29a(%rip), %xmm2     # 0x120a0
movsd 0x10(%rsp), %xmm6
ucomisd %xmm6, %xmm2
jbe 0x3f1f
movsd 0xd8(%rsp), %xmm4
sqrtsd %xmm4, %xmm2
movsd 0x108(%rsp), %xmm3
subsd %xmm2, %xmm3
addsd 0xe270(%rip), %xmm2     # 0x120a8
addsd 0xe240(%rip), %xmm3     # 0x12080
movsd 0x48(%rsp), %xmm5
cmpnlesd %xmm4, %xmm5
andpd %xmm5, %xmm3
andnpd %xmm2, %xmm5
orpd %xmm3, %xmm5
movsd 0xe239(%rip), %xmm2     # 0x12098
ucomisd %xmm6, %xmm2
jbe 0x3ede
movq 0x160(%rsp), %rax
movq 0x168(%rsp), %rcx
movsd 0xe1f3(%rip), %xmm2     # 0x12070
cmpq %rcx, %rax
je 0x3eae
movapd %xmm0, %xmm3
subsd 0x8(%rax), %xmm3
movapd %xmm1, %xmm4
subsd 0x10(%rax), %xmm4
mulsd %xmm4, %xmm4
mulsd %xmm3, %xmm3
addsd %xmm4, %xmm3
minsd %xmm2, %xmm3
addq $0x78, %rax
movapd %xmm3, %xmm2
jmp 0x3e7d
imull $0x4e20, %r15d, %eax    # imm = 0x4E20
cvtsi2sd %eax, %xmm1
movapd %xmm5, %xmm3
addsd %xmm1, %xmm3
movsd 0xe17f(%rip), %xmm1     # 0x12048
cmpltsd %xmm2, %xmm1
andpd %xmm1, %xmm3
andnpd %xmm5, %xmm1
orpd %xmm3, %xmm1
movapd %xmm1, %xmm5
movq 0xb0(%rsp), %rax
cvtsi2sdl 0x68(%rax), %xmm1
mulsd 0xe1bd(%rip), %xmm1     # 0x120b0
movsd 0xe195(%rip), %xmm2     # 0x12090
addsd %xmm2, %xmm1
addsd 0xe1b1(%rip), %xmm1     # 0x120b8
movsd 0x10(%rsp), %xmm3
minsd %xmm1, %xmm3
mulsd %xmm2, %xmm3
subsd %xmm3, %xmm5
movapd %xmm5, 0x20(%rsp)
cvtdq2pd 0x18dc1(%rip), %xmm1    # 0x1cce8
subpd %xmm0, %xmm1
minpd %xmm0, %xmm1
movapd 0xe309(%rip), %xmm0     # 0x12240
subpd %xmm1, %xmm0
xorpd %xmm1, %xmm1
cmpltpd %xmm0, %xmm1
movmskpd %xmm1, %eax
xorpd %xmm2, %xmm2
movapd %xmm0, %xmm1
testb $0x1, %al
jne 0x3f58
xorpd %xmm1, %xmm1
testb $0x2, %al
je 0x3f64
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
movapd %xmm0, %xmm2
movapd 0x20(%rsp), %xmm0
addsd %xmm1, %xmm0
addsd %xmm2, %xmm0
movapd %xmm0, 0x20(%rsp)
cmpl $-0x1, 0x1c(%rsp)
je 0x3fbe
movq %r13, %rdi
leaq 0x30(%rsp), %rsi
leaq 0x190(%rsp), %rdx
callq 0x436e
movsd 0xe124(%rip), %xmm1     # 0x120c0
ucomisd %xmm0, %xmm1
jbe 0x3fbe
movapd 0x20(%rsp), %xmm0
addsd 0xe118(%rip), %xmm0     # 0x120c8
movapd %xmm0, 0x20(%rsp)
movb $0x1, %al
movl %eax, 0x10(%rsp)
jmp 0x3fc6
movl $0x0, 0x10(%rsp)
movq 0x90(%rsp), %r14
movq 0x98(%rsp), %rbx
cmpq %r14, %rbx
je 0x404f
sqrtsd 0xd8(%rsp), %xmm0
movapd 0x20(%rsp), %xmm1
subsd %xmm0, %xmm1
movapd %xmm1, 0x20(%rsp)
cmpq %rbx, %r14
je 0x404f
movq %r14, %rdi
callq 0x9c54
movsd 0x30(%rsp), %xmm2
movsd 0x38(%rsp), %xmm3
subsd %xmm0, %xmm2
subsd %xmm1, %xmm3
mulsd %xmm3, %xmm3
mulsd %xmm2, %xmm2
addsd %xmm3, %xmm2
sqrtsd %xmm2, %xmm0
maxsd 0xdfe3(%rip), %xmm0     # 0x12010
sqrtsd %xmm0, %xmm0
mulsd 0xe097(%rip), %xmm0     # 0x120d0
movapd 0x20(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, 0x20(%rsp)
addq $0x78, %r14
jmp 0x3ff4
cmpb $0x0, 0xf(%rsp)
je 0x40c8
movq 0x130(%rsp), %rax
movq 0x138(%rsp), %rcx
movsd 0x30(%rsp), %xmm0
movsd 0x38(%rsp), %xmm1
cmpq %rcx, %rax
je 0x40c8
movapd %xmm0, %xmm2
subsd 0x8(%rax), %xmm2
movapd %xmm1, %xmm3
subsd 0x10(%rax), %xmm3
mulsd %xmm3, %xmm3
mulsd %xmm2, %xmm2
addsd %xmm3, %xmm2
movapd 0x20(%rsp), %xmm4
movapd %xmm4, %xmm3
addsd 0xdf81(%rip), %xmm3     # 0x12028
cmpltsd 0xe028(%rip), %xmm2     # 0x120d8
andpd %xmm2, %xmm3
andnpd %xmm4, %xmm2
orpd %xmm3, %xmm2
addq $0x78, %rax
movapd %xmm2, 0x20(%rsp)
jmp 0x4072
cmpb $0x0, 0x18(%rsp)
je 0x4163
cmpb $0x1, 0x1815a(%rip)     # 0x1c234
jne 0x4163
cmpl $0x4, 0x18149(%rip)     # 0x1c230
jne 0x4163
cmpb $0x1, 0x18bf4(%rip)     # 0x1cce4
jne 0x4103
andq $0x0, 0x88(%rsp)
movsd 0x30(%rsp), %xmm0
jmp 0x411a
andq $0x0, 0x88(%rsp)
cvtsi2sdl 0x18bd4(%rip), %xmm0 # 0x1cce8
subsd 0x30(%rsp), %xmm0
addsd 0xdfbe(%rip), %xmm0     # 0x120e0
movsd %xmm0, 0x80(%rsp)
ucomisd 0xdfbd(%rip), %xmm0     # 0x120f0
leaq 0x88(%rsp), %rax
leaq 0x80(%rsp), %rcx
cmovaq %rcx, %rax
movsd (%rax), %xmm0
mulsd 0xdf95(%rip), %xmm0     # 0x120e8
movapd 0x20(%rsp), %xmm1
addsd %xmm0, %xmm1
movapd %xmm1, 0x20(%rsp)
movsd 0x58(%rsp), %xmm0
movapd 0x20(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x41b0
movl 0x10(%rsp), %eax
movq %rax, 0xc0(%rsp)
movl %r15d, 0x54(%rsp)
movsd 0x128(%rsp), %xmm0
movsd %xmm0, 0xc8(%rsp)
movsd 0x118(%rsp), %xmm0
movsd %xmm0, 0xb8(%rsp)
movsd %xmm1, 0x58(%rsp)
incq %r12
jmp 0x3b61
incl %ebp
jmp 0x3b1a
movq 0xb0(%rsp), %rax
movl (%rax), %eax
xorl %ecx, %ecx
movq 0x100(%rsp), %rbx
movb %cl, 0x48(%rbx)
andl $0x0, 0x30(%rbx)
movb %cl, 0x34(%rbx)
movl $0x1, (%rbx)
movl %eax, 0x4(%rbx)
movsd 0xc8(%rsp), %xmm0
movsd %xmm0, 0x8(%rbx)
movsd 0xb8(%rsp), %xmm0
movsd %xmm0, 0x10(%rbx)
andl $0x0, 0x18(%rbx)
movsd 0x58(%rsp), %xmm0
movsd %xmm0, 0x20(%rbx)
movq 0xc0(%rsp), %rax
andb $0x1, %al
movb %al, 0x28(%rbx)
movl 0x54(%rsp), %eax
movl %eax, 0x2c(%rbx)
leaq 0xe0(%rsp), %rdi
callq 0xdbf8
leaq 0x90(%rsp), %rdi
callq 0xd7f8
leaq 0x130(%rsp), %rdi
callq 0xd7f8
leaq 0x60(%rsp), %rdi
callq 0xd7f8
leaq 0x148(%rsp), %rdi
callq 0xd7f8
leaq 0x160(%rsp), %rdi
callq 0xd7f8
leaq 0x178(%rsp), %rdi
callq 0xd7f8
movq %rbx, %rax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18eb7(%rip), %rbx     # 0x1d150
movq 0x18eb8(%rip), %r12     # 0x1d158
leaq 0xe0(%rsp), %r14
cmpq %r12, %rbx
je 0x3a1e
movl 0x10(%rbx), %eax
cmpl 0x18a22(%rip), %eax     # 0x1ccdc
je 0x42e0
movq %r13, %rdi
movq %rbx, %rsi
callq 0x9ab4
movsd 0xdd81(%rip), %xmm1     # 0x12050
ucomisd %xmm0, %xmm1
jbe 0x42e0
movq %r14, %rdi
movq %rbx, %rsi
callq 0x9bfe
addq $0x18, %rbx
jmp 0x42a8
jmp 0x430b
jmp 0x430b
movq %rax, %rbx
jmp 0x4328
movq %rax, %rbx
jmp 0x433f
movq %rax, %rbx
jmp 0x4335
movq %rax, %rbx
jmp 0x434c
movq %rax, %rbx
jmp 0x4359
jmp 0x430b
jmp 0x430b
jmp 0x430b
jmp 0x430b
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0xdbf8
leaq 0x90(%rsp), %rdi
callq 0xd7f8
leaq 0x130(%rsp), %rdi
callq 0xd7f8
leaq 0x60(%rsp), %rdi
callq 0xd7f8
leaq 0x148(%rsp), %rdi
callq 0xd7f8
leaq 0x160(%rsp), %rdi
callq 0xd7f8
leaq 0x178(%rsp), %rdi
callq 0xd7f8
movq %rbx, %rdi
callq 0x23f0