#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 double GLfloat;

/* Variables and functions */
int /*<<< orphan*/ GL_TRIANGLE_STRIP;
float cos(double);
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glColor3f(double, double, double);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glNormal3f(double, double, double);
int /*<<< orphan*/ glTexCoord2f(int, int);
int /*<<< orphan*/ glVertex3f(double, double, double);
float sin(double);
void drawSphere(void) {
  int numMajor = 24;
  int numMinor = 32;
  float radius = 0.8;
  double majorStep = (3.14159265358979323846 / numMajor);
  double minorStep = (2.0 * 3.14159265358979323846 / numMinor);
  int i, j;
  glColor3f(0.50, 0.50, 0.50);
  for (i = 0; i < numMajor; ++i) {
    double a = i * majorStep;
    double b = a + majorStep;
    double r0 = radius * sin(a);
    double r1 = radius * sin(b);
    GLfloat z0 = radius * cos(a);
    GLfloat z1 = radius * cos(b);
    glBegin(GL_TRIANGLE_STRIP);
    for (j = 0; j <= numMinor; ++j) {
      double c = j * minorStep;
      GLfloat x = cos(c);
      GLfloat y = sin(c);
      glNormal3f((x * r0) / radius, (y * r0) / radius, z0 / radius);
      glTexCoord2f(j / (GLfloat)numMinor, i / (GLfloat)numMajor);
      glVertex3f(x * r0, y * r0, z0);
      glNormal3f((x * r1) / radius, (y * r1) / radius, z1 / radius);
      glTexCoord2f(j / (GLfloat)numMinor, (i + 1) / (GLfloat)numMajor);
      glVertex3f(x * r1, y * r1, z1);
    }
    glEnd();
  }
}


x86 assembly (clang, -O0):
<drawSphere>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x18,-0x4(%rbp)
movl   $0x20,-0x8(%rbp)
movss  0xe77(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xe5d(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe3f(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe26(%rip),%xmm2
movaps %xmm2,%xmm0
movaps %xmm2,%xmm1
call   1060 <glColor3f@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1450 <drawSphere+0x2d0>
cvtsi2sdl -0x24(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x80(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movss  -0x80(%rbp),%xmm0
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x7c(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movss  -0x7c(%rbp),%xmm0
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x78(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1080 <cos@plt>
movaps %xmm0,%xmm1
movss  -0x78(%rbp),%xmm0
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x74(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1080 <cos@plt>
movaps %xmm0,%xmm1
movss  -0x74(%rbp),%xmm0
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    0x2d37(%rip),%rax
mov    (%rax),%edi
call   1090 <glBegin@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     143b <drawSphere+0x2bb>
cvtsi2sdl -0x28(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
call   1080 <cos@plt>
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
call   1050 <sin@plt>
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x68(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
movsd  -0x70(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
movss  -0xc(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
divsd  %xmm2,%xmm1
movsd  -0x50(%rbp),%xmm2
movss  -0xc(%rbp),%xmm3
cvtss2sd %xmm3,%xmm3
divsd  %xmm3,%xmm2
call   10a0 <glNormal3f@plt>
cvtsi2sdl -0x28(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
cvtsi2sdl -0x24(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
call   1070 <glTexCoord2f@plt>
movsd  -0x68(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
mulsd  -0x40(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
call   1030 <glVertex3f@plt>
movsd  -0x68(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
movsd  -0x70(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movss  -0xc(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
divsd  %xmm2,%xmm1
movsd  -0x58(%rbp),%xmm2
movss  -0xc(%rbp),%xmm3
cvtss2sd %xmm3,%xmm3
divsd  %xmm3,%xmm2
call   10a0 <glNormal3f@plt>
cvtsi2sdl -0x28(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
call   1070 <glTexCoord2f@plt>
movsd  -0x68(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
mulsd  -0x48(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
call   1030 <glVertex3f@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    12cf <drawSphere+0x14f>
mov    $0x0,%al
call   1040 <glEnd@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ec <drawSphere+0x6c>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawSphere>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
movsd  0xe6a(%rip),%xmm0
movapd %xmm0,%xmm1
movapd %xmm0,%xmm2
call   1060 <glColor3f@plt>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
mov    0x2e44(%rip),%r15
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
movsd  0x18(%rsp),%xmm2
movsd  0xe3a(%rip),%xmm0
mulsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
movapd %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movapd %xmm2,%xmm0
call   1050 <sin@plt>
movss  0xe41(%rip),%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x50(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <sin@plt>
mulss  0xe20(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x48(%rsp)
movsd  0x8(%rsp),%xmm0
call   1080 <cos@plt>
mulss  0xe03(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  0x10(%rsp),%xmm0
call   1080 <cos@plt>
mulss  0xde6(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x20(%rsp)
mov    (%r15),%edi
call   1090 <glBegin@plt>
movsd  0x28(%rsp),%xmm1
movsd  0xd9e(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  %xmm1,0x40(%rsp)
movsd  0x18(%rsp),%xmm3
movapd %xmm3,%xmm0
movsd  0xd8a(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%r14d
movsd  0x20(%rsp),%xmm0
divsd  %xmm2,%xmm0
movsd  %xmm0,0x38(%rsp)
movsd  0xd71(%rip),%xmm0
addsd  %xmm0,%xmm3
movsd  %xmm3,0x18(%rsp)
add    $0x1,%r12d
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%r13d
mov    $0x21,%ebp
xorpd  %xmm1,%xmm1
nopw   0x0(%rax,%rax,1)
movsd  %xmm1,0x30(%rsp)
movapd %xmm1,%xmm0
mulsd  0xd36(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1080 <cos@plt>
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <sin@plt>
xorps  %xmm3,%xmm3
cvtss2sd %xmm0,%xmm3
movsd  %xmm3,0x8(%rsp)
movsd  0x50(%rsp),%xmm1
movapd %xmm1,%xmm0
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x60(%rsp)
movsd  0xcd3(%rip),%xmm2
divsd  %xmm2,%xmm0
mulsd  %xmm3,%xmm1
movsd  %xmm1,0x58(%rsp)
divsd  %xmm2,%xmm1
movsd  0x40(%rsp),%xmm2
call   10a0 <glNormal3f@plt>
movsd  0x30(%rsp),%xmm0
mulsd  0xcc8(%rip),%xmm0
cvttsd2si %xmm0,%ebx
mov    %ebx,%edi
mov    %r14d,%esi
call   1070 <glTexCoord2f@plt>
movsd  0x60(%rsp),%xmm0
movsd  0x58(%rsp),%xmm1
movsd  0x28(%rsp),%xmm2
call   1030 <glVertex3f@plt>
movsd  0x48(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xc65(%rip),%xmm3
divsd  %xmm3,%xmm0
movsd  0x8(%rsp),%xmm2
mulsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
movapd %xmm2,%xmm1
divsd  %xmm3,%xmm1
movsd  0x38(%rsp),%xmm2
call   10a0 <glNormal3f@plt>
mov    %ebx,%edi
mov    %r13d,%esi
call   1070 <glTexCoord2f@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
call   1030 <glVertex3f@plt>
movsd  0x30(%rsp),%xmm1
addsd  0xc1f(%rip),%xmm1
add    $0xffffffff,%ebp
jne    12e0 <drawSphere+0x160>
xor    %eax,%eax
call   1040 <glEnd@plt>
cmp    $0x18,%r12d
jne    11c0 <drawSphere+0x40>
add    $0x68,%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 @drawSphere() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store i32 24, i32* %1
store i32 32, i32* %2
store float 0x3FE99999A0000000, float* %3
%17 = load i32, i32* %1
%18 = sitofp i32 %17 to double
%19 = fdiv double 0x400921FB54442D18, %18
store double %19, double* %4
%20 = load i32, i32* %2
%21 = sitofp i32 %20 to double
%22 = fdiv double 0x401921FB54442D18, %21
store double %22, double* %5
%23 = call i32 @glColor3f(double 5.000000e-01, double 5.000000e-01, double 5.000000e-01)
store i32 0, i32* %6
br label %24
24: ; preds = %155, %0
%25 = load i32, i32* %6
%26 = load i32, i32* %1
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %158
28: ; preds = %24
%29 = load i32, i32* %6
%30 = sitofp i32 %29 to double
%31 = load double, double* %4
%32 = fmul double %30, %31
store double %32, double* %8
%33 = load double, double* %8
%34 = load double, double* %4
%35 = fadd double %33, %34
store double %35, double* %9
%36 = load float, float* %3
%37 = load double, double* %8
%38 = call float @sin(double %37)
%39 = fmul float %36, %38
%40 = fpext float %39 to double
store double %40, double* %10
%41 = load float, float* %3
%42 = load double, double* %9
%43 = call float @sin(double %42)
%44 = fmul float %41, %43
%45 = fpext float %44 to double
store double %45, double* %11
%46 = load float, float* %3
%47 = load double, double* %8
%48 = call float @cos(double %47)
%49 = fmul float %46, %48
%50 = fpext float %49 to double
store double %50, double* %12
%51 = load float, float* %3
%52 = load double, double* %9
%53 = call float @cos(double %52)
%54 = fmul float %51, %53
%55 = fpext float %54 to double
store double %55, double* %13
%56 = load i32, i32* @GL_TRIANGLE_STRIP
%57 = call i32 @glBegin(i32 %56)
store i32 0, i32* %7
br label %58
58: ; preds = %150, %28
%59 = load i32, i32* %7
%60 = load i32, i32* %2
%61 = icmp sle i32 %59, %60
br i1 %61, label %62, label %153
62: ; preds = %58
%63 = load i32, i32* %7
%64 = sitofp i32 %63 to double
%65 = load double, double* %5
%66 = fmul double %64, %65
store double %66, double* %14
%67 = load double, double* %14
%68 = call float @cos(double %67)
%69 = fpext float %68 to double
store double %69, double* %15
%70 = load double, double* %14
%71 = call float @sin(double %70)
%72 = fpext float %71 to double
store double %72, double* %16
%73 = load double, double* %15
%74 = load double, double* %10
%75 = fmul double %73, %74
%76 = load float, float* %3
%77 = fpext float %76 to double
%78 = fdiv double %75, %77
%79 = load double, double* %16
%80 = load double, double* %10
%81 = fmul double %79, %80
%82 = load float, float* %3
%83 = fpext float %82 to double
%84 = fdiv double %81, %83
%85 = load double, double* %12
%86 = load float, float* %3
%87 = fpext float %86 to double
%88 = fdiv double %85, %87
%89 = call i32 @glNormal3f(double %78, double %84, double %88)
%90 = load i32, i32* %7
%91 = sitofp i32 %90 to double
%92 = load i32, i32* %2
%93 = sitofp i32 %92 to double
%94 = fdiv double %91, %93
%95 = fptosi double %94 to i32
%96 = load i32, i32* %6
%97 = sitofp i32 %96 to double
%98 = load i32, i32* %1
%99 = sitofp i32 %98 to double
%100 = fdiv double %97, %99
%101 = fptosi double %100 to i32
%102 = call i32 @glTexCoord2f(i32 %95, i32 %101)
%103 = load double, double* %15
%104 = load double, double* %10
%105 = fmul double %103, %104
%106 = load double, double* %16
%107 = load double, double* %10
%108 = fmul double %106, %107
%109 = load double, double* %12
%110 = call i32 @glVertex3f(double %105, double %108, double %109)
%111 = load double, double* %15
%112 = load double, double* %11
%113 = fmul double %111, %112
%114 = load float, float* %3
%115 = fpext float %114 to double
%116 = fdiv double %113, %115
%117 = load double, double* %16
%118 = load double, double* %11
%119 = fmul double %117, %118
%120 = load float, float* %3
%121 = fpext float %120 to double
%122 = fdiv double %119, %121
%123 = load double, double* %13
%124 = load float, float* %3
%125 = fpext float %124 to double
%126 = fdiv double %123, %125
%127 = call i32 @glNormal3f(double %116, double %122, double %126)
%128 = load i32, i32* %7
%129 = sitofp i32 %128 to double
%130 = load i32, i32* %2
%131 = sitofp i32 %130 to double
%132 = fdiv double %129, %131
%133 = fptosi double %132 to i32
%134 = load i32, i32* %6
%135 = add nsw i32 %134, 1
%136 = sitofp i32 %135 to double
%137 = load i32, i32* %1
%138 = sitofp i32 %137 to double
%139 = fdiv double %136, %138
%140 = fptosi double %139 to i32
%141 = call i32 @glTexCoord2f(i32 %133, i32 %140)
%142 = load double, double* %15
%143 = load double, double* %11
%144 = fmul double %142, %143
%145 = load double, double* %16
%146 = load double, double* %11
%147 = fmul double %145, %146
%148 = load double, double* %13
%149 = call i32 @glVertex3f(double %144, double %147, double %148)
br label %150
150: ; preds = %62
%151 = load i32, i32* %7
%152 = add nsw i32 %151, 1
store i32 %152, i32* %7
br label %58
153: ; preds = %58
%154 = call i32 (...) @glEnd()
br label %155
155: ; preds = %153
%156 = load i32, i32* %6
%157 = add nsw i32 %156, 1
store i32 %157, i32* %6
br label %24
158: ; preds = %24
ret void
}

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