#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_ERR;
int /*<<< orphan*/ LOG_INFO;
int LOG_NDELAY;
int LOG_PID;
int /*<<< orphan*/ LOG_USER;
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ getuid();
int /*<<< orphan*/ openlog(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
int main() {
  openlog("syslog-example", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER);
  syslog(LOG_INFO, "syslog-example started by user: %d", getuid());
  syslog(LOG_ERR, "an error occured!");
  closelog();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
mov    0x2e79(%rip),%rax
or     (%rax),%esi
mov    0x2e50(%rip),%rax
or     (%rax),%esi
mov    0x2e77(%rip),%rax
mov    (%rax),%edx
lea    0xe86(%rip),%rdi
call   1060 <openlog@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1040 <getuid@plt>
mov    -0x8(%rbp),%edi
mov    %eax,%edx
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1050 <syslog@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
lea    0xe7d(%rip),%rsi
mov    $0x0,%al
call   1050 <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    0x2e88(%rip),%rax
mov    0x2e89(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e5e(%rip),%rax
or     (%rax),%esi
mov    0x2e85(%rip),%rax
mov    (%rax),%edx
lea    0xe94(%rip),%rdi
call   1060 <openlog@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1040 <getuid@plt>
lea    0xe87(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <syslog@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
lea    0xe8f(%rip),%rsi
xor    %eax,%eax
call   1050 <syslog@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"syslog-example\00"
@LOG_CONS = global i32 0
@LOG_PID = global i32 0
@LOG_NDELAY = global i32 0
@LOG_USER = global i32 0
@LOG_INFO = global i32 0
@.str.1 = [35 x i8] c"syslog-example started by user: %d\00"
@LOG_ERR = global i32 0
@.str.2 = [18 x i8] c"an error occured!\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = load i32, i32* @LOG_CONS
%3 = load i32, i32* @LOG_PID
%4 = or i32 %2, %3
%5 = load i32, i32* @LOG_NDELAY
%6 = or i32 %4, %5
%7 = load i32, i32* @LOG_USER
%8 = call i32 @openlog(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
%9 = load i32, i32* @LOG_INFO
%10 = call i32 (...) @getuid()
%11 = call i32 (i32, i8*, ...) @syslog(i32 %9, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = load i32, i32* @LOG_ERR
%13 = call i32 (i32, i8*, ...) @syslog(i32 %12, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 (...) @closelog()
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"syslog-example\00"
@LOG_CONS = global i32 0
@LOG_PID = global i32 0
@LOG_NDELAY = global i32 0
@LOG_USER = global i32 0
@LOG_INFO = global i32 0
@.str.1 = [35 x i8] c"syslog-example started by user: %d\00"
@LOG_ERR = global i32 0
@.str.2 = [18 x i8] c"an error occured!\00"
define i32 @main() {
%1 = load i32, i32* @LOG_CONS
%2 = load i32, i32* @LOG_PID
%3 = or i32 %2, %1
%4 = load i32, i32* @LOG_NDELAY
%5 = or i32 %3, %4
%6 = load i32, i32* @LOG_USER
%7 = tail call i32 @openlog(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %6)
%8 = load i32, i32* @LOG_INFO
%9 = tail call i32 (...) @getuid()
%10 = tail call i32 (i32, i8*, ...) @syslog(i32 %8, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = load i32, i32* @LOG_ERR
%12 = tail call i32 (i32, i8*, ...) @syslog(i32 %11, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 (...) @closelog()
ret i32 0
}