#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 */
scalar_t__ already_running();
int create_socket();
scalar_t__ prepare_for_daemon();
int /*<<< orphan*/ start_process(int);
int start_deamon() {
  int ret;
  int fd;
  if (prepare_for_daemon() < 0)
    return -1;
  if (already_running())
    return -1;
  if ((fd = create_socket()) < 0)
    return -1;
  start_process(fd);
  return 0;
}


x86 assembly (clang, -O0):
<start_deamon>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <prepare_for_daemon@plt>
cmp    $0x0,%rax
jge    1165 <start_deamon+0x25>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b0 <start_deamon+0x70>
mov    $0x0,%al
call   1030 <already_running@plt>
cmp    $0x0,%rax
je     1182 <start_deamon+0x42>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b0 <start_deamon+0x70>
mov    $0x0,%al
call   1050 <create_socket@plt>
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
jge    11a1 <start_deamon+0x61>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b0 <start_deamon+0x70>
mov    -0xc(%rbp),%edi
call   1040 <start_process@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_deamon>:
push   %rbx
xor    %eax,%eax
call   1060 <prepare_for_daemon@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
js     1172 <start_deamon+0x32>
xor    %eax,%eax
call   1030 <already_running@plt>
test   %rax,%rax
jne    1172 <start_deamon+0x32>
xor    %eax,%eax
call   1050 <create_socket@plt>
test   %eax,%eax
js     1172 <start_deamon+0x32>
mov    %eax,%edi
call   1040 <start_process@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @start_deamon() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i64 (...) @prepare_for_daemon()
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %0
store i32 -1, i32* %1
br label %18
7: ; preds = %0
%8 = call i64 (...) @already_running()
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 -1, i32* %1
br label %18
11: ; preds = %7
%12 = call i32 (...) @create_socket()
store i32 %12, i32* %3
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %11
store i32 -1, i32* %1
br label %18
15: ; preds = %11
%16 = load i32, i32* %3
%17 = call i32 @start_process(i32 %16)
store i32 0, i32* %1
br label %18
18: ; preds = %15, %14, %10, %6
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
define i32 @start_deamon() {
%1 = tail call i64 (...) @prepare_for_daemon()
%2 = icmp slt i64 %1, 0
br i1 %2, label %11, label %3
3: ; preds = %0
%4 = tail call i64 (...) @already_running()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = tail call i32 (...) @create_socket()
%8 = icmp slt i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @start_process(i32 %7)
br label %11
11: ; preds = %6, %3, %0, %9
%12 = phi i32 [ 0, %9 ], [ -1, %0 ], [ -1, %3 ], [ -1, %6 ]
ret i32 %12
}