#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 */
struct ecqv_gen_t {
  int dummy;
};

/* Variables and functions */
int ecqv_write_impl_cert(struct ecqv_gen_t *);
int ecqv_write_private_key(struct ecqv_gen_t *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int ecqv_export_keypair(struct ecqv_gen_t *ecqv_gen) {
  if (ecqv_write_private_key(ecqv_gen) == -1) {
    fprintf(stderr, "Exporting key pair failed.\n");
    return -1;
  }
  if (ecqv_write_impl_cert(ecqv_gen) == -1) {
    fprintf(stderr, "Exporting certificate failed.\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<ecqv_export_keypair>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <ecqv_write_private_key@plt>
cmp    $0xffffffff,%eax
jne    116f <ecqv_export_keypair+0x3f>
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
lea    0xea2(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a9 <ecqv_export_keypair+0x79>
mov    -0x10(%rbp),%rdi
call   1040 <ecqv_write_impl_cert@plt>
cmp    $0xffffffff,%eax
jne    11a2 <ecqv_export_keypair+0x72>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
lea    0xe8b(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a9 <ecqv_export_keypair+0x79>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ecqv_export_keypair>:
push   %rbx
mov    %rdi,%rbx
call   1030 <ecqv_write_private_key@plt>
cmp    $0xffffffff,%eax
je     1151 <ecqv_export_keypair+0x21>
mov    %rbx,%rdi
call   1040 <ecqv_write_impl_cert@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
je     115a <ecqv_export_keypair+0x2a>
pop    %rbx
ret
lea    0xea8(%rip),%rsi
jmp    1161 <ecqv_export_keypair+0x31>
lea    0xebb(%rip),%rsi
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
call   1050 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.ecqv_gen_t = type { i32 }
@stderr = global i32 0
@.str = [28 x i8] c"Exporting key pair failed.\0A\00"
@.str.1 = [31 x i8] c"Exporting certificate failed.\0A\00"
define i32 @ecqv_export_keypair(%struct.ecqv_gen_t* %0) {
%2 = alloca i32
%3 = alloca %struct.ecqv_gen_t*
store %struct.ecqv_gen_t* %0, %struct.ecqv_gen_t** %3
%4 = load %struct.ecqv_gen_t*, %struct.ecqv_gen_t** %3
%5 = call i32 @ecqv_write_private_key(%struct.ecqv_gen_t* %4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %18
10: ; preds = %1
%11 = load %struct.ecqv_gen_t*, %struct.ecqv_gen_t** %3
%12 = call i32 @ecqv_write_impl_cert(%struct.ecqv_gen_t* %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
br label %18
17: ; preds = %10
store i32 0, i32* %2
br label %18
18: ; preds = %17, %14, %7
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
%struct.ecqv_gen_t = type { i32 }
@stderr = global i32 0
@.str = [28 x i8] c"Exporting key pair failed.\0A\00"
@.str.1 = [31 x i8] c"Exporting certificate failed.\0A\00"
define i32 @ecqv_export_keypair(%struct.ecqv_gen_t* %0) {
%2 = tail call i32 @ecqv_write_private_key(%struct.ecqv_gen_t* %0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i32 @ecqv_write_impl_cert(%struct.ecqv_gen_t* %0)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %11
7: ; preds = %4, %1
%8 = phi i8* [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), %4 ]
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* %8)
br label %11
11: ; preds = %7, %4
%12 = phi i32 [ 0, %4 ], [ -1, %7 ]
ret i32 %12
}