int getnum(char *str) {
  char ch = str[0];
  switch (ch) {
  case 'm':
    return 0;
  case 't':
    if (str[1] == 'u') {
      return 1;
    } else {
      return 3;
    }
  case 'w':
    return 2;
  case 'f':
    return 4;
  case 's':
    if (str[1] == 'a') {
      return 5;
    } else {
      return 6;
    }
  }
}


x86 assembly (clang, -O0):
<getnum>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
add    $0xffffff9a,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x11,%eax
ja     11ac <getnum+0xac>
mov    -0x20(%rbp),%rax
lea    0xece(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x4(%rbp)
jmp    11ac <getnum+0xac>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x75,%eax
jne    1164 <getnum+0x64>
movl   $0x1,-0x4(%rbp)
jmp    11ac <getnum+0xac>
movl   $0x3,-0x4(%rbp)
jmp    11ac <getnum+0xac>
movl   $0x2,-0x4(%rbp)
jmp    11ac <getnum+0xac>
movl   $0x4,-0x4(%rbp)
jmp    11ac <getnum+0xac>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x61,%eax
jne    11a5 <getnum+0xa5>
movl   $0x5,-0x4(%rbp)
jmp    11ac <getnum+0xac>
movl   $0x6,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<getnum>:
movsbl (%rdi),%ecx
xor    %eax,%eax
add    $0xffffff9a,%ecx
cmp    $0x11,%ecx
ja     1133 <getnum+0x33>
lea    0xeec(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x4,%eax
ret
xor    %ecx,%ecx
cmpb   $0x61,0x1(%rdi)
sete   %cl
mov    $0x6,%eax
sub    %ecx,%eax
ret
xor    %eax,%eax
cmpb   $0x75,0x1(%rdi)
setne  %al
add    %eax,%eax
add    $0x1,%eax
ret
mov    $0x2,%eax
ret

LLVM IR (-O0):
define i32 @getnum(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
store i8 %7, i8* %4
%8 = load i8, i8* %4
%9 = sext i8 %8 to i32
switch i32 %9, label %29 [
i32 109, label %10
i32 116, label %11
i32 119, label %19
i32 102, label %20
i32 115, label %21
]
10: ; preds = %1
store i32 0, i32* %2
br label %29
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 117
br i1 %16, label %17, label %18
17: ; preds = %11
store i32 1, i32* %2
br label %29
18: ; preds = %11
store i32 3, i32* %2
br label %29
19: ; preds = %1
store i32 2, i32* %2
br label %29
20: ; preds = %1
store i32 4, i32* %2
br label %29
21: ; preds = %1
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i64 1
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 97
br i1 %26, label %27, label %28
27: ; preds = %21
store i32 5, i32* %2
br label %29
28: ; preds = %21
store i32 6, i32* %2
br label %29
29: ; preds = %10, %17, %18, %19, %20, %27, %28, %1
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
define i32 @getnum(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
switch i32 %3, label %16 [
i32 115, label %11
i32 116, label %4
i32 119, label %9
i32 102, label %10
]
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 117
%8 = select i1 %7, i32 1, i32 3
br label %16
9: ; preds = %1
br label %16
10: ; preds = %1
br label %16
11: ; preds = %1
%12 = getelementptr inbounds i8, i8* %0, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 97
%15 = select i1 %14, i32 5, i32 6
br label %16
16: ; preds = %1, %11, %4, %10, %9
%17 = phi i32 [ 4, %10 ], [ 2, %9 ], [ %8, %4 ], [ %15, %11 ], [ 0, %1 ]
ret i32 %17
}