#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*/ curs_set(int /*<<< orphan*/);
int /*<<< orphan*/ *initscr();
int /*<<< orphan*/ noecho();
int prepare_main_window();
int prepare_status_window();
int ui_init() {
  int err;
  if (initscr() == NULL) {
    return (-1);
  }
  noecho();
  curs_set(0);
  err = prepare_main_window();
  if (err == -1) {
    return (-1);
  }
  err = prepare_status_window();
  if (err == -1) {
    return (-1);
  }
  return (0);
}


x86 assembly (clang, -O0):
<ui_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <initscr@plt>
cmp    $0x0,%rax
jne    1175 <ui_init+0x25>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ca <ui_init+0x7a>
mov    $0x0,%al
call   1060 <noecho@plt>
xor    %edi,%edi
call   1070 <curs_set@plt>
mov    $0x0,%al
call   1030 <prepare_main_window@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    11a3 <ui_init+0x53>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ca <ui_init+0x7a>
mov    $0x0,%al
call   1050 <prepare_status_window@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    11c3 <ui_init+0x73>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ca <ui_init+0x7a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ui_init>:
push   %rbx
xor    %eax,%eax
call   1040 <initscr@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
je     118d <ui_init+0x3d>
xor    %eax,%eax
call   1060 <noecho@plt>
xor    %edi,%edi
call   1070 <curs_set@plt>
xor    %eax,%eax
call   1030 <prepare_main_window@plt>
cmp    $0xffffffff,%eax
je     118d <ui_init+0x3d>
xor    %eax,%eax
call   1050 <prepare_status_window@plt>
xor    %ebx,%ebx
cmp    $0xffffffff,%eax
sete   %bl
neg    %ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @ui_init() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32* (...) @initscr()
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %6
5: ; preds = %0
store i32 -1, i32* %1
br label %19
6: ; preds = %0
%7 = call i32 (...) @noecho()
%8 = call i32 @curs_set(i32 0)
%9 = call i32 (...) @prepare_main_window()
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %13
12: ; preds = %6
store i32 -1, i32* %1
br label %19
13: ; preds = %6
%14 = call i32 (...) @prepare_status_window()
store i32 %14, i32* %2
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %18
17: ; preds = %13
store i32 -1, i32* %1
br label %19
18: ; preds = %13
store i32 0, i32* %1
br label %19
19: ; preds = %18, %17, %12, %5
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
define i32 @ui_init() {
%1 = tail call i32* (...) @initscr()
%2 = icmp eq i32* %1, null
br i1 %2, label %12, label %3
3: ; preds = %0
%4 = tail call i32 (...) @noecho()
%5 = tail call i32 @curs_set(i32 0)
%6 = tail call i32 (...) @prepare_main_window()
%7 = icmp eq i32 %6, -1
br i1 %7, label %12, label %8
8: ; preds = %3
%9 = tail call i32 (...) @prepare_status_window()
%10 = icmp eq i32 %9, -1
%11 = sext i1 %10 to i32
br label %12
12: ; preds = %8, %3, %0
%13 = phi i32 [ -1, %0 ], [ -1, %3 ], [ %11, %8 ]
ret i32 %13
}