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

/* Variables and functions */
char *get_box_desc(int /*<<< orphan*/ const *);
char *indent(int, int);
int /*<<< orphan*/ printf(char *, char *, ...);
void mp4tree_box_print(const uint8_t *type, size_t len, int depth) {
  const char *desc;
  printf("%s--- Length: %zu Type: %c%c%c%c\n", indent(depth, 1), len, type[0],
         type[1], type[2], type[3]);
  desc = get_box_desc(type);
  if (desc)
    printf("%s  Description: %s\n", indent(depth + 1, 0), desc);
}


x86 assembly (clang, -O0):
<mp4tree_box_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   1040 <indent@plt>
mov    %rax,%rsi
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%r9d
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%eax
lea    0xe85(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <get_box_desc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11bf <mp4tree_box_print+0x8f>
mov    -0x14(%rbp),%edi
add    $0x1,%edi
xor    %esi,%esi
call   1040 <indent@plt>
mov    %rax,%rsi
mov    -0x20(%rbp),%rdx
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp4tree_box_print>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %edx,%edi
mov    $0x1,%esi
call   1040 <indent@plt>
mov    (%rbx),%ecx
mov    0x4(%rbx),%r8d
mov    0x8(%rbx),%r9d
mov    0xc(%rbx),%edx
mov    %edx,(%rsp)
lea    0xe9d(%rip),%rdi
mov    %rax,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1050 <get_box_desc@plt>
test   %rax,%rax
je     11a8 <mp4tree_box_print+0x78>
mov    %rax,%rbx
add    $0x1,%ebp
mov    %ebp,%edi
xor    %esi,%esi
call   1040 <indent@plt>
lea    0xe8f(%rip),%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"%s--- Length: %zu Type: %c%c%c%c\0A\00"
@.str.1 = [21 x i8] c"%s Description: %s\0A\00"
define void @mp4tree_box_print(i32* %0, i64 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i8*
store i32* %0, i32** %4
store i64 %1, i64* %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = call i8* @indent(i32 %8, i32 1)
%10 = load i64, i64* %5
%11 = load i32*, i32** %4
%12 = getelementptr inbounds i32, i32* %11, i64 0
%13 = load i32, i32* %12
%14 = load i32*, i32** %4
%15 = getelementptr inbounds i32, i32* %14, i64 1
%16 = load i32, i32* %15
%17 = load i32*, i32** %4
%18 = getelementptr inbounds i32, i32* %17, i64 2
%19 = load i32, i32* %18
%20 = load i32*, i32** %4
%21 = getelementptr inbounds i32, i32* %20, i64 3
%22 = load i32, i32* %21
%23 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %9, i64 %10, i32 %13, i32 %16, i32 %19, i32 %22)
%24 = load i32*, i32** %4
%25 = call i8* @get_box_desc(i32* %24)
store i8* %25, i8** %7
%26 = load i8*, i8** %7
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %34
28: ; preds = %3
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
%31 = call i8* @indent(i32 %30, i32 0)
%32 = load i8*, i8** %7
%33 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %31, i8* %32)
br label %34
34: ; preds = %28, %3
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c"%s--- Length: %zu Type: %c%c%c%c\0A\00"
@.str.1 = [21 x i8] c"%s Description: %s\0A\00"
define void @mp4tree_box_print(i32* %0, i64 %1, i32 %2) {
%4 = tail call i8* @indent(i32 %2, i32 1)
%5 = load i32, i32* %0
%6 = getelementptr inbounds i32, i32* %0, i64 1
%7 = load i32, i32* %6
%8 = getelementptr inbounds i32, i32* %0, i64 2
%9 = load i32, i32* %8
%10 = getelementptr inbounds i32, i32* %0, i64 3
%11 = load i32, i32* %10
%12 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8* %4, i64 %1, i32 %5, i32 %7, i32 %9, i32 %11)
%13 = tail call i8* @get_box_desc(i32* %0)
%14 = icmp eq i8* %13, null
br i1 %14, label %19, label %15
15: ; preds = %3
%16 = add nsw i32 %2, 1
%17 = tail call i8* @indent(i32 %16, i32 0)
%18 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* %13)
br label %19
19: ; preds = %15, %3
ret void
}