#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*/ endwin();
int /*<<< orphan*/ getch();
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ mvprintw(int, int, char *, ...);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ printw(char *);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ stdscr;
int strlen(char *);
int main() {
  char msg[] = "Just a string";
  int row, col;
  initscr();
  noecho();
  getmaxyx(stdscr, row, col);
  mvprintw(row / 2, (col - strlen(msg)) / 2, "%s", msg);
  mvprintw(row - 2, 0, "%d cols and %d rows\n", col, row);
  printw("Try resizing?\n");
  refresh();
  getch();
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe5a(%rip),%rax
mov    %rax,-0x12(%rbp)
mov    0xe58(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xe52(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    $0x0,%al
call   1040 <initscr@plt>
mov    $0x0,%al
call   10a0 <noecho@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1050 <getmaxyx@plt>
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
lea    -0x12(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x24(%rbp),%edi
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    -0x12(%rbp),%rcx
lea    0xdf2(%rip),%rdx
mov    $0x0,%al
call   10b0 <mvprintw@plt>
mov    -0x18(%rbp),%edi
sub    $0x2,%edi
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%r8d
xor    %esi,%esi
lea    0xdd8(%rip),%rdx
mov    $0x0,%al
call   10b0 <mvprintw@plt>
lea    0xddf(%rip),%rdi
call   1060 <printw@plt>
mov    $0x0,%al
call   1070 <refresh@plt>
mov    $0x0,%al
call   1080 <getch@plt>
mov    $0x0,%al
call   1090 <endwin@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movabs $0x676e6972747320,%rax
mov    %rax,0x6(%rsp)
movabs $0x732061207473754a,%rax
61 20 73
mov    %rax,(%rsp)
xor    %eax,%eax
call   1040 <initscr@plt>
xor    %eax,%eax
call   10a0 <noecho@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
call   1050 <getmaxyx@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xe2e(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   10b0 <mvprintw@plt>
lea    0xe1c(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   10b0 <mvprintw@plt>
lea    0xe21(%rip),%rdi
call   1060 <printw@plt>
xor    %eax,%eax
call   1070 <refresh@plt>
xor    %eax,%eax
call   1080 <getch@plt>
xor    %eax,%eax
call   1090 <endwin@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.msg = [14 x i8] c"Just a string\00"
@stdscr = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [21 x i8] c"%d cols and %d rows\0A\00"
@.str.2 = [15 x i8] c"Try resizing?\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [14 x i8]
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [14 x i8]* %2 to i8*
%6 = call i32 (...) @initscr()
%7 = call i32 (...) @noecho()
%8 = load i32, i32* @stdscr
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = call i32 @getmaxyx(i32 %8, i32 %9, i32 %10)
%12 = load i32, i32* %3
%13 = sdiv i32 %12, 2
%14 = load i32, i32* %4
%15 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%16 = call i32 @strlen(i8* %15)
%17 = sub nsw i32 %14, %16
%18 = sdiv i32 %17, 2
%19 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%20 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %13, i32 %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* %3
%22 = sub nsw i32 %21, 2
%23 = load i32, i32* %4
%24 = load i32, i32* %3
%25 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %22, i32 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %24)
%26 = call i32 @printw(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 (...) @refresh()
%28 = call i32 (...) @getch()
%29 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@__const.main.msg = [14 x i8] c"Just a string\00"
@stdscr = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [21 x i8] c"%d cols and %d rows\0A\00"
@.str.2 = [15 x i8] c"Try resizing?\0A\00"
define i32 @main() {
%1 = alloca [14 x i8]
%2 = getelementptr inbounds [14 x i8], [14 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @initscr()
%4 = tail call i32 (...) @noecho()
%5 = load i32, i32* @stdscr
%6 = tail call i32 @getmaxyx(i32 %5, i32 undef, i32 undef)
%7 = call i32 @strlen(i8* %2)
%8 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 0, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%9 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 undef, i32 undef)
%10 = call i32 @printw(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (...) @refresh()
%12 = call i32 (...) @getch()
%13 = call i32 (...) @endwin()
ret i32 0
}