#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 */
typedef float GLfloat;

/* Variables and functions */
int /*<<< orphan*/ GL_TRIANGLE_STRIP;
float cos(double);
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glNormal3f(float, float, double);
int /*<<< orphan*/ glTexCoord2f(int, int);
int /*<<< orphan*/ glVertex3f(float, float, float);
float sin(double);
void drawCylinder(int numMajor, int numMinor, float height, float radius) {
  double majorStep = height / numMajor;
  double minorStep = 2.0 * 3.14159265358979323846 / numMinor;
  int i, j;
  for (i = 0; i < numMajor; ++i) {
    GLfloat z0 = 0.5 * height - i * majorStep;
    GLfloat z1 = z0 - majorStep;
    glBegin(GL_TRIANGLE_STRIP);
    for (j = 0; j <= numMinor; ++j) {
      double a = j * minorStep;
      GLfloat x = radius * cos(a);
      GLfloat y = radius * sin(a);
      glNormal3f(x / radius, y / radius, 0.0);
      glTexCoord2f(j / (GLfloat)numMinor, i / (GLfloat)numMajor);
      glVertex3f(x, y, z0);
      glNormal3f(x / radius, y / radius, 0.0);
      glTexCoord2f(j / (GLfloat)numMinor, (i + 1) / (GLfloat)numMajor);
      glVertex3f(x, y, z1);
    }
    glEnd();
  }
}


x86 assembly (clang, -O0):
<drawCylinder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x4(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe54(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1376 <drawCylinder+0x206>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
mulsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe0e(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x2c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
subsd  -0x18(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x30(%rbp)
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
call   1080 <glBegin@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1361 <drawCylinder+0x1f1>
cvtsi2sdl -0x28(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movss  -0x48(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x44(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movss  -0x44(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x3c(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
movss  -0x40(%rbp),%xmm1
divss  -0x10(%rbp),%xmm1
xorps  %xmm2,%xmm2
call   1090 <glNormal3f@plt>
cvtsi2ssl -0x28(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
cvtsi2ssl -0x24(%rbp),%xmm0
cvtsi2ssl -0x4(%rbp),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%esi
call   1060 <glTexCoord2f@plt>
movss  -0x3c(%rbp),%xmm0
movss  -0x40(%rbp),%xmm1
movss  -0x2c(%rbp),%xmm2
call   1030 <glVertex3f@plt>
movss  -0x3c(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
movss  -0x40(%rbp),%xmm1
divss  -0x10(%rbp),%xmm1
xorps  %xmm2,%xmm2
call   1090 <glNormal3f@plt>
cvtsi2ssl -0x28(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%edi
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cvtsi2ss %eax,%xmm0
cvtsi2ssl -0x4(%rbp),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%esi
call   1060 <glTexCoord2f@plt>
movss  -0x3c(%rbp),%xmm0
movss  -0x40(%rbp),%xmm1
movss  -0x30(%rbp),%xmm2
call   1030 <glVertex3f@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1237 <drawCylinder+0xc7>
mov    $0x0,%al
call   1040 <glEnd@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11bc <drawCylinder+0x4c>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawCylinder>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movss  %xmm1,0xc(%rsp)
mov    %rsi,0x38(%rsp)
mov    %edi,0x8(%rsp)
test   %edi,%edi
jle    1374 <drawCylinder+0x204>
xorps  %xmm1,%xmm1
cvtsi2ssl 0x8(%rsp),%xmm1
cvtss2sd %xmm0,%xmm2
movss  %xmm1,0x1c(%rsp)
divss  %xmm1,%xmm0
movss  %xmm0,0x20(%rsp)
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x40(%rsp)
mov    0x38(%rsp),%rax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xe30(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x50(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  %xmm0,0x24(%rsp)
lea    0x1(%rax),%r13d
mulsd  0xe15(%rip),%xmm2
movsd  %xmm2,0x48(%rsp)
xor    %r14d,%r14d
jmp    1216 <drawCylinder+0xa6>
xchg   %ax,%ax
add    $0x1,%r14d
xor    %eax,%eax
call   1040 <glEnd@plt>
cmp    0x8(%rsp),%r14d
je     1374 <drawCylinder+0x204>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
call   1080 <glBegin@plt>
cmpl   $0x0,0x38(%rsp)
js     1200 <drawCylinder+0x90>
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
mulsd  0x40(%rsp),%xmm0
movsd  0x48(%rsp),%xmm1
subsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
movss  %xmm0,0x2c(%rsp)
movaps %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsi2ss %r14d,%xmm0
subss  0x20(%rsp),%xmm1
movss  %xmm1,0x28(%rsp)
movss  0x1c(%rsp),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%r12d
add    $0x1,%r14d
xorps  %xmm0,%xmm0
cvtsi2ss %r14d,%xmm0
divss  %xmm1,%xmm0
cvttss2si %xmm0,%ebx
xor    %r15d,%r15d
nopl   (%rax)
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
mulsd  0x50(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1070 <cos@plt>
mulss  0xc(%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <sin@plt>
movss  0xc(%rsp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,0x10(%rsp)
movss  0x4(%rsp),%xmm3
divss  %xmm1,%xmm3
movaps %xmm1,%xmm2
movss  %xmm3,0x34(%rsp)
movaps %xmm0,%xmm1
divss  %xmm2,%xmm1
movss  %xmm1,0x30(%rsp)
xorps  %xmm2,%xmm2
movaps %xmm3,%xmm0
call   1090 <glNormal3f@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %r15d,%xmm0
divss  0x24(%rsp),%xmm0
cvttss2si %xmm0,%ebp
mov    %ebp,%edi
mov    %r12d,%esi
call   1060 <glTexCoord2f@plt>
movss  0x4(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
movss  0x2c(%rsp),%xmm2
call   1030 <glVertex3f@plt>
xorps  %xmm2,%xmm2
movss  0x34(%rsp),%xmm0
movss  0x30(%rsp),%xmm1
call   1090 <glNormal3f@plt>
mov    %ebp,%edi
mov    %ebx,%esi
call   1060 <glTexCoord2f@plt>
movss  0x4(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
movss  0x28(%rsp),%xmm2
call   1030 <glVertex3f@plt>
add    $0x1,%r15d
cmp    %r15d,%r13d
jne    1290 <drawCylinder+0x120>
jmp    1204 <drawCylinder+0x94>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@GL_TRIANGLE_STRIP = global i32 0
define void @drawCylinder(i32 %0, i32 %1, float %2, float %3) {
%5 = sitofp i32 %0 to float
%6 = fdiv float %2, %5
%7 = fpext float %6 to double
%8 = sitofp i32 %1 to double
%9 = fdiv double 0x401921FB54442D18, %8
%10 = icmp sgt i32 %0, 0
br i1 %10, label %11, label %60
11: ; preds = %4
%12 = fpext float %2 to double
%13 = icmp slt i32 %1, 0
%14 = sitofp i32 %1 to float
br label %15
15: ; preds = %11, %56
%16 = phi i32 [ 0, %11 ], [ %57, %56 ]
%17 = sitofp i32 %16 to double
%18 = fneg double %17
%19 = fmul double %7, %18
%20 = tail call double @llvm.fmuladd.f64(double %12, double 5.000000e-01, double %19)
%21 = fptrunc double %20 to float
%22 = fsub float %21, %6
%23 = load i32, i32* @GL_TRIANGLE_STRIP
%24 = tail call i32 @glBegin(i32 %23)
br i1 %13, label %25, label %27
25: ; preds = %15
%26 = add nuw nsw i32 %16, 1
br label %56
27: ; preds = %15
%28 = sitofp i32 %16 to float
%29 = fdiv float %28, %5
%30 = fptosi float %29 to i32
%31 = add nuw nsw i32 %16, 1
%32 = sitofp i32 %31 to float
%33 = fdiv float %32, %5
%34 = fptosi float %33 to i32
br label %35
35: ; preds = %27, %35
%36 = phi i32 [ 0, %27 ], [ %54, %35 ]
%37 = sitofp i32 %36 to double
%38 = fmul double %9, %37
%39 = tail call float @cos(double %38)
%40 = fmul float %39, %3
%41 = tail call float @sin(double %38)
%42 = fmul float %41, %3
%43 = fdiv float %40, %3
%44 = fdiv float %42, %3
%45 = tail call i32 @glNormal3f(float %43, float %44, double 0.000000e+00)
%46 = sitofp i32 %36 to float
%47 = fdiv float %46, %14
%48 = fptosi float %47 to i32
%49 = tail call i32 @glTexCoord2f(i32 %48, i32 %30)
%50 = tail call i32 @glVertex3f(float %40, float %42, float %21)
%51 = tail call i32 @glNormal3f(float %43, float %44, double 0.000000e+00)
%52 = tail call i32 @glTexCoord2f(i32 %48, i32 %34)
%53 = tail call i32 @glVertex3f(float %40, float %42, float %22)
%54 = add nuw i32 %36, 1
%55 = icmp eq i32 %36, %1
br i1 %55, label %56, label %35
56: ; preds = %35, %25
%57 = phi i32 [ %26, %25 ], [ %31, %35 ]
%58 = tail call i32 (...) @glEnd()
%59 = icmp eq i32 %57, %0
br i1 %59, label %60, label %15
60: ; preds = %56, %4
ret void
}