#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_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ X509;
struct TYPE_5__ {
  TYPE_1__ *issuer_and_serial;
};
struct TYPE_4__ {
  int /*<<< orphan*/ serial;
  int /*<<< orphan*/ issuer;
};
typedef TYPE_2__ PKCS7_RECIP_INFO;

/* Variables and functions */
int ASN1_INTEGER_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int X509_NAME_cmp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ X509_get_issuer_name(int /*<<< orphan*/ *);
int /*<<< orphan*/ X509_get_serialNumber(int /*<<< orphan*/ *);
int pkcs7_cmp_ri(PKCS7_RECIP_INFO *ri, X509 *pcert) {
  int ret;
  ret =
      X509_NAME_cmp(ri->issuer_and_serial->issuer, X509_get_issuer_name(pcert));
  if (ret)
    return ret;
  return ASN1_INTEGER_cmp(X509_get_serialNumber(pcert),
                          ri->issuer_and_serial->serial);
}


x86 assembly (clang, -O0):
<pkcs7_cmp_ri>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <X509_get_issuer_name@plt>
mov    -0x20(%rbp),%edi
mov    %eax,%esi
call   1060 <X509_NAME_cmp@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1188 <pkcs7_cmp_ri+0x48>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a4 <pkcs7_cmp_ri+0x64>
mov    -0x18(%rbp),%rdi
call   1040 <X509_get_serialNumber@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%esi
call   1050 <ASN1_INTEGER_cmp@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pkcs7_cmp_ri>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    (%rdi),%rax
mov    0x4(%rax),%ebp
mov    %rsi,%rdi
call   1030 <X509_get_issuer_name@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1060 <X509_NAME_cmp@plt>
test   %eax,%eax
je     116a <pkcs7_cmp_ri+0x2a>
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rbx,%rdi
call   1040 <X509_get_serialNumber@plt>
mov    (%r14),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <ASN1_INTEGER_cmp@plt>

LLVM IR (-O0):
%struct.TYPE_5__ = type { %struct.TYPE_4__* }
%struct.TYPE_4__ = type { i32, i32 }
define i32 @pkcs7_cmp_ri(%struct.TYPE_5__* %0, i32* %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_5__*
%5 = alloca i32*
%6 = alloca i32
store %struct.TYPE_5__* %0, %struct.TYPE_5__** %4
store i32* %1, i32** %5
%7 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 0
%9 = load %struct.TYPE_4__*, %struct.TYPE_4__** %8
%10 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %9, i32 0, i32 1
%11 = load i32, i32* %10
%12 = load i32*, i32** %5
%13 = call i32 @X509_get_issuer_name(i32* %12)
%14 = call i32 @X509_NAME_cmp(i32 %11, i32 %13)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = load i32, i32* %6
store i32 %18, i32* %3
br label %28
19: ; preds = %2
%20 = load i32*, i32** %5
%21 = call i32 @X509_get_serialNumber(i32* %20)
%22 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%23 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %22, i32 0, i32 0
%24 = load %struct.TYPE_4__*, %struct.TYPE_4__** %23
%25 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %24, i32 0, i32 0
%26 = load i32, i32* %25
%27 = call i32 @ASN1_INTEGER_cmp(i32 %21, i32 %26)
store i32 %27, i32* %3
br label %28
28: ; preds = %19, %17
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { %struct.TYPE_4__* }
%struct.TYPE_4__ = type { i32, i32 }
define i32 @pkcs7_cmp_ri(%struct.TYPE_5__* nocapture %0, i32* %1) {
%3 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %0, i64 0, i32 0
%4 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
%5 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i64 0, i32 1
%6 = load i32, i32* %5
%7 = tail call i32 @X509_get_issuer_name(i32* %1)
%8 = tail call i32 @X509_NAME_cmp(i32 %6, i32 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = tail call i32 @X509_get_serialNumber(i32* %1)
%12 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
%13 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %12, i64 0, i32 0
%14 = load i32, i32* %13
%15 = tail call i32 @ASN1_INTEGER_cmp(i32 %11, i32 %14)
br label %16
16: ; preds = %2, %10
%17 = phi i32 [ %15, %10 ], [ %8, %2 ]
ret i32 %17
}