#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*/ LOG_INFO;
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ daemonize();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ run();
int /*<<< orphan*/ start_log();
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
int /*<<< orphan*/ unlock_pid_file();
int main(void) {
  start_log();
  daemonize();
  syslog(LOG_INFO, "Daemon started.\n");
  run();
  syslog(LOG_INFO, "Daemon ending.\n");
  unlock_pid_file();
  closelog();
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <start_log@plt>
mov    $0x0,%al
call   1040 <daemonize@plt>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
call   1070 <syslog@plt>
mov    $0x0,%al
call   1050 <run@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
lea    0xe58(%rip),%rsi
call   1070 <syslog@plt>
mov    $0x0,%al
call   1080 <unlock_pid_file@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1060 <start_log@plt>
xor    %eax,%eax
call   1040 <daemonize@plt>
mov    0x2e5a(%rip),%rbx
mov    (%rbx),%edi
lea    0xe71(%rip),%rsi
call   1070 <syslog@plt>
xor    %eax,%eax
call   1050 <run@plt>
mov    (%rbx),%edi
lea    0xe6d(%rip),%rsi
call   1070 <syslog@plt>
xor    %eax,%eax
call   1080 <unlock_pid_file@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@LOG_INFO = global i32 0
@.str = [17 x i8] c"Daemon started.\0A\00"
@.str.1 = [16 x i8] c"Daemon ending.\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @start_log()
%3 = call i32 (...) @daemonize()
%4 = load i32, i32* @LOG_INFO
%5 = call i32 @syslog(i32 %4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (...) @run()
%7 = load i32, i32* @LOG_INFO
%8 = call i32 @syslog(i32 %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (...) @unlock_pid_file()
%10 = call i32 (...) @closelog()
%11 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@LOG_INFO = global i32 0
@.str = [17 x i8] c"Daemon started.\0A\00"
@.str.1 = [16 x i8] c"Daemon ending.\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @start_log()
%2 = tail call i32 (...) @daemonize()
%3 = load i32, i32* @LOG_INFO
%4 = tail call i32 @syslog(i32 %3, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (...) @run()
%6 = load i32, i32* @LOG_INFO
%7 = tail call i32 @syslog(i32 %6, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 (...) @unlock_pid_file()
%9 = tail call i32 (...) @closelog()
%10 = tail call i32 @exit(i32 0)
unreachable
}