#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_10__ {
  TYPE_2__ *other;
  int /*<<< orphan*/ *data;
};
struct TYPE_11__ {
  TYPE_3__ d;
};
struct TYPE_8__ {
  int /*<<< orphan*/ *octet_string;
};
struct TYPE_9__ {
  scalar_t__ type;
  TYPE_1__ value;
};
typedef TYPE_4__ PKCS7;
typedef int /*<<< orphan*/ ASN1_OCTET_STRING;

/* Variables and functions */
scalar_t__ PKCS7_type_is_data(TYPE_4__ *);
scalar_t__ PKCS7_type_is_other(TYPE_4__ *);
scalar_t__ V_ASN1_OCTET_STRING;
ASN1_OCTET_STRING *PKCS7_get_octet_string(PKCS7 *p7) {
  if (PKCS7_type_is_data(p7))
    return p7->d.data;
  if (PKCS7_type_is_other(p7) && p7->d.other &&
      (p7->d.other->type == V_ASN1_OCTET_STRING))
    return p7->d.other->value.octet_string;
  return NULL;
}


x86 assembly (clang, -O0):
<PKCS7_get_octet_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <PKCS7_type_is_data@plt>
cmp    $0x0,%rax
je     1150 <PKCS7_get_octet_string+0x30>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    11a7 <PKCS7_get_octet_string+0x87>
mov    -0x10(%rbp),%rdi
call   1030 <PKCS7_type_is_other@plt>
cmp    $0x0,%rax
je     119f <PKCS7_get_octet_string+0x7f>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     119f <PKCS7_get_octet_string+0x7f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    0x2e5e(%rip),%rcx
cmp    (%rcx),%rax
jne    119f <PKCS7_get_octet_string+0x7f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    11a7 <PKCS7_get_octet_string+0x87>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PKCS7_get_octet_string>:
push   %rbx
mov    %rdi,%rbx
call   1040 <PKCS7_type_is_data@plt>
test   %rax,%rax
je     1137 <PKCS7_get_octet_string+0x17>
add    $0x8,%rbx
mov    (%rbx),%rax
pop    %rbx
ret
mov    %rbx,%rdi
call   1030 <PKCS7_type_is_other@plt>
test   %rax,%rax
je     115b <PKCS7_get_octet_string+0x3b>
mov    (%rbx),%rbx
test   %rbx,%rbx
je     115b <PKCS7_get_octet_string+0x3b>
mov    (%rbx),%rax
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%rax
je     112e <PKCS7_get_octet_string+0xe>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_11__ = type { %struct.TYPE_10__ }
%struct.TYPE_10__ = type { %struct.TYPE_9__*, i32* }
%struct.TYPE_9__ = type { i64, %struct.TYPE_8__ }
%struct.TYPE_8__ = type { i32* }
@V_ASN1_OCTET_STRING = global i64 0
define i32* @PKCS7_get_octet_string(%struct.TYPE_11__* %0) {
%2 = alloca i32*
%3 = alloca %struct.TYPE_11__*
store %struct.TYPE_11__* %0, %struct.TYPE_11__** %3
%4 = load %struct.TYPE_11__*, %struct.TYPE_11__** %3
%5 = call i64 @PKCS7_type_is_data(%struct.TYPE_11__* %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load %struct.TYPE_11__*, %struct.TYPE_11__** %3
%9 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %8, i32 0, i32 0
%10 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %9, i32 0, i32 1
%11 = load i32*, i32** %10
store i32* %11, i32** %2
br label %40
12: ; preds = %1
%13 = load %struct.TYPE_11__*, %struct.TYPE_11__** %3
%14 = call i64 @PKCS7_type_is_other(%struct.TYPE_11__* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %39
16: ; preds = %12
%17 = load %struct.TYPE_11__*, %struct.TYPE_11__** %3
%18 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %17, i32 0, i32 0
%19 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %18, i32 0, i32 0
%20 = load %struct.TYPE_9__*, %struct.TYPE_9__** %19
%21 = icmp ne %struct.TYPE_9__* %20, null
br i1 %21, label %22, label %39
22: ; preds = %16
%23 = load %struct.TYPE_11__*, %struct.TYPE_11__** %3
%24 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %23, i32 0, i32 0
%25 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %24, i32 0, i32 0
%26 = load %struct.TYPE_9__*, %struct.TYPE_9__** %25
%27 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %26, i32 0, i32 0
%28 = load i64, i64* %27
%29 = load i64, i64* @V_ASN1_OCTET_STRING
%30 = icmp eq i64 %28, %29
br i1 %30, label %31, label %39
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 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %33, i32 0, i32 0
%35 = load %struct.TYPE_9__*, %struct.TYPE_9__** %34
%36 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %35, i32 0, i32 1
%37 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %36, i32 0, i32 0
%38 = load i32*, i32** %37
store i32* %38, i32** %2
br label %40
39: ; preds = %22, %16, %12
store i32* null, i32** %2
br label %40
40: ; preds = %39, %31, %7
%41 = load i32*, i32** %2
ret i32* %41
}

LLVM IR (-O2):
%struct.TYPE_11__ = type { %struct.TYPE_10__ }
%struct.TYPE_10__ = type { %struct.TYPE_9__*, i32* }
%struct.TYPE_9__ = type { i64, %struct.TYPE_8__ }
%struct.TYPE_8__ = type { i32* }
@V_ASN1_OCTET_STRING = global i64 0
define i32* @PKCS7_get_octet_string(%struct.TYPE_11__* %0) {
%2 = tail call i64 @PKCS7_type_is_data(%struct.TYPE_11__* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %0, i64 0, i32 0, i32 1
br label %20
6: ; preds = %1
%7 = tail call i64 @PKCS7_type_is_other(%struct.TYPE_11__* %0)
%8 = icmp eq i64 %7, 0
br i1 %8, label %23, label %9
9: ; preds = %6
%10 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %0, i64 0, i32 0, i32 0
%11 = load %struct.TYPE_9__*, %struct.TYPE_9__** %10
%12 = icmp eq %struct.TYPE_9__* %11, null
br i1 %12, label %23, label %13
13: ; preds = %9
%14 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %11, i64 0, i32 0
%15 = load i64, i64* %14
%16 = load i64, i64* @V_ASN1_OCTET_STRING
%17 = icmp eq i64 %15, %16
br i1 %17, label %18, label %23
18: ; preds = %13
%19 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %11, i64 0, i32 1, i32 0
br label %20
20: ; preds = %4, %18
%21 = phi i32** [ %19, %18 ], [ %5, %4 ]
%22 = load i32*, i32** %21
br label %23
23: ; preds = %20, %6, %9, %13
%24 = phi i32* [ null, %13 ], [ null, %9 ], [ null, %6 ], [ %22, %20 ]
ret i32* %24
}