#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*/ banner(char *);
scalar_t__ check(char *);
int /*<<< orphan*/ free(char *);
char getchar();
char *initMap();
int /*<<< orphan*/ outMap(char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ scanf(char *, int *);
scalar_t__ setMap(char *, int);
int /*<<< orphan*/ setNPC(char *);
int /*<<< orphan*/ writeRecord(int);
int main(void) {
  char *map = initMap();
  banner(map);
  int input = 0;
  int turn;
  for (turn = 5; turn != 0; turn--) {
    printf("Dein Zug: ");
    if (scanf("%d", &input) <= 0) {
      printf("\nFehler bei der Eingabe!\n");
      while (getchar() != '\n')
        ;
      turn++;
      continue;
    }
    if (setMap(map, input) == 0) {
      if (check(map) != 0)
        break;
      outMap(map);
      printf("Gegner ist am Zug:\n");
      setNPC(map);
      outMap(map);
      if (check(map) != 0)
        break;
    } else {
      turn++;
    }
  }
  printf("Der Sieger ist...\n");
  int result = check(map);
  if (result == 0)
    printf("Niemand\n");
  else if (result == 1)
    printf("Der Spieler\n");
  else if (result == 2)
    printf("Der Computer\n");
  free(map);
  writeRecord(result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1080 <initMap@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <banner@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x5,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     12d1 <main+0x121>
lea    0xe0e(%rip),%rdi
call   1060 <printf@plt>
lea    0xe0d(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   10c0 <scanf@plt>
cmp    $0x0,%rax
jg     1243 <main+0x93>
lea    0xdf6(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   1090 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     1235 <main+0x85>
jmp    121d <main+0x6d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12c3 <main+0x113>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <setMap@plt>
cmp    $0x0,%rax
jne    12b5 <main+0x105>
mov    -0x10(%rbp),%rdi
call   10d0 <check@plt>
cmp    $0x0,%rax
je     1271 <main+0xc1>
jmp    12d1 <main+0x121>
mov    -0x10(%rbp),%rdi
call   10b0 <outMap@plt>
lea    0xda7(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <setNPC@plt>
mov    -0x10(%rbp),%rdi
call   10b0 <outMap@plt>
mov    -0x10(%rbp),%rdi
call   10d0 <check@plt>
cmp    $0x0,%rax
je     12b0 <main+0x100>
jmp    12d1 <main+0x121>
jmp    12be <main+0x10e>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12c3 <main+0x113>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    11e1 <main+0x31>
lea    0xd64(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   10d0 <check@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1304 <main+0x154>
lea    0xd55(%rip),%rdi
call   1060 <printf@plt>
jmp    133f <main+0x18f>
cmpl   $0x1,-0x1c(%rbp)
jne    131f <main+0x16f>
lea    0xd43(%rip),%rdi
call   1060 <printf@plt>
jmp    133a <main+0x18a>
cmpl   $0x2,-0x1c(%rbp)
jne    1335 <main+0x185>
lea    0xd35(%rip),%rdi
call   1060 <printf@plt>
jmp    133a <main+0x18a>
jmp    133f <main+0x18f>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%edi
call   10a0 <writeRecord@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1090 <initMap@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <banner@plt>
movl   $0x0,0x4(%rsp)
mov    $0x5,%ebp
lea    0xe0f(%rip),%r14
lea    0xe13(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xe50(%rip),%r13
jmp    121c <main+0x5c>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
add    $0xffffffff,%ebp
je     12b0 <main+0xf0>
mov    %r14,%rdi
call   1070 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   10d0 <scanf@plt>
test   %rax,%rax
jle    1290 <main+0xd0>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1060 <setMap@plt>
test   %rax,%rax
jne    1210 <main+0x50>
mov    %rbx,%rdi
call   10e0 <check@plt>
test   %rax,%rax
jne    12b0 <main+0xf0>
mov    %rbx,%rdi
call   10c0 <outMap@plt>
lea    0xde0(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1040 <setNPC@plt>
mov    %rbx,%rdi
call   10c0 <outMap@plt>
mov    %rbx,%rdi
call   10e0 <check@plt>
test   %rax,%rax
je     1213 <main+0x53>
jmp    12b0 <main+0xf0>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
call   1050 <puts@plt>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10a0 <getchar@plt>
cmp    $0xa,%al
jne    12a0 <main+0xe0>
jmp    1210 <main+0x50>
lea    0xd57(%rip),%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   10e0 <check@plt>
mov    %rax,%rbp
cmp    $0x2,%ebp
ja     12e2 <main+0x122>
movslq %ebp,%rax
lea    0xd9a(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%edi
call   10b0 <writeRecord@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Dein Zug: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"\0AFehler bei der Eingabe!\0A\00"
@.str.3 = [20 x i8] c"Gegner ist am Zug:\0A\00"
@.str.4 = [19 x i8] c"Der Sieger ist...\0A\00"
@.str.5 = [9 x i8] c"Niemand\0A\00"
@.str.6 = [13 x i8] c"Der Spieler\0A\00"
@.str.7 = [14 x i8] c"Der Computer\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i8* (...) @initMap()
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @banner(i8* %7)
store i32 0, i32* %3
store i32 5, i32* %4
br label %9
9: ; preds = %53, %0
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %56
12: ; preds = %9
%13 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%14 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%15 = icmp sle i64 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %12
%17 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %22, %16
%19 = call signext i8 (...) @getchar()
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 10
br i1 %21, label %22, label %23
22: ; preds = %18
br label %18
23: ; preds = %18
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %53
26: ; preds = %12
%27 = load i8*, i8** %2
%28 = load i32, i32* %3
%29 = call i64 @setMap(i8* %27, i32 %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %49
31: ; preds = %26
%32 = load i8*, i8** %2
%33 = call i64 @check(i8* %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %31
br label %56
36: ; preds = %31
%37 = load i8*, i8** %2
%38 = call i32 @outMap(i8* %37)
%39 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%40 = load i8*, i8** %2
%41 = call i32 @setNPC(i8* %40)
%42 = load i8*, i8** %2
%43 = call i32 @outMap(i8* %42)
%44 = load i8*, i8** %2
%45 = call i64 @check(i8* %44)
%46 = icmp ne i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %36
br label %56
48: ; preds = %36
br label %52
49: ; preds = %26
%50 = load i32, i32* %4
%51 = add nsw i32 %50, 1
store i32 %51, i32* %4
br label %52
52: ; preds = %49, %48
br label %53
53: ; preds = %52, %23
%54 = load i32, i32* %4
%55 = add nsw i32 %54, -1
store i32 %55, i32* %4
br label %9
56: ; preds = %47, %35, %9
%57 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%58 = load i8*, i8** %2
%59 = call i64 @check(i8* %58)
%60 = trunc i64 %59 to i32
store i32 %60, i32* %5
%61 = load i32, i32* %5
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %56
%64 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %77
65: ; preds = %56
%66 = load i32, i32* %5
%67 = icmp eq i32 %66, 1
br i1 %67, label %68, label %70
68: ; preds = %65
%69 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
br label %76
70: ; preds = %65
%71 = load i32, i32* %5
%72 = icmp eq i32 %71, 2
br i1 %72, label %73, label %75
73: ; preds = %70
%74 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
br label %75
75: ; preds = %73, %70
br label %76
76: ; preds = %75, %68
br label %77
77: ; preds = %76, %63
%78 = load i8*, i8** %2
%79 = call i32 @free(i8* %78)
%80 = load i32, i32* %5
%81 = call i32 @writeRecord(i32 %80)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"Dein Zug: \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [18 x i8] c"Der Sieger ist...\00"
@str.8 = [13 x i8] c"Der Computer\00"
@str.9 = [12 x i8] c"Der Spieler\00"
@str.10 = [8 x i8] c"Niemand\00"
@str.11 = [19 x i8] c"Gegner ist am Zug:\00"
@str.12 = [25 x i8] c"\0AFehler bei der Eingabe!\00"
@reltable.main = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @str.10 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([12 x i8]* @str.9 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @str.8 to i64), i64 ptrtoint ([3 x i32]* @reltable.main to i64)) to i32)]
define i32 @main() {
%1 = alloca i32
%2 = tail call i8* (...) @initMap()
%3 = tail call i32 @banner(i8* %2)
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %5
5: ; preds = %0, %33
%6 = phi i32 [ 5, %0 ], [ %35, %33 ]
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%8 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = icmp slt i64 %8, 1
br i1 %9, label %10, label %17
10: ; preds = %5
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.12, i64 0, i64 0))
br label %12
12: ; preds = %12, %10
%13 = call signext i8 (...) @getchar()
%14 = icmp eq i8 %13, 10
br i1 %14, label %15, label %12
15: ; preds = %12
%16 = add nsw i32 %6, 1
br label %33
17: ; preds = %5
%18 = load i32, i32* %1
%19 = call i64 @setMap(i8* %2, i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %31
21: ; preds = %17
%22 = call i64 @check(i8* %2)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %37
24: ; preds = %21
%25 = call i32 @outMap(i8* %2)
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.11, i64 0, i64 0))
%27 = call i32 @setNPC(i8* %2)
%28 = call i32 @outMap(i8* %2)
%29 = call i64 @check(i8* %2)
%30 = icmp eq i64 %29, 0
br i1 %30, label %33, label %37
31: ; preds = %17
%32 = add nsw i32 %6, 1
br label %33
33: ; preds = %31, %24, %15
%34 = phi i32 [ %16, %15 ], [ %6, %24 ], [ %32, %31 ]
%35 = add nsw i32 %34, -1
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %5
37: ; preds = %24, %21, %33
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%39 = call i64 @check(i8* %2)
%40 = trunc i64 %39 to i32
%41 = icmp ult i32 %40, 3
br i1 %41, label %42, label %48
42: ; preds = %37
%43 = shl i64 %39, 32
%44 = ashr exact i64 %43, 32
%45 = shl i64 %44, 2
%46 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.main to i8*), i64 %45)
%47 = call i32 @puts(i8* dereferenceable(1) %46)
br label %48
48: ; preds = %37, %42
%49 = call i32 @free(i8* %2)
%50 = call i32 @writeRecord(i32 %40)
ret i32 0
}