#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_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  unsigned char *data;
  int /*<<< orphan*/ flags;
};
typedef int /*<<< orphan*/ CMS_ContentInfo;
typedef TYPE_1__ ASN1_OCTET_STRING;

/* Variables and functions */
TYPE_1__ *ASN1_OCTET_STRING_new();
int /*<<< orphan*/ ASN1_STRING_FLAG_CONT;
int /*<<< orphan*/ ASN1_STRING_FLAG_NDEF;
int /*<<< orphan*/ CMS_F_CMS_STREAM;
TYPE_1__ **CMS_get0_content(int /*<<< orphan*/ *);
int /*<<< orphan*/ CMSerr(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ ERR_R_MALLOC_FAILURE;
int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms) {
  ASN1_OCTET_STRING **pos;
  pos = CMS_get0_content(cms);
  if (!pos)
    return 0;
  if (!*pos)
    *pos = ASN1_OCTET_STRING_new();
  if (*pos) {
    (*pos)->flags |= ASN1_STRING_FLAG_NDEF;
    (*pos)->flags &= ~ASN1_STRING_FLAG_CONT;
    *boundary = &(*pos)->data;
    return 1;
  }
  CMSerr(CMS_F_CMS_STREAM, ERR_R_MALLOC_FAILURE);
  return 0;
}


x86 assembly (clang, -O0):
<CMS_stream>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <CMS_get0_content@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1164 <CMS_stream+0x34>
movl   $0x0,-0x4(%rbp)
jmp    11f8 <CMS_stream+0xc8>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1183 <CMS_stream+0x53>
mov    $0x0,%al
call   1040 <ASN1_OCTET_STRING_new@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11da <CMS_stream+0xaa>
mov    0x2e40(%rip),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
or     0x8(%rax),%ecx
mov    %ecx,0x8(%rax)
mov    0x2e1a(%rip),%rax
mov    (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
and    0x8(%rax),%ecx
mov    %ecx,0x8(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    11f8 <CMS_stream+0xc8>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
mov    0x2dfe(%rip),%rax
mov    (%rax),%esi
call   1030 <CMSerr@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CMS_stream>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <CMS_get0_content@plt>
test   %rax,%rax
je     1186 <CMS_stream+0x56>
mov    %rax,%rbx
mov    (%rax),%rax
test   %rax,%rax
jne    1160 <CMS_stream+0x30>
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <ASN1_OCTET_STRING_new@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     118a <CMS_stream+0x5a>
mov    0x2e71(%rip),%rcx
mov    0x8(%rax),%edx
or     (%rcx),%edx
mov    0x2e55(%rip),%rcx
mov    (%rcx),%ecx
not    %ecx
and    %edx,%ecx
mov    %ecx,0x8(%rax)
mov    %rax,(%r14)
mov    $0x1,%ebp
jmp    11a1 <CMS_stream+0x71>
xor    %ebp,%ebp
jmp    11a1 <CMS_stream+0x71>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
mov    0x2e4e(%rip),%rax
mov    (%rax),%esi
call   1030 <CMSerr@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i8*, i32 }
@ASN1_STRING_FLAG_NDEF = global i32 0
@ASN1_STRING_FLAG_CONT = global i32 0
@CMS_F_CMS_STREAM = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
define i32 @CMS_stream(i8*** %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8***
%5 = alloca i32*
%6 = alloca %struct.TYPE_4__**
store i8*** %0, i8**** %4
store i32* %1, i32** %5
%7 = load i32*, i32** %5
%8 = call %struct.TYPE_4__** @CMS_get0_content(i32* %7)
store %struct.TYPE_4__** %8, %struct.TYPE_4__*** %6
%9 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %6
%10 = icmp ne %struct.TYPE_4__** %9, null
br i1 %10, label %12, label %11
11: ; preds = %2
store i32 0, i32* %3
br label %45
12: ; preds = %2
%13 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %6
%14 = load %struct.TYPE_4__*, %struct.TYPE_4__** %13
%15 = icmp ne %struct.TYPE_4__* %14, null
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = call %struct.TYPE_4__* (...) @ASN1_OCTET_STRING_new()
%18 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %6
store %struct.TYPE_4__* %17, %struct.TYPE_4__** %18
br label %19
19: ; preds = %16, %12
%20 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %6
%21 = load %struct.TYPE_4__*, %struct.TYPE_4__** %20
%22 = icmp ne %struct.TYPE_4__* %21, null
br i1 %22, label %23, label %41
23: ; preds = %19
%24 = load i32, i32* @ASN1_STRING_FLAG_NDEF
%25 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %6
%26 = load %struct.TYPE_4__*, %struct.TYPE_4__** %25
%27 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %26, i32 0, i32 1
%28 = load i32, i32* %27
%29 = or i32 %28, %24
store i32 %29, i32* %27
%30 = load i32, i32* @ASN1_STRING_FLAG_CONT
%31 = xor i32 %30, -1
%32 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %6
%33 = load %struct.TYPE_4__*, %struct.TYPE_4__** %32
%34 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %33, i32 0, i32 1
%35 = load i32, i32* %34
%36 = and i32 %35, %31
store i32 %36, i32* %34
%37 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %6
%38 = load %struct.TYPE_4__*, %struct.TYPE_4__** %37
%39 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %38, i32 0, i32 0
%40 = load i8***, i8**** %4
store i8** %39, i8*** %40
store i32 1, i32* %3
br label %45
41: ; preds = %19
%42 = load i32, i32* @CMS_F_CMS_STREAM
%43 = load i32, i32* @ERR_R_MALLOC_FAILURE
%44 = call i32 @CMSerr(i32 %42, i32 %43)
store i32 0, i32* %3
br label %45
45: ; preds = %41, %23, %11
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i8*, i32 }
@ASN1_STRING_FLAG_NDEF = global i32 0
@ASN1_STRING_FLAG_CONT = global i32 0
@CMS_F_CMS_STREAM = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
define i32 @CMS_stream(i8*** nocapture writeonly %0, i32* %1) {
%3 = tail call %struct.TYPE_4__** @CMS_get0_content(i32* %1)
%4 = icmp eq %struct.TYPE_4__** %3, null
br i1 %4, label %25, label %5
5: ; preds = %2
%6 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
%7 = icmp eq %struct.TYPE_4__* %6, null
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = tail call %struct.TYPE_4__* (...) @ASN1_OCTET_STRING_new()
store %struct.TYPE_4__* %9, %struct.TYPE_4__** %3
%10 = icmp eq %struct.TYPE_4__* %9, null
br i1 %10, label %21, label %11
11: ; preds = %5, %8
%12 = phi %struct.TYPE_4__* [ %9, %8 ], [ %6, %5 ]
%13 = load i32, i32* @ASN1_STRING_FLAG_NDEF
%14 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %12, i64 0, i32 1
%15 = load i32, i32* %14
%16 = or i32 %15, %13
%17 = load i32, i32* @ASN1_STRING_FLAG_CONT
%18 = xor i32 %17, -1
%19 = and i32 %16, %18
store i32 %19, i32* %14
%20 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %12, i64 0, i32 0
store i8** %20, i8*** %0
br label %25
21: ; preds = %8
%22 = load i32, i32* @CMS_F_CMS_STREAM
%23 = load i32, i32* @ERR_R_MALLOC_FAILURE
%24 = tail call i32 @CMSerr(i32 %22, i32 %23)
br label %25
25: ; preds = %2, %21, %11
%26 = phi i32 [ 1, %11 ], [ 0, %21 ], [ 0, %2 ]
ret i32 %26
}