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

/* Variables and functions */
int /*<<< orphan*/ BIO_indent(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ BIO_printf(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ ssl_print_certificate(int /*<<< orphan*/ *, int,
                                         unsigned char const **, size_t *);
int ssl_print_certificates(BIO *bio, int indent, const unsigned char *msg,
                           size_t msglen) {
  size_t clen;
  if (msglen < 3)
    return 0;
  clen = (msg[0] << 16) | (msg[1] << 8) | msg[2];
  if (msglen != clen + 3)
    return 0;
  msg += 3;
  BIO_indent(bio, indent, 80);
  BIO_printf(bio, "certificate_list, length=%d\n", (int)clen);
  while (clen > 0) {
    if (!ssl_print_certificate(bio, indent + 2, &msg, &clen))
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<ssl_print_certificates>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x3,-0x28(%rbp)
jae    115e <ssl_print_certificates+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    121c <ssl_print_certificates+0xec>
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
shl    $0x10,%eax
mov    -0x20(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x20(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
or     %ecx,%eax
cltq
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
add    $0x3,%rcx
cmp    %rcx,%rax
je     11a6 <ssl_print_certificates+0x76>
movl   $0x0,-0x4(%rbp)
jmp    121c <ssl_print_certificates+0xec>
mov    -0x20(%rbp),%rax
add    $0x3,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x50,%edx
call   1030 <BIO_indent@plt>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    %eax,%edx
lea    0xe2c(%rip),%rsi
call   1050 <BIO_printf@plt>
cmpq   $0x0,-0x30(%rbp)
jbe    1215 <ssl_print_certificates+0xe5>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x2,%esi
lea    -0x20(%rbp),%rdx
lea    -0x30(%rbp),%rcx
call   1040 <ssl_print_certificate@plt>
cmp    $0x0,%eax
jne    1210 <ssl_print_certificates+0xe0>
movl   $0x0,-0x4(%rbp)
jmp    121c <ssl_print_certificates+0xec>
jmp    11d9 <ssl_print_certificates+0xa9>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssl_print_certificates>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %r14d,%r14d
cmp    $0x3,%rcx
jb     11d1 <ssl_print_certificates+0xa1>
mov    %esi,%ebp
movzbl (%rdx),%eax
shl    $0x10,%rax
movzbl 0x1(%rdx),%esi
shl    $0x8,%rsi
or     %rax,%rsi
movzbl 0x2(%rdx),%eax
lea    (%rsi,%rax,1),%r15
mov    %r15,(%rsp)
add    %rsi,%rax
add    $0x3,%rax
cmp    %rcx,%rax
jne    11d1 <ssl_print_certificates+0xa1>
mov    %rdi,%rbx
add    $0x3,%rdx
mov    %rdx,0x8(%rsp)
mov    %ebp,%esi
mov    $0x50,%edx
call   1030 <BIO_indent@plt>
lea    0xe6c(%rip),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
call   1050 <BIO_printf@plt>
test   %r15,%r15
je     11cb <ssl_print_certificates+0x9b>
add    $0x2,%ebp
lea    0x8(%rsp),%r15
mov    %rsp,%r12
nop
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15,%rdx
mov    %r12,%rcx
call   1040 <ssl_print_certificate@plt>
test   %eax,%eax
je     11d1 <ssl_print_certificates+0xa1>
cmpq   $0x0,(%rsp)
jne    11b0 <ssl_print_certificates+0x80>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"certificate_list, length=%d\0A\00"
define i32 @ssl_print_certificates(i32* %0, i32 %1, i8* %2, i64 %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
store i32* %0, i32** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i64 %3, i64* %9
%11 = load i64, i64* %9
%12 = icmp ult i64 %11, 3
br i1 %12, label %13, label %14
13: ; preds = %4
store i32 0, i32* %5
br label %59
14: ; preds = %4
%15 = load i8*, i8** %8
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = shl i32 %18, 16
%20 = load i8*, i8** %8
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = shl i32 %23, 8
%25 = or i32 %19, %24
%26 = load i8*, i8** %8
%27 = getelementptr inbounds i8, i8* %26, i64 2
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = or i32 %25, %29
%31 = sext i32 %30 to i64
store i64 %31, i64* %10
%32 = load i64, i64* %9
%33 = load i64, i64* %10
%34 = add i64 %33, 3
%35 = icmp ne i64 %32, %34
br i1 %35, label %36, label %37
36: ; preds = %14
store i32 0, i32* %5
br label %59
37: ; preds = %14
%38 = load i8*, i8** %8
%39 = getelementptr inbounds i8, i8* %38, i64 3
store i8* %39, i8** %8
%40 = load i32*, i32** %6
%41 = load i32, i32* %7
%42 = call i32 @BIO_indent(i32* %40, i32 %41, i32 80)
%43 = load i32*, i32** %6
%44 = load i64, i64* %10
%45 = trunc i64 %44 to i32
%46 = call i32 @BIO_printf(i32* %43, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %57, %37
%48 = load i64, i64* %10
%49 = icmp ugt i64 %48, 0
br i1 %49, label %50, label %58
50: ; preds = %47
%51 = load i32*, i32** %6
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 2
%54 = call i32 @ssl_print_certificate(i32* %51, i32 %53, i8** %8, i64* %10)
%55 = icmp ne i32 %54, 0
br i1 %55, label %57, label %56
56: ; preds = %50
store i32 0, i32* %5
br label %59
57: ; preds = %50
br label %47
58: ; preds = %47
store i32 1, i32* %5
br label %59
59: ; preds = %58, %56, %36, %13
%60 = load i32, i32* %5
ret i32 %60
}

LLVM IR (-O2):
@.str = [29 x i8] c"certificate_list, length=%d\0A\00"
define i32 @ssl_print_certificates(i32* %0, i32 %1, i8* %2, i64 %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = bitcast i64* %6 to i8*
%8 = icmp ult i64 %3, 3
br i1 %8, label %37, label %9
9: ; preds = %4
%10 = load i8, i8* %2
%11 = zext i8 %10 to i64
%12 = shl nuw nsw i64 %11, 16
%13 = getelementptr inbounds i8, i8* %2, i64 1
%14 = load i8, i8* %13
%15 = zext i8 %14 to i64
%16 = shl nuw nsw i64 %15, 8
%17 = or i64 %16, %12
%18 = getelementptr inbounds i8, i8* %2, i64 2
%19 = load i8, i8* %18
%20 = zext i8 %19 to i64
%21 = or i64 %17, %20
store i64 %21, i64* %6
%22 = add nuw nsw i64 %21, 3
%23 = icmp eq i64 %22, %3
br i1 %23, label %24, label %37
24: ; preds = %9
%25 = getelementptr inbounds i8, i8* %2, i64 3
store i8* %25, i8** %5
%26 = tail call i32 @BIO_indent(i32* %0, i32 %1, i32 80)
%27 = trunc i64 %21 to i32
%28 = tail call i32 @BIO_printf(i32* %0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = add nsw i32 %1, 2
%30 = icmp eq i64 %21, 0
br i1 %30, label %37, label %31
31: ; preds = %24, %34
%32 = call i32 @ssl_print_certificate(i32* %0, i32 %29, i8** %5, i64* %6)
%33 = icmp eq i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = load i64, i64* %6
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %31
37: ; preds = %31, %34, %24, %9, %4
%38 = phi i32 [ 0, %4 ], [ 0, %9 ], [ 1, %24 ], [ 1, %34 ], [ 0, %31 ]
ret i32 %38
}