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

/* Variables and functions */
int /*<<< orphan*/ BIO_ctrl(int /*<<< orphan*/ *, int, int, char *);
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ BIO_s_file();
int /*<<< orphan*/ CRYPTO_MEM_CHECK_DISABLE;
int /*<<< orphan*/ CRYPTO_MEM_CHECK_ENABLE;
int /*<<< orphan*/ CRYPTO_mem_ctrl(int /*<<< orphan*/);
int CRYPTO_mem_leaks(int /*<<< orphan*/ *);
int CRYPTO_mem_leaks_fp(FILE *fp) {
  BIO *b;
  int ret;
  CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
  b = BIO_new(BIO_s_file());
  CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
  if (b == NULL)
    return -1;
  BIO_ctrl(b, 106, 0x00, (char *)fp);
  ret = CRYPTO_mem_leaks(b);
  BIO_free(b);
  return ret;
}


x86 assembly (clang, -O0):
<CRYPTO_mem_leaks_fp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
call   1060 <CRYPTO_mem_ctrl@plt>
mov    $0x0,%al
call   1080 <BIO_s_file@plt>
mov    %eax,%edi
call   1030 <BIO_new@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
call   1060 <CRYPTO_mem_ctrl@plt>
cmpq   $0x0,-0x18(%rbp)
jne    11b1 <CRYPTO_mem_leaks_fp+0x51>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e0 <CRYPTO_mem_leaks_fp+0x80>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x6a,%esi
xor    %edx,%edx
call   1040 <BIO_ctrl@plt>
mov    -0x18(%rbp),%rdi
call   1070 <CRYPTO_mem_leaks@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <BIO_free@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CRYPTO_mem_leaks_fp>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
call   1060 <CRYPTO_mem_ctrl@plt>
xor    %eax,%eax
call   1080 <BIO_s_file@plt>
mov    %eax,%edi
call   1030 <BIO_new@plt>
mov    %rax,%rbx
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
call   1060 <CRYPTO_mem_ctrl@plt>
test   %rbx,%rbx
je     11c1 <CRYPTO_mem_leaks_fp+0x61>
mov    %rbx,%rdi
mov    $0x6a,%esi
xor    %edx,%edx
mov    %r14,%rcx
call   1040 <BIO_ctrl@plt>
mov    %rbx,%rdi
call   1070 <CRYPTO_mem_leaks@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <BIO_free@plt>
mov    %ebp,%eax
jmp    11c6 <CRYPTO_mem_leaks_fp+0x66>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@CRYPTO_MEM_CHECK_DISABLE = global i32 0
@CRYPTO_MEM_CHECK_ENABLE = global i32 0
define i32 @CRYPTO_mem_leaks_fp(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %3
%6 = load i32, i32* @CRYPTO_MEM_CHECK_DISABLE
%7 = call i32 @CRYPTO_mem_ctrl(i32 %6)
%8 = call i32 (...) @BIO_s_file()
%9 = call i32* @BIO_new(i32 %8)
store i32* %9, i32** %4
%10 = load i32, i32* @CRYPTO_MEM_CHECK_ENABLE
%11 = call i32 @CRYPTO_mem_ctrl(i32 %10)
%12 = load i32*, i32** %4
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %15
14: ; preds = %1
store i32 -1, i32* %2
br label %25
15: ; preds = %1
%16 = load i32*, i32** %4
%17 = load i32*, i32** %3
%18 = bitcast i32* %17 to i8*
%19 = call i32 @BIO_ctrl(i32* %16, i32 106, i32 0, i8* %18)
%20 = load i32*, i32** %4
%21 = call i32 @CRYPTO_mem_leaks(i32* %20)
store i32 %21, i32* %5
%22 = load i32*, i32** %4
%23 = call i32 @BIO_free(i32* %22)
%24 = load i32, i32* %5
store i32 %24, i32* %2
br label %25
25: ; preds = %15, %14
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@CRYPTO_MEM_CHECK_DISABLE = global i32 0
@CRYPTO_MEM_CHECK_ENABLE = global i32 0
define i32 @CRYPTO_mem_leaks_fp(i32* %0) {
%2 = load i32, i32* @CRYPTO_MEM_CHECK_DISABLE
%3 = tail call i32 @CRYPTO_mem_ctrl(i32 %2)
%4 = tail call i32 (...) @BIO_s_file()
%5 = tail call i32* @BIO_new(i32 %4)
%6 = load i32, i32* @CRYPTO_MEM_CHECK_ENABLE
%7 = tail call i32 @CRYPTO_mem_ctrl(i32 %6)
%8 = icmp eq i32* %5, null
br i1 %8, label %14, label %9
9: ; preds = %1
%10 = bitcast i32* %0 to i8*
%11 = tail call i32 @BIO_ctrl(i32* %5, i32 106, i32 0, i8* %10)
%12 = tail call i32 @CRYPTO_mem_leaks(i32* %5)
%13 = tail call i32 @BIO_free(i32* %5)
br label %14
14: ; preds = %1, %9
%15 = phi i32 [ %12, %9 ], [ -1, %1 ]
ret i32 %15
}