#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_LOCAL1;
int LOG_NDELAY;
int /*<<< orphan*/ LOG_NOTICE;
int LOG_PID;
int /*<<< orphan*/ LOG_UPTO(int /*<<< orphan*/);
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ getuid();
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ setlogmask(int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int, char *, ...);
void glogger(int log_L) {
  setlogmask(LOG_UPTO(LOG_NOTICE));
  openlog("TERMlogger", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
  syslog(LOG_NOTICE, "PROGRAM %d", getuid());
  syslog(log_L, "PID -> %d", getpid());
  syslog(log_L, "Debug >- -- -<");
  closelog();
}


x86 assembly (clang, -O0):
<glogger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1050 <LOG_UPTO@plt>
mov    %eax,%edi
call   1070 <setlogmask@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%esi
mov    0x2e40(%rip),%rax
or     (%rax),%esi
mov    0x2e0f(%rip),%rax
or     (%rax),%esi
mov    0x2e1e(%rip),%rax
mov    (%rax),%edx
lea    0xe45(%rip),%rdi
call   1090 <openlog@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1060 <getuid@plt>
mov    -0xc(%rbp),%edi
mov    %eax,%edx
lea    0xe2c(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x8(%rbp),%edi
mov    %eax,%edx
lea    0xe17(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
mov    -0x4(%rbp),%edi
lea    0xe10(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<glogger>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2e4c(%rip),%rbp
mov    0x0(%rbp),%edi
call   1050 <LOG_UPTO@plt>
mov    %eax,%edi
call   1070 <setlogmask@plt>
mov    0x2e46(%rip),%rax
mov    0x2e47(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e14(%rip),%rax
or     (%rax),%esi
mov    0x2e23(%rip),%rax
mov    (%rax),%edx
lea    0xe4a(%rip),%rdi
call   1090 <openlog@plt>
mov    0x0(%rbp),%ebp
xor    %eax,%eax
call   1060 <getuid@plt>
lea    0xe3f(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <syslog@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe31(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <syslog@plt>
lea    0xe29(%rip),%rsi
mov    %ebx,%edi
xor    %eax,%eax
call   1080 <syslog@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <closelog@plt>

LLVM IR (-O0):
@LOG_NOTICE = global i32 0
@.str = [11 x i8] c"TERMlogger\00"
@LOG_CONS = global i32 0
@LOG_PID = global i32 0
@LOG_NDELAY = global i32 0
@LOG_LOCAL1 = global i32 0
@.str.1 = [11 x i8] c"PROGRAM %d\00"
@.str.2 = [10 x i8] c"PID -> %d\00"
@.str.3 = [15 x i8] c"Debug >- -- -<\00"
define void @glogger(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* @LOG_NOTICE
%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 ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %11)
%13 = load i32, i32* @LOG_NOTICE
%14 = call i32 (...) @getuid()
%15 = call i32 (i32, i8*, ...) @syslog(i32 %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %2
%17 = call i32 (...) @getpid()
%18 = call i32 (i32, i8*, ...) @syslog(i32 %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %2
%20 = call i32 (i32, i8*, ...) @syslog(i32 %19, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 (...) @closelog()
ret void
}

LLVM IR (-O2):
@LOG_NOTICE = global i32 0
@.str = [11 x i8] c"TERMlogger\00"
@LOG_CONS = global i32 0
@LOG_PID = global i32 0
@LOG_NDELAY = global i32 0
@LOG_LOCAL1 = global i32 0
@.str.1 = [11 x i8] c"PROGRAM %d\00"
@.str.2 = [10 x i8] c"PID -> %d\00"
@.str.3 = [15 x i8] c"Debug >- -- -<\00"
define void @glogger(i32 %0) {
%2 = load i32, i32* @LOG_NOTICE
%3 = tail call i32 @LOG_UPTO(i32 %2)
%4 = tail call i32 @setlogmask(i32 %3)
%5 = load i32, i32* @LOG_CONS
%6 = load i32, i32* @LOG_PID
%7 = or i32 %6, %5
%8 = load i32, i32* @LOG_NDELAY
%9 = or i32 %7, %8
%10 = load i32, i32* @LOG_LOCAL1
%11 = tail call i32 @openlog(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10)
%12 = load i32, i32* @LOG_NOTICE
%13 = tail call i32 (...) @getuid()
%14 = tail call i32 (i32, i8*, ...) @syslog(i32 %12, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = tail call i32 (...) @getpid()
%16 = tail call i32 (i32, i8*, ...) @syslog(i32 %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = tail call i32 (i32, i8*, ...) @syslog(i32 %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%18 = tail call i32 (...) @closelog()
ret void
}