#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*/ io_hlt();
void HariMain(void) {
  int i;
  char *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    $0xa0000,%eax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0xffff,-0x4(%rbp)
jg     1156 <HariMain+0x46>
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    1128 <HariMain+0x18>
jmp    115b <HariMain+0x4b>
mov    $0x0,%al
call   1030 <io_hlt@plt>
jmp    115b <HariMain+0x4b>

x86 assembly (clang, -O2):
<HariMain>:
push   %rax
movdqa 0xee7(%rip),%xmm0
mov    $0xa0030,%eax
xor    %ecx,%ecx
movdqa 0xee8(%rip),%xmm1
movdqa 0xef0(%rip),%xmm2
movdqa %xmm0,%xmm3
pand   %xmm1,%xmm3
movdqa %xmm3,-0x30(%rax,%rcx,1)
movdqa %xmm3,-0x20(%rax,%rcx,1)
movdqa %xmm3,-0x10(%rax,%rcx,1)
movdqa %xmm3,(%rax,%rcx,1)
add    $0x40,%rcx
paddb  %xmm2,%xmm0
cmp    $0x10000,%rcx
jne    1130 <HariMain+0x20>
xor    %eax,%eax
call   1030 <io_hlt@plt>
jmp    1160 <HariMain+0x50>

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

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