#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 event_base {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ _IONBF;
int /*<<< orphan*/ event_base_dispatch(struct event_base *);
struct event_base *event_base_new();
int /*<<< orphan*/ setvbuf(int /*<<< orphan*/, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ start_dns_server(struct event_base *);
scalar_t__ start_tproxy_server(struct event_base *);
int /*<<< orphan*/ stdout;
int main(int c, char **v) {
  struct event_base *base;
  base = event_base_new();
  if (!base)
    return 1;
  setvbuf(stdout, NULL, _IONBF, 0);
  if (start_dns_server(base) < 0)
    return 3;
  if (start_tproxy_server(base) < 0)
    return 2;
  event_base_dispatch(base);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <event_base_new@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1188 <main+0x38>
movl   $0x1,-0x4(%rbp)
jmp    11f3 <main+0xa3>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    0x2e50(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
xor    %ecx,%ecx
call   1060 <setvbuf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <start_dns_server@plt>
cmp    $0x0,%rax
jge    11c4 <main+0x74>
movl   $0x3,-0x4(%rbp)
jmp    11f3 <main+0xa3>
mov    -0x18(%rbp),%rdi
call   1040 <start_tproxy_server@plt>
cmp    $0x0,%rax
jge    11e3 <main+0x93>
movl   $0x2,-0x4(%rbp)
jmp    11f3 <main+0xa3>
mov    -0x18(%rbp),%rdi
call   1070 <event_base_dispatch@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <event_base_new@plt>
test   %rax,%rax
je     11a1 <main+0x51>
mov    %rax,%rbx
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
mov    0x2e78(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
xor    %ecx,%ecx
call   1060 <setvbuf@plt>
mov    %rbx,%rdi
call   1050 <start_dns_server@plt>
test   %rax,%rax
js     11a8 <main+0x58>
mov    %rbx,%rdi
call   1040 <start_tproxy_server@plt>
test   %rax,%rax
js     11af <main+0x5f>
mov    %rbx,%rdi
call   1070 <event_base_dispatch@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x3,%eax
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.event_base = type { i32 }
@stdout = global i32 0
@_IONBF = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.event_base*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call %struct.event_base* (...) @event_base_new()
store %struct.event_base* %7, %struct.event_base** %6
%8 = load %struct.event_base*, %struct.event_base** %6
%9 = icmp ne %struct.event_base* %8, null
br i1 %9, label %11, label %10
10: ; preds = %2
store i32 1, i32* %3
br label %27
11: ; preds = %2
%12 = load i32, i32* @stdout
%13 = load i32, i32* @_IONBF
%14 = call i32 @setvbuf(i32 %12, i32* null, i32 %13, i32 0)
%15 = load %struct.event_base*, %struct.event_base** %6
%16 = call i64 @start_dns_server(%struct.event_base* %15)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %11
store i32 3, i32* %3
br label %27
19: ; preds = %11
%20 = load %struct.event_base*, %struct.event_base** %6
%21 = call i64 @start_tproxy_server(%struct.event_base* %20)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %19
store i32 2, i32* %3
br label %27
24: ; preds = %19
%25 = load %struct.event_base*, %struct.event_base** %6
%26 = call i32 @event_base_dispatch(%struct.event_base* %25)
store i32 0, i32* %3
br label %27
27: ; preds = %24, %23, %18, %10
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
%struct.event_base = type { i32 }
@stdout = global i32 0
@_IONBF = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call %struct.event_base* (...) @event_base_new()
%4 = icmp eq %struct.event_base* %3, null
br i1 %4, label %16, label %5
5: ; preds = %2
%6 = load i32, i32* @stdout
%7 = load i32, i32* @_IONBF
%8 = tail call i32 @setvbuf(i32 %6, i32* null, i32 %7, i32 0)
%9 = tail call i64 @start_dns_server(%struct.event_base* %3)
%10 = icmp slt i64 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %5
%12 = tail call i64 @start_tproxy_server(%struct.event_base* %3)
%13 = icmp slt i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %11
%15 = tail call i32 @event_base_dispatch(%struct.event_base* %3)
br label %16
16: ; preds = %11, %5, %2, %14
%17 = phi i32 [ 0, %14 ], [ 1, %2 ], [ 3, %5 ], [ 2, %11 ]
ret i32 %17
}