#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*/ EXIT_FAILURE;
int /*<<< orphan*/ d(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ goblin(int /*<<< orphan*/);
int /*<<< orphan*/ human(int /*<<< orphan*/);
int /*<<< orphan*/ moonelf(int /*<<< orphan*/);
int /*<<< orphan*/ niceprint(char *);
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ shielddwarf(int /*<<< orphan*/);
void slaves(unsigned d4) {
  niceprint("The characters encounter slaves wandering the Underdark since "
            "their escape from Gracklstugh or Menzoberranzan. They are "
            "scrounging for food and water.\n\n");
  if (d4 < 4)
    niceprint("They are friendly and will join the party if given food and "
              "water.\n\n");
  switch (d4) {
  case 1:
    moonelf(d(2));
    break;
  case 2:
    shielddwarf(d(3));
    break;
  case 3:
    human(d(4));
    break;
  case 4:
    goblin(d(6));
    break;
  default:
    printf("Impossible slave encounter of %d\n", d4);
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<slaves>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe7e(%rip),%rdi
call   1080 <niceprint@plt>
cmpl   $0x4,-0x4(%rbp)
jae    11ad <slaves+0x2d>
lea    0xf01(%rip),%rdi
call   1080 <niceprint@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     122e <slaves+0xae>
mov    -0x10(%rbp),%rax
lea    0xe33(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x2,%edi
call   1030 <d@plt>
mov    %eax,%edi
call   1040 <moonelf@plt>
jmp    124b <slaves+0xcb>
mov    $0x3,%edi
call   1030 <d@plt>
mov    %eax,%edi
call   10a0 <shielddwarf@plt>
jmp    124b <slaves+0xcb>
mov    $0x4,%edi
call   1030 <d@plt>
mov    %eax,%edi
call   1060 <human@plt>
jmp    124b <slaves+0xcb>
mov    $0x6,%edi
call   1030 <d@plt>
mov    %eax,%edi
call   1070 <goblin@plt>
jmp    124b <slaves+0xcb>
mov    -0x4(%rbp),%esi
lea    0xeb6(%rip),%rdi
call   1050 <printf@plt>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<slaves>:
push   %rbx
mov    %edi,%ebx
lea    0xe86(%rip),%rdi
call   1080 <niceprint@plt>
cmp    $0x3,%ebx
ja     11a0 <slaves+0x20>
lea    0xf0e(%rip),%rdi
call   1080 <niceprint@plt>
lea    -0x1(%rbx),%eax
cmp    $0x3,%eax
ja     1200 <slaves+0x80>
lea    0xe51(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x2,%edi
call   1030 <d@plt>
mov    %eax,%edi
pop    %rbx
jmp    1040 <moonelf@plt>
mov    $0x4,%edi
call   1030 <d@plt>
mov    %eax,%edi
pop    %rbx
jmp    1060 <human@plt>
mov    $0x3,%edi
call   1030 <d@plt>
mov    %eax,%edi
pop    %rbx
jmp    10a0 <shielddwarf@plt>
mov    $0x6,%edi
call   1030 <d@plt>
mov    %eax,%edi
pop    %rbx
jmp    1070 <goblin@plt>
lea    0xee7(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [153 x i8] c"The characters encounter slaves wandering the Underdark since their escape from Gracklstugh or Menzoberranzan. They are scrounging for food and water.\0A\0A\00"
@.str.1 = [69 x i8] c"They are friendly and will join the party if given food and water.\0A\0A\00"
@.str.2 = [34 x i8] c"Impossible slave encounter of %d\0A\00"
@EXIT_FAILURE = global i32 0
define void @slaves(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @niceprint(i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* %2
%5 = icmp ult i32 %4, 4
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @niceprint(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %6, %1
%9 = load i32, i32* %2
switch i32 %9, label %22 [
i32 1, label %10
i32 2, label %13
i32 3, label %16
i32 4, label %19
]
10: ; preds = %8
%11 = call i32 @d(i32 2)
%12 = call i32 @moonelf(i32 %11)
br label %27
13: ; preds = %8
%14 = call i32 @d(i32 3)
%15 = call i32 @shielddwarf(i32 %14)
br label %27
16: ; preds = %8
%17 = call i32 @d(i32 4)
%18 = call i32 @human(i32 %17)
br label %27
19: ; preds = %8
%20 = call i32 @d(i32 6)
%21 = call i32 @goblin(i32 %20)
br label %27
22: ; preds = %8
%23 = load i32, i32* %2
%24 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %19, %16, %13, %10
ret void
}

LLVM IR (-O2):
@.str = [153 x i8] c"The characters encounter slaves wandering the Underdark since their escape from Gracklstugh or Menzoberranzan. They are scrounging for food and water.\0A\0A\00"
@.str.1 = [69 x i8] c"They are friendly and will join the party if given food and water.\0A\0A\00"
@.str.2 = [34 x i8] c"Impossible slave encounter of %d\0A\00"
@EXIT_FAILURE = global i32 0
define void @slaves(i32 %0) {
%2 = tail call i32 @niceprint(i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str, i64 0, i64 0))
%3 = icmp ult i32 %0, 4
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @niceprint(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
switch i32 %0, label %19 [
i32 1, label %7
i32 2, label %10
i32 3, label %13
i32 4, label %16
]
7: ; preds = %6
%8 = tail call i32 @d(i32 2)
%9 = tail call i32 @moonelf(i32 %8)
br label %23
10: ; preds = %6
%11 = tail call i32 @d(i32 3)
%12 = tail call i32 @shielddwarf(i32 %11)
br label %23
13: ; preds = %6
%14 = tail call i32 @d(i32 4)
%15 = tail call i32 @human(i32 %14)
br label %23
16: ; preds = %6
%17 = tail call i32 @d(i32 6)
%18 = tail call i32 @goblin(i32 %17)
br label %23
19: ; preds = %6
%20 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %0)
%21 = load i32, i32* @EXIT_FAILURE
%22 = tail call i32 @exit(i32 %21)
unreachable
23: ; preds = %16, %13, %10, %7
ret void
}