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

/* Variables and functions */
int ASN1_OP_NEW_PRE;
int /*<<< orphan*/ *DSA_SIG_new();
int /*<<< orphan*/ DSAerror(int /*<<< orphan*/);
int /*<<< orphan*/ ERR_R_MALLOC_FAILURE;
int sig_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) {
  if (operation == ASN1_OP_NEW_PRE) {
    DSA_SIG *sig;
    if ((sig = DSA_SIG_new()) == NULL) {
      DSAerror(ERR_R_MALLOC_FAILURE);
      return 0;
    }
    *pval = (ASN1_VALUE *)sig;
    return 2;
  }
  return 1;
}


x86 assembly (clang, -O0):
<sig_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2ea7(%rip),%rcx
cmp    (%rcx),%eax
jne    118f <sig_cb+0x6f>
mov    $0x0,%al
call   1030 <DSA_SIG_new@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1178 <sig_cb+0x58>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
call   1040 <DSAerror@plt>
movl   $0x0,-0x4(%rbp)
jmp    1196 <sig_cb+0x76>
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    1196 <sig_cb+0x76>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sig_cb>:
push   %r14
push   %rbx
push   %rax
mov    0x2ebd(%rip),%rax
mov    $0x1,%ebx
cmp    %edi,(%rax)
jne    115d <sig_cb+0x3d>
mov    %rsi,%r14
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <DSA_SIG_new@plt>
test   %rax,%rax
je     114f <sig_cb+0x2f>
mov    %rax,(%r14)
mov    $0x2,%ebx
jmp    115d <sig_cb+0x3d>
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
call   1040 <DSAerror@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@ASN1_OP_NEW_PRE = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
define i32 @sig_cb(i32 %0, i32** %1, i32* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32**
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i32*
store i32 %0, i32* %6
store i32** %1, i32*** %7
store i32* %2, i32** %8
store i8* %3, i8** %9
%11 = load i32, i32* %6
%12 = load i32, i32* @ASN1_OP_NEW_PRE
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %23
14: ; preds = %4
%15 = call i32* (...) @DSA_SIG_new()
store i32* %15, i32** %10
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* @ERR_R_MALLOC_FAILURE
%19 = call i32 @DSAerror(i32 %18)
store i32 0, i32* %5
br label %24
20: ; preds = %14
%21 = load i32*, i32** %10
%22 = load i32**, i32*** %7
store i32* %21, i32** %22
store i32 2, i32* %5
br label %24
23: ; preds = %4
store i32 1, i32* %5
br label %24
24: ; preds = %23, %20, %17
%25 = load i32, i32* %5
ret i32 %25
}

LLVM IR (-O2):
@ASN1_OP_NEW_PRE = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
define i32 @sig_cb(i32 %0, i32** nocapture writeonly %1, i32* nocapture readnone %2, i8* nocapture readnone %3) {
%5 = load i32, i32* @ASN1_OP_NEW_PRE
%6 = icmp eq i32 %5, %0
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = tail call i32* (...) @DSA_SIG_new()
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* @ERR_R_MALLOC_FAILURE
%12 = tail call i32 @DSAerror(i32 %11)
br label %14
13: ; preds = %7
store i32* %8, i32** %1
br label %14
14: ; preds = %4, %10, %13
%15 = phi i32 [ 0, %10 ], [ 2, %13 ], [ 1, %4 ]
ret i32 %15
}