#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*/ printw(char *);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ stdscr;
int strlen(char *);
int main(int argc, char const *argv[]) {
  char mesg[] = "Just a string";
  int row, col;
  initscr();
  getmaxyx(stdscr, row, col);
  mvprintw(row / 2, (col - strlen(mesg)) / 2, "%s", mesg);
  mvprintw(row - 2, 0, "This screen has %d rows and %d columns\n", row, col);
  printw(
      "Try resizing your window (if possible) and then run this program again");
  refresh();
  getch();
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe63(%rip),%rax
mov    %rax,-0x1e(%rbp)
mov    0xe61(%rip),%eax
mov    %eax,-0x16(%rbp)
mov    0xe5b(%rip),%ax
mov    %ax,-0x12(%rbp)
mov    $0x0,%al
call   1040 <initscr@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1050 <getmaxyx@plt>
mov    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x1e(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%edi
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    -0x1e(%rbp),%rcx
lea    0xe02(%rip),%rdx
mov    $0x0,%al
call   10a0 <mvprintw@plt>
mov    -0x24(%rbp),%edi
sub    $0x2,%edi
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
xor    %esi,%esi
lea    0xde8(%rip),%rdx
mov    $0x0,%al
call   10a0 <mvprintw@plt>
lea    0xe02(%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>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
call   1050 <getmaxyx@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0xe45(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   10a0 <mvprintw@plt>
lea    0xe33(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   10a0 <mvprintw@plt>
lea    0xe4b(%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.mesg = [14 x i8] c"Just a string\00"
@stdscr = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [40 x i8] c"This screen has %d rows and %d columns\0A\00"
@.str.2 = [71 x i8] c"Try resizing your window (if possible) and then run this program again\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [14 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [14 x i8]* %6 to i8*
%10 = call i32 (...) @initscr()
%11 = load i32, i32* @stdscr
%12 = load i32, i32* %7
%13 = load i32, i32* %8
%14 = call i32 @getmaxyx(i32 %11, i32 %12, i32 %13)
%15 = load i32, i32* %7
%16 = sdiv i32 %15, 2
%17 = load i32, i32* %8
%18 = getelementptr inbounds [14 x i8], [14 x i8]* %6, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = sub nsw i32 %17, %19
%21 = sdiv i32 %20, 2
%22 = getelementptr inbounds [14 x i8], [14 x i8]* %6, i64 0, i64 0
%23 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %16, i32 %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = load i32, i32* %7
%25 = sub nsw i32 %24, 2
%26 = load i32, i32* %7
%27 = load i32, i32* %8
%28 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %25, i32 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %26, i32 %27)
%29 = call i32 @printw(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.2, i64 0, i64 0))
%30 = call i32 (...) @refresh()
%31 = call i32 (...) @getch()
%32 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@__const.main.mesg = [14 x i8] c"Just a string\00"
@stdscr = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [40 x i8] c"This screen has %d rows and %d columns\0A\00"
@.str.2 = [71 x i8] c"Try resizing your window (if possible) and then run this program again\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [14 x i8]
%4 = getelementptr inbounds [14 x i8], [14 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (...) @initscr()
%6 = load i32, i32* @stdscr
%7 = tail call i32 @getmaxyx(i32 %6, i32 undef, i32 undef)
%8 = call i32 @strlen(i8* %4)
%9 = 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* %4)
%10 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 undef, i32 undef)
%11 = call i32 @printw(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (...) @refresh()
%13 = call i32 (...) @getch()
%14 = call i32 (...) @endwin()
ret i32 0
}