#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 LOG_CONS;
int /*<<< orphan*/ LOG_INFO;
int LOG_PERROR;
int /*<<< orphan*/ LOG_UPTO(int /*<<< orphan*/);
int /*<<< orphan*/ LOG_USER;
int /*<<< orphan*/ daemon(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ setlogmask(int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
int main() {
  setlogmask(LOG_UPTO(LOG_INFO));
  openlog("simpledaemon", LOG_CONS | LOG_PERROR, LOG_USER);
  daemon(0, 0);
  while (1) {
    syslog(LOG_INFO, "daemon running");
    sleep(10);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
call   1030 <LOG_UPTO@plt>
mov    %eax,%edi
call   1040 <setlogmask@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
mov    0x2e4c(%rip),%rax
or     (%rax),%esi
mov    0x2e4b(%rip),%rax
mov    (%rax),%edx
lea    0xe5a(%rip),%rdi
call   1070 <openlog@plt>
xor    %esi,%esi
mov    %esi,%edi
call   1060 <daemon@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
call   1050 <syslog@plt>
mov    $0xa,%edi
call   1080 <sleep@plt>
jmp    11b4 <main+0x54>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2e5d(%rip),%r14
mov    (%r14),%edi
call   1030 <LOG_UPTO@plt>
mov    %eax,%edi
call   1040 <setlogmask@plt>
mov    0x2e4f(%rip),%rax
mov    0x2e58(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e55(%rip),%rax
mov    (%rax),%edx
lea    0xe64(%rip),%rdi
call   1070 <openlog@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1060 <daemon@plt>
lea    0xe5c(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14),%edi
mov    %rbx,%rsi
call   1050 <syslog@plt>
mov    $0xa,%edi
call   1080 <sleep@plt>
jmp    11c0 <main+0x60>

LLVM IR (-O0):
@LOG_INFO = global i32 0
@.str = [13 x i8] c"simpledaemon\00"
@LOG_CONS = global i32 0
@LOG_PERROR = global i32 0
@LOG_USER = global i32 0
@.str.1 = [15 x i8] c"daemon running\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = load i32, i32* @LOG_INFO
%3 = call i32 @LOG_UPTO(i32 %2)
%4 = call i32 @setlogmask(i32 %3)
%5 = load i32, i32* @LOG_CONS
%6 = load i32, i32* @LOG_PERROR
%7 = or i32 %5, %6
%8 = load i32, i32* @LOG_USER
%9 = call i32 @openlog(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8)
%10 = call i32 @daemon(i32 0, i32 0)
br label %11
11: ; preds = %0, %11
%12 = load i32, i32* @LOG_INFO
%13 = call i32 @syslog(i32 %12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @sleep(i32 10)
br label %11
}

LLVM IR (-O2):
@LOG_INFO = global i32 0
@.str = [13 x i8] c"simpledaemon\00"
@LOG_CONS = global i32 0
@LOG_PERROR = global i32 0
@LOG_USER = global i32 0
@.str.1 = [15 x i8] c"daemon running\00"
define i32 @main() {
%1 = load i32, i32* @LOG_INFO
%2 = tail call i32 @LOG_UPTO(i32 %1)
%3 = tail call i32 @setlogmask(i32 %2)
%4 = load i32, i32* @LOG_CONS
%5 = load i32, i32* @LOG_PERROR
%6 = or i32 %5, %4
%7 = load i32, i32* @LOG_USER
%8 = tail call i32 @openlog(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
%9 = tail call i32 @daemon(i32 0, i32 0)
br label %10
10: ; preds = %0, %10
%11 = load i32, i32* @LOG_INFO
%12 = tail call i32 @syslog(i32 %11, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @sleep(i32 10)
br label %10
}