#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_ALERT;
int LOG_CONS;
int /*<<< orphan*/ LOG_CRIT;
int /*<<< orphan*/ LOG_EMERG;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ LOG_MAIL;
int LOG_NDELAY;
int /*<<< orphan*/ LOG_NOTICE;
int LOG_PID;
int /*<<< orphan*/ LOG_USER;
int /*<<< orphan*/ LOG_WARNING;
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int, char *, ...);
int main() {
  int invalid_priority = -1;
  syslog(invalid_priority, "Invalid %d", invalid_priority);
  invalid_priority = 10;
  syslog(invalid_priority, "Invalid %d", invalid_priority);
  invalid_priority = 55;
  syslog(invalid_priority, "Invalid %d", invalid_priority);
  syslog(LOG_INFO, "(Info) No open has been called prior to this");
  syslog(LOG_NOTICE, "(Notice) Program created with two arguments: %s and %s",
         "one", "two");
  openlog("Prepended message", LOG_CONS | LOG_NDELAY, LOG_MAIL);
  syslog(LOG_ERR, "(Err) Log after prepended message with one argument: %d",
         44);
  syslog(LOG_WARNING,
         "(Warning) Log number two after openlog set prepended message");
  closelog();
  syslog(LOG_WARNING,
         "(Warning) Log after closelog with three arguments. One is %u, "
         "another is %s, a third is %d",
         33, "this", 4011);
  openlog("Second prepended message", LOG_PID | LOG_CONS, LOG_USER);
  syslog(LOG_EMERG, "This is a test of an emergency log. You might need to "
                    "stop the program manually.");
  syslog(LOG_ALERT, "Alert log with the m argument: %m");
  closelog();
  syslog(LOG_CRIT,
         "Critical after cleared prepended message (closelog has been called)");
  closelog();
  openlog("Open after close prepended message", LOG_CONS, LOG_MAIL);
  syslog(
      LOG_INFO,
      "Info after openlog with both m: %m and two hex arguments: 0x%x and 0x%x",
      100, 50);
  closelog();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xffffffff,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%edx
lea    0xead(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
movl   $0xa,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%edx
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
movl   $0x37,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%edx
lea    0xe77(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
lea    0xeb1(%rip),%rdx
lea    0xeae(%rip),%rcx
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%esi
mov    0x2db4(%rip),%rax
or     (%rax),%esi
mov    0x2da3(%rip),%rax
mov    (%rax),%edx
lea    0xe89(%rip),%rdi
call   1050 <openlog@plt>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
lea    0xe86(%rip),%rsi
mov    $0x2c,%edx
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2db2(%rip),%rax
mov    (%rax),%edi
lea    0xea2(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
lea    0xec1(%rip),%rsi
mov    $0x21,%edx
lea    0xdea(%rip),%rcx
mov    $0xfab,%r8d
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2d5b(%rip),%rax
mov    (%rax),%esi
mov    0x2d4a(%rip),%rax
or     (%rax),%esi
mov    0x2d79(%rip),%rax
mov    (%rax),%edx
lea    0xee1(%rip),%rdi
call   1050 <openlog@plt>
mov    0x2d4c(%rip),%rax
mov    (%rax),%edi
lea    0xee5(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
lea    0xf1f(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
mov    0x2d1f(%rip),%rax
mov    (%rax),%edi
lea    0xf23(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
mov    0x2cd9(%rip),%rax
mov    (%rax),%esi
mov    0x2ca8(%rip),%rax
mov    (%rax),%edx
lea    0xf40(%rip),%rdi
call   1050 <openlog@plt>
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
lea    0xf4e(%rip),%rsi
mov    $0x64,%edx
mov    $0x32,%ecx
mov    $0x0,%al
call   1040 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec1(%rip),%rbx
mov    $0xffffffff,%edi
mov    %rbx,%rsi
mov    $0xffffffff,%edx
xor    %eax,%eax
call   1040 <syslog@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
mov    $0xa,%edx
xor    %eax,%eax
call   1040 <syslog@plt>
mov    $0x37,%edi
mov    %rbx,%rsi
mov    $0x37,%edx
xor    %eax,%eax
call   1040 <syslog@plt>
mov    0x2e1e(%rip),%r14
mov    (%r14),%edi
lea    0xe7f(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
lea    0xe95(%rip),%rsi
lea    0xec5(%rip),%rdx
lea    0xec2(%rip),%rcx
xor    %eax,%eax
call   1040 <syslog@plt>
mov    0x2df1(%rip),%r12
mov    0x2dca(%rip),%rax
mov    (%rax),%esi
or     (%r12),%esi
mov    0x2db5(%rip),%r15
mov    (%r15),%edx
lea    0xe9a(%rip),%rdi
call   1050 <openlog@plt>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
lea    0xe97(%rip),%rsi
mov    $0x2c,%edx
xor    %eax,%eax
call   1040 <syslog@plt>
mov    0x2dc3(%rip),%rbx
mov    (%rbx),%edi
lea    0xeb3(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
mov    (%rbx),%edi
lea    0xed9(%rip),%rsi
lea    0xe07(%rip),%rcx
mov    $0x21,%edx
mov    $0xfab,%r8d
xor    %eax,%eax
call   1040 <syslog@plt>
mov    0x2d73(%rip),%rax
mov    (%r12),%esi
or     (%rax),%esi
mov    0x2d96(%rip),%rax
mov    (%rax),%edx
lea    0xefe(%rip),%rdi
call   1050 <openlog@plt>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
lea    0xf02(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
lea    0xf3c(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
lea    0xf40(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
mov    (%r12),%esi
mov    (%r15),%edx
lea    0xf68(%rip),%rdi
call   1050 <openlog@plt>
mov    (%r14),%edi
lea    0xf7c(%rip),%rsi
mov    $0x64,%edx
mov    $0x32,%ecx
xor    %eax,%eax
call   1040 <syslog@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Invalid %d\00"
@LOG_INFO = global i32 0
@.str.1 = [45 x i8] c"(Info) No open has been called prior to this\00"
@LOG_NOTICE = global i32 0
@.str.2 = [55 x i8] c"(Notice) Program created with two arguments: %s and %s\00"
@.str.3 = [4 x i8] c"one\00"
@.str.4 = [4 x i8] c"two\00"
@.str.5 = [18 x i8] c"Prepended message\00"
@LOG_CONS = global i32 0
@LOG_NDELAY = global i32 0
@LOG_MAIL = global i32 0
@LOG_ERR = global i32 0
@.str.6 = [56 x i8] c"(Err) Log after prepended message with one argument: %d\00"
@LOG_WARNING = global i32 0
@.str.7 = [61 x i8] c"(Warning) Log number two after openlog set prepended message\00"
@.str.8 = [91 x i8] c"(Warning) Log after closelog with three arguments. One is %u, another is %s, a third is %d\00"
@.str.9 = [5 x i8] c"this\00"
@.str.10 = [25 x i8] c"Second prepended message\00"
@LOG_PID = global i32 0
@LOG_USER = global i32 0
@LOG_EMERG = global i32 0
@.str.11 = [81 x i8] c"This is a test of an emergency log. You might need to stop the program manually.\00"
@LOG_ALERT = global i32 0
@.str.12 = [34 x i8] c"Alert log with the m argument: %m\00"
@LOG_CRIT = global i32 0
@.str.13 = [68 x i8] c"Critical after cleared prepended message (closelog has been called)\00"
@.str.14 = [35 x i8] c"Open after close prepended message\00"
@.str.15 = [72 x i8] c"Info after openlog with both m: %m and two hex arguments: 0x%x and 0x%x\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 -1, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* %2
%5 = call i32 (i32, i8*, ...) @syslog(i32 %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 10, i32* %2
%6 = load i32, i32* %2
%7 = load i32, i32* %2
%8 = call i32 (i32, i8*, ...) @syslog(i32 %6, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %7)
store i32 55, i32* %2
%9 = load i32, i32* %2
%10 = load i32, i32* %2
%11 = call i32 (i32, i8*, ...) @syslog(i32 %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* @LOG_INFO
%13 = call i32 (i32, i8*, ...) @syslog(i32 %12, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* @LOG_NOTICE
%15 = call i32 (i32, i8*, ...) @syslog(i32 %14, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%16 = load i32, i32* @LOG_CONS
%17 = load i32, i32* @LOG_NDELAY
%18 = or i32 %16, %17
%19 = load i32, i32* @LOG_MAIL
%20 = call i32 @openlog(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %18, i32 %19)
%21 = load i32, i32* @LOG_ERR
%22 = call i32 (i32, i8*, ...) @syslog(i32 %21, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0), i32 44)
%23 = load i32, i32* @LOG_WARNING
%24 = call i32 (i32, i8*, ...) @syslog(i32 %23, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.7, i64 0, i64 0))
%25 = call i32 (...) @closelog()
%26 = load i32, i32* @LOG_WARNING
%27 = call i32 (i32, i8*, ...) @syslog(i32 %26, i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.8, i64 0, i64 0), i32 33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4011)
%28 = load i32, i32* @LOG_PID
%29 = load i32, i32* @LOG_CONS
%30 = or i32 %28, %29
%31 = load i32, i32* @LOG_USER
%32 = call i32 @openlog(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i32 %30, i32 %31)
%33 = load i32, i32* @LOG_EMERG
%34 = call i32 (i32, i8*, ...) @syslog(i32 %33, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.11, i64 0, i64 0))
%35 = load i32, i32* @LOG_ALERT
%36 = call i32 (i32, i8*, ...) @syslog(i32 %35, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.12, i64 0, i64 0))
%37 = call i32 (...) @closelog()
%38 = load i32, i32* @LOG_CRIT
%39 = call i32 (i32, i8*, ...) @syslog(i32 %38, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.13, i64 0, i64 0))
%40 = call i32 (...) @closelog()
%41 = load i32, i32* @LOG_CONS
%42 = load i32, i32* @LOG_MAIL
%43 = call i32 @openlog(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.14, i64 0, i64 0), i32 %41, i32 %42)
%44 = load i32, i32* @LOG_INFO
%45 = call i32 (i32, i8*, ...) @syslog(i32 %44, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.15, i64 0, i64 0), i32 100, i32 50)
%46 = call i32 (...) @closelog()
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"Invalid %d\00"
@LOG_INFO = global i32 0
@.str.1 = [45 x i8] c"(Info) No open has been called prior to this\00"
@LOG_NOTICE = global i32 0
@.str.2 = [55 x i8] c"(Notice) Program created with two arguments: %s and %s\00"
@.str.3 = [4 x i8] c"one\00"
@.str.4 = [4 x i8] c"two\00"
@.str.5 = [18 x i8] c"Prepended message\00"
@LOG_CONS = global i32 0
@LOG_NDELAY = global i32 0
@LOG_MAIL = global i32 0
@LOG_ERR = global i32 0
@.str.6 = [56 x i8] c"(Err) Log after prepended message with one argument: %d\00"
@LOG_WARNING = global i32 0
@.str.7 = [61 x i8] c"(Warning) Log number two after openlog set prepended message\00"
@.str.8 = [91 x i8] c"(Warning) Log after closelog with three arguments. One is %u, another is %s, a third is %d\00"
@.str.9 = [5 x i8] c"this\00"
@.str.10 = [25 x i8] c"Second prepended message\00"
@LOG_PID = global i32 0
@LOG_USER = global i32 0
@LOG_EMERG = global i32 0
@.str.11 = [81 x i8] c"This is a test of an emergency log. You might need to stop the program manually.\00"
@LOG_ALERT = global i32 0
@.str.12 = [34 x i8] c"Alert log with the m argument: %m\00"
@LOG_CRIT = global i32 0
@.str.13 = [68 x i8] c"Critical after cleared prepended message (closelog has been called)\00"
@.str.14 = [35 x i8] c"Open after close prepended message\00"
@.str.15 = [72 x i8] c"Info after openlog with both m: %m and two hex arguments: 0x%x and 0x%x\00"
define i32 @main() {
%1 = tail call i32 (i32, i8*, ...) @syslog(i32 -1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 -1)
%2 = tail call i32 (i32, i8*, ...) @syslog(i32 10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 10)
%3 = tail call i32 (i32, i8*, ...) @syslog(i32 55, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 55)
%4 = load i32, i32* @LOG_INFO
%5 = tail call i32 (i32, i8*, ...) @syslog(i32 %4, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32, i32* @LOG_NOTICE
%7 = tail call i32 (i32, i8*, ...) @syslog(i32 %6, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%8 = load i32, i32* @LOG_CONS
%9 = load i32, i32* @LOG_NDELAY
%10 = or i32 %9, %8
%11 = load i32, i32* @LOG_MAIL
%12 = tail call i32 @openlog(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %10, i32 %11)
%13 = load i32, i32* @LOG_ERR
%14 = tail call i32 (i32, i8*, ...) @syslog(i32 %13, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.6, i64 0, i64 0), i32 44)
%15 = load i32, i32* @LOG_WARNING
%16 = tail call i32 (i32, i8*, ...) @syslog(i32 %15, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.7, i64 0, i64 0))
%17 = tail call i32 (...) @closelog()
%18 = load i32, i32* @LOG_WARNING
%19 = tail call i32 (i32, i8*, ...) @syslog(i32 %18, i8* getelementptr inbounds ([91 x i8], [91 x i8]* @.str.8, i64 0, i64 0), i32 33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4011)
%20 = load i32, i32* @LOG_PID
%21 = load i32, i32* @LOG_CONS
%22 = or i32 %21, %20
%23 = load i32, i32* @LOG_USER
%24 = tail call i32 @openlog(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i32 %22, i32 %23)
%25 = load i32, i32* @LOG_EMERG
%26 = tail call i32 (i32, i8*, ...) @syslog(i32 %25, i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.11, i64 0, i64 0))
%27 = load i32, i32* @LOG_ALERT
%28 = tail call i32 (i32, i8*, ...) @syslog(i32 %27, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.12, i64 0, i64 0))
%29 = tail call i32 (...) @closelog()
%30 = load i32, i32* @LOG_CRIT
%31 = tail call i32 (i32, i8*, ...) @syslog(i32 %30, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.13, i64 0, i64 0))
%32 = tail call i32 (...) @closelog()
%33 = load i32, i32* @LOG_CONS
%34 = load i32, i32* @LOG_MAIL
%35 = tail call i32 @openlog(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.14, i64 0, i64 0), i32 %33, i32 %34)
%36 = load i32, i32* @LOG_INFO
%37 = tail call i32 (i32, i8*, ...) @syslog(i32 %36, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.15, i64 0, i64 0), i32 100, i32 50)
%38 = tail call i32 (...) @closelog()
ret i32 0
}