#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_INFO;
int /*<<< orphan*/ LOG_PID;
int /*<<< orphan*/ LOG_USER;
int /*<<< orphan*/ closelog();
int /*<<< orphan*/ openlog(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, char *);
void testlog(char *argv[]) {
  char *str = "test";
  openlog(argv[0], LOG_PID, LOG_USER);
  printf("1. sudo vim /etc/rsyslog.d/50-default.conf uncommet `user.*'\n");
  printf("2. sudo service rsyslog restart\n");
  printf("3. run this and log will write to /var/log/user.log\n");
  syslog(LOG_INFO, "%s\n", str);
  closelog();
}


x86 assembly (clang, -O0):
<testlog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xead(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    0x2e73(%rip),%rax
mov    (%rax),%esi
mov    0x2e7a(%rip),%rax
mov    (%rax),%edx
call   1060 <openlog@plt>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
call   1040 <printf@plt>
lea    0xed0(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xeec(%rip),%rsi
call   1050 <syslog@plt>
mov    $0x0,%al
call   1030 <closelog@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testlog>:
push   %rax
mov    (%rdi),%rdi
mov    0x2e8d(%rip),%rax
mov    (%rax),%esi
mov    0x2e94(%rip),%rax
mov    (%rax),%edx
call   1060 <openlog@plt>
lea    0xea7(%rip),%rdi
call   1040 <puts@plt>
lea    0xed8(%rip),%rdi
call   1040 <puts@plt>
lea    0xeec(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
lea    0xe76(%rip),%rsi
lea    0xe6a(%rip),%rdx
call   1050 <syslog@plt>
xor    %eax,%eax
pop    %rcx
jmp    1030 <closelog@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"test\00"
@LOG_PID = global i32 0
@LOG_USER = global i32 0
@.str.1 = [62 x i8] c"1. sudo vim /etc/rsyslog.d/50-default.conf uncommet `user.*'\0A\00"
@.str.2 = [33 x i8] c"2. sudo service rsyslog restart\0A\00"
@.str.3 = [53 x i8] c"3. run this and log will write to /var/log/user.log\0A\00"
@LOG_INFO = global i32 0
@.str.4 = [4 x i8] c"%s\0A\00"
define void @testlog(i8** %0) {
%2 = alloca i8**
%3 = alloca i8*
store i8** %0, i8*** %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %3
%4 = load i8**, i8*** %2
%5 = getelementptr inbounds i8*, i8** %4, i64 0
%6 = load i8*, i8** %5
%7 = load i32, i32* @LOG_PID
%8 = load i32, i32* @LOG_USER
%9 = call i32 @openlog(i8* %6, i32 %7, i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.3, i64 0, i64 0))
%13 = load i32, i32* @LOG_INFO
%14 = load i8*, i8** %3
%15 = call i32 @syslog(i32 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %14)
%16 = call i32 (...) @closelog()
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"test\00"
@LOG_PID = global i32 0
@LOG_USER = global i32 0
@LOG_INFO = global i32 0
@.str.4 = [4 x i8] c"%s\0A\00"
@str = [61 x i8] c"1. sudo vim /etc/rsyslog.d/50-default.conf uncommet `user.*'\00"
@str.5 = [32 x i8] c"2. sudo service rsyslog restart\00"
@str.6 = [52 x i8] c"3. run this and log will write to /var/log/user.log\00"
define void @testlog(i8** nocapture %0) {
%2 = load i8*, i8** %0
%3 = load i32, i32* @LOG_PID
%4 = load i32, i32* @LOG_USER
%5 = tail call i32 @openlog(i8* %2, i32 %3, i32 %4)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.5, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.6, i64 0, i64 0))
%9 = load i32, i32* @LOG_INFO
%10 = tail call i32 @syslog(i32 %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 (...) @closelog()
ret void
}