#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*/ InitialiseFrameBuffer(int, int, int);
int /*<<< orphan*/ WritePixel(unsigned int, unsigned int, int);
void setup_framebuffer(void) {
  InitialiseFrameBuffer(1024, 768, 16);
  char message[] = "this is a message";
  unsigned int y = 0;
  unsigned int x = 0;
  while (y <= 768) {
    while (x <= 1024) {
      WritePixel(x, y, 0x001F);
      x++;
    }
    y++;
    x = 0;
  }
}


x86 assembly (clang, -O0):
<setup_framebuffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x400,%edi
mov    $0x300,%esi
mov    $0x10,%edx
call   1040 <InitialiseFrameBuffer@plt>
mov    0xebd(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb7(%rip),%ax
mov    %ax,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x300,-0x24(%rbp)
ja     11bd <setup_framebuffer+0x9d>
jmp    117d <setup_framebuffer+0x5d>
cmpl   $0x400,-0x28(%rbp)
ja     11a8 <setup_framebuffer+0x88>
mov    -0x28(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    $0x1f,%edx
call   1030 <WritePixel@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    117d <setup_framebuffer+0x5d>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
jmp    116b <setup_framebuffer+0x4b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_framebuffer>:
push   %rbp
push   %rbx
push   %rax
mov    $0x400,%edi
mov    $0x300,%esi
mov    $0x10,%edx
call   1040 <InitialiseFrameBuffer@plt>
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x1f,%edx
call   1030 <WritePixel@plt>
add    $0x1,%ebp
cmp    $0x401,%ebp
jne    1150 <setup_framebuffer+0x30>
add    $0x1,%ebx
cmp    $0x301,%ebx
jne    1140 <setup_framebuffer+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.setup_framebuffer.message = [18 x i8] c"this is a message\00"
define void @setup_framebuffer() {
%1 = alloca [18 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @InitialiseFrameBuffer(i32 1024, i32 768, i32 16)
%5 = bitcast [18 x i8]* %1 to i8*
store i32 0, i32* %2
store i32 0, i32* %3
br label %6
6: ; preds = %19, %0
%7 = load i32, i32* %2
%8 = icmp ule i32 %7, 768
br i1 %8, label %9, label %22
9: ; preds = %6
br label %10
10: ; preds = %13, %9
%11 = load i32, i32* %3
%12 = icmp ule i32 %11, 1024
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = call i32 @WritePixel(i32 %14, i32 %15, i32 31)
%17 = load i32, i32* %3
%18 = add i32 %17, 1
store i32 %18, i32* %3
br label %10
19: ; preds = %10
%20 = load i32, i32* %2
%21 = add i32 %20, 1
store i32 %21, i32* %2
store i32 0, i32* %3
br label %6
22: ; preds = %6
ret void
}

LLVM IR (-O2):
define void @setup_framebuffer() {
%1 = tail call i32 @InitialiseFrameBuffer(i32 1024, i32 768, i32 16)
br label %2
2: ; preds = %0, %9
%3 = phi i32 [ 0, %0 ], [ %10, %9 ]
br label %4
4: ; preds = %2, %4
%5 = phi i32 [ 0, %2 ], [ %7, %4 ]
%6 = tail call i32 @WritePixel(i32 %5, i32 %3, i32 31)
%7 = add nuw nsw i32 %5, 1
%8 = icmp eq i32 %7, 1025
br i1 %8, label %9, label %4
9: ; preds = %4
%10 = add nuw nsw i32 %3, 1
%11 = icmp eq i32 %10, 769
br i1 %11, label %12, label %2
12: ; preds = %9
ret void
}