#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*/ DH;
typedef int /*<<< orphan*/ ASN1_VALUE;
typedef int /*<<< orphan*/ ASN1_ITEM;

/* Variables and functions */
int ASN1_OP_FREE_PRE;
int ASN1_OP_NEW_PRE;
int /*<<< orphan*/ DH_free(int /*<<< orphan*/ *);
scalar_t__ DH_new();
int dh_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it) {
  if (operation == ASN1_OP_NEW_PRE) {
    *pval = (ASN1_VALUE *)DH_new();
    if (*pval)
      return 2;
    return 0;
  } else if (operation == ASN1_OP_FREE_PRE) {
    DH_free((DH *)*pval);
    *pval = NULL;
    return 2;
  }
  return 1;
}


x86 assembly (clang, -O0):
<dh_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2ea3(%rip),%rcx
cmp    (%rcx),%eax
jne    117c <dh_cb+0x5c>
mov    $0x0,%al
call   1030 <DH_new@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1170 <dh_cb+0x50>
movl   $0x2,-0x4(%rbp)
jmp    11bd <dh_cb+0x9d>
movl   $0x0,-0x4(%rbp)
jmp    11bd <dh_cb+0x9d>
mov    -0x8(%rbp),%eax
mov    0x2e62(%rip),%rcx
cmp    (%rcx),%eax
jne    11b1 <dh_cb+0x91>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1040 <DH_free@plt>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    11bd <dh_cb+0x9d>
jmp    11b6 <dh_cb+0x96>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dh_cb>:
push   %rbx
mov    %rsi,%rbx
mov    0x2eb5(%rip),%rax
cmp    %edi,(%rax)
jne    1148 <dh_cb+0x28>
xor    %eax,%eax
call   1030 <DH_new@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
mov    %rcx,(%rbx)
add    %eax,%eax
pop    %rbx
ret
mov    0x2e99(%rip),%rcx
mov    $0x1,%eax
cmp    %edi,(%rcx)
jne    116c <dh_cb+0x4c>
mov    (%rbx),%rdi
call   1040 <DH_free@plt>
movq   $0x0,(%rbx)
mov    $0x2,%eax
pop    %rbx
ret

LLVM IR (-O0):
@ASN1_OP_NEW_PRE = global i32 0
@ASN1_OP_FREE_PRE = global i32 0
define i32 @dh_cb(i32 %0, i32** %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32**
%7 = alloca i32*
store i32 %0, i32* %5
store i32** %1, i32*** %6
store i32* %2, i32** %7
%8 = load i32, i32* %5
%9 = load i32, i32* @ASN1_OP_NEW_PRE
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %20
11: ; preds = %3
%12 = call i64 (...) @DH_new()
%13 = inttoptr i64 %12 to i32*
%14 = load i32**, i32*** %6
store i32* %13, i32** %14
%15 = load i32**, i32*** %6
%16 = load i32*, i32** %15
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %19
18: ; preds = %11
store i32 2, i32* %4
br label %31
19: ; preds = %11
store i32 0, i32* %4
br label %31
20: ; preds = %3
%21 = load i32, i32* %5
%22 = load i32, i32* @ASN1_OP_FREE_PRE
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = load i32**, i32*** %6
%26 = load i32*, i32** %25
%27 = call i32 @DH_free(i32* %26)
%28 = load i32**, i32*** %6
store i32* null, i32** %28
store i32 2, i32* %4
br label %31
29: ; preds = %20
br label %30
30: ; preds = %29
store i32 1, i32* %4
br label %31
31: ; preds = %30, %24, %19, %18
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
@ASN1_OP_NEW_PRE = global i32 0
@ASN1_OP_FREE_PRE = global i32 0
define i32 @dh_cb(i32 %0, i32** nocapture %1, i32* nocapture readnone %2) {
%4 = load i32, i32* @ASN1_OP_NEW_PRE
%5 = icmp eq i32 %4, %0
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = tail call i64 (...) @DH_new()
%8 = inttoptr i64 %7 to i32*
store i32* %8, i32** %1
%9 = icmp eq i64 %7, 0
%10 = select i1 %9, i32 0, i32 2
br label %17
11: ; preds = %3
%12 = load i32, i32* @ASN1_OP_FREE_PRE
%13 = icmp eq i32 %12, %0
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = load i32*, i32** %1
%16 = tail call i32 @DH_free(i32* %15)
store i32* null, i32** %1
br label %17
17: ; preds = %11, %6, %14
%18 = phi i32 [ 2, %14 ], [ %10, %6 ], [ 1, %11 ]
ret i32 %18
}