#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 cos(float);
int /*<<< orphan*/ quad(float, double, float, float, double, float, float,
                        float, float, float, float, float);
float sin(float);
void y_cylinder(float r, float h, int detail) {
  for (int j = 0; j < detail; ++j) {
    float p = 2.0 * 3.14159265358979323846 * (float)j / (float)detail;
    float q = 2.0 * 3.14159265358979323846 * (float)(j + 1) / (float)detail;
    quad(r * cos(p), 0.0, r * sin(p), r * cos(q), 0.0, r * sin(q), r * cos(q),
         h, r * sin(q), r * cos(p), h, r * sin(p));
  }
}


x86 assembly (clang, -O0):
<y_cylinder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1353 <y_cylinder+0x223>
cvtsi2ssl -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe94(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe64(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x5c(%rbp)
movss  -0x14(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movss  -0x5c(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x58(%rbp)
movss  -0x14(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movss  -0x58(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x54(%rbp)
movss  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movss  -0x54(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x38(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x50(%rbp)
movss  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movss  -0x50(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4c(%rbp)
movss  -0x18(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movss  -0x4c(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
movss  -0x18(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movss  -0x48(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x44(%rbp)
movss  -0x14(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movss  -0x44(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x14(%rbp),%xmm0
call   1040 <sin@plt>
movss  -0x40(%rbp),%xmm8
movss  -0x3c(%rbp),%xmm2
movss  -0x38(%rbp),%xmm3
movss  -0x34(%rbp),%xmm5
movss  -0x30(%rbp),%xmm6
movss  -0x2c(%rbp),%xmm7
movss  -0x28(%rbp),%xmm11
movss  -0x24(%rbp),%xmm10
movss  -0x20(%rbp),%xmm9
movaps %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
mulss  %xmm1,%xmm8
xorps  %xmm4,%xmm4
movaps %xmm4,%xmm1
movss  %xmm11,(%rsp)
movss  %xmm10,0x8(%rsp)
movss  %xmm9,0x10(%rsp)
movss  %xmm8,0x18(%rsp)
call   1030 <quad@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114f <y_cylinder+0x1f>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<y_cylinder>:
push   %rbp
push   %rbx
sub    $0x58,%rsp
movss  %xmm1,0x34(%rsp)
movss  %xmm0,0x28(%rsp)
test   %edi,%edi
jle    12b4 <y_cylinder+0x184>
mov    %edi,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %edi,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x50(%rsp)
xor    %ebp,%ebp
nop
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe8d(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  0x50(%rsp),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x30(%rsp)
add    $0x1,%ebp
xorps  %xmm3,%xmm3
cvtsi2ss %ebp,%xmm3
cvtss2sd %xmm3,%xmm3
mulsd  %xmm2,%xmm3
divsd  %xmm1,%xmm3
xorps  %xmm1,%xmm1
cvtsd2ss %xmm3,%xmm1
movss  %xmm1,0x2c(%rsp)
call   1050 <cos@plt>
mulss  0x28(%rsp),%xmm0
movss  %xmm0,0x4c(%rsp)
movss  0x30(%rsp),%xmm0
call   1040 <sin@plt>
mulss  0x28(%rsp),%xmm0
movss  %xmm0,0x48(%rsp)
movss  0x2c(%rsp),%xmm0
call   1050 <cos@plt>
mulss  0x28(%rsp),%xmm0
movss  %xmm0,0x44(%rsp)
movss  0x2c(%rsp),%xmm0
call   1040 <sin@plt>
mulss  0x28(%rsp),%xmm0
movss  %xmm0,0x40(%rsp)
movss  0x2c(%rsp),%xmm0
call   1050 <cos@plt>
mulss  0x28(%rsp),%xmm0
movss  %xmm0,0x3c(%rsp)
movss  0x2c(%rsp),%xmm0
call   1040 <sin@plt>
mulss  0x28(%rsp),%xmm0
movss  %xmm0,0x2c(%rsp)
movss  0x30(%rsp),%xmm0
call   1050 <cos@plt>
mulss  0x28(%rsp),%xmm0
movss  %xmm0,0x38(%rsp)
movss  0x30(%rsp),%xmm0
call   1040 <sin@plt>
mulss  0x28(%rsp),%xmm0
movss  %xmm0,0x18(%rsp)
movss  0x34(%rsp),%xmm7
movss  %xmm7,0x10(%rsp)
movss  0x38(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
movss  0x2c(%rsp),%xmm0
movss  %xmm0,(%rsp)
xorps  %xmm1,%xmm1
xorps  %xmm4,%xmm4
movss  0x4c(%rsp),%xmm0
movss  0x48(%rsp),%xmm2
movss  0x44(%rsp),%xmm3
movss  0x40(%rsp),%xmm5
movss  0x3c(%rsp),%xmm6
call   1030 <quad@plt>
cmp    %ebp,%ebx
jne    1160 <y_cylinder+0x30>
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define void @y_cylinder(float %0, float %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = sitofp i32 %2 to float
%7 = fpext float %6 to double
br label %9
8: ; preds = %9, %3
ret void
9: ; preds = %5, %9
%10 = phi i32 [ 0, %5 ], [ %16, %9 ]
%11 = sitofp i32 %10 to float
%12 = fpext float %11 to double
%13 = fmul double %12, 0x401921FB54442D18
%14 = fdiv double %13, %7
%15 = fptrunc double %14 to float
%16 = add nuw nsw i32 %10, 1
%17 = sitofp i32 %16 to float
%18 = fpext float %17 to double
%19 = fmul double %18, 0x401921FB54442D18
%20 = fdiv double %19, %7
%21 = fptrunc double %20 to float
%22 = tail call float @cos(float %15)
%23 = fmul float %22, %0
%24 = tail call float @sin(float %15)
%25 = fmul float %24, %0
%26 = tail call float @cos(float %21)
%27 = fmul float %26, %0
%28 = tail call float @sin(float %21)
%29 = fmul float %28, %0
%30 = tail call float @cos(float %21)
%31 = fmul float %30, %0
%32 = tail call float @sin(float %21)
%33 = fmul float %32, %0
%34 = tail call float @cos(float %15)
%35 = fmul float %34, %0
%36 = tail call float @sin(float %15)
%37 = fmul float %36, %0
%38 = tail call i32 @quad(float %23, double 0.000000e+00, float %25, float %27, double 0.000000e+00, float %29, float %31, float %1, float %33, float %35, float %1, float %37)
%39 = icmp eq i32 %16, %2
br i1 %39, label %8, label %9
}