#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 */
size_t getRegisterNumber(char *);
int /*<<< orphan*/ printf(char *, ...);
void printRegisters(int *registers) {
  int i;
  char *reg[] = {"A", "X", "L", "B", "S", "T", "F", "PC", "SW"};
  printf("   ----Registers----\n");
  for (i = 0; i < 9; i++)
    printf("  %-3s: %06X\n", reg[i],
           registers[getRegisterNumber(reg[i])] & 0xFFFFFF);
}


x86 assembly (clang, -O0):
<printRegisters>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x60(%rbp),%rdi
lea    0x2c89(%rip),%rsi
mov    $0x48,%edx
call   1040 <memcpy@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x9,-0xc(%rbp)
jge    11c3 <printRegisters+0x93>
movslq -0xc(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rax
mov    %rax,-0x70(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x68(%rbp)
movslq -0xc(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rdi
call   1050 <getRegisterNumber@plt>
mov    -0x70(%rbp),%rsi
mov    %rax,%rcx
mov    -0x68(%rbp),%rax
mov    (%rax,%rcx,4),%edx
and    $0xffffff,%edx
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1166 <printRegisters+0x36>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printRegisters>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee1(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb3(%rip),%r15
mov    %r15,%rdi
call   1050 <getRegisterNumber@plt>
mov    $0xffffff,%ebp
mov    (%rbx,%rax,4),%edx
and    %ebp,%edx
lea    0xeae(%rip),%r14
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe88(%rip),%r15
mov    %r15,%rdi
call   1050 <getRegisterNumber@plt>
mov    (%rbx,%rax,4),%edx
and    %ebp,%edx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe69(%rip),%r15
mov    %r15,%rdi
call   1050 <getRegisterNumber@plt>
mov    (%rbx,%rax,4),%edx
and    %ebp,%edx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe4a(%rip),%r15
mov    %r15,%rdi
call   1050 <getRegisterNumber@plt>
mov    (%rbx,%rax,4),%edx
and    %ebp,%edx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe2b(%rip),%r15
mov    %r15,%rdi
call   1050 <getRegisterNumber@plt>
mov    (%rbx,%rax,4),%edx
and    %ebp,%edx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe0c(%rip),%r15
mov    %r15,%rdi
call   1050 <getRegisterNumber@plt>
mov    (%rbx,%rax,4),%edx
and    %ebp,%edx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xded(%rip),%r15
mov    %r15,%rdi
call   1050 <getRegisterNumber@plt>
mov    (%rbx,%rax,4),%edx
and    %ebp,%edx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdce(%rip),%r15
mov    %r15,%rdi
call   1050 <getRegisterNumber@plt>
mov    (%rbx,%rax,4),%edx
and    %ebp,%edx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdb0(%rip),%r15
mov    %r15,%rdi
call   1050 <getRegisterNumber@plt>
and    (%rbx,%rax,4),%ebp
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"A\00"
@.str.1 = [2 x i8] c"X\00"
@.str.2 = [2 x i8] c"L\00"
@.str.3 = [2 x i8] c"B\00"
@.str.4 = [2 x i8] c"S\00"
@.str.5 = [2 x i8] c"T\00"
@.str.6 = [2 x i8] c"F\00"
@.str.7 = [3 x i8] c"PC\00"
@.str.8 = [3 x i8] c"SW\00"
@__const.printRegisters.reg = [9 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i32 0, i32 0)]
@.str.9 = [22 x i8] c" ----Registers----\0A\00"
@.str.10 = [14 x i8] c" %-3s: %06X\0A\00"
define void @printRegisters(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca [9 x i8*]
store i32* %0, i32** %2
%5 = bitcast [9 x i8*]* %4 to i8*
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %3
br label %7
7: ; preds = %25, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 9
br i1 %9, label %10, label %28
10: ; preds = %7
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [9 x i8*], [9 x i8*]* %4, i64 0, i64 %12
%14 = load i8*, i8** %13
%15 = load i32*, i32** %2
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [9 x i8*], [9 x i8*]* %4, i64 0, i64 %17
%19 = load i8*, i8** %18
%20 = call i64 @getRegisterNumber(i8* %19)
%21 = getelementptr inbounds i32, i32* %15, i64 %20
%22 = load i32, i32* %21
%23 = and i32 %22, 16777215
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* %14, i32 %23)
br label %25
25: ; preds = %10
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %7
28: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"A\00"
@.str.1 = [2 x i8] c"X\00"
@.str.2 = [2 x i8] c"L\00"
@.str.3 = [2 x i8] c"B\00"
@.str.4 = [2 x i8] c"S\00"
@.str.5 = [2 x i8] c"T\00"
@.str.6 = [2 x i8] c"F\00"
@.str.7 = [3 x i8] c"PC\00"
@.str.8 = [3 x i8] c"SW\00"
@.str.10 = [14 x i8] c" %-3s: %06X\0A\00"
@str = [21 x i8] c" ----Registers----\00"
define void @printRegisters(i32* nocapture %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%3 = tail call i64 @getRegisterNumber(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = getelementptr inbounds i32, i32* %0, i64 %3
%5 = load i32, i32* %4
%6 = and i32 %5, 16777215
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = tail call i64 @getRegisterNumber(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = getelementptr inbounds i32, i32* %0, i64 %8
%10 = load i32, i32* %9
%11 = and i32 %10, 16777215
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = tail call i64 @getRegisterNumber(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = getelementptr inbounds i32, i32* %0, i64 %13
%15 = load i32, i32* %14
%16 = and i32 %15, 16777215
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = tail call i64 @getRegisterNumber(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%19 = getelementptr inbounds i32, i32* %0, i64 %18
%20 = load i32, i32* %19
%21 = and i32 %20, 16777215
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = tail call i64 @getRegisterNumber(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%24 = getelementptr inbounds i32, i32* %0, i64 %23
%25 = load i32, i32* %24
%26 = and i32 %25, 16777215
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = tail call i64 @getRegisterNumber(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%29 = getelementptr inbounds i32, i32* %0, i64 %28
%30 = load i32, i32* %29
%31 = and i32 %30, 16777215
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 %31)
%33 = tail call i64 @getRegisterNumber(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%34 = getelementptr inbounds i32, i32* %0, i64 %33
%35 = load i32, i32* %34
%36 = and i32 %35, 16777215
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 %36)
%38 = tail call i64 @getRegisterNumber(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%39 = getelementptr inbounds i32, i32* %0, i64 %38
%40 = load i32, i32* %39
%41 = and i32 %40, 16777215
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 %41)
%43 = tail call i64 @getRegisterNumber(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%44 = getelementptr inbounds i32, i32* %0, i64 %43
%45 = load i32, i32* %44
%46 = and i32 %45, 16777215
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 %46)
ret void
}