#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_CRL;
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_CRL_print(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ X509_F_X509_CRL_PRINT_FP;
int /*<<< orphan*/ X509err(int /*<<< orphan*/, int /*<<< orphan*/);
int X509_CRL_print_fp(FILE *fp, X509_CRL *x) {
  BIO *b;
  int ret;
  if ((b = BIO_new(BIO_s_file())) == NULL) {
    X509err(X509_F_X509_CRL_PRINT_FP, ERR_R_BUF_LIB);
    return (0);
  }
  BIO_set_fp(b, fp, BIO_NOCLOSE);
  ret = X509_CRL_print(b, x);
  BIO_free(b);
  return (ret);
}


x86 assembly (clang, -O0):
<X509_CRL_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    11af <X509_CRL_print_fp+0x4f>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
call   1060 <X509err@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e4 <X509_CRL_print_fp+0x84>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e22(%rip),%rax
mov    (%rax),%edx
call   1070 <BIO_set_fp@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <X509_CRL_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_CRL_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_CRL_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   1030 <X509_CRL_print@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <BIO_free@plt>
mov    %ebp,%eax
jmp    11c9 <X509_CRL_print_fp+0x69>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
mov    0x2e38(%rip),%rax
mov    (%rax),%esi
call   1060 <X509err@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@X509_F_X509_CRL_PRINT_FP = global i32 0
@ERR_R_BUF_LIB = global i32 0
@BIO_NOCLOSE = global i32 0
define i32 @X509_CRL_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 %15
11: ; preds = %2
%12 = load i32, i32* @X509_F_X509_CRL_PRINT_FP
%13 = load i32, i32* @ERR_R_BUF_LIB
%14 = call i32 @X509err(i32 %12, i32 %13)
store i32 0, i32* %3
br label %26
15: ; preds = %2
%16 = load i32*, i32** %6
%17 = load i32*, i32** %4
%18 = load i32, i32* @BIO_NOCLOSE
%19 = call i32 @BIO_set_fp(i32* %16, i32* %17, i32 %18)
%20 = load i32*, i32** %6
%21 = load i32*, i32** %5
%22 = call i32 @X509_CRL_print(i32* %20, i32* %21)
store i32 %22, i32* %7
%23 = load i32*, i32** %6
%24 = call i32 @BIO_free(i32* %23)
%25 = load i32, i32* %7
store i32 %25, i32* %3
br label %26
26: ; preds = %15, %11
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@X509_F_X509_CRL_PRINT_FP = global i32 0
@ERR_R_BUF_LIB = global i32 0
@BIO_NOCLOSE = global i32 0
define i32 @X509_CRL_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 %10
6: ; preds = %2
%7 = load i32, i32* @X509_F_X509_CRL_PRINT_FP
%8 = load i32, i32* @ERR_R_BUF_LIB
%9 = tail call i32 @X509err(i32 %7, i32 %8)
br label %15
10: ; preds = %2
%11 = load i32, i32* @BIO_NOCLOSE
%12 = tail call i32 @BIO_set_fp(i32* %4, i32* %0, i32 %11)
%13 = tail call i32 @X509_CRL_print(i32* %4, i32* %1)
%14 = tail call i32 @BIO_free(i32* %4)
br label %15
15: ; preds = %10, %6
%16 = phi i32 [ 0, %6 ], [ %13, %10 ]
ret i32 %16
}