#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 */
char *AbbrevMode(char *);
char *AllocKey(char *, int, char *);
int /*<<< orphan*/ CheckModes(char *);
char *NormalMode(char *);
int /*<<< orphan*/ save_all_modes(char *, char *, char *, char *);
int /*<<< orphan*/ save_all_submodes(char *, char *, char *, char *);
char *Mode2Key(char *type, char *name, char *cond, int submode) {
  int c;
  char *abbrev = AbbrevMode(name);
  char *normal = NormalMode(name);
  char *tmp;
  CheckModes(normal);
  CheckModes(abbrev);
  switch (c = *type) {
  case 'b':
  case 'e':
  case 'i':
  case 's':
    break;
  case 'r':
    c = 'x';
  }
  save_all_modes(type, normal, abbrev, cond);
  if (submode)
    save_all_submodes(type, normal, abbrev, cond);
  tmp = AllocKey(normal, c, abbrev);
  return tmp;
}


x86 assembly (clang, -O0):
<Mode2Key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <AbbrevMode@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <NormalMode@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <CheckModes@plt>
mov    -0x28(%rbp),%rdi
call   1060 <CheckModes@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    %eax,-0x20(%rbp)
sub    $0x62,%eax
je     1202 <Mode2Key+0xa2>
jmp    11be <Mode2Key+0x5e>
mov    -0x3c(%rbp),%eax
sub    $0x65,%eax
je     1202 <Mode2Key+0xa2>
jmp    11cf <Mode2Key+0x6f>
mov    -0x3c(%rbp),%eax
sub    $0x69,%eax
je     1202 <Mode2Key+0xa2>
jmp    11e0 <Mode2Key+0x80>
mov    -0x3c(%rbp),%eax
sub    $0x72,%eax
je     1207 <Mode2Key+0xa7>
jmp    11f1 <Mode2Key+0x91>
mov    -0x3c(%rbp),%eax
sub    $0x73,%eax
jne    120e <Mode2Key+0xae>
jmp    1202 <Mode2Key+0xa2>
jmp    120e <Mode2Key+0xae>
movl   $0x78,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1050 <save_all_modes@plt>
cmpl   $0x0,-0x1c(%rbp)
je     1242 <Mode2Key+0xe2>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rcx
call   1080 <save_all_submodes@plt>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1070 <AllocKey@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Mode2Key>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r12
mov    %rsi,%rdi
call   1030 <AbbrevMode@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1040 <NormalMode@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <CheckModes@plt>
mov    %r15,%rdi
call   1060 <CheckModes@plt>
mov    (%r12),%r13b
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1050 <save_all_modes@plt>
test   %ebp,%ebp
je     11c6 <Mode2Key+0x66>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
call   1080 <save_all_submodes@plt>
cmp    $0x72,%r13b
movzbl %r13b,%eax
mov    $0x78,%ecx
cmovne %eax,%ecx
movsbl %cl,%esi
mov    %rbx,%rdi
mov    %r15,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <AllocKey@plt>

LLVM IR (-O0):
define i8* @Mode2Key(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%13 = load i8*, i8** %6
%14 = call i8* @AbbrevMode(i8* %13)
store i8* %14, i8** %10
%15 = load i8*, i8** %6
%16 = call i8* @NormalMode(i8* %15)
store i8* %16, i8** %11
%17 = load i8*, i8** %11
%18 = call i32 @CheckModes(i8* %17)
%19 = load i8*, i8** %10
%20 = call i32 @CheckModes(i8* %19)
%21 = load i8*, i8** %5
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
store i32 %23, i32* %9
switch i32 %23, label %26 [
i32 98, label %24
i32 101, label %24
i32 105, label %24
i32 115, label %24
i32 114, label %25
]
24: ; preds = %4, %4, %4, %4
br label %26
25: ; preds = %4
store i32 120, i32* %9
br label %26
26: ; preds = %25, %4, %24
%27 = load i8*, i8** %5
%28 = load i8*, i8** %11
%29 = load i8*, i8** %10
%30 = load i8*, i8** %7
%31 = call i32 @save_all_modes(i8* %27, i8* %28, i8* %29, i8* %30)
%32 = load i32, i32* %8
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %26
%35 = load i8*, i8** %5
%36 = load i8*, i8** %11
%37 = load i8*, i8** %10
%38 = load i8*, i8** %7
%39 = call i32 @save_all_submodes(i8* %35, i8* %36, i8* %37, i8* %38)
br label %40
40: ; preds = %34, %26
%41 = load i8*, i8** %11
%42 = load i32, i32* %9
%43 = load i8*, i8** %10
%44 = call i8* @AllocKey(i8* %41, i32 %42, i8* %43)
store i8* %44, i8** %12
%45 = load i8*, i8** %12
ret i8* %45
}

LLVM IR (-O2):
define i8* @Mode2Key(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i8* @AbbrevMode(i8* %1)
%6 = tail call i8* @NormalMode(i8* %1)
%7 = tail call i32 @CheckModes(i8* %6)
%8 = tail call i32 @CheckModes(i8* %5)
%9 = load i8, i8* %0
%10 = tail call i32 @save_all_modes(i8* %0, i8* %6, i8* %5, i8* %2)
%11 = icmp eq i32 %3, 0
br i1 %11, label %14, label %12
12: ; preds = %4
%13 = tail call i32 @save_all_submodes(i8* %0, i8* %6, i8* %5, i8* %2)
br label %14
14: ; preds = %12, %4
%15 = icmp eq i8 %9, 114
%16 = select i1 %15, i8 120, i8 %9
%17 = sext i8 %16 to i32
%18 = tail call i8* @AllocKey(i8* %6, i32 %17, i8* %5)
ret i8* %18
}