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

/* Variables and functions */
int /*<<< orphan*/ GL_FLAT;
int /*<<< orphan*/ GL_SMOOTH;
int /*<<< orphan*/ GL_TRIANGLE_STRIP;
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glColor4f(float, float, float, float);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glShadeModel(int /*<<< orphan*/);
int /*<<< orphan*/ glVertex3f(float, float, float);
void DrawGround(void) {
  GLfloat fExtent = 20.0f;
  GLfloat fStep = 0.5f;
  GLfloat y = 0.0f;
  GLfloat fColor;
  GLfloat iStrip, iRun;
  GLint iBounce = 0;
  glShadeModel(GL_FLAT);
  for (iStrip = -fExtent; iStrip <= fExtent; iStrip += fStep) {
    glBegin(GL_TRIANGLE_STRIP);
    for (iRun = fExtent; iRun >= -fExtent; iRun -= fStep) {
      if ((iBounce % 2) == 0)
        fColor = 1.0f;
      else
        fColor = 0.0f;
      glColor4f(fColor, fColor, fColor, 0.5f);
      glVertex3f(iStrip, y, iRun);
      glVertex3f(iStrip + fStep, y, iRun);
      iBounce++;
    }
    glEnd();
  }
  glShadeModel(GL_SMOOTH);
}


x86 assembly (clang, -O0):
<DrawGround>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  0xea4(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  0xe93(%rip),%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
call   1060 <glShadeModel@plt>
movss  -0x4(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm1
movss  -0x4(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     12a4 <DrawGround+0x154>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
call   1070 <glBegin@plt>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x4(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
ucomiss %xmm1,%xmm0
jb     1289 <DrawGround+0x139>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1217 <DrawGround+0xc7>
movss  0xdfb(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    121f <DrawGround+0xcf>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x10(%rbp),%xmm1
movss  -0x10(%rbp),%xmm2
movss  0xdca(%rip),%xmm3
call   1030 <glColor4f@plt>
movss  -0x14(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0x18(%rbp),%xmm2
call   1040 <glVertex3f@plt>
movss  -0x14(%rbp),%xmm0
addss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0x18(%rbp),%xmm2
call   1040 <glVertex3f@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movss  -0x8(%rbp),%xmm1
movss  -0x18(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
jmp    11d1 <DrawGround+0x81>
mov    $0x0,%al
call   1050 <glEnd@plt>
movss  -0x8(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    11a6 <DrawGround+0x56>
mov    0x2d25(%rip),%rax
mov    (%rax),%edi
call   1060 <glShadeModel@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DrawGround>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
call   1060 <glShadeModel@plt>
movss  0xe90(%rip),%xmm1
mov    0x2e81(%rip),%r14
xor    %ebx,%ebx
movss  %xmm1,0x14(%rsp)
jmp    11b7 <DrawGround+0x67>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <glEnd@plt>
movss  0xe69(%rip),%xmm0
movss  0xc(%rsp),%xmm1
ucomiss %xmm1,%xmm0
mov    %r15d,%ebx
movss  %xmm1,0x14(%rsp)
jb     125f <DrawGround+0x10f>
movss  %xmm1,0xc(%rsp)
mov    (%r14),%edi
call   1070 <glBegin@plt>
movss  0xc(%rsp),%xmm0
addss  0xe31(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
lea    0x51(%rbx),%r15d
xor    %ebp,%ebp
movss  0xe21(%rip),%xmm0
movss  %xmm0,0x10(%rsp)
jmp    124b <DrawGround+0xfb>
nop
movaps %xmm0,%xmm1
movaps %xmm0,%xmm2
movss  0xe06(%rip),%xmm3
call   1030 <glColor4f@plt>
xorps  %xmm1,%xmm1
movss  0x14(%rsp),%xmm0
movss  0x10(%rsp),%xmm2
call   1040 <glVertex3f@plt>
xorps  %xmm1,%xmm1
movss  0xc(%rsp),%xmm0
movss  0x10(%rsp),%xmm2
call   1040 <glVertex3f@plt>
movss  0x10(%rsp),%xmm0
addss  0xdd7(%rip),%xmm0
movss  %xmm0,0x10(%rsp)
add    $0x1,%ebp
cmp    $0x51,%ebp
je     1190 <DrawGround+0x40>
lea    (%rbx,%rbp,1),%eax
movss  0xdb6(%rip),%xmm0
test   $0x1,%al
je     11f0 <DrawGround+0xa0>
xorps  %xmm0,%xmm0
jmp    11f0 <DrawGround+0xa0>
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <glShadeModel@plt>

LLVM IR (-O0):
@GL_FLAT = global i32 0
@GL_TRIANGLE_STRIP = global i32 0
@GL_SMOOTH = global i32 0
define void @DrawGround() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i32
store float 2.000000e+01, float* %1
store float 5.000000e-01, float* %2
store float 0.000000e+00, float* %3
store i32 0, i32* %7
%8 = load i32, i32* @GL_FLAT
%9 = call i32 @glShadeModel(i32 %8)
%10 = load float, float* %1
%11 = fneg float %10
store float %11, float* %5
br label %12
12: ; preds = %54, %0
%13 = load float, float* %5
%14 = load float, float* %1
%15 = fcmp ole float %13, %14
br i1 %15, label %16, label %58
16: ; preds = %12
%17 = load i32, i32* @GL_TRIANGLE_STRIP
%18 = call i32 @glBegin(i32 %17)
%19 = load float, float* %1
store float %19, float* %6
br label %20
20: ; preds = %48, %16
%21 = load float, float* %6
%22 = load float, float* %1
%23 = fneg float %22
%24 = fcmp oge float %21, %23
br i1 %24, label %25, label %52
25: ; preds = %20
%26 = load i32, i32* %7
%27 = srem i32 %26, 2
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
store float 1.000000e+00, float* %4
br label %31
30: ; preds = %25
store float 0.000000e+00, float* %4
br label %31
31: ; preds = %30, %29
%32 = load float, float* %4
%33 = load float, float* %4
%34 = load float, float* %4
%35 = call i32 @glColor4f(float %32, float %33, float %34, float 5.000000e-01)
%36 = load float, float* %5
%37 = load float, float* %3
%38 = load float, float* %6
%39 = call i32 @glVertex3f(float %36, float %37, float %38)
%40 = load float, float* %5
%41 = load float, float* %2
%42 = fadd float %40, %41
%43 = load float, float* %3
%44 = load float, float* %6
%45 = call i32 @glVertex3f(float %42, float %43, float %44)
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %48
48: ; preds = %31
%49 = load float, float* %2
%50 = load float, float* %6
%51 = fsub float %50, %49
store float %51, float* %6
br label %20
52: ; preds = %20
%53 = call i32 (...) @glEnd()
br label %54
54: ; preds = %52
%55 = load float, float* %2
%56 = load float, float* %5
%57 = fadd float %56, %55
store float %57, float* %5
br label %12
58: ; preds = %12
%59 = load i32, i32* @GL_SMOOTH
%60 = call i32 @glShadeModel(i32 %59)
ret void
}

LLVM IR (-O2):
@GL_FLAT = global i32 0
@GL_TRIANGLE_STRIP = global i32 0
@GL_SMOOTH = global i32 0
define void @DrawGround() {
%1 = load i32, i32* @GL_FLAT
%2 = tail call i32 @glShadeModel(i32 %1)
br label %3
3: ; preds = %0, %22
%4 = phi i32 [ 0, %0 ], [ %9, %22 ]
%5 = phi float [ -2.000000e+01, %0 ], [ %8, %22 ]
%6 = load i32, i32* @GL_TRIANGLE_STRIP
%7 = tail call i32 @glBegin(i32 %6)
%8 = fadd float %5, 5.000000e-01
%9 = add i32 %4, 81
br label %10
10: ; preds = %3, %10
%11 = phi i32 [ %4, %3 ], [ %19, %10 ]
%12 = phi float [ 2.000000e+01, %3 ], [ %20, %10 ]
%13 = and i32 %11, 1
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, float 1.000000e+00, float 0.000000e+00
%16 = tail call i32 @glColor4f(float %15, float %15, float %15, float 5.000000e-01)
%17 = tail call i32 @glVertex3f(float %5, float 0.000000e+00, float %12)
%18 = tail call i32 @glVertex3f(float %8, float 0.000000e+00, float %12)
%19 = add i32 %11, 1
%20 = fadd float %12, -5.000000e-01
%21 = icmp eq i32 %19, %9
br i1 %21, label %22, label %10
22: ; preds = %10
%23 = tail call i32 (...) @glEnd()
%24 = fcmp ugt float %8, 2.000000e+01
br i1 %24, label %25, label %3
25: ; preds = %22
%26 = load i32, i32* @GL_SMOOTH
%27 = tail call i32 @glShadeModel(i32 %26)
ret void
}