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


x86 assembly (clang, -O0):
<WriteHostWord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x4,-0x10(%rbp)
jae    11a7 <WriteHostWord+0x87>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rcx
shl    $0x3,%rcx
shr    %cl,%rsi
and    $0xff,%rsi
mov    $0x67,%edi
call   1040 <writeVIC@plt>
mov    $0x63,%edi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <writeVIC@plt>
mov    $0x63,%edi
call   1030 <readVIC@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    118c <WriteHostWord+0x6c>
jmp    1191 <WriteHostWord+0x71>
jmp    116d <WriteHostWord+0x4d>
jmp    1196 <WriteHostWord+0x76>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1134 <WriteHostWord+0x14>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WriteHostWord>:
push   %rbx
mov    %rdi,%rbx
movzbl %bl,%esi
mov    $0x67,%edi
call   1040 <writeVIC@plt>
mov    $0x63,%edi
xor    %esi,%esi
call   1040 <writeVIC@plt>
nopl   (%rax)
mov    $0x63,%edi
call   1030 <readVIC@plt>
test   %eax,%eax
je     1140 <WriteHostWord+0x20>
movzbl %bh,%esi
mov    $0x67,%edi
call   1040 <writeVIC@plt>
mov    $0x63,%edi
xor    %esi,%esi
call   1040 <writeVIC@plt>
nopw   0x0(%rax,%rax,1)
mov    $0x63,%edi
call   1030 <readVIC@plt>
test   %eax,%eax
je     1170 <WriteHostWord+0x50>
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%esi
mov    $0x67,%edi
call   1040 <writeVIC@plt>
mov    $0x63,%edi
xor    %esi,%esi
call   1040 <writeVIC@plt>
nopl   0x0(%rax)
mov    $0x63,%edi
call   1030 <readVIC@plt>
test   %eax,%eax
je     11a0 <WriteHostWord+0x80>
shr    $0x18,%ebx
mov    $0x67,%edi
mov    %rbx,%rsi
call   1040 <writeVIC@plt>
mov    $0x63,%edi
xor    %esi,%esi
call   1040 <writeVIC@plt>
nopw   0x0(%rax,%rax,1)
mov    $0x63,%edi
call   1030 <readVIC@plt>
test   %eax,%eax
je     11d0 <WriteHostWord+0xb0>
pop    %rbx
ret

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

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