#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 EXIT_SUCCESS;
int /*<<< orphan*/ bind_sighandler();
int /*<<< orphan*/ daemonize(char *);
int /*<<< orphan*/ main_loop(int);
int open_port(int);
int /*<<< orphan*/ parse_args(int, char **, int *, int *, char **);
int /*<<< orphan*/ write_pid_to_file(char *);
int main(int argc, char **argv) {
  int fd, port = 8080, daemon = 0;
  char *pidfile = NULL;
  parse_args(argc, argv, &daemon, &port, &pidfile);
  bind_sighandler();
  fd = open_port(port);
  if (daemon) {
    daemonize(pidfile);
  } else if (pidfile) {
    write_pid_to_file(pidfile);
  }
  main_loop(fd);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1f90,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x28(%rbp),%r8
call   1040 <parse_args@plt>
mov    $0x0,%al
call   1060 <bind_sighandler@plt>
mov    -0x18(%rbp),%edi
call   1080 <open_port@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11ce <main+0x6e>
mov    -0x28(%rbp),%rdi
call   1030 <daemonize@plt>
jmp    11e7 <main+0x87>
cmpq   $0x0,-0x28(%rbp)
je     11e2 <main+0x82>
mov    -0x28(%rbp),%rdi
call   1050 <write_pid_to_file@plt>
jmp    11e7 <main+0x87>
mov    -0x14(%rbp),%edi
call   1070 <main_loop@plt>
mov    0x2dea(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x1f90,0x4(%rsp)
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %rsp,%rdx
lea    0x4(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1040 <parse_args@plt>
xor    %eax,%eax
call   1060 <bind_sighandler@plt>
mov    0x4(%rsp),%edi
call   1080 <open_port@plt>
mov    %eax,%ebx
cmpl   $0x0,(%rsp)
mov    0x8(%rsp),%rdi
je     11b3 <main+0x53>
call   1030 <daemonize@plt>
jmp    11bd <main+0x5d>
test   %rdi,%rdi
je     11bd <main+0x5d>
call   1050 <write_pid_to_file@plt>
mov    %ebx,%edi
call   1070 <main_loop@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 8080, i32* %7
store i32 0, i32* %8
store i8* null, i8** %9
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @parse_args(i32 %10, i8** %11, i32* %8, i32* %7, i8** %9)
%13 = call i32 (...) @bind_sighandler()
%14 = load i32, i32* %7
%15 = call i32 @open_port(i32 %14)
store i32 %15, i32* %6
%16 = load i32, i32* %8
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load i8*, i8** %9
%20 = call i32 @daemonize(i8* %19)
br label %28
21: ; preds = %2
%22 = load i8*, i8** %9
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %21
%25 = load i8*, i8** %9
%26 = call i32 @write_pid_to_file(i8* %25)
br label %27
27: ; preds = %24, %21
br label %28
28: ; preds = %27, %18
%29 = load i32, i32* %6
%30 = call i32 @main_loop(i32 %29)
%31 = load i32, i32* @EXIT_SUCCESS
ret i32 %31
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = bitcast i32* %3 to i8*
store i32 8080, i32* %3
%7 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%8 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%9 = call i32 @parse_args(i32 %0, i8** %1, i32* %4, i32* %3, i8** %5)
%10 = call i32 (...) @bind_sighandler()
%11 = load i32, i32* %3
%12 = call i32 @open_port(i32 %11)
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 0
%15 = load i8*, i8** %5
br i1 %14, label %18, label %16
16: ; preds = %2
%17 = call i32 @daemonize(i8* %15)
br label %22
18: ; preds = %2
%19 = icmp eq i8* %15, null
br i1 %19, label %22, label %20
20: ; preds = %18
%21 = call i32 @write_pid_to_file(i8* %15)
br label %22
22: ; preds = %18, %20, %16
%23 = call i32 @main_loop(i32 %12)
%24 = load i32, i32* @EXIT_SUCCESS
ret i32 %24
}