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

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ ndef_bio;
  int /*<<< orphan*/ out;
  int /*<<< orphan*/ boundary;
};
typedef int /*<<< orphan*/ CMS_ContentInfo;
typedef int /*<<< orphan*/ ASN1_VALUE;
typedef TYPE_1__ ASN1_STREAM_ARG;
typedef int /*<<< orphan*/ ASN1_ITEM;

/* Variables and functions */
#define ASN1_OP_DETACHED_POST 131
#define ASN1_OP_DETACHED_PRE 130
#define ASN1_OP_STREAM_POST 129
#define ASN1_OP_STREAM_PRE 128
int /*<<< orphan*/ CMS_dataFinal(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ CMS_dataInit(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ CMS_stream(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int cms_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, void *exarg) {
  ASN1_STREAM_ARG *sarg = exarg;
  CMS_ContentInfo *cms = NULL;
  if (pval)
    cms = (CMS_ContentInfo *)*pval;
  else
    return 1;
  switch (operation) {
  case ASN1_OP_STREAM_PRE:
    if (CMS_stream(&sarg->boundary, cms) <= 0)
      return 0;
  case ASN1_OP_DETACHED_PRE:
    sarg->ndef_bio = CMS_dataInit(cms, sarg->out);
    if (!sarg->ndef_bio)
      return 0;
    break;
  case ASN1_OP_STREAM_POST:
  case ASN1_OP_DETACHED_POST:
    if (CMS_dataFinal(cms, sarg->ndef_bio) <= 0)
      return 0;
    break;
  }
  return 1;
}


x86 assembly (clang, -O0):
<cms_cb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1172 <cms_cb+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    117e <cms_cb+0x4e>
movl   $0x1,-0x4(%rbp)
jmp    1238 <cms_cb+0x108>
mov    -0x8(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x3,%eax
ja     1231 <cms_cb+0x101>
mov    -0x38(%rbp),%rax
lea    0xe62(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x28(%rbp),%rdi
add    $0x8,%rdi
mov    -0x30(%rbp),%rsi
call   1050 <CMS_stream@plt>
cmp    $0x0,%eax
jg     11cd <cms_cb+0x9d>
movl   $0x0,-0x4(%rbp)
jmp    1238 <cms_cb+0x108>
jmp    11d2 <cms_cb+0xa2>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%esi
call   1030 <CMS_dataInit@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1203 <cms_cb+0xd3>
movl   $0x0,-0x4(%rbp)
jmp    1238 <cms_cb+0x108>
jmp    1231 <cms_cb+0x101>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    (%rax),%esi
call   1040 <CMS_dataFinal@plt>
cmp    $0x0,%eax
jg     122c <cms_cb+0xfc>
movl   $0x0,-0x4(%rbp)
jmp    1238 <cms_cb+0x108>
jmp    1231 <cms_cb+0x101>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cms_cb>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%ebp
test   %rsi,%rsi
je     118f <cms_cb+0x5f>
add    $0xffffff80,%edi
cmp    $0x3,%edi
ja     118f <cms_cb+0x5f>
mov    %rcx,%rbx
mov    (%rsi),%r14
lea    0xead(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    (%rbx),%esi
mov    %r14,%rdi
call   1040 <CMS_dataFinal@plt>
test   %eax,%eax
jg     118f <cms_cb+0x5f>
jmp    118d <cms_cb+0x5d>
lea    0x8(%rbx),%rdi
mov    %r14,%rsi
call   1050 <CMS_stream@plt>
test   %eax,%eax
jle    118d <cms_cb+0x5d>
mov    0x4(%rbx),%esi
mov    %r14,%rdi
call   1030 <CMS_dataInit@plt>
mov    %eax,(%rbx)
test   %eax,%eax
jne    118f <cms_cb+0x5f>
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_2__ = type { i32, i32, i32 }
define i32 @cms_cb(i32 %0, i32** %1, i32* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32**
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca %struct.TYPE_2__*
%11 = alloca i32*
store i32 %0, i32* %6
store i32** %1, i32*** %7
store i32* %2, i32** %8
store i8* %3, i8** %9
%12 = load i8*, i8** %9
%13 = bitcast i8* %12 to %struct.TYPE_2__*
store %struct.TYPE_2__* %13, %struct.TYPE_2__** %10
store i32* null, i32** %11
%14 = load i32**, i32*** %7
%15 = icmp ne i32** %14, null
br i1 %15, label %16, label %19
16: ; preds = %4
%17 = load i32**, i32*** %7
%18 = load i32*, i32** %17
store i32* %18, i32** %11
br label %20
19: ; preds = %4
store i32 1, i32* %5
br label %54
20: ; preds = %16
%21 = load i32, i32* %6
switch i32 %21, label %53 [
i32 128, label %22
i32 130, label %30
i32 129, label %44
i32 131, label %44
]
22: ; preds = %20
%23 = load %struct.TYPE_2__*, %struct.TYPE_2__** %10
%24 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %23, i32 0, i32 2
%25 = load i32*, i32** %11
%26 = call i32 @CMS_stream(i32* %24, i32* %25)
%27 = icmp sle i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %22
store i32 0, i32* %5
br label %54
29: ; preds = %22
br label %30
30: ; preds = %20, %29
%31 = load i32*, i32** %11
%32 = load %struct.TYPE_2__*, %struct.TYPE_2__** %10
%33 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %32, i32 0, i32 1
%34 = load i32, i32* %33
%35 = call i32 @CMS_dataInit(i32* %31, i32 %34)
%36 = load %struct.TYPE_2__*, %struct.TYPE_2__** %10
%37 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %36, i32 0, i32 0
store i32 %35, i32* %37
%38 = load %struct.TYPE_2__*, %struct.TYPE_2__** %10
%39 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %38, i32 0, i32 0
%40 = load i32, i32* %39
%41 = icmp ne i32 %40, 0
br i1 %41, label %43, label %42
42: ; preds = %30
store i32 0, i32* %5
br label %54
43: ; preds = %30
br label %53
44: ; preds = %20, %20
%45 = load i32*, i32** %11
%46 = load %struct.TYPE_2__*, %struct.TYPE_2__** %10
%47 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %46, i32 0, i32 0
%48 = load i32, i32* %47
%49 = call i32 @CMS_dataFinal(i32* %45, i32 %48)
%50 = icmp sle i32 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %44
store i32 0, i32* %5
br label %54
52: ; preds = %44
br label %53
53: ; preds = %20, %52, %43
store i32 1, i32* %5
br label %54
54: ; preds = %53, %51, %42, %28, %19
%55 = load i32, i32* %5
ret i32 %55
}

LLVM IR (-O2):
define i32 @cms_cb(i32 %0, i32** %1, i32* nocapture readnone %2, i8* %3) {
%5 = icmp eq i32** %1, null
br i1 %5, label %26, label %6
6: ; preds = %4
%7 = load i32*, i32** %1
switch i32 %0, label %25 [
i32 128, label %8
i32 130, label %13
i32 129, label %20
i32 131, label %20
]
8: ; preds = %6
%9 = getelementptr inbounds i8, i8* %3, i64 8
%10 = bitcast i8* %9 to i32*
%11 = tail call i32 @CMS_stream(i32* %10, i32* %7)
%12 = icmp slt i32 %11, 1
br i1 %12, label %26, label %13
13: ; preds = %8, %6
%14 = getelementptr inbounds i8, i8* %3, i64 4
%15 = bitcast i8* %14 to i32*
%16 = load i32, i32* %15
%17 = tail call i32 @CMS_dataInit(i32* %7, i32 %16)
%18 = bitcast i8* %3 to i32*
store i32 %17, i32* %18
%19 = icmp eq i32 %17, 0
br i1 %19, label %26, label %25
20: ; preds = %6, %6
%21 = bitcast i8* %3 to i32*
%22 = load i32, i32* %21
%23 = tail call i32 @CMS_dataFinal(i32* %7, i32 %22)
%24 = icmp slt i32 %23, 1
br i1 %24, label %26, label %25
25: ; preds = %20, %13, %6
br label %26
26: ; preds = %20, %13, %8, %4, %25
%27 = phi i32 [ 1, %25 ], [ 1, %4 ], [ 0, %8 ], [ 0, %13 ], [ 0, %20 ]
ret i32 %27
}