#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*/ WINDOW;

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ FreeWorm();
int /*<<< orphan*/ curs_set(int);
int /*<<< orphan*/ delwin(int /*<<< orphan*/ *);
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ refresh();
void Quit(int reason) {
  extern WINDOW *mainwin;
  extern int oldcur;
  extern int score;
  delwin(mainwin);
  curs_set(oldcur);
  endwin();
  refresh();
  FreeWorm();
  switch (reason) {
  case 3:
    printf("\nYou hit a wall!\n");
    printf("Your score is %d\n", score);
    break;
  case 2:
    printf("\nYou ran into yourself!\n");
    printf("Your score is %d\n", score);
    break;
  default:
    printf("\nGoodbye!\n");
    break;
  }
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<Quit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e66(%rip),%rax
mov    (%rax),%rdi
call   1050 <delwin@plt>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
call   1090 <curs_set@plt>
xor    %eax,%eax
mov    %al,-0x9(%rbp)
call   1070 <endwin@plt>
mov    -0x9(%rbp),%al
call   1060 <refresh@plt>
mov    -0x9(%rbp),%al
call   1040 <FreeWorm@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x2,%eax
je     1201 <Quit+0x91>
jmp    11c6 <Quit+0x56>
mov    -0x8(%rbp),%eax
sub    $0x3,%eax
jne    122b <Quit+0xbb>
jmp    11d7 <Quit+0x67>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%esi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1239 <Quit+0xc9>
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dc2(%rip),%rax
mov    (%rax),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1239 <Quit+0xc9>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<Quit>:
push   %rbx
mov    %edi,%ebx
mov    0x2e5e(%rip),%rax
mov    (%rax),%rdi
call   1060 <delwin@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
call   10a0 <curs_set@plt>
xor    %eax,%eax
call   1080 <endwin@plt>
xor    %eax,%eax
call   1070 <refresh@plt>
xor    %eax,%eax
call   1050 <FreeWorm@plt>
cmp    $0x2,%ebx
je     11c8 <Quit+0x48>
cmp    $0x3,%ebx
jne    11ed <Quit+0x6d>
lea    0xe64(%rip),%rdi
jmp    11cf <Quit+0x4f>
lea    0xe43(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%esi
lea    0xe1c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11f9 <Quit+0x79>
lea    0xe47(%rip),%rdi
call   1030 <puts@plt>
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@mainwin = external global i32*
@oldcur = external global i32
@.str = [18 x i8] c"\0AYou hit a wall!\0A\00"
@.str.1 = [18 x i8] c"Your score is %d\0A\00"
@score = external global i32
@.str.2 = [25 x i8] c"\0AYou ran into yourself!\0A\00"
@.str.3 = [11 x i8] c"\0AGoodbye!\0A\00"
@EXIT_SUCCESS = global i32 0
define void @Quit(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32*, i32** @mainwin
%4 = call i32 @delwin(i32* %3)
%5 = load i32, i32* @oldcur
%6 = call i32 @curs_set(i32 %5)
%7 = call i32 (...) @endwin()
%8 = call i32 (...) @refresh()
%9 = call i32 (...) @FreeWorm()
%10 = load i32, i32* %2
switch i32 %10, label %19 [
i32 3, label %11
i32 2, label %15
]
11: ; preds = %1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @score
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %21
15: ; preds = %1
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%17 = load i32, i32* @score
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %21
19: ; preds = %1
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %19, %15, %11
%22 = load i32, i32* @EXIT_SUCCESS
%23 = call i32 @exit(i32 %22)
unreachable
}

LLVM IR (-O2):
@mainwin = external global i32*
@oldcur = external global i32
@.str.1 = [18 x i8] c"Your score is %d\0A\00"
@score = external global i32
@EXIT_SUCCESS = global i32 0
@str = [24 x i8] c"\0AYou ran into yourself!\00"
@str.4 = [17 x i8] c"\0AYou hit a wall!\00"
@str.5 = [10 x i8] c"\0AGoodbye!\00"
define void @Quit(i32 %0) {
%2 = load i32*, i32** @mainwin
%3 = tail call i32 @delwin(i32* %2)
%4 = load i32, i32* @oldcur
%5 = tail call i32 @curs_set(i32 %4)
%6 = tail call i32 (...) @endwin()
%7 = tail call i32 (...) @refresh()
%8 = tail call i32 (...) @FreeWorm()
switch i32 %0, label %17 [
i32 3, label %9
i32 2, label %13
]
9: ; preds = %1
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.4, i64 0, i64 0))
%11 = load i32, i32* @score
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %19
13: ; preds = %1
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%15 = load i32, i32* @score
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %15)
br label %19
17: ; preds = %1
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.5, i64 0, i64 0))
br label %19
19: ; preds = %17, %13, %9
%20 = load i32, i32* @EXIT_SUCCESS
%21 = tail call i32 @exit(i32 %20)
unreachable
}