#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 /*<<< orphan*/ LOG_CONS;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ LOG_INFO;
int /*<<< orphan*/ LOG_USER;
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ openlog(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *);
int main() {
  openlog("just for test", LOG_CONS, LOG_USER);
  syslog(LOG_ERR, "how to use syslog");
  syslog(LOG_INFO, "THIS IS INFO MESSAGE");
  closelog();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%esi
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
lea    0xea8(%rip),%rdi
call   1050 <openlog@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    0xea1(%rip),%rsi
call   1040 <syslog@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    0xe9e(%rip),%rsi
call   1040 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
mov    0x2ea7(%rip),%rax
mov    (%rax),%edx
lea    0xeb6(%rip),%rdi
call   1050 <openlog@plt>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
lea    0xeaf(%rip),%rsi
call   1040 <syslog@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
lea    0xeac(%rip),%rsi
call   1040 <syslog@plt>
xor    %eax,%eax
call   1030 <closelog@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"just for test\00"
@LOG_CONS = global i32 0
@LOG_USER = global i32 0
@LOG_ERR = global i32 0
@.str.1 = [18 x i8] c"how to use syslog\00"
@LOG_INFO = global i32 0
@.str.2 = [21 x i8] c"THIS IS INFO MESSAGE\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = load i32, i32* @LOG_CONS
%3 = load i32, i32* @LOG_USER
%4 = call i32 @openlog(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %3)
%5 = load i32, i32* @LOG_ERR
%6 = call i32 @syslog(i32 %5, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32, i32* @LOG_INFO
%8 = call i32 @syslog(i32 %7, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 (...) @closelog()
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"just for test\00"
@LOG_CONS = global i32 0
@LOG_USER = global i32 0
@LOG_ERR = global i32 0
@.str.1 = [18 x i8] c"how to use syslog\00"
@LOG_INFO = global i32 0
@.str.2 = [21 x i8] c"THIS IS INFO MESSAGE\00"
define i32 @main() {
%1 = load i32, i32* @LOG_CONS
%2 = load i32, i32* @LOG_USER
%3 = tail call i32 @openlog(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2)
%4 = load i32, i32* @LOG_ERR
%5 = tail call i32 @syslog(i32 %4, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%6 = load i32, i32* @LOG_INFO
%7 = tail call i32 @syslog(i32 %6, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 (...) @closelog()
ret i32 0
}