#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*/ getch();
int /*<<< orphan*/ slowprintfc(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int /*<<< orphan*/ strtolower(char *);
void help(char *topic) {
  if (topic)
    strtolower(topic);
  if (!strncmp(topic, "co", 2)) {
    slowprintfc(
        "~6WEREWOLVES AND WANDERER COMMANDS\n\n"
        "~1bGO ~7- Travel to a different room. ~1bGO ~7then ~1bEAST~7,\n"
        "     ~1bGO EAST~7, or just ~1bEAST ~7are all the same.\n"
        "~1bLOOK ~7- Get a description of the room\n"
        "~1bINVENTORY ~7- See your stats.\n"
        "~1bGET ~7or ~1bPICK UP ~7- Add the treasure in the room\n"
        "     to your wealth total.\n"
        "~1bTRADE ~7or ~1bBUY ~7- Purchase items from the merchant\n"
        "     if available. Typing ~1bTRADE ~7then ~1bAXE ~7or\n"
        "     ~1bBUY AXE ~7are the same.\n"
        "~1bEAT ~7- Consume food to increase your strength.\n"
        "~1bFIGHT ~7- Engage monster in the room to combat.\n"
        "~1bRUN ~7or ~1bFLEE ~7- Attempt to escape from monsters\n"
        "     in the room. ~1bRUN ~7then ~1bEAST ~7or ~1bRUN EAST~7\n"
        "     both have the same effect.\n"
        "~1bMAGIC ~7- If you have the amulet you can summon\n"
        "     its power to teleport you within the castle.\n"
        "~1bEXAMINE ~7- In certain rooms you may learn more\n"
        "     about the story.\n"
        "~1bHIGH SCORE ~7- look at the high score table.\n"
        "~1bQUIT ~7- End your game.\n\n");
  } else {
    slowprintfc("~6WEREWOLVES AND WANDERER\n"
                "Original game by Tim Hartnell.\n"
                "Remake by Joseph Larson\n\n"
                "~7In this adventure you are the wanderer and\n"
                "werewolves and other strange creatures inhabit\n"
                "an ancient, abandoned, stone castle where you\n"
                "are seeking untold fortune.\n\n"
                "This is a basic text-adventure that seeks to\n"
                "simplify the experience by giving you the\n"
                "available exits and commands without needing\n"
                "to hunt around for them, tho it will also\n"
                "accept a few other commands as well as\n"
                "occasional two word commands.\n\n"
                "The ~1bEXAMINE ~7command is the one exception. Typing\n"
                "~1bEXAMINE ~7in a room may give you extra expository\n"
                "information about that room, tho the game may not\n"
                "always tell you when you can use it.\n\n"
                "Type ~1bHELP COMMANDS ~7for a list of all commands.\n\n");
  }
  slowprintfc("Press ~2bENTER ~7to continue\n");
  getch();
}


x86 assembly (clang, -O0):
<help>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1160 <help+0x20>
mov    -0x8(%rbp),%rdi
call   1050 <strtolower@plt>
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    118f <help+0x4f>
lea    0xe7e(%rip),%rdi
call   1040 <slowprintfc@plt>
jmp    119b <help+0x5b>
lea    0x1228(%rip),%rdi
call   1040 <slowprintfc@plt>
lea    0x1502(%rip),%rdi
call   1040 <slowprintfc@plt>
mov    $0x0,%al
call   1060 <getch@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<help>:
push   %rbx
mov    %rdi,%rbx
test   %rdi,%rdi
je     1151 <help+0x11>
mov    %rbx,%rdi
call   1050 <strtolower@plt>
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
lea    0xe95(%rip),%rax
lea    0x1249(%rip),%rdi
cmove  %rax,%rdi
call   1040 <slowprintfc@plt>
lea    0x151f(%rip),%rdi
call   1040 <slowprintfc@plt>
xor    %eax,%eax
pop    %rbx
jmp    1060 <getch@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"co\00"
@.str.1 = [955 x i8] c"~6WEREWOLVES AND WANDERER COMMANDS\0A\0A~1bGO ~7- Travel to a different room. ~1bGO ~7then ~1bEAST~7,\0A ~1bGO EAST~7, or just ~1bEAST ~7are all the same.\0A~1bLOOK ~7- Get a description of the room\0A~1bINVENTORY ~7- See your stats.\0A~1bGET ~7or ~1bPICK UP ~7- Add the treasure in the room\0A to your wealth total.\0A~1bTRADE ~7or ~1bBUY ~7- Purchase items from the merchant\0A if available. Typing ~1bTRADE ~7then ~1bAXE ~7or\0A ~1bBUY AXE ~7are the same.\0A~1bEAT ~7- Consume food to increase your strength.\0A~1bFIGHT ~7- Engage monster in the room to combat.\0A~1bRUN ~7or ~1bFLEE ~7- Attempt to escape from monsters\0A in the room. ~1bRUN ~7then ~1bEAST ~7or ~1bRUN EAST~7\0A both have the same effect.\0A~1bMAGIC ~7- If you have the amulet you can summon\0A its power to teleport you within the castle.\0A~1bEXAMINE ~7- In certain rooms you may learn more\0A about the story.\0A~1bHIGH SCORE ~7- look at the high score table.\0A~1bQUIT ~7- End your game.\0A\0A\00"
@.str.2 = [742 x i8] c"~6WEREWOLVES AND WANDERER\0AOriginal game by Tim Hartnell.\0ARemake by Joseph Larson\0A\0A~7In this adventure you are the wanderer and\0Awerewolves and other strange creatures inhabit\0Aan ancient, abandoned, stone castle where you\0Aare seeking untold fortune.\0A\0AThis is a basic text-adventure that seeks to\0Asimplify the experience by giving you the\0Aavailable exits and commands without needing\0Ato hunt around for them, tho it will also\0Aaccept a few other commands as well as\0Aoccasional two word commands.\0A\0AThe ~1bEXAMINE ~7command is the one exception. Typing\0A~1bEXAMINE ~7in a room may give you extra expository\0Ainformation about that room, tho the game may not\0Aalways tell you when you can use it.\0A\0AType ~1bHELP COMMANDS ~7for a list of all commands.\0A\0A\00"
@.str.3 = [30 x i8] c"Press ~2bENTER ~7to continue\0A\00"
define void @help(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = icmp ne i8* %3, null
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = load i8*, i8** %2
%7 = call i32 @strtolower(i8* %6)
br label %8
8: ; preds = %5, %1
%9 = load i8*, i8** %2
%10 = call i32 @strncmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%11 = icmp ne i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = call i32 @slowprintfc(i8* getelementptr inbounds ([955 x i8], [955 x i8]* @.str.1, i64 0, i64 0))
br label %16
14: ; preds = %8
%15 = call i32 @slowprintfc(i8* getelementptr inbounds ([742 x i8], [742 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %12
%17 = call i32 @slowprintfc(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 (...) @getch()
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"co\00"
@.str.1 = [955 x i8] c"~6WEREWOLVES AND WANDERER COMMANDS\0A\0A~1bGO ~7- Travel to a different room. ~1bGO ~7then ~1bEAST~7,\0A ~1bGO EAST~7, or just ~1bEAST ~7are all the same.\0A~1bLOOK ~7- Get a description of the room\0A~1bINVENTORY ~7- See your stats.\0A~1bGET ~7or ~1bPICK UP ~7- Add the treasure in the room\0A to your wealth total.\0A~1bTRADE ~7or ~1bBUY ~7- Purchase items from the merchant\0A if available. Typing ~1bTRADE ~7then ~1bAXE ~7or\0A ~1bBUY AXE ~7are the same.\0A~1bEAT ~7- Consume food to increase your strength.\0A~1bFIGHT ~7- Engage monster in the room to combat.\0A~1bRUN ~7or ~1bFLEE ~7- Attempt to escape from monsters\0A in the room. ~1bRUN ~7then ~1bEAST ~7or ~1bRUN EAST~7\0A both have the same effect.\0A~1bMAGIC ~7- If you have the amulet you can summon\0A its power to teleport you within the castle.\0A~1bEXAMINE ~7- In certain rooms you may learn more\0A about the story.\0A~1bHIGH SCORE ~7- look at the high score table.\0A~1bQUIT ~7- End your game.\0A\0A\00"
@.str.2 = [742 x i8] c"~6WEREWOLVES AND WANDERER\0AOriginal game by Tim Hartnell.\0ARemake by Joseph Larson\0A\0A~7In this adventure you are the wanderer and\0Awerewolves and other strange creatures inhabit\0Aan ancient, abandoned, stone castle where you\0Aare seeking untold fortune.\0A\0AThis is a basic text-adventure that seeks to\0Asimplify the experience by giving you the\0Aavailable exits and commands without needing\0Ato hunt around for them, tho it will also\0Aaccept a few other commands as well as\0Aoccasional two word commands.\0A\0AThe ~1bEXAMINE ~7command is the one exception. Typing\0A~1bEXAMINE ~7in a room may give you extra expository\0Ainformation about that room, tho the game may not\0Aalways tell you when you can use it.\0A\0AType ~1bHELP COMMANDS ~7for a list of all commands.\0A\0A\00"
@.str.3 = [30 x i8] c"Press ~2bENTER ~7to continue\0A\00"
define void @help(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = tail call i32 @strtolower(i8* %0)
br label %5
5: ; preds = %3, %1
%6 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([955 x i8], [955 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([742 x i8], [742 x i8]* @.str.2, i64 0, i64 0)
%9 = tail call i32 @slowprintfc(i8* %8)
%10 = tail call i32 @slowprintfc(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 (...) @getch()
ret void
}