#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 */
float M_PI;
float cos(float);
int /*<<< orphan*/ cylinder(float, float, float);
int /*<<< orphan*/ endonion();
int /*<<< orphan*/ endrotate();
int /*<<< orphan*/ endxlate();
int /*<<< orphan*/ onion();
int /*<<< orphan*/ rotate(int, int /*<<< orphan*/, int, int);
float sin(float);
int /*<<< orphan*/ sphere(float);
int /*<<< orphan*/ xlate(float, float, float);
void finger(float length, float angle, int segments, float thickness,
            float taper, float curl, int kink) {
  float len = length / (float)segments;
  float a = angle;
  float curve = 1.0;
  float diam = thickness;
  float x, y;
  int i;
  onion();
  x = 0;
  y = 0;
  for (i = 0; i < segments; i++) {
    xlate(x, y, 0);
    rotate(a, 0, 0, 1);
    rotate(90, 0, 1, 0);
    xlate(0, 0, 0);
    sphere(diam * 1.1);
    endxlate();
    xlate(0, 0, len);
    sphere(diam * 1.1);
    endxlate();
    cylinder(len * 1.05, diam, diam * taper);
    endrotate();
    endrotate();
    endxlate();
    x = x + cos(a * M_PI / 180.0) * len;
    y = y + sin(a * M_PI / 180.0) * len;
    if (kink && i == segments / 2)
      a = a + curve * 10;
    else
      a = a + curve;
    curve = curve * curl;
    diam = diam * taper;
  }
  endonion();
}


x86 assembly (clang, -O0):
<finger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  %xmm3,-0x14(%rbp)
movss  %xmm4,-0x18(%rbp)
mov    %esi,-0x1c(%rbp)
movss  -0x4(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  0xe14(%rip),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    $0x0,%al
call   1050 <onion@plt>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1422 <finger+0x282>
movss  -0x30(%rbp),%xmm0
movss  -0x34(%rbp),%xmm1
xorps  %xmm2,%xmm2
call   1040 <xlate@plt>
cvttss2si -0x24(%rbp),%edi
xor    %edx,%edx
mov    $0x1,%ecx
mov    %edx,%esi
call   1070 <rotate@plt>
mov    $0x5a,%edi
xor    %ecx,%ecx
mov    $0x1,%edx
mov    %ecx,%esi
call   1070 <rotate@plt>
xorps  %xmm2,%xmm2
movaps %xmm2,%xmm0
movaps %xmm2,%xmm1
call   1040 <xlate@plt>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd9c(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   10c0 <sphere@plt>
mov    $0x0,%al
call   1090 <endxlate@plt>
movss  -0x20(%rbp),%xmm2
xorps  %xmm1,%xmm1
movaps %xmm1,%xmm0
call   1040 <xlate@plt>
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd67(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   10c0 <sphere@plt>
mov    $0x0,%al
call   1090 <endxlate@plt>
movss  -0x20(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd3a(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  -0x2c(%rbp),%xmm1
movss  -0x2c(%rbp),%xmm2
mulss  -0x14(%rbp),%xmm2
call   1030 <cylinder@plt>
mov    $0x0,%al
call   1080 <endrotate@plt>
mov    $0x0,%al
call   1080 <endrotate@plt>
mov    $0x0,%al
call   1090 <endxlate@plt>
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x24(%rbp),%xmm0
mov    0x2ccb(%rip),%rax
mulss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xcdb(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   10b0 <cos@plt>
movss  -0x40(%rbp),%xmm1
movss  -0x20(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x24(%rbp),%xmm0
mov    0x2c81(%rip),%rax
mulss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xc91(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1060 <sin@plt>
movss  -0x3c(%rbp),%xmm1
movss  -0x20(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x34(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     13e7 <finger+0x247>
mov    -0x38(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
cmp    %ecx,%eax
jne    13e7 <finger+0x247>
movss  -0x24(%rbp),%xmm1
movss  -0x28(%rbp),%xmm0
movss  0xc2f(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
jmp    13f6 <finger+0x256>
movss  -0x24(%rbp),%xmm0
addss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x28(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x2c(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1219 <finger+0x79>
mov    $0x0,%al
call   10a0 <endonion@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<finger>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x60,%rsp
mov    %esi,%r14d
movss  %xmm4,0x14(%rsp)
movss  %xmm3,0x10(%rsp)
movss  %xmm2,0x8(%rsp)
mov    %edi,%r15d
movss  %xmm1,0x4(%rsp)
movaps %xmm0,0x30(%rsp)
xor    %eax,%eax
call   1050 <onion@plt>
test   %r15d,%r15d
jle    13cf <finger+0x22f>
xorps  %xmm0,%xmm0
cvtsi2ss %r15d,%xmm0
movaps 0x30(%rsp),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mulsd  0xe01(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
mov    %r15d,%ebp
shr    %ebp
movaps %xmm1,0x30(%rsp)
shufps $0x0,%xmm1,%xmm1
movaps %xmm1,0x50(%rsp)
xorps  %xmm1,%xmm1
movss  0xde9(%rip),%xmm5
mov    0x2dba(%rip),%r12
xor    %ebx,%ebx
jmp    1263 <finger+0xc3>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movss  %xmm3,0x4(%rsp)
unpcklps %xmm2,%xmm0
mulps  0x50(%rsp),%xmm0
addps  %xmm0,%xmm1
mulss  0x14(%rsp),%xmm5
add    $0x1,%ebx
cmp    %ebx,%r15d
je     13cf <finger+0x22f>
movss  %xmm5,0x1c(%rsp)
movss  0x8(%rsp),%xmm0
movss  %xmm0,0x20(%rsp)
movaps %xmm1,%xmm0
shufps $0x55,%xmm1,%xmm0
xorps  %xmm2,%xmm2
movaps %xmm1,0x40(%rsp)
call   1040 <xlate@plt>
cvttss2si 0x4(%rsp),%edi
xor    %esi,%esi
xor    %edx,%edx
mov    $0x1,%ecx
call   1070 <rotate@plt>
mov    $0x5a,%edi
xor    %esi,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1070 <rotate@plt>
xorps  %xmm0,%xmm0
xorps  %xmm1,%xmm1
xorps  %xmm2,%xmm2
call   1040 <xlate@plt>
movss  0x20(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xd38(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x18(%rsp)
call   10c0 <sphere@plt>
xor    %eax,%eax
call   1090 <endxlate@plt>
xorps  %xmm0,%xmm0
xorps  %xmm1,%xmm1
movaps 0x30(%rsp),%xmm2
call   1040 <xlate@plt>
movss  0x18(%rsp),%xmm0
call   10c0 <sphere@plt>
xor    %eax,%eax
call   1090 <endxlate@plt>
movss  0x8(%rsp),%xmm2
mulss  0x10(%rsp),%xmm2
movss  0xc(%rsp),%xmm0
movss  0x20(%rsp),%xmm1
movss  %xmm2,0x8(%rsp)
call   1030 <cylinder@plt>
xor    %eax,%eax
call   1080 <endrotate@plt>
xor    %eax,%eax
call   1080 <endrotate@plt>
xor    %eax,%eax
call   1090 <endxlate@plt>
movss  (%r12),%xmm0
mulss  0x4(%rsp),%xmm0
movss  0xcc0(%rip),%xmm1
divss  %xmm1,%xmm0
call   10b0 <cos@plt>
movaps %xmm0,0x20(%rsp)
movss  (%r12),%xmm0
mulss  0x4(%rsp),%xmm0
divss  0xc9e(%rip),%xmm0
call   1060 <sin@plt>
movss  0x1c(%rsp),%xmm5
movss  0x4(%rsp),%xmm3
movaps %xmm5,%xmm2
mulss  0xc86(%rip),%xmm2
movaps %xmm3,%xmm4
addss  %xmm5,%xmm4
cmp    %ebx,%ebp
je     13b0 <finger+0x210>
movaps %xmm4,%xmm3
jmp    13b4 <finger+0x214>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
addss  %xmm2,%xmm3
movaps 0x40(%rsp),%xmm1
movaps 0x20(%rsp),%xmm2
test   %r14d,%r14d
jne    1240 <finger+0xa0>
movaps %xmm4,%xmm3
jmp    1240 <finger+0xa0>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <endonion@plt>

LLVM IR (-O0):
@M_PI = global float 0.000000e+00
define void @finger(float %0, float %1, i32 %2, float %3, float %4, float %5, i32 %6) {
%8 = alloca float
%9 = alloca float
%10 = alloca i32
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca i32
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca float
%21 = alloca i32
store float %0, float* %8
store float %1, float* %9
store i32 %2, i32* %10
store float %3, float* %11
store float %4, float* %12
store float %5, float* %13
store i32 %6, i32* %14
%22 = load float, float* %8
%23 = load i32, i32* %10
%24 = sitofp i32 %23 to float
%25 = fdiv float %22, %24
store float %25, float* %15
%26 = load float, float* %9
store float %26, float* %16
store float 1.000000e+00, float* %17
%27 = load float, float* %11
store float %27, float* %18
%28 = call i32 (...) @onion()
store float 0.000000e+00, float* %19
store float 0.000000e+00, float* %20
store i32 0, i32* %21
br label %29
29: ; preds = %110, %7
%30 = load i32, i32* %21
%31 = load i32, i32* %10
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %113
33: ; preds = %29
%34 = load float, float* %19
%35 = load float, float* %20
%36 = call i32 @xlate(float %34, float %35, float 0.000000e+00)
%37 = load float, float* %16
%38 = fptosi float %37 to i32
%39 = call i32 @rotate(i32 %38, i32 0, i32 0, i32 1)
%40 = call i32 @rotate(i32 90, i32 0, i32 1, i32 0)
%41 = call i32 @xlate(float 0.000000e+00, float 0.000000e+00, float 0.000000e+00)
%42 = load float, float* %18
%43 = fpext float %42 to double
%44 = fmul double %43, 1.100000e+00
%45 = fptrunc double %44 to float
%46 = call i32 @sphere(float %45)
%47 = call i32 (...) @endxlate()
%48 = load float, float* %15
%49 = call i32 @xlate(float 0.000000e+00, float 0.000000e+00, float %48)
%50 = load float, float* %18
%51 = fpext float %50 to double
%52 = fmul double %51, 1.100000e+00
%53 = fptrunc double %52 to float
%54 = call i32 @sphere(float %53)
%55 = call i32 (...) @endxlate()
%56 = load float, float* %15
%57 = fpext float %56 to double
%58 = fmul double %57, 1.050000e+00
%59 = fptrunc double %58 to float
%60 = load float, float* %18
%61 = load float, float* %18
%62 = load float, float* %12
%63 = fmul float %61, %62
%64 = call i32 @cylinder(float %59, float %60, float %63)
%65 = call i32 (...) @endrotate()
%66 = call i32 (...) @endrotate()
%67 = call i32 (...) @endxlate()
%68 = load float, float* %19
%69 = load float, float* %16
%70 = load float, float* @M_PI
%71 = fmul float %69, %70
%72 = fpext float %71 to double
%73 = fdiv double %72, 1.800000e+02
%74 = fptrunc double %73 to float
%75 = call float @cos(float %74)
%76 = load float, float* %15
%77 = call float @llvm.fmuladd.f32(float %75, float %76, float %68)
store float %77, float* %19
%78 = load float, float* %20
%79 = load float, float* %16
%80 = load float, float* @M_PI
%81 = fmul float %79, %80
%82 = fpext float %81 to double
%83 = fdiv double %82, 1.800000e+02
%84 = fptrunc double %83 to float
%85 = call float @sin(float %84)
%86 = load float, float* %15
%87 = call float @llvm.fmuladd.f32(float %85, float %86, float %78)
store float %87, float* %20
%88 = load i32, i32* %14
%89 = icmp ne i32 %88, 0
br i1 %89, label %90, label %99
90: ; preds = %33
%91 = load i32, i32* %21
%92 = load i32, i32* %10
%93 = sdiv i32 %92, 2
%94 = icmp eq i32 %91, %93
br i1 %94, label %95, label %99
95: ; preds = %90
%96 = load float, float* %16
%97 = load float, float* %17
%98 = call float @llvm.fmuladd.f32(float %97, float 1.000000e+01, float %96)
store float %98, float* %16
br label %103
99: ; preds = %90, %33
%100 = load float, float* %16
%101 = load float, float* %17
%102 = fadd float %100, %101
store float %102, float* %16
br label %103
103: ; preds = %99, %95
%104 = load float, float* %17
%105 = load float, float* %13
%106 = fmul float %104, %105
store float %106, float* %17
%107 = load float, float* %18
%108 = load float, float* %12
%109 = fmul float %107, %108
store float %109, float* %18
br label %110
110: ; preds = %103
%111 = load i32, i32* %21
%112 = add nsw i32 %111, 1
store i32 %112, i32* %21
br label %29
113: ; preds = %29
%114 = call i32 (...) @endonion()
ret void
}

LLVM IR (-O2):
@M_PI = global float 0.000000e+00
define void @finger(float %0, float %1, i32 %2, float %3, float %4, float %5, i32 %6) {
%8 = sitofp i32 %2 to float
%9 = fdiv float %0, %8
%10 = tail call i32 (...) @onion()
%11 = icmp sgt i32 %2, 0
br i1 %11, label %12, label %65
12: ; preds = %7
%13 = fpext float %9 to double
%14 = fmul double %13, 1.050000e+00
%15 = fptrunc double %14 to float
%16 = icmp ne i32 %6, 0
%17 = lshr i32 %2, 1
%18 = insertelement <2 x float> poison, float %9, i64 0
%19 = shufflevector <2 x float> %18, <2 x float> poison, <2 x i32> zeroinitializer
br label %20
20: ; preds = %12, %20
%21 = phi i32 [ 0, %12 ], [ %63, %20 ]
%22 = phi float [ %3, %12 ], [ %41, %20 ]
%23 = phi float [ 1.000000e+00, %12 ], [ %62, %20 ]
%24 = phi float [ %1, %12 ], [ %61, %20 ]
%25 = phi <2 x float> [ zeroinitializer, %12 ], [ %56, %20 ]
%26 = extractelement <2 x float> %25, i64 0
%27 = extractelement <2 x float> %25, i64 1
%28 = tail call i32 @xlate(float %27, float %26, float 0.000000e+00)
%29 = fptosi float %24 to i32
%30 = tail call i32 @rotate(i32 %29, i32 0, i32 0, i32 1)
%31 = tail call i32 @rotate(i32 90, i32 0, i32 1, i32 0)
%32 = tail call i32 @xlate(float 0.000000e+00, float 0.000000e+00, float 0.000000e+00)
%33 = fpext float %22 to double
%34 = fmul double %33, 1.100000e+00
%35 = fptrunc double %34 to float
%36 = tail call i32 @sphere(float %35)
%37 = tail call i32 (...) @endxlate()
%38 = tail call i32 @xlate(float 0.000000e+00, float 0.000000e+00, float %9)
%39 = tail call i32 @sphere(float %35)
%40 = tail call i32 (...) @endxlate()
%41 = fmul float %22, %4
%42 = tail call i32 @cylinder(float %15, float %22, float %41)
%43 = tail call i32 (...) @endrotate()
%44 = tail call i32 (...) @endrotate()
%45 = tail call i32 (...) @endxlate()
%46 = load float, float* @M_PI
%47 = fmul float %24, %46
%48 = fdiv float %47, 1.800000e+02
%49 = tail call float @cos(float %48)
%50 = load float, float* @M_PI
%51 = fmul float %24, %50
%52 = fdiv float %51, 1.800000e+02
%53 = tail call float @sin(float %52)
%54 = insertelement <2 x float> poison, float %53, i64 0
%55 = insertelement <2 x float> %54, float %49, i64 1
%56 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %55, <2 x float> %19, <2 x float> %25)
%57 = icmp eq i32 %21, %17
%58 = select i1 %16, i1 %57, i1 false
%59 = tail call float @llvm.fmuladd.f32(float %23, float 1.000000e+01, float %24)
%60 = fadd float %24, %23
%61 = select i1 %58, float %59, float %60
%62 = fmul float %23, %5
%63 = add nuw nsw i32 %21, 1
%64 = icmp eq i32 %63, %2
br i1 %64, label %65, label %20
65: ; preds = %20, %7
%66 = tail call i32 (...) @endonion()
ret void
}