#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*/ X509_REQ;
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_NOCLOSE;
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ BIO_s_file();
int /*<<< orphan*/ BIO_set_fp(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                              int /*<<< orphan*/);
int /*<<< orphan*/ ERR_R_BUF_LIB;
int X509_REQ_print(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ X509error(int /*<<< orphan*/);
int X509_REQ_print_fp(FILE *fp, X509_REQ *x) {
  BIO *b;
  int ret;
  if ((b = BIO_new(BIO_s_file())) == NULL) {
    X509error(ERR_R_BUF_LIB);
    return (0);
  }
  BIO_set_fp(b, fp, BIO_NOCLOSE);
  ret = X509_REQ_print(b, x);
  BIO_free(b);
  return (ret);
}


x86 assembly (clang, -O0):
<X509_REQ_print_fp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x0,%al
call   1080 <BIO_s_file@plt>
mov    %eax,%edi
call   1040 <BIO_new@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11a6 <X509_REQ_print_fp+0x46>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
call   1030 <X509error@plt>
movl   $0x0,-0x4(%rbp)
jmp    11db <X509_REQ_print_fp+0x7b>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e2b(%rip),%rax
mov    (%rax),%edx
call   1070 <BIO_set_fp@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <X509_REQ_print@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <BIO_free@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<X509_REQ_print_fp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %eax,%eax
call   1080 <BIO_s_file@plt>
mov    %eax,%edi
call   1040 <BIO_new@plt>
test   %rax,%rax
je     11b0 <X509_REQ_print_fp+0x50>
mov    %rax,%rbx
mov    0x2e56(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1070 <BIO_set_fp@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <X509_REQ_print@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <BIO_free@plt>
mov    %ebp,%eax
jmp    11c0 <X509_REQ_print_fp+0x60>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
call   1030 <X509error@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@ERR_R_BUF_LIB = global i32 0
@BIO_NOCLOSE = global i32 0
define i32 @X509_REQ_print_fp(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
%8 = call i32 (...) @BIO_s_file()
%9 = call i32* @BIO_new(i32 %8)
store i32* %9, i32** %6
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @ERR_R_BUF_LIB
%13 = call i32 @X509error(i32 %12)
store i32 0, i32* %3
br label %25
14: ; preds = %2
%15 = load i32*, i32** %6
%16 = load i32*, i32** %4
%17 = load i32, i32* @BIO_NOCLOSE
%18 = call i32 @BIO_set_fp(i32* %15, i32* %16, i32 %17)
%19 = load i32*, i32** %6
%20 = load i32*, i32** %5
%21 = call i32 @X509_REQ_print(i32* %19, i32* %20)
store i32 %21, i32* %7
%22 = load i32*, i32** %6
%23 = call i32 @BIO_free(i32* %22)
%24 = load i32, i32* %7
store i32 %24, i32* %3
br label %25
25: ; preds = %14, %11
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@ERR_R_BUF_LIB = global i32 0
@BIO_NOCLOSE = global i32 0
define i32 @X509_REQ_print_fp(i32* %0, i32* %1) {
%3 = tail call i32 (...) @BIO_s_file()
%4 = tail call i32* @BIO_new(i32 %3)
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @ERR_R_BUF_LIB
%8 = tail call i32 @X509error(i32 %7)
br label %14
9: ; preds = %2
%10 = load i32, i32* @BIO_NOCLOSE
%11 = tail call i32 @BIO_set_fp(i32* %4, i32* %0, i32 %10)
%12 = tail call i32 @X509_REQ_print(i32* %4, i32* %1)
%13 = tail call i32 @BIO_free(i32* %4)
br label %14
14: ; preds = %9, %6
%15 = phi i32 [ 0, %6 ], [ %12, %9 ]
ret i32 %15
}