#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 */
double FindMaxDouble(double *);
int cos(double);
int /*<<< orphan*/ motorSet(int, int);
int /*<<< orphan*/ motorStop(int);
void RadianOutput(double radians, double speed, int rotation) {
  if (speed > 0) {
    double frontLeftOutput = -127 * cos((3.14159265358979 / 4) - radians),
           frontRightOutput = 127 * cos((3.14159265358979 / 4) + radians),
           rearRightOutput = 127 * cos((3.14159265358979 / 4) - radians),
           rearLeftOutput = -127 * cos((3.14159265358979 / 4) + radians);
    frontLeftOutput += rotation;
    frontRightOutput += rotation;
    rearRightOutput += rotation;
    rearLeftOutput += rotation;
    double output[4] = {frontLeftOutput, frontRightOutput, rearLeftOutput,
                        rearRightOutput};
    double maxValue = FindMaxDouble(output);
    speed *= 127 / maxValue;
    frontLeftOutput *= speed;
    frontRightOutput *= speed;
    rearLeftOutput *= speed;
    rearRightOutput *= speed;
    motorSet(3, frontLeftOutput);
    motorSet(4, frontRightOutput);
    motorSet(2, rearLeftOutput);
    motorSet(5, rearRightOutput);
  } else if (rotation > 20 || rotation < -20) {
    motorSet(3, rotation);
    motorSet(4, rotation);
    motorSet(2, rotation);
    motorSet(5, rotation);
  } else {
    motorStop(3);
    motorStop(4);
    motorStop(2);
    motorStop(5);
  }
}


x86 assembly (clang, -O0):
<RadianOutput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12eb <RadianOutput+0x1ab>
movsd  0xe99(%rip),%xmm0
subsd  -0x8(%rbp),%xmm0
call   1050 <cos@plt>
imul   $0xffffff81,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe78(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
call   1050 <cos@plt>
imul   $0x7f,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe5a(%rip),%xmm0
subsd  -0x8(%rbp),%xmm0
call   1050 <cos@plt>
imul   $0x7f,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe3c(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
call   1050 <cos@plt>
imul   $0xffffff81,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x38(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
lea    -0x60(%rbp),%rdi
call   1030 <FindMaxDouble@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  0xda1(%rip),%xmm0
divsd  -0x68(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
cvttsd2si -0x20(%rbp),%esi
mov    $0x3,%edi
call   1040 <motorSet@plt>
cvttsd2si -0x28(%rbp),%esi
mov    $0x4,%edi
call   1040 <motorSet@plt>
cvttsd2si -0x38(%rbp),%esi
mov    $0x2,%edi
call   1040 <motorSet@plt>
cvttsd2si -0x30(%rbp),%esi
mov    $0x5,%edi
call   1040 <motorSet@plt>
jmp    1365 <RadianOutput+0x225>
cmpl   $0x14,-0x14(%rbp)
jg     12ff <RadianOutput+0x1bf>
cmpl   $0xffffffec,-0x14(%rbp)
jge    1338 <RadianOutput+0x1f8>
mov    -0x14(%rbp),%esi
mov    $0x3,%edi
call   1040 <motorSet@plt>
mov    -0x14(%rbp),%esi
mov    $0x4,%edi
call   1040 <motorSet@plt>
mov    -0x14(%rbp),%esi
mov    $0x2,%edi
call   1040 <motorSet@plt>
mov    -0x14(%rbp),%esi
mov    $0x5,%edi
call   1040 <motorSet@plt>
jmp    1360 <RadianOutput+0x220>
mov    $0x3,%edi
call   1060 <motorStop@plt>
mov    $0x4,%edi
call   1060 <motorStop@plt>
mov    $0x2,%edi
call   1060 <motorStop@plt>
mov    $0x5,%edi
call   1060 <motorStop@plt>
jmp    1365 <RadianOutput+0x225>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RadianOutput>:
push   %rbx
sub    $0x50,%rsp
mov    %edi,%ebx
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jbe    12e1 <RadianOutput+0x1a1>
movsd  0xe9f(%rip),%xmm0
subsd  %xmm2,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  %xmm1,0x28(%rsp)
movsd  %xmm2,0x8(%rsp)
call   1050 <cos@plt>
mov    %eax,%ecx
shl    $0x7,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  0xe62(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1050 <cos@plt>
mov    %eax,%ecx
shl    $0x7,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <cos@plt>
mov    %eax,%ecx
shl    $0x7,%ecx
sub    %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <cos@plt>
mov    %eax,%ecx
shl    $0x7,%ecx
sub    %ecx,%eax
cvtsi2sd %eax,%xmm3
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0x18(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x20(%rsp),%xmm2
addsd  %xmm0,%xmm2
movsd  %xmm2,0x20(%rsp)
movsd  0x10(%rsp),%xmm4
addsd  %xmm0,%xmm4
movsd  %xmm4,0x10(%rsp)
addsd  %xmm0,%xmm3
movsd  %xmm3,0x8(%rsp)
movsd  %xmm1,0x30(%rsp)
movsd  %xmm2,0x38(%rsp)
movsd  %xmm3,0x40(%rsp)
movsd  %xmm4,0x48(%rsp)
lea    0x30(%rsp),%rdi
call   1030 <FindMaxDouble@plt>
movsd  0xdab(%rip),%xmm1
divsd  %xmm0,%xmm1
mulsd  0x28(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
mulsd  %xmm1,%xmm2
movsd  0x20(%rsp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
mulsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x18(%rsp)
cvttsd2si %xmm2,%esi
mov    $0x3,%edi
call   1040 <motorSet@plt>
cvttsd2si 0x20(%rsp),%esi
mov    $0x4,%edi
call   1040 <motorSet@plt>
cvttsd2si 0x8(%rsp),%esi
mov    $0x2,%edi
call   1040 <motorSet@plt>
cvttsd2si 0x18(%rsp),%esi
mov    $0x5,%edi
call   1040 <motorSet@plt>
add    $0x50,%rsp
pop    %rbx
ret
lea    -0x15(%rbx),%eax
mov    $0x3,%edi
cmp    $0xffffffd6,%eax
ja     131e <RadianOutput+0x1de>
mov    %ebx,%esi
call   1040 <motorSet@plt>
mov    $0x4,%edi
mov    %ebx,%esi
call   1040 <motorSet@plt>
mov    $0x2,%edi
mov    %ebx,%esi
call   1040 <motorSet@plt>
mov    $0x5,%edi
mov    %ebx,%esi
add    $0x50,%rsp
pop    %rbx
jmp    1040 <motorSet@plt>
call   1060 <motorStop@plt>
mov    $0x4,%edi
call   1060 <motorStop@plt>
mov    $0x2,%edi
call   1060 <motorStop@plt>
mov    $0x5,%edi
add    $0x50,%rsp
pop    %rbx
jmp    1060 <motorStop@plt>

LLVM IR (-O0):
define void @RadianOutput(double %0, double %1, i32 %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca [4 x double]
%12 = alloca double
store double %0, double* %4
store double %1, double* %5
store i32 %2, i32* %6
%13 = load double, double* %5
%14 = fcmp ogt double %13, 0.000000e+00
br i1 %14, label %15, label %90
15: ; preds = %3
%16 = load double, double* %4
%17 = fsub double 0x3FE921FB54442D11, %16
%18 = call i32 @cos(double %17)
%19 = mul nsw i32 -127, %18
%20 = sitofp i32 %19 to double
store double %20, double* %7
%21 = load double, double* %4
%22 = fadd double 0x3FE921FB54442D11, %21
%23 = call i32 @cos(double %22)
%24 = mul nsw i32 127, %23
%25 = sitofp i32 %24 to double
store double %25, double* %8
%26 = load double, double* %4
%27 = fsub double 0x3FE921FB54442D11, %26
%28 = call i32 @cos(double %27)
%29 = mul nsw i32 127, %28
%30 = sitofp i32 %29 to double
store double %30, double* %9
%31 = load double, double* %4
%32 = fadd double 0x3FE921FB54442D11, %31
%33 = call i32 @cos(double %32)
%34 = mul nsw i32 -127, %33
%35 = sitofp i32 %34 to double
store double %35, double* %10
%36 = load i32, i32* %6
%37 = sitofp i32 %36 to double
%38 = load double, double* %7
%39 = fadd double %38, %37
store double %39, double* %7
%40 = load i32, i32* %6
%41 = sitofp i32 %40 to double
%42 = load double, double* %8
%43 = fadd double %42, %41
store double %43, double* %8
%44 = load i32, i32* %6
%45 = sitofp i32 %44 to double
%46 = load double, double* %9
%47 = fadd double %46, %45
store double %47, double* %9
%48 = load i32, i32* %6
%49 = sitofp i32 %48 to double
%50 = load double, double* %10
%51 = fadd double %50, %49
store double %51, double* %10
%52 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 0
%53 = load double, double* %7
store double %53, double* %52
%54 = getelementptr inbounds double, double* %52, i64 1
%55 = load double, double* %8
store double %55, double* %54
%56 = getelementptr inbounds double, double* %54, i64 1
%57 = load double, double* %10
store double %57, double* %56
%58 = getelementptr inbounds double, double* %56, i64 1
%59 = load double, double* %9
store double %59, double* %58
%60 = getelementptr inbounds [4 x double], [4 x double]* %11, i64 0, i64 0
%61 = call double @FindMaxDouble(double* %60)
store double %61, double* %12
%62 = load double, double* %12
%63 = fdiv double 1.270000e+02, %62
%64 = load double, double* %5
%65 = fmul double %64, %63
store double %65, double* %5
%66 = load double, double* %5
%67 = load double, double* %7
%68 = fmul double %67, %66
store double %68, double* %7
%69 = load double, double* %5
%70 = load double, double* %8
%71 = fmul double %70, %69
store double %71, double* %8
%72 = load double, double* %5
%73 = load double, double* %10
%74 = fmul double %73, %72
store double %74, double* %10
%75 = load double, double* %5
%76 = load double, double* %9
%77 = fmul double %76, %75
store double %77, double* %9
%78 = load double, double* %7
%79 = fptosi double %78 to i32
%80 = call i32 @motorSet(i32 3, i32 %79)
%81 = load double, double* %8
%82 = fptosi double %81 to i32
%83 = call i32 @motorSet(i32 4, i32 %82)
%84 = load double, double* %10
%85 = fptosi double %84 to i32
%86 = call i32 @motorSet(i32 2, i32 %85)
%87 = load double, double* %9
%88 = fptosi double %87 to i32
%89 = call i32 @motorSet(i32 5, i32 %88)
br label %111
90: ; preds = %3
%91 = load i32, i32* %6
%92 = icmp sgt i32 %91, 20
br i1 %92, label %96, label %93
93: ; preds = %90
%94 = load i32, i32* %6
%95 = icmp slt i32 %94, -20
br i1 %95, label %96, label %105
96: ; preds = %93, %90
%97 = load i32, i32* %6
%98 = call i32 @motorSet(i32 3, i32 %97)
%99 = load i32, i32* %6
%100 = call i32 @motorSet(i32 4, i32 %99)
%101 = load i32, i32* %6
%102 = call i32 @motorSet(i32 2, i32 %101)
%103 = load i32, i32* %6
%104 = call i32 @motorSet(i32 5, i32 %103)
br label %110
105: ; preds = %93
%106 = call i32 @motorStop(i32 3)
%107 = call i32 @motorStop(i32 4)
%108 = call i32 @motorStop(i32 2)
%109 = call i32 @motorStop(i32 5)
br label %110
110: ; preds = %105, %96
br label %111
111: ; preds = %110, %15
ret void
}

LLVM IR (-O2):
define void @RadianOutput(double %0, double %1, i32 %2) {
%4 = alloca [4 x double]
%5 = fcmp ogt double %1, 0.000000e+00
br i1 %5, label %6, label %46
6: ; preds = %3
%7 = fsub double 0x3FE921FB54442D11, %0
%8 = tail call i32 @cos(double %7)
%9 = mul nsw i32 %8, -127
%10 = sitofp i32 %9 to double
%11 = fadd double %0, 0x3FE921FB54442D11
%12 = tail call i32 @cos(double %11)
%13 = mul nsw i32 %12, 127
%14 = sitofp i32 %13 to double
%15 = tail call i32 @cos(double %7)
%16 = mul nsw i32 %15, 127
%17 = sitofp i32 %16 to double
%18 = tail call i32 @cos(double %11)
%19 = mul nsw i32 %18, -127
%20 = sitofp i32 %19 to double
%21 = sitofp i32 %2 to double
%22 = fadd double %21, %10
%23 = fadd double %21, %14
%24 = fadd double %21, %17
%25 = fadd double %21, %20
%26 = bitcast [4 x double]* %4 to i8*
%27 = getelementptr inbounds [4 x double], [4 x double]* %4, i64 0, i64 0
store double %22, double* %27
%28 = getelementptr inbounds [4 x double], [4 x double]* %4, i64 0, i64 1
store double %23, double* %28
%29 = getelementptr inbounds [4 x double], [4 x double]* %4, i64 0, i64 2
store double %25, double* %29
%30 = getelementptr inbounds [4 x double], [4 x double]* %4, i64 0, i64 3
store double %24, double* %30
%31 = call double @FindMaxDouble(double* %27)
%32 = fdiv double 1.270000e+02, %31
%33 = fmul double %32, %1
%34 = fmul double %22, %33
%35 = fmul double %23, %33
%36 = fmul double %25, %33
%37 = fmul double %24, %33
%38 = fptosi double %34 to i32
%39 = call i32 @motorSet(i32 3, i32 %38)
%40 = fptosi double %35 to i32
%41 = call i32 @motorSet(i32 4, i32 %40)
%42 = fptosi double %36 to i32
%43 = call i32 @motorSet(i32 2, i32 %42)
%44 = fptosi double %37 to i32
%45 = call i32 @motorSet(i32 5, i32 %44)
br label %59
46: ; preds = %3
%47 = add i32 %2, -21
%48 = icmp ult i32 %47, -41
br i1 %48, label %49, label %54
49: ; preds = %46
%50 = tail call i32 @motorSet(i32 3, i32 %2)
%51 = tail call i32 @motorSet(i32 4, i32 %2)
%52 = tail call i32 @motorSet(i32 2, i32 %2)
%53 = tail call i32 @motorSet(i32 5, i32 %2)
br label %59
54: ; preds = %46
%55 = tail call i32 @motorStop(i32 3)
%56 = tail call i32 @motorStop(i32 4)
%57 = tail call i32 @motorStop(i32 2)
%58 = tail call i32 @motorStop(i32 5)
br label %59
59: ; preds = %49, %54, %6
ret void
}