#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_15__ TYPE_5__;
typedef struct TYPE_14__ TYPE_4__;
typedef struct TYPE_13__ TYPE_3__;
typedef struct TYPE_12__ TYPE_2__;
typedef struct TYPE_11__ TYPE_1__;

/* Type definitions */
struct TYPE_14__ {
  TYPE_3__ *parameter;
};
typedef TYPE_4__ X509_ALGOR;
struct TYPE_15__ {
  int /*<<< orphan*/ maskGenAlgorithm;
};
struct TYPE_12__ {
  TYPE_1__ *sequence;
};
struct TYPE_13__ {
  scalar_t__ type;
  TYPE_2__ value;
};
struct TYPE_11__ {
  unsigned char *data;
  int length;
};
typedef TYPE_5__ RSA_PSS_PARAMS;

/* Variables and functions */
scalar_t__ V_ASN1_SEQUENCE;
TYPE_5__ *d2i_RSA_PSS_PARAMS(int /*<<< orphan*/ *, unsigned char const **, int);
TYPE_4__ *rsa_mgf1_decode(int /*<<< orphan*/);
RSA_PSS_PARAMS *rsa_pss_decode(const X509_ALGOR *alg, X509_ALGOR **pmaskHash) {
  const unsigned char *p;
  int plen;
  RSA_PSS_PARAMS *pss;
  *pmaskHash = NULL;
  if (!alg->parameter || alg->parameter->type != V_ASN1_SEQUENCE)
    return NULL;
  p = alg->parameter->value.sequence->data;
  plen = alg->parameter->value.sequence->length;
  pss = d2i_RSA_PSS_PARAMS(NULL, &p, plen);
  if (!pss)
    return NULL;
  *pmaskHash = rsa_mgf1_decode(pss->maskGenAlgorithm);
  return pss;
}


x86 assembly (clang, -O0):
<rsa_pss_decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1163 <rsa_pss_decode+0x43>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    0x2e7e(%rip),%rcx
cmp    (%rcx),%rax
je     1170 <rsa_pss_decode+0x50>
movq   $0x0,-0x8(%rbp)
jmp    11dc <rsa_pss_decode+0xbc>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edx
xor    %eax,%eax
mov    %eax,%edi
lea    -0x20(%rbp),%rsi
call   1040 <d2i_RSA_PSS_PARAMS@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11bf <rsa_pss_decode+0x9f>
movq   $0x0,-0x8(%rbp)
jmp    11dc <rsa_pss_decode+0xbc>
mov    -0x30(%rbp),%rax
mov    (%rax),%edi
call   1030 <rsa_mgf1_decode@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rsa_pss_decode>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movq   $0x0,(%rsi)
mov    (%rdi),%rax
test   %rax,%rax
je     117e <rsa_pss_decode+0x5e>
mov    (%rax),%rcx
mov    0x2e96(%rip),%rdx
cmp    (%rdx),%rcx
jne    117e <rsa_pss_decode+0x5e>
mov    %rsi,%r14
mov    0x8(%rax),%rax
mov    (%rax),%rcx
mov    %rcx,0x8(%rsp)
mov    0x8(%rax),%edx
xor    %ebx,%ebx
lea    0x8(%rsp),%rsi
xor    %edi,%edi
call   1040 <d2i_RSA_PSS_PARAMS@plt>
test   %rax,%rax
je     1180 <rsa_pss_decode+0x60>
mov    %rax,%r15
mov    (%rax),%edi
call   1030 <rsa_mgf1_decode@plt>
mov    %rax,(%r14)
mov    %r15,%rbx
jmp    1180 <rsa_pss_decode+0x60>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_15__ = type { i32 }
%struct.TYPE_14__ = type { %struct.TYPE_13__* }
%struct.TYPE_13__ = type { i64, %struct.TYPE_12__ }
%struct.TYPE_12__ = type { %struct.TYPE_11__* }
%struct.TYPE_11__ = type { i8*, i32 }
@V_ASN1_SEQUENCE = global i64 0
define %struct.TYPE_15__* @rsa_pss_decode(%struct.TYPE_14__* %0, %struct.TYPE_14__** %1) {
%3 = alloca %struct.TYPE_15__*
%4 = alloca %struct.TYPE_14__*
%5 = alloca %struct.TYPE_14__**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca %struct.TYPE_15__*
store %struct.TYPE_14__* %0, %struct.TYPE_14__** %4
store %struct.TYPE_14__** %1, %struct.TYPE_14__*** %5
%9 = load %struct.TYPE_14__**, %struct.TYPE_14__*** %5
store %struct.TYPE_14__* null, %struct.TYPE_14__** %9
%10 = load %struct.TYPE_14__*, %struct.TYPE_14__** %4
%11 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %10, i32 0, i32 0
%12 = load %struct.TYPE_13__*, %struct.TYPE_13__** %11
%13 = icmp ne %struct.TYPE_13__* %12, null
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = load %struct.TYPE_14__*, %struct.TYPE_14__** %4
%16 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %15, i32 0, i32 0
%17 = load %struct.TYPE_13__*, %struct.TYPE_13__** %16
%18 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %17, i32 0, i32 0
%19 = load i64, i64* %18
%20 = load i64, i64* @V_ASN1_SEQUENCE
%21 = icmp ne i64 %19, %20
br i1 %21, label %22, label %23
22: ; preds = %14, %2
store %struct.TYPE_15__* null, %struct.TYPE_15__** %3
br label %52
23: ; preds = %14
%24 = load %struct.TYPE_14__*, %struct.TYPE_14__** %4
%25 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %24, i32 0, i32 0
%26 = load %struct.TYPE_13__*, %struct.TYPE_13__** %25
%27 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %26, i32 0, i32 1
%28 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %27, i32 0, i32 0
%29 = load %struct.TYPE_11__*, %struct.TYPE_11__** %28
%30 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %29, i32 0, i32 0
%31 = load i8*, i8** %30
store i8* %31, i8** %6
%32 = load %struct.TYPE_14__*, %struct.TYPE_14__** %4
%33 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %32, i32 0, i32 0
%34 = load %struct.TYPE_13__*, %struct.TYPE_13__** %33
%35 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %34, i32 0, i32 1
%36 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %35, i32 0, i32 0
%37 = load %struct.TYPE_11__*, %struct.TYPE_11__** %36
%38 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %37, i32 0, i32 1
%39 = load i32, i32* %38
store i32 %39, i32* %7
%40 = load i32, i32* %7
%41 = call %struct.TYPE_15__* @d2i_RSA_PSS_PARAMS(i32* null, i8** %6, i32 %40)
store %struct.TYPE_15__* %41, %struct.TYPE_15__** %8
%42 = load %struct.TYPE_15__*, %struct.TYPE_15__** %8
%43 = icmp ne %struct.TYPE_15__* %42, null
br i1 %43, label %45, label %44
44: ; preds = %23
store %struct.TYPE_15__* null, %struct.TYPE_15__** %3
br label %52
45: ; preds = %23
%46 = load %struct.TYPE_15__*, %struct.TYPE_15__** %8
%47 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %46, i32 0, i32 0
%48 = load i32, i32* %47
%49 = call %struct.TYPE_14__* @rsa_mgf1_decode(i32 %48)
%50 = load %struct.TYPE_14__**, %struct.TYPE_14__*** %5
store %struct.TYPE_14__* %49, %struct.TYPE_14__** %50
%51 = load %struct.TYPE_15__*, %struct.TYPE_15__** %8
store %struct.TYPE_15__* %51, %struct.TYPE_15__** %3
br label %52
52: ; preds = %45, %44, %22
%53 = load %struct.TYPE_15__*, %struct.TYPE_15__** %3
ret %struct.TYPE_15__* %53
}

LLVM IR (-O2):
%struct.TYPE_15__ = type { i32 }
%struct.TYPE_14__ = type { %struct.TYPE_13__* }
%struct.TYPE_13__ = type { i64, %struct.TYPE_12__ }
%struct.TYPE_12__ = type { %struct.TYPE_11__* }
%struct.TYPE_11__ = type { i8*, i32 }
@V_ASN1_SEQUENCE = global i64 0
define %struct.TYPE_15__* @rsa_pss_decode(%struct.TYPE_14__* nocapture %0, %struct.TYPE_14__** nocapture writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store %struct.TYPE_14__* null, %struct.TYPE_14__** %1
%5 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %0, i64 0, i32 0
%6 = load %struct.TYPE_13__*, %struct.TYPE_13__** %5
%7 = icmp eq %struct.TYPE_13__* %6, null
br i1 %7, label %26, label %8
8: ; preds = %2
%9 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %6, i64 0, i32 0
%10 = load i64, i64* %9
%11 = load i64, i64* @V_ASN1_SEQUENCE
%12 = icmp eq i64 %10, %11
br i1 %12, label %13, label %26
13: ; preds = %8
%14 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %6, i64 0, i32 1, i32 0
%15 = load %struct.TYPE_11__*, %struct.TYPE_11__** %14
%16 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %15, i64 0, i32 0
%17 = load i8*, i8** %16
store i8* %17, i8** %3
%18 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %15, i64 0, i32 1
%19 = load i32, i32* %18
%20 = call %struct.TYPE_15__* @d2i_RSA_PSS_PARAMS(i32* null, i8** %3, i32 %19)
%21 = icmp eq %struct.TYPE_15__* %20, null
br i1 %21, label %26, label %22
22: ; preds = %13
%23 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %20, i64 0, i32 0
%24 = load i32, i32* %23
%25 = call %struct.TYPE_14__* @rsa_mgf1_decode(i32 %24)
store %struct.TYPE_14__* %25, %struct.TYPE_14__** %1
br label %26
26: ; preds = %13, %2, %8, %22
%27 = phi %struct.TYPE_15__* [ %20, %22 ], [ null, %8 ], [ null, %2 ], [ null, %13 ]
ret %struct.TYPE_15__* %27
}