#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 *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int getRegisterNumber(char *register_name) {
  char *reg[] = {"A", "X", "L", "B", "S", "T", "F", "PC", "SW"};
  int reg_num[] = {0, 1, 2, 3, 4, 5, 6, 8, 9}, i;
  for (i = 0; i < 9; i++)
    if (!strcmp(reg[i], register_name))
      return reg_num[i];
  {
    printf("run: undefined register %s is found.\n", register_name);
    return -1;
  };
  return -1;
}


x86 assembly (clang, -O0):
<getRegisterNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x60(%rbp),%rdi
lea    0x2c86(%rip),%rsi
mov    $0x48,%edx
call   1050 <memcpy@plt>
lea    -0x90(%rbp),%rdi
lea    0xede(%rip),%rsi
mov    $0x24,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x94(%rbp)
cmpl   $0x9,-0x94(%rbp)
jge    11d0 <getRegisterNumber+0xa0>
movslq -0x94(%rbp),%rax
mov    -0x60(%rbp,%rax,8),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11b7 <getRegisterNumber+0x87>
movslq -0x94(%rbp),%rax
mov    -0x90(%rbp,%rax,4),%eax
mov    %eax,-0x4(%rbp)
jmp    11e7 <getRegisterNumber+0xb7>
jmp    11bc <getRegisterNumber+0x8c>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1176 <getRegisterNumber+0x46>
mov    -0x10(%rbp),%rsi
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getRegisterNumber>:
push   %rbx
mov    %rdi,%rbx
lea    0xed5(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11f5 <getRegisterNumber+0xd5>
lea    0xec0(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11f9 <getRegisterNumber+0xd9>
lea    0xeab(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1200 <getRegisterNumber+0xe0>
lea    0xe96(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1207 <getRegisterNumber+0xe7>
lea    0xe81(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     120e <getRegisterNumber+0xee>
lea    0xe70(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1215 <getRegisterNumber+0xf5>
lea    0xe5f(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     121c <getRegisterNumber+0xfc>
lea    0xe4e(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1223 <getRegisterNumber+0x103>
lea    0xe3e(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     122a <getRegisterNumber+0x10a>
lea    0xe2e(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret
xor    %eax,%eax
jmp    122f <getRegisterNumber+0x10f>
mov    $0x1,%eax
jmp    122f <getRegisterNumber+0x10f>
mov    $0x2,%eax
jmp    122f <getRegisterNumber+0x10f>
mov    $0x3,%eax
jmp    122f <getRegisterNumber+0x10f>
mov    $0x4,%eax
jmp    122f <getRegisterNumber+0x10f>
mov    $0x5,%eax
jmp    122f <getRegisterNumber+0x10f>
mov    $0x6,%eax
jmp    122f <getRegisterNumber+0x10f>
mov    $0x7,%eax
jmp    122f <getRegisterNumber+0x10f>
mov    $0x8,%eax
lea    0xe0a(%rip),%rcx
mov    (%rcx,%rax,4),%eax
pop    %rbx
ret

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.getRegisterNumber.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)]
@__const.getRegisterNumber.reg_num = [9 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 8, i32 9]
@.str.9 = [38 x i8] c"run: undefined register %s is found.\0A\00"
define i32 @getRegisterNumber(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [9 x i8*]
%5 = alloca [9 x i32]
%6 = alloca i32
store i8* %0, i8** %3
%7 = bitcast [9 x i8*]* %4 to i8*
%8 = bitcast [9 x i32]* %5 to i8*
store i32 0, i32* %6
br label %9
9: ; preds = %26, %1
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 9
br i1 %11, label %12, label %29
12: ; preds = %9
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [9 x i8*], [9 x i8*]* %4, i64 0, i64 %14
%16 = load i8*, i8** %15
%17 = load i8*, i8** %3
%18 = call i32 @strcmp(i8* %16, i8* %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %12
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [9 x i32], [9 x i32]* %5, i64 0, i64 %22
%24 = load i32, i32* %23
store i32 %24, i32* %2
br label %32
25: ; preds = %12
br label %26
26: ; preds = %25
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %9
29: ; preds = %9
%30 = load i8*, i8** %3
%31 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0), i8* %30)
store i32 -1, i32* %2
br label %32
32: ; preds = %29, %20
%33 = load i32, i32* %2
ret i32 %33
}

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"
@__const.getRegisterNumber.reg_num = [9 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 8, i32 9]
@.str.9 = [38 x i8] c"run: undefined register %s is found.\0A\00"
define i32 @getRegisterNumber(i8* %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %29, %26, %23, %20, %17, %14, %11, %8, %1
%5 = phi i64 [ 0, %1 ], [ 1, %8 ], [ 2, %11 ], [ 3, %14 ], [ 4, %17 ], [ 5, %20 ], [ 6, %23 ], [ 7, %26 ], [ 8, %29 ]
%6 = getelementptr inbounds [9 x i32], [9 x i32]* @__const.getRegisterNumber.reg_num, i64 0, i64 %5
%7 = load i32, i32* %6
br label %34
8: ; preds = %1
%9 = tail call i32 @strcmp(i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* dereferenceable(1) %0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %4, label %11
11: ; preds = %8
%12 = tail call i32 @strcmp(i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i8* dereferenceable(1) %0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %4, label %14
14: ; preds = %11
%15 = tail call i32 @strcmp(i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* dereferenceable(1) %0)
%16 = icmp eq i32 %15, 0
br i1 %16, label %4, label %17
17: ; preds = %14
%18 = tail call i32 @strcmp(i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* dereferenceable(1) %0)
%19 = icmp eq i32 %18, 0
br i1 %19, label %4, label %20
20: ; preds = %17
%21 = tail call i32 @strcmp(i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* dereferenceable(1) %0)
%22 = icmp eq i32 %21, 0
br i1 %22, label %4, label %23
23: ; preds = %20
%24 = tail call i32 @strcmp(i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* dereferenceable(1) %0)
%25 = icmp eq i32 %24, 0
br i1 %25, label %4, label %26
26: ; preds = %23
%27 = tail call i32 @strcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* dereferenceable(1) %0)
%28 = icmp eq i32 %27, 0
br i1 %28, label %4, label %29
29: ; preds = %26
%30 = tail call i32 @strcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* dereferenceable(1) %0)
%31 = icmp eq i32 %30, 0
br i1 %31, label %4, label %32
32: ; preds = %29
%33 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0), i8* %0)
br label %34
34: ; preds = %32, %4
%35 = phi i32 [ %7, %4 ], [ -1, %32 ]
ret i32 %35
}