#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 d(int);
int /*<<< orphan*/ drow(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ niceprint(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ putchar(char);
void emissary() {
  niceprint("A drow proudly wearing the insignia of a drow house travels with "
            "an entourage of quaggoth slaves. The "
            "drow is in Gracklstugh to retrieve a cargo of duergar metalwork "
            "and knows nothing about the recent events "
            "in Velkynvelve.");
  (void)putchar('\n');
  switch (d(3)) {
  case 1:
    niceprint("House Baenre: A current ally of House Xorlarrin and House "
              "Mizzrym. Given their affiliation with "
              "House Mizzrym they know that the characters are escaped "
              "prisoners from Velkynvelve and seeks out "
              "Xalith and warns her that the characters are in Gracklstugh.");
    break;
  case 2:
    niceprint("House Faen Tlabbar: A bitter rival of House Mizzrym. If the "
              "characters divulge that they are "
              "enemies or former prisoners of House Mizzrym, the drow warn the "
              "party about Xalith");
    break;
  case 3:
    niceprint("Xorlarrin: A current ally of House Baenre and House Mizzrym. "
              "Given their affiliation with "
              "House Mizzrym they know that the characters are escaped "
              "prisoners from Velkynvelve and seeks out "
              "Xalith and warns her that the characters are in Gracklstugh.");
    break;
  default:
    printf("Impossible drow house\n");
    exit(EXIT_FAILURE);
  }
  (void)putchar('\n');
  drow(1);
}


x86 assembly (clang, -O0):
<emissary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe91(%rip),%rdi
call   1070 <niceprint@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x3,%edi
call   1040 <d@plt>
mov    %eax,%ecx
mov    %ecx,-0x4(%rbp)
sub    $0x1,%eax
je     11bd <emissary+0x5d>
jmp    119b <emissary+0x3b>
mov    -0x4(%rbp),%eax
sub    $0x2,%eax
je     11ce <emissary+0x6e>
jmp    11ac <emissary+0x4c>
mov    -0x4(%rbp),%eax
sub    $0x3,%eax
je     11df <emissary+0x7f>
jmp    11f0 <emissary+0x90>
lea    0xf1c(%rip),%rdi
call   1070 <niceprint@plt>
jmp    120a <emissary+0xaa>
lea    0x1009(%rip),%rdi
call   1070 <niceprint@plt>
jmp    120a <emissary+0xaa>
lea    0x10a8(%rip),%rdi
call   1070 <niceprint@plt>
jmp    120a <emissary+0xaa>
lea    0x118f(%rip),%rdi
call   1060 <printf@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
call   1050 <drow@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<emissary>:
push   %rax
lea    0xe98(%rip),%rdi
call   1070 <niceprint@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x3,%edi
call   1050 <d@plt>
add    $0xffffffff,%eax
cmp    $0x3,%eax
jae    11b3 <emissary+0x53>
cltq
lea    0x120a(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1070 <niceprint@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x1,%edi
pop    %rax
jmp    1060 <drow@plt>
lea    0x11cc(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [224 x i8] c"A drow proudly wearing the insignia of a drow house travels with an entourage of quaggoth slaves. The drow is in Gracklstugh to retrieve a cargo of duergar metalwork and knows nothing about the recent events in Velkynvelve.\00"
@.str.1 = [254 x i8] c"House Baenre: A current ally of House Xorlarrin and House Mizzrym. Given their affiliation with House Mizzrym they know that the characters are escaped prisoners from Velkynvelve and seeks out Xalith and warns her that the characters are in Gracklstugh.\00"
@.str.2 = [176 x i8] c"House Faen Tlabbar: A bitter rival of House Mizzrym. If the characters divulge that they are enemies or former prisoners of House Mizzrym, the drow warn the party about Xalith\00"
@.str.3 = [248 x i8] c"Xorlarrin: A current ally of House Baenre and House Mizzrym. Given their affiliation with House Mizzrym they know that the characters are escaped prisoners from Velkynvelve and seeks out Xalith and warns her that the characters are in Gracklstugh.\00"
@.str.4 = [23 x i8] c"Impossible drow house\0A\00"
@EXIT_FAILURE = global i32 0
define void @emissary() {
%1 = call i32 @niceprint(i8* getelementptr inbounds ([224 x i8], [224 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @putchar(i8 signext 10)
%3 = call i32 @d(i32 3)
switch i32 %3, label %10 [
i32 1, label %4
i32 2, label %6
i32 3, label %8
]
4: ; preds = %0
%5 = call i32 @niceprint(i8* getelementptr inbounds ([254 x i8], [254 x i8]* @.str.1, i64 0, i64 0))
br label %14
6: ; preds = %0
%7 = call i32 @niceprint(i8* getelementptr inbounds ([176 x i8], [176 x i8]* @.str.2, i64 0, i64 0))
br label %14
8: ; preds = %0
%9 = call i32 @niceprint(i8* getelementptr inbounds ([248 x i8], [248 x i8]* @.str.3, i64 0, i64 0))
br label %14
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %8, %6, %4
%15 = call i32 @putchar(i8 signext 10)
%16 = call i32 @drow(i32 1)
ret void
}

LLVM IR (-O2):
@.str = [224 x i8] c"A drow proudly wearing the insignia of a drow house travels with an entourage of quaggoth slaves. The drow is in Gracklstugh to retrieve a cargo of duergar metalwork and knows nothing about the recent events in Velkynvelve.\00"
@.str.1 = [254 x i8] c"House Baenre: A current ally of House Xorlarrin and House Mizzrym. Given their affiliation with House Mizzrym they know that the characters are escaped prisoners from Velkynvelve and seeks out Xalith and warns her that the characters are in Gracklstugh.\00"
@.str.2 = [176 x i8] c"House Faen Tlabbar: A bitter rival of House Mizzrym. If the characters divulge that they are enemies or former prisoners of House Mizzrym, the drow warn the party about Xalith\00"
@.str.3 = [248 x i8] c"Xorlarrin: A current ally of House Baenre and House Mizzrym. Given their affiliation with House Mizzrym they know that the characters are escaped prisoners from Velkynvelve and seeks out Xalith and warns her that the characters are in Gracklstugh.\00"
@EXIT_FAILURE = global i32 0
@str = [22 x i8] c"Impossible drow house\00"
@reltable.emissary = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([254 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.emissary to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([176 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.emissary to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([248 x i8]* @.str.3 to i64), i64 ptrtoint ([3 x i32]* @reltable.emissary to i64)) to i32)]
define void @emissary() {
%1 = tail call i32 @niceprint(i8* getelementptr inbounds ([224 x i8], [224 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @putchar(i8 signext 10)
%3 = tail call i32 @d(i32 3)
%4 = add i32 %3, -1
%5 = icmp ult i32 %4, 3
br i1 %5, label %10, label %6
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %0
%11 = sext i32 %4 to i64
%12 = shl i64 %11, 2
%13 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.emissary to i8*), i64 %12)
%14 = tail call i32 @niceprint(i8* %13)
%15 = tail call i32 @putchar(i8 signext 10)
%16 = tail call i32 @drow(i32 1)
ret void
}