#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_ERR;
int /*<<< orphan*/ LOG_PID;
int LOG_SYSLOG;
int /*<<< orphan*/ getpid();
int /*<<< orphan*/ openlog(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ syslog(int, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  printf("this is a syslog demo\n");
  openlog("uplookingd", LOG_PID, LOG_SYSLOG);
  syslog(LOG_ERR | LOG_SYSLOG, "this is from uplookingd, pid = %d\n", getpid());
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e77(%rip),%rax
mov    (%rax),%esi
mov    0x2e66(%rip),%rax
mov    (%rax),%edx
lea    0xe9c(%rip),%rdi
call   1060 <openlog@plt>
mov    0x2e41(%rip),%rax
mov    (%rax),%eax
mov    0x2e48(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x14(%rbp),%edi
mov    %eax,%edx
lea    0xe7a(%rip),%rsi
call   1050 <syslog@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e8c(%rip),%rax
mov    (%rax),%esi
mov    0x2e7b(%rip),%rbx
mov    (%rbx),%edx
lea    0xe9a(%rip),%rdi
call   1060 <openlog@plt>
mov    0x2e56(%rip),%rax
mov    (%rbx),%ebx
or     (%rax),%ebx
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe87(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
call   1050 <syslog@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"this is a syslog demo\0A\00"
@.str.1 = [11 x i8] c"uplookingd\00"
@LOG_PID = global i32 0
@LOG_SYSLOG = global i32 0
@LOG_ERR = global i32 0
@.str.2 = [35 x i8] c"this is from uplookingd, pid = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @LOG_PID
%8 = load i32, i32* @LOG_SYSLOG
%9 = call i32 @openlog(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %7, i32 %8)
%10 = load i32, i32* @LOG_ERR
%11 = load i32, i32* @LOG_SYSLOG
%12 = or i32 %10, %11
%13 = call i32 (...) @getpid()
%14 = call i32 @syslog(i32 %12, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %13)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"uplookingd\00"
@LOG_PID = global i32 0
@LOG_SYSLOG = global i32 0
@LOG_ERR = global i32 0
@.str.2 = [35 x i8] c"this is from uplookingd, pid = %d\0A\00"
@str = [22 x i8] c"this is a syslog demo\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%4 = load i32, i32* @LOG_PID
%5 = load i32, i32* @LOG_SYSLOG
%6 = tail call i32 @openlog(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %5)
%7 = load i32, i32* @LOG_ERR
%8 = load i32, i32* @LOG_SYSLOG
%9 = or i32 %8, %7
%10 = tail call i32 (...) @getpid()
%11 = tail call i32 @syslog(i32 %9, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %10)
ret i32 0
}