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

/* Variables and functions */
int /*<<< orphan*/ ERR_print_errors_fp(int /*<<< orphan*/);
int /*<<< orphan*/
PEM_write_PrivateKey(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                     int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                     int /*<<< orphan*/, int /*<<< orphan*/ *,
                     int /*<<< orphan*/ *);
int /*<<< orphan*/ assert(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int abac_write_privkey_to_fp(EVP_PKEY *key, FILE *fp) {
  assert(key);
  if (!PEM_write_PrivateKey(fp, key, NULL, NULL, 0, NULL, NULL)) {
    ERR_print_errors_fp(stderr);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<abac_write_privkey_to_fp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r9d
xor    %r8d,%r8d
mov    %r9,%rdx
mov    %r9,%rcx
movq   $0x0,(%rsp)
call   1040 <PEM_write_PrivateKey@plt>
cmp    $0x0,%eax
jne    118f <abac_write_privkey_to_fp+0x5f>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
call   1050 <ERR_print_errors_fp@plt>
movl   $0x1,-0x4(%rbp)
jmp    1196 <abac_write_privkey_to_fp+0x66>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<abac_write_privkey_to_fp>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <assert@plt>
movq   $0x0,(%rsp)
xor    %r14d,%r14d
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1040 <PEM_write_PrivateKey@plt>
test   %eax,%eax
jne    117c <abac_write_privkey_to_fp+0x4c>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
call   1050 <ERR_print_errors_fp@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
define i32 @abac_write_privkey_to_fp(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
store i32* %0, i32** %4
store i32* %1, i32** %5
%6 = load i32*, i32** %4
%7 = call i32 @assert(i32* %6)
%8 = load i32*, i32** %5
%9 = load i32*, i32** %4
%10 = call i32 @PEM_write_PrivateKey(i32* %8, i32* %9, i32* null, i32* null, i32 0, i32* null, i32* null)
%11 = icmp ne i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 @ERR_print_errors_fp(i32 %13)
store i32 1, i32* %3
br label %16
15: ; preds = %2
store i32 0, i32* %3
br label %16
16: ; preds = %15, %12
%17 = load i32, i32* %3
ret i32 %17
}

LLVM IR (-O2):
@stderr = global i32 0
define i32 @abac_write_privkey_to_fp(i32* %0, i32* %1) {
%3 = tail call i32 @assert(i32* %0)
%4 = tail call i32 @PEM_write_PrivateKey(i32* %1, i32* %0, i32* null, i32* null, i32 0, i32* null, i32* null)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @ERR_print_errors_fp(i32 %7)
br label %9
9: ; preds = %2, %6
%10 = phi i32 [ 1, %6 ], [ 0, %2 ]
ret i32 %10
}