#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 */
typedef int /*<<< orphan*/ regs_w;
typedef int /*<<< orphan*/ regs_b;

/* Variables and functions */
int /*<<< orphan*/ strcmp(char const *, char const *);
const char *map_reg(const char *reg) {
  const char *regs_f[] = {"eax", "ebx", "ecx", "edx", "esi", "edi"};
  const char *regs_w[] = {"ax", "bx", "cx", "dx", "si", "di"};
  const char *regs_b[] = {"al", "bl", "cl", "dl"};
  int i;
  for (i = 0; i < (sizeof(regs_w) / sizeof(regs_w[0])); i++)
    if (!strcmp(reg, regs_w[i]))
      return regs_f[i];
  for (i = 0; i < (sizeof(regs_b) / sizeof(regs_b[0])); i++)
    if (!strcmp(reg, regs_b[i]))
      return regs_f[i];
  return reg;
}


x86 assembly (clang, -O0):
<map_reg>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
lea    0xeba(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xeb3(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xeac(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xea5(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe9e(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe97(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
lea    0xe69(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xe62(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    0xe5b(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xe54(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0xe4d(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xe46(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0x2c26(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    0x2c20(%rip),%rax
mov    %rax,-0x88(%rbp)
mov    0x2c1a(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0x2c17(%rip),%rax
mov    %rax,-0x78(%rbp)
movl   $0x0,-0x94(%rbp)
movslq -0x94(%rbp),%rax
cmp    $0x6,%rax
jae    126c <map_reg+0x14c>
mov    -0x10(%rbp),%rdi
movslq -0x94(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1253 <map_reg+0x133>
movslq -0x94(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rax
mov    %rax,-0x8(%rbp)
jmp    12de <map_reg+0x1be>
jmp    1258 <map_reg+0x138>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    120f <map_reg+0xef>
movl   $0x0,-0x94(%rbp)
movslq -0x94(%rbp),%rax
cmp    $0x4,%rax
jae    12d6 <map_reg+0x1b6>
mov    -0x10(%rbp),%rdi
movslq -0x94(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rsi
ff
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    12bd <map_reg+0x19d>
movslq -0x94(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rax
mov    %rax,-0x8(%rbp)
jmp    12de <map_reg+0x1be>
jmp    12c2 <map_reg+0x1a2>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1276 <map_reg+0x156>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<map_reg>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdi,%rbx
lea    0xedf(%rip),%rax
mov    %rax,(%rsp)
lea    0xed8(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xed0(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xec8(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0xec0(%rip),%rax
mov    %rax,0x20(%rsp)
lea    0xeb8(%rip),%rax
mov    %rax,0x28(%rsp)
lea    0xe99(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1244 <map_reg+0x134>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    $0x1,%r14d
test   %eax,%eax
je     1267 <map_reg+0x157>
lea    0xe70(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1249 <map_reg+0x139>
lea    0xe5d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1251 <map_reg+0x141>
lea    0xe4a(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1259 <map_reg+0x149>
lea    0xe37(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1261 <map_reg+0x151>
lea    0xe27(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1244 <map_reg+0x134>
lea    0xe17(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1267 <map_reg+0x157>
lea    0xe07(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    $0x2,%r14d
test   %eax,%eax
je     1267 <map_reg+0x157>
lea    0xdf1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    $0x3,%r14d
test   %eax,%eax
jne    126b <map_reg+0x15b>
jmp    1267 <map_reg+0x157>
xor    %r14d,%r14d
jmp    1267 <map_reg+0x157>
mov    $0x2,%r14d
jmp    1267 <map_reg+0x157>
mov    $0x3,%r14d
jmp    1267 <map_reg+0x157>
mov    $0x4,%r14d
jmp    1267 <map_reg+0x157>
mov    $0x5,%r14d
mov    (%rsp,%r14,8),%rbx
mov    %rbx,%rax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"eax\00"
@.str.1 = [4 x i8] c"ebx\00"
@.str.2 = [4 x i8] c"ecx\00"
@.str.3 = [4 x i8] c"edx\00"
@.str.4 = [4 x i8] c"esi\00"
@.str.5 = [4 x i8] c"edi\00"
@.str.6 = [3 x i8] c"ax\00"
@.str.7 = [3 x i8] c"bx\00"
@.str.8 = [3 x i8] c"cx\00"
@.str.9 = [3 x i8] c"dx\00"
@.str.10 = [3 x i8] c"si\00"
@.str.11 = [3 x i8] c"di\00"
@.str.12 = [3 x i8] c"al\00"
@.str.13 = [3 x i8] c"bl\00"
@.str.14 = [3 x i8] c"cl\00"
@.str.15 = [3 x i8] c"dl\00"
@__const.map_reg.regs_b = [4 x i8*] [i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i32 0, i32 0)]
define i8* @map_reg(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [6 x i8*]
%5 = alloca [6 x i8*]
%6 = alloca [4 x i8*]
%7 = alloca i32
store i8* %0, i8** %3
%8 = bitcast [6 x i8*]* %4 to i8*
%9 = bitcast i8* %8 to [6 x i8*]*
%10 = getelementptr inbounds [6 x i8*], [6 x i8*]* %9, i32 0, i32 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %9, i32 0, i32 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %9, i32 0, i32 2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [6 x i8*], [6 x i8*]* %9, i32 0, i32 3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [6 x i8*], [6 x i8*]* %9, i32 0, i32 4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i32 0, i32 0), i8** %14
%15 = getelementptr inbounds [6 x i8*], [6 x i8*]* %9, i32 0, i32 5
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i8** %15
%16 = bitcast [6 x i8*]* %5 to i8*
%17 = bitcast i8* %16 to [6 x i8*]*
%18 = getelementptr inbounds [6 x i8*], [6 x i8*]* %17, i32 0, i32 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i32 0, i32 0), i8** %18
%19 = getelementptr inbounds [6 x i8*], [6 x i8*]* %17, i32 0, i32 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i32 0, i32 0), i8** %19
%20 = getelementptr inbounds [6 x i8*], [6 x i8*]* %17, i32 0, i32 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i32 0, i32 0), i8** %20
%21 = getelementptr inbounds [6 x i8*], [6 x i8*]* %17, i32 0, i32 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i32 0, i32 0), i8** %21
%22 = getelementptr inbounds [6 x i8*], [6 x i8*]* %17, i32 0, i32 4
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i32 0, i32 0), i8** %22
%23 = getelementptr inbounds [6 x i8*], [6 x i8*]* %17, i32 0, i32 5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i32 0, i32 0), i8** %23
%24 = bitcast [4 x i8*]* %6 to i8*
store i32 0, i32* %7
br label %25
25: ; preds = %43, %1
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = icmp ult i64 %27, 6
br i1 %28, label %29, label %46
29: ; preds = %25
%30 = load i8*, i8** %3
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [6 x i8*], [6 x i8*]* %5, i64 0, i64 %32
%34 = load i8*, i8** %33
%35 = call i32 @strcmp(i8* %30, i8* %34)
%36 = icmp ne i32 %35, 0
br i1 %36, label %42, label %37
37: ; preds = %29
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 %39
%41 = load i8*, i8** %40
store i8* %41, i8** %2
br label %70
42: ; preds = %29
br label %43
43: ; preds = %42
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %25
46: ; preds = %25
store i32 0, i32* %7
br label %47
47: ; preds = %65, %46
%48 = load i32, i32* %7
%49 = sext i32 %48 to i64
%50 = icmp ult i64 %49, 4
br i1 %50, label %51, label %68
51: ; preds = %47
%52 = load i8*, i8** %3
%53 = load i32, i32* %7
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [4 x i8*], [4 x i8*]* %6, i64 0, i64 %54
%56 = load i8*, i8** %55
%57 = call i32 @strcmp(i8* %52, i8* %56)
%58 = icmp ne i32 %57, 0
br i1 %58, label %64, label %59
59: ; preds = %51
%60 = load i32, i32* %7
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [6 x i8*], [6 x i8*]* %4, i64 0, i64 %61
%63 = load i8*, i8** %62
store i8* %63, i8** %2
br label %70
64: ; preds = %51
br label %65
65: ; preds = %64
%66 = load i32, i32* %7
%67 = add nsw i32 %66, 1
store i32 %67, i32* %7
br label %47
68: ; preds = %47
%69 = load i8*, i8** %3
store i8* %69, i8** %2
br label %70
70: ; preds = %68, %59, %37
%71 = load i8*, i8** %2
ret i8* %71
}

LLVM IR (-O2):
@.str = [4 x i8] c"eax\00"
@.str.1 = [4 x i8] c"ebx\00"
@.str.2 = [4 x i8] c"ecx\00"
@.str.3 = [4 x i8] c"edx\00"
@.str.4 = [4 x i8] c"esi\00"
@.str.5 = [4 x i8] c"edi\00"
@.str.6 = [3 x i8] c"ax\00"
@.str.7 = [3 x i8] c"bx\00"
@.str.8 = [3 x i8] c"cx\00"
@.str.9 = [3 x i8] c"dx\00"
@.str.10 = [3 x i8] c"si\00"
@.str.11 = [3 x i8] c"di\00"
@.str.12 = [3 x i8] c"al\00"
@.str.13 = [3 x i8] c"bl\00"
@.str.14 = [3 x i8] c"cl\00"
@.str.15 = [3 x i8] c"dl\00"
define i8* @map_reg(i8* %0) {
%2 = alloca [6 x i8*]
%3 = bitcast [6 x i8*]* %2 to i8*
%4 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %5
%6 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %6
%7 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %7
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 5
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %9
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %39, label %12
12: ; preds = %1
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %39, label %15
15: ; preds = %12
%16 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %39, label %18
18: ; preds = %15
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %39, label %21
21: ; preds = %18
%22 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %39, label %24
24: ; preds = %21
%25 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %39, label %27
27: ; preds = %24
%28 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%29 = icmp eq i32 %28, 0
br i1 %29, label %39, label %30
30: ; preds = %27
%31 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
%32 = icmp eq i32 %31, 0
br i1 %32, label %39, label %33
33: ; preds = %30
%34 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
%35 = icmp eq i32 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %33
%37 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0))
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %27, %30, %33, %36, %1, %12, %15, %18, %21, %24
%40 = phi i64 [ 0, %1 ], [ 1, %12 ], [ 2, %15 ], [ 3, %18 ], [ 4, %21 ], [ 5, %24 ], [ 0, %27 ], [ 1, %30 ], [ 2, %33 ], [ 3, %36 ]
%41 = getelementptr inbounds [6 x i8*], [6 x i8*]* %2, i64 0, i64 %40
%42 = load i8*, i8** %41
br label %43
43: ; preds = %39, %36
%44 = phi i8* [ %0, %36 ], [ %42, %39 ]
ret i8* %44
}