#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*/ closeWordList();
int /*<<< orphan*/ free(char *);
char *getRandomWord();
int /*<<< orphan*/ openWordList(char const *);
scalar_t__ playGame(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int startGame(const char *wordList) {
  openWordList(wordList);
  char *randomWord = getRandomWord();
  if (playGame(randomWord, 10) == 0)
    printf("Congratulations, you guessed the word \"%s\" correctly.\n",
           randomWord);
  else
    printf("You did not guess \"%s\" correctly, and have been hanged.\n",
           randomWord);
  closeWordList();
  free(randomWord);
  return 0;
}


x86 assembly (clang, -O0):
<startGame>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <openWordList@plt>
mov    $0x0,%al
call   1060 <getRandomWord@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0xa,%esi
call   1080 <playGame@plt>
cmp    $0x0,%rax
jne    11ad <startGame+0x4d>
mov    -0x10(%rbp),%rsi
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
jmp    11bd <startGame+0x5d>
mov    -0x10(%rbp),%rsi
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <closeWordList@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<startGame>:
push   %rbx
call   1050 <openWordList@plt>
xor    %eax,%eax
call   1060 <getRandomWord@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0xa,%esi
call   1080 <playGame@plt>
test   %rax,%rax
lea    0xe79(%rip),%rax
lea    0xea9(%rip),%rdi
cmove  %rax,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <closeWordList@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [55 x i8] c"Congratulations, you guessed the word \22%s\22 correctly.\0A\00"
@.str.1 = [57 x i8] c"You did not guess \22%s\22 correctly, and have been hanged.\0A\00"
define i32 @startGame(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = call i32 @openWordList(i8* %4)
%6 = call i8* (...) @getRandomWord()
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i64 @playGame(i8* %7, i32 10)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %16
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %16
16: ; preds = %13, %10
%17 = call i32 (...) @closeWordList()
%18 = load i8*, i8** %3
%19 = call i32 @free(i8* %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [55 x i8] c"Congratulations, you guessed the word \22%s\22 correctly.\0A\00"
@.str.1 = [57 x i8] c"You did not guess \22%s\22 correctly, and have been hanged.\0A\00"
define i32 @startGame(i8* %0) {
%2 = tail call i32 @openWordList(i8* %0)
%3 = tail call i8* (...) @getRandomWord()
%4 = tail call i64 @playGame(i8* %3, i32 10)
%5 = icmp eq i64 %4, 0
%6 = select i1 %5, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0)
%7 = tail call i32 @printf(i8* %6, i8* %3)
%8 = tail call i32 (...) @closeWordList()
%9 = tail call i32 @free(i8* %3)
ret i32 0
}