#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*/ LOG_LOCAL5;
int /*<<< orphan*/ LOG_NOTICE;
int /*<<< orphan*/ LOG_PID;
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ daemonize(char *);
int /*<<< orphan*/ openlog(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
int main(int argc, char *argv[]) {
  openlog("mydaemon", LOG_PID, LOG_LOCAL5);
  syslog(LOG_INFO, "starting");
  daemonize("/var/lock/subsys/"
            "mydaemon");
  syslog(LOG_NOTICE, "terminated");
  closelog();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e83(%rip),%rax
mov    (%rax),%esi
mov    0x2e72(%rip),%rax
mov    (%rax),%edx
lea    0xeab(%rip),%rdi
call   1060 <openlog@plt>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
lea    0xe7c(%rip),%rsi
call   1050 <syslog@plt>
lea    0xe79(%rip),%rdi
call   1040 <daemonize@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    0xe7e(%rip),%rsi
call   1050 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2e98(%rip),%rax
mov    (%rax),%esi
mov    0x2e87(%rip),%rax
mov    (%rax),%edx
lea    0xec0(%rip),%rdi
call   1060 <openlog@plt>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
call   1050 <syslog@plt>
lea    0xe8e(%rip),%rdi
call   1040 <daemonize@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe93(%rip),%rsi
call   1050 <syslog@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"mydaemon\00"
@LOG_PID = global i32 0
@LOG_LOCAL5 = global i32 0
@LOG_INFO = global i32 0
@.str.1 = [9 x i8] c"starting\00"
@.str.2 = [26 x i8] c"/var/lock/subsys/mydaemon\00"
@LOG_NOTICE = global i32 0
@.str.3 = [11 x i8] c"terminated\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* @LOG_PID
%7 = load i32, i32* @LOG_LOCAL5
%8 = call i32 @openlog(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
%9 = load i32, i32* @LOG_INFO
%10 = call i32 @syslog(i32 %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @daemonize(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32, i32* @LOG_NOTICE
%13 = call i32 @syslog(i32 %12, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (...) @closelog()
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"mydaemon\00"
@LOG_PID = global i32 0
@LOG_LOCAL5 = global i32 0
@LOG_INFO = global i32 0
@.str.1 = [9 x i8] c"starting\00"
@.str.2 = [26 x i8] c"/var/lock/subsys/mydaemon\00"
@LOG_NOTICE = global i32 0
@.str.3 = [11 x i8] c"terminated\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @LOG_PID
%4 = load i32, i32* @LOG_LOCAL5
%5 = tail call i32 @openlog(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4)
%6 = load i32, i32* @LOG_INFO
%7 = tail call i32 @syslog(i32 %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @daemonize(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32, i32* @LOG_NOTICE
%10 = tail call i32 @syslog(i32 %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 (...) @closelog()
ret i32 0
}