#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 COLS;
int LINES;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ box(int /*<<< orphan*/ *, int /*<<< orphan*/,
                       int /*<<< orphan*/);
int /*<<< orphan*/ *newwin(int, int, int, int);
int /*<<< orphan*/ scrollok(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ waddstr(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ wmove(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
int /*<<< orphan*/ wsetscrreg(int /*<<< orphan*/ *, int, int);
WINDOW *chatwin() {
  WINDOW *temp;
  int height = 5;
  int width = COLS;
  int starty = (LINES - height - 1);
  int startx = (COLS - width);
  temp = newwin(height, width, starty, startx);
  box(temp, 0, 0);
  scrollok(temp, TRUE);
  wsetscrreg(temp, 1, height);
  waddstr(temp, "Chat: ");
  wmove(temp, 1, 1);
  wrefresh(temp);
  return temp;
}


x86 assembly (clang, -O0):
<chatwin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x5,-0xc(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
sub    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    0x2e34(%rip),%rax
mov    (%rax),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1050 <newwin@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1070 <box@plt>
mov    -0x8(%rbp),%rdi
mov    0x2e07(%rip),%rax
mov    (%rax),%esi
call   1080 <scrollok@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    $0x1,%esi
call   1060 <wsetscrreg@plt>
mov    -0x8(%rbp),%rdi
lea    0xe04(%rip),%rsi
call   1030 <waddstr@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1090 <wmove@plt>
mov    -0x8(%rbp),%rdi
call   1040 <wrefresh@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chatwin>:
push   %rbx
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
mov    0x2e67(%rip),%rax
mov    (%rax),%edx
add    $0xfffffffa,%edx
mov    $0x5,%edi
xor    %ecx,%ecx
call   1050 <newwin@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <box@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1080 <scrollok@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x5,%edx
call   1060 <wsetscrreg@plt>
lea    0xe35(%rip),%rsi
mov    %rbx,%rdi
call   1030 <waddstr@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1090 <wmove@plt>
mov    %rbx,%rdi
call   1040 <wrefresh@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@COLS = global i32 0
@LINES = global i32 0
@TRUE = global i32 0
@.str = [7 x i8] c"Chat: \00"
define i32* @chatwin() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 5, i32* %2
%6 = load i32, i32* @COLS
store i32 %6, i32* %3
%7 = load i32, i32* @LINES
%8 = load i32, i32* %2
%9 = sub nsw i32 %7, %8
%10 = sub nsw i32 %9, 1
store i32 %10, i32* %4
%11 = load i32, i32* @COLS
%12 = load i32, i32* %3
%13 = sub nsw i32 %11, %12
store i32 %13, i32* %5
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = call i32* @newwin(i32 %14, i32 %15, i32 %16, i32 %17)
store i32* %18, i32** %1
%19 = load i32*, i32** %1
%20 = call i32 @box(i32* %19, i32 0, i32 0)
%21 = load i32*, i32** %1
%22 = load i32, i32* @TRUE
%23 = call i32 @scrollok(i32* %21, i32 %22)
%24 = load i32*, i32** %1
%25 = load i32, i32* %2
%26 = call i32 @wsetscrreg(i32* %24, i32 1, i32 %25)
%27 = load i32*, i32** %1
%28 = call i32 @waddstr(i32* %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%29 = load i32*, i32** %1
%30 = call i32 @wmove(i32* %29, i32 1, i32 1)
%31 = load i32*, i32** %1
%32 = call i32 @wrefresh(i32* %31)
%33 = load i32*, i32** %1
ret i32* %33
}

LLVM IR (-O2):
@COLS = global i32 0
@LINES = global i32 0
@TRUE = global i32 0
@.str = [7 x i8] c"Chat: \00"
define i32* @chatwin() {
%1 = load i32, i32* @COLS
%2 = load i32, i32* @LINES
%3 = add nsw i32 %2, -6
%4 = tail call i32* @newwin(i32 5, i32 %1, i32 %3, i32 0)
%5 = tail call i32 @box(i32* %4, i32 0, i32 0)
%6 = load i32, i32* @TRUE
%7 = tail call i32 @scrollok(i32* %4, i32 %6)
%8 = tail call i32 @wsetscrreg(i32* %4, i32 1, i32 5)
%9 = tail call i32 @waddstr(i32* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @wmove(i32* %4, i32 1, i32 1)
%11 = tail call i32 @wrefresh(i32* %4)
ret i32* %4
}