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

/* Variables and functions */
int /*<<< orphan*/ GLUT_WINDOW_HEIGHT;
int /*<<< orphan*/ GLUT_WINDOW_WIDTH;
int /*<<< orphan*/ GL_LINES;
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glColor3f(double, double, double);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glVertex2i(int, int);
int glutGet(int /*<<< orphan*/);
void drawGrid() {
  GLint w = glutGet(GLUT_WINDOW_WIDTH), h = glutGet(GLUT_WINDOW_HEIGHT);
  glColor3f(1.0, 1.0, 1.0);
  glBegin(GL_LINES);
  int i;
  for (i = 0; i < 40; i++) {
    glVertex2i(20 * i, 0);
    glVertex2i(20 * i, h);
  }
  for (i = 30; i > -10; i--) {
    glVertex2i(0, 20 * i);
    glVertex2i(w, 20 * i);
  }
  glEnd();
}


x86 assembly (clang, -O0):
<drawGrid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
call   1040 <glutGet@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
call   1040 <glutGet@plt>
mov    %eax,-0x8(%rbp)
movsd  0xe7e(%rip),%xmm2
movaps %xmm2,%xmm0
movaps %xmm2,%xmm1
call   1060 <glColor3f@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
call   1070 <glBegin@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x28,-0xc(%rbp)
jge    11d1 <drawGrid+0x81>
imul   $0x14,-0xc(%rbp),%edi
xor    %esi,%esi
call   1030 <glVertex2i@plt>
imul   $0x14,-0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <glVertex2i@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a2 <drawGrid+0x52>
movl   $0x1e,-0xc(%rbp)
cmpl   $0xfffffff6,-0xc(%rbp)
jle    1207 <drawGrid+0xb7>
imul   $0x14,-0xc(%rbp),%esi
xor    %edi,%edi
call   1030 <glVertex2i@plt>
mov    -0x4(%rbp),%edi
imul   $0x14,-0xc(%rbp),%esi
call   1030 <glVertex2i@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    11d8 <drawGrid+0x88>
mov    $0x0,%al
call   1050 <glEnd@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawGrid>:
push   %rbp
push   %r14
push   %rbx
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
call   1040 <glutGet@plt>
mov    %eax,%r14d
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
call   1040 <glutGet@plt>
mov    %eax,%ebp
movsd  0xe83(%rip),%xmm0
movaps %xmm0,%xmm1
movaps %xmm0,%xmm2
call   1060 <glColor3f@plt>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
call   1070 <glBegin@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %ebx,%edi
xor    %esi,%esi
call   1030 <glVertex2i@plt>
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <glVertex2i@plt>
add    $0x14,%ebx
cmp    $0x320,%ebx
jne    11a0 <drawGrid+0x50>
mov    $0x1f,%ebx
mov    $0x258,%ebp
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %ebp,%esi
call   1030 <glVertex2i@plt>
mov    %r14d,%edi
mov    %ebp,%esi
call   1030 <glVertex2i@plt>
add    $0xffffffff,%ebx
add    $0xffffffec,%ebp
cmp    $0xfffffff7,%ebx
jg     11d0 <drawGrid+0x80>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <glEnd@plt>

LLVM IR (-O0):
@GLUT_WINDOW_WIDTH = global i32 0
@GLUT_WINDOW_HEIGHT = global i32 0
@GL_LINES = global i32 0
define void @drawGrid() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = load i32, i32* @GLUT_WINDOW_WIDTH
%5 = call i32 @glutGet(i32 %4)
store i32 %5, i32* %1
%6 = load i32, i32* @GLUT_WINDOW_HEIGHT
%7 = call i32 @glutGet(i32 %6)
store i32 %7, i32* %2
%8 = call i32 @glColor3f(double 1.000000e+00, double 1.000000e+00, double 1.000000e+00)
%9 = load i32, i32* @GL_LINES
%10 = call i32 @glBegin(i32 %9)
store i32 0, i32* %3
br label %11
11: ; preds = %22, %0
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 40
br i1 %13, label %14, label %25
14: ; preds = %11
%15 = load i32, i32* %3
%16 = mul nsw i32 20, %15
%17 = call i32 @glVertex2i(i32 %16, i32 0)
%18 = load i32, i32* %3
%19 = mul nsw i32 20, %18
%20 = load i32, i32* %2
%21 = call i32 @glVertex2i(i32 %19, i32 %20)
br label %22
22: ; preds = %14
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %11
25: ; preds = %11
store i32 30, i32* %3
br label %26
26: ; preds = %37, %25
%27 = load i32, i32* %3
%28 = icmp sgt i32 %27, -10
br i1 %28, label %29, label %40
29: ; preds = %26
%30 = load i32, i32* %3
%31 = mul nsw i32 20, %30
%32 = call i32 @glVertex2i(i32 0, i32 %31)
%33 = load i32, i32* %1
%34 = load i32, i32* %3
%35 = mul nsw i32 20, %34
%36 = call i32 @glVertex2i(i32 %33, i32 %35)
br label %37
37: ; preds = %29
%38 = load i32, i32* %3
%39 = add nsw i32 %38, -1
store i32 %39, i32* %3
br label %26
40: ; preds = %26
%41 = call i32 (...) @glEnd()
ret void
}

LLVM IR (-O2):
@GLUT_WINDOW_WIDTH = global i32 0
@GLUT_WINDOW_HEIGHT = global i32 0
@GL_LINES = global i32 0
define void @drawGrid() {
%1 = load i32, i32* @GLUT_WINDOW_WIDTH
%2 = tail call i32 @glutGet(i32 %1)
%3 = load i32, i32* @GLUT_WINDOW_HEIGHT
%4 = tail call i32 @glutGet(i32 %3)
%5 = tail call i32 @glColor3f(double 1.000000e+00, double 1.000000e+00, double 1.000000e+00)
%6 = load i32, i32* @GL_LINES
%7 = tail call i32 @glBegin(i32 %6)
br label %8
8: ; preds = %0, %8
%9 = phi i32 [ 0, %0 ], [ %13, %8 ]
%10 = mul nuw nsw i32 %9, 20
%11 = tail call i32 @glVertex2i(i32 %10, i32 0)
%12 = tail call i32 @glVertex2i(i32 %10, i32 %4)
%13 = add nuw nsw i32 %9, 1
%14 = icmp eq i32 %13, 40
br i1 %14, label %15, label %8
15: ; preds = %8, %15
%16 = phi i32 [ %20, %15 ], [ 30, %8 ]
%17 = mul nsw i32 %16, 20
%18 = tail call i32 @glVertex2i(i32 0, i32 %17)
%19 = tail call i32 @glVertex2i(i32 %2, i32 %17)
%20 = add nsw i32 %16, -1
%21 = icmp sgt i32 %16, -9
br i1 %21, label %15, label %22
22: ; preds = %15
%23 = tail call i32 (...) @glEnd()
ret void
}