#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;
struct obstack {
  int dummy;
};
typedef int /*<<< orphan*/ f;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ bzero(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ init_obstream(int /*<<< orphan*/ *, struct obstack *);
int vfprintf(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/);
int obstack_vprintf(struct obstack *obstack, const char *format, va_list args) {
  int result;
  FILE f;
  bzero(&f, sizeof(f));
  init_obstream(&f, obstack);
  result = vfprintf(&f, format, args);
  if (result >= 0)
    fflush(&f);
  return result;
}


x86 assembly (clang, -O0):
<obstack_vprintf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0x1c(%rbp),%rdi
mov    $0x4,%esi
call   1050 <bzero@plt>
mov    -0x8(%rbp),%rsi
lea    -0x1c(%rbp),%rdi
call   1030 <init_obstream@plt>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    -0x1c(%rbp),%rdi
call   1060 <vfprintf@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     1194 <obstack_vprintf+0x54>
lea    -0x1c(%rbp),%rdi
call   1040 <fflush@plt>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<obstack_vprintf>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x4,%esi
call   1050 <bzero@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <init_obstream@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
call   1060 <vfprintf@plt>
mov    %eax,%ebx
test   %eax,%eax
js     118b <obstack_vprintf+0x4b>
lea    0x4(%rsp),%rdi
call   1040 <fflush@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.obstack = type { i32 }
define i32 @obstack_vprintf(%struct.obstack* %0, i8* %1, i32 %2) {
%4 = alloca %struct.obstack*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store %struct.obstack* %0, %struct.obstack** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = call i32 @bzero(i32* %8, i32 4)
%10 = load %struct.obstack*, %struct.obstack** %4
%11 = call i32 @init_obstream(i32* %8, %struct.obstack* %10)
%12 = load i8*, i8** %5
%13 = load i32, i32* %6
%14 = call i32 @vfprintf(i32* %8, i8* %12, i32 %13)
store i32 %14, i32* %7
%15 = load i32, i32* %7
%16 = icmp sge i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %3
%18 = call i32 @fflush(i32* %8)
br label %19
19: ; preds = %17, %3
%20 = load i32, i32* %7
ret i32 %20
}

LLVM IR (-O2):
%struct.obstack = type { i32 }
define i32 @obstack_vprintf(%struct.obstack* %0, i8* nocapture %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = call i32 @bzero(i32* %4, i32 4)
%7 = call i32 @init_obstream(i32* %4, %struct.obstack* %0)
%8 = call i32 @vfprintf(i32* %4, i8* %1, i32 %2)
%9 = icmp sgt i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = call i32 @fflush(i32* %4)
br label %12
12: ; preds = %10, %3
ret i32 %8
}