#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*/ TRUE;
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ echo();
int /*<<< orphan*/ halfdelay(int);
int /*<<< orphan*/ *initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ raw();
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ stdscr;
int CSLP_InitCurses(int flags, int delay) {
  if (initscr() == NULL) {
    return 1;
  }
  if (delay != 0) {
    halfdelay(delay);
  }
  if (flags & 1) {
    noecho();
  } else {
    echo();
  }
  if (flags & 2) {
    raw();
    if (flags & 4) {
      flags &= ~4;
    }
  }
  if (flags & 4) {
    cbreak();
  }
  if (flags & 8) {
    keypad(stdscr, TRUE);
  }
  if (flags & 16) {
    start_color();
  }
  return (0);
}


x86 assembly (clang, -O0):
<CSLP_InitCurses>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x0,%al
call   1060 <initscr@plt>
cmp    $0x0,%rax
jne    11ab <CSLP_InitCurses+0x2b>
movl   $0x1,-0x4(%rbp)
jmp    126b <CSLP_InitCurses+0xeb>
cmpl   $0x0,-0xc(%rbp)
je     11bd <CSLP_InitCurses+0x3d>
mov    -0xc(%rbp),%edi
call   1090 <halfdelay@plt>
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11d8 <CSLP_InitCurses+0x58>
mov    $0x0,%al
call   10a0 <noecho@plt>
jmp    11df <CSLP_InitCurses+0x5f>
mov    $0x0,%al
call   1030 <echo@plt>
mov    -0x8(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1212 <CSLP_InitCurses+0x92>
mov    $0x0,%al
call   1070 <raw@plt>
mov    -0x8(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     120d <CSLP_InitCurses+0x8d>
mov    -0x8(%rbp),%eax
and    $0xfffffffb,%eax
mov    %eax,-0x8(%rbp)
jmp    1212 <CSLP_InitCurses+0x92>
mov    -0x8(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     1228 <CSLP_InitCurses+0xa8>
mov    $0x0,%al
call   1040 <cbreak@plt>
mov    -0x8(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
je     124e <CSLP_InitCurses+0xce>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
mov    0x2d99(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
mov    -0x8(%rbp),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     1264 <CSLP_InitCurses+0xe4>
mov    $0x0,%al
call   1080 <start_color@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CSLP_InitCurses>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
xor    %eax,%eax
call   1060 <initscr@plt>
test   %rax,%rax
je     11b1 <CSLP_InitCurses+0x31>
test   %ebp,%ebp
je     119e <CSLP_InitCurses+0x1e>
mov    %ebp,%edi
call   1090 <halfdelay@plt>
xor    %eax,%eax
test   $0x1,%bl
jne    11b8 <CSLP_InitCurses+0x38>
call   1030 <echo@plt>
test   $0x2,%bl
jne    11c2 <CSLP_InitCurses+0x42>
jmp    11cc <CSLP_InitCurses+0x4c>
mov    $0x1,%ebp
jmp    11fd <CSLP_InitCurses+0x7d>
call   10a0 <noecho@plt>
test   $0x2,%bl
je     11cc <CSLP_InitCurses+0x4c>
xor    %eax,%eax
call   1070 <raw@plt>
and    $0xfffffffb,%ebx
test   $0x4,%bl
jne    1206 <CSLP_InitCurses+0x86>
test   $0x8,%bl
je     11ed <CSLP_InitCurses+0x6d>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
mov    0x2dfa(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
xor    %ebp,%ebp
test   $0x10,%bl
je     11fd <CSLP_InitCurses+0x7d>
xor    %ebp,%ebp
xor    %eax,%eax
call   1080 <start_color@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %eax,%eax
call   1040 <cbreak@plt>
test   $0x8,%bl
jne    11d6 <CSLP_InitCurses+0x56>
jmp    11ed <CSLP_InitCurses+0x6d>

LLVM IR (-O0):
@stdscr = global i32 0
@TRUE = global i32 0
define i32 @CSLP_InitCurses(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = call i32* (...) @initscr()
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %9
8: ; preds = %2
store i32 1, i32* %3
br label %57
9: ; preds = %2
%10 = load i32, i32* %5
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* %5
%14 = call i32 @halfdelay(i32 %13)
br label %15
15: ; preds = %12, %9
%16 = load i32, i32* %4
%17 = and i32 %16, 1
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 (...) @noecho()
br label %23
21: ; preds = %15
%22 = call i32 (...) @echo()
br label %23
23: ; preds = %21, %19
%24 = load i32, i32* %4
%25 = and i32 %24, 2
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %23
%28 = call i32 (...) @raw()
%29 = load i32, i32* %4
%30 = and i32 %29, 4
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = load i32, i32* %4
%34 = and i32 %33, -5
store i32 %34, i32* %4
br label %35
35: ; preds = %32, %27
br label %36
36: ; preds = %35, %23
%37 = load i32, i32* %4
%38 = and i32 %37, 4
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = call i32 (...) @cbreak()
br label %42
42: ; preds = %40, %36
%43 = load i32, i32* %4
%44 = and i32 %43, 8
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %42
%47 = load i32, i32* @stdscr
%48 = load i32, i32* @TRUE
%49 = call i32 @keypad(i32 %47, i32 %48)
br label %50
50: ; preds = %46, %42
%51 = load i32, i32* %4
%52 = and i32 %51, 16
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %50
%55 = call i32 (...) @start_color()
br label %56
56: ; preds = %54, %50
store i32 0, i32* %3
br label %57
57: ; preds = %56, %8
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@stdscr = global i32 0
@TRUE = global i32 0
define i32 @CSLP_InitCurses(i32 %0, i32 %1) {
%3 = tail call i32* (...) @initscr()
%4 = icmp eq i32* %3, null
br i1 %4, label %40, label %5
5: ; preds = %2
%6 = icmp eq i32 %1, 0
br i1 %6, label %9, label %7
7: ; preds = %5
%8 = tail call i32 @halfdelay(i32 %1)
br label %9
9: ; preds = %7, %5
%10 = and i32 %0, 1
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 (...) @noecho()
br label %16
14: ; preds = %9
%15 = tail call i32 (...) @echo()
br label %16
16: ; preds = %14, %12
%17 = and i32 %0, 2
%18 = icmp eq i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = tail call i32 (...) @raw()
%21 = and i32 %0, -5
br label %22
22: ; preds = %19, %16
%23 = phi i32 [ %0, %16 ], [ %21, %19 ]
%24 = and i32 %23, 4
%25 = icmp eq i32 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %22
%27 = tail call i32 (...) @cbreak()
br label %28
28: ; preds = %26, %22
%29 = and i32 %23, 8
%30 = icmp eq i32 %29, 0
br i1 %30, label %35, label %31
31: ; preds = %28
%32 = load i32, i32* @stdscr
%33 = load i32, i32* @TRUE
%34 = tail call i32 @keypad(i32 %32, i32 %33)
br label %35
35: ; preds = %31, %28
%36 = and i32 %23, 16
%37 = icmp eq i32 %36, 0
br i1 %37, label %40, label %38
38: ; preds = %35
%39 = tail call i32 (...) @start_color()
br label %40
40: ; preds = %35, %38, %2
%41 = phi i32 [ 1, %2 ], [ 0, %38 ], [ 0, %35 ]
ret i32 %41
}