#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 */
typedef int uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ panos_pin_clear(int);
int /*<<< orphan*/ panos_pin_function(int, int);
int /*<<< orphan*/ panos_pin_set(int);
int *panos_screen_framebuffer();
int panos_screen_initialize(int, int, int);
int /*<<< orphan*/ panos_uart_string(char *);
int /*<<< orphan*/ panos_wait_us(int);
int main(void) {
  int ret_val = panos_screen_initialize(1680, 1050, 24);
  uint32_t interval;
  if (ret_val == 0) {
    interval = 100000;
    uint32_t stride = 1680 * 3;
    uint8_t *buffer = panos_screen_framebuffer();
    for (uint32_t y = 0; y < 1050; ++y) {
      for (uint32_t x = 0; x < 1680; ++x) {
        buffer[y * stride + x * 3 + 0] = 255;
        buffer[y * stride + x * 3 + 1] = x % 256;
        buffer[y * stride + x * 3 + 2] = y % 256;
      }
    }
  } else {
    interval = 1000000;
  }
  panos_pin_function(16, 0x1);
  panos_pin_set(16);
  while (1) {
    panos_pin_set(16);
    panos_wait_us(interval);
    panos_pin_clear(16);
    panos_wait_us(interval);
    (void)panos_uart_string("Hello, World.\r\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x690,%edi
mov    $0x41a,%esi
mov    $0x18,%edx
call   1050 <panos_screen_initialize@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    126f <main+0xff>
movl   $0x186a0,-0xc(%rbp)
movl   $0x13b0,-0x10(%rbp)
mov    $0x0,%al
call   1060 <panos_screen_framebuffer@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x41a,-0x1c(%rbp)
jge    126a <main+0xfa>
movl   $0x0,-0x20(%rbp)
cmpl   $0x690,-0x20(%rbp)
jge    1257 <main+0xe7>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x10(%rbp),%ecx
imul   $0x3,-0x20(%rbp),%edx
add    %edx,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
movl   $0xff,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x10(%rbp),%ecx
imul   $0x3,-0x20(%rbp),%esi
add    %esi,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
imul   -0x10(%rbp),%ecx
imul   $0x3,-0x20(%rbp),%esi
add    %esi,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d4 <main+0x64>
jmp    125c <main+0xec>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c0 <main+0x50>
jmp    1276 <main+0x106>
movl   $0xf4240,-0xc(%rbp)
mov    $0x10,%edi
mov    $0x1,%esi
call   1040 <panos_pin_function@plt>
mov    $0x10,%edi
call   1090 <panos_pin_set@plt>
mov    $0x10,%edi
call   1090 <panos_pin_set@plt>
mov    -0xc(%rbp),%edi
call   1070 <panos_wait_us@plt>
mov    $0x10,%edi
call   1080 <panos_pin_clear@plt>
mov    -0xc(%rbp),%edi
call   1070 <panos_wait_us@plt>
lea    0xd46(%rip),%rdi
call   1030 <panos_uart_string@plt>
jmp    128f <main+0x11f>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x690,%edi
mov    $0x41a,%esi
mov    $0x18,%edx
call   1050 <panos_screen_initialize@plt>
mov    $0xf4240,%ebx
test   %eax,%eax
jne    1201 <main+0x91>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <panos_screen_framebuffer@plt>
add    $0x14,%rax
xchg   %ax,%ax
movzbl %bl,%ecx
mov    %rax,%rdx
xor    %esi,%esi
nopl   0x0(%rax,%rax,1)
movl   $0xff,-0x14(%rdx)
mov    %esi,%edi
and    $0xfe,%edi
mov    %edi,-0x10(%rdx)
mov    %ecx,-0xc(%rdx)
movl   $0xff,-0x8(%rdx)
lea    0x1(%rsi),%edi
movzbl %dil,%edi
mov    %edi,-0x4(%rdx)
mov    %ecx,(%rdx)
add    $0x2,%rsi
add    $0x18,%rdx
cmp    $0x690,%rsi
jne    11b0 <main+0x40>
add    $0x1,%rbx
add    $0x4ec0,%rax
cmp    $0x41a,%rbx
jne    11a0 <main+0x30>
mov    $0x186a0,%ebx
mov    $0x10,%edi
mov    $0x1,%esi
call   1040 <panos_pin_function@plt>
mov    $0x10,%edi
call   1090 <panos_pin_set@plt>
lea    0xddf(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x10,%edi
call   1090 <panos_pin_set@plt>
mov    %ebx,%edi
call   1070 <panos_wait_us@plt>
mov    $0x10,%edi
call   1080 <panos_pin_clear@plt>
mov    %ebx,%edi
call   1070 <panos_wait_us@plt>
mov    %r14,%rdi
call   1030 <panos_uart_string@plt>
jmp    1230 <main+0xc0>

LLVM IR (-O0):
@.str = [16 x i8] c"Hello, World.\0D\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 @panos_screen_initialize(i32 1680, i32 1050, i32 24)
store i32 %8, i32* %2
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %63
11: ; preds = %0
store i32 100000, i32* %3
store i32 5040, i32* %4
%12 = call i32* (...) @panos_screen_framebuffer()
store i32* %12, i32** %5
store i32 0, i32* %6
br label %13
13: ; preds = %59, %11
%14 = load i32, i32* %6
%15 = icmp slt i32 %14, 1050
br i1 %15, label %16, label %62
16: ; preds = %13
store i32 0, i32* %7
br label %17
17: ; preds = %55, %16
%18 = load i32, i32* %7
%19 = icmp slt i32 %18, 1680
br i1 %19, label %20, label %58
20: ; preds = %17
%21 = load i32*, i32** %5
%22 = load i32, i32* %6
%23 = load i32, i32* %4
%24 = mul nsw i32 %22, %23
%25 = load i32, i32* %7
%26 = mul nsw i32 %25, 3
%27 = add nsw i32 %24, %26
%28 = add nsw i32 %27, 0
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %21, i64 %29
store i32 255, i32* %30
%31 = load i32, i32* %7
%32 = srem i32 %31, 256
%33 = load i32*, i32** %5
%34 = load i32, i32* %6
%35 = load i32, i32* %4
%36 = mul nsw i32 %34, %35
%37 = load i32, i32* %7
%38 = mul nsw i32 %37, 3
%39 = add nsw i32 %36, %38
%40 = add nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %33, i64 %41
store i32 %32, i32* %42
%43 = load i32, i32* %6
%44 = srem i32 %43, 256
%45 = load i32*, i32** %5
%46 = load i32, i32* %6
%47 = load i32, i32* %4
%48 = mul nsw i32 %46, %47
%49 = load i32, i32* %7
%50 = mul nsw i32 %49, 3
%51 = add nsw i32 %48, %50
%52 = add nsw i32 %51, 2
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %45, i64 %53
store i32 %44, i32* %54
br label %55
55: ; preds = %20
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
store i32 %57, i32* %7
br label %17
58: ; preds = %17
br label %59
59: ; preds = %58
%60 = load i32, i32* %6
%61 = add nsw i32 %60, 1
store i32 %61, i32* %6
br label %13
62: ; preds = %13
br label %64
63: ; preds = %0
store i32 1000000, i32* %3
br label %64
64: ; preds = %63, %62
%65 = call i32 @panos_pin_function(i32 16, i32 1)
%66 = call i32 @panos_pin_set(i32 16)
br label %67
67: ; preds = %64, %67
%68 = call i32 @panos_pin_set(i32 16)
%69 = load i32, i32* %3
%70 = call i32 @panos_wait_us(i32 %69)
%71 = call i32 @panos_pin_clear(i32 16)
%72 = load i32, i32* %3
%73 = call i32 @panos_wait_us(i32 %72)
%74 = call i32 @panos_uart_string(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %67
}

LLVM IR (-O2):
@.str = [16 x i8] c"Hello, World.\0D\0A\00"
define i32 @main() {
%1 = tail call i32 @panos_screen_initialize(i32 1680, i32 1050, i32 24)
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %36
3: ; preds = %0
%4 = tail call i32* (...) @panos_screen_framebuffer()
br label %5
5: ; preds = %3, %10
%6 = phi i64 [ 0, %3 ], [ %11, %10 ]
%7 = mul nuw nsw i64 %6, 5040
%8 = trunc i64 %6 to i32
%9 = and i32 %8, 255
br label %13
10: ; preds = %13
%11 = add nuw nsw i64 %6, 1
%12 = icmp eq i64 %11, 1050
br i1 %12, label %36, label %5
13: ; preds = %13, %5
%14 = phi i64 [ 0, %5 ], [ %34, %13 ]
%15 = mul nuw nsw i64 %14, 3
%16 = add nuw nsw i64 %15, %7
%17 = getelementptr inbounds i32, i32* %4, i64 %16
store i32 255, i32* %17
%18 = trunc i64 %14 to i32
%19 = and i32 %18, 254
%20 = or i64 %16, 1
%21 = getelementptr inbounds i32, i32* %4, i64 %20
store i32 %19, i32* %21
%22 = add nuw nsw i64 %16, 2
%23 = getelementptr inbounds i32, i32* %4, i64 %22
store i32 %9, i32* %23
%24 = or i64 %14, 1
%25 = mul nuw nsw i64 %24, 3
%26 = add nuw nsw i64 %25, %7
%27 = getelementptr inbounds i32, i32* %4, i64 %26
store i32 255, i32* %27
%28 = trunc i64 %24 to i32
%29 = and i32 %28, 255
%30 = add nuw nsw i64 %26, 1
%31 = getelementptr inbounds i32, i32* %4, i64 %30
store i32 %29, i32* %31
%32 = add nuw nsw i64 %26, 2
%33 = getelementptr inbounds i32, i32* %4, i64 %32
store i32 %9, i32* %33
%34 = add nuw nsw i64 %14, 2
%35 = icmp eq i64 %34, 1680
br i1 %35, label %10, label %13
36: ; preds = %10, %0
%37 = phi i32 [ 1000000, %0 ], [ 100000, %10 ]
%38 = tail call i32 @panos_pin_function(i32 16, i32 1)
%39 = tail call i32 @panos_pin_set(i32 16)
br label %40
40: ; preds = %40, %36
%41 = tail call i32 @panos_pin_set(i32 16)
%42 = tail call i32 @panos_wait_us(i32 %37)
%43 = tail call i32 @panos_pin_clear(i32 16)
%44 = tail call i32 @panos_wait_us(i32 %37)
%45 = tail call i32 @panos_uart_string(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %40
}