#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 sol_http_client_init();
int sol_http_server_init();
int sol_network_init();
int /*<<< orphan*/ sol_network_shutdown();
int sol_comms_init(void) {
  int ret;
  ret = sol_network_init();
  if (ret != 0)
    return -1;
  ret = sol_http_client_init();
  if (ret != 0)
    goto http_client_error;
  ret = sol_http_server_init();
  if (ret != 0)
    goto http_server_error;
  return 0;
http_server_error:
  sol_http_client_init();
http_client_error:
  sol_network_shutdown();
  return -1;
}


x86 assembly (clang, -O0):
<sol_comms_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <sol_network_init@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1168 <sol_comms_init+0x28>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bb <sol_comms_init+0x7b>
mov    $0x0,%al
call   1040 <sol_http_client_init@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1181 <sol_comms_init+0x41>
jmp    11ad <sol_comms_init+0x6d>
mov    $0x0,%al
call   1030 <sol_http_server_init@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     119a <sol_comms_init+0x5a>
jmp    11a6 <sol_comms_init+0x66>
movl   $0x0,-0x4(%rbp)
jmp    11bb <sol_comms_init+0x7b>
mov    $0x0,%al
call   1040 <sol_http_client_init@plt>
mov    $0x0,%al
call   1050 <sol_network_shutdown@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sol_comms_init>:
push   %rbx
xor    %eax,%eax
call   1060 <sol_network_init@plt>
mov    $0xffffffff,%ebx
test   %eax,%eax
jne    117c <sol_comms_init+0x3c>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <sol_http_client_init@plt>
test   %eax,%eax
jne    1170 <sol_comms_init+0x30>
xor    %eax,%eax
call   1030 <sol_http_server_init@plt>
test   %eax,%eax
je     117c <sol_comms_init+0x3c>
xor    %eax,%eax
call   1040 <sol_http_client_init@plt>
xor    %eax,%eax
call   1050 <sol_network_shutdown@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @sol_comms_init() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @sol_network_init()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %0
store i32 -1, i32* %1
br label %22
7: ; preds = %0
%8 = call i32 (...) @sol_http_client_init()
store i32 %8, i32* %2
%9 = load i32, i32* %2
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
br label %20
12: ; preds = %7
%13 = call i32 (...) @sol_http_server_init()
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
br label %18
17: ; preds = %12
store i32 0, i32* %1
br label %22
18: ; preds = %16
%19 = call i32 (...) @sol_http_client_init()
br label %20
20: ; preds = %18, %11
%21 = call i32 (...) @sol_network_shutdown()
store i32 -1, i32* %1
br label %22
22: ; preds = %20, %17, %6
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
define i32 @sol_comms_init() {
%1 = tail call i32 (...) @sol_network_init()
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %13
3: ; preds = %0
%4 = tail call i32 (...) @sol_http_client_init()
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = tail call i32 (...) @sol_http_server_init()
%8 = icmp eq i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %6
%10 = tail call i32 (...) @sol_http_client_init()
br label %11
11: ; preds = %3, %9
%12 = tail call i32 (...) @sol_network_shutdown()
br label %13
13: ; preds = %6, %0, %11
%14 = phi i32 [ -1, %11 ], [ -1, %0 ], [ 0, %6 ]
ret i32 %14
}