#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 */

/* Type definitions */
typedef int /*<<< orphan*/ CMS_ContentInfo;
typedef int /*<<< orphan*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_free_all(int /*<<< orphan*/ *);
int /*<<< orphan*/ CMS_F_CMS_DATA;
int /*<<< orphan*/ CMS_R_TYPE_NOT_DATA;
int /*<<< orphan*/ *CMS_dataInit(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ CMS_get0_type(int /*<<< orphan*/ *);
int /*<<< orphan*/ CMSerr(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ NID_pkcs7_data;
scalar_t__ OBJ_obj2nid(int /*<<< orphan*/);
int cms_copy_content(int /*<<< orphan*/ *, int /*<<< orphan*/ *, unsigned int);
int CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags) {
  BIO *cont;
  int r;
  if (OBJ_obj2nid(CMS_get0_type(cms)) != NID_pkcs7_data) {
    CMSerr(CMS_F_CMS_DATA, CMS_R_TYPE_NOT_DATA);
    return 0;
  }
  cont = CMS_dataInit(cms, NULL);
  if (!cont)
    return 0;
  r = cms_copy_content(out, cont, flags);
  BIO_free_all(cont);
  return r;
}


x86 assembly (clang, -O0):
<CMS_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <CMS_get0_type@plt>
mov    %eax,%edi
call   1030 <OBJ_obj2nid@plt>
mov    0x2e5e(%rip),%rcx
cmp    (%rcx),%rax
je     11b6 <CMS_data+0x56>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
mov    0x2e2d(%rip),%rax
mov    (%rax),%esi
call   1040 <CMSerr@plt>
movl   $0x0,-0x4(%rbp)
jmp    1200 <CMS_data+0xa0>
mov    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <CMS_dataInit@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11de <CMS_data+0x7e>
movl   $0x0,-0x4(%rbp)
jmp    1200 <CMS_data+0xa0>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1060 <cms_copy_content@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1080 <BIO_free_all@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CMS_data>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1070 <CMS_get0_type@plt>
mov    %eax,%edi
call   1030 <OBJ_obj2nid@plt>
mov    0x2e68(%rip),%rcx
cmp    (%rcx),%rax
jne    11b3 <CMS_data+0x53>
mov    %rbp,%rdi
xor    %esi,%esi
call   1050 <CMS_dataInit@plt>
test   %rax,%rax
je     11ca <CMS_data+0x6a>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %r14d,%edx
call   1060 <cms_copy_content@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1080 <BIO_free_all@plt>
mov    %ebx,%eax
jmp    11cc <CMS_data+0x6c>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
call   1040 <CMSerr@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@NID_pkcs7_data = global i64 0
@CMS_F_CMS_DATA = global i32 0
@CMS_R_TYPE_NOT_DATA = global i32 0
define i32 @CMS_data(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
%10 = load i32*, i32** %5
%11 = call i32 @CMS_get0_type(i32* %10)
%12 = call i64 @OBJ_obj2nid(i32 %11)
%13 = load i64, i64* @NID_pkcs7_data
%14 = icmp ne i64 %12, %13
br i1 %14, label %15, label %19
15: ; preds = %3
%16 = load i32, i32* @CMS_F_CMS_DATA
%17 = load i32, i32* @CMS_R_TYPE_NOT_DATA
%18 = call i32 @CMSerr(i32 %16, i32 %17)
store i32 0, i32* %4
br label %33
19: ; preds = %3
%20 = load i32*, i32** %5
%21 = call i32* @CMS_dataInit(i32* %20, i32* null)
store i32* %21, i32** %8
%22 = load i32*, i32** %8
%23 = icmp ne i32* %22, null
br i1 %23, label %25, label %24
24: ; preds = %19
store i32 0, i32* %4
br label %33
25: ; preds = %19
%26 = load i32*, i32** %6
%27 = load i32*, i32** %8
%28 = load i32, i32* %7
%29 = call i32 @cms_copy_content(i32* %26, i32* %27, i32 %28)
store i32 %29, i32* %9
%30 = load i32*, i32** %8
%31 = call i32 @BIO_free_all(i32* %30)
%32 = load i32, i32* %9
store i32 %32, i32* %4
br label %33
33: ; preds = %25, %24, %15
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
@NID_pkcs7_data = global i64 0
@CMS_F_CMS_DATA = global i32 0
@CMS_R_TYPE_NOT_DATA = global i32 0
define i32 @CMS_data(i32* %0, i32* %1, i32 %2) {
%4 = tail call i32 @CMS_get0_type(i32* %0)
%5 = tail call i64 @OBJ_obj2nid(i32 %4)
%6 = load i64, i64* @NID_pkcs7_data
%7 = icmp eq i64 %5, %6
br i1 %7, label %12, label %8
8: ; preds = %3
%9 = load i32, i32* @CMS_F_CMS_DATA
%10 = load i32, i32* @CMS_R_TYPE_NOT_DATA
%11 = tail call i32 @CMSerr(i32 %9, i32 %10)
br label %18
12: ; preds = %3
%13 = tail call i32* @CMS_dataInit(i32* %0, i32* null)
%14 = icmp eq i32* %13, null
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i32 @cms_copy_content(i32* %1, i32* %13, i32 %2)
%17 = tail call i32 @BIO_free_all(i32* %13)
br label %18
18: ; preds = %12, %15, %8
%19 = phi i32 [ 0, %8 ], [ %16, %15 ], [ 0, %12 ]
ret i32 %19
}