#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__ {
  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*/);
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;
  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    1183 <ESS_get_signing_cert+0x63>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%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     1150 <ESS_get_signing_cert+0x30>
mov    (%rax),%rcx
mov    (%rcx),%rcx
mov    %rcx,(%rsp)
mov    (%rax),%rax
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 { %struct.TYPE_6__ }
%struct.TYPE_6__ = type { %struct.TYPE_5__* }
%struct.TYPE_5__ = type { i8*, i32 }
@NID_id_smime_aa_signingCertificate = global i32 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 %26
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 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %14, i32 0, i32 0
%16 = load %struct.TYPE_5__*, %struct.TYPE_5__** %15
%17 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %16, i32 0, i32 0
%18 = load i8*, i8** %17
store i8* %18, i8** %5
%19 = load %struct.TYPE_7__*, %struct.TYPE_7__** %4
%20 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %19, i32 0, i32 0
%21 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %20, i32 0, i32 0
%22 = load %struct.TYPE_5__*, %struct.TYPE_5__** %21
%23 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %22, i32 0, i32 1
%24 = load i32, i32* %23
%25 = call i32* @d2i_ESS_SIGNING_CERT(i32* null, i8** %5, i32 %24)
store i32* %25, i32** %2
br label %26
26: ; preds = %12, %11
%27 = load i32*, i32** %2
ret i32* %27
}

LLVM IR (-O2):
%struct.TYPE_7__ = type { %struct.TYPE_6__ }
%struct.TYPE_6__ = type { %struct.TYPE_5__* }
%struct.TYPE_5__ = type { i8*, i32 }
@NID_id_smime_aa_signingCertificate = global i32 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 %16, label %7
7: ; preds = %1
%8 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %5, i64 0, i32 0, i32 0
%9 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %9, i64 0, i32 0
%11 = load i8*, i8** %10
store i8* %11, i8** %2
%12 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i64 0, i32 1
%14 = load i32, i32* %13
%15 = call i32* @d2i_ESS_SIGNING_CERT(i32* null, i8** %2, i32 %14)
br label %16
16: ; preds = %1, %7
%17 = phi i32* [ %15, %7 ], [ null, %1 ]
ret i32* %17
}