#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*/ getuid();
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ setlogmask(int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
int main() {
  setlogmask(LOG_UPTO(LOG_NOTICE));
  openlog("exampleprog", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
  syslog(LOG_NOTICE, "Program started by User %d", getuid());
  syslog(LOG_INFO, "A tree falls in a forest");
  closelog();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
call   1040 <LOG_UPTO@plt>
mov    %eax,%edi
call   1060 <setlogmask@plt>
mov    0x2e54(%rip),%rax
mov    (%rax),%esi
mov    0x2e53(%rip),%rax
or     (%rax),%esi
mov    0x2e1a(%rip),%rax
or     (%rax),%esi
mov    0x2e31(%rip),%rax
mov    (%rax),%edx
lea    0xe58(%rip),%rdi
call   1080 <openlog@plt>
mov    0x2e14(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1050 <getuid@plt>
mov    -0x4(%rbp),%edi
mov    %eax,%edx
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1070 <syslog@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
lea    0xe44(%rip),%rsi
mov    $0x0,%al
call   1070 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e60(%rip),%rbx
mov    (%rbx),%edi
call   1040 <LOG_UPTO@plt>
mov    %eax,%edi
call   1060 <setlogmask@plt>
mov    0x2e5b(%rip),%rax
mov    0x2e5c(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e21(%rip),%rax
or     (%rax),%esi
mov    0x2e38(%rip),%rax
mov    (%rax),%edx
lea    0xe5f(%rip),%rdi
call   1080 <openlog@plt>
mov    (%rbx),%ebx
xor    %eax,%eax
call   1050 <getuid@plt>
lea    0xe56(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <syslog@plt>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
lea    0xe56(%rip),%rsi
xor    %eax,%eax
call   1070 <syslog@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@LOG_NOTICE = 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
@.str.1 = [27 x i8] c"Program started by User %d\00"
@LOG_INFO = global i32 0
@.str.2 = [25 x i8] c"A tree falls in a forest\00"
define i32 @main() {
%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 ([12 x i8], [12 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 (i32, i8*, ...) @syslog(i32 %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 (...) @closelog()
ret i32 0
}

LLVM IR (-O2):
@LOG_NOTICE = 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
@.str.1 = [27 x i8] c"Program started by User %d\00"
@LOG_INFO = global i32 0
@.str.2 = [25 x i8] c"A tree falls in a forest\00"
define i32 @main() {
%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 ([12 x i8], [12 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 (i32, i8*, ...) @syslog(i32 %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 (...) @closelog()
ret i32 0
}