#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*/ printf(char *, ...);
void ik_update_xyz(float *xyz_pos, int which, int change) {
  float step, max, min;
  int i;
  printf("Update XYZ\n");
  for (i = 0; i < 3; i++) {
    printf("\n -- xyz[%d] - %f", i, xyz_pos[i]);
  }
  if (which == 0) {
    max = 0.29;
    min = 0.0995;
    step = (0.29 - 0.0995) / 100;
    printf("Update X by: %f\n", step);
  } else if (which == 1) {
    max = 0.2051;
    min = -0.2051;
    step = (0.2051 - -0.2051) / 100;
    printf("Update Y by: %f\n", step);
  } else if (which == 2) {
    max = 0.3407;
    min = 0.0400;
    step = (0.3407 - 0.0400) / 100;
    printf("Update Z by: %f\n", step);
  } else
    return;
  if ((change == 1) && (xyz_pos[which] < max)) {
    xyz_pos[which] += step;
    if (xyz_pos[which] > max) {
      xyz_pos[which] = max;
    }
  } else if ((change == 0) && (xyz_pos[which] + step > min)) {
    xyz_pos[which] -= step;
    if (xyz_pos[which] < min) {
      xyz_pos[which] = min;
    }
  }
}


x86 assembly (clang, -O0):
<ik_update_xyz>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    0xefb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x3,-0x20(%rbp)
jge    1171 <ik_update_xyz+0x61>
mov    -0x20(%rbp),%esi
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xed4(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1137 <ik_update_xyz+0x27>
cmpl   $0x0,-0xc(%rbp)
jne    11be <ik_update_xyz+0xae>
movss  0xe9d(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xe8c(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xe7b(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe90(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1267 <ik_update_xyz+0x157>
cmpl   $0x1,-0xc(%rbp)
jne    120b <ik_update_xyz+0xfb>
movss  0xe44(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xe33(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xe22(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe54(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1262 <ik_update_xyz+0x152>
cmpl   $0x2,-0xc(%rbp)
jne    1258 <ik_update_xyz+0x148>
movss  0xdeb(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xdda(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xdc9(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe18(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    125d <ik_update_xyz+0x14d>
jmp    1349 <ik_update_xyz+0x239>
jmp    1262 <ik_update_xyz+0x152>
jmp    1267 <ik_update_xyz+0x157>
cmpl   $0x1,-0x10(%rbp)
jne    12d1 <ik_update_xyz+0x1c1>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
movss  -0x18(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    12d1 <ik_update_xyz+0x1c1>
movss  -0x14(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
addss  (%rax,%rcx,4),%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
ucomiss -0x18(%rbp),%xmm0
jbe    12cc <ik_update_xyz+0x1bc>
movss  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
jmp    1349 <ik_update_xyz+0x239>
cmpl   $0x0,-0x10(%rbp)
jne    1344 <ik_update_xyz+0x234>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
addss  -0x14(%rbp),%xmm0
ucomiss -0x1c(%rbp),%xmm0
jbe    1344 <ik_update_xyz+0x234>
movss  -0x14(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
movss  -0x1c(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    133f <ik_update_xyz+0x22f>
movss  -0x1c(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
jmp    1344 <ik_update_xyz+0x234>
jmp    1349 <ik_update_xyz+0x239>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ik_update_xyz>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%rbx
lea    0xf4a(%rip),%rdi
call   1030 <puts@plt>
movss  (%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xef1(%rip),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x4(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x8(%rbx),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
mov    $0x2,%esi
mov    $0x1,%al
call   1040 <printf@plt>
cmp    $0x2,%r15d
je     11d8 <ik_update_xyz+0xb8>
cmp    $0x1,%r15d
je     1233 <ik_update_xyz+0x113>
test   %r15d,%r15d
jne    128d <ik_update_xyz+0x16d>
lea    0xea7(%rip),%rdi
movsd  0xe61(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xe72(%rip),%xmm1
movss  0xe6e(%rip),%xmm2
movss  0xe6a(%rip),%xmm0
test   %r14d,%r14d
jne    120b <ik_update_xyz+0xeb>
jmp    1266 <ik_update_xyz+0x146>
lea    0xe91(%rip),%rdi
movsd  0xe19(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xe22(%rip),%xmm1
movss  0xe1e(%rip),%xmm2
movss  0xe1a(%rip),%xmm0
test   %r14d,%r14d
je     1266 <ik_update_xyz+0x146>
cmp    $0x1,%r14d
jne    128d <ik_update_xyz+0x16d>
mov    %r15d,%eax
movss  (%rbx,%rax,4),%xmm1
ucomiss %xmm1,%xmm2
jbe    128d <ik_update_xyz+0x16d>
addss  %xmm1,%xmm0
movss  %xmm0,(%rbx,%rax,4)
ucomiss %xmm2,%xmm0
jbe    128d <ik_update_xyz+0x16d>
movss  %xmm2,(%rbx,%rax,4)
jmp    128d <ik_update_xyz+0x16d>
lea    0xe25(%rip),%rdi
movsd  0xdc6(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xdd3(%rip),%xmm1
movss  0xdcf(%rip),%xmm2
movss  0xdcb(%rip),%xmm0
test   %r14d,%r14d
jne    120b <ik_update_xyz+0xeb>
mov    %r15d,%eax
movss  (%rbx,%rax,4),%xmm2
movaps %xmm0,%xmm3
addss  %xmm2,%xmm3
ucomiss %xmm1,%xmm3
jbe    128d <ik_update_xyz+0x16d>
subss  %xmm0,%xmm2
movss  %xmm2,(%rbx,%rax,4)
ucomiss %xmm2,%xmm1
jbe    128d <ik_update_xyz+0x16d>
movss  %xmm1,(%rbx,%rax,4)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Update XYZ\0A\00"
@.str.1 = [18 x i8] c"\0A -- xyz[%d] - %f\00"
@.str.2 = [17 x i8] c"Update X by: %f\0A\00"
@.str.3 = [17 x i8] c"Update Y by: %f\0A\00"
@.str.4 = [17 x i8] c"Update Z by: %f\0A\00"
define void @ik_update_xyz(float* %0, i32 %1, i32 %2) {
%4 = alloca float*
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca i32
store float* %0, float** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %10
br label %12
12: ; preds = %24, %3
%13 = load i32, i32* %10
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %27
15: ; preds = %12
%16 = load i32, i32* %10
%17 = load float*, float** %4
%18 = load i32, i32* %10
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds float, float* %17, i64 %19
%21 = load float, float* %20
%22 = fpext float %21 to double
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %16, double %22)
br label %24
24: ; preds = %15
%25 = load i32, i32* %10
%26 = add nsw i32 %25, 1
store i32 %26, i32* %10
br label %12
27: ; preds = %12
%28 = load i32, i32* %5
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %27
store float 0x3FD28F5C20000000, float* %8
store float 0x3FB978D500000000, float* %9
store float 0x3F5F362620000000, float* %7
%31 = load float, float* %7
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double %32)
br label %51
34: ; preds = %27
%35 = load i32, i32* %5
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %41
37: ; preds = %34
store float 0x3FCA40B780000000, float* %8
store float 0xBFCA40B780000000, float* %9
store float 0x3F70CD4240000000, float* %7
%38 = load float, float* %7
%39 = fpext float %38 to double
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double %39)
br label %50
41: ; preds = %34
%42 = load i32, i32* %5
%43 = icmp eq i32 %42, 2
br i1 %43, label %44, label %48
44: ; preds = %41
store float 0x3FD5CE0760000000, float* %8
store float 0x3FA47AE140000000, float* %9
store float 0x3F68A222E0000000, float* %7
%45 = load float, float* %7
%46 = fpext float %45 to double
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %46)
br label %49
48: ; preds = %41
br label %120
49: ; preds = %44
br label %50
50: ; preds = %49, %37
br label %51
51: ; preds = %50, %30
%52 = load i32, i32* %6
%53 = icmp eq i32 %52, 1
br i1 %53, label %54, label %84
54: ; preds = %51
%55 = load float*, float** %4
%56 = load i32, i32* %5
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds float, float* %55, i64 %57
%59 = load float, float* %58
%60 = load float, float* %8
%61 = fcmp olt float %59, %60
br i1 %61, label %62, label %84
62: ; preds = %54
%63 = load float, float* %7
%64 = load float*, float** %4
%65 = load i32, i32* %5
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds float, float* %64, i64 %66
%68 = load float, float* %67
%69 = fadd float %68, %63
store float %69, float* %67
%70 = load float*, float** %4
%71 = load i32, i32* %5
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds float, float* %70, i64 %72
%74 = load float, float* %73
%75 = load float, float* %8
%76 = fcmp ogt float %74, %75
br i1 %76, label %77, label %83
77: ; preds = %62
%78 = load float, float* %8
%79 = load float*, float** %4
%80 = load i32, i32* %5
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds float, float* %79, i64 %81
store float %78, float* %82
br label %83
83: ; preds = %77, %62
br label %120
84: ; preds = %54, %51
%85 = load i32, i32* %6
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %119
87: ; preds = %84
%88 = load float*, float** %4
%89 = load i32, i32* %5
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds float, float* %88, i64 %90
%92 = load float, float* %91
%93 = load float, float* %7
%94 = fadd float %92, %93
%95 = load float, float* %9
%96 = fcmp ogt float %94, %95
br i1 %96, label %97, label %119
97: ; preds = %87
%98 = load float, float* %7
%99 = load float*, float** %4
%100 = load i32, i32* %5
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds float, float* %99, i64 %101
%103 = load float, float* %102
%104 = fsub float %103, %98
store float %104, float* %102
%105 = load float*, float** %4
%106 = load i32, i32* %5
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds float, float* %105, i64 %107
%109 = load float, float* %108
%110 = load float, float* %9
%111 = fcmp olt float %109, %110
br i1 %111, label %112, label %118
112: ; preds = %97
%113 = load float, float* %9
%114 = load float*, float** %4
%115 = load i32, i32* %5
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds float, float* %114, i64 %116
store float %113, float* %117
br label %118
118: ; preds = %112, %97
br label %119
119: ; preds = %118, %87, %84
br label %120
120: ; preds = %48, %119, %83
ret void
}

LLVM IR (-O2):
@.str.1 = [18 x i8] c"\0A -- xyz[%d] - %f\00"
@.str.2 = [17 x i8] c"Update X by: %f\0A\00"
@.str.3 = [17 x i8] c"Update Y by: %f\0A\00"
@.str.4 = [17 x i8] c"Update Z by: %f\0A\00"
@str = [11 x i8] c"Update XYZ\00"
define void @ik_update_xyz(float* nocapture %0, i32 %1, i32 %2) {
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%5 = load float, float* %0
%6 = fpext float %5 to double
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 0, double %6)
%8 = getelementptr inbounds float, float* %0, i64 1
%9 = load float, float* %8
%10 = fpext float %9 to double
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 1, double %10)
%12 = getelementptr inbounds float, float* %0, i64 2
%13 = load float, float* %12
%14 = fpext float %13 to double
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 2, double %14)
switch i32 %1, label %45 [
i32 0, label %16
i32 1, label %18
i32 2, label %20
]
16: ; preds = %3
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double 0x3F5F362620000000)
br label %22
18: ; preds = %3
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), double 0x3F70CD4240000000)
br label %22
20: ; preds = %3
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double 0x3F68A222E0000000)
br label %22
22: ; preds = %18, %20, %16
%23 = phi float [ 0x3F5F362620000000, %16 ], [ 0x3F70CD4240000000, %18 ], [ 0x3F68A222E0000000, %20 ]
%24 = phi float [ 0x3FD28F5C20000000, %16 ], [ 0x3FCA40B780000000, %18 ], [ 0x3FD5CE0760000000, %20 ]
%25 = phi float [ 0x3FB978D500000000, %16 ], [ 0xBFCA40B780000000, %18 ], [ 0x3FA47AE140000000, %20 ]
switch i32 %2, label %45 [
i32 1, label %26
i32 0, label %35
]
26: ; preds = %22
%27 = zext i32 %1 to i64
%28 = getelementptr inbounds float, float* %0, i64 %27
%29 = load float, float* %28
%30 = fcmp olt float %29, %24
br i1 %30, label %31, label %45
31: ; preds = %26
%32 = fadd float %23, %29
store float %32, float* %28
%33 = fcmp ogt float %32, %24
br i1 %33, label %34, label %45
34: ; preds = %31
store float %24, float* %28
br label %45
35: ; preds = %22
%36 = zext i32 %1 to i64
%37 = getelementptr inbounds float, float* %0, i64 %36
%38 = load float, float* %37
%39 = fadd float %23, %38
%40 = fcmp ogt float %39, %25
br i1 %40, label %41, label %45
41: ; preds = %35
%42 = fsub float %38, %23
store float %42, float* %37
%43 = fcmp olt float %42, %25
br i1 %43, label %44, label %45
44: ; preds = %41
store float %25, float* %37
br label %45
45: ; preds = %26, %34, %31, %41, %44, %35, %22, %3
ret void
}