#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() {
  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    0xe6a(%rip),%rax
mov    %rax,-0x12(%rbp)
mov    0xe68(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xe62(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    $0x0,%al
call   1040 <initscr@plt>
mov    0x2e2c(%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    0xe09(%rip),%rdx
mov    $0x0,%al
call   10a0 <mvprintw@plt>
mov    -0x18(%rbp),%edi
sub    $0x2,%edi
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
xor    %esi,%esi
lea    0xdef(%rip),%rdx
mov    $0x0,%al
call   10a0 <mvprintw@plt>
lea    0xe09(%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 = [70 x i8] c"Try resizing your window(if possible) and then run this program again\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 = load i32, i32* @stdscr
%8 = load i32, i32* %3
%9 = load i32, i32* %4
%10 = call i32 @getmaxyx(i32 %7, i32 %8, i32 %9)
%11 = load i32, i32* %3
%12 = sdiv i32 %11, 2
%13 = load i32, i32* %4
%14 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = sub nsw i32 %13, %15
%17 = sdiv i32 %16, 2
%18 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%19 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %12, i32 %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i32, i32* %3
%21 = sub nsw i32 %20, 2
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %21, i32 0, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23)
%25 = call i32 @printw(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 (...) @refresh()
%27 = call i32 (...) @getch()
%28 = 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 = [70 x i8] c"Try resizing your window(if possible) and then run this program again\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 = load i32, i32* @stdscr
%5 = tail call i32 @getmaxyx(i32 %4, i32 undef, i32 undef)
%6 = call i32 @strlen(i8* %2)
%7 = 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)
%8 = 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)
%9 = call i32 @printw(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (...) @refresh()
%11 = call i32 (...) @getch()
%12 = call i32 (...) @endwin()
ret i32 0
}