#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 */
scalar_t__ strcasecmp(char const *, char *);
int reg16(const char *name) {
  if (!name)
    return (-1);
  if (strcasecmp(name, "PC") == 0)
    return (0);
  if (strcasecmp(name, "AF") == 0)
    return (2);
  if (strcasecmp(name, "BC") == 0)
    return (4);
  if (strcasecmp(name, "DE") == 0)
    return (6);
  if (strcasecmp(name, "HL") == 0)
    return (8);
  if (strcasecmp(name, "IX") == 0)
    return (10);
  if (strcasecmp(name, "IY") == 0)
    return (12);
  if (strcasecmp(name, "SP") == 0)
    return (16);
  if (strcasecmp(name, "AF'") == 0)
    return (18);
  if (strcasecmp(name, "BC'") == 0)
    return (20);
  if (strcasecmp(name, "DE'") == 0)
    return (22);
  if (strcasecmp(name, "HL'") == 0)
    return (24);
  return (-1);
}


x86 assembly (clang, -O0):
<reg16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <reg16+0x23>
movl   $0xffffffff,-0x4(%rbp)
jmp    1302 <reg16+0x1f2>
mov    -0x10(%rbp),%rdi
lea    0xec2(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1159 <reg16+0x49>
movl   $0x0,-0x4(%rbp)
jmp    1302 <reg16+0x1f2>
mov    -0x10(%rbp),%rdi
lea    0xe9f(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    117f <reg16+0x6f>
movl   $0x2,-0x4(%rbp)
jmp    1302 <reg16+0x1f2>
mov    -0x10(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11a5 <reg16+0x95>
movl   $0x4,-0x4(%rbp)
jmp    1302 <reg16+0x1f2>
mov    -0x10(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11cb <reg16+0xbb>
movl   $0x6,-0x4(%rbp)
jmp    1302 <reg16+0x1f2>
mov    -0x10(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    11f1 <reg16+0xe1>
movl   $0x8,-0x4(%rbp)
jmp    1302 <reg16+0x1f2>
mov    -0x10(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1217 <reg16+0x107>
movl   $0xa,-0x4(%rbp)
jmp    1302 <reg16+0x1f2>
mov    -0x10(%rbp),%rdi
lea    0xdf0(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    123d <reg16+0x12d>
movl   $0xc,-0x4(%rbp)
jmp    1302 <reg16+0x1f2>
mov    -0x10(%rbp),%rdi
lea    0xdcd(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1263 <reg16+0x153>
movl   $0x10,-0x4(%rbp)
jmp    1302 <reg16+0x1f2>
mov    -0x10(%rbp),%rdi
lea    0xdaa(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1289 <reg16+0x179>
movl   $0x12,-0x4(%rbp)
jmp    1302 <reg16+0x1f2>
mov    -0x10(%rbp),%rdi
lea    0xd88(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    12af <reg16+0x19f>
movl   $0x14,-0x4(%rbp)
jmp    1302 <reg16+0x1f2>
mov    -0x10(%rbp),%rdi
lea    0xd66(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    12d5 <reg16+0x1c5>
movl   $0x16,-0x4(%rbp)
jmp    1302 <reg16+0x1f2>
mov    -0x10(%rbp),%rdi
lea    0xd44(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    12fb <reg16+0x1eb>
movl   $0x18,-0x4(%rbp)
jmp    1302 <reg16+0x1f2>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reg16>:
push   %rbx
test   %rdi,%rdi
je     122f <reg16+0x11f>
mov    %rdi,%rbx
lea    0xedc(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1236 <reg16+0x126>
lea    0xeca(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     123a <reg16+0x12a>
lea    0xeb5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1241 <reg16+0x131>
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1248 <reg16+0x138>
lea    0xe8b(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     124f <reg16+0x13f>
lea    0xe76(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1256 <reg16+0x146>
lea    0xe61(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     125d <reg16+0x14d>
lea    0xe4c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1264 <reg16+0x154>
lea    0xe37(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     126b <reg16+0x15b>
lea    0xe27(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1272 <reg16+0x162>
lea    0xe17(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1279 <reg16+0x169>
lea    0xe07(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
neg    %rax
sbb    %eax,%eax
or     $0x18,%eax
pop    %rbx
ret
mov    $0xffffffff,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
ret
mov    $0x4,%eax
pop    %rbx
ret
mov    $0x6,%eax
pop    %rbx
ret
mov    $0x8,%eax
pop    %rbx
ret
mov    $0xa,%eax
pop    %rbx
ret
mov    $0xc,%eax
pop    %rbx
ret
mov    $0x10,%eax
pop    %rbx
ret
mov    $0x12,%eax
pop    %rbx
ret
mov    $0x14,%eax
pop    %rbx
ret
mov    $0x16,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"PC\00"
@.str.1 = [3 x i8] c"AF\00"
@.str.2 = [3 x i8] c"BC\00"
@.str.3 = [3 x i8] c"DE\00"
@.str.4 = [3 x i8] c"HL\00"
@.str.5 = [3 x i8] c"IX\00"
@.str.6 = [3 x i8] c"IY\00"
@.str.7 = [3 x i8] c"SP\00"
@.str.8 = [4 x i8] c"AF'\00"
@.str.9 = [4 x i8] c"BC'\00"
@.str.10 = [4 x i8] c"DE'\00"
@.str.11 = [4 x i8] c"HL'\00"
define i32 @reg16(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp ne i8* %4, null
br i1 %5, label %7, label %6
6: ; preds = %1
store i32 -1, i32* %2
br label %68
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i64 @strcasecmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
store i32 0, i32* %2
br label %68
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i64 @strcasecmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 2, i32* %2
br label %68
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = call i64 @strcasecmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 4, i32* %2
br label %68
22: ; preds = %17
%23 = load i8*, i8** %3
%24 = call i64 @strcasecmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i32 6, i32* %2
br label %68
27: ; preds = %22
%28 = load i8*, i8** %3
%29 = call i64 @strcasecmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 8, i32* %2
br label %68
32: ; preds = %27
%33 = load i8*, i8** %3
%34 = call i64 @strcasecmp(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 10, i32* %2
br label %68
37: ; preds = %32
%38 = load i8*, i8** %3
%39 = call i64 @strcasecmp(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %37
store i32 12, i32* %2
br label %68
42: ; preds = %37
%43 = load i8*, i8** %3
%44 = call i64 @strcasecmp(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %42
store i32 16, i32* %2
br label %68
47: ; preds = %42
%48 = load i8*, i8** %3
%49 = call i64 @strcasecmp(i8* %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %47
store i32 18, i32* %2
br label %68
52: ; preds = %47
%53 = load i8*, i8** %3
%54 = call i64 @strcasecmp(i8* %53, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %57
56: ; preds = %52
store i32 20, i32* %2
br label %68
57: ; preds = %52
%58 = load i8*, i8** %3
%59 = call i64 @strcasecmp(i8* %58, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %57
store i32 22, i32* %2
br label %68
62: ; preds = %57
%63 = load i8*, i8** %3
%64 = call i64 @strcasecmp(i8* %63, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %62
store i32 24, i32* %2
br label %68
67: ; preds = %62
store i32 -1, i32* %2
br label %68
68: ; preds = %67, %66, %61, %56, %51, %46, %41, %36, %31, %26, %21, %16, %11, %6
%69 = load i32, i32* %2
ret i32 %69
}

LLVM IR (-O2):
@.str = [3 x i8] c"PC\00"
@.str.1 = [3 x i8] c"AF\00"
@.str.2 = [3 x i8] c"BC\00"
@.str.3 = [3 x i8] c"DE\00"
@.str.4 = [3 x i8] c"HL\00"
@.str.5 = [3 x i8] c"IX\00"
@.str.6 = [3 x i8] c"IY\00"
@.str.7 = [3 x i8] c"SP\00"
@.str.8 = [4 x i8] c"AF'\00"
@.str.9 = [4 x i8] c"BC'\00"
@.str.10 = [4 x i8] c"DE'\00"
@.str.11 = [4 x i8] c"HL'\00"
define i32 @reg16(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %40, label %3
3: ; preds = %1
%4 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %40, label %6
6: ; preds = %3
%7 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %40, label %9
9: ; preds = %6
%10 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %40, label %12
12: ; preds = %9
%13 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %40, label %15
15: ; preds = %12
%16 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %40, label %18
18: ; preds = %15
%19 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %40, label %21
21: ; preds = %18
%22 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %40, label %24
24: ; preds = %21
%25 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %40, label %27
27: ; preds = %24
%28 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %40, label %30
30: ; preds = %27
%31 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %40, label %33
33: ; preds = %30
%34 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %40, label %36
36: ; preds = %33
%37 = tail call i64 @strcasecmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
%39 = select i1 %38, i32 24, i32 -1
br label %40
40: ; preds = %36, %33, %30, %27, %24, %21, %18, %15, %12, %9, %6, %3, %1
%41 = phi i32 [ -1, %1 ], [ 0, %3 ], [ 2, %6 ], [ 4, %9 ], [ 6, %12 ], [ 8, %15 ], [ 10, %18 ], [ 12, %21 ], [ 16, %24 ], [ 18, %27 ], [ 20, %30 ], [ 22, %33 ], [ %39, %36 ]
ret i32 %41
}