#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 conn_sslcons_init();
int /*<<< orphan*/ conn_sslserv_close();
int conn_sslserv_init();
int /*<<< orphan*/ conn_tun_close();
int conn_tun_init();
int /*<<< orphan*/ conn_udpcon_close();
int conn_udpcon_init();
int /*<<< orphan*/ logmsg(int, char *);
int conn_initsocks() {
  int r;
  logmsg(2, "Initializing tun");
  r = conn_tun_init();
  if (r != 0)
    return r;
  logmsg(2, "Initializing UDP");
  r = conn_udpcon_init();
  if (r != 0) {
    conn_tun_close();
    return r;
  }
  logmsg(2, "Initializing SSL server socket");
  r = conn_sslserv_init();
  if (r != 0) {
    conn_tun_close();
    conn_udpcon_close();
    return r;
  }
  logmsg(2, "Initializing SSL connection list");
  r = conn_sslcons_init();
  if (r != 0) {
    conn_tun_close();
    conn_udpcon_close();
    conn_sslserv_close();
    return r;
  }
  return 0;
}


x86 assembly (clang, -O0):
<conn_initsocks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x2,%edi
lea    0xe6c(%rip),%rsi
call   1070 <logmsg@plt>
mov    $0x0,%al
call   10a0 <conn_tun_init@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11b8 <conn_initsocks+0x38>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1279 <conn_initsocks+0xf9>
mov    $0x2,%edi
lea    0xe4d(%rip),%rsi
call   1070 <logmsg@plt>
mov    $0x0,%al
call   1060 <conn_udpcon_init@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11ef <conn_initsocks+0x6f>
mov    $0x0,%al
call   1080 <conn_tun_close@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1279 <conn_initsocks+0xf9>
mov    $0x2,%edi
lea    0xe27(%rip),%rsi
call   1070 <logmsg@plt>
mov    $0x0,%al
call   1040 <conn_sslserv_init@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     122d <conn_initsocks+0xad>
mov    $0x0,%al
call   1080 <conn_tun_close@plt>
mov    $0x0,%al
call   1030 <conn_udpcon_close@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1279 <conn_initsocks+0xf9>
mov    $0x2,%edi
lea    0xe08(%rip),%rsi
call   1070 <logmsg@plt>
mov    $0x0,%al
call   1090 <conn_sslcons_init@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1272 <conn_initsocks+0xf2>
mov    $0x0,%al
call   1080 <conn_tun_close@plt>
mov    $0x0,%al
call   1030 <conn_udpcon_close@plt>
mov    $0x0,%al
call   1050 <conn_sslserv_close@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1279 <conn_initsocks+0xf9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conn_initsocks>:
push   %rbp
push   %rbx
push   %rax
lea    0xe76(%rip),%rsi
mov    $0x2,%edi
call   1070 <logmsg@plt>
xor    %eax,%eax
call   10a0 <conn_tun_init@plt>
mov    %eax,%ebx
test   %eax,%eax
jne    1231 <conn_initsocks+0xb1>
lea    0xe65(%rip),%rsi
mov    $0x2,%edi
call   1070 <logmsg@plt>
xor    %eax,%eax
call   1060 <conn_udpcon_init@plt>
test   %eax,%eax
je     11cc <conn_initsocks+0x4c>
mov    %eax,%ebx
xor    %eax,%eax
call   1080 <conn_tun_close@plt>
jmp    1231 <conn_initsocks+0xb1>
lea    0xe4f(%rip),%rsi
mov    $0x2,%edi
call   1070 <logmsg@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <conn_sslserv_init@plt>
test   %eax,%eax
je     11fc <conn_initsocks+0x7c>
mov    %eax,%ebp
xor    %eax,%eax
call   1080 <conn_tun_close@plt>
xor    %eax,%eax
call   1030 <conn_udpcon_close@plt>
jmp    122f <conn_initsocks+0xaf>
lea    0xe3e(%rip),%rsi
mov    $0x2,%edi
call   1070 <logmsg@plt>
xor    %eax,%eax
call   1090 <conn_sslcons_init@plt>
test   %eax,%eax
je     1231 <conn_initsocks+0xb1>
mov    %eax,%ebp
xor    %eax,%eax
call   1080 <conn_tun_close@plt>
xor    %eax,%eax
call   1030 <conn_udpcon_close@plt>
xor    %eax,%eax
call   1050 <conn_sslserv_close@plt>
mov    %ebp,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Initializing tun\00"
@.str.1 = [17 x i8] c"Initializing UDP\00"
@.str.2 = [31 x i8] c"Initializing SSL server socket\00"
@.str.3 = [33 x i8] c"Initializing SSL connection list\00"
define i32 @conn_initsocks() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @logmsg(i32 2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (...) @conn_tun_init()
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = load i32, i32* %2
store i32 %8, i32* %1
br label %37
9: ; preds = %0
%10 = call i32 @logmsg(i32 2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (...) @conn_udpcon_init()
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = call i32 (...) @conn_tun_close()
%16 = load i32, i32* %2
store i32 %16, i32* %1
br label %37
17: ; preds = %9
%18 = call i32 @logmsg(i32 2, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 (...) @conn_sslserv_init()
store i32 %19, i32* %2
%20 = load i32, i32* %2
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %17
%23 = call i32 (...) @conn_tun_close()
%24 = call i32 (...) @conn_udpcon_close()
%25 = load i32, i32* %2
store i32 %25, i32* %1
br label %37
26: ; preds = %17
%27 = call i32 @logmsg(i32 2, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 (...) @conn_sslcons_init()
store i32 %28, i32* %2
%29 = load i32, i32* %2
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %36
31: ; preds = %26
%32 = call i32 (...) @conn_tun_close()
%33 = call i32 (...) @conn_udpcon_close()
%34 = call i32 (...) @conn_sslserv_close()
%35 = load i32, i32* %2
store i32 %35, i32* %1
br label %37
36: ; preds = %26
store i32 0, i32* %1
br label %37
37: ; preds = %36, %31, %22, %14, %7
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
@.str = [17 x i8] c"Initializing tun\00"
@.str.1 = [17 x i8] c"Initializing UDP\00"
@.str.2 = [31 x i8] c"Initializing SSL server socket\00"
@.str.3 = [33 x i8] c"Initializing SSL connection list\00"
define i32 @conn_initsocks() {
%1 = tail call i32 @logmsg(i32 2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @conn_tun_init()
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %25
4: ; preds = %0
%5 = tail call i32 @logmsg(i32 2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 (...) @conn_udpcon_init()
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %4
%9 = tail call i32 (...) @conn_tun_close()
br label %25
10: ; preds = %4
%11 = tail call i32 @logmsg(i32 2, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 (...) @conn_sslserv_init()
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = tail call i32 (...) @conn_tun_close()
%16 = tail call i32 (...) @conn_udpcon_close()
br label %25
17: ; preds = %10
%18 = tail call i32 @logmsg(i32 2, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%19 = tail call i32 (...) @conn_sslcons_init()
%20 = icmp eq i32 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %17
%22 = tail call i32 (...) @conn_tun_close()
%23 = tail call i32 (...) @conn_udpcon_close()
%24 = tail call i32 (...) @conn_sslserv_close()
br label %25
25: ; preds = %17, %0, %21, %14, %8
%26 = phi i32 [ %6, %8 ], [ %12, %14 ], [ %19, %21 ], [ %2, %0 ], [ 0, %17 ]
ret i32 %26
}