#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_POINTS;
int /*<<< orphan*/ glBegin(int /*<<< orphan*/);
int /*<<< orphan*/ glColor3f(float, float, float);
int /*<<< orphan*/ glEnd();
int /*<<< orphan*/ glVertex2i(int, int);
int rand();
void beginColors(float color[][500][3]) {
  int i, j;
  int k;
  for (i = 0; i < 500; i++) {
    for (j = 0; j < 500; j++) {
      for (k = 0; k < 3; k++)
        color[i][j][k] = (float)((rand() % 1000) / 1000.0);
      glBegin(GL_POINTS);
      glColor3f(color[i][j][0], color[i][j][1], color[i][j][2]);
      glVertex2i(i, j);
      glEnd();
    }
  }
}


x86 assembly (clang, -O0):
<beginColors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x1f4,-0xc(%rbp)
jge    1297 <beginColors+0x147>
movl   $0x0,-0x10(%rbp)
cmpl   $0x1f4,-0x10(%rbp)
jge    1284 <beginColors+0x134>
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    11ec <beginColors+0x9c>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movsd  0xe50(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x1770,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x14(%rbp),%rcx
movss  %xmm0,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118b <beginColors+0x3b>
mov    0x2df5(%rip),%rax
mov    (%rax),%edi
call   1060 <glBegin@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x1770,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x1770,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movss  0x4(%rax),%xmm1
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x1770,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movss  0x8(%rax),%xmm2
call   1050 <glColor3f@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1030 <glVertex2i@plt>
mov    $0x0,%al
call   1040 <glEnd@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1177 <beginColors+0x27>
jmp    1289 <beginColors+0x139>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1163 <beginColors+0x13>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<beginColors>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r14
add    $0x8,%r14
mov    0x2e81(%rip),%r12
xor    %r15d,%r15d
nopw   0x0(%rax,%rax,1)
mov    %r14,%rbx
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0xe4c(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbx)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xe0b(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4(%rbx)
xor    %eax,%eax
call   1070 <rand@plt>
cltq
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x26,%rcx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
sub    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xdce(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,(%rbx)
mov    (%r12),%edi
call   1060 <glBegin@plt>
movss  -0x8(%rbx),%xmm0
movss  -0x4(%rbx),%xmm1
movss  (%rbx),%xmm2
call   1050 <glColor3f@plt>
mov    %r15d,%edi
mov    %r13d,%esi
call   1030 <glVertex2i@plt>
xor    %eax,%eax
call   1040 <glEnd@plt>
add    $0x1,%r13
add    $0xc,%rbx
cmp    $0x1f4,%r13
jne    1180 <beginColors+0x30>
add    $0x1,%r15
add    $0x1770,%r14
cmp    $0x1f4,%r15
jne    1170 <beginColors+0x20>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@GL_POINTS = global i32 0
define void @beginColors([500 x [3 x float]]* %0) {
%2 = alloca [500 x [3 x float]]*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store [500 x [3 x float]]* %0, [500 x [3 x float]]** %2
store i32 0, i32* %3
br label %6
6: ; preds = %75, %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 500
br i1 %8, label %9, label %78
9: ; preds = %6
store i32 0, i32* %4
br label %10
10: ; preds = %71, %9
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 500
br i1 %12, label %13, label %74
13: ; preds = %10
store i32 0, i32* %5
br label %14
14: ; preds = %33, %13
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 3
br i1 %16, label %17, label %36
17: ; preds = %14
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 1000
%20 = sitofp i32 %19 to double
%21 = fdiv double %20, 1.000000e+03
%22 = fptrunc double %21 to float
%23 = load [500 x [3 x float]]*, [500 x [3 x float]]** %2
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [500 x [3 x float]], [500 x [3 x float]]* %23, i64 %25
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [500 x [3 x float]], [500 x [3 x float]]* %26, i64 0, i64 %28
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [3 x float], [3 x float]* %29, i64 0, i64 %31
store float %22, float* %32
br label %33
33: ; preds = %17
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %14
36: ; preds = %14
%37 = load i32, i32* @GL_POINTS
%38 = call i32 @glBegin(i32 %37)
%39 = load [500 x [3 x float]]*, [500 x [3 x float]]** %2
%40 = load i32, i32* %3
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [500 x [3 x float]], [500 x [3 x float]]* %39, i64 %41
%43 = load i32, i32* %4
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [500 x [3 x float]], [500 x [3 x float]]* %42, i64 0, i64 %44
%46 = getelementptr inbounds [3 x float], [3 x float]* %45, i64 0, i64 0
%47 = load float, float* %46
%48 = load [500 x [3 x float]]*, [500 x [3 x float]]** %2
%49 = load i32, i32* %3
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [500 x [3 x float]], [500 x [3 x float]]* %48, i64 %50
%52 = load i32, i32* %4
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [500 x [3 x float]], [500 x [3 x float]]* %51, i64 0, i64 %53
%55 = getelementptr inbounds [3 x float], [3 x float]* %54, i64 0, i64 1
%56 = load float, float* %55
%57 = load [500 x [3 x float]]*, [500 x [3 x float]]** %2
%58 = load i32, i32* %3
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [500 x [3 x float]], [500 x [3 x float]]* %57, i64 %59
%61 = load i32, i32* %4
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [500 x [3 x float]], [500 x [3 x float]]* %60, i64 0, i64 %62
%64 = getelementptr inbounds [3 x float], [3 x float]* %63, i64 0, i64 2
%65 = load float, float* %64
%66 = call i32 @glColor3f(float %47, float %56, float %65)
%67 = load i32, i32* %3
%68 = load i32, i32* %4
%69 = call i32 @glVertex2i(i32 %67, i32 %68)
%70 = call i32 (...) @glEnd()
br label %71
71: ; preds = %36
%72 = load i32, i32* %4
%73 = add nsw i32 %72, 1
store i32 %73, i32* %4
br label %10
74: ; preds = %10
br label %75
75: ; preds = %74
%76 = load i32, i32* %3
%77 = add nsw i32 %76, 1
store i32 %77, i32* %3
br label %6
78: ; preds = %6
ret void
}

LLVM IR (-O2):
@GL_POINTS = global i32 0
define void @beginColors([500 x [3 x float]]* nocapture %0) {
br label %2
2: ; preds = %1, %36
%3 = phi i64 [ 0, %1 ], [ %37, %36 ]
%4 = trunc i64 %3 to i32
br label %5
5: ; preds = %2, %5
%6 = phi i64 [ 0, %2 ], [ %34, %5 ]
%7 = tail call i32 (...) @rand()
%8 = srem i32 %7, 1000
%9 = sitofp i32 %8 to double
%10 = fdiv double %9, 1.000000e+03
%11 = fptrunc double %10 to float
%12 = getelementptr inbounds [500 x [3 x float]], [500 x [3 x float]]* %0, i64 %3, i64 %6, i64 0
store float %11, float* %12
%13 = tail call i32 (...) @rand()
%14 = srem i32 %13, 1000
%15 = sitofp i32 %14 to double
%16 = fdiv double %15, 1.000000e+03
%17 = fptrunc double %16 to float
%18 = getelementptr inbounds [500 x [3 x float]], [500 x [3 x float]]* %0, i64 %3, i64 %6, i64 1
store float %17, float* %18
%19 = tail call i32 (...) @rand()
%20 = srem i32 %19, 1000
%21 = sitofp i32 %20 to double
%22 = fdiv double %21, 1.000000e+03
%23 = fptrunc double %22 to float
%24 = getelementptr inbounds [500 x [3 x float]], [500 x [3 x float]]* %0, i64 %3, i64 %6, i64 2
store float %23, float* %24
%25 = load i32, i32* @GL_POINTS
%26 = tail call i32 @glBegin(i32 %25)
%27 = load float, float* %12
%28 = load float, float* %18
%29 = load float, float* %24
%30 = tail call i32 @glColor3f(float %27, float %28, float %29)
%31 = trunc i64 %6 to i32
%32 = tail call i32 @glVertex2i(i32 %4, i32 %31)
%33 = tail call i32 (...) @glEnd()
%34 = add nuw nsw i64 %6, 1
%35 = icmp eq i64 %34, 500
br i1 %35, label %36, label %5
36: ; preds = %5
%37 = add nuw nsw i64 %3, 1
%38 = icmp eq i64 %37, 500
br i1 %38, label %39, label %2
39: ; preds = %36
ret void
}