#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ ang_diff(float, double);
int fabs(scalar_t__);
double get_vps_theta();
int /*<<< orphan*/ printf(char *, double, ...);
int /*<<< orphan*/ set_wheel_pows(int, int);
void vps_rotate(float target_theta) {
  printf("Rotating from %.2f to %.2f\n", get_vps_theta(), target_theta);
  while (fabs(ang_diff(target_theta, get_vps_theta())) > 5) {
    printf("\t%.2f\n", get_vps_theta());
    int direction = ang_diff(target_theta, get_vps_theta()) > 0 ? 1 : -1;
    set_wheel_pows(-direction * 0.3, direction * 0.3);
  }
  set_wheel_pows(0, 0);
}


x86 assembly (clang, -O0):
<vps_rotate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <get_vps_theta@plt>
movss  -0x4(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe94(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
mov    $0x0,%al
call   1060 <get_vps_theta@plt>
movaps %xmm0,%xmm1
movss  -0xc(%rbp),%xmm0
call   1030 <ang_diff@plt>
mov    %rax,%rdi
call   1050 <fabs@plt>
cmp    $0x5,%eax
jle    122c <vps_rotate+0xdc>
mov    $0x0,%al
call   1060 <get_vps_theta@plt>
lea    0xe6c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1060 <get_vps_theta@plt>
movaps %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
call   1030 <ang_diff@plt>
mov    %rax,%rdx
mov    $0xffffffff,%eax
mov    $0x1,%ecx
cmp    $0x0,%rdx
cmovg  %ecx,%eax
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
sub    -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xdfb(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xde6(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
call   1070 <set_wheel_pows@plt>
jmp    117b <vps_rotate+0x2b>
xor    %esi,%esi
mov    %esi,%edi
call   1070 <set_wheel_pows@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vps_rotate>:
push   %rbx
sub    $0x10,%rsp
movss  %xmm0,0xc(%rsp)
xor    %eax,%eax
call   1060 <get_vps_theta@plt>
movss  0xc(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe8d(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <get_vps_theta@plt>
movaps %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
call   1030 <ang_diff@plt>
mov    %rax,%rdi
call   1050 <fabs@plt>
cmp    $0x6,%eax
jl     1201 <vps_rotate+0xb1>
lea    0xe79(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1060 <get_vps_theta@plt>
mov    %rbx,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <get_vps_theta@plt>
movaps %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
call   1030 <ang_diff@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1070 <set_wheel_pows@plt>
xor    %eax,%eax
call   1060 <get_vps_theta@plt>
movaps %xmm0,%xmm1
movss  0xc(%rsp),%xmm0
call   1030 <ang_diff@plt>
mov    %rax,%rdi
call   1050 <fabs@plt>
cmp    $0x5,%eax
jg     11b0 <vps_rotate+0x60>
xor    %edi,%edi
xor    %esi,%esi
add    $0x10,%rsp
pop    %rbx
jmp    1070 <set_wheel_pows@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"Rotating from %.2f to %.2f\0A\00"
@.str.1 = [7 x i8] c"\09%.2f\0A\00"
define void @vps_rotate(float %0) {
%2 = alloca float
%3 = alloca i32
store float %0, float* %2
%4 = call double (...) @get_vps_theta()
%5 = load float, float* %2
%6 = fpext float %5 to double
%7 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %4, double %6)
br label %8
8: ; preds = %14, %1
%9 = load float, float* %2
%10 = call double (...) @get_vps_theta()
%11 = call i64 @ang_diff(float %9, double %10)
%12 = call i32 @fabs(i64 %11)
%13 = icmp sgt i32 %12, 5
br i1 %13, label %14, label %33
14: ; preds = %8
%15 = call double (...) @get_vps_theta()
%16 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %15)
%17 = load float, float* %2
%18 = call double (...) @get_vps_theta()
%19 = call i64 @ang_diff(float %17, double %18)
%20 = icmp sgt i64 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i32 1, i32 -1
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = sub nsw i32 0, %23
%25 = sitofp i32 %24 to double
%26 = fmul double %25, 3.000000e-01
%27 = fptosi double %26 to i32
%28 = load i32, i32* %3
%29 = sitofp i32 %28 to double
%30 = fmul double %29, 3.000000e-01
%31 = fptosi double %30 to i32
%32 = call i32 @set_wheel_pows(i32 %27, i32 %31)
br label %8
33: ; preds = %8
%34 = call i32 @set_wheel_pows(i32 0, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [28 x i8] c"Rotating from %.2f to %.2f\0A\00"
@.str.1 = [7 x i8] c"\09%.2f\0A\00"
define void @vps_rotate(float %0) {
%2 = tail call double (...) @get_vps_theta()
%3 = fpext float %0 to double
%4 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), double %2, double %3)
%5 = tail call double (...) @get_vps_theta()
%6 = tail call i64 @ang_diff(float %0, double %5)
%7 = tail call i32 @fabs(i64 %6)
%8 = icmp sgt i32 %7, 5
br i1 %8, label %9, label %19
9: ; preds = %1, %9
%10 = tail call double (...) @get_vps_theta()
%11 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %10)
%12 = tail call double (...) @get_vps_theta()
%13 = tail call i64 @ang_diff(float %0, double %12)
%14 = tail call i32 @set_wheel_pows(i32 0, i32 0)
%15 = tail call double (...) @get_vps_theta()
%16 = tail call i64 @ang_diff(float %0, double %15)
%17 = tail call i32 @fabs(i64 %16)
%18 = icmp sgt i32 %17, 5
br i1 %18, label %9, label %19
19: ; preds = %9, %1
%20 = tail call i32 @set_wheel_pows(i32 0, i32 0)
ret void
}