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

/* Variables and functions */
int _MLWriteLog(char *, int /*<<< orphan*/);
int snprintf(char *, int, char *, char, char const *, char const *);
int /*<<< orphan*/ strlen(char *);
int vsnprintf(char *, int, char *, int /*<<< orphan*/);
int _MLPrintVaLog(int priority, const char *tag, const char *fmt,
                  va_list args) {
  int result;
  char buf[(256)];
  char new_fmt[(256)];
  char priority_char;
  if (0 == fmt) {
    fmt = "";
  }
  switch (priority) {
  case (0):
    priority_char = 'U';
    break;
  case (2):
    priority_char = 'V';
    break;
  case (3):
    priority_char = 'D';
    break;
  case (4):
    priority_char = 'I';
    break;
  case (5):
    priority_char = 'W';
    break;
  case (6):
    priority_char = 'E';
    break;
  case (8):
    priority_char = 'S';
    break;
  case (1):
  default:
    priority_char = 'D';
    break;
  };
  result =
      snprintf(new_fmt, sizeof(new_fmt), "%c/%s:%s", priority_char, tag, fmt);
  if (result <= 0) {
    return (50);
  }
  result = vsnprintf(buf, sizeof(buf), new_fmt, args);
  if (result <= 0) {
    return (51);
  }
  result = _MLWriteLog(buf, strlen(buf));
  return (0);
}


x86 assembly (clang, -O0):
<_MLPrintVaLog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
jne    1170 <_MLPrintVaLog+0x30>
lea    0xec0(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x230(%rbp)
sub    $0x8,%rax
ja     11f4 <_MLPrintVaLog+0xb4>
mov    -0x230(%rbp),%rax
lea    0xe6e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x55,-0x221(%rbp)
jmp    11fb <_MLPrintVaLog+0xbb>
movb   $0x56,-0x221(%rbp)
jmp    11fb <_MLPrintVaLog+0xbb>
movb   $0x44,-0x221(%rbp)
jmp    11fb <_MLPrintVaLog+0xbb>
movb   $0x49,-0x221(%rbp)
jmp    11fb <_MLPrintVaLog+0xbb>
movb   $0x57,-0x221(%rbp)
jmp    11fb <_MLPrintVaLog+0xbb>
movb   $0x45,-0x221(%rbp)
jmp    11fb <_MLPrintVaLog+0xbb>
movb   $0x53,-0x221(%rbp)
jmp    11fb <_MLPrintVaLog+0xbb>
jmp    11f4 <_MLPrintVaLog+0xb4>
movb   $0x44,-0x221(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x221(%rbp),%al
mov    -0x10(%rbp),%r8
mov    -0x18(%rbp),%r9
mov    $0x100,%esi
lea    0xe08(%rip),%rdx
movsbl %al,%ecx
call   1060 <snprintf@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jg     123d <_MLPrintVaLog+0xfd>
movl   $0x32,-0x4(%rbp)
jmp    12a3 <_MLPrintVaLog+0x163>
lea    -0x120(%rbp),%rdi
lea    -0x220(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    $0x100,%esi
call   1040 <vsnprintf@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jg     1271 <_MLPrintVaLog+0x131>
movl   $0x33,-0x4(%rbp)
jmp    12a3 <_MLPrintVaLog+0x163>
lea    -0x120(%rbp),%rax
mov    %rax,-0x238(%rbp)
lea    -0x120(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x238(%rbp),%rdi
mov    %eax,%esi
call   1030 <_MLWriteLog@plt>
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_MLPrintVaLog>:
push   %rbx
sub    $0x200,%rsp
mov    %ecx,%ebx
mov    %rsi,%r8
test   %rdx,%rdx
lea    0xeb1(%rip),%r9
cmovne %rdx,%r9
mov    $0x44,%al
cmp    $0x8,%edi
ja     116f <_MLPrintVaLog+0x2f>
movslq %edi,%rax
lea    0xe9d(%rip),%rcx
mov    (%rax,%rcx,1),%al
movsbl %al,%ecx
lea    0xe87(%rip),%rdx
mov    %rsp,%rdi
mov    $0x100,%esi
call   1060 <snprintf@plt>
test   %eax,%eax
jle    11c3 <_MLPrintVaLog+0x83>
lea    0x100(%rsp),%rdi
mov    %rsp,%rdx
mov    $0x100,%esi
mov    %ebx,%ecx
call   1040 <vsnprintf@plt>
test   %eax,%eax
jle    11ca <_MLPrintVaLog+0x8a>
lea    0x100(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <_MLWriteLog@plt>
xor    %eax,%eax
jmp    11cf <_MLPrintVaLog+0x8f>
mov    $0x32,%eax
jmp    11cf <_MLPrintVaLog+0x8f>
mov    $0x33,%eax
add    $0x200,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [9 x i8] c"%c/%s:%s\00"
define i32 @_MLPrintVaLog(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca [256 x i8]
%12 = alloca [256 x i8]
%13 = alloca i8
store i32 %0, i32* %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%14 = load i8*, i8** %8
%15 = icmp eq i8* null, %14
br i1 %15, label %16, label %17
16: ; preds = %4
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %8
br label %17
17: ; preds = %16, %4
%18 = load i32, i32* %6
switch i32 %18, label %27 [
i32 0, label %19
i32 2, label %20
i32 3, label %21
i32 4, label %22
i32 5, label %23
i32 6, label %24
i32 8, label %25
i32 1, label %26
]
19: ; preds = %17
store i8 85, i8* %13
br label %28
20: ; preds = %17
store i8 86, i8* %13
br label %28
21: ; preds = %17
store i8 68, i8* %13
br label %28
22: ; preds = %17
store i8 73, i8* %13
br label %28
23: ; preds = %17
store i8 87, i8* %13
br label %28
24: ; preds = %17
store i8 69, i8* %13
br label %28
25: ; preds = %17
store i8 83, i8* %13
br label %28
26: ; preds = %17
br label %27
27: ; preds = %17, %26
store i8 68, i8* %13
br label %28
28: ; preds = %27, %25, %24, %23, %22, %21, %20, %19
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%30 = load i8, i8* %13
%31 = load i8*, i8** %7
%32 = load i8*, i8** %8
%33 = call i32 @snprintf(i8* %29, i32 256, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8 signext %30, i8* %31, i8* %32)
store i32 %33, i32* %10
%34 = load i32, i32* %10
%35 = icmp sle i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %28
store i32 50, i32* %5
br label %50
37: ; preds = %28
%38 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%40 = load i32, i32* %9
%41 = call i32 @vsnprintf(i8* %38, i32 256, i8* %39, i32 %40)
store i32 %41, i32* %10
%42 = load i32, i32* %10
%43 = icmp sle i32 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %37
store i32 51, i32* %5
br label %50
45: ; preds = %37
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%48 = call i32 @strlen(i8* %47)
%49 = call i32 @_MLWriteLog(i8* %46, i32 %48)
store i32 %49, i32* %10
store i32 0, i32* %5
br label %50
50: ; preds = %45, %44, %36
%51 = load i32, i32* %5
ret i32 %51
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [9 x i8] c"%c/%s:%s\00"
@switch.table._MLPrintVaLog = [9 x i8] c"UDVDIWEDS"
define i32 @_MLPrintVaLog(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca [256 x i8]
%6 = alloca [256 x i8]
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%9 = icmp eq i8* %2, null
%10 = select i1 %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8* %2
%11 = icmp ult i32 %0, 9
br i1 %11, label %12, label %16
12: ; preds = %4
%13 = sext i32 %0 to i64
%14 = getelementptr inbounds [9 x i8], [9 x i8]* @switch.table._MLPrintVaLog, i64 0, i64 %13
%15 = load i8, i8* %14
br label %16
16: ; preds = %4, %12
%17 = phi i8 [ %15, %12 ], [ 68, %4 ]
%18 = call i32 @snprintf(i8* %8, i32 256, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8 signext %17, i8* %1, i8* %10)
%19 = icmp slt i32 %18, 1
br i1 %19, label %26, label %20
20: ; preds = %16
%21 = call i32 @vsnprintf(i8* %7, i32 256, i8* %8, i32 %3)
%22 = icmp slt i32 %21, 1
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = call i32 @strlen(i8* %7)
%25 = call i32 @_MLWriteLog(i8* %7, i32 %24)
br label %26
26: ; preds = %20, %16, %23
%27 = phi i32 [ 0, %23 ], [ 50, %16 ], [ 51, %20 ]
ret i32 %27
}