#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*/ EXIT_FAILURE;
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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ predaemon(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    fprintf(stderr,
            "ERROR: missing command. One of (start | stop) required.\n");
    exit(EXIT_FAILURE);
  }
  if (argc > 2) {
    fprintf(stderr,
            "ERROR: too many arguments. Only one of (start | stop) allowed\n");
    exit(EXIT_FAILURE);
  }
  char *cmd = argv[1];
  predaemon(cmd);
  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    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11c3 <main+0x43>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
jle    11f0 <main+0x70>
mov    0x2dec(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <predaemon@plt>
mov    $0x0,%al
call   1040 <daemonize@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
call   1060 <syslog@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
call   1060 <syslog@plt>
mov    $0xa,%edi
call   10a0 <sleep@plt>
mov    0x2d47(%rip),%rax
mov    (%rax),%edi
lea    0xe3a(%rip),%rsi
call   1060 <syslog@plt>
mov    $0xa,%edi
call   10a0 <sleep@plt>
mov    0x2d40(%rip),%rax
mov    (%rax),%edi
lea    0xe20(%rip),%rsi
call   1060 <syslog@plt>
mov    $0xa,%edi
call   10a0 <sleep@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
lea    0xe08(%rip),%rsi
call   1060 <syslog@plt>
mov    $0xa,%edi
call   10a0 <sleep@plt>
mov    0x2cda(%rip),%rax
mov    (%rax),%edi
lea    0xdf1(%rip),%rsi
call   1060 <syslog@plt>
mov    $0xa,%edi
call   10a0 <sleep@plt>
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
lea    0xdd6(%rip),%rsi
call   1060 <syslog@plt>
mov    $0xa,%edi
call   10a0 <sleep@plt>
mov    0x2cfc(%rip),%rax
mov    (%rax),%edi
lea    0xdbc(%rip),%rsi
call   1060 <syslog@plt>
mov    $0xa,%edi
call   10a0 <sleep@plt>
mov    0x2ccd(%rip),%rax
mov    (%rax),%edi
lea    0xda3(%rip),%rsi
call   1060 <syslog@plt>
mov    $0x168,%edi
call   10a0 <sleep@plt>
mov    $0x0,%al
call   1080 <cleanup@plt>
mov    0x2c7f(%rip),%rax
mov    (%rax),%edi
lea    0xd83(%rip),%rsi
call   1060 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
mov    0x2c5b(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
jle    12da <main+0x15a>
cmp    $0x2,%edi
jne    12ec <main+0x16c>
mov    0x8(%rsi),%rdi
call   1070 <predaemon@plt>
xor    %eax,%eax
call   1040 <daemonize@plt>
mov    0x2dee(%rip),%rbx
mov    (%rbx),%edi
lea    0xec5(%rip),%rsi
call   1060 <syslog@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
lea    0xebc(%rip),%rsi
call   1060 <syslog@plt>
mov    $0xa,%edi
call   10a0 <sleep@plt>
mov    (%rbx),%edi
lea    0xeaa(%rip),%rsi
call   1060 <syslog@plt>
mov    $0xa,%edi
call   10a0 <sleep@plt>
mov    0x2db0(%rip),%rbx
mov    (%rbx),%edi
lea    0xe90(%rip),%rsi
call   1060 <syslog@plt>
mov    $0xa,%edi
call   10a0 <sleep@plt>
mov    0x2db1(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
call   1060 <syslog@plt>
mov    $0xa,%edi
call   10a0 <sleep@plt>
mov    0x2d4a(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
call   1060 <syslog@plt>
mov    $0xa,%edi
call   10a0 <sleep@plt>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
lea    0xe46(%rip),%rsi
call   1060 <syslog@plt>
mov    $0xa,%edi
call   10a0 <sleep@plt>
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
lea    0xe2c(%rip),%rsi
call   1060 <syslog@plt>
mov    $0xa,%edi
call   10a0 <sleep@plt>
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
lea    0xe13(%rip),%rsi
call   1060 <syslog@plt>
mov    $0x168,%edi
call   10a0 <sleep@plt>
xor    %eax,%eax
call   1080 <cleanup@plt>
mov    (%rbx),%edi
lea    0xdfa(%rip),%rsi
call   1060 <syslog@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
mov    0x2cd2(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret
mov    0x2cdf(%rip),%rax
mov    (%rax),%edi
lea    0xd16(%rip),%rsi
jmp    12fc <main+0x17c>
mov    0x2ccd(%rip),%rax
mov    (%rax),%edi
lea    0xd3d(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2cb0(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [57 x i8] c"ERROR: missing command. One of (start | stop) required.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [63 x i8] c"ERROR: too many arguments. Only one of (start | stop) allowed\0A\00"
@LOG_INFO = global i32 0
@.str.2 = [22 x i8] c"started successfully.\00"
@LOG_DEBUG = global i32 0
@.str.3 = [6 x i8] c"DEBUG\00"
@.str.4 = [5 x i8] c"INFO\00"
@LOG_NOTICE = global i32 0
@.str.5 = [7 x i8] c"NOTICE\00"
@LOG_WARNING = global i32 0
@.str.6 = [8 x i8] c"WARNING\00"
@LOG_ERR = global i32 0
@.str.7 = [4 x i8] c"ERR\00"
@LOG_CRIT = global i32 0
@.str.8 = [5 x i8] c"CRIT\00"
@LOG_ALERT = global i32 0
@.str.9 = [6 x i8] c"ALERT\00"
@LOG_EMERG = global i32 0
@.str.10 = [6 x i8] c"EMERG\00"
@.str.11 = [27 x i8] c"terminating automatically.\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %2
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 2
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %14
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
store i8* %25, i8** %6
%26 = load i8*, i8** %6
%27 = call i32 @predaemon(i8* %26)
%28 = call i32 (...) @daemonize()
%29 = load i32, i32* @LOG_INFO
%30 = call i32 @syslog(i32 %29, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %22
%32 = call i32 @sleep(i32 1)
%33 = load i32, i32* @LOG_DEBUG
%34 = call i32 @syslog(i32 %33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%35 = call i32 @sleep(i32 10)
%36 = load i32, i32* @LOG_INFO
%37 = call i32 @syslog(i32 %36, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%38 = call i32 @sleep(i32 10)
%39 = load i32, i32* @LOG_NOTICE
%40 = call i32 @syslog(i32 %39, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%41 = call i32 @sleep(i32 10)
%42 = load i32, i32* @LOG_WARNING
%43 = call i32 @syslog(i32 %42, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%44 = call i32 @sleep(i32 10)
%45 = load i32, i32* @LOG_ERR
%46 = call i32 @syslog(i32 %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%47 = call i32 @sleep(i32 10)
%48 = load i32, i32* @LOG_CRIT
%49 = call i32 @syslog(i32 %48, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%50 = call i32 @sleep(i32 10)
%51 = load i32, i32* @LOG_ALERT
%52 = call i32 @syslog(i32 %51, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%53 = call i32 @sleep(i32 10)
%54 = load i32, i32* @LOG_EMERG
%55 = call i32 @syslog(i32 %54, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%56 = call i32 @sleep(i32 360)
br label %57
57: ; preds = %31
%58 = call i32 (...) @cleanup()
%59 = load i32, i32* @LOG_NOTICE
%60 = call i32 @syslog(i32 %59, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0))
%61 = call i32 (...) @closelog()
%62 = load i32, i32* @EXIT_SUCCESS
ret i32 %62
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [57 x i8] c"ERROR: missing command. One of (start | stop) required.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [63 x i8] c"ERROR: too many arguments. Only one of (start | stop) allowed\0A\00"
@LOG_INFO = global i32 0
@.str.2 = [22 x i8] c"started successfully.\00"
@LOG_DEBUG = global i32 0
@.str.3 = [6 x i8] c"DEBUG\00"
@.str.4 = [5 x i8] c"INFO\00"
@LOG_NOTICE = global i32 0
@.str.5 = [7 x i8] c"NOTICE\00"
@LOG_WARNING = global i32 0
@.str.6 = [8 x i8] c"WARNING\00"
@LOG_ERR = global i32 0
@.str.7 = [4 x i8] c"ERR\00"
@LOG_CRIT = global i32 0
@.str.8 = [5 x i8] c"CRIT\00"
@LOG_ALERT = global i32 0
@.str.9 = [6 x i8] c"ALERT\00"
@LOG_EMERG = global i32 0
@.str.10 = [6 x i8] c"EMERG\00"
@.str.11 = [27 x i8] c"terminating automatically.\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = icmp eq i32 %0, 2
br i1 %10, label %16, label %11
11: ; preds = %9
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* @EXIT_FAILURE
%15 = tail call i32 @exit(i32 %14)
unreachable
16: ; preds = %9
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i32 @predaemon(i8* %18)
%20 = tail call i32 (...) @daemonize()
%21 = load i32, i32* @LOG_INFO
%22 = tail call i32 @syslog(i32 %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%23 = tail call i32 @sleep(i32 1)
%24 = load i32, i32* @LOG_DEBUG
%25 = tail call i32 @syslog(i32 %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%26 = tail call i32 @sleep(i32 10)
%27 = load i32, i32* @LOG_INFO
%28 = tail call i32 @syslog(i32 %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%29 = tail call i32 @sleep(i32 10)
%30 = load i32, i32* @LOG_NOTICE
%31 = tail call i32 @syslog(i32 %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%32 = tail call i32 @sleep(i32 10)
%33 = load i32, i32* @LOG_WARNING
%34 = tail call i32 @syslog(i32 %33, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%35 = tail call i32 @sleep(i32 10)
%36 = load i32, i32* @LOG_ERR
%37 = tail call i32 @syslog(i32 %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%38 = tail call i32 @sleep(i32 10)
%39 = load i32, i32* @LOG_CRIT
%40 = tail call i32 @syslog(i32 %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%41 = tail call i32 @sleep(i32 10)
%42 = load i32, i32* @LOG_ALERT
%43 = tail call i32 @syslog(i32 %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%44 = tail call i32 @sleep(i32 10)
%45 = load i32, i32* @LOG_EMERG
%46 = tail call i32 @syslog(i32 %45, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
%47 = tail call i32 @sleep(i32 360)
%48 = tail call i32 (...) @cleanup()
%49 = load i32, i32* @LOG_NOTICE
%50 = tail call i32 @syslog(i32 %49, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0))
%51 = tail call i32 (...) @closelog()
%52 = load i32, i32* @EXIT_SUCCESS
ret i32 %52
}