#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_1__ *digest;
  TYPE_2__ *sign;
};
struct TYPE_11__ {
  TYPE_3__ d;
  int /*<<< orphan*/ type;
};
struct TYPE_9__ {
  TYPE_4__ *contents;
};
struct TYPE_8__ {
  TYPE_4__ *contents;
};
typedef TYPE_4__ PKCS7;

/* Variables and functions */
#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
int OBJ_obj2nid(int /*<<< orphan*/);
int /*<<< orphan*/ PKCS7_R_UNSUPPORTED_CONTENT_TYPE;
int /*<<< orphan*/ PKCS7_free(TYPE_4__ *);
int /*<<< orphan*/ PKCS7error(int /*<<< orphan*/);
int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data) {
  int i;
  i = OBJ_obj2nid(p7->type);
  switch (i) {
  case NID_pkcs7_signed:
    if (p7->d.sign->contents != NULL)
      PKCS7_free(p7->d.sign->contents);
    p7->d.sign->contents = p7_data;
    break;
  case NID_pkcs7_digest:
    if (p7->d.digest->contents != NULL)
      PKCS7_free(p7->d.digest->contents);
    p7->d.digest->contents = p7_data;
    break;
  case NID_pkcs7_data:
  case NID_pkcs7_enveloped:
  case NID_pkcs7_signedAndEnveloped:
  case NID_pkcs7_encrypted:
  default:
    PKCS7error(PKCS7_R_UNSUPPORTED_CONTENT_TYPE);
    goto err;
  }
  return (1);
err:
  return (0);
}


x86 assembly (clang, -O0):
<PKCS7_set_content>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%edi
call   1030 <OBJ_obj2nid@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x80,%eax
je     121d <PKCS7_set_content+0xed>
jmp    1165 <PKCS7_set_content+0x35>
mov    -0x20(%rbp),%eax
sub    $0x81,%eax
je     11b4 <PKCS7_set_content+0x84>
jmp    1178 <PKCS7_set_content+0x48>
mov    -0x20(%rbp),%eax
add    $0xffffff7e,%eax
sub    $0x2,%eax
jb     121d <PKCS7_set_content+0xed>
jmp    118e <PKCS7_set_content+0x5e>
mov    -0x20(%rbp),%eax
sub    $0x84,%eax
je     11ea <PKCS7_set_content+0xba>
jmp    11a1 <PKCS7_set_content+0x71>
mov    -0x20(%rbp),%eax
sub    $0x85,%eax
je     121d <PKCS7_set_content+0xed>
jmp    1222 <PKCS7_set_content+0xf2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
cmpq   $0x0,(%rax)
je     11d6 <PKCS7_set_content+0xa6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rdi
call   1040 <PKCS7_free@plt>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rcx,(%rax)
jmp    1235 <PKCS7_set_content+0x105>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
cmpq   $0x0,(%rax)
je     120a <PKCS7_set_content+0xda>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rdi
call   1040 <PKCS7_free@plt>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rcx,(%rax)
jmp    1235 <PKCS7_set_content+0x105>
jmp    1222 <PKCS7_set_content+0xf2>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
call   1050 <PKCS7error@plt>
jmp    1241 <PKCS7_set_content+0x111>
movl   $0x1,-0x4(%rbp)
jmp    1248 <PKCS7_set_content+0x118>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PKCS7_set_content>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x10(%rdi),%edi
call   1030 <OBJ_obj2nid@plt>
cmp    $0x84,%eax
je     1167 <PKCS7_set_content+0x37>
cmp    $0x81,%eax
jne    1184 <PKCS7_set_content+0x54>
mov    0x8(%rbx),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     117a <PKCS7_set_content+0x4a>
call   1040 <PKCS7_free@plt>
mov    0x8(%rbx),%rax
jmp    117a <PKCS7_set_content+0x4a>
mov    (%rbx),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     117a <PKCS7_set_content+0x4a>
call   1040 <PKCS7_free@plt>
mov    (%rbx),%rax
mov    %r14,(%rax)
mov    $0x1,%eax
jmp    1194 <PKCS7_set_content+0x64>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
call   1050 <PKCS7error@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_11__ = type { %struct.TYPE_10__, i32 }
%struct.TYPE_10__ = type { %struct.TYPE_8__*, %struct.TYPE_9__* }
%struct.TYPE_8__ = type { %struct.TYPE_11__* }
%struct.TYPE_9__ = type { %struct.TYPE_11__* }
@PKCS7_R_UNSUPPORTED_CONTENT_TYPE = global i32 0
define i32 @PKCS7_set_content(%struct.TYPE_11__* %0, %struct.TYPE_11__* %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_11__*
%5 = alloca %struct.TYPE_11__*
%6 = alloca i32
store %struct.TYPE_11__* %0, %struct.TYPE_11__** %4
store %struct.TYPE_11__* %1, %struct.TYPE_11__** %5
%7 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%8 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %7, i32 0, i32 1
%9 = load i32, i32* %8
%10 = call i32 @OBJ_obj2nid(i32 %9)
store i32 %10, i32* %6
%11 = load i32, i32* %6
switch i32 %11, label %59 [
i32 129, label %12
i32 132, label %35
i32 133, label %58
i32 130, label %58
i32 128, label %58
i32 131, label %58
]
12: ; preds = %2
%13 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%14 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %13, i32 0, i32 0
%15 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %14, i32 0, i32 1
%16 = load %struct.TYPE_9__*, %struct.TYPE_9__** %15
%17 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %16, i32 0, i32 0
%18 = load %struct.TYPE_11__*, %struct.TYPE_11__** %17
%19 = icmp ne %struct.TYPE_11__* %18, null
br i1 %19, label %20, label %28
20: ; preds = %12
%21 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%22 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %21, i32 0, i32 0
%23 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %22, i32 0, i32 1
%24 = load %struct.TYPE_9__*, %struct.TYPE_9__** %23
%25 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %24, i32 0, i32 0
%26 = load %struct.TYPE_11__*, %struct.TYPE_11__** %25
%27 = call i32 @PKCS7_free(%struct.TYPE_11__* %26)
br label %28
28: ; preds = %20, %12
%29 = load %struct.TYPE_11__*, %struct.TYPE_11__** %5
%30 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%31 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %30, i32 0, i32 0
%32 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %31, i32 0, i32 1
%33 = load %struct.TYPE_9__*, %struct.TYPE_9__** %32
%34 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %33, i32 0, i32 0
store %struct.TYPE_11__* %29, %struct.TYPE_11__** %34
br label %62
35: ; preds = %2
%36 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%37 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %36, i32 0, i32 0
%38 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %37, i32 0, i32 0
%39 = load %struct.TYPE_8__*, %struct.TYPE_8__** %38
%40 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %39, i32 0, i32 0
%41 = load %struct.TYPE_11__*, %struct.TYPE_11__** %40
%42 = icmp ne %struct.TYPE_11__* %41, null
br i1 %42, label %43, label %51
43: ; preds = %35
%44 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%45 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %44, i32 0, i32 0
%46 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %45, i32 0, i32 0
%47 = load %struct.TYPE_8__*, %struct.TYPE_8__** %46
%48 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %47, i32 0, i32 0
%49 = load %struct.TYPE_11__*, %struct.TYPE_11__** %48
%50 = call i32 @PKCS7_free(%struct.TYPE_11__* %49)
br label %51
51: ; preds = %43, %35
%52 = load %struct.TYPE_11__*, %struct.TYPE_11__** %5
%53 = load %struct.TYPE_11__*, %struct.TYPE_11__** %4
%54 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %53, i32 0, i32 0
%55 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %54, i32 0, i32 0
%56 = load %struct.TYPE_8__*, %struct.TYPE_8__** %55
%57 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %56, i32 0, i32 0
store %struct.TYPE_11__* %52, %struct.TYPE_11__** %57
br label %62
58: ; preds = %2, %2, %2, %2
br label %59
59: ; preds = %2, %58
%60 = load i32, i32* @PKCS7_R_UNSUPPORTED_CONTENT_TYPE
%61 = call i32 @PKCS7error(i32 %60)
br label %63
62: ; preds = %51, %28
store i32 1, i32* %3
br label %64
63: ; preds = %59
store i32 0, i32* %3
br label %64
64: ; preds = %63, %62
%65 = load i32, i32* %3
ret i32 %65
}

LLVM IR (-O2):
%struct.TYPE_11__ = type { %struct.TYPE_10__, i32 }
%struct.TYPE_10__ = type { %struct.TYPE_8__*, %struct.TYPE_9__* }
%struct.TYPE_8__ = type { %struct.TYPE_11__* }
%struct.TYPE_9__ = type { %struct.TYPE_11__* }
@PKCS7_R_UNSUPPORTED_CONTENT_TYPE = global i32 0
define i32 @PKCS7_set_content(%struct.TYPE_11__* nocapture %0, %struct.TYPE_11__* %1) {
%3 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %0, i64 0, i32 1
%4 = load i32, i32* %3
%5 = tail call i32 @OBJ_obj2nid(i32 %4)
switch i32 %5, label %30 [
i32 129, label %6
i32 132, label %18
]
6: ; preds = %2
%7 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %0, i64 0, i32 0, i32 1
%8 = load %struct.TYPE_9__*, %struct.TYPE_9__** %7
%9 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %8, i64 0, i32 0
%10 = load %struct.TYPE_11__*, %struct.TYPE_11__** %9
%11 = icmp eq %struct.TYPE_11__* %10, null
br i1 %11, label %15, label %12
12: ; preds = %6
%13 = tail call i32 @PKCS7_free(%struct.TYPE_11__* %10)
%14 = load %struct.TYPE_9__*, %struct.TYPE_9__** %7
br label %15
15: ; preds = %12, %6
%16 = phi %struct.TYPE_9__* [ %14, %12 ], [ %8, %6 ]
%17 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %16, i64 0, i32 0
store %struct.TYPE_11__* %1, %struct.TYPE_11__** %17
br label %33
18: ; preds = %2
%19 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %0, i64 0, i32 0, i32 0
%20 = load %struct.TYPE_8__*, %struct.TYPE_8__** %19
%21 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %20, i64 0, i32 0
%22 = load %struct.TYPE_11__*, %struct.TYPE_11__** %21
%23 = icmp eq %struct.TYPE_11__* %22, null
br i1 %23, label %27, label %24
24: ; preds = %18
%25 = tail call i32 @PKCS7_free(%struct.TYPE_11__* %22)
%26 = load %struct.TYPE_8__*, %struct.TYPE_8__** %19
br label %27
27: ; preds = %24, %18
%28 = phi %struct.TYPE_8__* [ %26, %24 ], [ %20, %18 ]
%29 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %28, i64 0, i32 0
store %struct.TYPE_11__* %1, %struct.TYPE_11__** %29
br label %33
30: ; preds = %2
%31 = load i32, i32* @PKCS7_R_UNSUPPORTED_CONTENT_TYPE
%32 = tail call i32 @PKCS7error(i32 %31)
br label %33
33: ; preds = %15, %27, %30
%34 = phi i32 [ 0, %30 ], [ 1, %27 ], [ 1, %15 ]
ret i32 %34
}