#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 EXIT_FAILURE;
int EXIT_SUCCESS;
float atof(char *);
double kinematicsDegToRad(double);
int /*<<< orphan*/ kinematicsForward(float *, float *, float, float, float,
                                     float);
int /*<<< orphan*/ kinematicsInverse(float, float, float, float, float *,
                                     float *);
double kinematicsRadToDeg(float);
int kinematicsRadToStep(float);
int /*<<< orphan*/ printf(char *, float, float, ...);
int /*<<< orphan*/ warning(char *, char *, char *);
int kinematicsTest(int argc, char *argv[]) {
  float x, y, L1, L2, S, E;
  if (argc != 4) {
    warning("usage: %s %s kinematics <X> <Y>\n", argv[0], argv[1]);
    return EXIT_FAILURE;
  }
  x = atof(argv[2]);
  y = atof(argv[3]);
  L1 = 100.0;
  L2 = 100.0;
  printf("x = %.2f   y = %.2f   L1 = %.2f   L2 = %.2f\n", x, y, L1, L2);
  kinematicsInverse(x, y, L1, L2, &S, &E);
  printf("raw  -  S = %.4f   E = %.4f\n", S, E);
  printf("deg  -  S = %.4f   E = %.4f\n", kinematicsRadToDeg(S),
         kinematicsRadToDeg(E));
  printf("rad  -  S = %.4f   E = %.4f\n",
         kinematicsDegToRad(kinematicsRadToDeg(S)),
         kinematicsDegToRad(kinematicsRadToDeg(E)));
  printf("step -  S = %4d   E = %4d\n", kinematicsRadToStep(S),
         kinematicsRadToStep(E));
  kinematicsForward(&x, &y, L1, L2, S, E);
  printf("x = %.4f   y = %.4f\n", x, y);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<kinematicsTest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11c5 <kinematicsTest+0x45>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe55(%rip),%rdi
call   1030 <warning@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1357 <kinematicsTest+0x1d7>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <atof@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <atof@plt>
movss  %xmm0,-0x18(%rbp)
movss  0xe0f(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xe02(%rip),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
movss  -0x20(%rbp),%xmm3
cvtss2sd %xmm3,%xmm3
lea    0xdff(%rip),%rdi
mov    $0x4,%al
call   1070 <printf@plt>
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
movss  -0x1c(%rbp),%xmm2
movss  -0x20(%rbp),%xmm3
lea    -0x24(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1080 <kinematicsInverse@plt>
movss  -0x24(%rbp),%xmm0
movss  -0x28(%rbp),%xmm1
lea    0xdf3(%rip),%rdi
mov    $0x2,%al
call   1070 <printf@plt>
movss  -0x24(%rbp),%xmm0
call   1090 <kinematicsRadToDeg@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x28(%rbp),%xmm0
call   1090 <kinematicsRadToDeg@plt>
movaps %xmm0,%xmm1
movss  -0x34(%rbp),%xmm0
cvtsd2ss %xmm1,%xmm1
lea    0xdd9(%rip),%rdi
mov    $0x2,%al
call   1070 <printf@plt>
movss  -0x24(%rbp),%xmm0
call   1090 <kinematicsRadToDeg@plt>
call   1060 <kinematicsDegToRad@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x28(%rbp),%xmm0
call   1090 <kinematicsRadToDeg@plt>
call   1060 <kinematicsDegToRad@plt>
movaps %xmm0,%xmm1
movss  -0x30(%rbp),%xmm0
cvtsd2ss %xmm1,%xmm1
lea    0xdb5(%rip),%rdi
mov    $0x2,%al
call   1070 <printf@plt>
movss  -0x24(%rbp),%xmm0
call   10a0 <kinematicsRadToStep@plt>
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x28(%rbp),%xmm0
call   10a0 <kinematicsRadToStep@plt>
movss  -0x2c(%rbp),%xmm0
cvtsi2ss %eax,%xmm1
lea    0xd9e(%rip),%rdi
mov    $0x2,%al
call   1070 <printf@plt>
movss  -0x1c(%rbp),%xmm0
movss  -0x20(%rbp),%xmm1
movss  -0x24(%rbp),%xmm2
movss  -0x28(%rbp),%xmm3
lea    -0x14(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <kinematicsForward@plt>
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
lea    0xd80(%rip),%rdi
mov    $0x2,%al
call   1070 <printf@plt>
mov    0x2c86(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kinematicsTest>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
cmp    $0x4,%edi
jne    1324 <kinematicsTest+0x1a4>
mov    0x10(%rbx),%rdi
call   1040 <atof@plt>
movss  %xmm0,0x8(%rsp)
movss  %xmm0,0x18(%rsp)
mov    0x18(%rbx),%rdi
call   1040 <atof@plt>
movaps %xmm0,%xmm1
movss  %xmm0,0x1c(%rsp)
movss  %xmm0,0x14(%rsp)
lea    0xe68(%rip),%rdi
movsd  0xe33(%rip),%xmm2
movss  0x8(%rsp),%xmm0
movaps %xmm2,%xmm3
mov    $0x4,%al
call   1070 <printf@plt>
movss  0xe23(%rip),%xmm2
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
movss  0x8(%rsp),%xmm0
movss  0x1c(%rsp),%xmm1
movaps %xmm2,%xmm3
call   1080 <kinematicsInverse@plt>
movss  0x10(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
lea    0xe44(%rip),%rdi
mov    $0x2,%al
call   1070 <printf@plt>
movss  0x10(%rsp),%xmm0
call   1090 <kinematicsRadToDeg@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
movss  0xc(%rsp),%xmm0
call   1090 <kinematicsRadToDeg@plt>
xorps  %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm1
lea    0xe2c(%rip),%rdi
movss  0x8(%rsp),%xmm0
mov    $0x2,%al
call   1070 <printf@plt>
movss  0x10(%rsp),%xmm0
call   1090 <kinematicsRadToDeg@plt>
call   1060 <kinematicsDegToRad@plt>
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
movss  0xc(%rsp),%xmm0
call   1090 <kinematicsRadToDeg@plt>
call   1060 <kinematicsDegToRad@plt>
xorps  %xmm1,%xmm1
cvtsd2ss %xmm0,%xmm1
lea    0xe04(%rip),%rdi
movss  0x8(%rsp),%xmm0
mov    $0x2,%al
call   1070 <printf@plt>
movss  0x10(%rsp),%xmm0
call   10a0 <kinematicsRadToStep@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x8(%rsp)
movss  0xc(%rsp),%xmm0
call   10a0 <kinematicsRadToStep@plt>
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
lea    0xde3(%rip),%rdi
movss  0x8(%rsp),%xmm0
mov    $0x2,%al
call   1070 <printf@plt>
movss  0x10(%rsp),%xmm2
movss  0xc(%rsp),%xmm3
lea    0x18(%rsp),%rdi
lea    0x14(%rsp),%rsi
movss  0xd0f(%rip),%xmm0
movaps %xmm0,%xmm1
call   1050 <kinematicsForward@plt>
movss  0x18(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
lea    0xdb8(%rip),%rdi
mov    $0x2,%al
call   1070 <printf@plt>
mov    0x2cb6(%rip),%rax
jmp    133e <kinematicsTest+0x1be>
mov    (%rbx),%rsi
mov    0x8(%rbx),%rdx
lea    0xcda(%rip),%rdi
call   1030 <warning@plt>
mov    0x2ca2(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"usage: %s %s kinematics <X> <Y>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [45 x i8] c"x = %.2f y = %.2f L1 = %.2f L2 = %.2f\0A\00"
@.str.2 = [29 x i8] c"raw - S = %.4f E = %.4f\0A\00"
@.str.3 = [29 x i8] c"deg - S = %.4f E = %.4f\0A\00"
@.str.4 = [29 x i8] c"rad - S = %.4f E = %.4f\0A\00"
@.str.5 = [27 x i8] c"step - S = %4d E = %4d\0A\00"
@.str.6 = [21 x i8] c"x = %.4f y = %.4f\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @kinematicsTest(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 4
br i1 %13, label %14, label %23
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @warning(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
store i32 %22, i32* %3
br label %79
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call float @atof(i8* %26)
store float %27, float* %6
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 3
%30 = load i8*, i8** %29
%31 = call float @atof(i8* %30)
store float %31, float* %7
store float 1.000000e+02, float* %8
store float 1.000000e+02, float* %9
%32 = load float, float* %6
%33 = load float, float* %7
%34 = load float, float* %8
%35 = fpext float %34 to double
%36 = load float, float* %9
%37 = fpext float %36 to double
%38 = call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), float %32, float %33, double %35, double %37)
%39 = load float, float* %6
%40 = load float, float* %7
%41 = load float, float* %8
%42 = load float, float* %9
%43 = call i32 @kinematicsInverse(float %39, float %40, float %41, float %42, float* %10, float* %11)
%44 = load float, float* %10
%45 = load float, float* %11
%46 = call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), float %44, float %45)
%47 = load float, float* %10
%48 = call double @kinematicsRadToDeg(float %47)
%49 = fptrunc double %48 to float
%50 = load float, float* %11
%51 = call double @kinematicsRadToDeg(float %50)
%52 = fptrunc double %51 to float
%53 = call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), float %49, float %52)
%54 = load float, float* %10
%55 = call double @kinematicsRadToDeg(float %54)
%56 = call double @kinematicsDegToRad(double %55)
%57 = fptrunc double %56 to float
%58 = load float, float* %11
%59 = call double @kinematicsRadToDeg(float %58)
%60 = call double @kinematicsDegToRad(double %59)
%61 = fptrunc double %60 to float
%62 = call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), float %57, float %61)
%63 = load float, float* %10
%64 = call i32 @kinematicsRadToStep(float %63)
%65 = sitofp i32 %64 to float
%66 = load float, float* %11
%67 = call i32 @kinematicsRadToStep(float %66)
%68 = sitofp i32 %67 to float
%69 = call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), float %65, float %68)
%70 = load float, float* %8
%71 = load float, float* %9
%72 = load float, float* %10
%73 = load float, float* %11
%74 = call i32 @kinematicsForward(float* %6, float* %7, float %70, float %71, float %72, float %73)
%75 = load float, float* %6
%76 = load float, float* %7
%77 = call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), float %75, float %76)
%78 = load i32, i32* @EXIT_SUCCESS
store i32 %78, i32* %3
br label %79
79: ; preds = %23, %14
%80 = load i32, i32* %3
ret i32 %80
}

LLVM IR (-O2):
@.str = [33 x i8] c"usage: %s %s kinematics <X> <Y>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [45 x i8] c"x = %.2f y = %.2f L1 = %.2f L2 = %.2f\0A\00"
@.str.2 = [29 x i8] c"raw - S = %.4f E = %.4f\0A\00"
@.str.3 = [29 x i8] c"deg - S = %.4f E = %.4f\0A\00"
@.str.4 = [29 x i8] c"rad - S = %.4f E = %.4f\0A\00"
@.str.5 = [27 x i8] c"step - S = %4d E = %4d\0A\00"
@.str.6 = [21 x i8] c"x = %.4f y = %.4f\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @kinematicsTest(i32 %0, i8** nocapture %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = bitcast float* %3 to i8*
%8 = bitcast float* %4 to i8*
%9 = bitcast float* %5 to i8*
%10 = bitcast float* %6 to i8*
%11 = icmp eq i32 %0, 4
br i1 %11, label %17, label %12
12: ; preds = %2
%13 = load i8*, i8** %1
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32 @warning(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %15)
br label %58
17: ; preds = %2
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = tail call float @atof(i8* %19)
store float %20, float* %3
%21 = getelementptr inbounds i8*, i8** %1, i64 3
%22 = load i8*, i8** %21
%23 = tail call float @atof(i8* %22)
store float %23, float* %4
%24 = tail call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), float %20, float %23, double 1.000000e+02, double 1.000000e+02)
%25 = call i32 @kinematicsInverse(float %20, float %23, float 1.000000e+02, float 1.000000e+02, float* %5, float* %6)
%26 = load float, float* %5
%27 = load float, float* %6
%28 = call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), float %26, float %27)
%29 = load float, float* %5
%30 = call double @kinematicsRadToDeg(float %29)
%31 = fptrunc double %30 to float
%32 = load float, float* %6
%33 = call double @kinematicsRadToDeg(float %32)
%34 = fptrunc double %33 to float
%35 = call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), float %31, float %34)
%36 = load float, float* %5
%37 = call double @kinematicsRadToDeg(float %36)
%38 = call double @kinematicsDegToRad(double %37)
%39 = fptrunc double %38 to float
%40 = load float, float* %6
%41 = call double @kinematicsRadToDeg(float %40)
%42 = call double @kinematicsDegToRad(double %41)
%43 = fptrunc double %42 to float
%44 = call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), float %39, float %43)
%45 = load float, float* %5
%46 = call i32 @kinematicsRadToStep(float %45)
%47 = sitofp i32 %46 to float
%48 = load float, float* %6
%49 = call i32 @kinematicsRadToStep(float %48)
%50 = sitofp i32 %49 to float
%51 = call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), float %47, float %50)
%52 = load float, float* %5
%53 = load float, float* %6
%54 = call i32 @kinematicsForward(float* %3, float* %4, float 1.000000e+02, float 1.000000e+02, float %52, float %53)
%55 = load float, float* %3
%56 = load float, float* %4
%57 = call i32 (i8*, float, float, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), float %55, float %56)
br label %58
58: ; preds = %17, %12
%59 = phi i32* [ @EXIT_FAILURE, %12 ], [ @EXIT_SUCCESS, %17 ]
%60 = load i32, i32* %59
ret i32 %60
}