// File: /workspace/github_c_makefile_star2_O0/QwazyWabbitWOS[P]lmctf60/g_func.c
// Function: plat_Accelerate
void plat_Accelerate (moveinfo_t *moveinfo)
{
	// are we decelerating?
	if (moveinfo->remaining_distance <= moveinfo->decel_distance)
	{
		if (moveinfo->remaining_distance < moveinfo->decel_distance)
		{
			if (moveinfo->next_speed)
			{
				moveinfo->current_speed = moveinfo->next_speed;
				moveinfo->next_speed = 0;
				return;
			}
			if (moveinfo->current_speed > moveinfo->decel)
				moveinfo->current_speed -= moveinfo->decel;
		}
		return;
	}

	// are we at full speed and need to start decelerating during this move?
	if (moveinfo->current_speed == moveinfo->move_speed)
		if ((moveinfo->remaining_distance - moveinfo->current_speed) < moveinfo->decel_distance)
		{
			float	p1_distance;
			float	p2_distance;
			float	distance;

			p1_distance = moveinfo->remaining_distance - moveinfo->decel_distance;
			p2_distance = moveinfo->move_speed * (1.0 - (p1_distance / moveinfo->move_speed));
			distance = p1_distance + p2_distance;
			moveinfo->current_speed = moveinfo->move_speed;
			moveinfo->next_speed = moveinfo->move_speed - moveinfo->decel * (p2_distance / distance);
			return;
		}

	// are we accelerating?
	if (moveinfo->current_speed < moveinfo->speed)
	{
		float	old_speed;
		float	p1_distance;
		float	p1_speed;
		float	p2_distance;
		float	distance;

		old_speed = moveinfo->current_speed;

		// figure simple acceleration up to move_speed
		moveinfo->current_speed += moveinfo->accel;
		if (moveinfo->current_speed > moveinfo->speed)
			moveinfo->current_speed = moveinfo->speed;

		// are we accelerating throughout this entire move?
		if ((moveinfo->remaining_distance - moveinfo->current_speed) >= moveinfo->decel_distance)
			return;

		// during this move we will accelrate from current_speed to move_speed
		// and cross over the decel_distance; figure the average speed for the
		// entire move
		p1_distance = moveinfo->remaining_distance - moveinfo->decel_distance;
		p1_speed = (old_speed + moveinfo->move_speed) / 2.0f;
		p2_distance = moveinfo->move_speed * (1.0 - (p1_distance / p1_speed));
		distance = p1_distance + p2_distance;
		moveinfo->current_speed = (p1_speed * (p1_distance / distance)) + (moveinfo->move_speed * (p2_distance / distance));
		moveinfo->next_speed = moveinfo->move_speed - moveinfo->decel * (p2_distance / distance);
		return;
	}

	// we are at constant velocity (move_speed)
	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movss 0x6c(%rax), %xmm1
movq -0x8(%rbp), %rax
movss 0x70(%rax), %xmm0
ucomiss %xmm1, %xmm0
jb 0x33fb7
movq -0x8(%rbp), %rax
movss 0x6c(%rax), %xmm1
movq -0x8(%rbp), %rax
movss 0x70(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x33fb2
movq -0x8(%rbp), %rax
movss 0x68(%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x33f5f
jp 0x33f5f
jmp 0x33f82
movq -0x8(%rbp), %rax
movss 0x68(%rax), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x60(%rax)
movq -0x8(%rbp), %rax
xorps %xmm0, %xmm0
movss %xmm0, 0x68(%rax)
jmp 0x3421d
movq -0x8(%rbp), %rax
movss 0x60(%rax), %xmm0
movq -0x8(%rbp), %rax
ucomiss 0x44(%rax), %xmm0
jbe 0x33fb0
movq -0x8(%rbp), %rax
movss 0x44(%rax), %xmm1
movq -0x8(%rbp), %rax
movss 0x60(%rax), %xmm0
subss %xmm1, %xmm0
movss %xmm0, 0x60(%rax)
jmp 0x33fb2
jmp 0x3421d
movq -0x8(%rbp), %rax
movss 0x60(%rax), %xmm0
movq -0x8(%rbp), %rax
ucomiss 0x64(%rax), %xmm0
jne 0x340a9
jp 0x340a9
movq -0x8(%rbp), %rax
movss 0x6c(%rax), %xmm1
movq -0x8(%rbp), %rax
subss 0x60(%rax), %xmm1
movq -0x8(%rbp), %rax
movss 0x70(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x340a7
movq -0x8(%rbp), %rax
movss 0x6c(%rax), %xmm0
movq -0x8(%rbp), %rax
subss 0x70(%rax), %xmm0
movss %xmm0, -0xc(%rbp)
movq -0x8(%rbp), %rax
movss 0x64(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0xc(%rbp), %xmm1
movq -0x8(%rbp), %rax
divss 0x64(%rax), %xmm1
cvtss2sd %xmm1, %xmm2
movsd 0x3bf0a(%rip), %xmm1    # 0x6ff40
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x10(%rbp)
movss -0xc(%rbp), %xmm0
addss -0x10(%rbp), %xmm0
movss %xmm0, -0x14(%rbp)
movq -0x8(%rbp), %rax
movss 0x64(%rax), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x60(%rax)
movq -0x8(%rbp), %rax
movss 0x64(%rax), %xmm1
movq -0x8(%rbp), %rax
movss 0x44(%rax), %xmm0
movss -0x10(%rbp), %xmm2
divss -0x14(%rbp), %xmm2
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x68(%rax)
jmp 0x3421d
jmp 0x340a9
movq -0x8(%rbp), %rax
movss 0x60(%rax), %xmm1
movq -0x8(%rbp), %rax
movss 0x40(%rax), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x3421b
movq -0x8(%rbp), %rax
movss 0x60(%rax), %xmm0
movss %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movss 0x3c(%rax), %xmm0
movq -0x8(%rbp), %rax
addss 0x60(%rax), %xmm0
movss %xmm0, 0x60(%rax)
movq -0x8(%rbp), %rax
movss 0x60(%rax), %xmm0
movq -0x8(%rbp), %rax
ucomiss 0x40(%rax), %xmm0
jbe 0x3410e
movq -0x8(%rbp), %rax
movss 0x40(%rax), %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x60(%rax)
movq -0x8(%rbp), %rax
movss 0x6c(%rax), %xmm0
movq -0x8(%rbp), %rax
subss 0x60(%rax), %xmm0
movq -0x8(%rbp), %rax
ucomiss 0x70(%rax), %xmm0
jb 0x3412f
jmp 0x3421d
movq -0x8(%rbp), %rax
movss 0x6c(%rax), %xmm0
movq -0x8(%rbp), %rax
subss 0x70(%rax), %xmm0
movss %xmm0, -0x1c(%rbp)
movss -0x18(%rbp), %xmm0
movq -0x8(%rbp), %rax
addss 0x64(%rax), %xmm0
movss 0x3bd8c(%rip), %xmm1    # 0x6fee8
divss %xmm1, %xmm0
movss %xmm0, -0x20(%rbp)
movq -0x8(%rbp), %rax
movss 0x64(%rax), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x1c(%rbp), %xmm1
divss -0x20(%rbp), %xmm1
cvtss2sd %xmm1, %xmm2
movsd 0x3bdb8(%rip), %xmm1    # 0x6ff40
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x24(%rbp)
movss -0x1c(%rbp), %xmm0
addss -0x24(%rbp), %xmm0
movss %xmm0, -0x28(%rbp)
movss -0x20(%rbp), %xmm0
movss -0x1c(%rbp), %xmm2
divss -0x28(%rbp), %xmm2
movq -0x8(%rbp), %rax
movss 0x64(%rax), %xmm1
movss -0x24(%rbp), %xmm3
divss -0x28(%rbp), %xmm3
mulss %xmm3, %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x60(%rax)
movq -0x8(%rbp), %rax
movss 0x64(%rax), %xmm1
movq -0x8(%rbp), %rax
movss 0x44(%rax), %xmm0
movss -0x24(%rbp), %xmm2
divss -0x28(%rbp), %xmm2
movd %xmm0, %eax
xorl $0x80000000, %eax       # imm = 0x80000000
movd %eax, %xmm0
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movq -0x8(%rbp), %rax
movss %xmm0, 0x68(%rax)
jmp 0x3421d
jmp 0x3421d
popq %rbp
retq
nop