#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_table_print(char *, char *, int const *, int, int,
                                       int const, int);
int /*<<< orphan*/ printf(char *, char *, int const);
int /*<<< orphan*/ strcat(char *, char *);
void mp4tree_box_trun_print(const uint8_t *p, size_t len, int depth) {
  uint32_t flags = get_u24(p + 1);
  const uint32_t samples = get_u32(p + 4);
  char table_hdr[128] = {0};
  int table_fields = 0;
  printf("%s  Version:     %u\n", indent(depth, 0), p[0]);
  printf("%s  Flags:       0x%.6x\n", indent(depth, 0), flags);
  printf("%s  Samples:     %u\n", indent(depth, 0), samples);
  p += 8;
  if (flags & 1) {
    printf("%s  Data Offset: %u\n", indent(depth, 0), get_u32(p));
    p += 4;
  }
  if (flags & 0x100) {
    strcat(table_hdr, "Duration    ");
    table_fields++;
  }
  if (flags & 0x200) {
    strcat(table_hdr, "Size    ");
    table_fields++;
  }
  if (flags & 0x400) {
    strcat(table_hdr, "Flags    ");
    table_fields++;
  }
  if (flags & 0x800) {
    strcat(table_hdr, "Composition-Time-Offset (CTS)");
    table_fields++;
  }
  mp4tree_table_print("Sample Table", table_hdr, p, 4, table_fields, samples,
                      depth);
}


x86 assembly (clang, -O0):
<mp4tree_box_trun_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
call   1080 <get_u24@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x10,%rdi
call   1050 <get_u32@plt>
mov    %eax,-0x1c(%rbp)
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1060 <memset@plt>
movl   $0x0,-0xa4(%rbp)
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1070 <indent@plt>
mov    %rax,%rsi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
lea    0xe23(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1070 <indent@plt>
mov    %rax,%rsi
mov    -0x18(%rbp),%edx
lea    0xe1c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1070 <indent@plt>
mov    %rax,%rsi
mov    -0x1c(%rbp),%edx
lea    0xe19(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1270 <mp4tree_box_trun_print+0x100>
mov    -0x14(%rbp),%edi
xor    %esi,%esi
call   1070 <indent@plt>
mov    %rax,-0xb0(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <get_u32@plt>
mov    -0xb0(%rbp),%rsi
mov    %eax,%edx
lea    0xde4(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%eax
and    $0x100,%eax
cmp    $0x0,%eax
je     12a3 <mp4tree_box_trun_print+0x133>
lea    -0xa0(%rbp),%rdi
lea    0xdc9(%rip),%rsi
call   1090 <strcat@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
mov    -0x18(%rbp),%eax
and    $0x200,%eax
cmp    $0x0,%eax
je     12d6 <mp4tree_box_trun_print+0x166>
lea    -0xa0(%rbp),%rdi
lea    0xda3(%rip),%rsi
call   1090 <strcat@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
mov    -0x18(%rbp),%eax
and    $0x400,%eax
cmp    $0x0,%eax
je     1309 <mp4tree_box_trun_print+0x199>
lea    -0xa0(%rbp),%rdi
lea    0xd79(%rip),%rsi
call   1090 <strcat@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
mov    -0x18(%rbp),%eax
and    $0x800,%eax
cmp    $0x0,%eax
je     133c <mp4tree_box_trun_print+0x1cc>
lea    -0xa0(%rbp),%rdi
lea    0xd50(%rip),%rsi
call   1090 <strcat@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
lea    -0xa0(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0xa4(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x14(%rbp),%eax
lea    0xd3a(%rip),%rdi
mov    $0x4,%ecx
mov    %eax,(%rsp)
call   1030 <mp4tree_table_print@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mp4tree_box_trun_print>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %edx,%r15d
mov    %rdi,%rbp
add    $0x4,%rdi
call   1070 <get_u24@plt>
mov    %eax,%ebx
lea    0x10(%rbp),%rdi
call   1050 <get_u32@plt>
mov    %eax,%r14d
xorps  %xmm0,%xmm0
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
xor    %r13d,%r13d
mov    %r15d,%edi
xor    %esi,%esi
call   1060 <indent@plt>
mov    0x0(%rbp),%edx
lea    0xe2d(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %r15d,%edi
xor    %esi,%esi
call   1060 <indent@plt>
lea    0xe29(%rip),%rdi
mov    %rax,%rsi
mov    %ebx,%edx
call   1040 <printf@plt>
mov    %r15d,%edi
xor    %esi,%esi
call   1060 <indent@plt>
lea    0xe27(%rip),%rdi
mov    %rax,%rsi
mov    %r14d,%edx
call   1040 <printf@plt>
lea    0x20(%rbp),%r12
test   $0x1,%bl
jne    1291 <mp4tree_box_trun_print+0x131>
test   $0x100,%ebx
jne    12d0 <mp4tree_box_trun_print+0x170>
test   $0x200,%ebx
jne    12f3 <mp4tree_box_trun_print+0x193>
test   $0x400,%ebx
jne    1314 <mp4tree_box_trun_print+0x1b4>
test   $0x800,%ebx
je     125c <mp4tree_box_trun_print+0xfc>
lea    0xe2a(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1080 <strcat@plt>
add    $0x1,%r13d
mov    %r15d,(%rsp)
lea    0xe2f(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %r12,%rdx
mov    $0x4,%ecx
mov    %r13d,%r8d
mov    %r14d,%r9d
call   1030 <mp4tree_table_print@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15d,%edi
xor    %esi,%esi
call   1060 <indent@plt>
mov    %r12,%rdi
mov    %r14d,%r12d
mov    %rax,%r14
call   1050 <get_u32@plt>
lea    0xd93(%rip),%rdi
mov    %r14,%rsi
mov    %r12d,%r14d
mov    %eax,%edx
call   1040 <printf@plt>
add    $0x30,%rbp
mov    %rbp,%r12
test   $0x100,%ebx
je     1227 <mp4tree_box_trun_print+0xc7>
lea    0xd81(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1080 <strcat@plt>
mov    $0x1,%r13d
test   $0x200,%ebx
je     1233 <mp4tree_box_trun_print+0xd3>
lea    0xd6b(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1080 <strcat@plt>
add    $0x1,%r13d
test   $0x400,%ebx
je     123f <mp4tree_box_trun_print+0xdf>
lea    0xd53(%rip),%rsi
lea    0x10(%rsp),%rdi
call   1080 <strcat@plt>
add    $0x1,%r13d
test   $0x800,%ebx
jne    1247 <mp4tree_box_trun_print+0xe7>
jmp    125c <mp4tree_box_trun_print+0xfc>

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 Samples: %u\0A\00"
@.str.3 = [21 x i8] c"%s Data Offset: %u\0A\00"
@.str.4 = [13 x i8] c"Duration \00"
@.str.5 = [9 x i8] c"Size \00"
@.str.6 = [10 x i8] c"Flags \00"
@.str.7 = [30 x i8] c"Composition-Time-Offset (CTS)\00"
@.str.8 = [13 x i8] c"Sample Table\00"
define void @mp4tree_box_trun_print(i32* %0, i64 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [128 x i8]
%10 = alloca i32
store i32* %0, i32** %4
store i64 %1, i64* %5
store i32 %2, i32* %6
%11 = load i32*, i32** %4
%12 = getelementptr inbounds i32, i32* %11, i64 1
%13 = call i32 @get_u24(i32* %12)
store i32 %13, i32* %7
%14 = load i32*, i32** %4
%15 = getelementptr inbounds i32, i32* %14, i64 4
%16 = call i32 @get_u32(i32* %15)
store i32 %16, i32* %8
%17 = bitcast [128 x i8]* %9 to i8*
store i32 0, i32* %10
%18 = load i32, i32* %6
%19 = call i8* @indent(i32 %18, i32 0)
%20 = load i32*, i32** %4
%21 = getelementptr inbounds i32, i32* %20, i64 0
%22 = load i32, i32* %21
%23 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %19, i32 %22)
%24 = load i32, i32* %6
%25 = call i8* @indent(i32 %24, i32 0)
%26 = load i32, i32* %7
%27 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %25, i32 %26)
%28 = load i32, i32* %6
%29 = call i8* @indent(i32 %28, i32 0)
%30 = load i32, i32* %8
%31 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %29, i32 %30)
%32 = load i32*, i32** %4
%33 = getelementptr inbounds i32, i32* %32, i64 8
store i32* %33, i32** %4
%34 = load i32, i32* %7
%35 = and i32 %34, 1
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %45
37: ; preds = %3
%38 = load i32, i32* %6
%39 = call i8* @indent(i32 %38, i32 0)
%40 = load i32*, i32** %4
%41 = call i32 @get_u32(i32* %40)
%42 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %39, i32 %41)
%43 = load i32*, i32** %4
%44 = getelementptr inbounds i32, i32* %43, i64 4
store i32* %44, i32** %4
br label %45
45: ; preds = %37, %3
%46 = load i32, i32* %7
%47 = and i32 %46, 256
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %45
%50 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%51 = call i32 @strcat(i8* %50, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%52 = load i32, i32* %10
%53 = add nsw i32 %52, 1
store i32 %53, i32* %10
br label %54
54: ; preds = %49, %45
%55 = load i32, i32* %7
%56 = and i32 %55, 512
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %63
58: ; preds = %54
%59 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%60 = call i32 @strcat(i8* %59, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%61 = load i32, i32* %10
%62 = add nsw i32 %61, 1
store i32 %62, i32* %10
br label %63
63: ; preds = %58, %54
%64 = load i32, i32* %7
%65 = and i32 %64, 1024
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %72
67: ; preds = %63
%68 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%69 = call i32 @strcat(i8* %68, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%70 = load i32, i32* %10
%71 = add nsw i32 %70, 1
store i32 %71, i32* %10
br label %72
72: ; preds = %67, %63
%73 = load i32, i32* %7
%74 = and i32 %73, 2048
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %81
76: ; preds = %72
%77 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%78 = call i32 @strcat(i8* %77, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%79 = load i32, i32* %10
%80 = add nsw i32 %79, 1
store i32 %80, i32* %10
br label %81
81: ; preds = %76, %72
%82 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%83 = load i32*, i32** %4
%84 = load i32, i32* %10
%85 = load i32, i32* %8
%86 = load i32, i32* %6
%87 = call i32 @mp4tree_table_print(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %82, i32* %83, i32 4, i32 %84, i32 %85, i32 %86)
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 Samples: %u\0A\00"
@.str.3 = [21 x i8] c"%s Data Offset: %u\0A\00"
@.str.4 = [13 x i8] c"Duration \00"
@.str.5 = [9 x i8] c"Size \00"
@.str.6 = [10 x i8] c"Flags \00"
@.str.7 = [30 x i8] c"Composition-Time-Offset (CTS)\00"
@.str.8 = [13 x i8] c"Sample Table\00"
define void @mp4tree_box_trun_print(i32* %0, i64 %1, i32 %2) {
%4 = alloca [128 x i8]
%5 = getelementptr inbounds i32, i32* %0, i64 1
%6 = tail call i32 @get_u24(i32* %5)
%7 = getelementptr inbounds i32, i32* %0, i64 4
%8 = tail call i32 @get_u32(i32* %7)
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%10 = tail call i8* @indent(i32 %2, i32 0)
%11 = load i32, i32* %0
%12 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %10, i32 %11)
%13 = tail call i8* @indent(i32 %2, i32 0)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %13, i32 %6)
%15 = tail call i8* @indent(i32 %2, i32 0)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %15, i32 %8)
%17 = getelementptr inbounds i32, i32* %0, i64 8
%18 = and i32 %6, 1
%19 = icmp eq i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %3
%21 = tail call i8* @indent(i32 %2, i32 0)
%22 = tail call i32 @get_u32(i32* %17)
%23 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %21, i32 %22)
%24 = getelementptr inbounds i32, i32* %0, i64 12
br label %25
25: ; preds = %20, %3
%26 = phi i32* [ %24, %20 ], [ %17, %3 ]
%27 = and i32 %6, 256
%28 = icmp eq i32 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %25
%30 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %29, %25
%32 = phi i32 [ 1, %29 ], [ 0, %25 ]
%33 = and i32 %6, 512
%34 = icmp eq i32 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %31
%36 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%37 = add nuw nsw i32 %32, 1
br label %38
38: ; preds = %35, %31
%39 = phi i32 [ %37, %35 ], [ %32, %31 ]
%40 = and i32 %6, 1024
%41 = icmp eq i32 %40, 0
br i1 %41, label %45, label %42
42: ; preds = %38
%43 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%44 = add nuw nsw i32 %39, 1
br label %45
45: ; preds = %42, %38
%46 = phi i32 [ %44, %42 ], [ %39, %38 ]
%47 = and i32 %6, 2048
%48 = icmp eq i32 %47, 0
br i1 %48, label %52, label %49
49: ; preds = %45
%50 = call i32 @strcat(i8* %9, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
%51 = add nuw nsw i32 %46, 1
br label %52
52: ; preds = %49, %45
%53 = phi i32 [ %51, %49 ], [ %46, %45 ]
%54 = call i32 @mp4tree_table_print(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %9, i32* %26, i32 4, i32 %53, i32 %8, i32 %2)
ret void
}