#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 atoi(char *);
scalar_t__ strcmp(char *, char *);
int getRegArg(char *arg) {
  int argvalue;
  if (strcmp(arg, "BP") == 0 || strcmp(arg, "bp") == 0)
    return (28);
  else if (strcmp(arg, "SP") == 0 || strcmp(arg, "sp") == 0)
    return (29);
  else if (strcmp(arg, "IP") == 0 || strcmp(arg, "ip") == 0)
    return (30);
  else if (strcmp(arg, "PTBR") == 0 || strcmp(arg, "ptbr") == 0)
    return (31);
  else if (strcmp(arg, "PTLR") == 0 || strcmp(arg, "ptlr") == 0)
    return (32);
  else if (strcmp(arg, "EFR") == 0 || strcmp(arg, "efr") == 0)
    return (33);
  else
    argvalue = atoi(arg + 1);
  switch (arg[0]) {
  case 'R':
  case 'r':
    if (argvalue >= 0 && argvalue < 8)
      ;
    return (0 + argvalue);
    break;
  case 'S':
  case 's':
    if (argvalue >= 0 && argvalue < 16)
      ;
    return (8 + argvalue);
    break;
  case 'T':
  case 't':
    if (argvalue >= 0 && argvalue < 4)
      ;
    return (24 + argvalue);
    break;
  }
  return -1;
}


x86 assembly (clang, -O0):
<getRegArg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1160 <getRegArg+0x40>
mov    -0x10(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    116c <getRegArg+0x4c>
movl   $0x1c,-0x4(%rbp)
jmp    13be <getRegArg+0x29e>
mov    -0x10(%rbp),%rdi
lea    0xe8f(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11a0 <getRegArg+0x80>
mov    -0x10(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11ac <getRegArg+0x8c>
movl   $0x1d,-0x4(%rbp)
jmp    13be <getRegArg+0x29e>
mov    -0x10(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11e0 <getRegArg+0xc0>
mov    -0x10(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11ec <getRegArg+0xcc>
movl   $0x1e,-0x4(%rbp)
jmp    13be <getRegArg+0x29e>
mov    -0x10(%rbp),%rdi
lea    0xe1b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1220 <getRegArg+0x100>
mov    -0x10(%rbp),%rdi
lea    0xe06(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    122c <getRegArg+0x10c>
movl   $0x1f,-0x4(%rbp)
jmp    13be <getRegArg+0x29e>
mov    -0x10(%rbp),%rdi
lea    0xde5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1260 <getRegArg+0x140>
mov    -0x10(%rbp),%rdi
lea    0xdd0(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    126c <getRegArg+0x14c>
movl   $0x20,-0x4(%rbp)
jmp    13be <getRegArg+0x29e>
mov    -0x10(%rbp),%rdi
lea    0xdaf(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     12a0 <getRegArg+0x180>
mov    -0x10(%rbp),%rdi
lea    0xd99(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    12ac <getRegArg+0x18c>
movl   $0x21,-0x4(%rbp)
jmp    13be <getRegArg+0x29e>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
jmp    12c1 <getRegArg+0x1a1>
jmp    12c6 <getRegArg+0x1a6>
jmp    12cb <getRegArg+0x1ab>
jmp    12d0 <getRegArg+0x1b0>
jmp    12d5 <getRegArg+0x1b5>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
sub    $0x52,%eax
je     1342 <getRegArg+0x222>
jmp    12ed <getRegArg+0x1cd>
mov    -0x18(%rbp),%eax
sub    $0x53,%eax
je     1369 <getRegArg+0x249>
jmp    12fe <getRegArg+0x1de>
mov    -0x18(%rbp),%eax
sub    $0x54,%eax
je     1390 <getRegArg+0x270>
jmp    130f <getRegArg+0x1ef>
mov    -0x18(%rbp),%eax
sub    $0x72,%eax
je     1342 <getRegArg+0x222>
jmp    1320 <getRegArg+0x200>
mov    -0x18(%rbp),%eax
sub    $0x73,%eax
je     1369 <getRegArg+0x249>
jmp    1331 <getRegArg+0x211>
mov    -0x18(%rbp),%eax
sub    $0x74,%eax
je     1390 <getRegArg+0x270>
jmp    13b7 <getRegArg+0x297>
cmpl   $0x0,-0x14(%rbp)
jl     135b <getRegArg+0x23b>
cmpl   $0x8,-0x14(%rbp)
jge    135b <getRegArg+0x23b>
jmp    135b <getRegArg+0x23b>
mov    -0x14(%rbp),%eax
add    $0x0,%eax
mov    %eax,-0x4(%rbp)
jmp    13be <getRegArg+0x29e>
cmpl   $0x0,-0x14(%rbp)
jl     1382 <getRegArg+0x262>
cmpl   $0x10,-0x14(%rbp)
jge    1382 <getRegArg+0x262>
jmp    1382 <getRegArg+0x262>
mov    -0x14(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x4(%rbp)
jmp    13be <getRegArg+0x29e>
cmpl   $0x0,-0x14(%rbp)
jl     13a9 <getRegArg+0x289>
cmpl   $0x4,-0x14(%rbp)
jge    13a9 <getRegArg+0x289>
jmp    13a9 <getRegArg+0x289>
mov    -0x14(%rbp),%eax
add    $0x18,%eax
mov    %eax,-0x4(%rbp)
jmp    13be <getRegArg+0x29e>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getRegArg>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xed3(%rip),%rsi
call   1030 <strcmp@plt>
mov    $0x1c,%ebp
test   %rax,%rax
je     12ae <getRegArg+0x18e>
lea    0xebc(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12ae <getRegArg+0x18e>
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    $0x1d,%ebp
test   %rax,%rax
je     12ae <getRegArg+0x18e>
lea    0xe8d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12ae <getRegArg+0x18e>
lea    0xe78(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    $0x1e,%ebp
test   %rax,%rax
je     12ae <getRegArg+0x18e>
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12ae <getRegArg+0x18e>
lea    0xe49(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    $0x1f,%ebp
test   %rax,%rax
je     12ae <getRegArg+0x18e>
lea    0xe31(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12ae <getRegArg+0x18e>
lea    0xe1e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    $0x20,%ebp
test   %rax,%rax
je     12ae <getRegArg+0x18e>
lea    0xe06(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12ae <getRegArg+0x18e>
lea    0xdf3(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    $0x21,%ebp
test   %rax,%rax
je     12ae <getRegArg+0x18e>
lea    0xdde(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     12ae <getRegArg+0x18e>
lea    0x1(%rbx),%rdi
call   1040 <atoi@plt>
mov    %eax,%ebp
movsbl (%rbx),%eax
add    $0xffffffae,%eax
cmp    $0x22,%eax
ja     12a9 <getRegArg+0x189>
movabs $0x100000001,%rcx
bt     %rax,%rcx
jb     12ae <getRegArg+0x18e>
movabs $0x200000002,%rcx
bt     %rax,%rcx
jb     12a4 <getRegArg+0x184>
movabs $0x400000004,%rcx
bt     %rax,%rcx
jae    12a9 <getRegArg+0x189>
add    $0x18,%ebp
jmp    12ae <getRegArg+0x18e>
add    $0x8,%ebp
jmp    12ae <getRegArg+0x18e>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"BP\00"
@.str.1 = [3 x i8] c"bp\00"
@.str.2 = [3 x i8] c"SP\00"
@.str.3 = [3 x i8] c"sp\00"
@.str.4 = [3 x i8] c"IP\00"
@.str.5 = [3 x i8] c"ip\00"
@.str.6 = [5 x i8] c"PTBR\00"
@.str.7 = [5 x i8] c"ptbr\00"
@.str.8 = [5 x i8] c"PTLR\00"
@.str.9 = [5 x i8] c"ptlr\00"
@.str.10 = [4 x i8] c"EFR\00"
@.str.11 = [4 x i8] c"efr\00"
define i32 @getRegArg(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8, %1
store i32 28, i32* %2
br label %103
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17, %13
store i32 29, i32* %2
br label %103
22: ; preds = %17
%23 = load i8*, i8** %3
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %30, label %26
26: ; preds = %22
%27 = load i8*, i8** %3
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %26, %22
store i32 30, i32* %2
br label %103
31: ; preds = %26
%32 = load i8*, i8** %3
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %39, label %35
35: ; preds = %31
%36 = load i8*, i8** %3
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %35, %31
store i32 31, i32* %2
br label %103
40: ; preds = %35
%41 = load i8*, i8** %3
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %40
%45 = load i8*, i8** %3
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %44, %40
store i32 32, i32* %2
br label %103
49: ; preds = %44
%50 = load i8*, i8** %3
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %57, label %53
53: ; preds = %49
%54 = load i8*, i8** %3
%55 = call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %53, %49
store i32 33, i32* %2
br label %103
58: ; preds = %53
%59 = load i8*, i8** %3
%60 = getelementptr inbounds i8, i8* %59, i64 1
%61 = call i32 @atoi(i8* %60)
store i32 %61, i32* %4
br label %62
62: ; preds = %58
br label %63
63: ; preds = %62
br label %64
64: ; preds = %63
br label %65
65: ; preds = %64
br label %66
66: ; preds = %65
br label %67
67: ; preds = %66
%68 = load i8*, i8** %3
%69 = getelementptr inbounds i8, i8* %68, i64 0
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
switch i32 %71, label %102 [
i32 82, label %72
i32 114, label %72
i32 83, label %82
i32 115, label %82
i32 84, label %92
i32 116, label %92
]
72: ; preds = %67, %67
%73 = load i32, i32* %4
%74 = icmp sge i32 %73, 0
br i1 %74, label %75, label %79
75: ; preds = %72
%76 = load i32, i32* %4
%77 = icmp slt i32 %76, 8
br i1 %77, label %78, label %79
78: ; preds = %75
br label %79
79: ; preds = %78, %75, %72
%80 = load i32, i32* %4
%81 = add nsw i32 0, %80
store i32 %81, i32* %2
br label %103
82: ; preds = %67, %67
%83 = load i32, i32* %4
%84 = icmp sge i32 %83, 0
br i1 %84, label %85, label %89
85: ; preds = %82
%86 = load i32, i32* %4
%87 = icmp slt i32 %86, 16
br i1 %87, label %88, label %89
88: ; preds = %85
br label %89
89: ; preds = %88, %85, %82
%90 = load i32, i32* %4
%91 = add nsw i32 8, %90
store i32 %91, i32* %2
br label %103
92: ; preds = %67, %67
%93 = load i32, i32* %4
%94 = icmp sge i32 %93, 0
br i1 %94, label %95, label %99
95: ; preds = %92
%96 = load i32, i32* %4
%97 = icmp slt i32 %96, 4
br i1 %97, label %98, label %99
98: ; preds = %95
br label %99
99: ; preds = %98, %95, %92
%100 = load i32, i32* %4
%101 = add nsw i32 24, %100
store i32 %101, i32* %2
br label %103
102: ; preds = %67
store i32 -1, i32* %2
br label %103
103: ; preds = %102, %99, %89, %79, %57, %48, %39, %30, %21, %12
%104 = load i32, i32* %2
ret i32 %104
}

LLVM IR (-O2):
@.str = [3 x i8] c"BP\00"
@.str.1 = [3 x i8] c"bp\00"
@.str.2 = [3 x i8] c"SP\00"
@.str.3 = [3 x i8] c"sp\00"
@.str.4 = [3 x i8] c"IP\00"
@.str.5 = [3 x i8] c"ip\00"
@.str.6 = [5 x i8] c"PTBR\00"
@.str.7 = [5 x i8] c"ptbr\00"
@.str.8 = [5 x i8] c"PTLR\00"
@.str.9 = [5 x i8] c"ptlr\00"
@.str.10 = [4 x i8] c"EFR\00"
@.str.11 = [4 x i8] c"efr\00"
define i32 @getRegArg(i8* %0) {
%2 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %47, label %4
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %47, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %47, label %10
10: ; preds = %7
%11 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %47, label %13
13: ; preds = %10
%14 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %47, label %16
16: ; preds = %13
%17 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %47, label %19
19: ; preds = %16
%20 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %47, label %22
22: ; preds = %19
%23 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %47, label %25
25: ; preds = %22
%26 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %47, label %28
28: ; preds = %25
%29 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %47, label %31
31: ; preds = %28
%32 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %47, label %34
34: ; preds = %31
%35 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %47, label %37
37: ; preds = %34
%38 = getelementptr inbounds i8, i8* %0, i64 1
%39 = tail call i32 @atoi(i8* %38)
%40 = load i8, i8* %0
%41 = sext i8 %40 to i32
switch i32 %41, label %46 [
i32 82, label %47
i32 114, label %47
i32 83, label %42
i32 115, label %42
i32 84, label %44
i32 116, label %44
]
42: ; preds = %37, %37
%43 = add nsw i32 %39, 8
br label %47
44: ; preds = %37, %37
%45 = add nsw i32 %39, 24
br label %47
46: ; preds = %37
br label %47
47: ; preds = %37, %37, %31, %34, %25, %28, %19, %22, %13, %16, %7, %10, %1, %4, %46, %44, %42
%48 = phi i32 [ -1, %46 ], [ %45, %44 ], [ %43, %42 ], [ 28, %4 ], [ 28, %1 ], [ 29, %10 ], [ 29, %7 ], [ 30, %16 ], [ 30, %13 ], [ 31, %22 ], [ 31, %19 ], [ 32, %28 ], [ 32, %25 ], [ 33, %34 ], [ 33, %31 ], [ %39, %37 ], [ %39, %37 ]
ret i32 %48
}