#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 vsprintf(char *, char const *, int /*<<< orphan*/);
int writeStringToPrintfStream(char *);
signed int vprintf(const char *pFormat, va_list ap) {
  char pStr[(64)];
  char pError[] = "stdio.c: vprintf error\r\n";
  if (vsprintf(pStr, pFormat, ap) >= (64)) {
    writeStringToPrintfStream(pError);
    return 0;
  }
  return writeStringToPrintfStream(pStr);
}


x86 assembly (clang, -O0):
<vprintf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    0xec7(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xec4(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0xec1(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xebf(%rip),%al
mov    %al,-0x68(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <vsprintf@plt>
cmp    $0x40,%eax
jl     118a <vprintf+0x6a>
lea    -0x80(%rbp),%rdi
call   1030 <writeStringToPrintfStream@plt>
movl   $0x0,-0x4(%rbp)
jmp    1196 <vprintf+0x76>
lea    -0x60(%rbp),%rdi
call   1030 <writeStringToPrintfStream@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vprintf>:
sub    $0x68,%rsp
mov    %esi,%edx
mov    %rdi,%rsi
movups 0xed9(%rip),%xmm0
movups %xmm0,0x9(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x20(%rsp),%rdi
call   1040 <vsprintf@plt>
cmp    $0x40,%eax
jl     115e <vprintf+0x3e>
mov    %rsp,%rdi
call   1030 <writeStringToPrintfStream@plt>
xor    %eax,%eax
add    $0x68,%rsp
ret
lea    0x20(%rsp),%rdi
call   1030 <writeStringToPrintfStream@plt>
add    $0x68,%rsp
ret

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

LLVM IR (-O2):
@__const.vprintf.pError = [25 x i8] c"stdio.c: vprintf error\0D\0A\00"
define i32 @vprintf(i8* nocapture %0, i32 %1) {
%3 = alloca [64 x i8]
%4 = alloca [25 x i8]
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [25 x i8], [25 x i8]* %4, i64 0, i64 0
%7 = call i32 @vsprintf(i8* %5, i8* %0, i32 %1)
%8 = icmp sgt i32 %7, 63
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @writeStringToPrintfStream(i8* %6)
br label %13
11: ; preds = %2
%12 = call i32 @writeStringToPrintfStream(i8* %5)
br label %13
13: ; preds = %11, %9
%14 = phi i32 [ 0, %9 ], [ %12, %11 ]
ret i32 %14
}