#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_LINE_LOOP;
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glColor3f(double, double, double);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glVertex2i(int, int);
void grid_draw() {
  glColor3f(0.8, 0.8, 0.8);
  int i = 0;
  while (i < 10 + 1) {
    glBegin(GL_LINE_LOOP);
    glVertex2i(i * 40, 0 * 40);
    glVertex2i(i * 40, 20 * 40);
    glEnd();
    i++;
  }
  i = 0;
  while (i < 20) {
    glBegin(GL_LINE_LOOP);
    glVertex2i(0 * 40, i * 40);
    glVertex2i(10 * 40, i * 40);
    glEnd();
    i++;
  }
}


x86 assembly (clang, -O0):
<grid_draw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  0xeb0(%rip),%xmm2
movaps %xmm2,%xmm0
movaps %xmm2,%xmm1
call   1050 <glColor3f@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0xb,-0x4(%rbp)
jge    11a8 <grid_draw+0x68>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
call   1060 <glBegin@plt>
imul   $0x28,-0x4(%rbp),%edi
xor    %esi,%esi
call   1030 <glVertex2i@plt>
imul   $0x28,-0x4(%rbp),%edi
mov    $0x320,%esi
call   1030 <glVertex2i@plt>
mov    $0x0,%al
call   1040 <glEnd@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1162 <grid_draw+0x22>
movl   $0x0,-0x4(%rbp)
cmpl   $0x14,-0x4(%rbp)
jge    11f5 <grid_draw+0xb5>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
call   1060 <glBegin@plt>
imul   $0x28,-0x4(%rbp),%esi
xor    %edi,%edi
call   1030 <glVertex2i@plt>
imul   $0x28,-0x4(%rbp),%esi
mov    $0x190,%edi
call   1030 <glVertex2i@plt>
mov    $0x0,%al
call   1040 <glEnd@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11af <grid_draw+0x6f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grid_draw>:
push   %r14
push   %rbx
push   %rax
movsd  0xeb4(%rip),%xmm0
movaps %xmm0,%xmm1
movaps %xmm0,%xmm2
call   1050 <glColor3f@plt>
mov    0x2e8a(%rip),%r14
mov    (%r14),%edi
call   1060 <glBegin@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <glVertex2i@plt>
xor    %edi,%edi
mov    $0x320,%esi
call   1030 <glVertex2i@plt>
xor    %eax,%eax
call   1040 <glEnd@plt>
mov    (%r14),%edi
call   1060 <glBegin@plt>
mov    $0x28,%edi
xor    %esi,%esi
call   1030 <glVertex2i@plt>
mov    $0x28,%edi
mov    $0x320,%esi
call   1030 <glVertex2i@plt>
xor    %eax,%eax
call   1040 <glEnd@plt>
mov    (%r14),%edi
call   1060 <glBegin@plt>
mov    $0x50,%edi
xor    %esi,%esi
call   1030 <glVertex2i@plt>
mov    $0x50,%edi
mov    $0x320,%esi
call   1030 <glVertex2i@plt>
xor    %eax,%eax
call   1040 <glEnd@plt>
mov    (%r14),%edi
call   1060 <glBegin@plt>
mov    $0x78,%edi
xor    %esi,%esi
call   1030 <glVertex2i@plt>
mov    $0x78,%edi
mov    $0x320,%esi
call   1030 <glVertex2i@plt>
xor    %eax,%eax
call   1040 <glEnd@plt>
mov    (%r14),%edi
call   1060 <glBegin@plt>
mov    $0xa0,%edi
xor    %esi,%esi
call   1030 <glVertex2i@plt>
mov    $0xa0,%edi
mov    $0x320,%esi
call   1030 <glVertex2i@plt>
xor    %eax,%eax
call   1040 <glEnd@plt>
mov    (%r14),%edi
call   1060 <glBegin@plt>
mov    $0xc8,%edi
xor    %esi,%esi
call   1030 <glVertex2i@plt>
mov    $0xc8,%edi
mov    $0x320,%esi
call   1030 <glVertex2i@plt>
xor    %eax,%eax
call   1040 <glEnd@plt>
mov    (%r14),%edi
call   1060 <glBegin@plt>
mov    $0xf0,%edi
xor    %esi,%esi
call   1030 <glVertex2i@plt>
mov    $0xf0,%edi
mov    $0x320,%esi
call   1030 <glVertex2i@plt>
xor    %eax,%eax
call   1040 <glEnd@plt>
mov    (%r14),%edi
call   1060 <glBegin@plt>
mov    $0x118,%edi
xor    %esi,%esi
call   1030 <glVertex2i@plt>
mov    $0x118,%edi
mov    $0x320,%esi
call   1030 <glVertex2i@plt>
xor    %eax,%eax
call   1040 <glEnd@plt>
mov    (%r14),%edi
call   1060 <glBegin@plt>
mov    $0x140,%edi
xor    %esi,%esi
call   1030 <glVertex2i@plt>
mov    $0x140,%edi
mov    $0x320,%esi
call   1030 <glVertex2i@plt>
xor    %eax,%eax
call   1040 <glEnd@plt>
mov    (%r14),%edi
call   1060 <glBegin@plt>
mov    $0x168,%edi
xor    %esi,%esi
call   1030 <glVertex2i@plt>
mov    $0x168,%edi
mov    $0x320,%esi
call   1030 <glVertex2i@plt>
xor    %eax,%eax
call   1040 <glEnd@plt>
mov    (%r14),%edi
call   1060 <glBegin@plt>
mov    $0x190,%edi
xor    %esi,%esi
call   1030 <glVertex2i@plt>
mov    $0x190,%edi
mov    $0x320,%esi
call   1030 <glVertex2i@plt>
xor    %eax,%eax
call   1040 <glEnd@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r14),%edi
call   1060 <glBegin@plt>
xor    %edi,%edi
mov    %ebx,%esi
call   1030 <glVertex2i@plt>
mov    $0x190,%edi
mov    %ebx,%esi
call   1030 <glVertex2i@plt>
xor    %eax,%eax
call   1040 <glEnd@plt>
add    $0x28,%ebx
cmp    $0x320,%ebx
jne    1330 <grid_draw+0x1f0>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@GL_LINE_LOOP = global i32 0
define void @grid_draw() {
%1 = alloca i32
%2 = call i32 @glColor3f(double 8.000000e-01, double 8.000000e-01, double 8.000000e-01)
store i32 0, i32* %1
br label %3
3: ; preds = %6, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 11
br i1 %5, label %6, label %18
6: ; preds = %3
%7 = load i32, i32* @GL_LINE_LOOP
%8 = call i32 @glBegin(i32 %7)
%9 = load i32, i32* %1
%10 = mul nsw i32 %9, 40
%11 = call i32 @glVertex2i(i32 %10, i32 0)
%12 = load i32, i32* %1
%13 = mul nsw i32 %12, 40
%14 = call i32 @glVertex2i(i32 %13, i32 800)
%15 = call i32 (...) @glEnd()
%16 = load i32, i32* %1
%17 = add nsw i32 %16, 1
store i32 %17, i32* %1
br label %3
18: ; preds = %3
store i32 0, i32* %1
br label %19
19: ; preds = %22, %18
%20 = load i32, i32* %1
%21 = icmp slt i32 %20, 20
br i1 %21, label %22, label %34
22: ; preds = %19
%23 = load i32, i32* @GL_LINE_LOOP
%24 = call i32 @glBegin(i32 %23)
%25 = load i32, i32* %1
%26 = mul nsw i32 %25, 40
%27 = call i32 @glVertex2i(i32 0, i32 %26)
%28 = load i32, i32* %1
%29 = mul nsw i32 %28, 40
%30 = call i32 @glVertex2i(i32 400, i32 %29)
%31 = call i32 (...) @glEnd()
%32 = load i32, i32* %1
%33 = add nsw i32 %32, 1
store i32 %33, i32* %1
br label %19
34: ; preds = %19
ret void
}

LLVM IR (-O2):
@GL_LINE_LOOP = global i32 0
define void @grid_draw() {
%1 = tail call i32 @glColor3f(double 8.000000e-01, double 8.000000e-01, double 8.000000e-01)
%2 = load i32, i32* @GL_LINE_LOOP
%3 = tail call i32 @glBegin(i32 %2)
%4 = tail call i32 @glVertex2i(i32 0, i32 0)
%5 = tail call i32 @glVertex2i(i32 0, i32 800)
%6 = tail call i32 (...) @glEnd()
%7 = load i32, i32* @GL_LINE_LOOP
%8 = tail call i32 @glBegin(i32 %7)
%9 = tail call i32 @glVertex2i(i32 40, i32 0)
%10 = tail call i32 @glVertex2i(i32 40, i32 800)
%11 = tail call i32 (...) @glEnd()
%12 = load i32, i32* @GL_LINE_LOOP
%13 = tail call i32 @glBegin(i32 %12)
%14 = tail call i32 @glVertex2i(i32 80, i32 0)
%15 = tail call i32 @glVertex2i(i32 80, i32 800)
%16 = tail call i32 (...) @glEnd()
%17 = load i32, i32* @GL_LINE_LOOP
%18 = tail call i32 @glBegin(i32 %17)
%19 = tail call i32 @glVertex2i(i32 120, i32 0)
%20 = tail call i32 @glVertex2i(i32 120, i32 800)
%21 = tail call i32 (...) @glEnd()
%22 = load i32, i32* @GL_LINE_LOOP
%23 = tail call i32 @glBegin(i32 %22)
%24 = tail call i32 @glVertex2i(i32 160, i32 0)
%25 = tail call i32 @glVertex2i(i32 160, i32 800)
%26 = tail call i32 (...) @glEnd()
%27 = load i32, i32* @GL_LINE_LOOP
%28 = tail call i32 @glBegin(i32 %27)
%29 = tail call i32 @glVertex2i(i32 200, i32 0)
%30 = tail call i32 @glVertex2i(i32 200, i32 800)
%31 = tail call i32 (...) @glEnd()
%32 = load i32, i32* @GL_LINE_LOOP
%33 = tail call i32 @glBegin(i32 %32)
%34 = tail call i32 @glVertex2i(i32 240, i32 0)
%35 = tail call i32 @glVertex2i(i32 240, i32 800)
%36 = tail call i32 (...) @glEnd()
%37 = load i32, i32* @GL_LINE_LOOP
%38 = tail call i32 @glBegin(i32 %37)
%39 = tail call i32 @glVertex2i(i32 280, i32 0)
%40 = tail call i32 @glVertex2i(i32 280, i32 800)
%41 = tail call i32 (...) @glEnd()
%42 = load i32, i32* @GL_LINE_LOOP
%43 = tail call i32 @glBegin(i32 %42)
%44 = tail call i32 @glVertex2i(i32 320, i32 0)
%45 = tail call i32 @glVertex2i(i32 320, i32 800)
%46 = tail call i32 (...) @glEnd()
%47 = load i32, i32* @GL_LINE_LOOP
%48 = tail call i32 @glBegin(i32 %47)
%49 = tail call i32 @glVertex2i(i32 360, i32 0)
%50 = tail call i32 @glVertex2i(i32 360, i32 800)
%51 = tail call i32 (...) @glEnd()
%52 = load i32, i32* @GL_LINE_LOOP
%53 = tail call i32 @glBegin(i32 %52)
%54 = tail call i32 @glVertex2i(i32 400, i32 0)
%55 = tail call i32 @glVertex2i(i32 400, i32 800)
%56 = tail call i32 (...) @glEnd()
br label %57
57: ; preds = %0, %57
%58 = phi i32 [ %65, %57 ], [ 0, %0 ]
%59 = load i32, i32* @GL_LINE_LOOP
%60 = tail call i32 @glBegin(i32 %59)
%61 = mul nuw nsw i32 %58, 40
%62 = tail call i32 @glVertex2i(i32 0, i32 %61)
%63 = tail call i32 @glVertex2i(i32 400, i32 %61)
%64 = tail call i32 (...) @glEnd()
%65 = add nuw nsw i32 %58, 1
%66 = icmp eq i32 %65, 20
br i1 %66, label %67, label %57
67: ; preds = %57
ret void
}