#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 *, unsigned int);
int /*<<< orphan*/ BIO_puts(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ ssl_print_hexbuf(int /*<<< orphan*/ *, int, char *, int,
                                    unsigned char const **, size_t *);
int ssl_print_ticket(BIO *bio, int indent, const unsigned char *msg,
                     size_t msglen) {
  unsigned int tick_life;
  if (msglen == 0) {
    BIO_indent(bio, indent + 2, 80);
    BIO_puts(bio, "No Ticket\n");
    return 1;
  }
  if (msglen < 4)
    return 0;
  tick_life = (msg[0] << 24) | (msg[1] << 16) | (msg[2] << 8) | msg[3];
  msglen -= 4;
  msg += 4;
  BIO_indent(bio, indent + 2, 80);
  BIO_printf(bio, "ticket_lifetime_hint=%u\n", tick_life);
  if (!ssl_print_hexbuf(bio, indent + 2, "ticket", 2, &msg, &msglen))
    return 0;
  if (msglen)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<ssl_print_ticket>:
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   $0x0,-0x28(%rbp)
jne    1192 <ssl_print_ticket+0x52>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x2,%esi
mov    $0x50,%edx
call   1030 <BIO_indent@plt>
mov    -0x10(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1060 <BIO_puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    126f <ssl_print_ticket+0x12f>
cmpq   $0x4,-0x28(%rbp)
jae    11a9 <ssl_print_ticket+0x69>
movl   $0x0,-0x4(%rbp)
jmp    126f <ssl_print_ticket+0x12f>
mov    -0x20(%rbp),%rax
movzbl (%rax),%eax
shl    $0x18,%eax
mov    -0x20(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x20(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x20(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
or     %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
sub    $0x4,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x2,%esi
mov    $0x50,%edx
call   1030 <BIO_indent@plt>
mov    -0x10(%rbp),%rdi
mov    -0x2c(%rbp),%edx
lea    0xdf7(%rip),%rsi
call   1040 <BIO_printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    $0x2,%esi
lea    0xdfa(%rip),%rdx
mov    $0x2,%ecx
lea    -0x20(%rbp),%r8
lea    -0x28(%rbp),%r9
call   1050 <ssl_print_hexbuf@plt>
cmp    $0x0,%eax
jne    1251 <ssl_print_ticket+0x111>
movl   $0x0,-0x4(%rbp)
jmp    126f <ssl_print_ticket+0x12f>
cmpq   $0x0,-0x28(%rbp)
je     1268 <ssl_print_ticket+0x128>
movl   $0x0,-0x4(%rbp)
jmp    126f <ssl_print_ticket+0x12f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssl_print_ticket>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
test   %rcx,%rcx
je     11d0 <ssl_print_ticket+0x90>
xor    %r14d,%r14d
cmp    $0x4,%rcx
jb     11f7 <ssl_print_ticket+0xb7>
mov    (%rdx),%r15d
bswap  %r15d
add    $0xfffffffffffffffc,%rcx
mov    %rcx,0x8(%rsp)
add    $0x4,%rdx
mov    %rdx,0x10(%rsp)
add    $0x2,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x50,%edx
call   1030 <BIO_indent@plt>
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
mov    %r15d,%edx
call   1040 <BIO_printf@plt>
lea    0xe80(%rip),%rdx
lea    0x10(%rsp),%r8
lea    0x8(%rsp),%r9
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x2,%ecx
call   1050 <ssl_print_hexbuf@plt>
test   %eax,%eax
je     11f7 <ssl_print_ticket+0xb7>
xor    %r14d,%r14d
cmpq   $0x0,0x8(%rsp)
sete   %r14b
jmp    11f7 <ssl_print_ticket+0xb7>
add    $0x2,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x50,%edx
call   1030 <BIO_indent@plt>
lea    0xe17(%rip),%rsi
mov    %rbx,%rdi
call   1060 <BIO_puts@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"No Ticket\0A\00"
@.str.1 = [25 x i8] c"ticket_lifetime_hint=%u\0A\00"
@.str.2 = [7 x i8] c"ticket\00"
define i32 @ssl_print_ticket(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 i32
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 eq i64 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %4
%14 = load i32*, i32** %6
%15 = load i32, i32* %7
%16 = add nsw i32 %15, 2
%17 = call i32 @BIO_indent(i32* %14, i32 %16, i32 80)
%18 = load i32*, i32** %6
%19 = call i32 @BIO_puts(i32* %18, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %5
br label %69
20: ; preds = %4
%21 = load i64, i64* %9
%22 = icmp ult i64 %21, 4
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 0, i32* %5
br label %69
24: ; preds = %20
%25 = load i8*, i8** %8
%26 = getelementptr inbounds i8, i8* %25, i64 0
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = shl i32 %28, 24
%30 = load i8*, i8** %8
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = shl i32 %33, 16
%35 = or i32 %29, %34
%36 = load i8*, i8** %8
%37 = getelementptr inbounds i8, i8* %36, i64 2
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = shl i32 %39, 8
%41 = or i32 %35, %40
%42 = load i8*, i8** %8
%43 = getelementptr inbounds i8, i8* %42, i64 3
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = or i32 %41, %45
store i32 %46, i32* %10
%47 = load i64, i64* %9
%48 = sub i64 %47, 4
store i64 %48, i64* %9
%49 = load i8*, i8** %8
%50 = getelementptr inbounds i8, i8* %49, i64 4
store i8* %50, i8** %8
%51 = load i32*, i32** %6
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 2
%54 = call i32 @BIO_indent(i32* %51, i32 %53, i32 80)
%55 = load i32*, i32** %6
%56 = load i32, i32* %10
%57 = call i32 @BIO_printf(i32* %55, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %56)
%58 = load i32*, i32** %6
%59 = load i32, i32* %7
%60 = add nsw i32 %59, 2
%61 = call i32 @ssl_print_hexbuf(i32* %58, i32 %60, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 2, i8** %8, i64* %9)
%62 = icmp ne i32 %61, 0
br i1 %62, label %64, label %63
63: ; preds = %24
store i32 0, i32* %5
br label %69
64: ; preds = %24
%65 = load i64, i64* %9
%66 = icmp ne i64 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %64
store i32 0, i32* %5
br label %69
68: ; preds = %64
store i32 1, i32* %5
br label %69
69: ; preds = %68, %67, %63, %23, %13
%70 = load i32, i32* %5
ret i32 %70
}

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