#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*/ EC_GROUP;
typedef int /*<<< orphan*/ BN_CTX;
typedef int /*<<< orphan*/ BIGNUM;

/* Variables and functions */
int /*<<< orphan*/ BN_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BN_new();
int /*<<< orphan*/ EC_GROUP_get_order(int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *);
BIGNUM *make_order(EC_GROUP *grp, BN_CTX *ctx) {
  BIGNUM *ord;
  ord = BN_new();
  if (ord == NULL)
    return NULL;
  if (!EC_GROUP_get_order(grp, ord, ctx)) {
    BN_free(ord);
    return NULL;
  }
  return ord;
}


x86 assembly (clang, -O0):
<make_order>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x0,%al
call   1030 <BN_new@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1163 <make_order+0x33>
movq   $0x0,-0x8(%rbp)
jmp    119b <make_order+0x6b>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <EC_GROUP_get_order@plt>
cmp    $0x0,%eax
jne    1193 <make_order+0x63>
mov    -0x20(%rbp),%rdi
call   1050 <BN_free@plt>
movq   $0x0,-0x8(%rbp)
jmp    119b <make_order+0x6b>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_order>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %eax,%eax
call   1030 <BN_new@plt>
test   %rax,%rax
je     1164 <make_order+0x34>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
call   1040 <EC_GROUP_get_order@plt>
test   %eax,%eax
jne    1166 <make_order+0x36>
mov    %rbx,%rdi
call   1050 <BN_free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32* @make_order(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
store i32* %0, i32** %4
store i32* %1, i32** %5
%7 = call i32* (...) @BN_new()
store i32* %7, i32** %6
%8 = load i32*, i32** %6
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %11
10: ; preds = %2
store i32* null, i32** %3
br label %22
11: ; preds = %2
%12 = load i32*, i32** %4
%13 = load i32*, i32** %6
%14 = load i32*, i32** %5
%15 = call i32 @EC_GROUP_get_order(i32* %12, i32* %13, i32* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %11
%18 = load i32*, i32** %6
%19 = call i32 @BN_free(i32* %18)
store i32* null, i32** %3
br label %22
20: ; preds = %11
%21 = load i32*, i32** %6
store i32* %21, i32** %3
br label %22
22: ; preds = %20, %17, %10
%23 = load i32*, i32** %3
ret i32* %23
}

LLVM IR (-O2):
define i32* @make_order(i32* %0, i32* %1) {
%3 = tail call i32* (...) @BN_new()
%4 = icmp eq i32* %3, null
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = tail call i32 @EC_GROUP_get_order(i32* %0, i32* %3, i32* %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @BN_free(i32* %3)
br label %10
10: ; preds = %5, %2, %8
%11 = phi i32* [ null, %8 ], [ null, %2 ], [ %3, %5 ]
ret i32* %11
}