#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_POLYGON;
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glColor3i(int, int, int);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glFlush();
int /*<<< orphan*/ glVertex2i(int, int);
int /*<<< orphan*/ glutSwapBuffers();
int rand();
void display(void) {
  int i;
  int x, y;
  for (i = 0; i < 7; i++) {
    x = rand() % 540;
    y = rand() % 380;
    glBegin(GL_POLYGON);
    glColor3i(rand(), rand(), rand());
    glVertex2i(x, y);
    glVertex2i(x + 100, y + 10);
    glVertex2i(x + 70, y + 100);
    glEnd();
  }
  glutSwapBuffers();
  glFlush();
}


x86 assembly (clang, -O0):
<display>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
cmpl   $0x7,-0x4(%rbp)
jge    1225 <display+0xb5>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x21c,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x17c,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
call   1080 <glBegin@plt>
mov    $0x0,%al
call   1090 <rand@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    %eax,%edx
call   1030 <glColor3i@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1040 <glVertex2i@plt>
mov    -0x8(%rbp),%edi
add    $0x64,%edi
mov    -0xc(%rbp),%esi
add    $0xa,%esi
call   1040 <glVertex2i@plt>
mov    -0x8(%rbp),%edi
add    $0x46,%edi
mov    -0xc(%rbp),%esi
add    $0x64,%esi
call   1040 <glVertex2i@plt>
mov    $0x0,%al
call   1060 <glEnd@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    117f <display+0xf>
mov    $0x0,%al
call   1050 <glutSwapBuffers@plt>
mov    $0x0,%al
call   1070 <glFlush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x7,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rdx
mov    %rdx,0x10(%rsp)
imul   $0xfffffffff2b9d649,%rdx,%rax
shr    $0x20,%rax
add    %edx,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x9,%eax
add    %ecx,%eax
imul   $0x21c,%eax,%eax
mov    %rax,0x8(%rsp)
mov    %edx,%ebx
sub    %eax,%ebx
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%r13
imul   $0xffffffffac769185,%r13,%rax
shr    $0x20,%rax
add    %r13d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x8,%eax
add    %ecx,%eax
imul   $0x17c,%eax,%r12d
mov    %r13d,%ebp
sub    %r12d,%ebp
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
call   1080 <glBegin@plt>
xor    %eax,%eax
call   1090 <rand@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1090 <rand@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1090 <rand@plt>
mov    %r14d,%edi
mov    %r15d,%esi
mov    %eax,%edx
call   1030 <glColor3i@plt>
mov    %ebx,%edi
mov    %ebp,%esi
call   1040 <glVertex2i@plt>
add    $0x64,%ebx
add    $0xa,%ebp
mov    %ebx,%edi
mov    %ebp,%esi
call   1040 <glVertex2i@plt>
mov    0x8(%rsp),%rcx
neg    %ecx
mov    0x10(%rsp),%rax
lea    (%rax,%rcx,1),%edi
add    $0x46,%edi
neg    %r12d
lea    (%r12,%r13,1),%esi
add    $0x64,%esi
call   1040 <glVertex2i@plt>
xor    %eax,%eax
call   1060 <glEnd@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
jne    1190 <display+0x20>
xor    %eax,%eax
call   1050 <glutSwapBuffers@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <glFlush@plt>

LLVM IR (-O0):
@GL_POLYGON = global i32 0
define void @display() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %32, %0
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 7
br i1 %6, label %7, label %35
7: ; preds = %4
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 540
store i32 %9, i32* %2
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 380
store i32 %11, i32* %3
%12 = load i32, i32* @GL_POLYGON
%13 = call i32 @glBegin(i32 %12)
%14 = call i32 (...) @rand()
%15 = call i32 (...) @rand()
%16 = call i32 (...) @rand()
%17 = call i32 @glColor3i(i32 %14, i32 %15, i32 %16)
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call i32 @glVertex2i(i32 %18, i32 %19)
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 100
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 10
%25 = call i32 @glVertex2i(i32 %22, i32 %24)
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 70
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 100
%30 = call i32 @glVertex2i(i32 %27, i32 %29)
%31 = call i32 (...) @glEnd()
br label %32
32: ; preds = %7
%33 = load i32, i32* %1
%34 = add nsw i32 %33, 1
store i32 %34, i32* %1
br label %4
35: ; preds = %4
%36 = call i32 (...) @glutSwapBuffers()
%37 = call i32 (...) @glFlush()
ret void
}

LLVM IR (-O2):
@GL_POLYGON = global i32 0
define void @display() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %21, %1 ]
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 540
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 380
%7 = load i32, i32* @GL_POLYGON
%8 = tail call i32 @glBegin(i32 %7)
%9 = tail call i32 (...) @rand()
%10 = tail call i32 (...) @rand()
%11 = tail call i32 (...) @rand()
%12 = tail call i32 @glColor3i(i32 %9, i32 %10, i32 %11)
%13 = tail call i32 @glVertex2i(i32 %4, i32 %6)
%14 = add nsw i32 %4, 100
%15 = add nsw i32 %6, 10
%16 = tail call i32 @glVertex2i(i32 %14, i32 %15)
%17 = add nsw i32 %4, 70
%18 = add nsw i32 %6, 100
%19 = tail call i32 @glVertex2i(i32 %17, i32 %18)
%20 = tail call i32 (...) @glEnd()
%21 = add nuw nsw i32 %2, 1
%22 = icmp eq i32 %21, 7
br i1 %22, label %23, label %1
23: ; preds = %1
%24 = tail call i32 (...) @glutSwapBuffers()
%25 = tail call i32 (...) @glFlush()
ret void
}