#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*/ printf(char *, char *, ...);
void mp4tree_box_schm_print(const uint8_t *p, size_t len, int depth) {
  uint32_t flags = get_u24(p + 1);
  printf("%s  Version:       %u\n", indent(depth, 0), p[0]);
  printf("%s  Flags:         0x%.6x\n", indent(depth, 0), flags);
  printf("%s  Scheme Type:    %c%c%c%c\n", indent(depth, 0), p[4], p[5], p[6],
         p[7]);
  printf("%s  Scheme Version: %u\n", indent(depth, 0), get_u32(p + 8));
  if (flags & 0x1) {
    printf("%s  Scheme URI: TODO\n", indent(depth, 0));
  }
}


x86 assembly (clang, -O0):
<mp4tree_box_schm_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   1060 <get_u24@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1050 <indent@plt>
mov    %rax,%rsi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1050 <indent@plt>
mov    %rax,%rsi
mov    -0x18(%rbp),%edx
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1050 <indent@plt>
mov    %rax,%rsi
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%edx
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%r8d
mov    -0x8(%rbp),%rax
mov    0x1c(%rax),%r9d
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1050 <indent@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
call   1040 <get_u32@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1234 <mp4tree_box_schm_print+0xf4>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1050 <indent@plt>
mov    %rax,%rsi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp4tree_box_schm_print>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %rdi,%rbp
add    $0x4,%rdi
call   1060 <get_u24@plt>
mov    %eax,%r14d
mov    %r15d,%edi
xor    %esi,%esi
call   1050 <indent@plt>
mov    0x0(%rbp),%edx
lea    0xe93(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15d,%edi
xor    %esi,%esi
call   1050 <indent@plt>
lea    0xe8f(%rip),%rdi
mov    %rax,%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15d,%edi
xor    %esi,%esi
call   1050 <indent@plt>
mov    0x10(%rbp),%edx
mov    0x14(%rbp),%ecx
mov    0x18(%rbp),%r8d
mov    0x1c(%rbp),%r9d
lea    0xe7e(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15d,%edi
xor    %esi,%esi
call   1050 <indent@plt>
mov    %rax,%rbx
add    $0x20,%rbp
mov    %rbp,%rdi
call   1040 <get_u32@plt>
lea    0xe72(%rip),%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
test   $0x1,%r14b
jne    11fb <mp4tree_box_schm_print+0xbb>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15d,%edi
xor    %esi,%esi
call   1050 <indent@plt>
lea    0xe5c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [23 x i8] c"%s Version: %u\0A\00"
@.str.1 = [27 x i8] c"%s Flags: 0x%.6x\0A\00"
@.str.2 = [30 x i8] c"%s Scheme Type: %c%c%c%c\0A\00"
@.str.3 = [24 x i8] c"%s Scheme Version: %u\0A\00"
@.str.4 = [22 x i8] c"%s Scheme URI: TODO\0A\00"
define void @mp4tree_box_schm_print(i32* %0, i64 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i64 %1, i64* %5
store i32 %2, i32* %6
%8 = load i32*, i32** %4
%9 = getelementptr inbounds i32, i32* %8, i64 1
%10 = call i32 @get_u24(i32* %9)
store i32 %10, i32* %7
%11 = load i32, i32* %6
%12 = call i8* @indent(i32 %11, i32 0)
%13 = load i32*, i32** %4
%14 = getelementptr inbounds i32, i32* %13, i64 0
%15 = load i32, i32* %14
%16 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %12, i32 %15)
%17 = load i32, i32* %6
%18 = call i8* @indent(i32 %17, i32 0)
%19 = load i32, i32* %7
%20 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %18, i32 %19)
%21 = load i32, i32* %6
%22 = call i8* @indent(i32 %21, i32 0)
%23 = load i32*, i32** %4
%24 = getelementptr inbounds i32, i32* %23, i64 4
%25 = load i32, i32* %24
%26 = load i32*, i32** %4
%27 = getelementptr inbounds i32, i32* %26, i64 5
%28 = load i32, i32* %27
%29 = load i32*, i32** %4
%30 = getelementptr inbounds i32, i32* %29, i64 6
%31 = load i32, i32* %30
%32 = load i32*, i32** %4
%33 = getelementptr inbounds i32, i32* %32, i64 7
%34 = load i32, i32* %33
%35 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %22, i32 %25, i32 %28, i32 %31, i32 %34)
%36 = load i32, i32* %6
%37 = call i8* @indent(i32 %36, i32 0)
%38 = load i32*, i32** %4
%39 = getelementptr inbounds i32, i32* %38, i64 8
%40 = call i32 @get_u32(i32* %39)
%41 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %37, i32 %40)
%42 = load i32, i32* %7
%43 = and i32 %42, 1
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %3
%46 = load i32, i32* %6
%47 = call i8* @indent(i32 %46, i32 0)
%48 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %45, %3
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"%s Version: %u\0A\00"
@.str.1 = [27 x i8] c"%s Flags: 0x%.6x\0A\00"
@.str.2 = [30 x i8] c"%s Scheme Type: %c%c%c%c\0A\00"
@.str.3 = [24 x i8] c"%s Scheme Version: %u\0A\00"
@.str.4 = [22 x i8] c"%s Scheme URI: TODO\0A\00"
define void @mp4tree_box_schm_print(i32* %0, i64 %1, i32 %2) {
%4 = getelementptr inbounds i32, i32* %0, i64 1
%5 = tail call i32 @get_u24(i32* %4)
%6 = tail call i8* @indent(i32 %2, i32 0)
%7 = load i32, i32* %0
%8 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %6, i32 %7)
%9 = tail call i8* @indent(i32 %2, i32 0)
%10 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %9, i32 %5)
%11 = tail call i8* @indent(i32 %2, i32 0)
%12 = getelementptr inbounds i32, i32* %0, i64 4
%13 = load i32, i32* %12
%14 = getelementptr inbounds i32, i32* %0, i64 5
%15 = load i32, i32* %14
%16 = getelementptr inbounds i32, i32* %0, i64 6
%17 = load i32, i32* %16
%18 = getelementptr inbounds i32, i32* %0, i64 7
%19 = load i32, i32* %18
%20 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %11, i32 %13, i32 %15, i32 %17, i32 %19)
%21 = tail call i8* @indent(i32 %2, i32 0)
%22 = getelementptr inbounds i32, i32* %0, i64 8
%23 = tail call i32 @get_u32(i32* %22)
%24 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %21, i32 %23)
%25 = and i32 %5, 1
%26 = icmp eq i32 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %3
%28 = tail call i8* @indent(i32 %2, i32 0)
%29 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %27, %3
ret void
}