#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 tolower(char);
int chartodirection(char c) {
  switch (tolower(c)) {
  case 'l':
    return 0;
  case 'u':
    return 1;
  case 'r':
    return 2;
  case 'd':
    return 3;
  case 's':
    return 5;
  case 'w':
    return 6;
  case 'n':
    return 4;
  default:
    return 7;
  }
}


x86 assembly (clang, -O0):
<chartodirection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1030 <tolower@plt>
add    $0xffffff9c,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x13,%eax
ja     11a1 <chartodirection+0x91>
mov    -0x10(%rbp),%rax
lea    0xebc(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x4(%rbp)
jmp    11a8 <chartodirection+0x98>
movl   $0x1,-0x4(%rbp)
jmp    11a8 <chartodirection+0x98>
movl   $0x2,-0x4(%rbp)
jmp    11a8 <chartodirection+0x98>
movl   $0x3,-0x4(%rbp)
jmp    11a8 <chartodirection+0x98>
movl   $0x5,-0x4(%rbp)
jmp    11a8 <chartodirection+0x98>
movl   $0x6,-0x4(%rbp)
jmp    11a8 <chartodirection+0x98>
movl   $0x4,-0x4(%rbp)
jmp    11a8 <chartodirection+0x98>
movl   $0x7,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chartodirection>:
push   %rax
call   1030 <tolower@plt>
mov    %eax,%ecx
add    $0xffffff9c,%ecx
cmp    $0x13,%ecx
ja     1139 <chartodirection+0x29>
xor    %eax,%eax
lea    0xed7(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    $0x3,%eax
pop    %rcx
ret
mov    $0x7,%eax
pop    %rcx
ret
mov    $0x4,%eax
pop    %rcx
ret
mov    $0x2,%eax
pop    %rcx
ret
mov    $0x1,%eax
pop    %rcx
ret
mov    $0x6,%eax
pop    %rcx
ret
mov    $0x5,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @chartodirection(i8 signext %0) {
%2 = alloca i32
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = call i32 @tolower(i8 signext %4)
switch i32 %5, label %13 [
i32 108, label %6
i32 117, label %7
i32 114, label %8
i32 100, label %9
i32 115, label %10
i32 119, label %11
i32 110, label %12
]
6: ; preds = %1
store i32 0, i32* %2
br label %14
7: ; preds = %1
store i32 1, i32* %2
br label %14
8: ; preds = %1
store i32 2, i32* %2
br label %14
9: ; preds = %1
store i32 3, i32* %2
br label %14
10: ; preds = %1
store i32 5, i32* %2
br label %14
11: ; preds = %1
store i32 6, i32* %2
br label %14
12: ; preds = %1
store i32 4, i32* %2
br label %14
13: ; preds = %1
store i32 7, i32* %2
br label %14
14: ; preds = %13, %12, %11, %10, %9, %8, %7, %6
%15 = load i32, i32* %2
ret i32 %15
}

LLVM IR (-O2):
define i32 @chartodirection(i8 signext %0) {
%2 = tail call i32 @tolower(i8 signext %0)
switch i32 %2, label %9 [
i32 108, label %10
i32 117, label %3
i32 114, label %4
i32 100, label %5
i32 115, label %6
i32 119, label %7
i32 110, label %8
]
3: ; preds = %1
br label %10
4: ; preds = %1
br label %10
5: ; preds = %1
br label %10
6: ; preds = %1
br label %10
7: ; preds = %1
br label %10
8: ; preds = %1
br label %10
9: ; preds = %1
br label %10
10: ; preds = %1, %9, %8, %7, %6, %5, %4, %3
%11 = phi i32 [ 7, %9 ], [ 4, %8 ], [ 6, %7 ], [ 5, %6 ], [ 3, %5 ], [ 2, %4 ], [ 1, %3 ], [ 0, %1 ]
ret i32 %11
}