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

/* Variables and functions */
int /*<<< orphan*/ GL_COMPILE;
int /*<<< orphan*/ GL_QUAD_STRIP;
int const cos(int);
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glEndList();
int /*<<< orphan*/ glNewList(int, int /*<<< orphan*/);
int /*<<< orphan*/ glNormal3f(int const, int const, int const);
int /*<<< orphan*/ glVertex3f(int, int, int);
int const sin(int);
void build_torus(int tess) {
  int i, j, k, l;
  int numg = 1.2 * tess;
  int nums = tess;
  GLfloat x, y, z;
  GLfloat theta, phi;
  const GLfloat twopi = 2.0 * 3.14159265358979323846;
  const GLfloat rg = 2.0, rs = 1.0;
  glNewList(100 + 4, GL_COMPILE);
  for (i = 0; i < numg; i++) {
    glBegin(GL_QUAD_STRIP);
    for (j = 0; j <= nums; j++) {
      phi = twopi * j / nums;
      for (k = 0; k <= 1; k++) {
        l = (i + k) % numg;
        theta = twopi * l / numg;
        glNormal3f(rs * cos(phi) * cos(theta), rs * cos(phi) * sin(theta),
                   rs * sin(phi));
        x = (rg + rs * cos(phi)) * cos(theta);
        y = (rg + rs * cos(phi)) * sin(theta);
        z = rs * sin(phi);
        glVertex3f(x, y, z);
      }
    }
    glEnd();
  }
  glEndList();
}


x86 assembly (clang, -O0):
<build_torus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xe68(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x6,-0x34(%rbp)
movl   $0x2,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    0x2e13(%rip),%rax
mov    (%rax),%esi
mov    $0x68,%edi
call   1040 <glNewList@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    132d <build_torus+0x1ad>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
call   1080 <glBegin@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     1318 <build_torus+0x198>
imul   $0x6,-0xc(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jg     1305 <build_torus+0x185>
mov    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %edx,-0x14(%rbp)
imul   $0x6,-0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%edi
call   1070 <cos@plt>
shl    $0x0,%eax
mov    %eax,-0x54(%rbp)
mov    -0x2c(%rbp),%edi
call   1070 <cos@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x30(%rbp),%edi
call   1070 <cos@plt>
shl    $0x0,%eax
mov    %eax,-0x50(%rbp)
mov    -0x2c(%rbp),%edi
call   1060 <sin@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x48(%rbp)
mov    -0x30(%rbp),%edi
call   1060 <sin@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%esi
mov    %eax,%edx
shl    $0x0,%edx
call   10a0 <glNormal3f@plt>
mov    -0x30(%rbp),%edi
call   1070 <cos@plt>
shl    $0x0,%eax
add    $0x2,%eax
mov    %eax,-0x44(%rbp)
mov    -0x2c(%rbp),%edi
call   1070 <cos@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x30(%rbp),%edi
call   1070 <cos@plt>
shl    $0x0,%eax
add    $0x2,%eax
mov    %eax,-0x40(%rbp)
mov    -0x2c(%rbp),%edi
call   1060 <sin@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%edi
call   1060 <sin@plt>
shl    $0x0,%eax
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1030 <glVertex3f@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1217 <build_torus+0x97>
jmp    130a <build_torus+0x18a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11f9 <build_torus+0x79>
mov    $0x0,%al
call   1050 <glEnd@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d8 <build_torus+0x58>
mov    $0x0,%al
call   1090 <glEndList@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_torus>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
cvtsi2sd %edi,%xmm0
mulsd  0xe64(%rip),%xmm0
cvttsd2si %xmm0,%r14d
mov    0x2e30(%rip),%rax
mov    (%rax),%esi
mov    $0x68,%edi
call   1040 <glNewList@plt>
test   %r14d,%r14d
jle    1362 <build_torus+0x1e2>
mov    %r14d,%ebp
xor    %r14d,%r14d
mov    %ebx,0x4(%rsp)
mov    %ebp,(%rsp)
jmp    11e4 <build_torus+0x64>
nopl   0x0(%rax)
add    $0x1,%r14d
xor    %eax,%eax
call   1050 <glEnd@plt>
cmp    %ebp,%r14d
je     1362 <build_torus+0x1e2>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
call   1080 <glBegin@plt>
test   %ebx,%ebx
js     11d0 <build_torus+0x50>
lea    (%r14,%r14,1),%ecx
lea    (%rcx,%rcx,2),%eax
cltd
mov    %ebp,%esi
idiv   %ebp
mov    %eax,0xc(%rsp)
add    $0x1,%r14d
xor    %r13d,%r13d
mov    %r14,0x10(%rsp)
cmp    %ebp,%r14d
lea    0x6(%rcx,%rcx,2),%eax
cmove  %r13d,%eax
mov    %eax,0x8(%rsp)
mov    $0xffffffff,%r12d
nopw   0x0(%rax,%rax,1)
mov    %r13d,%eax
cltd
idiv   %ebx
mov    %eax,%ebp
mov    %eax,%edi
call   1070 <cos@plt>
mov    %eax,%ebx
mov    0xc(%rsp),%r14d
mov    %r14d,%edi
call   1070 <cos@plt>
imul   %eax,%ebx
mov    %ebp,%edi
call   1070 <cos@plt>
mov    %eax,%r15d
mov    %r14d,%edi
call   1060 <sin@plt>
imul   %eax,%r15d
mov    %ebp,%edi
call   1060 <sin@plt>
mov    %ebx,%edi
mov    %r15d,%esi
mov    %eax,%edx
call   10a0 <glNormal3f@plt>
mov    %ebp,%edi
call   1070 <cos@plt>
lea    0x2(%rax),%r15d
mov    %r14d,%edi
call   1070 <cos@plt>
imul   %eax,%r15d
mov    %ebp,%edi
call   1070 <cos@plt>
lea    0x2(%rax),%ebx
mov    %r14d,%edi
call   1060 <sin@plt>
imul   %eax,%ebx
mov    %ebp,%edi
call   1060 <sin@plt>
mov    %r15d,%edi
mov    %ebx,%esi
mov    %eax,%edx
call   1030 <glVertex3f@plt>
mov    0x8(%rsp),%eax
cltd
idivl  (%rsp)
mov    %eax,%r15d
mov    %ebp,%edi
call   1070 <cos@plt>
mov    %eax,%ebx
mov    %r15d,%edi
call   1070 <cos@plt>
imul   %eax,%ebx
mov    %ebp,%edi
call   1070 <cos@plt>
mov    %eax,%r14d
mov    %r15d,%edi
call   1060 <sin@plt>
imul   %eax,%r14d
mov    %ebp,%edi
call   1060 <sin@plt>
mov    %ebx,%edi
mov    %r14d,%esi
mov    %eax,%edx
call   10a0 <glNormal3f@plt>
mov    %ebp,%edi
call   1070 <cos@plt>
lea    0x2(%rax),%r14d
mov    %r15d,%edi
call   1070 <cos@plt>
imul   %eax,%r14d
mov    %ebp,%edi
call   1070 <cos@plt>
lea    0x2(%rax),%ebx
mov    %r15d,%edi
call   1060 <sin@plt>
imul   %eax,%ebx
mov    %ebp,%edi
call   1060 <sin@plt>
mov    %r14d,%edi
mov    (%rsp),%ebp
mov    %ebx,%esi
mov    0x4(%rsp),%ebx
mov    %eax,%edx
call   1030 <glVertex3f@plt>
add    $0x1,%r12d
add    $0x6,%r13d
cmp    %r12d,%ebx
jne    1230 <build_torus+0xb0>
mov    0x10(%rsp),%r14
jmp    11d4 <build_torus+0x54>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <glEndList@plt>

LLVM IR (-O0):
@GL_COMPILE = global i32 0
@GL_QUAD_STRIP = global i32 0
define void @build_torus(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 %0, i32* %2
%17 = load i32, i32* %2
%18 = sitofp i32 %17 to double
%19 = fmul double 1.200000e+00, %18
%20 = fptosi double %19 to i32
store i32 %20, i32* %7
%21 = load i32, i32* %2
store i32 %21, i32* %8
store i32 6, i32* %14
store i32 2, i32* %15
store i32 1, i32* %16
%22 = load i32, i32* @GL_COMPILE
%23 = call i32 @glNewList(i32 104, i32 %22)
store i32 0, i32* %3
br label %24
24: ; preds = %99, %1
%25 = load i32, i32* %3
%26 = load i32, i32* %7
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %102
28: ; preds = %24
%29 = load i32, i32* @GL_QUAD_STRIP
%30 = call i32 @glBegin(i32 %29)
store i32 0, i32* %4
br label %31
31: ; preds = %94, %28
%32 = load i32, i32* %4
%33 = load i32, i32* %8
%34 = icmp sle i32 %32, %33
br i1 %34, label %35, label %97
35: ; preds = %31
%36 = load i32, i32* %4
%37 = mul nsw i32 6, %36
%38 = load i32, i32* %8
%39 = sdiv i32 %37, %38
store i32 %39, i32* %13
store i32 0, i32* %5
br label %40
40: ; preds = %90, %35
%41 = load i32, i32* %5
%42 = icmp sle i32 %41, 1
br i1 %42, label %43, label %93
43: ; preds = %40
%44 = load i32, i32* %3
%45 = load i32, i32* %5
%46 = add nsw i32 %44, %45
%47 = load i32, i32* %7
%48 = srem i32 %46, %47
store i32 %48, i32* %6
%49 = load i32, i32* %6
%50 = mul nsw i32 6, %49
%51 = load i32, i32* %7
%52 = sdiv i32 %50, %51
store i32 %52, i32* %12
%53 = load i32, i32* %13
%54 = call i32 @cos(i32 %53)
%55 = mul nsw i32 1, %54
%56 = load i32, i32* %12
%57 = call i32 @cos(i32 %56)
%58 = mul nsw i32 %55, %57
%59 = load i32, i32* %13
%60 = call i32 @cos(i32 %59)
%61 = mul nsw i32 1, %60
%62 = load i32, i32* %12
%63 = call i32 @sin(i32 %62)
%64 = mul nsw i32 %61, %63
%65 = load i32, i32* %13
%66 = call i32 @sin(i32 %65)
%67 = mul nsw i32 1, %66
%68 = call i32 @glNormal3f(i32 %58, i32 %64, i32 %67)
%69 = load i32, i32* %13
%70 = call i32 @cos(i32 %69)
%71 = mul nsw i32 1, %70
%72 = add nsw i32 2, %71
%73 = load i32, i32* %12
%74 = call i32 @cos(i32 %73)
%75 = mul nsw i32 %72, %74
store i32 %75, i32* %9
%76 = load i32, i32* %13
%77 = call i32 @cos(i32 %76)
%78 = mul nsw i32 1, %77
%79 = add nsw i32 2, %78
%80 = load i32, i32* %12
%81 = call i32 @sin(i32 %80)
%82 = mul nsw i32 %79, %81
store i32 %82, i32* %10
%83 = load i32, i32* %13
%84 = call i32 @sin(i32 %83)
%85 = mul nsw i32 1, %84
store i32 %85, i32* %11
%86 = load i32, i32* %9
%87 = load i32, i32* %10
%88 = load i32, i32* %11
%89 = call i32 @glVertex3f(i32 %86, i32 %87, i32 %88)
br label %90
90: ; preds = %43
%91 = load i32, i32* %5
%92 = add nsw i32 %91, 1
store i32 %92, i32* %5
br label %40
93: ; preds = %40
br label %94
94: ; preds = %93
%95 = load i32, i32* %4
%96 = add nsw i32 %95, 1
store i32 %96, i32* %4
br label %31
97: ; preds = %31
%98 = call i32 (...) @glEnd()
br label %99
99: ; preds = %97
%100 = load i32, i32* %3
%101 = add nsw i32 %100, 1
store i32 %101, i32* %3
br label %24
102: ; preds = %24
%103 = call i32 (...) @glEndList()
ret void
}

LLVM IR (-O2):
@GL_COMPILE = global i32 0
@GL_QUAD_STRIP = global i32 0
define void @build_torus(i32 %0) {
%2 = sitofp i32 %0 to double
%3 = fmul double %2, 1.200000e+00
%4 = fptosi double %3 to i32
%5 = load i32, i32* @GL_COMPILE
%6 = tail call i32 @glNewList(i32 104, i32 %5)
%7 = icmp sgt i32 %4, 0
br i1 %7, label %8, label %70
8: ; preds = %1
%9 = icmp slt i32 %0, 0
br label %10
10: ; preds = %8, %66
%11 = phi i32 [ 0, %8 ], [ %67, %66 ]
%12 = load i32, i32* @GL_QUAD_STRIP
%13 = tail call i32 @glBegin(i32 %12)
br i1 %9, label %14, label %16
14: ; preds = %10
%15 = add nuw nsw i32 %11, 1
br label %66
16: ; preds = %10
%17 = mul nsw i32 %11, 6
%18 = sdiv i32 %17, %4
%19 = add nuw nsw i32 %11, 1
%20 = icmp eq i32 %19, %4
%21 = mul nsw i32 %19, 6
%22 = select i1 %20, i32 0, i32 %21
br label %23
23: ; preds = %16, %23
%24 = phi i32 [ %64, %23 ], [ 0, %16 ]
%25 = mul nuw nsw i32 %24, 6
%26 = sdiv i32 %25, %0
%27 = tail call i32 @cos(i32 %26)
%28 = tail call i32 @cos(i32 %18)
%29 = mul nsw i32 %28, %27
%30 = tail call i32 @cos(i32 %26)
%31 = tail call i32 @sin(i32 %18)
%32 = mul nsw i32 %31, %30
%33 = tail call i32 @sin(i32 %26)
%34 = tail call i32 @glNormal3f(i32 %29, i32 %32, i32 %33)
%35 = tail call i32 @cos(i32 %26)
%36 = add nsw i32 %35, 2
%37 = tail call i32 @cos(i32 %18)
%38 = mul nsw i32 %36, %37
%39 = tail call i32 @cos(i32 %26)
%40 = add nsw i32 %39, 2
%41 = tail call i32 @sin(i32 %18)
%42 = mul nsw i32 %40, %41
%43 = tail call i32 @sin(i32 %26)
%44 = tail call i32 @glVertex3f(i32 %38, i32 %42, i32 %43)
%45 = sdiv i32 %22, %4
%46 = tail call i32 @cos(i32 %26)
%47 = tail call i32 @cos(i32 %45)
%48 = mul nsw i32 %47, %46
%49 = tail call i32 @cos(i32 %26)
%50 = tail call i32 @sin(i32 %45)
%51 = mul nsw i32 %50, %49
%52 = tail call i32 @sin(i32 %26)
%53 = tail call i32 @glNormal3f(i32 %48, i32 %51, i32 %52)
%54 = tail call i32 @cos(i32 %26)
%55 = add nsw i32 %54, 2
%56 = tail call i32 @cos(i32 %45)
%57 = mul nsw i32 %55, %56
%58 = tail call i32 @cos(i32 %26)
%59 = add nsw i32 %58, 2
%60 = tail call i32 @sin(i32 %45)
%61 = mul nsw i32 %59, %60
%62 = tail call i32 @sin(i32 %26)
%63 = tail call i32 @glVertex3f(i32 %57, i32 %61, i32 %62)
%64 = add nuw i32 %24, 1
%65 = icmp eq i32 %24, %0
br i1 %65, label %66, label %23
66: ; preds = %23, %14
%67 = phi i32 [ %15, %14 ], [ %19, %23 ]
%68 = tail call i32 (...) @glEnd()
%69 = icmp eq i32 %67, %4
br i1 %69, label %70, label %10
70: ; preds = %66, %1
%71 = tail call i32 (...) @glEndList()
ret void
}