#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*/ LOG_ERR;
char *create_buffer(int, char const *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ vsyslog(int /*<<< orphan*/, char const *,
                           int /*<<< orphan*/);
void vlog_err(int mode, const char *msg, va_list az) {
  int err_type, exit_code;
  exit_code = (mode >> 2);
  err_type = (mode & 0x3);
  ;
  if (err_type) {
    char *buffer;
    buffer = create_buffer(err_type, msg);
    vsyslog(LOG_ERR, buffer, az);
    free(buffer);
  } else {
    vsyslog(LOG_ERR, msg, az);
  }
  exit(exit_code);
  return;
}


x86 assembly (clang, -O0):
<vlog_err>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x4(%rbp),%eax
and    $0x3,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11a1 <vlog_err+0x61>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <create_buffer@plt>
mov    %rax,-0x28(%rbp)
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <vsyslog@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
jmp    11b6 <vlog_err+0x76>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <vsyslog@plt>
mov    -0x1c(%rbp),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<vlog_err>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %edi,%ebx
and    $0x3,%edi
jne    1161 <vlog_err+0x21>
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
mov    %r14d,%edx
call   1050 <vsyslog@plt>
jmp    1185 <vlog_err+0x45>
call   1040 <create_buffer@plt>
mov    %rax,%rbp
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1050 <vsyslog@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
sar    $0x2,%ebx
mov    %ebx,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@LOG_ERR = global i32 0
define void @vlog_err(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%10 = load i32, i32* %4
%11 = ashr i32 %10, 2
store i32 %11, i32* %8
%12 = load i32, i32* %4
%13 = and i32 %12, 3
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %3
%17 = load i32, i32* %7
%18 = load i8*, i8** %5
%19 = call i8* @create_buffer(i32 %17, i8* %18)
store i8* %19, i8** %9
%20 = load i32, i32* @LOG_ERR
%21 = load i8*, i8** %9
%22 = load i32, i32* %6
%23 = call i32 @vsyslog(i32 %20, i8* %21, i32 %22)
%24 = load i8*, i8** %9
%25 = call i32 @free(i8* %24)
br label %31
26: ; preds = %3
%27 = load i32, i32* @LOG_ERR
%28 = load i8*, i8** %5
%29 = load i32, i32* %6
%30 = call i32 @vsyslog(i32 %27, i8* %28, i32 %29)
br label %31
31: ; preds = %26, %16
%32 = load i32, i32* %8
%33 = call i32 @exit(i32 %32)
unreachable
}

LLVM IR (-O2):
@LOG_ERR = global i32 0
define void @vlog_err(i32 %0, i8* %1, i32 %2) {
%4 = and i32 %0, 3
%5 = icmp eq i32 %4, 0
br i1 %5, label %11, label %6
6: ; preds = %3
%7 = tail call i8* @create_buffer(i32 %4, i8* %1)
%8 = load i32, i32* @LOG_ERR
%9 = tail call i32 @vsyslog(i32 %8, i8* %7, i32 %2)
%10 = tail call i32 @free(i8* %7)
br label %14
11: ; preds = %3
%12 = load i32, i32* @LOG_ERR
%13 = tail call i32 @vsyslog(i32 %12, i8* %1, i32 %2)
br label %14
14: ; preds = %11, %6
%15 = ashr i32 %0, 2
%16 = tail call i32 @exit(i32 %15)
unreachable
}