#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 tcp4_start(int);
int /*<<< orphan*/ tcp4_stop();
int tcp6_start(int);
int udp4_start(int);
int /*<<< orphan*/ udp4_stop();
int udp6_start(int);
int /*<<< orphan*/ udp6_stop();
int manager_start(int port4, int port6) {
  int ret;
  ret = udp4_start(port4);
  if (ret < 0)
    return ret;
  ret = tcp4_start(port4);
  if (ret < 0)
    goto tcp4_fail;
  ret = udp6_start(port6);
  if (ret < 0)
    goto udp6_fail;
  ret = tcp6_start(port6);
  if (ret < 0)
    goto tcp6_fail;
  return ret;
tcp6_fail:
  udp6_stop();
udp6_fail:
  tcp4_stop();
tcp4_fail:
  udp4_stop();
  return ret;
}


x86 assembly (clang, -O0):
<manager_start>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1070 <udp4_start@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    119e <manager_start+0x2e>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1212 <manager_start+0xa2>
mov    -0x8(%rbp),%edi
call   1060 <tcp4_start@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    11b8 <manager_start+0x48>
jmp    1205 <manager_start+0x95>
mov    -0xc(%rbp),%edi
call   1090 <udp6_start@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    11d2 <manager_start+0x62>
jmp    11fe <manager_start+0x8e>
mov    -0xc(%rbp),%edi
call   1050 <tcp6_start@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jge    11ec <manager_start+0x7c>
jmp    11f7 <manager_start+0x87>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1212 <manager_start+0xa2>
mov    $0x0,%al
call   1080 <udp6_stop@plt>
mov    $0x0,%al
call   1040 <tcp4_stop@plt>
mov    $0x0,%al
call   1030 <udp4_stop@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<manager_start>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebp
call   1070 <udp4_start@plt>
test   %eax,%eax
js     11b0 <manager_start+0x40>
mov    %ebp,%edi
call   1060 <tcp4_start@plt>
test   %eax,%eax
js     11b4 <manager_start+0x44>
mov    %r14d,%edi
call   1090 <udp6_start@plt>
test   %eax,%eax
js     11b8 <manager_start+0x48>
mov    %r14d,%edi
call   1050 <tcp6_start@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    11c8 <manager_start+0x58>
xor    %eax,%eax
call   1080 <udp6_stop@plt>
jmp    11ba <manager_start+0x4a>
mov    %eax,%ebx
jmp    11c8 <manager_start+0x58>
mov    %eax,%ebx
jmp    11c1 <manager_start+0x51>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <tcp4_stop@plt>
xor    %eax,%eax
call   1030 <udp4_stop@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @manager_start(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = call i32 @udp4_start(i32 %7)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load i32, i32* %6
store i32 %12, i32* %3
br label %40
13: ; preds = %2
%14 = load i32, i32* %4
%15 = call i32 @tcp4_start(i32 %14)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %13
br label %37
19: ; preds = %13
%20 = load i32, i32* %5
%21 = call i32 @udp6_start(i32 %20)
store i32 %21, i32* %6
%22 = load i32, i32* %6
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %19
br label %35
25: ; preds = %19
%26 = load i32, i32* %5
%27 = call i32 @tcp6_start(i32 %26)
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %25
br label %33
31: ; preds = %25
%32 = load i32, i32* %6
store i32 %32, i32* %3
br label %40
33: ; preds = %30
%34 = call i32 (...) @udp6_stop()
br label %35
35: ; preds = %33, %24
%36 = call i32 (...) @tcp4_stop()
br label %37
37: ; preds = %35, %18
%38 = call i32 (...) @udp4_stop()
%39 = load i32, i32* %6
store i32 %39, i32* %3
br label %40
40: ; preds = %37, %31, %11
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
define i32 @manager_start(i32 %0, i32 %1) {
%3 = tail call i32 @udp4_start(i32 %0)
%4 = icmp slt i32 %3, 0
br i1 %4, label %22, label %5
5: ; preds = %2
%6 = tail call i32 @tcp4_start(i32 %0)
%7 = icmp slt i32 %6, 0
br i1 %7, label %19, label %8
8: ; preds = %5
%9 = tail call i32 @udp6_start(i32 %1)
%10 = icmp slt i32 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %8
%12 = tail call i32 @tcp6_start(i32 %1)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = tail call i32 (...) @udp6_stop()
br label %16
16: ; preds = %8, %14
%17 = phi i32 [ %9, %8 ], [ %12, %14 ]
%18 = tail call i32 (...) @tcp4_stop()
br label %19
19: ; preds = %5, %16
%20 = phi i32 [ %6, %5 ], [ %17, %16 ]
%21 = tail call i32 (...) @udp4_stop()
br label %22
22: ; preds = %11, %2, %19
%23 = phi i32 [ %20, %19 ], [ %3, %2 ], [ %12, %11 ]
ret i32 %23
}