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

/* Variables and functions */
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ BIO_s_null();
int /*<<< orphan*/ ERR_clear_error();
int /*<<< orphan*/ OPENSSL_free(unsigned char *);
int /*<<< orphan*/ X509_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ X509_issuer_and_serial_hash(int /*<<< orphan*/ *);
int /*<<< orphan*/ X509_print(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *d2i_X509(int /*<<< orphan*/ *, unsigned char const **,
                             size_t);
int /*<<< orphan*/ i2d_X509(int /*<<< orphan*/ *, unsigned char **);
int FuzzerTestOneInput(const uint8_t *buf, size_t len) {
  const unsigned char *p = buf;
  unsigned char *der = NULL;
  X509 *x509 = d2i_X509(NULL, &p, len);
  if (x509 != NULL) {
    BIO *bio = BIO_new(BIO_s_null());
    X509_print(bio, x509);
    BIO_free(bio);
    X509_issuer_and_serial_hash(x509);
    i2d_X509(x509, &der);
    OPENSSL_free(der);
    X509_free(x509);
  }
  ERR_clear_error();
  return 0;
}


x86 assembly (clang, -O0):
<FuzzerTestOneInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%edi
lea    -0x18(%rbp),%rsi
call   1090 <d2i_X509@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1230 <FuzzerTestOneInput+0x90>
mov    $0x0,%al
call   1040 <BIO_s_null@plt>
mov    %eax,%edi
call   1060 <BIO_new@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10c0 <X509_print@plt>
mov    -0x30(%rbp),%rdi
call   1070 <BIO_free@plt>
mov    -0x28(%rbp),%rdi
call   10b0 <X509_issuer_and_serial_hash@plt>
mov    -0x28(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <i2d_X509@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <OPENSSL_free@plt>
mov    -0x28(%rbp),%rdi
call   1080 <X509_free@plt>
mov    $0x0,%al
call   1050 <ERR_clear_error@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FuzzerTestOneInput>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rdx
mov    %rdi,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rsi
xor    %edi,%edi
call   1090 <d2i_X509@plt>
test   %rax,%rax
je     1217 <FuzzerTestOneInput+0x77>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <BIO_s_null@plt>
mov    %eax,%edi
call   1060 <BIO_new@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
call   10c0 <X509_print@plt>
mov    %r14,%rdi
call   1070 <BIO_free@plt>
mov    %rbx,%rdi
call   10b0 <X509_issuer_and_serial_hash@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <i2d_X509@plt>
mov    0x8(%rsp),%rdi
call   10a0 <OPENSSL_free@plt>
mov    %rbx,%rdi
call   1080 <X509_free@plt>
xor    %eax,%eax
call   1050 <ERR_clear_error@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @FuzzerTestOneInput(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
store i8* %0, i8** %3
store i64 %1, i64* %4
%9 = load i8*, i8** %3
store i8* %9, i8** %5
store i8* null, i8** %6
%10 = load i64, i64* %4
%11 = call i32* @d2i_X509(i32* null, i8** %5, i64 %10)
store i32* %11, i32** %7
%12 = load i32*, i32** %7
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %30
14: ; preds = %2
%15 = call i32 (...) @BIO_s_null()
%16 = call i32* @BIO_new(i32 %15)
store i32* %16, i32** %8
%17 = load i32*, i32** %8
%18 = load i32*, i32** %7
%19 = call i32 @X509_print(i32* %17, i32* %18)
%20 = load i32*, i32** %8
%21 = call i32 @BIO_free(i32* %20)
%22 = load i32*, i32** %7
%23 = call i32 @X509_issuer_and_serial_hash(i32* %22)
%24 = load i32*, i32** %7
%25 = call i32 @i2d_X509(i32* %24, i8** %6)
%26 = load i8*, i8** %6
%27 = call i32 @OPENSSL_free(i8* %26)
%28 = load i32*, i32** %7
%29 = call i32 @X509_free(i32* %28)
br label %30
30: ; preds = %14, %2
%31 = call i32 (...) @ERR_clear_error()
ret i32 0
}

LLVM IR (-O2):
define i32 @FuzzerTestOneInput(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = bitcast i8** %3 to i8*
store i8* %0, i8** %3
%6 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%7 = call i32* @d2i_X509(i32* null, i8** %3, i64 %1)
%8 = icmp eq i32* %7, null
br i1 %8, label %19, label %9
9: ; preds = %2
%10 = call i32 (...) @BIO_s_null()
%11 = call i32* @BIO_new(i32 %10)
%12 = call i32 @X509_print(i32* %11, i32* %7)
%13 = call i32 @BIO_free(i32* %11)
%14 = call i32 @X509_issuer_and_serial_hash(i32* %7)
%15 = call i32 @i2d_X509(i32* %7, i8** %4)
%16 = load i8*, i8** %4
%17 = call i32 @OPENSSL_free(i8* %16)
%18 = call i32 @X509_free(i32* %7)
br label %19
19: ; preds = %9, %2
%20 = call i32 (...) @ERR_clear_error()
ret i32 0
}