#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 */
typedef struct TYPE_7__ TYPE_3__;
typedef struct TYPE_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  TYPE_1__ *sequence;
};
struct TYPE_7__ {
  scalar_t__ type;
  TYPE_2__ value;
};
struct TYPE_5__ {
  unsigned char *data;
  int /*<<< orphan*/ length;
};
typedef int /*<<< orphan*/ PKCS7_SIGNER_INFO;
typedef int /*<<< orphan*/ ESS_SIGNING_CERT;
typedef TYPE_3__ ASN1_TYPE;

/* Variables and functions */
int /*<<< orphan*/ NID_id_smime_aa_signingCertificate;
TYPE_3__ *PKCS7_get_signed_attribute(int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ V_ASN1_SEQUENCE;
int /*<<< orphan*/ *d2i_ESS_SIGNING_CERT(int /*<<< orphan*/ *,
                                         unsigned char const **,
                                         int /*<<< orphan*/);
ESS_SIGNING_CERT *ESS_get_signing_cert(PKCS7_SIGNER_INFO *si) {
  ASN1_TYPE *attr;
  const unsigned char *p;
  attr = PKCS7_get_signed_attribute(si, NID_id_smime_aa_signingCertificate);
  if (!attr)
    return NULL;
  if (attr->type != V_ASN1_SEQUENCE)
    return NULL;
  p = attr->value.sequence->data;
  return d2i_ESS_SIGNING_CERT(NULL, &p, attr->value.sequence->length);
}


x86 assembly (clang, -O0):
<ESS_get_signing_cert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2eb1(%rip),%rax
mov    (%rax),%esi
call   1030 <PKCS7_get_signed_attribute@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    115a <ESS_get_signing_cert+0x3a>
movq   $0x0,-0x8(%rbp)
jmp    11a9 <ESS_get_signing_cert+0x89>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2e68(%rip),%rcx
cmp    (%rcx),%rax
je     117e <ESS_get_signing_cert+0x5e>
movq   $0x0,-0x8(%rbp)
jmp    11a9 <ESS_get_signing_cert+0x89>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x8(%rax),%edx
xor    %eax,%eax
mov    %eax,%edi
lea    -0x20(%rbp),%rsi
call   1040 <d2i_ESS_SIGNING_CERT@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ESS_get_signing_cert>:
push   %rax
mov    0x2ec0(%rip),%rax
mov    (%rax),%esi
call   1030 <PKCS7_get_signed_attribute@plt>
test   %rax,%rax
je     115d <ESS_get_signing_cert+0x3d>
mov    (%rax),%rcx
mov    0x2e92(%rip),%rdx
cmp    (%rdx),%rcx
jne    115d <ESS_get_signing_cert+0x3d>
mov    0x8(%rax),%rax
mov    (%rax),%rcx
mov    %rcx,(%rsp)
mov    0x8(%rax),%edx
mov    %rsp,%rsi
xor    %edi,%edi
call   1040 <d2i_ESS_SIGNING_CERT@plt>
pop    %rcx
ret
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.TYPE_7__ = type { i64, %struct.TYPE_6__ }
%struct.TYPE_6__ = type { %struct.TYPE_5__* }
%struct.TYPE_5__ = type { i8*, i32 }
@NID_id_smime_aa_signingCertificate = global i32 0
@V_ASN1_SEQUENCE = global i64 0
define i32* @ESS_get_signing_cert(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca %struct.TYPE_7__*
%5 = alloca i8*
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = load i32, i32* @NID_id_smime_aa_signingCertificate
%8 = call %struct.TYPE_7__* @PKCS7_get_signed_attribute(i32* %6, i32 %7)
store %struct.TYPE_7__* %8, %struct.TYPE_7__** %4
%9 = load %struct.TYPE_7__*, %struct.TYPE_7__** %4
%10 = icmp ne %struct.TYPE_7__* %9, null
br i1 %10, label %12, label %11
11: ; preds = %1
store i32* null, i32** %2
br label %33
12: ; preds = %1
%13 = load %struct.TYPE_7__*, %struct.TYPE_7__** %4
%14 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %13, i32 0, i32 0
%15 = load i64, i64* %14
%16 = load i64, i64* @V_ASN1_SEQUENCE
%17 = icmp ne i64 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %12
store i32* null, i32** %2
br label %33
19: ; preds = %12
%20 = load %struct.TYPE_7__*, %struct.TYPE_7__** %4
%21 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %20, i32 0, i32 1
%22 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %21, i32 0, i32 0
%23 = load %struct.TYPE_5__*, %struct.TYPE_5__** %22
%24 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %23, i32 0, i32 0
%25 = load i8*, i8** %24
store i8* %25, i8** %5
%26 = load %struct.TYPE_7__*, %struct.TYPE_7__** %4
%27 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %26, i32 0, i32 1
%28 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %27, i32 0, i32 0
%29 = load %struct.TYPE_5__*, %struct.TYPE_5__** %28
%30 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %29, i32 0, i32 1
%31 = load i32, i32* %30
%32 = call i32* @d2i_ESS_SIGNING_CERT(i32* null, i8** %5, i32 %31)
store i32* %32, i32** %2
br label %33
33: ; preds = %19, %18, %11
%34 = load i32*, i32** %2
ret i32* %34
}

LLVM IR (-O2):
%struct.TYPE_7__ = type { i64, %struct.TYPE_6__ }
%struct.TYPE_6__ = type { %struct.TYPE_5__* }
%struct.TYPE_5__ = type { i8*, i32 }
@NID_id_smime_aa_signingCertificate = global i32 0
@V_ASN1_SEQUENCE = global i64 0
define i32* @ESS_get_signing_cert(i32* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = load i32, i32* @NID_id_smime_aa_signingCertificate
%5 = tail call %struct.TYPE_7__* @PKCS7_get_signed_attribute(i32* %0, i32 %4)
%6 = icmp eq %struct.TYPE_7__* %5, null
br i1 %6, label %20, label %7
7: ; preds = %1
%8 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %5, i64 0, i32 0
%9 = load i64, i64* %8
%10 = load i64, i64* @V_ASN1_SEQUENCE
%11 = icmp eq i64 %9, %10
br i1 %11, label %12, label %20
12: ; preds = %7
%13 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %5, i64 0, i32 1, i32 0
%14 = load %struct.TYPE_5__*, %struct.TYPE_5__** %13
%15 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i64 0, i32 0
%16 = load i8*, i8** %15
store i8* %16, i8** %2
%17 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i64 0, i32 1
%18 = load i32, i32* %17
%19 = call i32* @d2i_ESS_SIGNING_CERT(i32* null, i8** %2, i32 %18)
br label %20
20: ; preds = %7, %1, %12
%21 = phi i32* [ %19, %12 ], [ null, %1 ], [ null, %7 ]
ret i32* %21
}