#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_create_bn_from_id(struct ecqv_gen_t *);
int ecqv_create_keypair(struct ecqv_gen_t *);
int ecqv_priv_reconstr_data(struct ecqv_gen_t *);
int ecqv_public_reconstr_data(struct ecqv_gen_t *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int ecqv_key_generation(struct ecqv_gen_t *ecqv_gen) {
  if (ecqv_public_reconstr_data(ecqv_gen) == -1) {
    fprintf(stderr, "Creating public reconstruction data (Pu) failed.\n");
    return -1;
  }
  if (ecqv_create_bn_from_id(ecqv_gen) == -1) {
    fprintf(stderr, "Creating bignum from the identity failed.\n");
    return -1;
  }
  if (ecqv_priv_reconstr_data(ecqv_gen) == -1) {
    fprintf(stderr, "Creating private reconstruction data (r) failed.\n");
    return -1;
  }
  if (ecqv_create_keypair(ecqv_gen) == -1) {
    fprintf(stderr, "Creating public/private key pair failed.\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<ecqv_key_generation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <ecqv_public_reconstr_data@plt>
cmp    $0xffffffff,%eax
jne    118f <ecqv_key_generation+0x3f>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122f <ecqv_key_generation+0xdf>
mov    -0x10(%rbp),%rdi
call   1030 <ecqv_create_bn_from_id@plt>
cmp    $0xffffffff,%eax
jne    11c2 <ecqv_key_generation+0x72>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    0xe81(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122f <ecqv_key_generation+0xdf>
mov    -0x10(%rbp),%rdi
call   1070 <ecqv_priv_reconstr_data@plt>
cmp    $0xffffffff,%eax
jne    11f5 <ecqv_key_generation+0xa5>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
lea    0xe79(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122f <ecqv_key_generation+0xdf>
mov    -0x10(%rbp),%rdi
call   1040 <ecqv_create_keypair@plt>
cmp    $0xffffffff,%eax
jne    1228 <ecqv_key_generation+0xd8>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122f <ecqv_key_generation+0xdf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ecqv_key_generation>:
push   %rbx
mov    %rdi,%rbx
call   1060 <ecqv_public_reconstr_data@plt>
cmp    $0xffffffff,%eax
je     118b <ecqv_key_generation+0x3b>
mov    %rbx,%rdi
call   1030 <ecqv_create_bn_from_id@plt>
cmp    $0xffffffff,%eax
je     1194 <ecqv_key_generation+0x44>
mov    %rbx,%rdi
call   1070 <ecqv_priv_reconstr_data@plt>
cmp    $0xffffffff,%eax
je     119d <ecqv_key_generation+0x4d>
mov    %rbx,%rdi
call   1040 <ecqv_create_keypair@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
je     11a6 <ecqv_key_generation+0x56>
pop    %rbx
ret
lea    0xe6e(%rip),%rsi
jmp    11ad <ecqv_key_generation+0x5d>
lea    0xe97(%rip),%rsi
jmp    11ad <ecqv_key_generation+0x5d>
lea    0xeb9(%rip),%rsi
jmp    11ad <ecqv_key_generation+0x5d>
lea    0xee2(%rip),%rsi
mov    0x2e2c(%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 = [50 x i8] c"Creating public reconstruction data (Pu) failed.\0A\00"
@.str.1 = [43 x i8] c"Creating bignum from the identity failed.\0A\00"
@.str.2 = [50 x i8] c"Creating private reconstruction data (r) failed.\0A\00"
@.str.3 = [42 x i8] c"Creating public/private key pair failed.\0A\00"
define i32 @ecqv_key_generation(%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_public_reconstr_data(%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 ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %32
10: ; preds = %1
%11 = load %struct.ecqv_gen_t*, %struct.ecqv_gen_t** %3
%12 = call i32 @ecqv_create_bn_from_id(%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 ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
br label %32
17: ; preds = %10
%18 = load %struct.ecqv_gen_t*, %struct.ecqv_gen_t** %3
%19 = call i32 @ecqv_priv_reconstr_data(%struct.ecqv_gen_t* %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %2
br label %32
24: ; preds = %17
%25 = load %struct.ecqv_gen_t*, %struct.ecqv_gen_t** %3
%26 = call i32 @ecqv_create_keypair(%struct.ecqv_gen_t* %25)
%27 = icmp eq i32 %26, -1
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %2
br label %32
31: ; preds = %24
store i32 0, i32* %2
br label %32
32: ; preds = %31, %28, %21, %14, %7
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
%struct.ecqv_gen_t = type { i32 }
@stderr = global i32 0
@.str = [50 x i8] c"Creating public reconstruction data (Pu) failed.\0A\00"
@.str.1 = [43 x i8] c"Creating bignum from the identity failed.\0A\00"
@.str.2 = [50 x i8] c"Creating private reconstruction data (r) failed.\0A\00"
@.str.3 = [42 x i8] c"Creating public/private key pair failed.\0A\00"
define i32 @ecqv_key_generation(%struct.ecqv_gen_t* %0) {
%2 = tail call i32 @ecqv_public_reconstr_data(%struct.ecqv_gen_t* %0)
%3 = icmp eq i32 %2, -1
br i1 %3, label %13, label %4
4: ; preds = %1
%5 = tail call i32 @ecqv_create_bn_from_id(%struct.ecqv_gen_t* %0)
%6 = icmp eq i32 %5, -1
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = tail call i32 @ecqv_priv_reconstr_data(%struct.ecqv_gen_t* %0)
%9 = icmp eq i32 %8, -1
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call i32 @ecqv_create_keypair(%struct.ecqv_gen_t* %0)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %17
13: ; preds = %10, %7, %4, %1
%14 = phi i8* [ getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), %7 ], [ getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), %10 ]
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* %14)
br label %17
17: ; preds = %13, %10
%18 = phi i32 [ 0, %10 ], [ -1, %13 ]
ret i32 %18
}