#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*/ FALSE;
int /*<<< orphan*/ box(int /*<<< orphan*/ *, int /*<<< orphan*/,
                       int /*<<< orphan*/);
int /*<<< orphan*/ curs_set(int);
int /*<<< orphan*/ delwin(int /*<<< orphan*/ *);
int /*<<< orphan*/ echo();
int /*<<< orphan*/ mvwgetnstr(int /*<<< orphan*/ *, int, int, char *, int);
int /*<<< orphan*/ mvwprintw(int /*<<< orphan*/ *, int, int const, char *);
int /*<<< orphan*/ *newwin(int const, int const, int const, int const);
int /*<<< orphan*/ nodelay(int /*<<< orphan*/ *, int /*<<< orphan*/);
double strlen(char *);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
char *getname() {
  extern int rows, cols;
  const int dialog_height = 7;
  const int dialog_width = 30 + 5;
  const int dialog_nwrow = rows / 2.0 - dialog_height / 2.0;
  const int dialog_nwcol = cols / 2.0 - dialog_width / 2.0;
  const int input_height = 3;
  const int input_width = 30 + 3;
  const int input_nwrow = dialog_nwrow + 3;
  const int input_nwcol = dialog_nwcol + 1;
  char *header = "HIGH SCORE!";
  char *text = "Enter your name:";
  static char name[30 + 1];
  WINDOW *dialog;
  WINDOW *input;
  dialog = newwin(dialog_height, dialog_width, dialog_nwrow, dialog_nwcol);
  input = newwin(input_height, input_width, input_nwrow, input_nwcol);
  box(dialog, 0, 0);
  box(input, 0, 0);
  mvwprintw(dialog, 1, dialog_width / 2.0 - strlen(header) / 2.0, header);
  mvwprintw(dialog, 2, dialog_width / 2.0 - strlen(text) / 2.0, text);
  wrefresh(dialog);
  wrefresh(input);
  nodelay(input, FALSE);
  curs_set(2);
  echo();
  mvwgetnstr(input, 1, 1, name, 30);
  delwin(dialog);
  delwin(input);
  return name;
}


x86 assembly (clang, -O0):
<getname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x7,-0x4(%rbp)
movl   $0x23,-0x8(%rbp)
mov    0x2e1b(%rip),%rax
cvtsi2sdl (%rax),%xmm0
movsd  0xe3f(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe3b(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
mov    0x2e11(%rip),%rax
cvtsi2sdl (%rax),%xmm0
movsd  0xe15(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe01(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
movl   $0x3,-0x14(%rbp)
movl   $0x21,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
lea    0xde7(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xde8(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    $0x7,%edi
mov    $0x23,%esi
call   1060 <newwin@plt>
mov    %rax,-0x38(%rbp)
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    $0x3,%edi
mov    $0x21,%esi
call   1060 <newwin@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1070 <box@plt>
mov    -0x40(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1070 <box@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x50(%rbp),%rdi
movaps %xmm0,%xmm1
movsd  0xd5c(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xd48(%rip),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   10b0 <mvwprintw@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x48(%rbp),%rdi
movaps %xmm0,%xmm1
movsd  0xd1a(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xd06(%rip),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
mov    -0x30(%rbp),%rcx
mov    $0x2,%esi
call   10b0 <mvwprintw@plt>
mov    -0x38(%rbp),%rdi
call   1050 <wrefresh@plt>
mov    -0x40(%rbp),%rdi
call   1050 <wrefresh@plt>
mov    -0x40(%rbp),%rdi
mov    0x2ca3(%rip),%rax
mov    (%rax),%esi
call   10a0 <nodelay@plt>
mov    $0x2,%edi
call   10c0 <curs_set@plt>
mov    $0x0,%al
call   1030 <echo@plt>
mov    -0x40(%rbp),%rdi
mov    $0x1,%edx
lea    0x2d2b(%rip),%rcx
mov    $0x1e,%r8d
mov    %edx,%esi
call   1090 <mvwgetnstr@plt>
mov    -0x38(%rbp),%rdi
call   1080 <delwin@plt>
mov    -0x40(%rbp),%rdi
call   1080 <delwin@plt>
lea    0x2d05(%rip),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getname>:
push   %rbp
push   %r14
push   %rbx
mov    0x2e2d(%rip),%rax
cvtsi2sdl (%rax),%xmm0
movsd  0xe49(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  0xe45(%rip),%xmm0
cvttsd2si %xmm0,%edx
mov    0x2e2a(%rip),%rax
xorps  %xmm0,%xmm0
cvtsi2sdl (%rax),%xmm0
mulsd  %xmm1,%xmm0
addsd  0xe2f(%rip),%xmm0
cvttsd2si %xmm0,%ecx
lea    0x3(%rdx),%ebx
lea    0x1(%rcx),%ebp
mov    $0x7,%edi
mov    $0x23,%esi
call   1060 <newwin@plt>
mov    %rax,%r14
mov    $0x3,%edi
mov    $0x21,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1060 <newwin@plt>
mov    %rax,%rbx
mov    %r14,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <box@plt>
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <box@plt>
lea    0xdee(%rip),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mulsd  0xdbe(%rip),%xmm0
movsd  0xdce(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edx
mov    %r14,%rdi
mov    $0x1,%esi
mov    %rbp,%rcx
call   10b0 <mvwprintw@plt>
lea    0xdc3(%rip),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mulsd  0xd87(%rip),%xmm0
movsd  0xd97(%rip),%xmm1
subsd  %xmm0,%xmm1
cvttsd2si %xmm1,%edx
mov    %r14,%rdi
mov    $0x2,%esi
mov    %rbp,%rcx
call   10b0 <mvwprintw@plt>
mov    %r14,%rdi
call   1050 <wrefresh@plt>
mov    %rbx,%rdi
call   1050 <wrefresh@plt>
mov    0x2d20(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10a0 <nodelay@plt>
mov    $0x2,%edi
call   10c0 <curs_set@plt>
xor    %eax,%eax
call   1030 <echo@plt>
lea    0x2dae(%rip),%rbp
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
mov    $0x1e,%r8d
call   1090 <mvwgetnstr@plt>
mov    %r14,%rdi
call   1080 <delwin@plt>
mov    %rbx,%rdi
call   1080 <delwin@plt>
mov    %rbp,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@rows = external global i32
@cols = external global i32
@.str = [12 x i8] c"HIGH SCORE!\00"
@.str.1 = [17 x i8] c"Enter your name:\00"
@getname.name = internal global [31 x i8] zeroinitializer
@FALSE = global i32 0
define i8* @getname() {
%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 i8*
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca i32*
store i32 7, i32* %1
store i32 35, i32* %2
%13 = load i32, i32* @rows
%14 = sitofp i32 %13 to double
%15 = fdiv double %14, 2.000000e+00
%16 = fsub double %15, 3.500000e+00
%17 = fptosi double %16 to i32
store i32 %17, i32* %3
%18 = load i32, i32* @cols
%19 = sitofp i32 %18 to double
%20 = fdiv double %19, 2.000000e+00
%21 = fsub double %20, 1.750000e+01
%22 = fptosi double %21 to i32
store i32 %22, i32* %4
store i32 3, i32* %5
store i32 33, i32* %6
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 3
store i32 %24, i32* %7
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %9
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8** %10
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = call i32* @newwin(i32 7, i32 35, i32 %27, i32 %28)
store i32* %29, i32** %11
%30 = load i32, i32* %7
%31 = load i32, i32* %8
%32 = call i32* @newwin(i32 3, i32 33, i32 %30, i32 %31)
store i32* %32, i32** %12
%33 = load i32*, i32** %11
%34 = call i32 @box(i32* %33, i32 0, i32 0)
%35 = load i32*, i32** %12
%36 = call i32 @box(i32* %35, i32 0, i32 0)
%37 = load i32*, i32** %11
%38 = load i8*, i8** %9
%39 = call double @strlen(i8* %38)
%40 = fdiv double %39, 2.000000e+00
%41 = fsub double 1.750000e+01, %40
%42 = fptosi double %41 to i32
%43 = load i8*, i8** %9
%44 = call i32 @mvwprintw(i32* %37, i32 1, i32 %42, i8* %43)
%45 = load i32*, i32** %11
%46 = load i8*, i8** %10
%47 = call double @strlen(i8* %46)
%48 = fdiv double %47, 2.000000e+00
%49 = fsub double 1.750000e+01, %48
%50 = fptosi double %49 to i32
%51 = load i8*, i8** %10
%52 = call i32 @mvwprintw(i32* %45, i32 2, i32 %50, i8* %51)
%53 = load i32*, i32** %11
%54 = call i32 @wrefresh(i32* %53)
%55 = load i32*, i32** %12
%56 = call i32 @wrefresh(i32* %55)
%57 = load i32*, i32** %12
%58 = load i32, i32* @FALSE
%59 = call i32 @nodelay(i32* %57, i32 %58)
%60 = call i32 @curs_set(i32 2)
%61 = call i32 (...) @echo()
%62 = load i32*, i32** %12
%63 = call i32 @mvwgetnstr(i32* %62, i32 1, i32 1, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @getname.name, i64 0, i64 0), i32 30)
%64 = load i32*, i32** %11
%65 = call i32 @delwin(i32* %64)
%66 = load i32*, i32** %12
%67 = call i32 @delwin(i32* %66)
ret i8* getelementptr inbounds ([31 x i8], [31 x i8]* @getname.name, i64 0, i64 0)
}

LLVM IR (-O2):
@rows = external global i32
@cols = external global i32
@.str = [12 x i8] c"HIGH SCORE!\00"
@.str.1 = [17 x i8] c"Enter your name:\00"
@getname.name = internal global [31 x i8] zeroinitializer
@FALSE = global i32 0
define i8* @getname() {
%1 = load i32, i32* @rows
%2 = sitofp i32 %1 to double
%3 = fmul double %2, 5.000000e-01
%4 = fadd double %3, -3.500000e+00
%5 = fptosi double %4 to i32
%6 = load i32, i32* @cols
%7 = sitofp i32 %6 to double
%8 = fmul double %7, 5.000000e-01
%9 = fadd double %8, -1.750000e+01
%10 = fptosi double %9 to i32
%11 = add nsw i32 %5, 3
%12 = add nsw i32 %10, 1
%13 = tail call i32* @newwin(i32 7, i32 35, i32 %5, i32 %10)
%14 = tail call i32* @newwin(i32 3, i32 33, i32 %11, i32 %12)
%15 = tail call i32 @box(i32* %13, i32 0, i32 0)
%16 = tail call i32 @box(i32* %14, i32 0, i32 0)
%17 = tail call double @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%18 = fmul double %17, 5.000000e-01
%19 = fsub double 1.750000e+01, %18
%20 = fptosi double %19 to i32
%21 = tail call i32 @mvwprintw(i32* %13, i32 1, i32 %20, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%22 = tail call double @strlen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%23 = fmul double %22, 5.000000e-01
%24 = fsub double 1.750000e+01, %23
%25 = fptosi double %24 to i32
%26 = tail call i32 @mvwprintw(i32* %13, i32 2, i32 %25, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%27 = tail call i32 @wrefresh(i32* %13)
%28 = tail call i32 @wrefresh(i32* %14)
%29 = load i32, i32* @FALSE
%30 = tail call i32 @nodelay(i32* %14, i32 %29)
%31 = tail call i32 @curs_set(i32 2)
%32 = tail call i32 (...) @echo()
%33 = tail call i32 @mvwgetnstr(i32* %14, i32 1, i32 1, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @getname.name, i64 0, i64 0), i32 30)
%34 = tail call i32 @delwin(i32* %13)
%35 = tail call i32 @delwin(i32* %14)
ret i8* getelementptr inbounds ([31 x i8], [31 x i8]* @getname.name, i64 0, i64 0)
}