#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*/ GL_QUAD_STRIP;
scalar_t__ M_PI;
double cos(double);
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glVertex3f(double, double, double);
double sin(double);
void torus_torus(int numc, int numt) {
  int i, j, k;
  double s, t, x, y, z, twopi;
  twopi = 2 * (double)M_PI;
  for (i = 0; i < numc; ++i) {
    glBegin(GL_QUAD_STRIP);
    for (j = 0; j <= numt; ++j) {
      for (k = 1; k >= 0; --k) {
        s = (i + k) % numc + 0.5;
        t = j % numt;
        x = (1 + .1 * cos(s * twopi / numc)) * cos(t * twopi / numt);
        y = (1 + .1 * cos(s * twopi / numc)) * sin(t * twopi / numt);
        z = .1 * sin(s * twopi / numc);
        glVertex3f(x, y, z);
      }
    }
    glEnd();
  }
}


x86 assembly (clang, -O0):
<torus_torus>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0x2e83(%rip),%rax
cvtsi2sdq (%rax),%xmm1
movsd  0xe8e(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1321 <torus_torus+0x1d1>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
call   1070 <glBegin@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     130c <torus_torus+0x1bc>
movl   $0x1,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     12f9 <torus_torus+0x1a9>
mov    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
cltd
idivl  -0x4(%rbp)
cvtsi2sd %edx,%xmm0
movsd  0xe42(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%eax
cltd
idivl  -0x8(%rbp)
cvtsi2sd %edx,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1060 <cos@plt>
movsd  0xdf9(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdf5(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1060 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1060 <cos@plt>
movsd  0xd9b(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd97(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  0xd3a(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
call   1030 <glVertex3f@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11b6 <torus_torus+0x66>
jmp    12fe <torus_torus+0x1ae>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a3 <torus_torus+0x53>
mov    $0x0,%al
call   1040 <glEnd@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1182 <torus_torus+0x32>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<torus_torus>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
test   %edi,%edi
jle    13d1 <torus_torus+0x281>
mov    %esi,%ebx
mov    %edi,%r14d
mov    0x2e76(%rip),%rax
cvtsi2sdq (%rax),%xmm0
cvtsi2sd %edi,%xmm1
movsd  %xmm1,0x40(%rsp)
addsd  %xmm0,%xmm0
movsd  %xmm0,0x30(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
movsd  %xmm0,0x38(%rsp)
lea    0x1(%rbx),%ebp
xor    %r15d,%r15d
xorpd  %xmm1,%xmm1
xor    %r13d,%r13d
xorpd  %xmm0,%xmm0
jmp    11ca <torus_torus+0x7a>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <glEnd@plt>
movsd  0x18(%rsp),%xmm0
movapd %xmm0,%xmm1
cmp    %r14d,%r13d
je     13d1 <torus_torus+0x281>
movsd  %xmm0,0x18(%rsp)
movsd  %xmm1,0x8(%rsp)
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
call   1070 <glBegin@plt>
add    $0x1,%r13d
movsd  0xe10(%rip),%xmm0
movsd  0x18(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
test   %ebx,%ebx
movsd  0x38(%rsp),%xmm4
js     11b0 <torus_torus+0x60>
xor    %r12d,%r12d
cmp    %r14d,%r13d
mov    %r13d,%eax
cmove  %r12d,%eax
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
movsd  0xde2(%rip),%xmm1
addsd  %xmm1,%xmm2
movsd  0x30(%rsp),%xmm3
mulsd  %xmm3,%xmm2
movsd  0x40(%rsp),%xmm0
divsd  %xmm0,%xmm2
movsd  %xmm2,0x28(%rsp)
movsd  0x8(%rsp),%xmm2
addsd  %xmm1,%xmm2
mulsd  %xmm3,%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
nopl   0x0(%rax)
cmp    %r12d,%ebx
mov    %r12d,%eax
cmove  %r15d,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x30(%rsp),%xmm0
divsd  %xmm4,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x28(%rsp),%xmm0
call   1060 <cos@plt>
movapd %xmm0,%xmm1
movsd  0xd78(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xd5c(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1060 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x28(%rsp),%xmm0
call   1060 <cos@plt>
mulsd  0xd3a(%rip),%xmm0
addsd  0xd22(%rip),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <sin@plt>
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x28(%rsp),%xmm0
call   1050 <sin@plt>
movapd %xmm0,%xmm2
mulsd  0xcfd(%rip),%xmm2
movsd  0x20(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1030 <glVertex3f@plt>
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
mulsd  0xcda(%rip),%xmm0
addsd  0xcc2(%rip),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1060 <cos@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1060 <cos@plt>
mulsd  0xca4(%rip),%xmm0
addsd  0xc8c(%rip),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <sin@plt>
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x8(%rsp),%xmm0
call   1050 <sin@plt>
movapd %xmm0,%xmm2
mulsd  0xc67(%rip),%xmm2
movsd  0x20(%rsp),%xmm0
movsd  (%rsp),%xmm1
call   1030 <glVertex3f@plt>
movsd  0x38(%rsp),%xmm4
add    $0x1,%r12d
cmp    %r12d,%ebp
jne    1260 <torus_torus+0x110>
jmp    11b0 <torus_torus+0x60>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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