#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 /*<<< orphan*/ scoterror(char *);
int letterval(int c) {
  switch (c) {
  case 'a':
    return 5;
  case 'b':
    return 6;
  case 'c':
    return 0;
  case 'd':
    return 1;
  case 'e':
    return 2;
  case 'f':
    return 3;
  case 'g':
    return 4;
  default:
    scoterror(("Invalid pitch class"));
    return 0;
  }
}


x86 assembly (clang, -O0):
<letterval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     1198 <letterval+0x88>
mov    -0x10(%rbp),%rax
lea    0xec5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x5,-0x4(%rbp)
jmp    11ab <letterval+0x9b>
movl   $0x6,-0x4(%rbp)
jmp    11ab <letterval+0x9b>
movl   $0x0,-0x4(%rbp)
jmp    11ab <letterval+0x9b>
movl   $0x1,-0x4(%rbp)
jmp    11ab <letterval+0x9b>
movl   $0x2,-0x4(%rbp)
jmp    11ab <letterval+0x9b>
movl   $0x3,-0x4(%rbp)
jmp    11ab <letterval+0x9b>
movl   $0x4,-0x4(%rbp)
jmp    11ab <letterval+0x9b>
lea    0xe7d(%rip),%rdi
call   1030 <scoterror@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<letterval>:
push   %rax
add    $0xffffff9f,%edi
cmp    $0x7,%edi
jae    1128 <letterval+0x18>
movslq %edi,%rax
lea    0xef1(%rip),%rcx
mov    (%rcx,%rax,4),%eax
pop    %rcx
ret
lea    0xed1(%rip),%rdi
call   1030 <scoterror@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Invalid pitch class\00"
define i32 @letterval(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
switch i32 %4, label %12 [
i32 97, label %5
i32 98, label %6
i32 99, label %7
i32 100, label %8
i32 101, label %9
i32 102, label %10
i32 103, label %11
]
5: ; preds = %1
store i32 5, i32* %2
br label %14
6: ; preds = %1
store i32 6, i32* %2
br label %14
7: ; preds = %1
store i32 0, i32* %2
br label %14
8: ; preds = %1
store i32 1, i32* %2
br label %14
9: ; preds = %1
store i32 2, i32* %2
br label %14
10: ; preds = %1
store i32 3, i32* %2
br label %14
11: ; preds = %1
store i32 4, i32* %2
br label %14
12: ; preds = %1
%13 = call i32 @scoterror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %14
14: ; preds = %12, %11, %10, %9, %8, %7, %6, %5
%15 = load i32, i32* %2
ret i32 %15
}

LLVM IR (-O2):
@.str = [20 x i8] c"Invalid pitch class\00"
@switch.table.letterval = [7 x i32] [i32 5, i32 6, i32 0, i32 1, i32 2, i32 3, i32 4]
define i32 @letterval(i32 %0) {
%2 = add i32 %0, -97
%3 = icmp ult i32 %2, 7
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @scoterror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %10
6: ; preds = %1
%7 = sext i32 %2 to i64
%8 = getelementptr inbounds [7 x i32], [7 x i32]* @switch.table.letterval, i64 0, i64 %7
%9 = load i32, i32* %8
br label %10
10: ; preds = %6, %4
%11 = phi i32 [ 0, %4 ], [ %9, %6 ]
ret i32 %11
}