#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 /*<<< orphan*/ puts(char const *);
int vsprintf(char *, char const *, int /*<<< orphan*/);
signed int vfprintf(FILE *pStream, const char *pFormat, va_list ap) {
  char pStr[128];
  const char pError[] = "stdio.c: increase MAX_PRINTF_STRING_SIZE\n";
  (void)pStream;
  if (vsprintf(pStr, pFormat, ap) >= 128) {
    puts(pError);
    while (1) {
    }
  }
  puts(pStr);
  return (0);
}


x86 assembly (clang, -O0):
<vfprintf>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0xd0(%rbp),%rdi
lea    0xeac(%rip),%rsi
mov    $0x2a,%edx
call   1040 <memcpy@plt>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1050 <vsprintf@plt>
cmp    $0x80,%eax
jl     118d <vfprintf+0x5d>
lea    -0xd0(%rbp),%rdi
call   1030 <puts@plt>
jmp    1188 <vfprintf+0x58>
lea    -0xa0(%rbp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vfprintf>:
sub    $0xb8,%rsp
movups 0xeec(%rip),%xmm0
movups %xmm0,0x1a(%rsp)
movaps 0xed6(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeba(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x30(%rsp),%rdi
call   1040 <vsprintf@plt>
cmp    $0x80,%eax
jl     1172 <vfprintf+0x52>
mov    %rsp,%rdi
call   1030 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
jmp    1170 <vfprintf+0x50>
lea    0x30(%rsp),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xb8,%rsp
ret

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

LLVM IR (-O2):
@__const.vfprintf.pError = [42 x i8] c"stdio.c: increase MAX_PRINTF_STRING_SIZE\0A\00"
define i32 @vfprintf(i32* nocapture readnone %0, i8* nocapture %1, i32 %2) {
%4 = alloca [128 x i8]
%5 = alloca [42 x i8]
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [42 x i8], [42 x i8]* %5, i64 0, i64 0
%8 = call i32 @vsprintf(i8* %6, i8* %1, i32 %2)
%9 = icmp sgt i32 %8, 127
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = call i32 @puts(i8* %7)
br label %12
12: ; preds = %12, %10
br label %12
13: ; preds = %3
%14 = call i32 @puts(i8* %6)
ret i32 0
}