#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 *);
int /*<<< orphan*/ kinematicsInverse(float, float, double, double, float *,
                                     float *);
int kinematicsRadToStep(float);
int /*<<< orphan*/ printf(char *, int, int, ...);
float sqrtf(float);
unsigned int strtoul(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ warning(char *, char *, char *);
int task_kinematics_line(int argc, char *argv[]) {
  float x = 0, y = 0, x1, y1, x2, y2, S, E;
  unsigned int segments;
  float d2, d, segmentLen;
  int i;
  if (argc != 8) {
    warning("usage: %s %s kinematics line <x1> <y1> <x2> <y2> <segments>\n",
            argv[0], argv[1]);
    return EXIT_FAILURE;
  }
  x1 = atof(argv[3]);
  y1 = atof(argv[4]);
  x2 = atof(argv[5]);
  y2 = atof(argv[6]);
  segments = strtoul(argv[7], NULL, 10);
  printf("# line from %f %f to %f %f in %d segments\n", x1, y1, x2, y2,
         segments);
  d2 = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
  d = sqrtf(d2);
  segmentLen = d / (float)segments;
  for (i = 0; i <= segments; ++i) {
    x = x1 + (((float)i * segmentLen) / d) * (x2 - x1);
    y = y1 + (((float)i * segmentLen) / d) * (y2 - y1);
    kinematicsInverse(x, y, 100.0, 75.0, &S, &E);
    printf("%d\t%d\n", kinematicsRadToStep(S), kinematicsRadToStep(E));
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<task_kinematics_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
cmpl   $0x8,-0x8(%rbp)
je     11c5 <task_kinematics_line+0x55>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe61(%rip),%rdi
call   1030 <warning@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1379 <task_kinematics_line+0x209>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <atof@plt>
movss  %xmm0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1040 <atof@plt>
movss  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   1040 <atof@plt>
movss  %xmm0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
call   1040 <atof@plt>
movss  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1090 <strtoul@plt>
mov    %eax,-0x34(%rbp)
cvttss2si -0x1c(%rbp),%esi
cvttss2si -0x20(%rbp),%edx
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x28(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mov    -0x34(%rbp),%ecx
lea    0xe01(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movss  -0x24(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
subss  %xmm1,%xmm0
movss  -0x28(%rbp),%xmm1
movss  -0x20(%rbp),%xmm2
subss  %xmm2,%xmm1
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x38(%rbp),%xmm0
call   1070 <sqrtf@plt>
movss  %xmm0,-0x3c(%rbp)
movss  -0x3c(%rbp),%xmm0
mov    -0x34(%rbp),%eax
cvtsi2ss %rax,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x34(%rbp),%eax
ja     136d <task_kinematics_line+0x1fd>
movss  -0x1c(%rbp),%xmm1
cvtsi2ssl -0x44(%rbp),%xmm0
mulss  -0x40(%rbp),%xmm0
divss  -0x3c(%rbp),%xmm0
movss  -0x24(%rbp),%xmm2
subss  -0x1c(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x20(%rbp),%xmm1
cvtsi2ssl -0x44(%rbp),%xmm0
mulss  -0x40(%rbp),%xmm0
divss  -0x3c(%rbp),%xmm0
movss  -0x28(%rbp),%xmm2
subss  -0x20(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
movsd  0xce0(%rip),%xmm2
movsd  0xce0(%rip),%xmm3
lea    -0x2c(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1060 <kinematicsInverse@plt>
movss  -0x2c(%rbp),%xmm0
call   1080 <kinematicsRadToStep@plt>
mov    %eax,-0x48(%rbp)
movss  -0x30(%rbp),%xmm0
call   1080 <kinematicsRadToStep@plt>
mov    -0x48(%rbp),%esi
mov    %eax,%edx
lea    0xd20(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    12ac <task_kinematics_line+0x13c>
mov    0x2c64(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<task_kinematics_line>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
cmp    $0x8,%edi
jne    1254 <task_kinematics_line+0xe4>
mov    0x18(%rbx),%rdi
call   1040 <atof@plt>
movss  %xmm0,0x18(%rsp)
mov    0x20(%rbx),%rdi
call   1040 <atof@plt>
movss  %xmm0,0x14(%rsp)
mov    0x28(%rbx),%rdi
call   1040 <atof@plt>
movss  %xmm0,0xc(%rsp)
mov    0x30(%rbx),%rdi
call   1040 <atof@plt>
movss  %xmm0,0x8(%rsp)
mov    0x38(%rbx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1090 <strtoul@plt>
mov    %eax,%ebx
cvttss2si 0x18(%rsp),%esi
cvttss2si 0x14(%rsp),%edx
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xe4e(%rip),%rdi
mov    %eax,%ecx
mov    $0x2,%al
call   1050 <printf@plt>
movss  0x8(%rsp),%xmm5
movss  0xc(%rsp),%xmm4
movss  0x14(%rsp),%xmm1
movss  0x18(%rsp),%xmm0
subss  %xmm0,%xmm4
subss  %xmm1,%xmm5
movaps %xmm5,%xmm1
mulss  %xmm5,%xmm1
movaps %xmm4,%xmm0
mulss  %xmm4,%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
movss  %xmm4,0xc(%rsp)
movss  %xmm5,0x8(%rsp)
jb     1273 <task_kinematics_line+0x103>
sqrtss %xmm0,%xmm0
jmp    1278 <task_kinematics_line+0x108>
mov    (%rbx),%rsi
mov    0x8(%rbx),%rdx
lea    0xdae(%rip),%rdi
call   1030 <warning@plt>
mov    0x2d72(%rip),%rax
jmp    1330 <task_kinematics_line+0x1c0>
call   1070 <sqrtf@plt>
movss  %xmm0,0x10(%rsp)
mov    %ebx,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
movss  0x10(%rsp),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0x1c(%rsp)
add    $0x1,%ebx
lea    0x24(%rsp),%r14
lea    0x20(%rsp),%r15
lea    0xdcc(%rip),%r12
xor    %r13d,%r13d
nop
xorps  %xmm1,%xmm1
cvtsi2ss %r13d,%xmm1
mulss  0x1c(%rsp),%xmm1
divss  0x10(%rsp),%xmm1
movaps %xmm1,%xmm0
mulss  0xc(%rsp),%xmm0
addss  0x18(%rsp),%xmm0
mulss  0x8(%rsp),%xmm1
addss  0x14(%rsp),%xmm1
movsd  0xd19(%rip),%xmm2
movsd  0xd19(%rip),%xmm3
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <kinematicsInverse@plt>
movss  0x24(%rsp),%xmm0
call   1080 <kinematicsRadToStep@plt>
mov    %eax,%ebp
movss  0x20(%rsp),%xmm0
call   1080 <kinematicsRadToStep@plt>
mov    %r12,%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r13d
cmp    %r13d,%ebx
jne    12b0 <task_kinematics_line+0x140>
mov    0x2ca8(%rip),%rax
mov    (%rax),%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [61 x i8] c"usage: %s %s kinematics line <x1> <y1> <x2> <y2> <segments>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [43 x i8] c"# line from %f %f to %f %f in %d segments\0A\00"
@.str.2 = [7 x i8] c"%d\09%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @task_kinematics_line(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
%12 = alloca float
%13 = alloca float
%14 = alloca i32
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store float 0.000000e+00, float* %6
store float 0.000000e+00, float* %7
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 8
br i1 %20, label %21, label %30
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @warning(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i8* %24, i8* %27)
%29 = load i32, i32* @EXIT_FAILURE
store i32 %29, i32* %3
br label %121
30: ; preds = %2
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 3
%33 = load i8*, i8** %32
%34 = call float @atof(i8* %33)
store float %34, float* %8
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 4
%37 = load i8*, i8** %36
%38 = call float @atof(i8* %37)
store float %38, float* %9
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 5
%41 = load i8*, i8** %40
%42 = call float @atof(i8* %41)
store float %42, float* %10
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 6
%45 = load i8*, i8** %44
%46 = call float @atof(i8* %45)
store float %46, float* %11
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 7
%49 = load i8*, i8** %48
%50 = call i32 @strtoul(i8* %49, i32* null, i32 10)
store i32 %50, i32* %14
%51 = load float, float* %8
%52 = fptosi float %51 to i32
%53 = load float, float* %9
%54 = fptosi float %53 to i32
%55 = load float, float* %10
%56 = fpext float %55 to double
%57 = load float, float* %11
%58 = fpext float %57 to double
%59 = load i32, i32* %14
%60 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %52, i32 %54, double %56, double %58, i32 %59)
%61 = load float, float* %10
%62 = load float, float* %8
%63 = fsub float %61, %62
%64 = load float, float* %10
%65 = load float, float* %8
%66 = fsub float %64, %65
%67 = load float, float* %11
%68 = load float, float* %9
%69 = fsub float %67, %68
%70 = load float, float* %11
%71 = load float, float* %9
%72 = fsub float %70, %71
%73 = fmul float %69, %72
%74 = call float @llvm.fmuladd.f32(float %63, float %66, float %73)
store float %74, float* %15
%75 = load float, float* %15
%76 = call float @sqrtf(float %75)
store float %76, float* %16
%77 = load float, float* %16
%78 = load i32, i32* %14
%79 = uitofp i32 %78 to float
%80 = fdiv float %77, %79
store float %80, float* %17
store i32 0, i32* %18
br label %81
81: ; preds = %116, %30
%82 = load i32, i32* %18
%83 = load i32, i32* %14
%84 = icmp ule i32 %82, %83
br i1 %84, label %85, label %119
85: ; preds = %81
%86 = load float, float* %8
%87 = load i32, i32* %18
%88 = sitofp i32 %87 to float
%89 = load float, float* %17
%90 = fmul float %88, %89
%91 = load float, float* %16
%92 = fdiv float %90, %91
%93 = load float, float* %10
%94 = load float, float* %8
%95 = fsub float %93, %94
%96 = call float @llvm.fmuladd.f32(float %92, float %95, float %86)
store float %96, float* %6
%97 = load float, float* %9
%98 = load i32, i32* %18
%99 = sitofp i32 %98 to float
%100 = load float, float* %17
%101 = fmul float %99, %100
%102 = load float, float* %16
%103 = fdiv float %101, %102
%104 = load float, float* %11
%105 = load float, float* %9
%106 = fsub float %104, %105
%107 = call float @llvm.fmuladd.f32(float %103, float %106, float %97)
store float %107, float* %7
%108 = load float, float* %6
%109 = load float, float* %7
%110 = call i32 @kinematicsInverse(float %108, float %109, double 1.000000e+02, double 7.500000e+01, float* %12, float* %13)
%111 = load float, float* %12
%112 = call i32 @kinematicsRadToStep(float %111)
%113 = load float, float* %13
%114 = call i32 @kinematicsRadToStep(float %113)
%115 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %112, i32 %114)
br label %116
116: ; preds = %85
%117 = load i32, i32* %18
%118 = add nsw i32 %117, 1
store i32 %118, i32* %18
br label %81
119: ; preds = %81
%120 = load i32, i32* @EXIT_SUCCESS
store i32 %120, i32* %3
br label %121
121: ; preds = %119, %21
%122 = load i32, i32* %3
ret i32 %122
}

LLVM IR (-O2):
@.str = [61 x i8] c"usage: %s %s kinematics line <x1> <y1> <x2> <y2> <segments>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [43 x i8] c"# line from %f %f to %f %f in %d segments\0A\00"
@.str.2 = [7 x i8] c"%d\09%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @task_kinematics_line(i32 %0, i8** nocapture %1) {
%3 = alloca float
%4 = alloca float
%5 = bitcast float* %3 to i8*
%6 = bitcast float* %4 to i8*
%7 = icmp eq i32 %0, 8
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @warning(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %11)
br label %56
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = tail call float @atof(i8* %15)
%17 = getelementptr inbounds i8*, i8** %1, i64 4
%18 = load i8*, i8** %17
%19 = tail call float @atof(i8* %18)
%20 = getelementptr inbounds i8*, i8** %1, i64 5
%21 = load i8*, i8** %20
%22 = tail call float @atof(i8* %21)
%23 = getelementptr inbounds i8*, i8** %1, i64 6
%24 = load i8*, i8** %23
%25 = tail call float @atof(i8* %24)
%26 = getelementptr inbounds i8*, i8** %1, i64 7
%27 = load i8*, i8** %26
%28 = tail call i32 @strtoul(i8* nocapture %27, i32* null, i32 10)
%29 = fptosi float %16 to i32
%30 = fptosi float %19 to i32
%31 = fpext float %22 to double
%32 = fpext float %25 to double
%33 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32 %30, double %31, double %32, i32 %28)
%34 = fsub float %22, %16
%35 = fsub float %25, %19
%36 = fmul float %35, %35
%37 = tail call float @llvm.fmuladd.f32(float %34, float %34, float %36)
%38 = tail call float @sqrtf(float %37)
%39 = uitofp i32 %28 to float
%40 = fdiv float %38, %39
br label %41
41: ; preds = %13, %41
%42 = phi i32 [ 0, %13 ], [ %54, %41 ]
%43 = sitofp i32 %42 to float
%44 = fmul float %40, %43
%45 = fdiv float %44, %38
%46 = call float @llvm.fmuladd.f32(float %45, float %34, float %16)
%47 = call float @llvm.fmuladd.f32(float %45, float %35, float %19)
%48 = call i32 @kinematicsInverse(float %46, float %47, double 1.000000e+02, double 7.500000e+01, float* %3, float* %4)
%49 = load float, float* %3
%50 = call i32 @kinematicsRadToStep(float %49)
%51 = load float, float* %4
%52 = call i32 @kinematicsRadToStep(float %51)
%53 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %50, i32 %52)
%54 = add nuw i32 %42, 1
%55 = icmp eq i32 %42, %28
br i1 %55, label %56, label %41
56: ; preds = %41, %8
%57 = phi i32* [ @EXIT_FAILURE, %8 ], [ @EXIT_SUCCESS, %41 ]
%58 = load i32, i32* %57
ret i32 %58
}