#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 /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glEndList();
int /*<<< orphan*/ glNewList(int, int /*<<< orphan*/);
int /*<<< orphan*/ glTexCoord3f(int, int, int);
int /*<<< orphan*/ glTranslatef(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ glVertex2f(int, int);
void generateTexturedSurface(void) {
  static GLfloat data[8] = {0, 1, 0, -1};
  int i, j;
  glNewList(1, GL_COMPILE);
  glTranslatef(-12 / 2.0 + .5, -12 / 2.0 + .5, 0);
  for (j = 0; j < 12; j++) {
    glBegin(GL_QUAD_STRIP);
    for (i = 0; i < 12; i++) {
      glTexCoord3f(i * (1.0 / 12), j * (1.0 / 12), data[(i + j) % 4]);
      glVertex2f(i - .5, j - .5);
      glTexCoord3f(i * (1.0 / 12), (j + 1) * (1.0 / 12), data[(i + j + 1) % 4]);
      glVertex2f(i - .5, j + .5);
    }
    glTexCoord3f((i + 1) * (1.0 / 12), j * (1.0 / 12), data[(i + j) % 4]);
    glVertex2f(i + .5, j - .5);
    glTexCoord3f((i + 1) * (1.0 / 12), (j + 1) * (1.0 / 12),
                 data[(i + j + 1) % 4]);
    glVertex2f(i + .5, j + .5);
    glEnd();
  }
  glEndList();
}


x86 assembly (clang, -O0):
<generateTexturedSurface>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
call   1040 <glNewList@plt>
mov    $0xfffffffb,%esi
xor    %edx,%edx
mov    %esi,%edi
call   1070 <glTranslatef@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xc,-0x8(%rbp)
jge    13ea <generateTexturedSurface+0x27a>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
call   1080 <glBegin@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0xc,-0x4(%rbp)
jge    12d1 <generateTexturedSurface+0x161>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xe32(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe1d(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    0x2e55(%rip),%rax
mov    (%rax,%rcx,4),%edx
call   1030 <glTexCoord3f@plt>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xde0(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xdcb(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
call   1060 <glVertex2f@plt>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xdb9(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xd9f(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
add    $0x1,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    0x2dd4(%rip),%rax
mov    (%rax,%rcx,4),%edx
call   1030 <glTexCoord3f@plt>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xd5f(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xd4a(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
call   1060 <glVertex2f@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11bf <generateTexturedSurface+0x4f>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xd25(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xd10(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    0x2d48(%rip),%rax
mov    (%rax,%rcx,4),%edx
call   1030 <glTexCoord3f@plt>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xcd3(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xcbe(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
call   1060 <glVertex2f@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xca7(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xc8d(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
add    $0x1,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
movslq %edx,%rcx
lea    0x2cc2(%rip),%rax
mov    (%rax,%rcx,4),%edx
call   1030 <glTexCoord3f@plt>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xc4d(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xc38(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
call   1060 <glVertex2f@plt>
mov    $0x0,%al
call   1050 <glEnd@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11a0 <generateTexturedSurface+0x30>
mov    $0x0,%al
call   1090 <glEndList@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generateTexturedSurface>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edi
call   1040 <glNewList@plt>
mov    $0xfffffffb,%edi
mov    $0xfffffffb,%esi
xor    %edx,%edx
call   1070 <glTranslatef@plt>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x20(%rsp)
lea    0xe6d(%rip),%r12
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
call   1080 <glBegin@plt>
movsd  0x8(%rsp),%xmm3
movapd %xmm3,%xmm0
movsd  0xe14(%rip),%xmm2
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%r13d
movapd %xmm3,%xmm0
movsd  0xe07(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x14(%rsp)
movsd  0xdfb(%rip),%xmm0
movsd  0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
lea    0x1(%rbp),%eax
mov    %eax,0x2c(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,0x18(%rsp)
addsd  0xdd1(%rip),%xmm3
cvttsd2si %xmm3,%eax
mov    %eax,0x1c(%rsp)
mov    %rbp,0x30(%rsp)
mov    %ebp,%r14d
mov    $0xc,%r15d
xorpd  %xmm0,%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  0xd7c(%rip),%xmm0
cvttsd2si %xmm0,%ebx
mov    %r14d,%eax
and    $0x3,%eax
mov    (%r12,%rax,4),%edx
mov    %ebx,%edi
mov    %r13d,%esi
call   1030 <glTexCoord3f@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xd5e(%rip),%xmm0
cvttsd2si %xmm0,%ebp
mov    %ebp,%edi
mov    0x14(%rsp),%esi
call   1060 <glVertex2f@plt>
add    $0x1,%r14d
mov    %r14d,%eax
and    $0x3,%eax
mov    (%r12,%rax,4),%edx
mov    %ebx,%edi
mov    0x18(%rsp),%esi
call   1030 <glTexCoord3f@plt>
mov    %ebp,%edi
mov    0x1c(%rsp),%esi
call   1060 <glVertex2f@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xd25(%rip),%xmm0
add    $0xffffffff,%r15d
jne    1270 <generateTexturedSurface+0x100>
mov    0x30(%rsp),%rax
and    $0x3,%eax
mov    (%r12,%rax,4),%edx
mov    $0x1,%edi
mov    %r13d,%esi
call   1030 <glTexCoord3f@plt>
mov    $0xc,%edi
mov    0x14(%rsp),%esi
call   1060 <glVertex2f@plt>
mov    0x2c(%rsp),%ebx
mov    %ebx,%eax
and    $0x3,%eax
mov    (%r12,%rax,4),%edx
mov    $0x1,%edi
mov    0x18(%rsp),%esi
call   1030 <glTexCoord3f@plt>
mov    $0xc,%edi
mov    0x1c(%rsp),%esi
call   1060 <glVertex2f@plt>
xor    %eax,%eax
call   1050 <glEnd@plt>
mov    %ebx,%ebp
cmp    $0xc,%ebx
jne    11c0 <generateTexturedSurface+0x50>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <glEndList@plt>

LLVM IR (-O0):
@generateTexturedSurface.data = internal global [8 x i32] [i32 0, i32 1, i32 0, i32 -1, i32 0, i32 0, i32 0, i32 0]
@GL_COMPILE = global i32 0
@GL_QUAD_STRIP = global i32 0
define void @generateTexturedSurface() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* @GL_COMPILE
%4 = call i32 @glNewList(i32 1, i32 %3)
%5 = call i32 @glTranslatef(i32 -5, i32 -5, i32 0)
store i32 0, i32* %2
br label %6
6: ; preds = %127, %0
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 12
br i1 %8, label %9, label %130
9: ; preds = %6
%10 = load i32, i32* @GL_QUAD_STRIP
%11 = call i32 @glBegin(i32 %10)
store i32 0, i32* %1
br label %12
12: ; preds = %68, %9
%13 = load i32, i32* %1
%14 = icmp slt i32 %13, 12
br i1 %14, label %15, label %71
15: ; preds = %12
%16 = load i32, i32* %1
%17 = sitofp i32 %16 to double
%18 = fmul double %17, 0x3FB5555555555555
%19 = fptosi double %18 to i32
%20 = load i32, i32* %2
%21 = sitofp i32 %20 to double
%22 = fmul double %21, 0x3FB5555555555555
%23 = fptosi double %22 to i32
%24 = load i32, i32* %1
%25 = load i32, i32* %2
%26 = add nsw i32 %24, %25
%27 = srem i32 %26, 4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [8 x i32], [8 x i32]* @generateTexturedSurface.data, i64 0, i64 %28
%30 = load i32, i32* %29
%31 = call i32 @glTexCoord3f(i32 %19, i32 %23, i32 %30)
%32 = load i32, i32* %1
%33 = sitofp i32 %32 to double
%34 = fsub double %33, 5.000000e-01
%35 = fptosi double %34 to i32
%36 = load i32, i32* %2
%37 = sitofp i32 %36 to double
%38 = fsub double %37, 5.000000e-01
%39 = fptosi double %38 to i32
%40 = call i32 @glVertex2f(i32 %35, i32 %39)
%41 = load i32, i32* %1
%42 = sitofp i32 %41 to double
%43 = fmul double %42, 0x3FB5555555555555
%44 = fptosi double %43 to i32
%45 = load i32, i32* %2
%46 = add nsw i32 %45, 1
%47 = sitofp i32 %46 to double
%48 = fmul double %47, 0x3FB5555555555555
%49 = fptosi double %48 to i32
%50 = load i32, i32* %1
%51 = load i32, i32* %2
%52 = add nsw i32 %50, %51
%53 = add nsw i32 %52, 1
%54 = srem i32 %53, 4
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [8 x i32], [8 x i32]* @generateTexturedSurface.data, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = call i32 @glTexCoord3f(i32 %44, i32 %49, i32 %57)
%59 = load i32, i32* %1
%60 = sitofp i32 %59 to double
%61 = fsub double %60, 5.000000e-01
%62 = fptosi double %61 to i32
%63 = load i32, i32* %2
%64 = sitofp i32 %63 to double
%65 = fadd double %64, 5.000000e-01
%66 = fptosi double %65 to i32
%67 = call i32 @glVertex2f(i32 %62, i32 %66)
br label %68
68: ; preds = %15
%69 = load i32, i32* %1
%70 = add nsw i32 %69, 1
store i32 %70, i32* %1
br label %12
71: ; preds = %12
%72 = load i32, i32* %1
%73 = add nsw i32 %72, 1
%74 = sitofp i32 %73 to double
%75 = fmul double %74, 0x3FB5555555555555
%76 = fptosi double %75 to i32
%77 = load i32, i32* %2
%78 = sitofp i32 %77 to double
%79 = fmul double %78, 0x3FB5555555555555
%80 = fptosi double %79 to i32
%81 = load i32, i32* %1
%82 = load i32, i32* %2
%83 = add nsw i32 %81, %82
%84 = srem i32 %83, 4
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [8 x i32], [8 x i32]* @generateTexturedSurface.data, i64 0, i64 %85
%87 = load i32, i32* %86
%88 = call i32 @glTexCoord3f(i32 %76, i32 %80, i32 %87)
%89 = load i32, i32* %1
%90 = sitofp i32 %89 to double
%91 = fadd double %90, 5.000000e-01
%92 = fptosi double %91 to i32
%93 = load i32, i32* %2
%94 = sitofp i32 %93 to double
%95 = fsub double %94, 5.000000e-01
%96 = fptosi double %95 to i32
%97 = call i32 @glVertex2f(i32 %92, i32 %96)
%98 = load i32, i32* %1
%99 = add nsw i32 %98, 1
%100 = sitofp i32 %99 to double
%101 = fmul double %100, 0x3FB5555555555555
%102 = fptosi double %101 to i32
%103 = load i32, i32* %2
%104 = add nsw i32 %103, 1
%105 = sitofp i32 %104 to double
%106 = fmul double %105, 0x3FB5555555555555
%107 = fptosi double %106 to i32
%108 = load i32, i32* %1
%109 = load i32, i32* %2
%110 = add nsw i32 %108, %109
%111 = add nsw i32 %110, 1
%112 = srem i32 %111, 4
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds [8 x i32], [8 x i32]* @generateTexturedSurface.data, i64 0, i64 %113
%115 = load i32, i32* %114
%116 = call i32 @glTexCoord3f(i32 %102, i32 %107, i32 %115)
%117 = load i32, i32* %1
%118 = sitofp i32 %117 to double
%119 = fadd double %118, 5.000000e-01
%120 = fptosi double %119 to i32
%121 = load i32, i32* %2
%122 = sitofp i32 %121 to double
%123 = fadd double %122, 5.000000e-01
%124 = fptosi double %123 to i32
%125 = call i32 @glVertex2f(i32 %120, i32 %124)
%126 = call i32 (...) @glEnd()
br label %127
127: ; preds = %71
%128 = load i32, i32* %2
%129 = add nsw i32 %128, 1
store i32 %129, i32* %2
br label %6
130: ; preds = %6
%131 = call i32 (...) @glEndList()
ret void
}

LLVM IR (-O2):
@generateTexturedSurface.data = internal unnamed_addr constant [8 x i32] [i32 0, i32 1, i32 0, i32 -1, i32 0, i32 0, i32 0, i32 0]
@GL_COMPILE = global i32 0
@GL_QUAD_STRIP = global i32 0
define void @generateTexturedSurface() {
%1 = load i32, i32* @GL_COMPILE
%2 = tail call i32 @glNewList(i32 1, i32 %1)
%3 = tail call i32 @glTranslatef(i32 -5, i32 -5, i32 0)
br label %4
4: ; preds = %0, %42
%5 = phi i32 [ 0, %0 ], [ %13, %42 ]
%6 = load i32, i32* @GL_QUAD_STRIP
%7 = tail call i32 @glBegin(i32 %6)
%8 = sitofp i32 %5 to double
%9 = fmul double %8, 0x3FB5555555555555
%10 = fptosi double %9 to i32
%11 = fadd double %8, -5.000000e-01
%12 = fptosi double %11 to i32
%13 = add nuw nsw i32 %5, 1
%14 = sitofp i32 %13 to double
%15 = fmul double %14, 0x3FB5555555555555
%16 = fptosi double %15 to i32
%17 = fadd double %8, 5.000000e-01
%18 = fptosi double %17 to i32
br label %19
19: ; preds = %4, %19
%20 = phi i32 [ 0, %4 ], [ %40, %19 ]
%21 = sitofp i32 %20 to double
%22 = fmul double %21, 0x3FB5555555555555
%23 = fptosi double %22 to i32
%24 = add nuw nsw i32 %20, %5
%25 = and i32 %24, 3
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds [8 x i32], [8 x i32]* @generateTexturedSurface.data, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = tail call i32 @glTexCoord3f(i32 %23, i32 %10, i32 %28)
%30 = fadd double %21, -5.000000e-01
%31 = fptosi double %30 to i32
%32 = tail call i32 @glVertex2f(i32 %31, i32 %12)
%33 = add nuw nsw i32 %24, 1
%34 = and i32 %33, 3
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds [8 x i32], [8 x i32]* @generateTexturedSurface.data, i64 0, i64 %35
%37 = load i32, i32* %36
%38 = tail call i32 @glTexCoord3f(i32 %23, i32 %16, i32 %37)
%39 = tail call i32 @glVertex2f(i32 %31, i32 %18)
%40 = add nuw nsw i32 %20, 1
%41 = icmp eq i32 %40, 12
br i1 %41, label %42, label %19
42: ; preds = %19
%43 = and i32 %5, 3
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds [8 x i32], [8 x i32]* @generateTexturedSurface.data, i64 0, i64 %44
%46 = load i32, i32* %45
%47 = tail call i32 @glTexCoord3f(i32 1, i32 %10, i32 %46)
%48 = tail call i32 @glVertex2f(i32 12, i32 %12)
%49 = add nuw i32 %5, 1
%50 = and i32 %49, 3
%51 = zext i32 %50 to i64
%52 = getelementptr inbounds [8 x i32], [8 x i32]* @generateTexturedSurface.data, i64 0, i64 %51
%53 = load i32, i32* %52
%54 = tail call i32 @glTexCoord3f(i32 1, i32 %16, i32 %53)
%55 = tail call i32 @glVertex2f(i32 12, i32 %18)
%56 = tail call i32 (...) @glEnd()
%57 = icmp eq i32 %13, 12
br i1 %57, label %58, label %4
58: ; preds = %42
%59 = tail call i32 (...) @glEndList()
ret void
}