#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_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int /*<<< orphan*/ algorithm;
};
typedef TYPE_1__ X509_ALGOR;
typedef int /*<<< orphan*/ EVP_PKEY;
typedef int /*<<< orphan*/ EVP_MD_CTX;
typedef int /*<<< orphan*/ ASN1_ITEM;
typedef int /*<<< orphan*/ ASN1_BIT_STRING;

/* Variables and functions */
scalar_t__ NID_rsassaPss;
scalar_t__ OBJ_obj2nid(int /*<<< orphan*/);
int /*<<< orphan*/ RSA_F_RSA_ITEM_VERIFY;
int /*<<< orphan*/ RSA_R_UNSUPPORTED_SIGNATURE_TYPE;
int /*<<< orphan*/ RSAerr(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ rsa_pss_to_ctx(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                          TYPE_1__ *, int /*<<< orphan*/ *);
int rsa_item_verify(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
                    X509_ALGOR *sigalg, ASN1_BIT_STRING *sig, EVP_PKEY *pkey) {
  if (OBJ_obj2nid(sigalg->algorithm) != NID_rsassaPss) {
    RSAerr(RSA_F_RSA_ITEM_VERIFY, RSA_R_UNSUPPORTED_SIGNATURE_TYPE);
    return -1;
  }
  if (rsa_pss_to_ctx(ctx, NULL, sigalg, pkey) > 0) {
    return 2;
  }
  return -1;
}


x86 assembly (clang, -O0):
<rsa_item_verify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%edi
call   1030 <OBJ_obj2nid@plt>
mov    0x2e7e(%rip),%rcx
cmp    (%rcx),%rax
je     118e <rsa_item_verify+0x5e>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
mov    0x2e4d(%rip),%rax
mov    (%rax),%esi
call   1050 <RSAerr@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c0 <rsa_item_verify+0x90>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x38(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%esi
call   1040 <rsa_pss_to_ctx@plt>
cmp    $0x0,%rax
jle    11b9 <rsa_item_verify+0x89>
movl   $0x2,-0x4(%rbp)
jmp    11c0 <rsa_item_verify+0x90>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rsa_item_verify>:
push   %r15
push   %r14
push   %rbx
mov    %r9,%r14
mov    %rcx,%rbx
mov    %rdi,%r15
mov    (%rcx),%edi
call   1030 <OBJ_obj2nid@plt>
mov    0x2e94(%rip),%rcx
cmp    (%rcx),%rax
jne    1171 <rsa_item_verify+0x41>
mov    %r15,%rdi
xor    %esi,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1040 <rsa_pss_to_ctx@plt>
xor    %ecx,%ecx
test   %rax,%rax
setg   %cl
lea    (%rcx,%rcx,2),%eax
add    $0xffffffff,%eax
jmp    118d <rsa_item_verify+0x5d>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
mov    0x2e47(%rip),%rax
mov    (%rax),%esi
call   1050 <RSAerr@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32 }
@NID_rsassaPss = global i64 0
@RSA_F_RSA_ITEM_VERIFY = global i32 0
@RSA_R_UNSUPPORTED_SIGNATURE_TYPE = global i32 0
define i32 @rsa_item_verify(i32* %0, i32* %1, i8* %2, %struct.TYPE_4__* %3, i32* %4, i32* %5) {
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca %struct.TYPE_4__*
%12 = alloca i32*
%13 = alloca i32*
store i32* %0, i32** %8
store i32* %1, i32** %9
store i8* %2, i8** %10
store %struct.TYPE_4__* %3, %struct.TYPE_4__** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
%14 = load %struct.TYPE_4__*, %struct.TYPE_4__** %11
%15 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = call i64 @OBJ_obj2nid(i32 %16)
%18 = load i64, i64* @NID_rsassaPss
%19 = icmp ne i64 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %6
%21 = load i32, i32* @RSA_F_RSA_ITEM_VERIFY
%22 = load i32, i32* @RSA_R_UNSUPPORTED_SIGNATURE_TYPE
%23 = call i32 @RSAerr(i32 %21, i32 %22)
store i32 -1, i32* %7
br label %32
24: ; preds = %6
%25 = load i32*, i32** %8
%26 = load %struct.TYPE_4__*, %struct.TYPE_4__** %11
%27 = load i32*, i32** %13
%28 = call i64 @rsa_pss_to_ctx(i32* %25, i32* null, %struct.TYPE_4__* %26, i32* %27)
%29 = icmp sgt i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %24
store i32 2, i32* %7
br label %32
31: ; preds = %24
store i32 -1, i32* %7
br label %32
32: ; preds = %31, %30, %20
%33 = load i32, i32* %7
ret i32 %33
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32 }
@NID_rsassaPss = global i64 0
@RSA_F_RSA_ITEM_VERIFY = global i32 0
@RSA_R_UNSUPPORTED_SIGNATURE_TYPE = global i32 0
define i32 @rsa_item_verify(i32* %0, i32* nocapture readnone %1, i8* nocapture readnone %2, %struct.TYPE_4__* %3, i32* nocapture readnone %4, i32* %5) {
%7 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %3, i64 0, i32 0
%8 = load i32, i32* %7
%9 = tail call i64 @OBJ_obj2nid(i32 %8)
%10 = load i64, i64* @NID_rsassaPss
%11 = icmp eq i64 %9, %10
br i1 %11, label %16, label %12
12: ; preds = %6
%13 = load i32, i32* @RSA_F_RSA_ITEM_VERIFY
%14 = load i32, i32* @RSA_R_UNSUPPORTED_SIGNATURE_TYPE
%15 = tail call i32 @RSAerr(i32 %13, i32 %14)
br label %20
16: ; preds = %6
%17 = tail call i64 @rsa_pss_to_ctx(i32* %0, i32* null, %struct.TYPE_4__* %3, i32* %5)
%18 = icmp sgt i64 %17, 0
%19 = select i1 %18, i32 2, i32 -1
br label %20
20: ; preds = %16, %12
%21 = phi i32 [ -1, %12 ], [ %19, %16 ]
ret i32 %21
}