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

/* Variables and functions */
int /*<<< orphan*/ *BN_bin2bn(unsigned char *, size_t, int /*<<< orphan*/ *);
size_t EC_POINT_point2buf(int /*<<< orphan*/ const *,
                          int /*<<< orphan*/ const *, int /*<<< orphan*/,
                          unsigned char **, int /*<<< orphan*/ *);
int /*<<< orphan*/ OPENSSL_free(unsigned char *);
BIGNUM *EC_POINT_point2bn(const EC_GROUP *group, const EC_POINT *point,
                          point_conversion_form_t form, BIGNUM *ret,
                          BN_CTX *ctx) {
  size_t buf_len = 0;
  unsigned char *buf;
  buf_len = EC_POINT_point2buf(group, point, form, &buf, ctx);
  if (buf_len == 0)
    return NULL;
  ret = BN_bin2bn(buf, buf_len, ret);
  OPENSSL_free(buf);
  return ret;
}


x86 assembly (clang, -O0):
<EC_POINT_point2bn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x30(%rbp),%r8
lea    -0x40(%rbp),%rcx
call   1040 <EC_POINT_point2buf@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1187 <EC_POINT_point2bn+0x57>
movq   $0x0,-0x8(%rbp)
jmp    11ad <EC_POINT_point2bn+0x7d>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <BN_bin2bn@plt>
mov    %rax,-0x28(%rbp)
mov    -0x40(%rbp),%rdi
call   1050 <OPENSSL_free@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EC_POINT_point2bn>:
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%rbx
lea    0x8(%rsp),%rcx
call   1040 <EC_POINT_point2buf@plt>
test   %rax,%rax
je     1166 <EC_POINT_point2bn+0x36>
mov    0x8(%rsp),%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
call   1030 <BN_bin2bn@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%rdi
call   1050 <OPENSSL_free@plt>
jmp    1168 <EC_POINT_point2bn+0x38>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32* @EC_POINT_point2bn(i32* %0, i32* %1, i32 %2, i32* %3, i32* %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i64
%13 = alloca i8*
store i32* %0, i32** %7
store i32* %1, i32** %8
store i32 %2, i32* %9
store i32* %3, i32** %10
store i32* %4, i32** %11
store i64 0, i64* %12
%14 = load i32*, i32** %7
%15 = load i32*, i32** %8
%16 = load i32, i32* %9
%17 = load i32*, i32** %11
%18 = call i64 @EC_POINT_point2buf(i32* %14, i32* %15, i32 %16, i8** %13, i32* %17)
store i64 %18, i64* %12
%19 = load i64, i64* %12
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %5
store i32* null, i32** %6
br label %30
22: ; preds = %5
%23 = load i8*, i8** %13
%24 = load i64, i64* %12
%25 = load i32*, i32** %10
%26 = call i32* @BN_bin2bn(i8* %23, i64 %24, i32* %25)
store i32* %26, i32** %10
%27 = load i8*, i8** %13
%28 = call i32 @OPENSSL_free(i8* %27)
%29 = load i32*, i32** %10
store i32* %29, i32** %6
br label %30
30: ; preds = %22, %21
%31 = load i32*, i32** %6
ret i32* %31
}

LLVM IR (-O2):
define i32* @EC_POINT_point2bn(i32* %0, i32* %1, i32 %2, i32* %3, i32* %4) {
%6 = alloca i8*
%7 = bitcast i8** %6 to i8*
%8 = call i64 @EC_POINT_point2buf(i32* %0, i32* %1, i32 %2, i8** %6, i32* %4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %5
%11 = load i8*, i8** %6
%12 = call i32* @BN_bin2bn(i8* %11, i64 %8, i32* %3)
%13 = load i8*, i8** %6
%14 = call i32 @OPENSSL_free(i8* %13)
br label %15
15: ; preds = %5, %10
%16 = phi i32* [ %12, %10 ], [ null, %5 ]
ret i32* %16
}