#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*/ setPixel(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ toColor(int, int, int);
int main() {
  int x = 0;
  for (int g = 0; g < 8; g++) {
    for (int b = 0; b < 4; b++) {
      for (int r = 0; r < 8; r++) {
        setPixel(x, 0, toColor(r, g, b));
        x++;
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    11c6 <main+0xa6>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    11b3 <main+0x93>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    11a0 <main+0x80>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <toColor@plt>
mov    -0x18(%rbp),%edi
mov    %eax,%edx
xor    %esi,%esi
call   1040 <setPixel@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115f <main+0x3f>
jmp    11a5 <main+0x85>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114e <main+0x2e>
jmp    11b8 <main+0x98>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    113d <main+0x1d>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %edi,%edi
mov    %r14d,%esi
mov    %ebp,%edx
call   1030 <toColor@plt>
mov    %ebx,%edi
xor    %esi,%esi
mov    %eax,%edx
call   1040 <setPixel@plt>
mov    $0x1,%edi
mov    %r14d,%esi
mov    %ebp,%edx
call   1030 <toColor@plt>
lea    0x1(%rbx),%edi
xor    %esi,%esi
mov    %eax,%edx
call   1040 <setPixel@plt>
mov    $0x2,%edi
mov    %r14d,%esi
mov    %ebp,%edx
call   1030 <toColor@plt>
lea    0x2(%rbx),%edi
xor    %esi,%esi
mov    %eax,%edx
call   1040 <setPixel@plt>
mov    $0x3,%edi
mov    %r14d,%esi
mov    %ebp,%edx
call   1030 <toColor@plt>
lea    0x3(%rbx),%edi
xor    %esi,%esi
mov    %eax,%edx
call   1040 <setPixel@plt>
mov    $0x4,%edi
mov    %r14d,%esi
mov    %ebp,%edx
call   1030 <toColor@plt>
lea    0x4(%rbx),%edi
xor    %esi,%esi
mov    %eax,%edx
call   1040 <setPixel@plt>
mov    $0x5,%edi
mov    %r14d,%esi
mov    %ebp,%edx
call   1030 <toColor@plt>
lea    0x5(%rbx),%edi
xor    %esi,%esi
mov    %eax,%edx
call   1040 <setPixel@plt>
mov    $0x6,%edi
mov    %r14d,%esi
mov    %ebp,%edx
call   1030 <toColor@plt>
lea    0x6(%rbx),%edi
xor    %esi,%esi
mov    %eax,%edx
call   1040 <setPixel@plt>
mov    $0x7,%edi
mov    %r14d,%esi
mov    %ebp,%edx
call   1030 <toColor@plt>
lea    0x7(%rbx),%edi
xor    %esi,%esi
mov    %eax,%edx
call   1040 <setPixel@plt>
add    $0x8,%ebx
add    $0x1,%ebp
cmp    $0x4,%ebp
jne    1140 <main+0x20>
add    $0x1,%r14d
cmp    $0x8,%r14d
jne    1130 <main+0x10>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
br label %6
6: ; preds = %34, %0
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 8
br i1 %8, label %9, label %37
9: ; preds = %6
store i32 0, i32* %4
br label %10
10: ; preds = %30, %9
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %33
13: ; preds = %10
store i32 0, i32* %5
br label %14
14: ; preds = %26, %13
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 8
br i1 %16, label %17, label %29
17: ; preds = %14
%18 = load i32, i32* %2
%19 = load i32, i32* %5
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = call i32 @toColor(i32 %19, i32 %20, i32 %21)
%23 = call i32 @setPixel(i32 %18, i32 0, i32 %22)
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
br label %26
26: ; preds = %17
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %14
29: ; preds = %14
br label %30
30: ; preds = %29
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 1
store i32 %32, i32* %4
br label %10
33: ; preds = %10
br label %34
34: ; preds = %33
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %6
37: ; preds = %6
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
define i32 @main() {
br label %1
1: ; preds = %0, %34
%2 = phi i32 [ 0, %0 ], [ %35, %34 ]
%3 = phi i32 [ 0, %0 ], [ %31, %34 ]
br label %5
4: ; preds = %34
ret i32 0
5: ; preds = %1, %5
%6 = phi i32 [ 0, %1 ], [ %32, %5 ]
%7 = phi i32 [ %3, %1 ], [ %31, %5 ]
%8 = tail call i32 @toColor(i32 0, i32 %2, i32 %6)
%9 = tail call i32 @setPixel(i32 %7, i32 0, i32 %8)
%10 = add nsw i32 %7, 1
%11 = tail call i32 @toColor(i32 1, i32 %2, i32 %6)
%12 = tail call i32 @setPixel(i32 %10, i32 0, i32 %11)
%13 = add nsw i32 %7, 2
%14 = tail call i32 @toColor(i32 2, i32 %2, i32 %6)
%15 = tail call i32 @setPixel(i32 %13, i32 0, i32 %14)
%16 = add nsw i32 %7, 3
%17 = tail call i32 @toColor(i32 3, i32 %2, i32 %6)
%18 = tail call i32 @setPixel(i32 %16, i32 0, i32 %17)
%19 = add nsw i32 %7, 4
%20 = tail call i32 @toColor(i32 4, i32 %2, i32 %6)
%21 = tail call i32 @setPixel(i32 %19, i32 0, i32 %20)
%22 = add nsw i32 %7, 5
%23 = tail call i32 @toColor(i32 5, i32 %2, i32 %6)
%24 = tail call i32 @setPixel(i32 %22, i32 0, i32 %23)
%25 = add nsw i32 %7, 6
%26 = tail call i32 @toColor(i32 6, i32 %2, i32 %6)
%27 = tail call i32 @setPixel(i32 %25, i32 0, i32 %26)
%28 = add nsw i32 %7, 7
%29 = tail call i32 @toColor(i32 7, i32 %2, i32 %6)
%30 = tail call i32 @setPixel(i32 %28, i32 0, i32 %29)
%31 = add nsw i32 %7, 8
%32 = add nuw nsw i32 %6, 1
%33 = icmp eq i32 %32, 4
br i1 %33, label %34, label %5
34: ; preds = %5
%35 = add nuw nsw i32 %2, 1
%36 = icmp eq i32 %35, 8
br i1 %36, label %4, label %1
}