#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_22__ TYPE_8__;
typedef struct TYPE_21__ TYPE_7__;
typedef struct TYPE_20__ TYPE_5__;
typedef struct TYPE_19__ TYPE_4__;
typedef struct TYPE_18__ TYPE_3__;
typedef struct TYPE_17__ TYPE_2__;
typedef struct TYPE_16__ TYPE_1__;
typedef struct TYPE_15__ TYPE_12__;
typedef struct TYPE_14__ TYPE_11__;
typedef struct TYPE_13__ TYPE_10__;

/* Type definitions */
struct TYPE_22__ {
  int /*<<< orphan*/ version;
};
struct TYPE_21__ {
  TYPE_1__ *enc_data;
  int /*<<< orphan*/ version;
};
struct TYPE_19__ {
  TYPE_12__ *digest;
  TYPE_11__ *encrypted;
  TYPE_10__ *enveloped;
  TYPE_7__ *signed_and_enveloped;
  int /*<<< orphan*/ *data;
  TYPE_8__ *sign;
};
struct TYPE_20__ {
  TYPE_4__ d;
  int /*<<< orphan*/ *type;
};
struct TYPE_18__ {
  void *content_type;
};
struct TYPE_17__ {
  void *content_type;
};
struct TYPE_16__ {
  void *content_type;
};
struct TYPE_15__ {
  int /*<<< orphan*/ version;
};
struct TYPE_14__ {
  TYPE_3__ *enc_data;
  int /*<<< orphan*/ version;
};
struct TYPE_13__ {
  TYPE_2__ *enc_data;
  int /*<<< orphan*/ version;
};
typedef TYPE_5__ PKCS7;
typedef int /*<<< orphan*/ ASN1_OBJECT;

/* Variables and functions */
int /*<<< orphan*/ ASN1_INTEGER_set(int /*<<< orphan*/, int);
int /*<<< orphan*/ *M_ASN1_OCTET_STRING_new();
#define NID_pkcs7_data 133
#define NID_pkcs7_digest 132
#define NID_pkcs7_encrypted 131
#define NID_pkcs7_enveloped 130
#define NID_pkcs7_signed 129
#define NID_pkcs7_signedAndEnveloped 128
void *OBJ_nid2obj(int const);
TYPE_12__ *PKCS7_DIGEST_new();
TYPE_11__ *PKCS7_ENCRYPT_new();
TYPE_10__ *PKCS7_ENVELOPE_new();
int /*<<< orphan*/ PKCS7_F_PKCS7_SET_TYPE;
int /*<<< orphan*/ PKCS7_R_UNSUPPORTED_CONTENT_TYPE;
int /*<<< orphan*/ PKCS7_SIGNED_free(TYPE_8__ *);
TYPE_8__ *PKCS7_SIGNED_new();
TYPE_7__ *PKCS7_SIGN_ENVELOPE_new();
int /*<<< orphan*/ PKCS7err(int /*<<< orphan*/, int /*<<< orphan*/);
int PKCS7_set_type(PKCS7 *p7, int type) {
  ASN1_OBJECT *obj;
  obj = OBJ_nid2obj(type);
  switch (type) {
  case NID_pkcs7_signed:
    p7->type = obj;
    if ((p7->d.sign = PKCS7_SIGNED_new()) == NULL)
      goto err;
    if (!ASN1_INTEGER_set(p7->d.sign->version, 1)) {
      PKCS7_SIGNED_free(p7->d.sign);
      p7->d.sign = NULL;
      goto err;
    }
    break;
  case NID_pkcs7_data:
    p7->type = obj;
    if ((p7->d.data = M_ASN1_OCTET_STRING_new()) == NULL)
      goto err;
    break;
  case NID_pkcs7_signedAndEnveloped:
    p7->type = obj;
    if ((p7->d.signed_and_enveloped = PKCS7_SIGN_ENVELOPE_new()) == NULL)
      goto err;
    ASN1_INTEGER_set(p7->d.signed_and_enveloped->version, 1);
    if (!ASN1_INTEGER_set(p7->d.signed_and_enveloped->version, 1))
      goto err;
    p7->d.signed_and_enveloped->enc_data->content_type =
        OBJ_nid2obj(NID_pkcs7_data);
    break;
  case NID_pkcs7_enveloped:
    p7->type = obj;
    if ((p7->d.enveloped = PKCS7_ENVELOPE_new()) == NULL)
      goto err;
    if (!ASN1_INTEGER_set(p7->d.enveloped->version, 0))
      goto err;
    p7->d.enveloped->enc_data->content_type = OBJ_nid2obj(NID_pkcs7_data);
    break;
  case NID_pkcs7_encrypted:
    p7->type = obj;
    if ((p7->d.encrypted = PKCS7_ENCRYPT_new()) == NULL)
      goto err;
    if (!ASN1_INTEGER_set(p7->d.encrypted->version, 0))
      goto err;
    p7->d.encrypted->enc_data->content_type = OBJ_nid2obj(NID_pkcs7_data);
    break;
  case NID_pkcs7_digest:
    p7->type = obj;
    if ((p7->d.digest = PKCS7_DIGEST_new()) == NULL)
      goto err;
    if (!ASN1_INTEGER_set(p7->d.digest->version, 0))
      goto err;
    break;
  default:
    PKCS7err(PKCS7_F_PKCS7_SET_TYPE, PKCS7_R_UNSUPPORTED_CONTENT_TYPE);
    goto err;
  }
  return (1);
err:
  return (0);
}


x86 assembly (clang, -O0):
<PKCS7_set_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <OBJ_nid2obj@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x5,%eax
ja     141f <PKCS7_set_type+0x27f>
mov    -0x28(%rbp),%rax
lea    0xe25(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x30(%rax)
mov    $0x0,%al
call   10a0 <PKCS7_SIGNED_new@plt>
mov    -0x10(%rbp),%rcx
mov    %rax,0x28(%rcx)
cmp    $0x0,%rax
jne    120e <PKCS7_set_type+0x6e>
jmp    1447 <PKCS7_set_type+0x2a7>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   1070 <ASN1_INTEGER_set@plt>
cmp    $0x0,%eax
jne    1249 <PKCS7_set_type+0xa9>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   10c0 <PKCS7_SIGNED_free@plt>
mov    -0x10(%rbp),%rax
movq   $0x0,0x28(%rax)
jmp    1447 <PKCS7_set_type+0x2a7>
jmp    143b <PKCS7_set_type+0x29b>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x30(%rax)
mov    $0x0,%al
call   10b0 <M_ASN1_OCTET_STRING_new@plt>
mov    -0x10(%rbp),%rcx
mov    %rax,0x20(%rcx)
cmp    $0x0,%rax
jne    1278 <PKCS7_set_type+0xd8>
jmp    1447 <PKCS7_set_type+0x2a7>
jmp    143b <PKCS7_set_type+0x29b>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x30(%rax)
mov    $0x0,%al
call   1030 <PKCS7_SIGN_ENVELOPE_new@plt>
mov    -0x10(%rbp),%rcx
mov    %rax,0x18(%rcx)
cmp    $0x0,%rax
jne    12a7 <PKCS7_set_type+0x107>
jmp    1447 <PKCS7_set_type+0x2a7>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    0x8(%rax),%edi
mov    $0x1,%esi
call   1070 <ASN1_INTEGER_set@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    0x8(%rax),%edi
mov    $0x1,%esi
call   1070 <ASN1_INTEGER_set@plt>
cmp    $0x0,%eax
jne    12df <PKCS7_set_type+0x13f>
jmp    1447 <PKCS7_set_type+0x2a7>
mov    $0x85,%edi
call   1040 <OBJ_nid2obj@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    (%rax),%rax
mov    %rcx,(%rax)
jmp    143b <PKCS7_set_type+0x29b>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x30(%rax)
mov    $0x0,%al
call   1060 <PKCS7_ENVELOPE_new@plt>
mov    -0x10(%rbp),%rcx
mov    %rax,0x10(%rcx)
cmp    $0x0,%rax
jne    1329 <PKCS7_set_type+0x189>
jmp    1447 <PKCS7_set_type+0x2a7>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    0x8(%rax),%edi
xor    %esi,%esi
call   1070 <ASN1_INTEGER_set@plt>
cmp    $0x0,%eax
jne    1349 <PKCS7_set_type+0x1a9>
jmp    1447 <PKCS7_set_type+0x2a7>
mov    $0x85,%edi
call   1040 <OBJ_nid2obj@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%rax
mov    %rcx,(%rax)
jmp    143b <PKCS7_set_type+0x29b>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x30(%rax)
mov    $0x0,%al
call   1080 <PKCS7_ENCRYPT_new@plt>
mov    -0x10(%rbp),%rcx
mov    %rax,0x8(%rcx)
cmp    $0x0,%rax
jne    1393 <PKCS7_set_type+0x1f3>
jmp    1447 <PKCS7_set_type+0x2a7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x8(%rax),%edi
xor    %esi,%esi
call   1070 <ASN1_INTEGER_set@plt>
cmp    $0x0,%eax
jne    13b3 <PKCS7_set_type+0x213>
jmp    1447 <PKCS7_set_type+0x2a7>
mov    $0x85,%edi
call   1040 <OBJ_nid2obj@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    %rcx,(%rax)
jmp    143b <PKCS7_set_type+0x29b>
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x30(%rax)
mov    $0x0,%al
call   1050 <PKCS7_DIGEST_new@plt>
mov    -0x10(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    13fc <PKCS7_set_type+0x25c>
jmp    1447 <PKCS7_set_type+0x2a7>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1070 <ASN1_INTEGER_set@plt>
cmp    $0x0,%eax
jne    141a <PKCS7_set_type+0x27a>
jmp    1447 <PKCS7_set_type+0x2a7>
jmp    143b <PKCS7_set_type+0x29b>
mov    0x2bba(%rip),%rax
mov    (%rax),%edi
mov    0x2bb9(%rip),%rax
mov    (%rax),%esi
call   1090 <PKCS7err@plt>
jmp    1447 <PKCS7_set_type+0x2a7>
movl   $0x1,-0x4(%rbp)
jmp    144e <PKCS7_set_type+0x2ae>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PKCS7_set_type>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    %esi,%edi
call   1040 <OBJ_nid2obj@plt>
add    $0xffffff80,%ebp
cmp    $0x5,%ebp
ja     1223 <PKCS7_set_type+0x83>
lea    0xe42(%rip),%rcx
movslq (%rcx,%rbp,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
mov    %rax,0x30(%rbx)
xor    %eax,%eax
call   1030 <PKCS7_SIGN_ENVELOPE_new@plt>
mov    %rax,0x18(%rbx)
test   %rax,%rax
je     133d <PKCS7_set_type+0x19d>
mov    0x8(%rax),%edi
mov    $0x1,%ebp
mov    $0x1,%esi
call   1070 <ASN1_INTEGER_set@plt>
mov    0x18(%rbx),%rax
mov    0x8(%rax),%edi
mov    $0x1,%esi
call   1070 <ASN1_INTEGER_set@plt>
test   %eax,%eax
je     133d <PKCS7_set_type+0x19d>
mov    $0x85,%edi
call   1040 <OBJ_nid2obj@plt>
mov    0x18(%rbx),%rcx
mov    (%rcx),%rcx
mov    %rax,(%rcx)
jmp    133f <PKCS7_set_type+0x19f>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
mov    0x2db5(%rip),%rax
mov    (%rax),%esi
call   1090 <PKCS7err@plt>
jmp    133d <PKCS7_set_type+0x19d>
mov    %rax,0x30(%rbx)
xor    %eax,%eax
call   10a0 <PKCS7_SIGNED_new@plt>
mov    %rax,0x28(%rbx)
test   %rax,%rax
je     133d <PKCS7_set_type+0x19d>
mov    (%rax),%edi
mov    $0x1,%ebp
mov    $0x1,%esi
call   1070 <ASN1_INTEGER_set@plt>
test   %eax,%eax
jne    133f <PKCS7_set_type+0x19f>
mov    0x28(%rbx),%rdi
call   10c0 <PKCS7_SIGNED_free@plt>
movq   $0x0,0x28(%rbx)
jmp    133d <PKCS7_set_type+0x19d>
mov    %rax,0x30(%rbx)
xor    %eax,%eax
call   1060 <PKCS7_ENVELOPE_new@plt>
mov    %rax,0x10(%rbx)
test   %rax,%rax
je     133d <PKCS7_set_type+0x19d>
mov    0x8(%rax),%edi
xor    %esi,%esi
call   1070 <ASN1_INTEGER_set@plt>
test   %eax,%eax
je     133d <PKCS7_set_type+0x19d>
mov    $0x85,%edi
call   1040 <OBJ_nid2obj@plt>
mov    0x10(%rbx),%rcx
jmp    12f0 <PKCS7_set_type+0x150>
mov    %rax,0x30(%rbx)
xor    %eax,%eax
call   1080 <PKCS7_ENCRYPT_new@plt>
mov    %rax,0x8(%rbx)
test   %rax,%rax
je     133d <PKCS7_set_type+0x19d>
mov    0x8(%rax),%edi
xor    %esi,%esi
call   1070 <ASN1_INTEGER_set@plt>
test   %eax,%eax
je     133d <PKCS7_set_type+0x19d>
mov    $0x85,%edi
call   1040 <OBJ_nid2obj@plt>
mov    0x8(%rbx),%rcx
mov    (%rcx),%rcx
mov    %rax,(%rcx)
mov    $0x1,%ebp
jmp    133f <PKCS7_set_type+0x19f>
mov    %rax,0x30(%rbx)
xor    %eax,%eax
call   1050 <PKCS7_DIGEST_new@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     133d <PKCS7_set_type+0x19d>
mov    (%rax),%edi
xor    %esi,%esi
call   1070 <ASN1_INTEGER_set@plt>
mov    $0x1,%ebp
test   %eax,%eax
jne    133f <PKCS7_set_type+0x19f>
jmp    133d <PKCS7_set_type+0x19d>
mov    %rax,0x30(%rbx)
xor    %eax,%eax
call   10b0 <M_ASN1_OCTET_STRING_new@plt>
mov    %rax,0x20(%rbx)
mov    $0x1,%ebp
test   %rax,%rax
jne    133f <PKCS7_set_type+0x19f>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_20__ = type { %struct.TYPE_19__, i32* }
%struct.TYPE_19__ = type { %struct.TYPE_15__*, %struct.TYPE_14__*, %struct.TYPE_13__*, %struct.TYPE_21__*, i32*, %struct.TYPE_22__* }
%struct.TYPE_15__ = type { i32 }
%struct.TYPE_14__ = type { %struct.TYPE_18__*, i32 }
%struct.TYPE_18__ = type { i8* }
%struct.TYPE_13__ = type { %struct.TYPE_17__*, i32 }
%struct.TYPE_17__ = type { i8* }
%struct.TYPE_21__ = type { %struct.TYPE_16__*, i32 }
%struct.TYPE_16__ = type { i8* }
%struct.TYPE_22__ = type { i32 }
@PKCS7_F_PKCS7_SET_TYPE = global i32 0
@PKCS7_R_UNSUPPORTED_CONTENT_TYPE = global i32 0
define i32 @PKCS7_set_type(%struct.TYPE_20__* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_20__*
%5 = alloca i32
%6 = alloca i32*
store %struct.TYPE_20__* %0, %struct.TYPE_20__** %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
%8 = call i8* @OBJ_nid2obj(i32 %7)
%9 = bitcast i8* %8 to i32*
store i32* %9, i32** %6
%10 = load i32, i32* %5
switch i32 %10, label %166 [
i32 129, label %11
i32 133, label %40
i32 128, label %51
i32 130, label %87
i32 131, label %116
i32 132, label %145
]
11: ; preds = %2
%12 = load i32*, i32** %6
%13 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%14 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %13, i32 0, i32 1
store i32* %12, i32** %14
%15 = call %struct.TYPE_22__* (...) @PKCS7_SIGNED_new()
%16 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%17 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %16, i32 0, i32 0
%18 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %17, i32 0, i32 5
store %struct.TYPE_22__* %15, %struct.TYPE_22__** %18
%19 = icmp eq %struct.TYPE_22__* %15, null
br i1 %19, label %20, label %21
20: ; preds = %11
br label %171
21: ; preds = %11
%22 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%23 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %22, i32 0, i32 0
%24 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %23, i32 0, i32 5
%25 = load %struct.TYPE_22__*, %struct.TYPE_22__** %24
%26 = getelementptr inbounds %struct.TYPE_22__, %struct.TYPE_22__* %25, i32 0, i32 0
%27 = load i32, i32* %26
%28 = call i32 @ASN1_INTEGER_set(i32 %27, i32 1)
%29 = icmp ne i32 %28, 0
br i1 %29, label %39, label %30
30: ; preds = %21
%31 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%32 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %31, i32 0, i32 0
%33 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %32, i32 0, i32 5
%34 = load %struct.TYPE_22__*, %struct.TYPE_22__** %33
%35 = call i32 @PKCS7_SIGNED_free(%struct.TYPE_22__* %34)
%36 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%37 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %36, i32 0, i32 0
%38 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %37, i32 0, i32 5
store %struct.TYPE_22__* null, %struct.TYPE_22__** %38
br label %171
39: ; preds = %21
br label %170
40: ; preds = %2
%41 = load i32*, i32** %6
%42 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%43 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %42, i32 0, i32 1
store i32* %41, i32** %43
%44 = call i32* (...) @M_ASN1_OCTET_STRING_new()
%45 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%46 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %45, i32 0, i32 0
%47 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %46, i32 0, i32 4
store i32* %44, i32** %47
%48 = icmp eq i32* %44, null
br i1 %48, label %49, label %50
49: ; preds = %40
br label %171
50: ; preds = %40
br label %170
51: ; preds = %2
%52 = load i32*, i32** %6
%53 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%54 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %53, i32 0, i32 1
store i32* %52, i32** %54
%55 = call %struct.TYPE_21__* (...) @PKCS7_SIGN_ENVELOPE_new()
%56 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%57 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %56, i32 0, i32 0
%58 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %57, i32 0, i32 3
store %struct.TYPE_21__* %55, %struct.TYPE_21__** %58
%59 = icmp eq %struct.TYPE_21__* %55, null
br i1 %59, label %60, label %61
60: ; preds = %51
br label %171
61: ; preds = %51
%62 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%63 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %62, i32 0, i32 0
%64 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %63, i32 0, i32 3
%65 = load %struct.TYPE_21__*, %struct.TYPE_21__** %64
%66 = getelementptr inbounds %struct.TYPE_21__, %struct.TYPE_21__* %65, i32 0, i32 1
%67 = load i32, i32* %66
%68 = call i32 @ASN1_INTEGER_set(i32 %67, i32 1)
%69 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%70 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %69, i32 0, i32 0
%71 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %70, i32 0, i32 3
%72 = load %struct.TYPE_21__*, %struct.TYPE_21__** %71
%73 = getelementptr inbounds %struct.TYPE_21__, %struct.TYPE_21__* %72, i32 0, i32 1
%74 = load i32, i32* %73
%75 = call i32 @ASN1_INTEGER_set(i32 %74, i32 1)
%76 = icmp ne i32 %75, 0
br i1 %76, label %78, label %77
77: ; preds = %61
br label %171
78: ; preds = %61
%79 = call i8* @OBJ_nid2obj(i32 133)
%80 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%81 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %80, i32 0, i32 0
%82 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %81, i32 0, i32 3
%83 = load %struct.TYPE_21__*, %struct.TYPE_21__** %82
%84 = getelementptr inbounds %struct.TYPE_21__, %struct.TYPE_21__* %83, i32 0, i32 0
%85 = load %struct.TYPE_16__*, %struct.TYPE_16__** %84
%86 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %85, i32 0, i32 0
store i8* %79, i8** %86
br label %170
87: ; preds = %2
%88 = load i32*, i32** %6
%89 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%90 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %89, i32 0, i32 1
store i32* %88, i32** %90
%91 = call %struct.TYPE_13__* (...) @PKCS7_ENVELOPE_new()
%92 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%93 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %92, i32 0, i32 0
%94 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %93, i32 0, i32 2
store %struct.TYPE_13__* %91, %struct.TYPE_13__** %94
%95 = icmp eq %struct.TYPE_13__* %91, null
br i1 %95, label %96, label %97
96: ; preds = %87
br label %171
97: ; preds = %87
%98 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%99 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %98, i32 0, i32 0
%100 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %99, i32 0, i32 2
%101 = load %struct.TYPE_13__*, %struct.TYPE_13__** %100
%102 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %101, i32 0, i32 1
%103 = load i32, i32* %102
%104 = call i32 @ASN1_INTEGER_set(i32 %103, i32 0)
%105 = icmp ne i32 %104, 0
br i1 %105, label %107, label %106
106: ; preds = %97
br label %171
107: ; preds = %97
%108 = call i8* @OBJ_nid2obj(i32 133)
%109 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%110 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %109, i32 0, i32 0
%111 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %110, i32 0, i32 2
%112 = load %struct.TYPE_13__*, %struct.TYPE_13__** %111
%113 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %112, i32 0, i32 0
%114 = load %struct.TYPE_17__*, %struct.TYPE_17__** %113
%115 = getelementptr inbounds %struct.TYPE_17__, %struct.TYPE_17__* %114, i32 0, i32 0
store i8* %108, i8** %115
br label %170
116: ; preds = %2
%117 = load i32*, i32** %6
%118 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%119 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %118, i32 0, i32 1
store i32* %117, i32** %119
%120 = call %struct.TYPE_14__* (...) @PKCS7_ENCRYPT_new()
%121 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%122 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %121, i32 0, i32 0
%123 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %122, i32 0, i32 1
store %struct.TYPE_14__* %120, %struct.TYPE_14__** %123
%124 = icmp eq %struct.TYPE_14__* %120, null
br i1 %124, label %125, label %126
125: ; preds = %116
br label %171
126: ; preds = %116
%127 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%128 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %127, i32 0, i32 0
%129 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %128, i32 0, i32 1
%130 = load %struct.TYPE_14__*, %struct.TYPE_14__** %129
%131 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %130, i32 0, i32 1
%132 = load i32, i32* %131
%133 = call i32 @ASN1_INTEGER_set(i32 %132, i32 0)
%134 = icmp ne i32 %133, 0
br i1 %134, label %136, label %135
135: ; preds = %126
br label %171
136: ; preds = %126
%137 = call i8* @OBJ_nid2obj(i32 133)
%138 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%139 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %138, i32 0, i32 0
%140 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %139, i32 0, i32 1
%141 = load %struct.TYPE_14__*, %struct.TYPE_14__** %140
%142 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %141, i32 0, i32 0
%143 = load %struct.TYPE_18__*, %struct.TYPE_18__** %142
%144 = getelementptr inbounds %struct.TYPE_18__, %struct.TYPE_18__* %143, i32 0, i32 0
store i8* %137, i8** %144
br label %170
145: ; preds = %2
%146 = load i32*, i32** %6
%147 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%148 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %147, i32 0, i32 1
store i32* %146, i32** %148
%149 = call %struct.TYPE_15__* (...) @PKCS7_DIGEST_new()
%150 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%151 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %150, i32 0, i32 0
%152 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %151, i32 0, i32 0
store %struct.TYPE_15__* %149, %struct.TYPE_15__** %152
%153 = icmp eq %struct.TYPE_15__* %149, null
br i1 %153, label %154, label %155
154: ; preds = %145
br label %171
155: ; preds = %145
%156 = load %struct.TYPE_20__*, %struct.TYPE_20__** %4
%157 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %156, i32 0, i32 0
%158 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %157, i32 0, i32 0
%159 = load %struct.TYPE_15__*, %struct.TYPE_15__** %158
%160 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %159, i32 0, i32 0
%161 = load i32, i32* %160
%162 = call i32 @ASN1_INTEGER_set(i32 %161, i32 0)
%163 = icmp ne i32 %162, 0
br i1 %163, label %165, label %164
164: ; preds = %155
br label %171
165: ; preds = %155
br label %170
166: ; preds = %2
%167 = load i32, i32* @PKCS7_F_PKCS7_SET_TYPE
%168 = load i32, i32* @PKCS7_R_UNSUPPORTED_CONTENT_TYPE
%169 = call i32 @PKCS7err(i32 %167, i32 %168)
br label %171
170: ; preds = %165, %136, %107, %78, %50, %39
store i32 1, i32* %3
br label %172
171: ; preds = %166, %164, %154, %135, %125, %106, %96, %77, %60, %49, %30, %20
store i32 0, i32* %3
br label %172
172: ; preds = %171, %170
%173 = load i32, i32* %3
ret i32 %173
}

LLVM IR (-O2):
%struct.TYPE_20__ = type { %struct.TYPE_19__, i32* }
%struct.TYPE_19__ = type { %struct.TYPE_15__*, %struct.TYPE_14__*, %struct.TYPE_13__*, %struct.TYPE_21__*, i32*, %struct.TYPE_22__* }
%struct.TYPE_15__ = type { i32 }
%struct.TYPE_14__ = type { %struct.TYPE_18__*, i32 }
%struct.TYPE_18__ = type { i8* }
%struct.TYPE_13__ = type { %struct.TYPE_17__*, i32 }
%struct.TYPE_17__ = type { i8* }
%struct.TYPE_21__ = type { %struct.TYPE_16__*, i32 }
%struct.TYPE_16__ = type { i8* }
%struct.TYPE_22__ = type { i32 }
@PKCS7_F_PKCS7_SET_TYPE = global i32 0
@PKCS7_R_UNSUPPORTED_CONTENT_TYPE = global i32 0
define i32 @PKCS7_set_type(%struct.TYPE_20__* nocapture %0, i32 %1) {
%3 = tail call i8* @OBJ_nid2obj(i32 %1)
switch i32 %1, label %90 [
i32 129, label %4
i32 133, label %18
i32 128, label %24
i32 130, label %45
i32 131, label %62
i32 132, label %79
]
4: ; preds = %2
%5 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %0, i64 0, i32 1
%6 = bitcast i32** %5 to i8**
store i8* %3, i8** %6
%7 = tail call %struct.TYPE_22__* (...) @PKCS7_SIGNED_new()
%8 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %0, i64 0, i32 0, i32 5
store %struct.TYPE_22__* %7, %struct.TYPE_22__** %8
%9 = icmp eq %struct.TYPE_22__* %7, null
br i1 %9, label %94, label %10
10: ; preds = %4
%11 = getelementptr inbounds %struct.TYPE_22__, %struct.TYPE_22__* %7, i64 0, i32 0
%12 = load i32, i32* %11
%13 = tail call i32 @ASN1_INTEGER_set(i32 %12, i32 1)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %95
15: ; preds = %10
%16 = load %struct.TYPE_22__*, %struct.TYPE_22__** %8
%17 = tail call i32 @PKCS7_SIGNED_free(%struct.TYPE_22__* %16)
store %struct.TYPE_22__* null, %struct.TYPE_22__** %8
br label %94
18: ; preds = %2
%19 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %0, i64 0, i32 1
%20 = bitcast i32** %19 to i8**
store i8* %3, i8** %20
%21 = tail call i32* (...) @M_ASN1_OCTET_STRING_new()
%22 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %0, i64 0, i32 0, i32 4
store i32* %21, i32** %22
%23 = icmp eq i32* %21, null
br i1 %23, label %94, label %95
24: ; preds = %2
%25 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %0, i64 0, i32 1
%26 = bitcast i32** %25 to i8**
store i8* %3, i8** %26
%27 = tail call %struct.TYPE_21__* (...) @PKCS7_SIGN_ENVELOPE_new()
%28 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %0, i64 0, i32 0, i32 3
store %struct.TYPE_21__* %27, %struct.TYPE_21__** %28
%29 = icmp eq %struct.TYPE_21__* %27, null
br i1 %29, label %94, label %30
30: ; preds = %24
%31 = getelementptr inbounds %struct.TYPE_21__, %struct.TYPE_21__* %27, i64 0, i32 1
%32 = load i32, i32* %31
%33 = tail call i32 @ASN1_INTEGER_set(i32 %32, i32 1)
%34 = load %struct.TYPE_21__*, %struct.TYPE_21__** %28
%35 = getelementptr inbounds %struct.TYPE_21__, %struct.TYPE_21__* %34, i64 0, i32 1
%36 = load i32, i32* %35
%37 = tail call i32 @ASN1_INTEGER_set(i32 %36, i32 1)
%38 = icmp eq i32 %37, 0
br i1 %38, label %94, label %39
39: ; preds = %30
%40 = tail call i8* @OBJ_nid2obj(i32 133)
%41 = load %struct.TYPE_21__*, %struct.TYPE_21__** %28
%42 = getelementptr inbounds %struct.TYPE_21__, %struct.TYPE_21__* %41, i64 0, i32 0
%43 = load %struct.TYPE_16__*, %struct.TYPE_16__** %42
%44 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %43, i64 0, i32 0
store i8* %40, i8** %44
br label %95
45: ; preds = %2
%46 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %0, i64 0, i32 1
%47 = bitcast i32** %46 to i8**
store i8* %3, i8** %47
%48 = tail call %struct.TYPE_13__* (...) @PKCS7_ENVELOPE_new()
%49 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %0, i64 0, i32 0, i32 2
store %struct.TYPE_13__* %48, %struct.TYPE_13__** %49
%50 = icmp eq %struct.TYPE_13__* %48, null
br i1 %50, label %94, label %51
51: ; preds = %45
%52 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %48, i64 0, i32 1
%53 = load i32, i32* %52
%54 = tail call i32 @ASN1_INTEGER_set(i32 %53, i32 0)
%55 = icmp eq i32 %54, 0
br i1 %55, label %94, label %56
56: ; preds = %51
%57 = tail call i8* @OBJ_nid2obj(i32 133)
%58 = load %struct.TYPE_13__*, %struct.TYPE_13__** %49
%59 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %58, i64 0, i32 0
%60 = load %struct.TYPE_17__*, %struct.TYPE_17__** %59
%61 = getelementptr inbounds %struct.TYPE_17__, %struct.TYPE_17__* %60, i64 0, i32 0
store i8* %57, i8** %61
br label %95
62: ; preds = %2
%63 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %0, i64 0, i32 1
%64 = bitcast i32** %63 to i8**
store i8* %3, i8** %64
%65 = tail call %struct.TYPE_14__* (...) @PKCS7_ENCRYPT_new()
%66 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %0, i64 0, i32 0, i32 1
store %struct.TYPE_14__* %65, %struct.TYPE_14__** %66
%67 = icmp eq %struct.TYPE_14__* %65, null
br i1 %67, label %94, label %68
68: ; preds = %62
%69 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %65, i64 0, i32 1
%70 = load i32, i32* %69
%71 = tail call i32 @ASN1_INTEGER_set(i32 %70, i32 0)
%72 = icmp eq i32 %71, 0
br i1 %72, label %94, label %73
73: ; preds = %68
%74 = tail call i8* @OBJ_nid2obj(i32 133)
%75 = load %struct.TYPE_14__*, %struct.TYPE_14__** %66
%76 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %75, i64 0, i32 0
%77 = load %struct.TYPE_18__*, %struct.TYPE_18__** %76
%78 = getelementptr inbounds %struct.TYPE_18__, %struct.TYPE_18__* %77, i64 0, i32 0
store i8* %74, i8** %78
br label %95
79: ; preds = %2
%80 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %0, i64 0, i32 1
%81 = bitcast i32** %80 to i8**
store i8* %3, i8** %81
%82 = tail call %struct.TYPE_15__* (...) @PKCS7_DIGEST_new()
%83 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %0, i64 0, i32 0, i32 0
store %struct.TYPE_15__* %82, %struct.TYPE_15__** %83
%84 = icmp eq %struct.TYPE_15__* %82, null
br i1 %84, label %94, label %85
85: ; preds = %79
%86 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %82, i64 0, i32 0
%87 = load i32, i32* %86
%88 = tail call i32 @ASN1_INTEGER_set(i32 %87, i32 0)
%89 = icmp eq i32 %88, 0
br i1 %89, label %94, label %95
90: ; preds = %2
%91 = load i32, i32* @PKCS7_F_PKCS7_SET_TYPE
%92 = load i32, i32* @PKCS7_R_UNSUPPORTED_CONTENT_TYPE
%93 = tail call i32 @PKCS7err(i32 %91, i32 %92)
br label %94
94: ; preds = %85, %79, %68, %62, %51, %45, %30, %24, %18, %4, %90, %15
br label %95
95: ; preds = %39, %56, %73, %10, %18, %85, %94
%96 = phi i32 [ 0, %94 ], [ 1, %85 ], [ 1, %18 ], [ 1, %10 ], [ 1, %73 ], [ 1, %56 ], [ 1, %39 ]
ret i32 %96
}