#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*/ parser_Abort(char *);
int /*<<< orphan*/ parser_str_to_upper(char *);
scalar_t__ strcmp(char *, char *);
int BuscaRegistrador(char *nome) {
  parser_str_to_upper(nome);
  if (strcmp(nome, "R0") == 0) {
    return 0;
  } else if (strcmp(nome, "R1") == 0) {
    return 1;
  } else if (strcmp(nome, "R2") == 0) {
    return 2;
  } else if (strcmp(nome, "R3") == 0) {
    return 3;
  } else if (strcmp(nome, "R4") == 0) {
    return 4;
  } else if (strcmp(nome, "R5") == 0) {
    return 5;
  } else if (strcmp(nome, "R6") == 0) {
    return 6;
  } else if (strcmp(nome, "R7") == 0) {
    return 7;
  } else if (strcmp(nome, "FR") == 0) {
    return 8;
  } else if (strcmp(nome, "SP") == 0) {
    return 9;
  } else {
    parser_Abort("Registrador invalido!");
  }
  return -1;
}


x86 assembly (clang, -O0):
<BuscaRegistrador>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <parser_str_to_upper@plt>
mov    -0x10(%rbp),%rdi
lea    0xeb0(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    116b <BuscaRegistrador+0x3b>
movl   $0x0,-0x4(%rbp)
jmp    1301 <BuscaRegistrador+0x1d1>
mov    -0x10(%rbp),%rdi
lea    0xe8d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1191 <BuscaRegistrador+0x61>
movl   $0x1,-0x4(%rbp)
jmp    1301 <BuscaRegistrador+0x1d1>
mov    -0x10(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11b7 <BuscaRegistrador+0x87>
movl   $0x2,-0x4(%rbp)
jmp    1301 <BuscaRegistrador+0x1d1>
mov    -0x10(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11dd <BuscaRegistrador+0xad>
movl   $0x3,-0x4(%rbp)
jmp    1301 <BuscaRegistrador+0x1d1>
mov    -0x10(%rbp),%rdi
lea    0xe24(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1203 <BuscaRegistrador+0xd3>
movl   $0x4,-0x4(%rbp)
jmp    1301 <BuscaRegistrador+0x1d1>
mov    -0x10(%rbp),%rdi
lea    0xe01(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1229 <BuscaRegistrador+0xf9>
movl   $0x5,-0x4(%rbp)
jmp    1301 <BuscaRegistrador+0x1d1>
mov    -0x10(%rbp),%rdi
lea    0xdde(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    124f <BuscaRegistrador+0x11f>
movl   $0x6,-0x4(%rbp)
jmp    1301 <BuscaRegistrador+0x1d1>
mov    -0x10(%rbp),%rdi
lea    0xdbb(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1275 <BuscaRegistrador+0x145>
movl   $0x7,-0x4(%rbp)
jmp    1301 <BuscaRegistrador+0x1d1>
mov    -0x10(%rbp),%rdi
lea    0xd98(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    129b <BuscaRegistrador+0x16b>
movl   $0x8,-0x4(%rbp)
jmp    1301 <BuscaRegistrador+0x1d1>
mov    -0x10(%rbp),%rdi
lea    0xd75(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    12c1 <BuscaRegistrador+0x191>
movl   $0x9,-0x4(%rbp)
jmp    1301 <BuscaRegistrador+0x1d1>
lea    0xd56(%rip),%rdi
call   1040 <parser_Abort@plt>
jmp    12d2 <BuscaRegistrador+0x1a2>
jmp    12d7 <BuscaRegistrador+0x1a7>
jmp    12dc <BuscaRegistrador+0x1ac>
jmp    12e1 <BuscaRegistrador+0x1b1>
jmp    12e6 <BuscaRegistrador+0x1b6>
jmp    12eb <BuscaRegistrador+0x1bb>
jmp    12f0 <BuscaRegistrador+0x1c0>
jmp    12f5 <BuscaRegistrador+0x1c5>
jmp    12fa <BuscaRegistrador+0x1ca>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BuscaRegistrador>:
push   %rbx
mov    %rdi,%rbx
call   1050 <parser_str_to_upper@plt>
lea    0xec0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     122c <BuscaRegistrador+0xfc>
lea    0xeab(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1230 <BuscaRegistrador+0x100>
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1237 <BuscaRegistrador+0x107>
lea    0xe81(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     123e <BuscaRegistrador+0x10e>
lea    0xe6c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1245 <BuscaRegistrador+0x115>
lea    0xe57(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     124c <BuscaRegistrador+0x11c>
lea    0xe42(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1253 <BuscaRegistrador+0x123>
lea    0xe31(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     125a <BuscaRegistrador+0x12a>
lea    0xe20(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1261 <BuscaRegistrador+0x131>
lea    0xe0f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1268 <BuscaRegistrador+0x138>
lea    0xdfe(%rip),%rdi
call   1040 <parser_Abort@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
ret
mov    $0x3,%eax
pop    %rbx
ret
mov    $0x4,%eax
pop    %rbx
ret
mov    $0x5,%eax
pop    %rbx
ret
mov    $0x6,%eax
pop    %rbx
ret
mov    $0x7,%eax
pop    %rbx
ret
mov    $0x8,%eax
pop    %rbx
ret
mov    $0x9,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"R0\00"
@.str.1 = [3 x i8] c"R1\00"
@.str.2 = [3 x i8] c"R2\00"
@.str.3 = [3 x i8] c"R3\00"
@.str.4 = [3 x i8] c"R4\00"
@.str.5 = [3 x i8] c"R5\00"
@.str.6 = [3 x i8] c"R6\00"
@.str.7 = [3 x i8] c"R7\00"
@.str.8 = [3 x i8] c"FR\00"
@.str.9 = [3 x i8] c"SP\00"
@.str.10 = [22 x i8] c"Registrador invalido!\00"
define i32 @BuscaRegistrador(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @parser_str_to_upper(i8* %4)
%6 = load i8*, i8** %3
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 0, i32* %2
br label %67
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 1, i32* %2
br label %67
15: ; preds = %10
%16 = load i8*, i8** %3
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 2, i32* %2
br label %67
20: ; preds = %15
%21 = load i8*, i8** %3
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 3, i32* %2
br label %67
25: ; preds = %20
%26 = load i8*, i8** %3
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
store i32 4, i32* %2
br label %67
30: ; preds = %25
%31 = load i8*, i8** %3
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 5, i32* %2
br label %67
35: ; preds = %30
%36 = load i8*, i8** %3
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %35
store i32 6, i32* %2
br label %67
40: ; preds = %35
%41 = load i8*, i8** %3
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %40
store i32 7, i32* %2
br label %67
45: ; preds = %40
%46 = load i8*, i8** %3
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %45
store i32 8, i32* %2
br label %67
50: ; preds = %45
%51 = load i8*, i8** %3
%52 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %50
store i32 9, i32* %2
br label %67
55: ; preds = %50
%56 = call i32 @parser_Abort(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
br label %57
57: ; preds = %55
br label %58
58: ; preds = %57
br label %59
59: ; preds = %58
br label %60
60: ; preds = %59
br label %61
61: ; preds = %60
br label %62
62: ; preds = %61
br label %63
63: ; preds = %62
br label %64
64: ; preds = %63
br label %65
65: ; preds = %64
br label %66
66: ; preds = %65
store i32 -1, i32* %2
br label %67
67: ; preds = %66, %54, %49, %44, %39, %34, %29, %24, %19, %14, %9
%68 = load i32, i32* %2
ret i32 %68
}

LLVM IR (-O2):
@.str = [3 x i8] c"R0\00"
@.str.1 = [3 x i8] c"R1\00"
@.str.2 = [3 x i8] c"R2\00"
@.str.3 = [3 x i8] c"R3\00"
@.str.4 = [3 x i8] c"R4\00"
@.str.5 = [3 x i8] c"R5\00"
@.str.6 = [3 x i8] c"R6\00"
@.str.7 = [3 x i8] c"R7\00"
@.str.8 = [3 x i8] c"FR\00"
@.str.9 = [3 x i8] c"SP\00"
@.str.10 = [22 x i8] c"Registrador invalido!\00"
define i32 @BuscaRegistrador(i8* %0) {
%2 = tail call i32 @parser_str_to_upper(i8* %0)
%3 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %34, label %5
5: ; preds = %1
%6 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %34, label %8
8: ; preds = %5
%9 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %34, label %11
11: ; preds = %8
%12 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %34, label %14
14: ; preds = %11
%15 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %34, label %17
17: ; preds = %14
%18 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %34, label %20
20: ; preds = %17
%21 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %34, label %23
23: ; preds = %20
%24 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %34, label %26
26: ; preds = %23
%27 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %34, label %29
29: ; preds = %26
%30 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %29
%33 = tail call i32 @parser_Abort(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.10, i64 0, i64 0))
br label %34
34: ; preds = %29, %26, %23, %20, %17, %14, %11, %8, %5, %1, %32
%35 = phi i32 [ -1, %32 ], [ 0, %1 ], [ 1, %5 ], [ 2, %8 ], [ 3, %11 ], [ 4, %14 ], [ 5, %17 ], [ 6, %20 ], [ 7, %23 ], [ 8, %26 ], [ 9, %29 ]
ret i32 %35
}