#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*/ printf(char *, ...);
void print(int tier, unsigned short AC, unsigned short PC, unsigned short DR,
           unsigned short AR, unsigned short IR, unsigned short E,
           unsigned short memory[]) {
  if (tier == -1) {
    printf("    |  IR  |  AC  |  DR  |  PC  |  AR  | M[AR]|   E  |\n");
    printf("----|------+------+------+------+------+------+------|\n");
  }
  if (tier == -1) {
    printf("init| %04hX | %04hX | %04hX | %04hX | %04hX | %04hX | %04hX |\n",
           IR, AC, DR, PC, AR, memory[AR], E);
  } else {
    printf(" T%i | %04hX | %04hX | %04hX | %04hX | %04hX | %04hX | %04hX |\n",
           tier, IR, AC, DR, PC, AR, memory[AR], E);
  }
  printf("----|------+------+------+------+------+------+------|\n");
}


x86 assembly (clang, -O0):
<print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %r8d,-0x20(%rbp)
mov    %ecx,%eax
mov    -0x20(%rbp),%ecx
mov    %eax,-0x1c(%rbp)
mov    %edx,%eax
mov    -0x1c(%rbp),%edx
mov    %eax,-0x18(%rbp)
mov    %esi,%eax
mov    -0x18(%rbp),%esi
mov    %eax,-0x14(%rbp)
mov    %edi,%r8d
mov    -0x14(%rbp),%edi
mov    %r9w,%ax
mov    0x18(%rbp),%r9
mov    0x10(%rbp),%r9w
mov    %r8d,-0x4(%rbp)
mov    %di,-0x6(%rbp)
mov    %si,-0x8(%rbp)
mov    %dx,-0xa(%rbp)
mov    %cx,-0xc(%rbp)
mov    %ax,-0xe(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
jne    1185 <print+0x75>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xffffffff,-0x4(%rbp)
jne    11d1 <print+0xc1>
movzwl -0xe(%rbp),%esi
movzwl -0x6(%rbp),%edx
movzwl -0xa(%rbp),%ecx
movzwl -0x8(%rbp),%r8d
movzwl -0xc(%rbp),%r9d
mov    0x18(%rbp),%rax
movzwl -0xc(%rbp),%edi
movzwl (%rax,%rdi,2),%r10d
movzwl 0x10(%rbp),%eax
lea    0xeb3(%rip),%rdi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1217 <print+0x107>
mov    -0x4(%rbp),%esi
movzwl -0xe(%rbp),%edx
movzwl -0x6(%rbp),%ecx
movzwl -0xa(%rbp),%r8d
movzwl -0x8(%rbp),%r9d
movzwl -0xc(%rbp),%r11d
mov    0x18(%rbp),%rax
movzwl -0xc(%rbp),%edi
movzwl (%rax,%rdi,2),%r10d
movzwl 0x10(%rbp),%eax
lea    0xeac(%rip),%rdi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%ebp
mov    %r8d,%eax
mov    %ecx,%r12d
mov    %edx,%r15d
mov    %esi,%ebx
mov    0x48(%rsp),%r14
movzwl 0x40(%rsp),%r13d
cmp    $0xffffffff,%edi
je     1181 <print+0x61>
mov    %edi,%esi
movzwl %bp,%edx
movzwl %bx,%ecx
movzwl %r12w,%r8d
movzwl %r15w,%r9d
movzwl %ax,%ebp
movzwl (%r14,%rbp,2),%r10d
movzwl %r13w,%ebx
sub    $0x8,%rsp
lea    0xecf(%rip),%rdi
xor    %eax,%eax
push   %rbx
push   %r10
push   %rbp
call   1040 <printf@plt>
add    $0x20,%rsp
jmp    11ce <print+0xae>
lea    0xef7(%rip),%rdi
mov    %eax,0x4(%rsp)
call   1030 <puts@plt>
lea    0xf1e(%rip),%rdi
call   1030 <puts@plt>
movzwl %bp,%esi
movzwl %bx,%edx
movzwl %r12w,%ecx
movzwl %r15w,%r8d
movzwl 0x4(%rsp),%r9d
movzwl (%r14,%r9,2),%ebp
movzwl %r13w,%ebx
lea    0xe3f(%rip),%rdi
xor    %eax,%eax
push   %rbx
push   %rbp
call   1040 <printf@plt>
add    $0x10,%rsp
lea    0xee1(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [56 x i8] c" | IR | AC | DR | PC | AR | M[AR]| E |\0A\00"
@.str.1 = [56 x i8] c"----|------+------+------+------+------+------+------|\0A\00"
@.str.2 = [63 x i8] c"init| %04hX | %04hX | %04hX | %04hX | %04hX | %04hX | %04hX |\0A\00"
@.str.3 = [64 x i8] c" T%i | %04hX | %04hX | %04hX | %04hX | %04hX | %04hX | %04hX |\0A\00"
define void @print(i32 %0, i16 zeroext %1, i16 zeroext %2, i16 zeroext %3, i16 zeroext %4, i16 zeroext %5, i16 zeroext %6, i16* %7) {
%9 = alloca i32
%10 = alloca i16
%11 = alloca i16
%12 = alloca i16
%13 = alloca i16
%14 = alloca i16
%15 = alloca i16
%16 = alloca i16*
store i32 %0, i32* %9
store i16 %1, i16* %10
store i16 %2, i16* %11
store i16 %3, i16* %12
store i16 %4, i16* %13
store i16 %5, i16* %14
store i16 %6, i16* %15
store i16* %7, i16** %16
%17 = load i32, i32* %9
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %22
19: ; preds = %8
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %19, %8
%23 = load i32, i32* %9
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %45
25: ; preds = %22
%26 = load i16, i16* %14
%27 = zext i16 %26 to i32
%28 = load i16, i16* %10
%29 = zext i16 %28 to i32
%30 = load i16, i16* %12
%31 = zext i16 %30 to i32
%32 = load i16, i16* %11
%33 = zext i16 %32 to i32
%34 = load i16, i16* %13
%35 = zext i16 %34 to i32
%36 = load i16*, i16** %16
%37 = load i16, i16* %13
%38 = zext i16 %37 to i64
%39 = getelementptr inbounds i16, i16* %36, i64 %38
%40 = load i16, i16* %39
%41 = zext i16 %40 to i32
%42 = load i16, i16* %15
%43 = zext i16 %42 to i32
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %29, i32 %31, i32 %33, i32 %35, i32 %41, i32 %43)
br label %66
45: ; preds = %22
%46 = load i32, i32* %9
%47 = load i16, i16* %14
%48 = zext i16 %47 to i32
%49 = load i16, i16* %10
%50 = zext i16 %49 to i32
%51 = load i16, i16* %12
%52 = zext i16 %51 to i32
%53 = load i16, i16* %11
%54 = zext i16 %53 to i32
%55 = load i16, i16* %13
%56 = zext i16 %55 to i32
%57 = load i16*, i16** %16
%58 = load i16, i16* %13
%59 = zext i16 %58 to i64
%60 = getelementptr inbounds i16, i16* %57, i64 %59
%61 = load i16, i16* %60
%62 = zext i16 %61 to i32
%63 = load i16, i16* %15
%64 = zext i16 %63 to i32
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), i32 %46, i32 %48, i32 %50, i32 %52, i32 %54, i32 %56, i32 %62, i32 %64)
br label %66
66: ; preds = %45, %25
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.2 = [63 x i8] c"init| %04hX | %04hX | %04hX | %04hX | %04hX | %04hX | %04hX |\0A\00"
@.str.3 = [64 x i8] c" T%i | %04hX | %04hX | %04hX | %04hX | %04hX | %04hX | %04hX |\0A\00"
@str.4 = [55 x i8] c" | IR | AC | DR | PC | AR | M[AR]| E |\00"
@str.5 = [55 x i8] c"----|------+------+------+------+------+------+------|\00"
define void @print(i32 %0, i16 zeroext %1, i16 zeroext %2, i16 zeroext %3, i16 zeroext %4, i16 zeroext %5, i16 zeroext %6, i16* nocapture %7) {
%9 = icmp eq i32 %0, -1
br i1 %9, label %10, label %24
10: ; preds = %8
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.4, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.5, i64 0, i64 0))
%13 = zext i16 %5 to i32
%14 = zext i16 %1 to i32
%15 = zext i16 %3 to i32
%16 = zext i16 %2 to i32
%17 = zext i16 %4 to i32
%18 = zext i16 %4 to i64
%19 = getelementptr inbounds i16, i16* %7, i64 %18
%20 = load i16, i16* %19
%21 = zext i16 %20 to i32
%22 = zext i16 %6 to i32
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %14, i32 %15, i32 %16, i32 %17, i32 %21, i32 %22)
br label %36
24: ; preds = %8
%25 = zext i16 %5 to i32
%26 = zext i16 %1 to i32
%27 = zext i16 %3 to i32
%28 = zext i16 %2 to i32
%29 = zext i16 %4 to i32
%30 = zext i16 %4 to i64
%31 = getelementptr inbounds i16, i16* %7, i64 %30
%32 = load i16, i16* %31
%33 = zext i16 %32 to i32
%34 = zext i16 %6 to i32
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), i32 %0, i32 %25, i32 %26, i32 %27, i32 %28, i32 %29, i32 %33, i32 %34)
br label %36
36: ; preds = %24, %10
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.5, i64 0, i64 0))
ret void
}