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

/* Variables and functions */
int /*<<< orphan*/ erase();
int /*<<< orphan*/ getbegyx(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ mvprintw(int, int, char const *);
int /*<<< orphan*/ stdscr;
int strlen(char const *);
int gui_render_endscreen() {
  int win_w, win_h;
  int win_l, win_t;
  int num_messages;
  int i;
  int row, col;
  const char *messages[] = {
      "Thanks for playing battlecurses!", "Press any key to quit.", "",
      "battlecurses is free software licensed under GNU GPLv3.",
      "Leave feedback at <https://github.com/TorinCooperBennun/battlecurses>."};
  num_messages = sizeof(messages) / sizeof(const char *);
  erase();
  getmaxyx(stdscr, win_h, win_w);
  getbegyx(stdscr, win_t, win_l);
  for (i = 0; i < num_messages; ++i) {
    row = win_t + (win_h - 1) / 2 - num_messages / 2 + i;
    col = win_l + (win_w - 1) / 2 - strlen(messages[i]) / 2;
    mvprintw(row, col, messages[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<gui_render_endscreen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
lea    0xe81(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xe97(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xe8b(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe98(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xec5(%rip),%rax
mov    %rax,-0x30(%rbp)
movl   $0x5,-0x14(%rbp)
mov    $0x0,%al
call   1040 <erase@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
call   1060 <getmaxyx@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1070 <getbegyx@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    128e <gui_render_endscreen+0x12e>
mov    -0x10(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x60(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x5c(%rbp),%eax
sub    %ecx,%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x58(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x54(%rbp)
movslq -0x18(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rdi
call   1030 <strlen@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
movslq -0x18(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rdx
call   1080 <mvprintw@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11ec <gui_render_endscreen+0x8c>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gui_render_endscreen>:
push   %rbx
xor    %eax,%eax
call   1040 <erase@plt>
mov    0x2e89(%rip),%rbx
mov    (%rbx),%edi
call   1050 <getmaxyx@plt>
mov    (%rbx),%edi
call   1060 <getbegyx@plt>
lea    0xe8c(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdx
call   1070 <mvprintw@plt>
lea    0xe96(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdx
call   1070 <mvprintw@plt>
lea    0xe7e(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdx
call   1070 <mvprintw@plt>
lea    0xe7f(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdx
call   1070 <mvprintw@plt>
lea    0xea0(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdx
call   1070 <mvprintw@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Thanks for playing battlecurses!\00"
@.str.1 = [23 x i8] c"Press any key to quit.\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [56 x i8] c"battlecurses is free software licensed under GNU GPLv3.\00"
@.str.4 = [71 x i8] c"Leave feedback at <https://github.com/TorinCooperBennun/battlecurses>.\00"
@stdscr = global i32 0
define i32 @gui_render_endscreen() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [5 x i8*]
%10 = bitcast [5 x i8*]* %9 to i8*
%11 = bitcast i8* %10 to [5 x i8*]*
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 0
store i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 1
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 2
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i32 0, i32 0), i8** %14
%15 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 3
store i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i32 0, i32 0), i8** %15
%16 = getelementptr inbounds [5 x i8*], [5 x i8*]* %11, i32 0, i32 4
store i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.4, i32 0, i32 0), i8** %16
store i32 5, i32* %5
%17 = call i32 (...) @erase()
%18 = load i32, i32* @stdscr
%19 = load i32, i32* %2
%20 = load i32, i32* %1
%21 = call i32 @getmaxyx(i32 %18, i32 %19, i32 %20)
%22 = load i32, i32* @stdscr
%23 = load i32, i32* %4
%24 = load i32, i32* %3
%25 = call i32 @getbegyx(i32 %22, i32 %23, i32 %24)
store i32 0, i32* %6
br label %26
26: ; preds = %60, %0
%27 = load i32, i32* %6
%28 = load i32, i32* %5
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %63
30: ; preds = %26
%31 = load i32, i32* %4
%32 = load i32, i32* %2
%33 = sub nsw i32 %32, 1
%34 = sdiv i32 %33, 2
%35 = add nsw i32 %31, %34
%36 = load i32, i32* %5
%37 = sdiv i32 %36, 2
%38 = sub nsw i32 %35, %37
%39 = load i32, i32* %6
%40 = add nsw i32 %38, %39
store i32 %40, i32* %7
%41 = load i32, i32* %3
%42 = load i32, i32* %1
%43 = sub nsw i32 %42, 1
%44 = sdiv i32 %43, 2
%45 = add nsw i32 %41, %44
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [5 x i8*], [5 x i8*]* %9, i64 0, i64 %47
%49 = load i8*, i8** %48
%50 = call i32 @strlen(i8* %49)
%51 = sdiv i32 %50, 2
%52 = sub nsw i32 %45, %51
store i32 %52, i32* %8
%53 = load i32, i32* %7
%54 = load i32, i32* %8
%55 = load i32, i32* %6
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [5 x i8*], [5 x i8*]* %9, i64 0, i64 %56
%58 = load i8*, i8** %57
%59 = call i32 @mvprintw(i32 %53, i32 %54, i8* %58)
br label %60
60: ; preds = %30
%61 = load i32, i32* %6
%62 = add nsw i32 %61, 1
store i32 %62, i32* %6
br label %26
63: ; preds = %26
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"Thanks for playing battlecurses!\00"
@.str.1 = [23 x i8] c"Press any key to quit.\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [56 x i8] c"battlecurses is free software licensed under GNU GPLv3.\00"
@.str.4 = [71 x i8] c"Leave feedback at <https://github.com/TorinCooperBennun/battlecurses>.\00"
@stdscr = global i32 0
define i32 @gui_render_endscreen() {
%1 = tail call i32 (...) @erase()
%2 = load i32, i32* @stdscr
%3 = tail call i32 @getmaxyx(i32 %2, i32 undef, i32 undef)
%4 = load i32, i32* @stdscr
%5 = tail call i32 @getbegyx(i32 %4, i32 undef, i32 undef)
%6 = tail call i32 @strlen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @mvprintw(i32 undef, i32 undef, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @mvprintw(i32 undef, i32 undef, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @strlen(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 @mvprintw(i32 undef, i32 undef, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @strlen(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0))
%13 = tail call i32 @mvprintw(i32 undef, i32 undef, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0))
%14 = tail call i32 @strlen(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.4, i64 0, i64 0))
%15 = tail call i32 @mvprintw(i32 undef, i32 undef, i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}