#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*/ FILE;

/* Variables and functions */
int fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *stderr;
int vsprintf(char *, char const *, int /*<<< orphan*/);
signed int vfprintf(FILE *pStream, const char *pFormat, va_list ap) {
  char pStr[100];
  char pError[] = "stdio.c: increase MAX_STRING_SIZE\n\r";
  if (vsprintf(pStr, pFormat, ap) >= 100) {
    fputs(pError, stderr);
    while (1)
      ;
  }
  return fputs(pStr, pStream);
}


x86 assembly (clang, -O0):
<vfprintf>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0xeac(%rip),%rsi
mov    $0x24,%edx
call   1040 <memcpy@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <vsprintf@plt>
cmp    $0x64,%eax
jl     1192 <vfprintf+0x62>
lea    -0xb0(%rbp),%rdi
mov    0x2e5b(%rip),%rax
mov    (%rax),%rsi
call   1030 <fputs@plt>
jmp    118d <vfprintf+0x5d>
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <fputs@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vfprintf>:
push   %rbx
sub    $0xa0,%rsp
mov    %rdi,%rbx
movaps 0xede(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xec2(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0xd0a45,0x20(%rsp)
lea    0x30(%rsp),%rdi
call   1040 <vsprintf@plt>
cmp    $0x64,%eax
jl     1172 <vfprintf+0x52>
mov    0x2e80(%rip),%rax
mov    (%rax),%rsi
mov    %rsp,%rdi
call   1030 <fputs@plt>
nopl   0x0(%rax,%rax,1)
jmp    1170 <vfprintf+0x50>
lea    0x30(%rsp),%rdi
mov    %rbx,%rsi
call   1030 <fputs@plt>
add    $0xa0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.vfprintf.pError = [36 x i8] c"stdio.c: increase MAX_STRING_SIZE\0A\0D\00"
@stderr = global i32* null
define i32 @vfprintf(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [100 x i8]
%8 = alloca [36 x i8]
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = bitcast [36 x i8]* %8 to i8*
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%11 = load i8*, i8** %5
%12 = load i32, i32* %6
%13 = call i32 @vsprintf(i8* %10, i8* %11, i32 %12)
%14 = icmp sge i32 %13, 100
br i1 %14, label %15, label %20
15: ; preds = %3
%16 = getelementptr inbounds [36 x i8], [36 x i8]* %8, i64 0, i64 0
%17 = load i32*, i32** @stderr
%18 = call i32 @fputs(i8* %16, i32* %17)
br label %19
19: ; preds = %15, %19
br label %19
20: ; preds = %3
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%22 = load i32*, i32** %4
%23 = call i32 @fputs(i8* %21, i32* %22)
ret i32 %23
}

LLVM IR (-O2):
@__const.vfprintf.pError = [36 x i8] c"stdio.c: increase MAX_STRING_SIZE\0A\0D\00"
@stderr = global i32* null
define i32 @vfprintf(i32* nocapture %0, i8* nocapture %1, i32 %2) {
%4 = alloca [100 x i8]
%5 = alloca [36 x i8]
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [36 x i8], [36 x i8]* %5, i64 0, i64 0
%8 = call i32 @vsprintf(i8* %6, i8* %1, i32 %2)
%9 = icmp sgt i32 %8, 99
br i1 %9, label %10, label %14
10: ; preds = %3
%11 = load i32*, i32** @stderr
%12 = call i32 @fputs(i8* %7, i32* %11)
br label %13
13: ; preds = %13, %10
br label %13
14: ; preds = %3
%15 = call i32 @fputs(i8* %6, i32* %0)
ret i32 %15
}