#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int tty_init();
int x11h_init(int *, char const *);
int xenv_init(int *xenv_flags, const char *window_title) {
  int ret;
  ret = x11h_init(xenv_flags, window_title);
  if (ret == 0)
    goto out;
  if (xenv_flags != NULL)
    *xenv_flags &= ~((1 << 0) | (1 << 1));
  ret = tty_init();
  if (ret == 0)
    goto out;
  fprintf(stderr, "xenv: "
                  "error: both x11h_init and tty_init failed\n");
  ret = -1;
out:
  return ret;
}


x86 assembly (clang, -O0):
<xenv_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <x11h_init@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    115f <xenv_init+0x2f>
jmp    11aa <xenv_init+0x7a>
cmpq   $0x0,-0x8(%rbp)
je     1175 <xenv_init+0x45>
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
and    $0xfffffffc,%ecx
mov    %ecx,(%rax)
mov    $0x0,%al
call   1030 <tty_init@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    118e <xenv_init+0x5e>
jmp    11aa <xenv_init+0x7a>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
lea    0xe62(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xenv_init>:
push   %rbx
mov    %rdi,%rbx
call   1050 <x11h_init@plt>
test   %eax,%eax
je     116e <xenv_init+0x3e>
test   %rbx,%rbx
je     1145 <xenv_init+0x15>
andb   $0xfc,(%rbx)
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <tty_init@plt>
test   %eax,%eax
je     1170 <xenv_init+0x40>
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
lea    0xe9e(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    1170 <xenv_init+0x40>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [49 x i8] c"xenv: error: both x11h_init and tty_init failed\0A\00"
define i32 @xenv_init(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
%6 = load i32*, i32** %3
%7 = load i8*, i8** %4
%8 = call i32 @x11h_init(i32* %6, i8* %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
br label %27
12: ; preds = %2
%13 = load i32*, i32** %3
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i32*, i32** %3
%17 = load i32, i32* %16
%18 = and i32 %17, -4
store i32 %18, i32* %16
br label %19
19: ; preds = %15, %12
%20 = call i32 (...) @tty_init()
store i32 %20, i32* %5
%21 = load i32, i32* %5
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
br label %27
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %5
br label %27
27: ; preds = %24, %23, %11
%28 = load i32, i32* %5
ret i32 %28
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [49 x i8] c"xenv: error: both x11h_init and tty_init failed\0A\00"
define i32 @xenv_init(i32* %0, i8* %1) {
%3 = tail call i32 @x11h_init(i32* %0, i8* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %16, label %5
5: ; preds = %2
%6 = icmp eq i32* %0, null
br i1 %6, label %10, label %7
7: ; preds = %5
%8 = load i32, i32* %0
%9 = and i32 %8, -4
store i32 %9, i32* %0
br label %10
10: ; preds = %7, %5
%11 = tail call i32 (...) @tty_init()
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %10, %2, %13
%17 = phi i32 [ 0, %2 ], [ 0, %10 ], [ -1, %13 ]
ret i32 %17
}