#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 */
struct chat_state {
  int dummy;
};

/* Variables and functions */
int COLOR_BLACK;
int COLOR_CYAN;
int COLOR_GREEN;
int COLOR_RED;
int COLOR_WHITE;
int /*<<< orphan*/ LC_ALL;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ init_pair(int, int, int);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ ui_update(struct chat_state *);
int /*<<< orphan*/ use_default_colors();
void ui_init(struct chat_state *state) {
  setlocale(LC_ALL, "");
  initscr();
  cbreak();
  noecho();
  use_default_colors();
  keypad(stdscr, TRUE);
  start_color();
  init_pair(1, COLOR_WHITE, COLOR_RED);
  init_pair(2, COLOR_WHITE, COLOR_GREEN);
  init_pair(0 + 3, -1, -1);
  init_pair(1 + 3, COLOR_BLACK, COLOR_WHITE);
  init_pair(2 + 3, COLOR_WHITE, COLOR_CYAN);
  ui_update(state);
}


x86 assembly (clang, -O0):
<ui_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
call   10a0 <setlocale@plt>
mov    $0x0,%al
call   1080 <initscr@plt>
mov    $0x0,%al
call   1040 <cbreak@plt>
mov    $0x0,%al
call   10b0 <noecho@plt>
mov    $0x0,%al
call   1030 <use_default_colors@plt>
mov    0x2e14(%rip),%rax
mov    (%rax),%edi
mov    0x2e03(%rip),%rax
mov    (%rax),%esi
call   1070 <keypad@plt>
mov    $0x0,%al
call   1090 <start_color@plt>
mov    0x2dc6(%rip),%rax
mov    (%rax),%esi
mov    0x2db5(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%edi
call   1060 <init_pair@plt>
mov    0x2daa(%rip),%rax
mov    (%rax),%esi
mov    0x2db1(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%edi
call   1060 <init_pair@plt>
mov    $0x3,%edi
mov    $0xffffffff,%edx
mov    %edx,%esi
call   1060 <init_pair@plt>
mov    0x2d9d(%rip),%rax
mov    (%rax),%esi
mov    0x2d74(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%edi
call   1060 <init_pair@plt>
mov    0x2d61(%rip),%rax
mov    (%rax),%esi
mov    0x2d70(%rip),%rax
mov    (%rax),%edx
mov    $0x5,%edi
call   1060 <init_pair@plt>
mov    -0x8(%rbp),%rdi
call   1050 <ui_update@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ui_init>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
lea    0xe59(%rip),%rsi
call   10a0 <setlocale@plt>
xor    %eax,%eax
call   1080 <initscr@plt>
xor    %eax,%eax
call   1040 <cbreak@plt>
xor    %eax,%eax
call   10b0 <noecho@plt>
xor    %eax,%eax
call   1030 <use_default_colors@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
mov    0x2e08(%rip),%rax
mov    (%rax),%esi
call   1070 <keypad@plt>
xor    %eax,%eax
call   1090 <start_color@plt>
mov    0x2dcb(%rip),%rbx
mov    (%rbx),%esi
mov    0x2dba(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%edi
call   1060 <init_pair@plt>
mov    (%rbx),%esi
mov    0x2dbd(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%edi
call   1060 <init_pair@plt>
mov    $0x3,%edi
mov    $0xffffffff,%esi
mov    $0xffffffff,%edx
call   1060 <init_pair@plt>
mov    0x2da6(%rip),%rax
mov    (%rax),%esi
mov    (%rbx),%edx
mov    $0x4,%edi
call   1060 <init_pair@plt>
mov    (%rbx),%esi
mov    0x2d87(%rip),%rax
mov    (%rax),%edx
mov    $0x5,%edi
call   1060 <init_pair@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <ui_update@plt>

LLVM IR (-O0):
%struct.chat_state = type { i32 }
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@stdscr = global i32 0
@TRUE = global i32 0
@COLOR_WHITE = global i32 0
@COLOR_RED = global i32 0
@COLOR_GREEN = global i32 0
@COLOR_BLACK = global i32 0
@COLOR_CYAN = global i32 0
define void @ui_init(%struct.chat_state* %0) {
%2 = alloca %struct.chat_state*
store %struct.chat_state* %0, %struct.chat_state** %2
%3 = load i32, i32* @LC_ALL
%4 = call i32 @setlocale(i32 %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (...) @initscr()
%6 = call i32 (...) @cbreak()
%7 = call i32 (...) @noecho()
%8 = call i32 (...) @use_default_colors()
%9 = load i32, i32* @stdscr
%10 = load i32, i32* @TRUE
%11 = call i32 @keypad(i32 %9, i32 %10)
%12 = call i32 (...) @start_color()
%13 = load i32, i32* @COLOR_WHITE
%14 = load i32, i32* @COLOR_RED
%15 = call i32 @init_pair(i32 1, i32 %13, i32 %14)
%16 = load i32, i32* @COLOR_WHITE
%17 = load i32, i32* @COLOR_GREEN
%18 = call i32 @init_pair(i32 2, i32 %16, i32 %17)
%19 = call i32 @init_pair(i32 3, i32 -1, i32 -1)
%20 = load i32, i32* @COLOR_BLACK
%21 = load i32, i32* @COLOR_WHITE
%22 = call i32 @init_pair(i32 4, i32 %20, i32 %21)
%23 = load i32, i32* @COLOR_WHITE
%24 = load i32, i32* @COLOR_CYAN
%25 = call i32 @init_pair(i32 5, i32 %23, i32 %24)
%26 = load %struct.chat_state*, %struct.chat_state** %2
%27 = call i32 @ui_update(%struct.chat_state* %26)
ret void
}

LLVM IR (-O2):
%struct.chat_state = type { i32 }
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@stdscr = global i32 0
@TRUE = global i32 0
@COLOR_WHITE = global i32 0
@COLOR_RED = global i32 0
@COLOR_GREEN = global i32 0
@COLOR_BLACK = global i32 0
@COLOR_CYAN = global i32 0
define void @ui_init(%struct.chat_state* %0) {
%2 = load i32, i32* @LC_ALL
%3 = tail call i32 @setlocale(i32 %2, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (...) @initscr()
%5 = tail call i32 (...) @cbreak()
%6 = tail call i32 (...) @noecho()
%7 = tail call i32 (...) @use_default_colors()
%8 = load i32, i32* @stdscr
%9 = load i32, i32* @TRUE
%10 = tail call i32 @keypad(i32 %8, i32 %9)
%11 = tail call i32 (...) @start_color()
%12 = load i32, i32* @COLOR_WHITE
%13 = load i32, i32* @COLOR_RED
%14 = tail call i32 @init_pair(i32 1, i32 %12, i32 %13)
%15 = load i32, i32* @COLOR_WHITE
%16 = load i32, i32* @COLOR_GREEN
%17 = tail call i32 @init_pair(i32 2, i32 %15, i32 %16)
%18 = tail call i32 @init_pair(i32 3, i32 -1, i32 -1)
%19 = load i32, i32* @COLOR_BLACK
%20 = load i32, i32* @COLOR_WHITE
%21 = tail call i32 @init_pair(i32 4, i32 %19, i32 %20)
%22 = load i32, i32* @COLOR_WHITE
%23 = load i32, i32* @COLOR_CYAN
%24 = tail call i32 @init_pair(i32 5, i32 %22, i32 %23)
%25 = tail call i32 @ui_update(%struct.chat_state* %0)
ret void
}