#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 uint8_t;
typedef int uint32_t;

/* Variables and functions */
int get_u24(int const *);
int get_u32(int const *);
char *indent(int, int /*<<< orphan*/);
int /*<<< orphan*/ mp4tree_print(int const *, size_t, int);
int /*<<< orphan*/ printf(char *, char *, int const);
void mp4tree_box_stsd_print(const uint8_t *p, size_t len, int depth) {
  uint32_t flags = get_u24(p + 1);
  const uint32_t num_entries = get_u32(p + 4);
  printf("%s  Version:     %u\n", indent(depth, 0), p[0]);
  printf("%s  Flags:       0x%.6x\n", indent(depth, 0), flags);
  printf("%s  Num Entries: %u\n", indent(depth, 0), num_entries);
  mp4tree_print(p + 8, len - 8, depth);
}


x86 assembly (clang, -O0):
<mp4tree_box_stsd_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
call   1070 <get_u24@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x10,%rdi
call   1040 <get_u32@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1050 <indent@plt>
mov    %rax,%rsi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
lea    0xe63(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1050 <indent@plt>
mov    %rax,%rsi
mov    -0x18(%rbp),%edx
lea    0xe5c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1050 <indent@plt>
mov    %rax,%rsi
mov    -0x1c(%rbp),%edx
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
mov    -0x10(%rbp),%rsi
sub    $0x8,%rsi
mov    -0x14(%rbp),%edx
call   1060 <mp4tree_print@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp4tree_box_stsd_print>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
add    $0x4,%rdi
call   1070 <get_u24@plt>
mov    %eax,%r12d
lea    0x10(%rbx),%rdi
call   1040 <get_u32@plt>
mov    %eax,%r15d
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <indent@plt>
mov    (%rbx),%edx
lea    0xe76(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <indent@plt>
lea    0xe73(%rip),%rdi
mov    %rax,%rsi
mov    %r12d,%edx
call   1030 <printf@plt>
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <indent@plt>
lea    0xe71(%rip),%rdi
mov    %rax,%rsi
mov    %r15d,%edx
call   1030 <printf@plt>
add    $0x20,%rbx
add    $0xfffffffffffffff8,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <mp4tree_print@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"%s Version: %u\0A\00"
@.str.1 = [25 x i8] c"%s Flags: 0x%.6x\0A\00"
@.str.2 = [21 x i8] c"%s Num Entries: %u\0A\00"
define void @mp4tree_box_stsd_print(i32* %0, i64 %1, i32 %2) {
%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
store i32 %2, i32* %6
%9 = load i32*, i32** %4
%10 = getelementptr inbounds i32, i32* %9, i64 1
%11 = call i32 @get_u24(i32* %10)
store i32 %11, i32* %7
%12 = load i32*, i32** %4
%13 = getelementptr inbounds i32, i32* %12, i64 4
%14 = call i32 @get_u32(i32* %13)
store i32 %14, i32* %8
%15 = load i32, i32* %6
%16 = call i8* @indent(i32 %15, i32 0)
%17 = load i32*, i32** %4
%18 = getelementptr inbounds i32, i32* %17, i64 0
%19 = load i32, i32* %18
%20 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %16, i32 %19)
%21 = load i32, i32* %6
%22 = call i8* @indent(i32 %21, i32 0)
%23 = load i32, i32* %7
%24 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %22, i32 %23)
%25 = load i32, i32* %6
%26 = call i8* @indent(i32 %25, i32 0)
%27 = load i32, i32* %8
%28 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %26, i32 %27)
%29 = load i32*, i32** %4
%30 = getelementptr inbounds i32, i32* %29, i64 8
%31 = load i64, i64* %5
%32 = sub i64 %31, 8
%33 = load i32, i32* %6
%34 = call i32 @mp4tree_print(i32* %30, i64 %32, i32 %33)
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"%s Version: %u\0A\00"
@.str.1 = [25 x i8] c"%s Flags: 0x%.6x\0A\00"
@.str.2 = [21 x i8] c"%s Num Entries: %u\0A\00"
define void @mp4tree_box_stsd_print(i32* %0, i64 %1, i32 %2) {
%4 = getelementptr inbounds i32, i32* %0, i64 1
%5 = tail call i32 @get_u24(i32* %4)
%6 = getelementptr inbounds i32, i32* %0, i64 4
%7 = tail call i32 @get_u32(i32* %6)
%8 = tail call i8* @indent(i32 %2, i32 0)
%9 = load i32, i32* %0
%10 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %9)
%11 = tail call i8* @indent(i32 %2, i32 0)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %11, i32 %5)
%13 = tail call i8* @indent(i32 %2, i32 0)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %13, i32 %7)
%15 = getelementptr inbounds i32, i32* %0, i64 8
%16 = add i64 %1, -8
%17 = tail call i32 @mp4tree_print(i32* %15, i64 %16, i32 %2)
ret void
}