#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 */
short get_rand(int, int);
char gr_dir(void) {
  short d;
  d = get_rand(1, 8);
  switch (d) {
  case 1:
    d = 'j';
    break;
  case 2:
    d = 'k';
    break;
  case 3:
    d = 'l';
    break;
  case 4:
    d = 'h';
    break;
  case 5:
    d = 'y';
    break;
  case 6:
    d = 'u';
    break;
  case 7:
    d = 'b';
    break;
  case 8:
    d = 'n';
    break;
  }
  return (d);
}


x86 assembly (clang, -O0):
<gr_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
mov    $0x8,%esi
call   1030 <get_rand@plt>
mov    %ax,-0x2(%rbp)
movswl -0x2(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x7,%eax
ja     11a8 <gr_dir+0x98>
mov    -0x10(%rbp),%rax
lea    0xeb4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movw   $0x6a,-0x2(%rbp)
jmp    11a8 <gr_dir+0x98>
movw   $0x6b,-0x2(%rbp)
jmp    11a8 <gr_dir+0x98>
movw   $0x6c,-0x2(%rbp)
jmp    11a8 <gr_dir+0x98>
movw   $0x68,-0x2(%rbp)
jmp    11a8 <gr_dir+0x98>
movw   $0x79,-0x2(%rbp)
jmp    11a8 <gr_dir+0x98>
movw   $0x75,-0x2(%rbp)
jmp    11a8 <gr_dir+0x98>
movw   $0x62,-0x2(%rbp)
jmp    11a8 <gr_dir+0x98>
movw   $0x6e,-0x2(%rbp)
mov    -0x2(%rbp),%ax
movsbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gr_dir>:
push   %rax
mov    $0x1,%edi
mov    $0x8,%esi
call   1030 <get_rand@plt>
movswl %ax,%ecx
add    $0xffffffff,%ecx
cmp    $0x7,%ecx
ja     1139 <gr_dir+0x29>
movslq %ecx,%rax
lea    0xecb(%rip),%rcx
movzwl (%rcx,%rax,2),%eax
pop    %rcx
ret

LLVM IR (-O0):
define signext i8 @gr_dir() {
%1 = alloca i16
%2 = call signext i16 @get_rand(i32 1, i32 8)
store i16 %2, i16* %1
%3 = load i16, i16* %1
%4 = sext i16 %3 to i32
switch i32 %4, label %13 [
i32 1, label %5
i32 2, label %6
i32 3, label %7
i32 4, label %8
i32 5, label %9
i32 6, label %10
i32 7, label %11
i32 8, label %12
]
5: ; preds = %0
store i16 106, i16* %1
br label %13
6: ; preds = %0
store i16 107, i16* %1
br label %13
7: ; preds = %0
store i16 108, i16* %1
br label %13
8: ; preds = %0
store i16 104, i16* %1
br label %13
9: ; preds = %0
store i16 121, i16* %1
br label %13
10: ; preds = %0
store i16 117, i16* %1
br label %13
11: ; preds = %0
store i16 98, i16* %1
br label %13
12: ; preds = %0
store i16 110, i16* %1
br label %13
13: ; preds = %0, %12, %11, %10, %9, %8, %7, %6, %5
%14 = load i16, i16* %1
%15 = trunc i16 %14 to i8
ret i8 %15
}

LLVM IR (-O2):
@switch.table.gr_dir = [8 x i16] [i16 106, i16 107, i16 108, i16 104, i16 121, i16 117, i16 98, i16 110]
define signext i8 @gr_dir() {
%1 = tail call signext i16 @get_rand(i32 1, i32 8)
%2 = sext i16 %1 to i32
%3 = add nsw i32 %2, -1
%4 = icmp ult i32 %3, 8
br i1 %4, label %5, label %9
5: ; preds = %0
%6 = sext i32 %3 to i64
%7 = getelementptr inbounds [8 x i16], [8 x i16]* @switch.table.gr_dir, i64 0, i64 %6
%8 = load i16, i16* %7
br label %9
9: ; preds = %5, %0
%10 = phi i16 [ %1, %0 ], [ %8, %5 ]
%11 = trunc i16 %10 to i8
ret i8 %11
}