#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 /*<<< orphan*/ daemonize();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ init_connections();
int /*<<< orphan*/ serve();
char *server_socket_name();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ system_error(char *);
int /*<<< orphan*/ unlink(char const *);
void start_server() {
  const char *socket_name = server_socket_name();
  unlink(socket_name);
  {
    int pid = fork();
    if (pid == -1)
      system_error("fork");
    if (pid == 0) {
      daemonize();
      init_connections();
      serve();
      unlink(socket_name);
      exit(0);
    } else
      sleep(1);
  }
}


x86 assembly (clang, -O0):
<start_server>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <server_socket_name@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <unlink@plt>
mov    $0x0,%al
call   10b0 <fork@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    11cc <start_server+0x3c>
lea    0xe39(%rip),%rdi
call   1080 <system_error@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11fb <start_server+0x6b>
mov    $0x0,%al
call   1040 <daemonize@plt>
mov    $0x0,%al
call   1060 <init_connections@plt>
mov    $0x0,%al
call   1070 <serve@plt>
mov    -0x8(%rbp),%rdi
call   1030 <unlink@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_server>:
push   %rbx
xor    %eax,%eax
call   1050 <server_socket_name@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <unlink@plt>
xor    %eax,%eax
call   10b0 <fork@plt>
cmp    $0xffffffff,%eax
je     11d7 <start_server+0x47>
test   %eax,%eax
jne    11e3 <start_server+0x53>
xor    %eax,%eax
call   1040 <daemonize@plt>
xor    %eax,%eax
call   1060 <init_connections@plt>
xor    %eax,%eax
call   1070 <serve@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
xor    %edi,%edi
call   1090 <exit@plt>
lea    0xe22(%rip),%rdi
call   1080 <system_error@plt>
mov    $0x1,%edi
pop    %rbx
jmp    10a0 <sleep@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"fork\00"
define void @start_server() {
%1 = alloca i8*
%2 = alloca i32
%3 = call i8* (...) @server_socket_name()
store i8* %3, i8** %1
%4 = load i8*, i8** %1
%5 = call i32 @unlink(i8* %4)
%6 = call i32 (...) @fork()
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @system_error(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %0
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = call i32 (...) @daemonize()
%16 = call i32 (...) @init_connections()
%17 = call i32 (...) @serve()
%18 = load i8*, i8** %1
%19 = call i32 @unlink(i8* %18)
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %11
%22 = call i32 @sleep(i32 1)
br label %23
23: ; preds = %21
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"fork\00"
define void @start_server() {
%1 = tail call i8* (...) @server_socket_name()
%2 = tail call i32 @unlink(i8* %1)
%3 = tail call i32 (...) @fork()
switch i32 %3, label %12 [
i32 -1, label %4
i32 0, label %6
]
4: ; preds = %0
%5 = tail call i32 @system_error(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %12
6: ; preds = %0
%7 = tail call i32 (...) @daemonize()
%8 = tail call i32 (...) @init_connections()
%9 = tail call i32 (...) @serve()
%10 = tail call i32 @unlink(i8* %1)
%11 = tail call i32 @exit(i32 0)
unreachable
12: ; preds = %4, %0
%13 = tail call i32 @sleep(i32 1)
ret void
}