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

/* Variables and functions */
int /*<<< orphan*/ *BN_dup(int /*<<< orphan*/ const *);
int /*<<< orphan*/ BN_free(int /*<<< orphan*/ *);
int int_dh_bn_cpy(BIGNUM **dst, const BIGNUM *src) {
  BIGNUM *a;
  if (src) {
    a = BN_dup(src);
    if (!a)
      return 0;
  } else
    a = NULL;
  if (*dst)
    BN_free(*dst);
  *dst = a;
  return 1;
}


x86 assembly (clang, -O0):
<int_dh_bn_cpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1164 <int_dh_bn_cpy+0x44>
mov    -0x18(%rbp),%rdi
call   1030 <BN_dup@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    115f <int_dh_bn_cpy+0x3f>
movl   $0x0,-0x4(%rbp)
jmp    1198 <int_dh_bn_cpy+0x78>
jmp    116c <int_dh_bn_cpy+0x4c>
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1186 <int_dh_bn_cpy+0x66>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <BN_free@plt>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_dh_bn_cpy>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %ebx,%ebx
test   %rsi,%rsi
je     1141 <int_dh_bn_cpy+0x21>
mov    %rsi,%rdi
call   1030 <BN_dup@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1144 <int_dh_bn_cpy+0x24>
jmp    1159 <int_dh_bn_cpy+0x39>
xor    %r15d,%r15d
mov    (%r14),%rdi
test   %rdi,%rdi
je     1151 <int_dh_bn_cpy+0x31>
call   1040 <BN_free@plt>
mov    %r15,(%r14)
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @int_dh_bn_cpy(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 = load i32*, i32** %5
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i32*, i32** %5
%11 = call i32* @BN_dup(i32* %10)
store i32* %11, i32** %6
%12 = load i32*, i32** %6
%13 = icmp ne i32* %12, null
br i1 %13, label %15, label %14
14: ; preds = %9
store i32 0, i32* %3
br label %28
15: ; preds = %9
br label %17
16: ; preds = %2
store i32* null, i32** %6
br label %17
17: ; preds = %16, %15
%18 = load i32**, i32*** %4
%19 = load i32*, i32** %18
%20 = icmp ne i32* %19, null
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i32**, i32*** %4
%23 = load i32*, i32** %22
%24 = call i32 @BN_free(i32* %23)
br label %25
25: ; preds = %21, %17
%26 = load i32*, i32** %6
%27 = load i32**, i32*** %4
store i32* %26, i32** %27
store i32 1, i32* %3
br label %28
28: ; preds = %25, %14
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
define i32 @int_dh_bn_cpy(i32** nocapture %0, i32* %1) {
%3 = icmp eq i32* %1, null
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i32* @BN_dup(i32* %1)
%6 = icmp eq i32* %5, null
br i1 %6, label %14, label %7
7: ; preds = %2, %4
%8 = phi i32* [ %5, %4 ], [ null, %2 ]
%9 = load i32*, i32** %0
%10 = icmp eq i32* %9, null
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = tail call i32 @BN_free(i32* %9)
br label %13
13: ; preds = %11, %7
store i32* %8, i32** %0
br label %14
14: ; preds = %4, %13
%15 = phi i32 [ 1, %13 ], [ 0, %4 ]
ret i32 %15
}