#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*/ clear_screen();
int /*<<< orphan*/ draw_char(int, int, char);
int /*<<< orphan*/ draw_menu(int, int);
int /*<<< orphan*/ draw_score(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ get_screen_size_(int *, int *);
int /*<<< orphan*/ show_screen();
int wait_char();
void running_zombie() {
  int width;
  int height;
  get_screen_size_(&(width), &(height));
  int x = width * 4 / 5;
  int y = height * 4 / 5;
  int score = 0;
  int turn = 0;
  draw_score(30, 0, score);
  draw_menu(width, height);
  draw_char(x, y, 'Z');
  show_screen();
  int key = wait_char();
  turn++;
  while ((key != 'q') && (key >= 0)) {
    switch (key) {
    case '4':
      x--;
      break;
    case '6':
      x++;
      break;
    case '8':
      y--;
      break;
    case '2':
      y++;
      break;
    case '7':
      x--;
      y--;
      break;
    case '3':
      x++;
      y++;
      break;
    case '9':
      x++;
      y--;
      break;
    case '1':
      x--;
      y++;
      break;
    }
    if ((turn % 5) == 0) {
      score++;
      turn = 0;
    }
    clear_screen();
    draw_score(30, 0, score);
    draw_menu(width, height);
    draw_char(x, y, 'Z');
    show_screen();
    key = wait_char();
    turn++;
  }
}


x86 assembly (clang, -O0):
<running_zombie>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <get_screen_size_@plt>
mov    -0x4(%rbp),%eax
shl    $0x2,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x2,%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%edx
mov    $0x1e,%edi
xor    %esi,%esi
call   1070 <draw_score@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1090 <draw_menu@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    $0x5a,%edx
call   1060 <draw_char@plt>
mov    $0x0,%al
call   1050 <show_screen@plt>
mov    $0x0,%al
call   1030 <wait_char@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x71,-0x1c(%rbp)
mov    %al,-0x1d(%rbp)
je     1212 <running_zombie+0xa2>
cmpl   $0x0,-0x1c(%rbp)
setge  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1222 <running_zombie+0xb2>
jmp    134e <running_zombie+0x1de>
mov    -0x1c(%rbp),%eax
add    $0xffffffcf,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x8,%eax
ja     12da <running_zombie+0x16a>
mov    -0x28(%rbp),%rax
lea    0xdbe(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    12da <running_zombie+0x16a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12da <running_zombie+0x16a>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    12da <running_zombie+0x16a>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    12da <running_zombie+0x16a>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    12da <running_zombie+0x16a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    12da <running_zombie+0x16a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    12da <running_zombie+0x16a>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    12fe <running_zombie+0x18e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1080 <clear_screen@plt>
mov    -0x14(%rbp),%edx
mov    $0x1e,%edi
xor    %esi,%esi
call   1070 <draw_score@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1090 <draw_menu@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    $0x5a,%edx
call   1060 <draw_char@plt>
mov    $0x0,%al
call   1050 <show_screen@plt>
mov    $0x0,%al
call   1030 <wait_char@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11f9 <running_zombie+0x89>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<running_zombie>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
call   1040 <get_screen_size_@plt>
mov    0x4(%rsp),%eax
shl    $0x2,%eax
cltq
imul   $0x66666667,%rax,%r14
mov    %r14,%rax
shr    $0x3f,%rax
sar    $0x21,%r14
add    %eax,%r14d
mov    (%rsp),%eax
shl    $0x2,%eax
cltq
imul   $0x66666667,%rax,%r13
mov    %r13,%rax
shr    $0x3f,%rax
sar    $0x21,%r13
add    %eax,%r13d
mov    $0x1e,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <draw_score@plt>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
call   1090 <draw_menu@plt>
mov    %r14d,%edi
mov    %r13d,%esi
mov    $0x5a,%edx
call   1060 <draw_char@plt>
xor    %eax,%eax
call   1050 <show_screen@plt>
xor    %eax,%eax
call   1030 <wait_char@plt>
cmp    $0x71,%eax
je     12c6 <running_zombie+0x156>
test   %eax,%eax
js     12c6 <running_zombie+0x156>
mov    $0x1,%r15d
lea    0xde7(%rip),%r12
mov    $0x1,%ebx
xor    %ebp,%ebp
add    $0xffffffcf,%eax
cmp    $0x8,%eax
ja     125b <running_zombie+0xeb>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
add    $0xffffffff,%r14d
jmp    123b <running_zombie+0xcb>
add    $0x1,%r14d
add    $0x1,%r13d
jmp    125b <running_zombie+0xeb>
add    $0xffffffff,%r14d
jmp    125b <running_zombie+0xeb>
add    $0x1,%r14d
jmp    125b <running_zombie+0xeb>
add    $0xffffffff,%r14d
jmp    1257 <running_zombie+0xe7>
add    $0x1,%r14d
add    $0xffffffff,%r13d
imul   $0xcccccccd,%ebx,%eax
add    $0x19999999,%eax
cmp    $0x33333333,%eax
adc    $0x0,%ebp
add    $0x1,%ebx
cmp    $0x33333333,%eax
cmovb  %r15d,%ebx
xor    %eax,%eax
call   1080 <clear_screen@plt>
mov    $0x1e,%edi
xor    %esi,%esi
mov    %ebp,%edx
call   1070 <draw_score@plt>
mov    0x4(%rsp),%edi
mov    (%rsp),%esi
call   1090 <draw_menu@plt>
mov    %r14d,%edi
mov    %r13d,%esi
mov    $0x5a,%edx
call   1060 <draw_char@plt>
xor    %eax,%eax
call   1050 <show_screen@plt>
xor    %eax,%eax
call   1030 <wait_char@plt>
cmp    $0x71,%eax
je     12c6 <running_zombie+0x156>
test   %eax,%eax
jns    1220 <running_zombie+0xb0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @running_zombie() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = call i32 @get_screen_size_(i32* %1, i32* %2)
%9 = load i32, i32* %1
%10 = mul nsw i32 %9, 4
%11 = sdiv i32 %10, 5
store i32 %11, i32* %3
%12 = load i32, i32* %2
%13 = mul nsw i32 %12, 4
%14 = sdiv i32 %13, 5
store i32 %14, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%15 = load i32, i32* %5
%16 = call i32 @draw_score(i32 30, i32 0, i32 %15)
%17 = load i32, i32* %1
%18 = load i32, i32* %2
%19 = call i32 @draw_menu(i32 %17, i32 %18)
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = call i32 @draw_char(i32 %20, i32 %21, i8 signext 90)
%23 = call i32 (...) @show_screen()
%24 = call i32 (...) @wait_char()
store i32 %24, i32* %7
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %27
27: ; preds = %76, %0
%28 = load i32, i32* %7
%29 = icmp ne i32 %28, 113
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* %7
%32 = icmp sge i32 %31, 0
br label %33
33: ; preds = %30, %27
%34 = phi i1 [ false, %27 ], [ %32, %30 ]
br i1 %34, label %35, label %90
35: ; preds = %33
%36 = load i32, i32* %7
switch i32 %36, label %69 [
i32 52, label %37
i32 54, label %40
i32 56, label %43
i32 50, label %46
i32 55, label %49
i32 51, label %54
i32 57, label %59
i32 49, label %64
]
37: ; preds = %35
%38 = load i32, i32* %3
%39 = add nsw i32 %38, -1
store i32 %39, i32* %3
br label %69
40: ; preds = %35
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %69
43: ; preds = %35
%44 = load i32, i32* %4
%45 = add nsw i32 %44, -1
store i32 %45, i32* %4
br label %69
46: ; preds = %35
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 1
store i32 %48, i32* %4
br label %69
49: ; preds = %35
%50 = load i32, i32* %3
%51 = add nsw i32 %50, -1
store i32 %51, i32* %3
%52 = load i32, i32* %4
%53 = add nsw i32 %52, -1
store i32 %53, i32* %4
br label %69
54: ; preds = %35
%55 = load i32, i32* %3
%56 = add nsw i32 %55, 1
store i32 %56, i32* %3
%57 = load i32, i32* %4
%58 = add nsw i32 %57, 1
store i32 %58, i32* %4
br label %69
59: ; preds = %35
%60 = load i32, i32* %3
%61 = add nsw i32 %60, 1
store i32 %61, i32* %3
%62 = load i32, i32* %4
%63 = add nsw i32 %62, -1
store i32 %63, i32* %4
br label %69
64: ; preds = %35
%65 = load i32, i32* %3
%66 = add nsw i32 %65, -1
store i32 %66, i32* %3
%67 = load i32, i32* %4
%68 = add nsw i32 %67, 1
store i32 %68, i32* %4
br label %69
69: ; preds = %35, %64, %59, %54, %49, %46, %43, %40, %37
%70 = load i32, i32* %6
%71 = srem i32 %70, 5
%72 = icmp eq i32 %71, 0
br i1 %72, label %73, label %76
73: ; preds = %69
%74 = load i32, i32* %5
%75 = add nsw i32 %74, 1
store i32 %75, i32* %5
store i32 0, i32* %6
br label %76
76: ; preds = %73, %69
%77 = call i32 (...) @clear_screen()
%78 = load i32, i32* %5
%79 = call i32 @draw_score(i32 30, i32 0, i32 %78)
%80 = load i32, i32* %1
%81 = load i32, i32* %2
%82 = call i32 @draw_menu(i32 %80, i32 %81)
%83 = load i32, i32* %3
%84 = load i32, i32* %4
%85 = call i32 @draw_char(i32 %83, i32 %84, i8 signext 90)
%86 = call i32 (...) @show_screen()
%87 = call i32 (...) @wait_char()
store i32 %87, i32* %7
%88 = load i32, i32* %6
%89 = add nsw i32 %88, 1
store i32 %89, i32* %6
br label %27
90: ; preds = %33
ret void
}

LLVM IR (-O2):
define void @running_zombie() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @get_screen_size_(i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = shl nsw i32 %6, 2
%8 = sdiv i32 %7, 5
%9 = load i32, i32* %2
%10 = shl nsw i32 %9, 2
%11 = sdiv i32 %10, 5
%12 = call i32 @draw_score(i32 30, i32 0, i32 0)
%13 = load i32, i32* %1
%14 = load i32, i32* %2
%15 = call i32 @draw_menu(i32 %13, i32 %14)
%16 = call i32 @draw_char(i32 %8, i32 %11, i8 signext 90)
%17 = call i32 (...) @show_screen()
%18 = call i32 (...) @wait_char()
%19 = icmp ne i32 %18, 113
%20 = icmp sgt i32 %18, -1
%21 = and i1 %19, %20
br i1 %21, label %22, label %68
22: ; preds = %0, %48
%23 = phi i32 [ %62, %48 ], [ %18, %0 ]
%24 = phi i32 [ %64, %48 ], [ 1, %0 ]
%25 = phi i32 [ %54, %48 ], [ 0, %0 ]
%26 = phi i32 [ %50, %48 ], [ %11, %0 ]
%27 = phi i32 [ %49, %48 ], [ %8, %0 ]
switch i32 %23, label %48 [
i32 52, label %28
i32 54, label %30
i32 56, label %32
i32 50, label %34
i32 55, label %36
i32 51, label %39
i32 57, label %42
i32 49, label %45
]
28: ; preds = %22
%29 = add nsw i32 %27, -1
br label %48
30: ; preds = %22
%31 = add nsw i32 %27, 1
br label %48
32: ; preds = %22
%33 = add nsw i32 %26, -1
br label %48
34: ; preds = %22
%35 = add nsw i32 %26, 1
br label %48
36: ; preds = %22
%37 = add nsw i32 %27, -1
%38 = add nsw i32 %26, -1
br label %48
39: ; preds = %22
%40 = add nsw i32 %27, 1
%41 = add nsw i32 %26, 1
br label %48
42: ; preds = %22
%43 = add nsw i32 %27, 1
%44 = add nsw i32 %26, -1
br label %48
45: ; preds = %22
%46 = add nsw i32 %27, -1
%47 = add nsw i32 %26, 1
br label %48
48: ; preds = %22, %45, %42, %39, %36, %34, %32, %30, %28
%49 = phi i32 [ %27, %22 ], [ %46, %45 ], [ %43, %42 ], [ %40, %39 ], [ %37, %36 ], [ %27, %34 ], [ %27, %32 ], [ %31, %30 ], [ %29, %28 ]
%50 = phi i32 [ %26, %22 ], [ %47, %45 ], [ %44, %42 ], [ %41, %39 ], [ %38, %36 ], [ %35, %34 ], [ %33, %32 ], [ %26, %30 ], [ %26, %28 ]
%51 = srem i32 %24, 5
%52 = icmp eq i32 %51, 0
%53 = zext i1 %52 to i32
%54 = add nuw nsw i32 %25, %53
%55 = call i32 (...) @clear_screen()
%56 = call i32 @draw_score(i32 30, i32 0, i32 %54)
%57 = load i32, i32* %1
%58 = load i32, i32* %2
%59 = call i32 @draw_menu(i32 %57, i32 %58)
%60 = call i32 @draw_char(i32 %49, i32 %50, i8 signext 90)
%61 = call i32 (...) @show_screen()
%62 = call i32 (...) @wait_char()
%63 = add nsw i32 %24, 1
%64 = select i1 %52, i32 1, i32 %63
%65 = icmp ne i32 %62, 113
%66 = icmp sgt i32 %62, -1
%67 = and i1 %65, %66
br i1 %67, label %22, label %68
68: ; preds = %48, %0
ret void
}