#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 */
typedef int /*<<< orphan*/ va_list;

/* Variables and functions */
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ msgheader();
int /*<<< orphan*/ print_priority(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ vfprintf(int /*<<< orphan*/, char const *,
                            int /*<<< orphan*/);
void vsyslog(int priority, const char *message, va_list ap) {
  msgheader();
  fputs("syslog(", stderr);
  print_priority(priority);
  fputs(", ", stderr);
  vfprintf(stderr, message, ap);
  fputs(")\n", stderr);
}


x86 assembly (clang, -O0):
<vsyslog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   1040 <msgheader@plt>
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
lea    0xe97(%rip),%rdi
call   1030 <fputs@plt>
mov    -0x4(%rbp),%edi
call   1050 <print_priority@plt>
mov    0x2e63(%rip),%rax
mov    (%rax),%esi
lea    0xe82(%rip),%rdi
call   1030 <fputs@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <vfprintf@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%esi
lea    0xe5b(%rip),%rdi
call   1030 <fputs@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vsyslog>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %edi,%ebp
xor    %eax,%eax
call   1040 <msgheader@plt>
mov    0x2e83(%rip),%rbx
mov    (%rbx),%esi
lea    0xe9a(%rip),%rdi
call   1030 <fputs@plt>
mov    %ebp,%edi
call   1050 <print_priority@plt>
mov    (%rbx),%esi
lea    0xe8d(%rip),%rdi
call   1030 <fputs@plt>
mov    (%rbx),%edi
mov    %r15,%rsi
mov    %r14d,%edx
call   1060 <vfprintf@plt>
mov    (%rbx),%esi
lea    0xe75(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fputs@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"syslog(\00"
@stderr = global i32 0
@.str.1 = [3 x i8] c", \00"
@.str.2 = [3 x i8] c")\0A\00"
define void @vsyslog(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%7 = call i32 (...) @msgheader()
%8 = load i32, i32* @stderr
%9 = call i32 @fputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %4
%11 = call i32 @print_priority(i32 %10)
%12 = load i32, i32* @stderr
%13 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %5
%16 = load i32, i32* %6
%17 = call i32 @vfprintf(i32 %14, i8* %15, i32 %16)
%18 = load i32, i32* @stderr
%19 = call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %18)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"syslog(\00"
@stderr = global i32 0
@.str.1 = [3 x i8] c", \00"
@.str.2 = [3 x i8] c")\0A\00"
define void @vsyslog(i32 %0, i8* %1, i32 %2) {
%4 = tail call i32 (...) @msgheader()
%5 = load i32, i32* @stderr
%6 = tail call i32 @fputs(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @print_priority(i32 %0)
%8 = load i32, i32* @stderr
%9 = tail call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = load i32, i32* @stderr
%11 = tail call i32 @vfprintf(i32 %10, i8* %1, i32 %2)
%12 = load i32, i32* @stderr
%13 = tail call i32 @fputs(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %12)
ret void
}