#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*/ check_player_died();
int get_char();
scalar_t__ player_dead();
int /*<<< orphan*/ reset_game();
scalar_t__ resize_detected();
scalar_t__ update_player(int);
scalar_t__ update_zombies();
int play_turn() {
  int result = 0;
  if (resize_detected()) {
    reset_game();
    return result;
  }
  int key_code = get_char();
  if (key_code == 'q' || key_code == 'Q') {
    return -1;
  } else if (key_code == 'r' || key_code == 'R') {
    reset_game();
    return 0;
  }
  if (player_dead()) {
    return 0;
  }
  if (update_player(key_code)) {
    result = 1;
  } else if (update_zombies()) {
    result = 1;
  }
  check_player_died();
  return result;
}


x86 assembly (clang, -O0):
<play_turn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1080 <resize_detected@plt>
cmp    $0x0,%rax
je     11a2 <play_turn+0x32>
mov    $0x0,%al
call   1040 <reset_game@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    125d <play_turn+0xed>
mov    $0x0,%al
call   1090 <get_char@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x71,-0xc(%rbp)
je     11c0 <play_turn+0x50>
cmpl   $0x51,-0xc(%rbp)
jne    11cc <play_turn+0x5c>
movl   $0xffffffff,-0x4(%rbp)
jmp    125d <play_turn+0xed>
cmpl   $0x72,-0xc(%rbp)
je     11e0 <play_turn+0x70>
cmpl   $0x52,-0xc(%rbp)
jne    11f3 <play_turn+0x83>
mov    $0x0,%al
call   1040 <reset_game@plt>
movl   $0x0,-0x4(%rbp)
jmp    125d <play_turn+0xed>
jmp    11f8 <play_turn+0x88>
mov    $0x0,%al
call   1050 <player_dead@plt>
cmp    $0x0,%rax
je     1215 <play_turn+0xa5>
movl   $0x0,-0x4(%rbp)
jmp    125d <play_turn+0xed>
mov    -0xc(%rbp),%edi
call   1070 <update_player@plt>
cmp    $0x0,%rax
je     1233 <play_turn+0xc3>
movl   $0x1,-0x8(%rbp)
jmp    1250 <play_turn+0xe0>
mov    $0x0,%al
call   1060 <update_zombies@plt>
cmp    $0x0,%rax
je     124b <play_turn+0xdb>
movl   $0x1,-0x8(%rbp)
jmp    1250 <play_turn+0xe0>
mov    $0x0,%al
call   1030 <check_player_died@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<play_turn>:
push   %rbp
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <resize_detected@plt>
test   %rax,%rax
je     1191 <play_turn+0x21>
xor    %eax,%eax
call   1040 <reset_game@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %eax,%eax
call   1090 <get_char@plt>
mov    %eax,%ebp
and    $0xffffffdf,%eax
cmp    $0x51,%eax
je     11de <play_turn+0x6e>
xor    %ebx,%ebx
cmp    $0x52,%eax
je     1181 <play_turn+0x11>
xor    %eax,%eax
call   1050 <player_dead@plt>
test   %rax,%rax
jne    1188 <play_turn+0x18>
mov    %ebp,%edi
call   1070 <update_player@plt>
mov    $0x1,%ebx
test   %rax,%rax
jne    11d5 <play_turn+0x65>
xor    %eax,%eax
call   1060 <update_zombies@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
xor    %eax,%eax
call   1030 <check_player_died@plt>
jmp    1188 <play_turn+0x18>
mov    $0xffffffff,%ebx
jmp    1188 <play_turn+0x18>

LLVM IR (-O0):
define i32 @play_turn() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
%4 = call i64 (...) @resize_detected()
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 (...) @reset_game()
%8 = load i32, i32* %2
store i32 %8, i32* %1
br label %43
9: ; preds = %0
%10 = call i32 (...) @get_char()
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 113
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 81
br i1 %15, label %16, label %17
16: ; preds = %13, %9
store i32 -1, i32* %1
br label %43
17: ; preds = %13
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 114
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 82
br i1 %22, label %23, label %25
23: ; preds = %20, %17
%24 = call i32 (...) @reset_game()
store i32 0, i32* %1
br label %43
25: ; preds = %20
br label %26
26: ; preds = %25
%27 = call i64 (...) @player_dead()
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %26
store i32 0, i32* %1
br label %43
30: ; preds = %26
%31 = load i32, i32* %3
%32 = call i64 @update_player(i32 %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 1, i32* %2
br label %40
35: ; preds = %30
%36 = call i64 (...) @update_zombies()
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %39
38: ; preds = %35
store i32 1, i32* %2
br label %39
39: ; preds = %38, %35
br label %40
40: ; preds = %39, %34
%41 = call i32 (...) @check_player_died()
%42 = load i32, i32* %2
store i32 %42, i32* %1
br label %43
43: ; preds = %40, %29, %23, %16, %6
%44 = load i32, i32* %1
ret i32 %44
}

LLVM IR (-O2):
define i32 @play_turn() {
%1 = tail call i64 (...) @resize_detected()
%2 = icmp eq i64 %1, 0
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 (...) @reset_game()
br label %23
5: ; preds = %0
%6 = tail call i32 (...) @get_char()
%7 = and i32 %6, -33
switch i32 %7, label %10 [
i32 81, label %23
i32 82, label %8
]
8: ; preds = %5
%9 = tail call i32 (...) @reset_game()
br label %23
10: ; preds = %5
%11 = tail call i64 (...) @player_dead()
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = tail call i64 @update_player(i32 %6)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = tail call i64 (...) @update_zombies()
%18 = icmp ne i64 %17, 0
%19 = zext i1 %18 to i32
br label %20
20: ; preds = %16, %13
%21 = phi i32 [ 1, %13 ], [ %19, %16 ]
%22 = tail call i32 (...) @check_player_died()
br label %23
23: ; preds = %5, %8, %20, %10, %3
%24 = phi i32 [ 0, %3 ], [ 0, %8 ], [ %21, %20 ], [ -1, %5 ], [ 0, %10 ]
ret i32 %24
}