#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_11__ TYPE_4__;
typedef struct TYPE_10__ TYPE_3__;
typedef struct TYPE_9__ TYPE_2__;
typedef struct TYPE_8__ TYPE_1__;

/* Type definitions */
struct TYPE_11__ {
  TYPE_3__ *parameter;
  int /*<<< orphan*/ algorithm;
};
typedef TYPE_4__ X509_ALGOR;
struct TYPE_9__ {
  TYPE_1__ *sequence;
};
struct TYPE_10__ {
  scalar_t__ type;
  TYPE_2__ value;
};
struct TYPE_8__ {
  unsigned char *data;
  int length;
};

/* Variables and functions */
scalar_t__ NID_mgf1;
scalar_t__ OBJ_obj2nid(int /*<<< orphan*/);
scalar_t__ V_ASN1_SEQUENCE;
TYPE_4__ *d2i_X509_ALGOR(int /*<<< orphan*/ *, unsigned char const **, int);
X509_ALGOR *rsa_mgf1_decode(X509_ALGOR *alg) {
  const unsigned char *p;
  int plen;
  if (alg == NULL || alg->parameter == NULL)
    return NULL;
  if (OBJ_obj2nid(alg->algorithm) != NID_mgf1)
    return NULL;
  if (alg->parameter->type != V_ASN1_SEQUENCE)
    return NULL;
  p = alg->parameter->value.sequence->data;
  plen = alg->parameter->value.sequence->length;
  return d2i_X509_ALGOR(NULL, &p, plen);
}


x86 assembly (clang, -O0):
<rsa_mgf1_decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1145 <rsa_mgf1_decode+0x25>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1152 <rsa_mgf1_decode+0x32>
movq   $0x0,-0x8(%rbp)
jmp    11d9 <rsa_mgf1_decode+0xb9>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%edi
call   1030 <OBJ_obj2nid@plt>
mov    0x2e6b(%rip),%rcx
cmp    (%rcx),%rax
je     117b <rsa_mgf1_decode+0x5b>
movq   $0x0,-0x8(%rbp)
jmp    11d9 <rsa_mgf1_decode+0xb9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    0x2e4c(%rip),%rcx
cmp    (%rcx),%rax
je     11a2 <rsa_mgf1_decode+0x82>
movq   $0x0,-0x8(%rbp)
jmp    11d9 <rsa_mgf1_decode+0xb9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edx
xor    %eax,%eax
mov    %eax,%edi
lea    -0x18(%rbp),%rsi
call   1040 <d2i_X509_ALGOR@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rsa_mgf1_decode>:
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
je     1176 <rsa_mgf1_decode+0x56>
mov    %rdi,%rbx
cmpq   $0x0,(%rdi)
je     1176 <rsa_mgf1_decode+0x56>
mov    0x8(%rbx),%edi
call   1030 <OBJ_obj2nid@plt>
mov    0x2e8e(%rip),%rcx
cmp    (%rcx),%rax
jne    1176 <rsa_mgf1_decode+0x56>
mov    (%rbx),%rax
mov    (%rax),%rcx
mov    0x2e84(%rip),%rdx
cmp    (%rdx),%rcx
jne    1176 <rsa_mgf1_decode+0x56>
mov    0x8(%rax),%rax
mov    (%rax),%rcx
mov    %rcx,0x8(%rsp)
mov    0x8(%rax),%edx
lea    0x8(%rsp),%rsi
xor    %edi,%edi
call   1040 <d2i_X509_ALGOR@plt>
jmp    1178 <rsa_mgf1_decode+0x58>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

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