#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*/ dToR(int);
int /*<<< orphan*/ printf(char *, int, ...);
double sin(int);
int sort(float, float *);
double tan(int /*<<< orphan*/);
void servoFix(int x, int y, float table[]) {
  float xDist;
  float yDist;
  int home = 68;
  float s0, s1;
  float s2;
  int s0angle;
  int s1angle, s2angle;
  xDist = 6.7 * sin(x);
  yDist = 6.7 * sin(y);
  s0 = table[home] + (7.7365 * tan(dToR(y)));
  s1 = table[home] - (3.8683 * tan(dToR(y))) - (6.7 * tan(dToR(x)));
  s2 = table[home] - (3.8683 * tan(dToR(y))) + (6.7 * tan(dToR(x)));
  printf("table[%d] = %f\n", home, table[home]);
  printf("s0 = %f, s1 = %f, s2 = %f\n", s0, s1, s2);
  s0angle = sort(s0, table);
  s1angle = sort(s1, table);
  s2angle = sort(s2, table);
  printf("s0angle = %d\n", s0angle);
  printf("s1angle = %d\n", s1angle);
  printf("s2angle = %d\n", s2angle);
  return;
}


x86 assembly (clang, -O0):
<servoFix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
movl   $0x44,-0x1c(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  0xe84(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  0xe64(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <dToR@plt>
mov    %eax,%edi
call   1070 <tan@plt>
movsd  -0x60(%rbp),%xmm1
movsd  0xe3d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <dToR@plt>
mov    %eax,%edi
call   1070 <tan@plt>
movsd  -0x58(%rbp),%xmm1
movsd  0xdea(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <dToR@plt>
mov    %eax,%edi
call   1070 <tan@plt>
movsd  -0x50(%rbp),%xmm1
movsd  0xdc9(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <dToR@plt>
mov    %eax,%edi
call   1070 <tan@plt>
movsd  -0x48(%rbp),%xmm1
movsd  0xd7e(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <dToR@plt>
mov    %eax,%edi
call   1070 <tan@plt>
movsd  -0x40(%rbp),%xmm1
movsd  0xd4d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd41(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cvttss2si -0x20(%rbp),%esi
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x28(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd2c(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movss  -0x20(%rbp),%xmm0
mov    -0x10(%rbp),%rdi
call   1040 <sort@plt>
mov    %eax,-0x2c(%rbp)
movss  -0x24(%rbp),%xmm0
mov    -0x10(%rbp),%rdi
call   1040 <sort@plt>
mov    %eax,-0x30(%rbp)
movss  -0x28(%rbp),%xmm0
mov    -0x10(%rbp),%rdi
call   1040 <sort@plt>
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%esi
lea    0xd03(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%esi
lea    0xd00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%esi
lea    0xcfd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<servoFix>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %edi,%r14d
call   1050 <sin@plt>
mov    %ebp,%edi
call   1050 <sin@plt>
movss  0x110(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
mov    %ebp,%edi
call   1060 <dToR@plt>
mov    %eax,%edi
call   1070 <tan@plt>
mulsd  0xe6c(%rip),%xmm0
addsd  0x18(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x18(%rsp)
movss  0x110(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %ebp,%edi
call   1060 <dToR@plt>
mov    %eax,%edi
call   1070 <tan@plt>
mulsd  0xe3c(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r14d,%edi
call   1060 <dToR@plt>
mov    %eax,%edi
call   1070 <tan@plt>
mulsd  0xe21(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
movss  0x110(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
call   1060 <dToR@plt>
mov    %eax,%edi
call   1070 <tan@plt>
mulsd  0xde1(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r14d,%edi
call   1060 <dToR@plt>
mov    %eax,%edi
call   1070 <tan@plt>
mulsd  0xdce(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
movss  0x110(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdb3(%rip),%rdi
mov    $0x44,%esi
mov    $0x1,%al
call   1030 <printf@plt>
cvttss2si 0x18(%rsp),%esi
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xd96(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
movss  0x18(%rsp),%xmm0
mov    %rbx,%rdi
call   1040 <sort@plt>
mov    %eax,%ebp
movss  0x10(%rsp),%xmm0
mov    %rbx,%rdi
call   1040 <sort@plt>
mov    %eax,%r14d
movss  0x8(%rsp),%xmm0
mov    %rbx,%rdi
call   1040 <sort@plt>
mov    %eax,%ebx
lea    0xd72(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xd70(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xd6d(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"table[%d] = %f\0A\00"
@.str.1 = [27 x i8] c"s0 = %f, s1 = %f, s2 = %f\0A\00"
@.str.2 = [14 x i8] c"s0angle = %d\0A\00"
@.str.3 = [14 x i8] c"s1angle = %d\0A\00"
@.str.4 = [14 x i8] c"s2angle = %d\0A\00"
define void @servoFix(i32 %0, i32 %1, float* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca float*
%7 = alloca float
%8 = alloca float
%9 = alloca i32
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store float* %2, float** %6
store i32 68, i32* %9
%16 = load i32, i32* %4
%17 = call double @sin(i32 %16)
%18 = fmul double 6.700000e+00, %17
%19 = fptrunc double %18 to float
store float %19, float* %7
%20 = load i32, i32* %5
%21 = call double @sin(i32 %20)
%22 = fmul double 6.700000e+00, %21
%23 = fptrunc double %22 to float
store float %23, float* %8
%24 = load float*, float** %6
%25 = load i32, i32* %9
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds float, float* %24, i64 %26
%28 = load float, float* %27
%29 = fpext float %28 to double
%30 = load i32, i32* %5
%31 = call i32 @dToR(i32 %30)
%32 = call double @tan(i32 %31)
%33 = call double @llvm.fmuladd.f64(double 7.736500e+00, double %32, double %29)
%34 = fptrunc double %33 to float
store float %34, float* %10
%35 = load float*, float** %6
%36 = load i32, i32* %9
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds float, float* %35, i64 %37
%39 = load float, float* %38
%40 = fpext float %39 to double
%41 = load i32, i32* %5
%42 = call i32 @dToR(i32 %41)
%43 = call double @tan(i32 %42)
%44 = call double @llvm.fmuladd.f64(double -3.868300e+00, double %43, double %40)
%45 = load i32, i32* %4
%46 = call i32 @dToR(i32 %45)
%47 = call double @tan(i32 %46)
%48 = call double @llvm.fmuladd.f64(double -6.700000e+00, double %47, double %44)
%49 = fptrunc double %48 to float
store float %49, float* %11
%50 = load float*, float** %6
%51 = load i32, i32* %9
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds float, float* %50, i64 %52
%54 = load float, float* %53
%55 = fpext float %54 to double
%56 = load i32, i32* %5
%57 = call i32 @dToR(i32 %56)
%58 = call double @tan(i32 %57)
%59 = call double @llvm.fmuladd.f64(double -3.868300e+00, double %58, double %55)
%60 = load i32, i32* %4
%61 = call i32 @dToR(i32 %60)
%62 = call double @tan(i32 %61)
%63 = call double @llvm.fmuladd.f64(double 6.700000e+00, double %62, double %59)
%64 = fptrunc double %63 to float
store float %64, float* %12
%65 = load i32, i32* %9
%66 = load float*, float** %6
%67 = load i32, i32* %9
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds float, float* %66, i64 %68
%70 = load float, float* %69
%71 = fpext float %70 to double
%72 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %65, double %71)
%73 = load float, float* %10
%74 = fptosi float %73 to i32
%75 = load float, float* %11
%76 = fpext float %75 to double
%77 = load float, float* %12
%78 = fpext float %77 to double
%79 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %74, double %76, double %78)
%80 = load float, float* %10
%81 = load float*, float** %6
%82 = call i32 @sort(float %80, float* %81)
store i32 %82, i32* %13
%83 = load float, float* %11
%84 = load float*, float** %6
%85 = call i32 @sort(float %83, float* %84)
store i32 %85, i32* %14
%86 = load float, float* %12
%87 = load float*, float** %6
%88 = call i32 @sort(float %86, float* %87)
store i32 %88, i32* %15
%89 = load i32, i32* %13
%90 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %89)
%91 = load i32, i32* %14
%92 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %91)
%93 = load i32, i32* %15
%94 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %93)
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"table[%d] = %f\0A\00"
@.str.1 = [27 x i8] c"s0 = %f, s1 = %f, s2 = %f\0A\00"
@.str.2 = [14 x i8] c"s0angle = %d\0A\00"
@.str.3 = [14 x i8] c"s1angle = %d\0A\00"
@.str.4 = [14 x i8] c"s2angle = %d\0A\00"
define void @servoFix(i32 %0, i32 %1, float* %2) {
%4 = tail call double @sin(i32 %0)
%5 = tail call double @sin(i32 %1)
%6 = getelementptr inbounds float, float* %2, i64 68
%7 = load float, float* %6
%8 = fpext float %7 to double
%9 = tail call i32 @dToR(i32 %1)
%10 = tail call double @tan(i32 %9)
%11 = tail call double @llvm.fmuladd.f64(double %10, double 7.736500e+00, double %8)
%12 = fptrunc double %11 to float
%13 = load float, float* %6
%14 = fpext float %13 to double
%15 = tail call i32 @dToR(i32 %1)
%16 = tail call double @tan(i32 %15)
%17 = tail call double @llvm.fmuladd.f64(double %16, double -3.868300e+00, double %14)
%18 = tail call i32 @dToR(i32 %0)
%19 = tail call double @tan(i32 %18)
%20 = tail call double @llvm.fmuladd.f64(double %19, double -6.700000e+00, double %17)
%21 = fptrunc double %20 to float
%22 = load float, float* %6
%23 = fpext float %22 to double
%24 = tail call i32 @dToR(i32 %1)
%25 = tail call double @tan(i32 %24)
%26 = tail call double @llvm.fmuladd.f64(double %25, double -3.868300e+00, double %23)
%27 = tail call i32 @dToR(i32 %0)
%28 = tail call double @tan(i32 %27)
%29 = tail call double @llvm.fmuladd.f64(double %28, double 6.700000e+00, double %26)
%30 = fptrunc double %29 to float
%31 = load float, float* %6
%32 = fpext float %31 to double
%33 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 68, double %32)
%34 = fptosi float %12 to i32
%35 = fpext float %21 to double
%36 = fpext float %30 to double
%37 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %34, double %35, double %36)
%38 = tail call i32 @sort(float %12, float* %2)
%39 = tail call i32 @sort(float %21, float* %2)
%40 = tail call i32 @sort(float %30, float* %2)
%41 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%42 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%43 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %40)
ret void
}