#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*/ LOG_ALERT;
int /*<<< orphan*/ LOG_CRIT;
int /*<<< orphan*/ LOG_DEBUG;
int /*<<< orphan*/ LOG_EMERG;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ LOG_NOTICE;
int /*<<< orphan*/ LOG_WARNING;
int /*<<< orphan*/ cleanup();
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ daemonize();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
int main() {
  daemonize();
  syslog(LOG_INFO, "started successfully.");
  while (1) {
    sleep(1);
    syslog(LOG_DEBUG, "DEBUG");
    sleep(10);
    syslog(LOG_INFO, "INFO");
    sleep(10);
    syslog(LOG_NOTICE, "NOTICE");
    sleep(10);
    syslog(LOG_WARNING, "WARNING");
    sleep(10);
    syslog(LOG_ERR, "ERR");
    sleep(10);
    syslog(LOG_CRIT, "CRIT");
    sleep(10);
    syslog(LOG_ALERT, "ALERT");
    sleep(10);
    syslog(LOG_EMERG, "EMERG");
    sleep(360);
    break;
  }
  cleanup();
  syslog(LOG_NOTICE, "terminating automatically.");
  closelog();
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <daemonize@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
call   1050 <syslog@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
call   1050 <syslog@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
call   1050 <syslog@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
lea    0xe4e(%rip),%rsi
call   1050 <syslog@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
lea    0xe36(%rip),%rsi
call   1050 <syslog@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    0x2d90(%rip),%rax
mov    (%rax),%edi
lea    0xe1f(%rip),%rsi
call   1050 <syslog@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
lea    0xe04(%rip),%rsi
call   1050 <syslog@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    0x2da2(%rip),%rax
mov    (%rax),%edi
lea    0xdea(%rip),%rsi
call   1050 <syslog@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
lea    0xdd1(%rip),%rsi
call   1050 <syslog@plt>
mov    $0x168,%edi
call   1070 <sleep@plt>
mov    $0x0,%al
call   1060 <cleanup@plt>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
lea    0xdb1(%rip),%rsi
call   1050 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
mov    0x2d11(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <daemonize@plt>
mov    0x2e49(%rip),%rbx
mov    (%rbx),%edi
lea    0xe98(%rip),%rsi
call   1050 <syslog@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xe8f(%rip),%rsi
call   1050 <syslog@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    (%rbx),%edi
lea    0xe7d(%rip),%rsi
call   1050 <syslog@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    0x2e0b(%rip),%rbx
mov    (%rbx),%edi
lea    0xe63(%rip),%rsi
call   1050 <syslog@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
lea    0xe4b(%rip),%rsi
call   1050 <syslog@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
lea    0xe34(%rip),%rsi
call   1050 <syslog@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
lea    0xe19(%rip),%rsi
call   1050 <syslog@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
lea    0xdff(%rip),%rsi
call   1050 <syslog@plt>
mov    $0xa,%edi
call   1070 <sleep@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%edi
lea    0xde6(%rip),%rsi
call   1050 <syslog@plt>
mov    $0x168,%edi
call   1070 <sleep@plt>
xor    %eax,%eax
call   1060 <cleanup@plt>
mov    (%rbx),%edi
lea    0xdcd(%rip),%rsi
call   1050 <syslog@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
mov    0x2d2d(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@LOG_INFO = global i32 0
@.str = [22 x i8] c"started successfully.\00"
@LOG_DEBUG = global i32 0
@.str.1 = [6 x i8] c"DEBUG\00"
@.str.2 = [5 x i8] c"INFO\00"
@LOG_NOTICE = global i32 0
@.str.3 = [7 x i8] c"NOTICE\00"
@LOG_WARNING = global i32 0
@.str.4 = [8 x i8] c"WARNING\00"
@LOG_ERR = global i32 0
@.str.5 = [4 x i8] c"ERR\00"
@LOG_CRIT = global i32 0
@.str.6 = [5 x i8] c"CRIT\00"
@LOG_ALERT = global i32 0
@.str.7 = [6 x i8] c"ALERT\00"
@LOG_EMERG = global i32 0
@.str.8 = [6 x i8] c"EMERG\00"
@.str.9 = [27 x i8] c"terminating automatically.\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @daemonize()
%3 = load i32, i32* @LOG_INFO
%4 = call i32 @syslog(i32 %3, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %0
%6 = call i32 @sleep(i32 1)
%7 = load i32, i32* @LOG_DEBUG
%8 = call i32 @syslog(i32 %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @sleep(i32 10)
%10 = load i32, i32* @LOG_INFO
%11 = call i32 @syslog(i32 %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @sleep(i32 10)
%13 = load i32, i32* @LOG_NOTICE
%14 = call i32 @syslog(i32 %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @sleep(i32 10)
%16 = load i32, i32* @LOG_WARNING
%17 = call i32 @syslog(i32 %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 @sleep(i32 10)
%19 = load i32, i32* @LOG_ERR
%20 = call i32 @syslog(i32 %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 @sleep(i32 10)
%22 = load i32, i32* @LOG_CRIT
%23 = call i32 @syslog(i32 %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%24 = call i32 @sleep(i32 10)
%25 = load i32, i32* @LOG_ALERT
%26 = call i32 @syslog(i32 %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%27 = call i32 @sleep(i32 10)
%28 = load i32, i32* @LOG_EMERG
%29 = call i32 @syslog(i32 %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%30 = call i32 @sleep(i32 360)
br label %31
31: ; preds = %5
%32 = call i32 (...) @cleanup()
%33 = load i32, i32* @LOG_NOTICE
%34 = call i32 @syslog(i32 %33, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%35 = call i32 (...) @closelog()
%36 = load i32, i32* @EXIT_SUCCESS
ret i32 %36
}

LLVM IR (-O2):
@LOG_INFO = global i32 0
@.str = [22 x i8] c"started successfully.\00"
@LOG_DEBUG = global i32 0
@.str.1 = [6 x i8] c"DEBUG\00"
@.str.2 = [5 x i8] c"INFO\00"
@LOG_NOTICE = global i32 0
@.str.3 = [7 x i8] c"NOTICE\00"
@LOG_WARNING = global i32 0
@.str.4 = [8 x i8] c"WARNING\00"
@LOG_ERR = global i32 0
@.str.5 = [4 x i8] c"ERR\00"
@LOG_CRIT = global i32 0
@.str.6 = [5 x i8] c"CRIT\00"
@LOG_ALERT = global i32 0
@.str.7 = [6 x i8] c"ALERT\00"
@LOG_EMERG = global i32 0
@.str.8 = [6 x i8] c"EMERG\00"
@.str.9 = [27 x i8] c"terminating automatically.\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @daemonize()
%2 = load i32, i32* @LOG_INFO
%3 = tail call i32 @syslog(i32 %2, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @sleep(i32 1)
%5 = load i32, i32* @LOG_DEBUG
%6 = tail call i32 @syslog(i32 %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @sleep(i32 10)
%8 = load i32, i32* @LOG_INFO
%9 = tail call i32 @syslog(i32 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @sleep(i32 10)
%11 = load i32, i32* @LOG_NOTICE
%12 = tail call i32 @syslog(i32 %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%13 = tail call i32 @sleep(i32 10)
%14 = load i32, i32* @LOG_WARNING
%15 = tail call i32 @syslog(i32 %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%16 = tail call i32 @sleep(i32 10)
%17 = load i32, i32* @LOG_ERR
%18 = tail call i32 @syslog(i32 %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%19 = tail call i32 @sleep(i32 10)
%20 = load i32, i32* @LOG_CRIT
%21 = tail call i32 @syslog(i32 %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%22 = tail call i32 @sleep(i32 10)
%23 = load i32, i32* @LOG_ALERT
%24 = tail call i32 @syslog(i32 %23, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
%25 = tail call i32 @sleep(i32 10)
%26 = load i32, i32* @LOG_EMERG
%27 = tail call i32 @syslog(i32 %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%28 = tail call i32 @sleep(i32 360)
%29 = tail call i32 (...) @cleanup()
%30 = load i32, i32* @LOG_NOTICE
%31 = tail call i32 @syslog(i32 %30, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%32 = tail call i32 (...) @closelog()
%33 = load i32, i32* @EXIT_SUCCESS
ret i32 %33
}