#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*/ uint8_t;
typedef int /*<<< orphan*/ CMS_ContentInfo;
typedef int /*<<< orphan*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ BIO_s_mem();
int /*<<< orphan*/ BIO_s_null();
scalar_t__ BIO_write(int /*<<< orphan*/ *, int /*<<< orphan*/ const *, size_t);
int /*<<< orphan*/ CMS_ContentInfo_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ ERR_clear_error();
int /*<<< orphan*/ OPENSSL_assert(int);
int /*<<< orphan*/ *d2i_CMS_bio(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ i2d_CMS_bio(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int FuzzerTestOneInput(const uint8_t *buf, size_t len) {
  CMS_ContentInfo *cms;
  BIO *in;
  if (len == 0)
    return 0;
  in = BIO_new(BIO_s_mem());
  OPENSSL_assert((size_t)BIO_write(in, buf, len) == len);
  cms = d2i_CMS_bio(in, NULL);
  if (cms != NULL) {
    BIO *out = BIO_new(BIO_s_null());
    i2d_CMS_bio(out, cms);
    BIO_free(out);
    CMS_ContentInfo_free(cms);
  }
  BIO_free(in);
  ERR_clear_error();
  return 0;
}


x86 assembly (clang, -O0):
<FuzzerTestOneInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11c7 <FuzzerTestOneInput+0x27>
movl   $0x0,-0x4(%rbp)
jmp    125f <FuzzerTestOneInput+0xbf>
mov    $0x0,%al
call   10b0 <BIO_s_mem@plt>
mov    %eax,%edi
call   1080 <BIO_new@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   10a0 <BIO_write@plt>
cmp    -0x18(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <OPENSSL_assert@plt>
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <d2i_CMS_bio@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1248 <FuzzerTestOneInput+0xa8>
mov    $0x0,%al
call   1060 <BIO_s_null@plt>
mov    %eax,%edi
call   1080 <BIO_new@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <i2d_CMS_bio@plt>
mov    -0x30(%rbp),%rdi
call   1090 <BIO_free@plt>
mov    -0x20(%rbp),%rdi
call   10c0 <CMS_ContentInfo_free@plt>
mov    -0x28(%rbp),%rdi
call   1090 <BIO_free@plt>
mov    $0x0,%al
call   1070 <ERR_clear_error@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FuzzerTestOneInput>:
test   %rsi,%rsi
je     1233 <FuzzerTestOneInput+0x93>
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r15
xor    %eax,%eax
call   10b0 <BIO_s_mem@plt>
mov    %eax,%edi
call   1080 <BIO_new@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   10a0 <BIO_write@plt>
xor    %edi,%edi
cmp    %rbx,%rax
sete   %dil
call   1040 <OPENSSL_assert@plt>
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <d2i_CMS_bio@plt>
test   %rax,%rax
je     121f <FuzzerTestOneInput+0x7f>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <BIO_s_null@plt>
mov    %eax,%edi
call   1080 <BIO_new@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <i2d_CMS_bio@plt>
mov    %r15,%rdi
call   1090 <BIO_free@plt>
mov    %rbx,%rdi
call   10c0 <CMS_ContentInfo_free@plt>
mov    %r14,%rdi
call   1090 <BIO_free@plt>
xor    %eax,%eax
call   1070 <ERR_clear_error@plt>
pop    %rbx
pop    %r14
pop    %r15
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @FuzzerTestOneInput(i32* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
store i32* %0, i32** %4
store i64 %1, i64* %5
%9 = load i64, i64* %5
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 0, i32* %3
br label %41
12: ; preds = %2
%13 = call i32 (...) @BIO_s_mem()
%14 = call i32* @BIO_new(i32 %13)
store i32* %14, i32** %7
%15 = load i32*, i32** %7
%16 = load i32*, i32** %4
%17 = load i64, i64* %5
%18 = call i64 @BIO_write(i32* %15, i32* %16, i64 %17)
%19 = load i64, i64* %5
%20 = icmp eq i64 %18, %19
%21 = zext i1 %20 to i32
%22 = call i32 @OPENSSL_assert(i32 %21)
%23 = load i32*, i32** %7
%24 = call i32* @d2i_CMS_bio(i32* %23, i32* null)
store i32* %24, i32** %6
%25 = load i32*, i32** %6
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %37
27: ; preds = %12
%28 = call i32 (...) @BIO_s_null()
%29 = call i32* @BIO_new(i32 %28)
store i32* %29, i32** %8
%30 = load i32*, i32** %8
%31 = load i32*, i32** %6
%32 = call i32 @i2d_CMS_bio(i32* %30, i32* %31)
%33 = load i32*, i32** %8
%34 = call i32 @BIO_free(i32* %33)
%35 = load i32*, i32** %6
%36 = call i32 @CMS_ContentInfo_free(i32* %35)
br label %37
37: ; preds = %27, %12
%38 = load i32*, i32** %7
%39 = call i32 @BIO_free(i32* %38)
%40 = call i32 (...) @ERR_clear_error()
store i32 0, i32* %3
br label %41
41: ; preds = %37, %11
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
define i32 @FuzzerTestOneInput(i32* %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %22, label %4
4: ; preds = %2
%5 = tail call i32 (...) @BIO_s_mem()
%6 = tail call i32* @BIO_new(i32 %5)
%7 = tail call i64 @BIO_write(i32* %6, i32* %0, i64 %1)
%8 = icmp eq i64 %7, %1
%9 = zext i1 %8 to i32
%10 = tail call i32 @OPENSSL_assert(i32 %9)
%11 = tail call i32* @d2i_CMS_bio(i32* %6, i32* null)
%12 = icmp eq i32* %11, null
br i1 %12, label %19, label %13
13: ; preds = %4
%14 = tail call i32 (...) @BIO_s_null()
%15 = tail call i32* @BIO_new(i32 %14)
%16 = tail call i32 @i2d_CMS_bio(i32* %15, i32* %11)
%17 = tail call i32 @BIO_free(i32* %15)
%18 = tail call i32 @CMS_ContentInfo_free(i32* %11)
br label %19
19: ; preds = %13, %4
%20 = tail call i32 @BIO_free(i32* %6)
%21 = tail call i32 (...) @ERR_clear_error()
br label %22
22: ; preds = %2, %19
ret i32 0
}