#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 LOG_CONS;
int /*<<< orphan*/ LOG_DEBUG;
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ LOG_NOTICE;
int LOG_PID;
int /*<<< orphan*/ LOG_UPTO(int /*<<< orphan*/);
int /*<<< orphan*/ LOG_USER;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
int setlogmask(int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
int main() {
  int logmask;
  openlog("logmask", LOG_PID | LOG_CONS, LOG_USER);
  syslog(LOG_INFO, "informative message, pid = %d", getpid());
  syslog(LOG_DEBUG, "debug message, should appear");
  logmask = setlogmask(LOG_UPTO(LOG_NOTICE));
  syslog(LOG_DEBUG, "debug message, should not appear");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
mov    0x2e51(%rip),%rax
or     (%rax),%esi
mov    0x2e60(%rip),%rax
mov    (%rax),%edx
lea    0xe6f(%rip),%rdi
call   1070 <openlog@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0xc(%rbp),%edi
mov    %eax,%edx
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
lea    0xe5a(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
call   1040 <LOG_UPTO@plt>
mov    %eax,%edi
call   1050 <setlogmask@plt>
mov    %eax,-0x8(%rbp)
mov    0x2dce(%rip),%rax
mov    (%rax),%edi
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1060 <syslog@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e70(%rip),%rax
mov    0x2e61(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e6e(%rip),%rax
mov    (%rax),%edx
lea    0xe7d(%rip),%rdi
call   1070 <openlog@plt>
mov    0x2e29(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xe69(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <syslog@plt>
mov    0x2e0f(%rip),%rbx
mov    (%rbx),%edi
lea    0xe6c(%rip),%rsi
xor    %eax,%eax
call   1060 <syslog@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
call   1040 <LOG_UPTO@plt>
mov    %eax,%edi
call   1050 <setlogmask@plt>
mov    (%rbx),%edi
lea    0xe64(%rip),%rsi
xor    %eax,%eax
call   1060 <syslog@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"logmask\00"
@LOG_PID = global i32 0
@LOG_CONS = global i32 0
@LOG_USER = global i32 0
@LOG_INFO = global i32 0
@.str.1 = [30 x i8] c"informative message, pid = %d\00"
@LOG_DEBUG = global i32 0
@.str.2 = [29 x i8] c"debug message, should appear\00"
@LOG_NOTICE = global i32 0
@.str.3 = [33 x i8] c"debug message, should not appear\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* @LOG_PID
%4 = load i32, i32* @LOG_CONS
%5 = or i32 %3, %4
%6 = load i32, i32* @LOG_USER
%7 = call i32 @openlog(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
%8 = load i32, i32* @LOG_INFO
%9 = call i32 (...) @getpid()
%10 = call i32 (i32, i8*, ...) @syslog(i32 %8, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = load i32, i32* @LOG_DEBUG
%12 = call i32 (i32, i8*, ...) @syslog(i32 %11, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32, i32* @LOG_NOTICE
%14 = call i32 @LOG_UPTO(i32 %13)
%15 = call i32 @setlogmask(i32 %14)
store i32 %15, i32* %2
%16 = load i32, i32* @LOG_DEBUG
%17 = call i32 (i32, i8*, ...) @syslog(i32 %16, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [8 x i8] c"logmask\00"
@LOG_PID = global i32 0
@LOG_CONS = global i32 0
@LOG_USER = global i32 0
@LOG_INFO = global i32 0
@.str.1 = [30 x i8] c"informative message, pid = %d\00"
@LOG_DEBUG = global i32 0
@.str.2 = [29 x i8] c"debug message, should appear\00"
@LOG_NOTICE = global i32 0
@.str.3 = [33 x i8] c"debug message, should not appear\00"
define i32 @main() {
%1 = load i32, i32* @LOG_PID
%2 = load i32, i32* @LOG_CONS
%3 = or i32 %2, %1
%4 = load i32, i32* @LOG_USER
%5 = tail call i32 @openlog(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4)
%6 = load i32, i32* @LOG_INFO
%7 = tail call i32 (...) @getpid()
%8 = tail call i32 (i32, i8*, ...) @syslog(i32 %6, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = load i32, i32* @LOG_DEBUG
%10 = tail call i32 (i32, i8*, ...) @syslog(i32 %9, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%11 = load i32, i32* @LOG_NOTICE
%12 = tail call i32 @LOG_UPTO(i32 %11)
%13 = tail call i32 @setlogmask(i32 %12)
%14 = load i32, i32* @LOG_DEBUG
%15 = tail call i32 (i32, i8*, ...) @syslog(i32 %14, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%16 = tail call i32 @exit(i32 0)
unreachable
}