#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 */
char *create_buffer(int, char const *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ vfprintf(int /*<<< orphan*/, char const *,
                            int /*<<< orphan*/);
void vstd_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);
    (void)vfprintf(stderr, buffer, az);
    free(buffer);
  } else {
    (void)vfprintf(stderr, msg, az);
  }
  (void)fprintf(stderr, "\n");
  exit(exit_code);
  return;
}


x86 assembly (clang, -O0):
<vstd_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     11b1 <vstd_err+0x61>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <create_buffer@plt>
mov    %rax,-0x28(%rbp)
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <vfprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
jmp    11c6 <vstd_err+0x76>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <vfprintf@plt>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
lea    0xe2a(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<vstd_err>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %edi,%ebx
and    $0x3,%edi
jne    1171 <vstd_err+0x21>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
mov    %r14d,%edx
call   1060 <vfprintf@plt>
jmp    1195 <vstd_err+0x45>
call   1050 <create_buffer@plt>
mov    %rax,%rbp
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1060 <vfprintf@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
sar    $0x2,%ebx
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xe58(%rip),%rsi
call   1040 <fprintf@plt>
mov    %ebx,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [2 x i8] c"\0A\00"
define void @vstd_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* @stderr
%21 = load i8*, i8** %9
%22 = load i32, i32* %6
%23 = call i32 @vfprintf(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* @stderr
%28 = load i8*, i8** %5
%29 = load i32, i32* %6
%30 = call i32 @vfprintf(i32 %27, i8* %28, i32 %29)
br label %31
31: ; preds = %26, %16
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%34 = load i32, i32* %8
%35 = call i32 @exit(i32 %34)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [2 x i8] c"\0A\00"
define void @vstd_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* @stderr
%9 = tail call i32 @vfprintf(i32 %8, i8* %7, i32 %2)
%10 = tail call i32 @free(i8* %7)
br label %14
11: ; preds = %3
%12 = load i32, i32* @stderr
%13 = tail call i32 @vfprintf(i32 %12, i8* %1, i32 %2)
br label %14
14: ; preds = %11, %6
%15 = ashr i32 %0, 2
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%18 = tail call i32 @exit(i32 %15)
unreachable
}