#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*/ fflush(int /*<<< orphan*/);
scalar_t__ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int vsprintf(char *, char const *, int /*<<< orphan*/);
int sarvprintf_std_warning(const char *format, va_list args) {
  char tmp[2048] = {
      0,
  };
  int res = vsprintf(tmp, format, args);
  res = res && fprintf(stderr, "Warning: %s\n", tmp);
  fflush(stderr);
  return res;
}


x86 assembly (clang, -O0):
<sarvprintf_std_warning>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x810(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1030 <memset@plt>
lea    -0x810(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1060 <vsprintf@plt>
mov    %eax,-0x814(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x814(%rbp)
mov    %al,-0x815(%rbp)
je     11bc <sarvprintf_std_warning+0x7c>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
lea    -0x810(%rbp),%rdx
lea    0xe56(%rip),%rsi
call   1040 <fprintf@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x815(%rbp)
mov    -0x815(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x814(%rbp)
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    -0x814(%rbp),%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sarvprintf_std_warning>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %esi,%r14d
mov    %rdi,%rbp
mov    %rsp,%r15
xor    %ebx,%ebx
mov    $0x800,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1060 <vsprintf@plt>
test   %eax,%eax
je     1199 <sarvprintf_std_warning+0x59>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
mov    %rsp,%rdx
call   1040 <fprintf@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    %ebx,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [13 x i8] c"Warning: %s\0A\00"
define i32 @sarvprintf_std_warning(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [2048 x i8]
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = bitcast [2048 x i8]* %5 to i8*
%8 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%9 = load i8*, i8** %3
%10 = load i32, i32* %4
%11 = call i32 @vsprintf(i8* %8, i8* %9, i32 %10)
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%17 = call i64 @fprintf(i32 %15, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = icmp ne i64 %17, 0
br label %19
19: ; preds = %14, %2
%20 = phi i1 [ false, %2 ], [ %18, %14 ]
%21 = zext i1 %20 to i32
store i32 %21, i32* %6
%22 = load i32, i32* @stderr
%23 = call i32 @fflush(i32 %22)
%24 = load i32, i32* %6
ret i32 %24
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [13 x i8] c"Warning: %s\0A\00"
define i32 @sarvprintf_std_warning(i8* nocapture %0, i32 %1) {
%3 = alloca [2048 x i8]
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%5 = call i32 @vsprintf(i8* %4, i8* %0, i32 %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = call i64 @fprintf(i32 %8, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %4)
%10 = icmp ne i64 %9, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %7, %2
%13 = phi i32 [ 0, %2 ], [ %11, %7 ]
%14 = load i32, i32* @stderr
%15 = call i32 @fflush(i32 %14)
ret i32 %13
}