#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 */
unsigned long readVIC(int);
int /*<<< orphan*/ writeVIC(int, int /*<<< orphan*/);
unsigned long ReadHostWord(void) {
  unsigned long val, i;
  for (i = 0, val = 0; i < 4; i++) {
    while (!(readVIC(0x63)))
      ;
    val |= readVIC(0x67);
    writeVIC(0x63, 0);
  }
  return (val);
}


x86 assembly (clang, -O0):
<ReadHostWord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x8(%rbp)
cmpq   $0x4,-0x10(%rbp)
jae    119c <ReadHostWord+0x7c>
jmp    1148 <ReadHostWord+0x28>
mov    $0x63,%edi
call   1030 <readVIC@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1168 <ReadHostWord+0x48>
jmp    116d <ReadHostWord+0x4d>
jmp    1148 <ReadHostWord+0x28>
mov    $0x67,%edi
call   1030 <readVIC@plt>
or     -0x8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    $0x63,%edi
xor    %esi,%esi
call   1040 <writeVIC@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1138 <ReadHostWord+0x18>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadHostWord>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
nopl   0x0(%rax,%rax,1)
mov    $0x63,%edi
call   1030 <readVIC@plt>
test   %rax,%rax
je     1130 <ReadHostWord+0x10>
mov    $0x67,%edi
call   1030 <readVIC@plt>
mov    %rax,%r14
mov    $0x63,%edi
xor    %esi,%esi
call   1040 <writeVIC@plt>
nopl   0x0(%rax,%rax,1)
mov    $0x63,%edi
call   1030 <readVIC@plt>
test   %rax,%rax
je     1160 <ReadHostWord+0x40>
mov    $0x67,%edi
call   1030 <readVIC@plt>
mov    %rax,%r15
mov    $0x63,%edi
xor    %esi,%esi
call   1040 <writeVIC@plt>
nopl   0x0(%rax,%rax,1)
mov    $0x63,%edi
call   1030 <readVIC@plt>
test   %rax,%rax
je     1190 <ReadHostWord+0x70>
mov    $0x67,%edi
call   1030 <readVIC@plt>
mov    %rax,%r12
mov    $0x63,%edi
xor    %esi,%esi
call   1040 <writeVIC@plt>
nopl   0x0(%rax,%rax,1)
mov    $0x63,%edi
call   1030 <readVIC@plt>
test   %rax,%rax
je     11c0 <ReadHostWord+0xa0>
or     %r14,%r15
or     %r15,%r12
mov    $0x67,%edi
call   1030 <readVIC@plt>
mov    %rax,%rbx
or     %r12,%rbx
mov    $0x63,%edi
xor    %esi,%esi
call   1040 <writeVIC@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @ReadHostWord() {
%1 = alloca i64
%2 = alloca i64
store i64 0, i64* %2
store i64 0, i64* %1
br label %3
3: ; preds = %17, %0
%4 = load i64, i64* %2
%5 = icmp ult i64 %4, 4
br i1 %5, label %6, label %20
6: ; preds = %3
br label %7
7: ; preds = %11, %6
%8 = call i64 @readVIC(i32 99)
%9 = icmp ne i64 %8, 0
%10 = xor i1 %9, true
br i1 %10, label %11, label %12
11: ; preds = %7
br label %7
12: ; preds = %7
%13 = call i64 @readVIC(i32 103)
%14 = load i64, i64* %1
%15 = or i64 %14, %13
store i64 %15, i64* %1
%16 = call i32 @writeVIC(i32 99, i32 0)
br label %17
17: ; preds = %12
%18 = load i64, i64* %2
%19 = add i64 %18, 1
store i64 %19, i64* %2
br label %3
20: ; preds = %3
%21 = load i64, i64* %1
ret i64 %21
}

LLVM IR (-O2):
define i64 @ReadHostWord() {
br label %1
1: ; preds = %0, %1
%2 = tail call i64 @readVIC(i32 99)
%3 = icmp eq i64 %2, 0
br i1 %3, label %1, label %4
4: ; preds = %1
%5 = tail call i64 @readVIC(i32 103)
%6 = tail call i32 @writeVIC(i32 99, i32 0)
br label %7
7: ; preds = %7, %4
%8 = tail call i64 @readVIC(i32 99)
%9 = icmp eq i64 %8, 0
br i1 %9, label %7, label %10
10: ; preds = %7
%11 = tail call i64 @readVIC(i32 103)
%12 = tail call i32 @writeVIC(i32 99, i32 0)
br label %13
13: ; preds = %13, %10
%14 = tail call i64 @readVIC(i32 99)
%15 = icmp eq i64 %14, 0
br i1 %15, label %13, label %16
16: ; preds = %13
%17 = tail call i64 @readVIC(i32 103)
%18 = tail call i32 @writeVIC(i32 99, i32 0)
br label %19
19: ; preds = %19, %16
%20 = tail call i64 @readVIC(i32 99)
%21 = icmp eq i64 %20, 0
br i1 %21, label %19, label %22
22: ; preds = %19
%23 = or i64 %11, %5
%24 = or i64 %17, %23
%25 = tail call i64 @readVIC(i32 103)
%26 = or i64 %25, %24
%27 = tail call i32 @writeVIC(i32 99, i32 0)
ret i64 %26
}