#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_NDELAY;
int /*<<< orphan*/ LOG_NOTICE;
int LOG_PID;
int /*<<< orphan*/ LOG_UPTO(int);
int /*<<< orphan*/ LOG_WARNING;
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ setlogmask(int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
void write_log(int LOG_LEVEL) {
  setlogmask(LOG_UPTO(LOG_LEVEL));
  openlog("log_given_level", 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    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <LOG_UPTO@plt>
mov    %eax,%edi
call   1050 <setlogmask@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%esi
mov    0x2e46(%rip),%rax
or     (%rax),%esi
mov    0x2e05(%rip),%rax
or     (%rax),%esi
mov    0x2e24(%rip),%rax
mov    (%rax),%edx
lea    0xe6b(%rip),%rdi
call   1070 <openlog@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
lea    0xe66(%rip),%rsi
call   1060 <syslog@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xe64(%rip),%rsi
call   1060 <syslog@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1060 <syslog@plt>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
lea    0xe6f(%rip),%rsi
call   1060 <syslog@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
call   1060 <syslog@plt>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
lea    0xe69(%rip),%rsi
call   1060 <syslog@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
lea    0xe75(%rip),%rsi
call   1060 <syslog@plt>
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
lea    0xe6e(%rip),%rsi
call   1060 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_log>:
push   %rax
call   1040 <LOG_UPTO@plt>
mov    %eax,%edi
call   1050 <setlogmask@plt>
mov    0x2e54(%rip),%rax
mov    0x2e55(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e12(%rip),%rax
or     (%rax),%esi
mov    0x2e31(%rip),%rax
mov    (%rax),%edx
lea    0xe78(%rip),%rdi
call   1070 <openlog@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0xe73(%rip),%rsi
call   1060 <syslog@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
lea    0xe71(%rip),%rsi
call   1060 <syslog@plt>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
lea    0xe7d(%rip),%rsi
call   1060 <syslog@plt>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
lea    0xe7c(%rip),%rsi
call   1060 <syslog@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
call   1060 <syslog@plt>
mov    0x2dab(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
call   1060 <syslog@plt>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
call   1060 <syslog@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
call   1060 <syslog@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <closelog@plt>

LLVM IR (-O0):
@.str = [16 x i8] c"log_given_level\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"
@LOG_DEBUG = global i32 0
@.str.8 = [21 x i8] c"Debug-level messages\00"
define void @write_log(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @LOG_UPTO(i32 %3)
%5 = call i32 @setlogmask(i32 %4)
%6 = load i32, i32* @LOG_CONS
%7 = load i32, i32* @LOG_PID
%8 = or i32 %6, %7
%9 = load i32, i32* @LOG_NDELAY
%10 = or i32 %8, %9
%11 = load i32, i32* @LOG_LOCAL1
%12 = call i32 @openlog(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11)
%13 = load i32, i32* @LOG_EMERG
%14 = call i32 @syslog(i32 %13, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @LOG_ALERT
%16 = call i32 @syslog(i32 %15, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%17 = load i32, i32* @LOG_CRIT
%18 = call i32 @syslog(i32 %17, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%19 = load i32, i32* @LOG_ERR
%20 = call i32 @syslog(i32 %19, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%21 = load i32, i32* @LOG_WARNING
%22 = call i32 @syslog(i32 %21, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%23 = load i32, i32* @LOG_NOTICE
%24 = call i32 @syslog(i32 %23, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%25 = load i32, i32* @LOG_INFO
%26 = call i32 @syslog(i32 %25, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%27 = load i32, i32* @LOG_DEBUG
%28 = call i32 @syslog(i32 %27, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
%29 = call i32 (...) @closelog()
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"log_given_level\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"
@LOG_DEBUG = global i32 0
@.str.8 = [21 x i8] c"Debug-level messages\00"
define void @write_log(i32 %0) {
%2 = tail call i32 @LOG_UPTO(i32 %0)
%3 = tail call i32 @setlogmask(i32 %2)
%4 = load i32, i32* @LOG_CONS
%5 = load i32, i32* @LOG_PID
%6 = or i32 %5, %4
%7 = load i32, i32* @LOG_NDELAY
%8 = or i32 %6, %7
%9 = load i32, i32* @LOG_LOCAL1
%10 = tail call i32 @openlog(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9)
%11 = load i32, i32* @LOG_EMERG
%12 = tail call i32 @syslog(i32 %11, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @LOG_ALERT
%14 = tail call i32 @syslog(i32 %13, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @LOG_CRIT
%16 = tail call i32 @syslog(i32 %15, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%17 = load i32, i32* @LOG_ERR
%18 = tail call i32 @syslog(i32 %17, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%19 = load i32, i32* @LOG_WARNING
%20 = tail call i32 @syslog(i32 %19, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
%21 = load i32, i32* @LOG_NOTICE
%22 = tail call i32 @syslog(i32 %21, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
%23 = load i32, i32* @LOG_INFO
%24 = tail call i32 @syslog(i32 %23, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%25 = load i32, i32* @LOG_DEBUG
%26 = tail call i32 @syslog(i32 %25, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
%27 = tail call i32 (...) @closelog()
ret void
}