#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*/ cyl(float, float, float, int);
int /*<<< orphan*/ end();
int /*<<< orphan*/ xlate(int /*<<< orphan*/, int /*<<< orphan*/, float);
void cylinder_rings(float length, float r1, float r2, int nrings) {
  int i;
  float ringspacing = length / (nrings + 1);
  float ringheight = ringspacing / 3.0;
  float z, dz, r, dr;
  z = -(ringspacing * nrings) / 2;
  dz = ringspacing;
  r = r1 * 1.3;
  dr = ((r2 * 1.3) - r) / nrings;
  for (i = 0; i < nrings; i++) {
    xlate(0, 0, z);
    cyl(ringheight, r, r, 1);
    z += dz;
    r += dr;
    end();
  }
}


x86 assembly (clang, -O0):
<cylinder_rings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
movss  -0x4(%rbp),%xmm0
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe95(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
mulss  %xmm1,%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  0xe6d(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe39(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x28(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xdfb(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    128c <cylinder_rings+0x15c>
movss  -0x20(%rbp),%xmm0
xor    %esi,%esi
mov    %esi,%edi
call   1030 <xlate@plt>
movss  -0x1c(%rbp),%xmm0
movss  -0x28(%rbp),%xmm1
movss  -0x28(%rbp),%xmm2
mov    $0x1,%edi
call   1050 <cyl@plt>
movss  -0x24(%rbp),%xmm0
addss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x2c(%rbp),%xmm0
addss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
mov    $0x0,%al
call   1040 <end@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1226 <cylinder_rings+0xf6>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cylinder_rings>:
push   %rbx
sub    $0x20,%rsp
test   %edi,%edi
jle    1229 <cylinder_rings+0xf9>
mov    %edi,%ebx
lea    0x1(%rbx),%eax
cvtsi2ss %eax,%xmm3
movaps %xmm0,%xmm4
divss  %xmm3,%xmm4
movaps %xmm4,%xmm0
divss  0xea8(%rip),%xmm0
movss  %xmm0,0x18(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movsd  0xe9b(%rip),%xmm1
mulsd  %xmm1,%xmm0
xorps  %xmm3,%xmm3
cvtsd2ss %xmm0,%xmm3
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
movss  %xmm3,0x10(%rsp)
xorps  %xmm2,%xmm2
cvtss2sd %xmm3,%xmm2
mulsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %edi,%xmm1
subsd  %xmm2,%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x14(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %edi,%xmm0
movss  %xmm4,0x1c(%rsp)
mulss  %xmm4,%xmm0
mulss  0xe42(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
xor    %esi,%esi
movss  0xc(%rsp),%xmm0
call   1030 <xlate@plt>
movss  0x18(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
movapd %xmm1,%xmm2
mov    $0x1,%edi
call   1050 <cyl@plt>
movss  0xc(%rsp),%xmm0
addss  0x1c(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x10(%rsp),%xmm0
addss  0x14(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1040 <end@plt>
add    $0xffffffff,%ebx
jne    11d0 <cylinder_rings+0xa0>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @cylinder_rings(float %0, float %1, float %2, i32 %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca i32
%9 = alloca i32
%10 = alloca float
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
store i32 %3, i32* %8
%16 = load float, float* %5
%17 = load i32, i32* %8
%18 = add nsw i32 %17, 1
%19 = sitofp i32 %18 to float
%20 = fdiv float %16, %19
store float %20, float* %10
%21 = load float, float* %10
%22 = fpext float %21 to double
%23 = fdiv double %22, 3.000000e+00
%24 = fptrunc double %23 to float
store float %24, float* %11
%25 = load float, float* %10
%26 = load i32, i32* %8
%27 = sitofp i32 %26 to float
%28 = fmul float %25, %27
%29 = fneg float %28
%30 = fdiv float %29, 2.000000e+00
store float %30, float* %12
%31 = load float, float* %10
store float %31, float* %13
%32 = load float, float* %6
%33 = fpext float %32 to double
%34 = fmul double %33, 1.300000e+00
%35 = fptrunc double %34 to float
store float %35, float* %14
%36 = load float, float* %7
%37 = fpext float %36 to double
%38 = load float, float* %14
%39 = fpext float %38 to double
%40 = fneg double %39
%41 = call double @llvm.fmuladd.f64(double %37, double 1.300000e+00, double %40)
%42 = load i32, i32* %8
%43 = sitofp i32 %42 to double
%44 = fdiv double %41, %43
%45 = fptrunc double %44 to float
store float %45, float* %15
store i32 0, i32* %9
br label %46
46: ; preds = %64, %4
%47 = load i32, i32* %9
%48 = load i32, i32* %8
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %67
50: ; preds = %46
%51 = load float, float* %12
%52 = call i32 @xlate(i32 0, i32 0, float %51)
%53 = load float, float* %11
%54 = load float, float* %14
%55 = load float, float* %14
%56 = call i32 @cyl(float %53, float %54, float %55, i32 1)
%57 = load float, float* %13
%58 = load float, float* %12
%59 = fadd float %58, %57
store float %59, float* %12
%60 = load float, float* %15
%61 = load float, float* %14
%62 = fadd float %61, %60
store float %62, float* %14
%63 = call i32 (...) @end()
br label %64
64: ; preds = %50
%65 = load i32, i32* %9
%66 = add nsw i32 %65, 1
store i32 %66, i32* %9
br label %46
67: ; preds = %46
ret void
}

LLVM IR (-O2):
define void @cylinder_rings(float %0, float %1, float %2, i32 %3) {
%5 = add nsw i32 %3, 1
%6 = sitofp i32 %5 to float
%7 = fdiv float %0, %6
%8 = fdiv float %7, 3.000000e+00
%9 = fpext float %1 to double
%10 = fmul double %9, 1.300000e+00
%11 = fptrunc double %10 to float
%12 = fpext float %2 to double
%13 = fpext float %11 to double
%14 = fneg double %13
%15 = tail call double @llvm.fmuladd.f64(double %12, double 1.300000e+00, double %14)
%16 = sitofp i32 %3 to double
%17 = fdiv double %15, %16
%18 = fptrunc double %17 to float
%19 = icmp sgt i32 %3, 0
br i1 %19, label %20, label %36
20: ; preds = %4
%21 = sitofp i32 %3 to float
%22 = fneg float %7
%23 = fmul float %21, %22
%24 = fmul float %23, 5.000000e-01
br label %25
25: ; preds = %20, %25
%26 = phi i32 [ %34, %25 ], [ 0, %20 ]
%27 = phi float [ %32, %25 ], [ %11, %20 ]
%28 = phi float [ %31, %25 ], [ %24, %20 ]
%29 = tail call i32 @xlate(i32 0, i32 0, float %28)
%30 = tail call i32 @cyl(float %8, float %27, float %27, i32 1)
%31 = fadd float %7, %28
%32 = fadd float %27, %18
%33 = tail call i32 (...) @end()
%34 = add nuw nsw i32 %26, 1
%35 = icmp eq i32 %34, %3
br i1 %35, label %36, label %25
36: ; preds = %25, %4
ret void
}