#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_DEBUG;
int /*<<< orphan*/ LOG_EMERG;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ LOG_LOCAL1;
int LOG_MASK(int /*<<< orphan*/);
int LOG_NDELAY;
int /*<<< orphan*/ LOG_NOTICE;
int LOG_PID;
int LOG_UPTO(int /*<<< orphan*/);
int /*<<< orphan*/ LOG_WARNING;
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ setlogmask(int);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
void write_log() {
  setlogmask(LOG_UPTO(LOG_DEBUG) | LOG_MASK(LOG_DEBUG));
  openlog("exampleprog", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
  syslog(LOG_EMERG, "System is unusable");
  syslog(LOG_ALERT, "Action must be taken immediately");
  syslog(LOG_CRIT, "Critical conditions");
  syslog(LOG_ERR, "Error conditions");
  syslog(LOG_WARNING, "Warning conditions");
  syslog(LOG_NOTICE, "Normal but significant condition");
  syslog(LOG_INFO, "Informational");
  syslog(LOG_DEBUG, "Debug-level messages");
  closelog();
}


x86 assembly (clang, -O0):
<write_log>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
call   1040 <LOG_UPTO@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
call   1050 <LOG_MASK@plt>
mov    -0x4(%rbp),%edi
or     %eax,%edi
call   1060 <setlogmask@plt>
mov    0x2e20(%rip),%rax
mov    (%rax),%esi
mov    0x2e1f(%rip),%rax
or     (%rax),%esi
mov    0x2dde(%rip),%rax
or     (%rax),%esi
mov    0x2dfd(%rip),%rax
mov    (%rax),%edx
lea    0xe44(%rip),%rdi
call   1080 <openlog@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xe3b(%rip),%rsi
call   1070 <syslog@plt>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
lea    0xe39(%rip),%rsi
call   1070 <syslog@plt>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
lea    0xe45(%rip),%rsi
call   1070 <syslog@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
lea    0xe44(%rip),%rsi
call   1070 <syslog@plt>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
call   1070 <syslog@plt>
mov    0x2d77(%rip),%rax
mov    (%rax),%edi
lea    0xe3e(%rip),%rsi
call   1070 <syslog@plt>
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
lea    0xe4a(%rip),%rsi
call   1070 <syslog@plt>
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
lea    0xe43(%rip),%rsi
call   1070 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_log>:
push   %r14
push   %rbx
push   %rax
mov    0x2e35(%rip),%r14
mov    (%r14),%edi
call   1040 <LOG_UPTO@plt>
mov    %eax,%ebx
mov    (%r14),%edi
call   1050 <LOG_MASK@plt>
or     %eax,%ebx
mov    %ebx,%edi
call   1060 <setlogmask@plt>
mov    0x2e2b(%rip),%rax
mov    0x2e2c(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2de9(%rip),%rax
or     (%rax),%esi
mov    0x2e08(%rip),%rax
mov    (%rax),%edx
lea    0xe4f(%rip),%rdi
call   1080 <openlog@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
lea    0xe46(%rip),%rsi
call   1070 <syslog@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
lea    0xe44(%rip),%rsi
call   1070 <syslog@plt>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
call   1070 <syslog@plt>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
lea    0xe4f(%rip),%rsi
call   1070 <syslog@plt>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
lea    0xe4b(%rip),%rsi
call   1070 <syslog@plt>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
call   1070 <syslog@plt>
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
lea    0xe55(%rip),%rsi
call   1070 <syslog@plt>
mov    (%r14),%edi
lea    0xe54(%rip),%rsi
call   1070 <syslog@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <closelog@plt>

LLVM IR (-O0):
@LOG_DEBUG = global i32 0
@.str = [12 x i8] c"exampleprog\00"
@LOG_CONS = global i32 0
@LOG_PID = global i32 0
@LOG_NDELAY = global i32 0
@LOG_LOCAL1 = global i32 0
@LOG_EMERG = global i32 0
@.str.1 = [19 x i8] c"System is unusable\00"
@LOG_ALERT = global i32 0
@.str.2 = [33 x i8] c"Action must be taken immediately\00"
@LOG_CRIT = global i32 0
@.str.3 = [20 x i8] c"Critical conditions\00"
@LOG_ERR = global i32 0
@.str.4 = [17 x i8] c"Error conditions\00"
@LOG_WARNING = global i32 0
@.str.5 = [19 x i8] c"Warning conditions\00"
@LOG_NOTICE = global i32 0
@.str.6 = [33 x i8] c"Normal but significant condition\00"
@LOG_INFO = global i32 0
@.str.7 = [14 x i8] c"Informational\00"
@.str.8 = [21 x i8] c"Debug-level messages\00"
define void @write_log() {
%1 = load i32, i32* @LOG_DEBUG
%2 = call i32 @LOG_UPTO(i32 %1)
%3 = load i32, i32* @LOG_DEBUG
%4 = call i32 @LOG_MASK(i32 %3)
%5 = or i32 %2, %4
%6 = call i32 @setlogmask(i32 %5)
%7 = load i32, i32* @LOG_CONS
%8 = load i32, i32* @LOG_PID
%9 = or i32 %7, %8
%10 = load i32, i32* @LOG_NDELAY
%11 = or i32 %9, %10
%12 = load i32, i32* @LOG_LOCAL1
%13 = call i32 @openlog(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12)
%14 = load i32, i32* @LOG_EMERG
%15 = call i32 @syslog(i32 %14, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @LOG_ALERT
%17 = call i32 @syslog(i32 %16, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32, i32* @LOG_CRIT
%19 = call i32 @syslog(i32 %18, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32, i32* @LOG_ERR
%21 = call i32 @syslog(i32 %20, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%22 = load i32, i32* @LOG_WARNING
%23 = call i32 @syslog(i32 %22, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%24 = load i32, i32* @LOG_NOTICE
%25 = call i32 @syslog(i32 %24, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%26 = load i32, i32* @LOG_INFO
%27 = call i32 @syslog(i32 %26, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%28 = load i32, i32* @LOG_DEBUG
%29 = call i32 @syslog(i32 %28, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
%30 = call i32 (...) @closelog()
ret void
}

LLVM IR (-O2):
@LOG_DEBUG = global i32 0
@.str = [12 x i8] c"exampleprog\00"
@LOG_CONS = global i32 0
@LOG_PID = global i32 0
@LOG_NDELAY = global i32 0
@LOG_LOCAL1 = global i32 0
@LOG_EMERG = global i32 0
@.str.1 = [19 x i8] c"System is unusable\00"
@LOG_ALERT = global i32 0
@.str.2 = [33 x i8] c"Action must be taken immediately\00"
@LOG_CRIT = global i32 0
@.str.3 = [20 x i8] c"Critical conditions\00"
@LOG_ERR = global i32 0
@.str.4 = [17 x i8] c"Error conditions\00"
@LOG_WARNING = global i32 0
@.str.5 = [19 x i8] c"Warning conditions\00"
@LOG_NOTICE = global i32 0
@.str.6 = [33 x i8] c"Normal but significant condition\00"
@LOG_INFO = global i32 0
@.str.7 = [14 x i8] c"Informational\00"
@.str.8 = [21 x i8] c"Debug-level messages\00"
define void @write_log() {
%1 = load i32, i32* @LOG_DEBUG
%2 = tail call i32 @LOG_UPTO(i32 %1)
%3 = load i32, i32* @LOG_DEBUG
%4 = tail call i32 @LOG_MASK(i32 %3)
%5 = or i32 %4, %2
%6 = tail call i32 @setlogmask(i32 %5)
%7 = load i32, i32* @LOG_CONS
%8 = load i32, i32* @LOG_PID
%9 = or i32 %8, %7
%10 = load i32, i32* @LOG_NDELAY
%11 = or i32 %9, %10
%12 = load i32, i32* @LOG_LOCAL1
%13 = tail call i32 @openlog(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12)
%14 = load i32, i32* @LOG_EMERG
%15 = tail call i32 @syslog(i32 %14, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @LOG_ALERT
%17 = tail call i32 @syslog(i32 %16, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32, i32* @LOG_CRIT
%19 = tail call i32 @syslog(i32 %18, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%20 = load i32, i32* @LOG_ERR
%21 = tail call i32 @syslog(i32 %20, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%22 = load i32, i32* @LOG_WARNING
%23 = tail call i32 @syslog(i32 %22, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%24 = load i32, i32* @LOG_NOTICE
%25 = tail call i32 @syslog(i32 %24, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%26 = load i32, i32* @LOG_INFO
%27 = tail call i32 @syslog(i32 %26, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%28 = load i32, i32* @LOG_DEBUG
%29 = tail call i32 @syslog(i32 %28, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
%30 = tail call i32 (...) @closelog()
ret void
}