#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 char_analysis(unsigned char);
unsigned char char_value(unsigned char _c) {
  int res;
  res = char_analysis(_c);
  switch (res) {
  case 4:
    return 1;
  case 3:
    return 2;
  case 2:
    return (_c - '0' + 3);
  case 1:
    return (_c - 'a' + 13);
  case 5:
    return 39;
  }
  return 0;
}


x86 assembly (clang, -O0):
<char_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%edi
call   1030 <char_analysis@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4,%eax
ja     1192 <char_value+0x82>
mov    -0x10(%rbp),%rax
lea    0xeb6(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x1,-0x1(%rbp)
jmp    1196 <char_value+0x86>
movb   $0x2,-0x1(%rbp)
jmp    1196 <char_value+0x86>
movzbl -0x2(%rbp),%eax
sub    $0x30,%eax
add    $0x3,%eax
mov    %al,-0x1(%rbp)
jmp    1196 <char_value+0x86>
movzbl -0x2(%rbp),%eax
sub    $0x61,%eax
add    $0xd,%eax
mov    %al,-0x1(%rbp)
jmp    1196 <char_value+0x86>
movb   $0x27,-0x1(%rbp)
jmp    1196 <char_value+0x86>
movb   $0x0,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<char_value>:
push   %rbx
mov    %edi,%ebx
call   1030 <char_analysis@plt>
mov    %eax,%ecx
add    $0xffffffff,%ecx
cmp    $0x4,%ecx
ja     1139 <char_value+0x29>
mov    $0x1,%al
lea    0xed5(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
add    $0xac,%bl
jmp    1140 <char_value+0x30>
xor    %eax,%eax
pop    %rbx
ret
add    $0xd3,%bl
mov    %ebx,%eax
pop    %rbx
ret
mov    $0x2,%al
pop    %rbx
ret
mov    $0x27,%al
pop    %rbx
ret

LLVM IR (-O0):
define zeroext i8 @char_value(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
%4 = alloca i32
store i8 %0, i8* %3
%5 = load i8, i8* %3
%6 = call i32 @char_analysis(i8 zeroext %5)
store i32 %6, i32* %4
%7 = load i32, i32* %4
switch i32 %7, label %23 [
i32 4, label %8
i32 3, label %9
i32 2, label %10
i32 1, label %16
i32 5, label %22
]
8: ; preds = %1
store i8 1, i8* %2
br label %24
9: ; preds = %1
store i8 2, i8* %2
br label %24
10: ; preds = %1
%11 = load i8, i8* %3
%12 = zext i8 %11 to i32
%13 = sub nsw i32 %12, 48
%14 = add nsw i32 %13, 3
%15 = trunc i32 %14 to i8
store i8 %15, i8* %2
br label %24
16: ; preds = %1
%17 = load i8, i8* %3
%18 = zext i8 %17 to i32
%19 = sub nsw i32 %18, 97
%20 = add nsw i32 %19, 13
%21 = trunc i32 %20 to i8
store i8 %21, i8* %2
br label %24
22: ; preds = %1
store i8 39, i8* %2
br label %24
23: ; preds = %1
store i8 0, i8* %2
br label %24
24: ; preds = %23, %22, %16, %10, %9, %8
%25 = load i8, i8* %2
ret i8 %25
}

LLVM IR (-O2):
define zeroext i8 @char_value(i8 zeroext %0) {
%2 = tail call i32 @char_analysis(i8 zeroext %0)
switch i32 %2, label %9 [
i32 4, label %10
i32 3, label %3
i32 2, label %4
i32 1, label %6
i32 5, label %8
]
3: ; preds = %1
br label %10
4: ; preds = %1
%5 = add i8 %0, -45
br label %10
6: ; preds = %1
%7 = add i8 %0, -84
br label %10
8: ; preds = %1
br label %10
9: ; preds = %1
br label %10
10: ; preds = %1, %9, %8, %6, %4, %3
%11 = phi i8 [ 0, %9 ], [ 39, %8 ], [ %7, %6 ], [ %5, %4 ], [ 2, %3 ], [ 1, %1 ]
ret i8 %11
}