#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 */
typedef int /*<<< orphan*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ LOG_NOTICE;
int /*<<< orphan*/ change_dir();
int /*<<< orphan*/ close_std_files();
int /*<<< orphan*/ do_fork(int /*<<< orphan*/ *);
int /*<<< orphan*/ do_session(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ getuid();
int /*<<< orphan*/ start_log();
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int /*<<< orphan*/ tcp_listener();
int /*<<< orphan*/ umask(int /*<<< orphan*/);
int main() {
  pid_t pid;
  pid_t sid;
  do_fork(&pid);
  umask(0);
  start_log();
  do_session(&sid);
  change_dir();
  close_std_files();
  syslog(LOG_NOTICE, "Daemon started by User %d", getuid());
  tcp_listener();
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <do_fork@plt>
xor    %edi,%edi
call   1080 <umask@plt>
mov    $0x0,%al
call   1060 <start_log@plt>
lea    -0xc(%rbp),%rdi
call   1070 <do_session@plt>
mov    $0x0,%al
call   10b0 <change_dir@plt>
mov    $0x0,%al
call   10a0 <close_std_files@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <getuid@plt>
mov    -0x10(%rbp),%edi
mov    %eax,%edx
lea    0xe04(%rip),%rsi
call   1090 <syslog@plt>
mov    $0x0,%al
call   1040 <tcp_listener@plt>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdi
call   1030 <do_fork@plt>
xor    %edi,%edi
call   1080 <umask@plt>
xor    %eax,%eax
call   1060 <start_log@plt>
lea    0x8(%rsp),%rdi
call   1070 <do_session@plt>
xor    %eax,%eax
call   10b0 <change_dir@plt>
xor    %eax,%eax
call   10a0 <close_std_files@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1050 <getuid@plt>
lea    0xe14(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
call   1090 <syslog@plt>
xor    %eax,%eax
call   1040 <tcp_listener@plt>
mov    0x2dd5(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@LOG_NOTICE = global i32 0
@.str = [26 x i8] c"Daemon started by User %d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @do_fork(i32* %2)
%5 = call i32 @umask(i32 0)
%6 = call i32 (...) @start_log()
%7 = call i32 @do_session(i32* %3)
%8 = call i32 (...) @change_dir()
%9 = call i32 (...) @close_std_files()
%10 = load i32, i32* @LOG_NOTICE
%11 = call i32 (...) @getuid()
%12 = call i32 @syslog(i32 %10, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 (...) @tcp_listener()
%14 = load i32, i32* @EXIT_SUCCESS
%15 = call i32 @exit(i32 %14)
unreachable
}

LLVM IR (-O2):
@LOG_NOTICE = global i32 0
@.str = [26 x i8] c"Daemon started by User %d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @do_fork(i32* %1)
%6 = call i32 @umask(i32 0)
%7 = call i32 (...) @start_log()
%8 = call i32 @do_session(i32* %2)
%9 = call i32 (...) @change_dir()
%10 = call i32 (...) @close_std_files()
%11 = load i32, i32* @LOG_NOTICE
%12 = call i32 (...) @getuid()
%13 = call i32 @syslog(i32 %11, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = call i32 (...) @tcp_listener()
%15 = load i32, i32* @EXIT_SUCCESS
%16 = call i32 @exit(i32 %15)
unreachable
}