#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 */
typedef int /*<<< orphan*/ s;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ chomp(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ message(char *);
int /*<<< orphan*/ play_game();
scalar_t__ read_in_mazes(int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, char *);
void start_game(char *fn) {
  char s[20];
  FILE *fp;
  if ((fp = fopen(fn, "rt")) == NULL) {
    message("Can't open file");
    return;
  }
  fgets(s, sizeof(s), fp);
  chomp(s);
  if (strcmp(s, "TMAZE")) {
    message("Invalid map file (doesn't have signature)");
    return;
  }
  if (read_in_mazes(fp)) {
    fclose(fp);
    return;
  }
  play_game();
  fclose(fp);
}


x86 assembly (clang, -O0):
<start_game>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11bb <start_game+0x3b>
lea    0xe52(%rip),%rdi
call   1030 <message@plt>
jmp    1232 <start_game+0xb2>
lea    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    $0x14,%esi
call   1050 <fgets@plt>
lea    -0x20(%rbp),%rdi
call   1080 <chomp@plt>
lea    -0x20(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1201 <start_game+0x81>
lea    0xe22(%rip),%rdi
call   1030 <message@plt>
jmp    1232 <start_game+0xb2>
mov    -0x28(%rbp),%rdi
call   1070 <read_in_mazes@plt>
cmp    $0x0,%rax
je     1222 <start_game+0xa2>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1232 <start_game+0xb2>
mov    $0x0,%al
call   1090 <play_game@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_game>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xe72(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     11d8 <start_game+0x58>
mov    %rax,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x14,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
mov    %r14,%rdi
call   1080 <chomp@plt>
lea    0xe56(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11eb <start_game+0x6b>
lea    0xe48(%rip),%rdi
call   1030 <message@plt>
jmp    1207 <start_game+0x87>
lea    0xe24(%rip),%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1030 <message@plt>
mov    %rbx,%rdi
call   1070 <read_in_mazes@plt>
test   %rax,%rax
jne    11ff <start_game+0x7f>
xor    %eax,%eax
call   1090 <play_game@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rt\00"
@.str.1 = [16 x i8] c"Can't open file\00"
@.str.2 = [6 x i8] c"TMAZE\00"
@.str.3 = [42 x i8] c"Invalid map file (doesn't have signature)\00"
define void @start_game(i8* %0) {
%2 = alloca i8*
%3 = alloca [20 x i8]
%4 = alloca i32*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %4
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @message(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %32
10: ; preds = %1
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%12 = load i32*, i32** %4
%13 = call i32 @fgets(i8* %11, i32 20, i32* %12)
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%15 = call i32 @chomp(i8* %14)
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %10
%20 = call i32 @message(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
br label %32
21: ; preds = %10
%22 = load i32*, i32** %4
%23 = call i64 @read_in_mazes(i32* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i32*, i32** %4
%27 = call i32 @fclose(i32* %26)
br label %32
28: ; preds = %21
%29 = call i32 (...) @play_game()
%30 = load i32*, i32** %4
%31 = call i32 @fclose(i32* %30)
br label %32
32: ; preds = %28, %25, %19, %8
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rt\00"
@.str.1 = [16 x i8] c"Can't open file\00"
@.str.2 = [6 x i8] c"TMAZE\00"
@.str.3 = [42 x i8] c"Invalid map file (doesn't have signature)\00"
define void @start_game(i8* nocapture %0) {
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @message(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %23
8: ; preds = %1
%9 = call i32 @fgets(i8* %3, i32 20, i32* %4)
%10 = call i32 @chomp(i8* %3)
%11 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %8
%14 = call i32 @message(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
br label %23
15: ; preds = %8
%16 = call i64 @read_in_mazes(i32* %4)
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = call i32 @fclose(i32* %4)
br label %23
20: ; preds = %15
%21 = call i32 (...) @play_game()
%22 = call i32 @fclose(i32* %4)
br label %23
23: ; preds = %20, %18, %13, %6
ret void
}