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

/* Variables and functions */
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
long BIO_make_bio_pair(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ BIO_s_bio();
long BIO_set_write_buf_size(int /*<<< orphan*/ *, size_t);
int BIO_new_bio_pair(BIO **bio1_p, size_t writebuf1, BIO **bio2_p,
                     size_t writebuf2) {
  BIO *bio1 = NULL, *bio2 = NULL;
  long r;
  int ret = 0;
  bio1 = BIO_new(BIO_s_bio());
  if (bio1 == NULL)
    goto err;
  bio2 = BIO_new(BIO_s_bio());
  if (bio2 == NULL)
    goto err;
  if (writebuf1) {
    r = BIO_set_write_buf_size(bio1, writebuf1);
    if (!r)
      goto err;
  }
  if (writebuf2) {
    r = BIO_set_write_buf_size(bio2, writebuf2);
    if (!r)
      goto err;
  }
  r = BIO_make_bio_pair(bio1, bio2);
  if (!r)
    goto err;
  ret = 1;
err:
  if (ret == 0) {
    BIO_free(bio1);
    bio1 = NULL;
    BIO_free(bio2);
    bio2 = NULL;
  }
  *bio1_p = bio1;
  *bio2_p = bio2;
  return ret;
}


x86 assembly (clang, -O0):
<BIO_new_bio_pair>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    $0x0,%al
call   1070 <BIO_s_bio@plt>
mov    %eax,%edi
call   1040 <BIO_new@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a1 <BIO_new_bio_pair+0x51>
jmp    124d <BIO_new_bio_pair+0xfd>
mov    $0x0,%al
call   1070 <BIO_s_bio@plt>
mov    %eax,%edi
call   1040 <BIO_new@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11c3 <BIO_new_bio_pair+0x73>
jmp    124d <BIO_new_bio_pair+0xfd>
cmpq   $0x0,-0x10(%rbp)
je     11f4 <BIO_new_bio_pair+0xa4>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <BIO_set_write_buf_size@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    11ef <BIO_new_bio_pair+0x9f>
jmp    124d <BIO_new_bio_pair+0xfd>
jmp    11f4 <BIO_new_bio_pair+0xa4>
cmpq   $0x0,-0x20(%rbp)
je     1225 <BIO_new_bio_pair+0xd5>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <BIO_set_write_buf_size@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1220 <BIO_new_bio_pair+0xd0>
jmp    124d <BIO_new_bio_pair+0xfd>
jmp    1225 <BIO_new_bio_pair+0xd5>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1060 <BIO_make_bio_pair@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1246 <BIO_new_bio_pair+0xf6>
jmp    124d <BIO_new_bio_pair+0xfd>
movl   $0x1,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    1279 <BIO_new_bio_pair+0x129>
mov    -0x28(%rbp),%rdi
call   1050 <BIO_free@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <BIO_free@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x28(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x3c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BIO_new_bio_pair>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
xor    %eax,%eax
call   1070 <BIO_s_bio@plt>
mov    %eax,%edi
call   1040 <BIO_new@plt>
mov    %rax,%r13
test   %rax,%rax
je     11d4 <BIO_new_bio_pair+0x84>
xor    %eax,%eax
call   1070 <BIO_s_bio@plt>
mov    %eax,%edi
call   1040 <BIO_new@plt>
test   %rax,%rax
je     11d4 <BIO_new_bio_pair+0x84>
mov    %rax,%rbx
test   %r14,%r14
je     11a8 <BIO_new_bio_pair+0x58>
mov    %r13,%rdi
mov    %r14,%rsi
call   1030 <BIO_set_write_buf_size@plt>
test   %rax,%rax
je     11d6 <BIO_new_bio_pair+0x86>
test   %rbp,%rbp
je     11bd <BIO_new_bio_pair+0x6d>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1030 <BIO_set_write_buf_size@plt>
test   %rax,%rax
je     11d6 <BIO_new_bio_pair+0x86>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1060 <BIO_make_bio_pair@plt>
test   %rax,%rax
je     11d6 <BIO_new_bio_pair+0x86>
mov    $0x1,%eax
jmp    11ed <BIO_new_bio_pair+0x9d>
xor    %ebx,%ebx
mov    %r13,%rdi
call   1050 <BIO_free@plt>
mov    %rbx,%rdi
call   1050 <BIO_free@plt>
xor    %r13d,%r13d
xor    %ebx,%ebx
xor    %eax,%eax
mov    %r13,(%r12)
mov    %rbx,(%r15)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @BIO_new_bio_pair(i32** %0, i64 %1, i32** %2, i64 %3) {
%5 = alloca i32**
%6 = alloca i64
%7 = alloca i32**
%8 = alloca i64
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i64
%12 = alloca i32
store i32** %0, i32*** %5
store i64 %1, i64* %6
store i32** %2, i32*** %7
store i64 %3, i64* %8
store i32* null, i32** %9
store i32* null, i32** %10
store i32 0, i32* %12
%13 = call i32 (...) @BIO_s_bio()
%14 = call i32* @BIO_new(i32 %13)
store i32* %14, i32** %9
%15 = load i32*, i32** %9
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %18
17: ; preds = %4
br label %54
18: ; preds = %4
%19 = call i32 (...) @BIO_s_bio()
%20 = call i32* @BIO_new(i32 %19)
store i32* %20, i32** %10
%21 = load i32*, i32** %10
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %24
23: ; preds = %18
br label %54
24: ; preds = %18
%25 = load i64, i64* %6
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %35
27: ; preds = %24
%28 = load i32*, i32** %9
%29 = load i64, i64* %6
%30 = call i64 @BIO_set_write_buf_size(i32* %28, i64 %29)
store i64 %30, i64* %11
%31 = load i64, i64* %11
%32 = icmp ne i64 %31, 0
br i1 %32, label %34, label %33
33: ; preds = %27
br label %54
34: ; preds = %27
br label %35
35: ; preds = %34, %24
%36 = load i64, i64* %8
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %46
38: ; preds = %35
%39 = load i32*, i32** %10
%40 = load i64, i64* %8
%41 = call i64 @BIO_set_write_buf_size(i32* %39, i64 %40)
store i64 %41, i64* %11
%42 = load i64, i64* %11
%43 = icmp ne i64 %42, 0
br i1 %43, label %45, label %44
44: ; preds = %38
br label %54
45: ; preds = %38
br label %46
46: ; preds = %45, %35
%47 = load i32*, i32** %9
%48 = load i32*, i32** %10
%49 = call i64 @BIO_make_bio_pair(i32* %47, i32* %48)
store i64 %49, i64* %11
%50 = load i64, i64* %11
%51 = icmp ne i64 %50, 0
br i1 %51, label %53, label %52
52: ; preds = %46
br label %54
53: ; preds = %46
store i32 1, i32* %12
br label %54
54: ; preds = %53, %52, %44, %33, %23, %17
%55 = load i32, i32* %12
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %62
57: ; preds = %54
%58 = load i32*, i32** %9
%59 = call i32 @BIO_free(i32* %58)
store i32* null, i32** %9
%60 = load i32*, i32** %10
%61 = call i32 @BIO_free(i32* %60)
store i32* null, i32** %10
br label %62
62: ; preds = %57, %54
%63 = load i32*, i32** %9
%64 = load i32**, i32*** %5
store i32* %63, i32** %64
%65 = load i32*, i32** %10
%66 = load i32**, i32*** %7
store i32* %65, i32** %66
%67 = load i32, i32* %12
ret i32 %67
}

LLVM IR (-O2):
define i32 @BIO_new_bio_pair(i32** nocapture writeonly %0, i64 %1, i32** nocapture writeonly %2, i64 %3) {
%5 = tail call i32 (...) @BIO_s_bio()
%6 = tail call i32* @BIO_new(i32 %5)
%7 = icmp eq i32* %6, null
br i1 %7, label %25, label %8
8: ; preds = %4
%9 = tail call i32 (...) @BIO_s_bio()
%10 = tail call i32* @BIO_new(i32 %9)
%11 = icmp eq i32* %10, null
br i1 %11, label %25, label %12
12: ; preds = %8
%13 = icmp eq i64 %1, 0
br i1 %13, label %17, label %14
14: ; preds = %12
%15 = tail call i64 @BIO_set_write_buf_size(i32* %6, i64 %1)
%16 = icmp eq i64 %15, 0
br i1 %16, label %25, label %17
17: ; preds = %14, %12
%18 = icmp eq i64 %3, 0
br i1 %18, label %22, label %19
19: ; preds = %17
%20 = tail call i64 @BIO_set_write_buf_size(i32* %10, i64 %3)
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %17, %19
%23 = tail call i64 @BIO_make_bio_pair(i32* %6, i32* %10)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %14, %19, %8, %4, %22
%26 = phi i32* [ %10, %22 ], [ %10, %14 ], [ %10, %19 ], [ null, %8 ], [ null, %4 ]
%27 = tail call i32 @BIO_free(i32* %6)
%28 = tail call i32 @BIO_free(i32* %26)
br label %29
29: ; preds = %25, %22
%30 = phi i32 [ 0, %25 ], [ 1, %22 ]
%31 = phi i32* [ null, %25 ], [ %6, %22 ]
%32 = phi i32* [ null, %25 ], [ %10, %22 ]
store i32* %31, i32** %0
store i32* %32, i32** %2
ret i32 %30
}