#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*/ init_palette();
int /*<<< orphan*/ io_hlt();
void HariMain(void) {
  int i;
  char *p;
  init_palette();
  p = (char *)0xa0000;
  for (i = 0; i <= 0xffff; i++) {
    p[i] = i & 0x0f;
  }
  for (;;) {
    io_hlt();
  }
}


x86 assembly (clang, -O0):
<HariMain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <init_palette@plt>
mov    $0xa0000,%eax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0xffff,-0x4(%rbp)
jg     116d <HariMain+0x4d>
mov    -0x4(%rbp),%eax
and    $0xf,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    113f <HariMain+0x1f>
jmp    1172 <HariMain+0x52>
mov    $0x0,%al
call   1030 <io_hlt@plt>
jmp    1172 <HariMain+0x52>

x86 assembly (clang, -O2):
<HariMain>:
push   %r14
push   %rbx
push   %rax
mov    $0xa0030,%r14d
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <init_palette@plt>
movdqa 0xec5(%rip),%xmm0
movdqa 0xecd(%rip),%xmm1
movdqa 0xed5(%rip),%xmm2
nopl   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm3
pand   %xmm1,%xmm3
movdqa %xmm3,-0x30(%r14,%rbx,1)
movdqa %xmm3,-0x20(%r14,%rbx,1)
movdqa %xmm3,-0x10(%r14,%rbx,1)
movdqa %xmm3,(%r14,%rbx,1)
add    $0x40,%rbx
paddb  %xmm2,%xmm0
cmp    $0x10000,%rbx
jne    1150 <HariMain+0x30>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   1030 <io_hlt@plt>
jmp    1190 <HariMain+0x70>

LLVM IR (-O0):
define void @HariMain() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i32 (...) @init_palette()
store i8* inttoptr (i64 655360 to i8*), i8** %2
store i32 0, i32* %1
br label %4
4: ; preds = %15, %0
%5 = load i32, i32* %1
%6 = icmp sle i32 %5, 65535
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = load i32, i32* %1
%9 = and i32 %8, 15
%10 = trunc i32 %9 to i8
%11 = load i8*, i8** %2
%12 = load i32, i32* %1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
store i8 %10, i8* %14
br label %15
15: ; preds = %7
%16 = load i32, i32* %1
%17 = add nsw i32 %16, 1
store i32 %17, i32* %1
br label %4
18: ; preds = %4
br label %19
19: ; preds = %19, %18
%20 = call i32 (...) @io_hlt()
br label %19
}

LLVM IR (-O2):
define void @HariMain() {
%1 = tail call i32 (...) @init_palette()
br label %2
2: ; preds = %2, %0
%3 = phi i64 [ 0, %0 ], [ %20, %2 ]
%4 = phi <16 x i8> [ <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, %0 ], [ %21, %2 ]
%5 = and <16 x i8> %4, <i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15>
%6 = getelementptr inbounds i8, i8* inttoptr (i64 655360 to i8*), i64 %3
%7 = bitcast i8* %6 to <16 x i8>*
store <16 x i8> %5, <16 x i8>* %7
%8 = or i64 %3, 16
%9 = and <16 x i8> %4, <i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15>
%10 = getelementptr inbounds i8, i8* inttoptr (i64 655360 to i8*), i64 %8
%11 = bitcast i8* %10 to <16 x i8>*
store <16 x i8> %9, <16 x i8>* %11
%12 = or i64 %3, 32
%13 = and <16 x i8> %4, <i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15>
%14 = getelementptr inbounds i8, i8* inttoptr (i64 655360 to i8*), i64 %12
%15 = bitcast i8* %14 to <16 x i8>*
store <16 x i8> %13, <16 x i8>* %15
%16 = or i64 %3, 48
%17 = and <16 x i8> %4, <i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15, i8 15>
%18 = getelementptr inbounds i8, i8* inttoptr (i64 655360 to i8*), i64 %16
%19 = bitcast i8* %18 to <16 x i8>*
store <16 x i8> %17, <16 x i8>* %19
%20 = add nuw nsw i64 %3, 64
%21 = add <16 x i8> %4, <i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64, i8 64>
%22 = icmp eq i64 %20, 65536
br i1 %22, label %23, label %2
23: ; preds = %2, %23
%24 = tail call i32 (...) @io_hlt()
br label %23
}