#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 copysign(double, double);
int /*<<< orphan*/ motor(int, int);
int /*<<< orphan*/ msleep(double);
int /*<<< orphan*/ printf(char *, double, double);
int rotate(double degrees) {
  int direction = copysign(1.0, degrees);
  int power = 25;
  int power_left = -direction * power;
  int power_right = direction * power * .99;
  double full_rotation_in_seconds = 6.775;
  double seconds = (full_rotation_in_seconds * direction) * (degrees / 360.0);
  printf("Move %f degrees (consumes %f seconds).\n", degrees, seconds);
  motor(0, power_left);
  motor(3, power_right);
  msleep(seconds * 1000);
  return 0;
}


x86 assembly (clang, -O0):
<rotate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  0xec6(%rip),%xmm0
call   1060 <copysign@plt>
mov    %eax,-0xc(%rbp)
movl   $0x19,-0x10(%rbp)
xor    %eax,%eax
sub    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xe90(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
movsd  0xe75(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x8(%rbp),%xmm1
movsd  0xe4d(%rip),%xmm2
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
lea    0xe4f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%esi
xor    %edi,%edi
call   1030 <motor@plt>
mov    -0x18(%rbp),%esi
mov    $0x3,%edi
call   1030 <motor@plt>
movsd  0xe03(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
call   1040 <msleep@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rotate>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movaps %xmm0,%xmm1
movsd  %xmm0,0x10(%rsp)
movsd  0xea9(%rip),%xmm0
call   1060 <copysign@plt>
lea    (%rax,%rax,4),%ecx
lea    (%rcx,%rcx,4),%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mulsd  0xe97(%rip),%xmm0
cvttsd2si %xmm0,%ebx
cvtsi2sd %eax,%xmm2
mulsd  0xe8f(%rip),%xmm2
imul   $0xffffffe7,%eax,%ebp
movsd  0x10(%rsp),%xmm0
movapd %xmm0,%xmm1
divsd  0xe82(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
lea    0xe81(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
mov    %ebp,%esi
call   1030 <motor@plt>
mov    $0x3,%edi
mov    %ebx,%esi
call   1030 <motor@plt>
movsd  0x8(%rsp),%xmm0
mulsd  0xe51(%rip),%xmm0
call   1040 <msleep@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"Move %f degrees (consumes %f seconds).\0A\00"
define i32 @rotate(double %0) {
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca double
%8 = alloca double
store double %0, double* %2
%9 = load double, double* %2
%10 = call i32 @copysign(double 1.000000e+00, double %9)
store i32 %10, i32* %3
store i32 25, i32* %4
%11 = load i32, i32* %3
%12 = sub nsw i32 0, %11
%13 = load i32, i32* %4
%14 = mul nsw i32 %12, %13
store i32 %14, i32* %5
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = mul nsw i32 %15, %16
%18 = sitofp i32 %17 to double
%19 = fmul double %18, 0x3FEFAE147AE147AE
%20 = fptosi double %19 to i32
store i32 %20, i32* %6
store double 6.775000e+00, double* %7
%21 = load double, double* %7
%22 = load i32, i32* %3
%23 = sitofp i32 %22 to double
%24 = fmul double %21, %23
%25 = load double, double* %2
%26 = fdiv double %25, 3.600000e+02
%27 = fmul double %24, %26
store double %27, double* %8
%28 = load double, double* %2
%29 = load double, double* %8
%30 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), double %28, double %29)
%31 = load i32, i32* %5
%32 = call i32 @motor(i32 0, i32 %31)
%33 = load i32, i32* %6
%34 = call i32 @motor(i32 3, i32 %33)
%35 = load double, double* %8
%36 = fmul double %35, 1.000000e+03
%37 = call i32 @msleep(double %36)
ret i32 0
}

LLVM IR (-O2):
@.str = [40 x i8] c"Move %f degrees (consumes %f seconds).\0A\00"
define i32 @rotate(double %0) {
%2 = tail call i32 @copysign(double 1.000000e+00, double %0)
%3 = mul i32 %2, -25
%4 = mul nsw i32 %2, 25
%5 = sitofp i32 %4 to double
%6 = fmul double %5, 0x3FEFAE147AE147AE
%7 = fptosi double %6 to i32
%8 = sitofp i32 %2 to double
%9 = fmul double %8, 6.775000e+00
%10 = fdiv double %0, 3.600000e+02
%11 = fmul double %10, %9
%12 = tail call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), double %0, double %11)
%13 = tail call i32 @motor(i32 0, i32 %3)
%14 = tail call i32 @motor(i32 3, i32 %7)
%15 = fmul double %11, 1.000000e+03
%16 = tail call i32 @msleep(double %15)
ret i32 0
}