#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 */
int /*<<< orphan*/ move_motor(int);
int gotoangle(double pa) {
  if (pa > 360. || pa < -360) {
    int x = pa / 360.;
    pa -= x * 360.;
  }
  if (pa > 180.)
    pa -= 360.;
  do {
  } while (0);
  int nusteps = pa / (360. / ((200.) * (8.) * (8.) * 2));
  move_motor(nusteps);
  return 0;
}


x86 assembly (clang, -O0):
<gotoangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xed6(%rip),%xmm1
ucomisd %xmm1,%xmm0
ja     1147 <gotoangle+0x37>
movsd  0xecc(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1195 <gotoangle+0x85>
movsd  -0x8(%rbp),%xmm0
movsd  0xeac(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe78(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xe6e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11c2 <gotoangle+0xb2>
movsd  -0x8(%rbp),%xmm0
movsd  0xe47(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11c7 <gotoangle+0xb7>
jmp    11cc <gotoangle+0xbc>
movsd  -0x8(%rbp),%xmm0
movsd  0xe3f(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   1030 <move_motor@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gotoangle>:
push   %rax
ucomisd 0xee7(%rip),%xmm0
ja     1129 <gotoangle+0x19>
movsd  0xee5(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1149 <gotoangle+0x39>
movsd  0xecf(%rip),%xmm1
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
cvttpd2dq %xmm2,%xmm2
cvtdq2pd %xmm2,%xmm2
mulsd  %xmm1,%xmm2
subsd  %xmm2,%xmm0
movsd  0xeb7(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xeb3(%rip),%xmm2
cmpltsd %xmm0,%xmm2
andpd  %xmm2,%xmm1
andnpd %xmm0,%xmm2
orpd   %xmm1,%xmm2
divsd  0xea2(%rip),%xmm2
cvttsd2si %xmm2,%edi
call   1030 <move_motor@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @gotoangle(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
store double %0, double* %2
%5 = load double, double* %2
%6 = fcmp ogt double %5, 3.600000e+02
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = load double, double* %2
%9 = fcmp olt double %8, -3.600000e+02
br i1 %9, label %10, label %19
10: ; preds = %7, %1
%11 = load double, double* %2
%12 = fdiv double %11, 3.600000e+02
%13 = fptosi double %12 to i32
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = sitofp i32 %14 to double
%16 = load double, double* %2
%17 = fneg double %15
%18 = call double @llvm.fmuladd.f64(double %17, double 3.600000e+02, double %16)
store double %18, double* %2
br label %19
19: ; preds = %10, %7
%20 = load double, double* %2
%21 = fcmp ogt double %20, 1.800000e+02
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load double, double* %2
%24 = fsub double %23, 3.600000e+02
store double %24, double* %2
br label %25
25: ; preds = %22, %19
br label %26
26: ; preds = %25
br label %27
27: ; preds = %26
%28 = load double, double* %2
%29 = fdiv double %28, 1.406250e-02
%30 = fptosi double %29 to i32
store i32 %30, i32* %4
%31 = load i32, i32* %4
%32 = call i32 @move_motor(i32 %31)
ret i32 0
}

LLVM IR (-O2):
define i32 @gotoangle(double %0) {
%2 = fcmp ogt double %0, 3.600000e+02
%3 = fcmp olt double %0, -3.600000e+02
%4 = or i1 %2, %3
br i1 %4, label %5, label %11
5: ; preds = %1
%6 = fdiv double %0, 3.600000e+02
%7 = fptosi double %6 to i32
%8 = sitofp i32 %7 to double
%9 = fneg double %8
%10 = tail call double @llvm.fmuladd.f64(double %9, double 3.600000e+02, double %0)
br label %11
11: ; preds = %1, %5
%12 = phi double [ %10, %5 ], [ %0, %1 ]
%13 = fcmp ogt double %12, 1.800000e+02
%14 = fadd double %12, -3.600000e+02
%15 = select i1 %13, double %14, double %12
%16 = fdiv double %15, 1.406250e-02
%17 = fptosi double %16 to i32
%18 = tail call i32 @move_motor(i32 %17)
ret i32 0
}