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

/* Variables and functions */
int /*<<< orphan*/ A_BOLD;
int /*<<< orphan*/ A_ITALIC;
int /*<<< orphan*/ attroff(int /*<<< orphan*/);
int /*<<< orphan*/ attron(int /*<<< orphan*/);
int /*<<< orphan*/ getch();
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ mvprintw(int, int, char *, ...);
int /*<<< orphan*/ refresh();
int snprintf(char *, int, char *);
int /*<<< orphan*/ stdscr;
void draw(void) {
  int row, col, len;
  char msg[80];
  getmaxyx(stdscr, row, col);
  attron(A_BOLD);
  mvprintw(0, 0, "Is this thing on?");
  attroff(A_BOLD);
  attron(A_ITALIC);
  len = snprintf(msg, sizeof(msg), "Hello, World!\n");
  mvprintw(row / 2, (col - len) / 2, "%s", msg);
  mvprintw(row - 2, 0, "%dx%d\n", row, col);
  mvprintw(row - 1, 0, "Press any key to continue...");
  refresh();
  getch();
}


x86 assembly (clang, -O0):
<draw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1060 <getmaxyx@plt>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
call   1050 <attron@plt>
xor    %esi,%esi
lea    0xe5d(%rip),%rdx
mov    %esi,%edi
mov    $0x0,%al
call   1090 <mvprintw@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1030 <attroff@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
call   1050 <attron@plt>
lea    -0x60(%rbp),%rdi
mov    $0x50,%esi
lea    0xe3a(%rip),%rdx
call   1040 <snprintf@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    -0x60(%rbp),%rcx
lea    0xe19(%rip),%rdx
mov    $0x0,%al
call   1090 <mvprintw@plt>
mov    -0x4(%rbp),%edi
sub    $0x2,%edi
mov    -0x4(%rbp),%ecx
mov    -0x8(%rbp),%r8d
xor    %esi,%esi
lea    0xdff(%rip),%rdx
mov    $0x0,%al
call   1090 <mvprintw@plt>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
xor    %esi,%esi
lea    0xdf0(%rip),%rdx
mov    $0x0,%al
call   1090 <mvprintw@plt>
mov    $0x0,%al
call   1070 <refresh@plt>
mov    $0x0,%al
call   1080 <getch@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw>:
push   %rbx
sub    $0x50,%rsp
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
call   1060 <getmaxyx@plt>
mov    0x2e46(%rip),%rbx
mov    (%rbx),%edi
call   1050 <attron@plt>
lea    0xe68(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1090 <mvprintw@plt>
mov    (%rbx),%edi
call   1030 <attroff@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
call   1050 <attron@plt>
lea    0xe53(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x50,%esi
call   1040 <snprintf@plt>
lea    0xe4b(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
mov    %rbx,%rcx
xor    %eax,%eax
call   1090 <mvprintw@plt>
lea    0xe39(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   1090 <mvprintw@plt>
lea    0xe30(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   1090 <mvprintw@plt>
xor    %eax,%eax
call   1070 <refresh@plt>
xor    %eax,%eax
call   1080 <getch@plt>
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stdscr = global i32 0
@A_BOLD = global i32 0
@.str = [18 x i8] c"Is this thing on?\00"
@A_ITALIC = global i32 0
@.str.1 = [15 x i8] c"Hello, World!\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [7 x i8] c"%dx%d\0A\00"
@.str.4 = [29 x i8] c"Press any key to continue...\00"
define void @draw() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [80 x i8]
%5 = load i32, i32* @stdscr
%6 = load i32, i32* %1
%7 = load i32, i32* %2
%8 = call i32 @getmaxyx(i32 %5, i32 %6, i32 %7)
%9 = load i32, i32* @A_BOLD
%10 = call i32 @attron(i32 %9)
%11 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 0, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @A_BOLD
%13 = call i32 @attroff(i32 %12)
%14 = load i32, i32* @A_ITALIC
%15 = call i32 @attron(i32 %14)
%16 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%17 = call i32 @snprintf(i8* %16, i32 80, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i32 %17, i32* %3
%18 = load i32, i32* %1
%19 = sdiv i32 %18, 2
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = sub nsw i32 %20, %21
%23 = sdiv i32 %22, 2
%24 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%25 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %19, i32 %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = load i32, i32* %1
%27 = sub nsw i32 %26, 2
%28 = load i32, i32* %1
%29 = load i32, i32* %2
%30 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %27, i32 0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %28, i32 %29)
%31 = load i32, i32* %1
%32 = sub nsw i32 %31, 1
%33 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %32, i32 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%34 = call i32 (...) @refresh()
%35 = call i32 (...) @getch()
ret void
}

LLVM IR (-O2):
@stdscr = global i32 0
@A_BOLD = global i32 0
@.str = [18 x i8] c"Is this thing on?\00"
@A_ITALIC = global i32 0
@.str.1 = [15 x i8] c"Hello, World!\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [7 x i8] c"%dx%d\0A\00"
@.str.4 = [29 x i8] c"Press any key to continue...\00"
define void @draw() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdscr
%4 = tail call i32 @getmaxyx(i32 %3, i32 undef, i32 undef)
%5 = load i32, i32* @A_BOLD
%6 = tail call i32 @attron(i32 %5)
%7 = tail call i32 (i32, i32, i8*, ...) @mvprintw(i32 0, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @A_BOLD
%9 = tail call i32 @attroff(i32 %8)
%10 = load i32, i32* @A_ITALIC
%11 = tail call i32 @attron(i32 %10)
%12 = call i32 @snprintf(i8* %2, i32 80, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 0, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%14 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 undef, i32 undef)
%15 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 (...) @refresh()
%17 = call i32 (...) @getch()
ret void
}