#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_INFO;
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 /*<<< orphan*/, char *, ...);
void logger() {
  setlogmask(LOG_UPTO(LOG_NOTICE));
  openlog("TERMlogger", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
  syslog(LOG_NOTICE, "Program started by User %d", getuid());
  syslog(LOG_INFO, "PID -> %d", getpid());
  syslog(LOG_INFO, "Debug --CRITICAL");
  closelog();
}


x86 assembly (clang, -O0):
<logger>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
call   1050 <LOG_UPTO@plt>
mov    %eax,%edi
call   1070 <setlogmask@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%esi
mov    0x2e43(%rip),%rax
or     (%rax),%esi
mov    0x2e0a(%rip),%rax
or     (%rax),%esi
mov    0x2e21(%rip),%rax
mov    (%rax),%edx
lea    0xe48(%rip),%rdi
call   1090 <openlog@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1060 <getuid@plt>
mov    -0x8(%rbp),%edi
mov    %eax,%edx
lea    0xe2f(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
mov    0x2dd6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x4(%rbp),%edi
mov    %eax,%edx
lea    0xe24(%rip),%rsi
mov    $0x0,%al
call   1080 <syslog@plt>
mov    0x2db0(%rip),%rax
mov    (%rax),%edi
lea    0xe17(%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):
<logger>:
push   %r14
push   %rbx
push   %rax
mov    0x2e4d(%rip),%rbx
mov    (%rbx),%edi
call   1050 <LOG_UPTO@plt>
mov    %eax,%edi
call   1070 <setlogmask@plt>
mov    0x2e48(%rip),%rax
mov    0x2e49(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e0e(%rip),%rax
or     (%rax),%esi
mov    0x2e25(%rip),%rax
mov    (%rax),%edx
lea    0xe4c(%rip),%rdi
call   1090 <openlog@plt>
mov    (%rbx),%ebx
xor    %eax,%eax
call   1060 <getuid@plt>
lea    0xe42(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <syslog@plt>
mov    0x2de5(%rip),%r14
mov    (%r14),%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe3a(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <syslog@plt>
mov    (%r14),%edi
lea    0xe2f(%rip),%rsi
xor    %eax,%eax
call   1080 <syslog@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
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 = [27 x i8] c"Program started by User %d\00"
@LOG_INFO = global i32 0
@.str.2 = [10 x i8] c"PID -> %d\00"
@.str.3 = [17 x i8] c"Debug --CRITICAL\00"
define void @logger() {
%1 = load i32, i32* @LOG_NOTICE
%2 = call i32 @LOG_UPTO(i32 %1)
%3 = call i32 @setlogmask(i32 %2)
%4 = load i32, i32* @LOG_CONS
%5 = load i32, i32* @LOG_PID
%6 = or i32 %4, %5
%7 = load i32, i32* @LOG_NDELAY
%8 = or i32 %6, %7
%9 = load i32, i32* @LOG_LOCAL1
%10 = call i32 @openlog(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9)
%11 = load i32, i32* @LOG_NOTICE
%12 = call i32 (...) @getuid()
%13 = call i32 (i32, i8*, ...) @syslog(i32 %11, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @LOG_INFO
%15 = call i32 (...) @getpid()
%16 = call i32 (i32, i8*, ...) @syslog(i32 %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = load i32, i32* @LOG_INFO
%18 = call i32 (i32, i8*, ...) @syslog(i32 %17, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%19 = 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 = [27 x i8] c"Program started by User %d\00"
@LOG_INFO = global i32 0
@.str.2 = [10 x i8] c"PID -> %d\00"
@.str.3 = [17 x i8] c"Debug --CRITICAL\00"
define void @logger() {
%1 = load i32, i32* @LOG_NOTICE
%2 = tail call i32 @LOG_UPTO(i32 %1)
%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 ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %9)
%11 = load i32, i32* @LOG_NOTICE
%12 = tail call i32 (...) @getuid()
%13 = tail call i32 (i32, i8*, ...) @syslog(i32 %11, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @LOG_INFO
%15 = tail call i32 (...) @getpid()
%16 = tail call i32 (i32, i8*, ...) @syslog(i32 %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = load i32, i32* @LOG_INFO
%18 = tail call i32 (i32, i8*, ...) @syslog(i32 %17, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%19 = tail call i32 (...) @closelog()
ret void
}