#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*/ free(char *);
int /*<<< orphan*/ vsnprintf(char *, size_t, char const *, int /*<<< orphan*/);
void vs_warn(char *buf, size_t bufsize, 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)vsnprintf(buf, bufsize, buffer, az);
    free(buffer);
  } else {
    (void)vsnprintf(buf, bufsize, msg, az);
  }
  return;
}


x86 assembly (clang, -O0):
<vs_warn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x14(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%eax
and    $0x3,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     1199 <vs_warn+0x69>
mov    -0x28(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1050 <create_buffer@plt>
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1040 <vsnprintf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
jmp    11ad <vs_warn+0x7d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1040 <vsnprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vs_warn>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
and    $0x3,%edx
je     1175 <vs_warn+0x45>
mov    %edx,%edi
mov    %rcx,%rsi
call   1050 <create_buffer@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
mov    %r14d,%ecx
call   1040 <vsnprintf@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %rcx,%rdx
mov    %r14d,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <vsnprintf@plt>

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

LLVM IR (-O2):
define void @vs_warn(i8* nocapture %0, i64 %1, i32 %2, i8* %3, i32 %4) {
%6 = and i32 %2, 3
%7 = icmp eq i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %5
%9 = tail call i8* @create_buffer(i32 %6, i8* %3)
%10 = tail call i32 @vsnprintf(i8* %0, i64 %1, i8* %9, i32 %4)
%11 = tail call i32 @free(i8* %9)
br label %14
12: ; preds = %5
%13 = tail call i32 @vsnprintf(i8* %0, i64 %1, i8* %3, i32 %4)
br label %14
14: ; preds = %12, %8
ret void
}