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

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ syslog(int, char *, char *);
int /*<<< orphan*/ vsnprintf(char *, int, char const *, int /*<<< orphan*/);
void syslog_vprintf(int mask, const char *fmt, va_list args) {
  char buf[640];
  int priority = ((mask)&0xFF);
  memset(buf, 0, sizeof(buf));
  vsnprintf(buf, sizeof(buf) - 1, fmt, args);
  syslog(priority, "%s", buf);
}


x86 assembly (clang, -O0):
<syslog_vprintf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2b0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x2a4(%rbp)
lea    -0x2a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x280,%edx
call   1040 <memset@plt>
lea    -0x2a0(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    $0x27f,%esi
call   1030 <vsnprintf@plt>
mov    -0x2a4(%rbp),%edi
lea    -0x2a0(%rbp),%rdx
lea    0xe6e(%rip),%rsi
call   1050 <syslog@plt>
add    $0x2b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<syslog_vprintf>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x288,%rsp
mov    %edx,%ebp
mov    %rsi,%rbx
movzbl %dil,%r14d
mov    %rsp,%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x280,%edx
call   1040 <memset@plt>
mov    %r15,%rdi
mov    $0x27f,%esi
mov    %rbx,%rdx
mov    %ebp,%ecx
call   1030 <vsnprintf@plt>
lea    0xe8f(%rip),%rsi
mov    %r14d,%edi
mov    %r15,%rdx
call   1050 <syslog@plt>
add    $0x288,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @syslog_vprintf(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [640 x i8]
%8 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i32, i32* %4
%10 = and i32 %9, 255
store i32 %10, i32* %8
%11 = getelementptr inbounds [640 x i8], [640 x i8]* %7, i64 0, i64 0
%12 = call i32 @memset(i8* %11, i32 0, i32 640)
%13 = getelementptr inbounds [640 x i8], [640 x i8]* %7, i64 0, i64 0
%14 = load i8*, i8** %5
%15 = load i32, i32* %6
%16 = call i32 @vsnprintf(i8* %13, i32 639, i8* %14, i32 %15)
%17 = load i32, i32* %8
%18 = getelementptr inbounds [640 x i8], [640 x i8]* %7, i64 0, i64 0
%19 = call i32 @syslog(i32 %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %18)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define void @syslog_vprintf(i32 %0, i8* nocapture %1, i32 %2) {
%4 = alloca [640 x i8]
%5 = getelementptr inbounds [640 x i8], [640 x i8]* %4, i64 0, i64 0
%6 = and i32 %0, 255
%7 = call i32 @memset(i8* %5, i32 0, i32 640)
%8 = call i32 @vsnprintf(i8* %5, i32 639, i8* %1, i32 %2)
%9 = call i32 @syslog(i32 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
ret void
}