#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 */
scalar_t__ PortAddress(unsigned int, int);
void cons_hook(void) {
  register int comstat;
  unsigned temp;
  unsigned int channel = 1;
  temp = *(unsigned int *)0xb4000464;
  *(unsigned int *)0xb4000464 = 0xffff4f14;
  (*(volatile unsigned char *)((unsigned long)(PortAddress(channel, 3))) =
       (0x83));
  (*(volatile unsigned char *)((unsigned long)(PortAddress(channel, 1))) =
       (0x00));
  (*(volatile unsigned char *)((unsigned long)(PortAddress(channel, 0))) =
       (0x02));
  (*(volatile unsigned char *)((unsigned long)(PortAddress(channel, 3))) =
       (0x03));
  comstat =
      (*(volatile unsigned char *)((unsigned long)(PortAddress(channel, 5))));
  comstat =
      (*(volatile unsigned char *)((unsigned long)(PortAddress(channel, 0))));
  (*(volatile unsigned char *)((unsigned long)(PortAddress(channel, 1))) =
       (0x00));
}


x86 assembly (clang, -O0):
<cons_hook>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0xc(%rbp)
mov    $0xb4000464,%eax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    $0xb4000464,%eax
movl   $0xffff4f14,(%rax)
mov    -0xc(%rbp),%edi
mov    $0x3,%esi
call   1030 <PortAddress@plt>
movb   $0x83,(%rax)
mov    -0xc(%rbp),%edi
mov    $0x1,%esi
call   1030 <PortAddress@plt>
movb   $0x0,(%rax)
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1030 <PortAddress@plt>
movb   $0x2,(%rax)
mov    -0xc(%rbp),%edi
mov    $0x3,%esi
call   1030 <PortAddress@plt>
movb   $0x3,(%rax)
mov    -0xc(%rbp),%edi
mov    $0x5,%esi
call   1030 <PortAddress@plt>
mov    (%rax),%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0xc(%rbp),%edi
xor    %esi,%esi
call   1030 <PortAddress@plt>
mov    (%rax),%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x1,%esi
call   1030 <PortAddress@plt>
movb   $0x0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cons_hook>:
push   %rax
mov    $0xb4000464,%eax
movl   $0xffff4f14,(%rax)
mov    $0x1,%edi
mov    $0x3,%esi
call   1030 <PortAddress@plt>
movb   $0x83,(%rax)
mov    $0x1,%edi
mov    $0x1,%esi
call   1030 <PortAddress@plt>
movb   $0x0,(%rax)
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <PortAddress@plt>
movb   $0x2,(%rax)
mov    $0x1,%edi
mov    $0x3,%esi
call   1030 <PortAddress@plt>
movb   $0x3,(%rax)
mov    $0x1,%edi
mov    $0x5,%esi
call   1030 <PortAddress@plt>
mov    (%rax),%al
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <PortAddress@plt>
mov    (%rax),%al
mov    $0x1,%edi
mov    $0x1,%esi
call   1030 <PortAddress@plt>
movb   $0x0,(%rax)
pop    %rax
ret

LLVM IR (-O0):
define void @cons_hook() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 1, i32* %3
%4 = load i32, i32* inttoptr (i64 3019900004 to i32*)
store i32 %4, i32* %2
store i32 -45292, i32* inttoptr (i64 3019900004 to i32*)
%5 = load i32, i32* %3
%6 = call i64 @PortAddress(i32 %5, i32 3)
%7 = inttoptr i64 %6 to i8*
store volatile i8 -125, i8* %7
%8 = load i32, i32* %3
%9 = call i64 @PortAddress(i32 %8, i32 1)
%10 = inttoptr i64 %9 to i8*
store volatile i8 0, i8* %10
%11 = load i32, i32* %3
%12 = call i64 @PortAddress(i32 %11, i32 0)
%13 = inttoptr i64 %12 to i8*
store volatile i8 2, i8* %13
%14 = load i32, i32* %3
%15 = call i64 @PortAddress(i32 %14, i32 3)
%16 = inttoptr i64 %15 to i8*
store volatile i8 3, i8* %16
%17 = load i32, i32* %3
%18 = call i64 @PortAddress(i32 %17, i32 5)
%19 = inttoptr i64 %18 to i8*
%20 = load volatile i8, i8* %19
%21 = zext i8 %20 to i32
store i32 %21, i32* %1
%22 = load i32, i32* %3
%23 = call i64 @PortAddress(i32 %22, i32 0)
%24 = inttoptr i64 %23 to i8*
%25 = load volatile i8, i8* %24
%26 = zext i8 %25 to i32
store i32 %26, i32* %1
%27 = load i32, i32* %3
%28 = call i64 @PortAddress(i32 %27, i32 1)
%29 = inttoptr i64 %28 to i8*
store volatile i8 0, i8* %29
ret void
}

LLVM IR (-O2):
define void @cons_hook() {
store i32 -45292, i32* inttoptr (i64 3019900004 to i32*)
%1 = tail call i64 @PortAddress(i32 1, i32 3)
%2 = inttoptr i64 %1 to i8*
store volatile i8 -125, i8* %2
%3 = tail call i64 @PortAddress(i32 1, i32 1)
%4 = inttoptr i64 %3 to i8*
store volatile i8 0, i8* %4
%5 = tail call i64 @PortAddress(i32 1, i32 0)
%6 = inttoptr i64 %5 to i8*
store volatile i8 2, i8* %6
%7 = tail call i64 @PortAddress(i32 1, i32 3)
%8 = inttoptr i64 %7 to i8*
store volatile i8 3, i8* %8
%9 = tail call i64 @PortAddress(i32 1, i32 5)
%10 = inttoptr i64 %9 to i8*
%11 = load volatile i8, i8* %10
%12 = tail call i64 @PortAddress(i32 1, i32 0)
%13 = inttoptr i64 %12 to i8*
%14 = load volatile i8, i8* %13
%15 = tail call i64 @PortAddress(i32 1, i32 1)
%16 = inttoptr i64 %15 to i8*
store volatile i8 0, i8* %16
ret void
}