// File: /workspace/github_c_makefile_star2_O0/kernfel[P]fNEAT/robot-simplistic.c
// Function: move_robot_in_room
void move_robot_in_room( Robot *bot, Room *room, struct Robot_Params *params, double *controller_outputs ) {
	// Adjust heading
	adjust_heading( bot, params, controller_outputs );

	// Calculate forward move
	double motor_output = controller_outputs[0];
	if ( fabs(motor_output) > params->motor_threshold ) {
		if ( motor_output > 0 )
			motor_output = motor_output - params->motor_threshold;
		else
			motor_output = motor_output + params->motor_threshold;
		double m_x = cos(bot->heading) * motor_output * params->motor_sensitivity;
		double m_y = sin(bot->heading) * motor_output * params->motor_sensitivity;

		// Detect depth of collision, if any
		double new_x = bot->x + m_x, new_y = bot->y + m_y;
		double adjust_x=0, adjust_y=0;
		if ( new_x - params->radius < 0 ) {
			adjust_x = -(params->radius - new_x) / m_x;
		} else if ( new_x + params->radius > room->x ) {
			adjust_x = (new_x + params->radius - room->x) / m_x;
		}
		if ( new_y - params->radius < 0 ) {
			adjust_y = -(params->radius - new_y) / m_y;
		} else if ( new_y + params->radius > room->y ) {
			adjust_y = (new_y + params->radius - room->y) / m_y;
		}

		// Apply the adjusted movement vector
		bot->x += (1-max(adjust_x, adjust_y)) * m_x;
		bot->y += (1-max(adjust_x, adjust_y)) * m_y;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x7cb0
movq -0x20(%rbp), %rax
movsd (%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
movaps 0x23fe(%rip), %xmm1     # 0xa1b0
pand %xmm1, %xmm0
movq -0x18(%rbp), %rax
ucomisd 0x10(%rax), %xmm0
jbe 0x800a
movsd -0x28(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x7de8
movsd -0x28(%rbp), %xmm0
movq -0x18(%rbp), %rax
subsd 0x10(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x7dfb
movsd -0x28(%rbp), %xmm0
movq -0x18(%rbp), %rax
addsd 0x10(%rax), %xmm0
movsd %xmm0, -0x28(%rbp)
movq -0x8(%rbp), %rax
movsd 0x10(%rax), %xmm0
callq 0x1090
mulsd -0x28(%rbp), %xmm0
movq -0x18(%rbp), %rax
mulsd 0x8(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x8(%rbp), %rax
movsd 0x10(%rax), %xmm0
callq 0x1140
mulsd -0x28(%rbp), %xmm0
movq -0x18(%rbp), %rax
mulsd 0x8(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x8(%rbp), %rax
movsd (%rax), %xmm0
addsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x8(%rbp), %rax
movsd 0x8(%rax), %xmm0
addsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x40(%rbp), %xmm1
movq -0x18(%rbp), %rax
subsd (%rax), %xmm1
xorps %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x7eb8
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
subsd -0x40(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
divsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
jmp 0x7ef0
movsd -0x40(%rbp), %xmm0
movq -0x18(%rbp), %rax
addsd (%rax), %xmm0
movq -0x10(%rbp), %rax
ucomisd (%rax), %xmm0
jbe 0x7eee
movsd -0x40(%rbp), %xmm0
movq -0x18(%rbp), %rax
addsd (%rax), %xmm0
movq -0x10(%rbp), %rax
subsd (%rax), %xmm0
divsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
jmp 0x7ef0
movsd -0x48(%rbp), %xmm1
movq -0x18(%rbp), %rax
subsd (%rax), %xmm1
xorps %xmm0, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x7f36
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
subsd -0x48(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
divsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x7f70
movsd -0x48(%rbp), %xmm0
movq -0x18(%rbp), %rax
addsd (%rax), %xmm0
movq -0x10(%rbp), %rax
ucomisd 0x8(%rax), %xmm0
jbe 0x7f6e
movsd -0x48(%rbp), %xmm0
movq -0x18(%rbp), %rax
addsd (%rax), %xmm0
movq -0x10(%rbp), %rax
subsd 0x8(%rax), %xmm0
divsd -0x38(%rbp), %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x7f70
movsd -0x50(%rbp), %xmm0
ucomisd -0x58(%rbp), %xmm0
jbe 0x7f88
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
jmp 0x7f92
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm1
movsd 0x20c9(%rip), %xmm0     # 0xa068
subsd %xmm1, %xmm0
movsd -0x30(%rbp), %xmm2
movq -0x8(%rbp), %rax
movsd (%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax)
movsd -0x50(%rbp), %xmm0
ucomisd -0x58(%rbp), %xmm0
jbe 0x7fd4
movsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
jmp 0x7fde
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x68(%rbp), %xmm1
movsd 0x207d(%rip), %xmm0     # 0xa068
subsd %xmm1, %xmm0
movsd -0x38(%rbp), %xmm2
movq -0x8(%rbp), %rax
movsd 0x8(%rax), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rax)
addq $0x70, %rsp
popq %rbp
retq