#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*/ FILE;

/* Variables and functions */
scalar_t__ dumpsub_gab2(int /*<<< orphan*/ *, unsigned int);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
unsigned int getle(int /*<<< orphan*/ *);
int /*<<< orphan*/ skip(int /*<<< orphan*/ *, unsigned int);
int /*<<< orphan*/ stderr;
int stream_id(unsigned int);
void dump(FILE *f) {
  unsigned int id, len;
  int stream = 0;
  int substream = -2;
  while (1) {
    id = getle(f);
    len = getle(f);
    if (feof(f))
      break;
    if (id == ((('R')) | (('I') << 8) | (('F') << 16) | (('F') << 24)) ||
        id == ((('L')) | (('I') << 8) | (('S') << 16) | (('T') << 24))) {
      getle(f);
      continue;
    } else if (id == ((('s')) | (('t') << 8) | (('r') << 16) | (('h') << 24))) {
      id = getle(f);
      len -= 4;
      fprintf(stderr, "Stream %d is %c%c%c%c", stream, id, id >> 8, id >> 16,
              id >> 24);
      if (id == ((('t')) | (('x') << 8) | (('t') << 16) | (('s') << 24))) {
        substream = stream;
        fprintf(stderr, " (subtitle stream)");
      }
      fprintf(stderr, ".\n");
      stream++;
    } else if (stream_id(id) == substream) {
      unsigned int subid;
      subid = getle(f);
      len -= 4;
      if (subid != ((('G')) | (('A') << 8) | (('B') << 16) | (('2') << 24))) {
        fprintf(stderr, "Unknown subtitle chunk %c%c%c%c (%08x).\n", id,
                id >> 8, id >> 16, id >> 24, subid);
      } else {
        skip(f, 1);
        len -= 1;
        len -= dumpsub_gab2(f, len);
      }
    }
    len += len & 1;
    skip(f, len);
  }
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0xfffffffe,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <getle@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <getle@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%rax
je     11aa <dump+0x4a>
jmp    1342 <dump+0x1e2>
cmpl   $0x46464952,-0xc(%rbp)
je     11c4 <dump+0x64>
cmpl   $0x5453494c,-0xc(%rbp)
jne    11d2 <dump+0x72>
mov    -0x8(%rbp),%rdi
call   1080 <getle@plt>
jmp    117a <dump+0x1a>
cmpl   $0x68727473,-0xc(%rbp)
jne    1279 <dump+0x119>
mov    -0x8(%rbp),%rdi
call   1080 <getle@plt>
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x10(%rbp)
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0xc(%rbp),%r8d
shr    $0x8,%r8d
mov    -0xc(%rbp),%r9d
shr    $0x10,%r9d
mov    -0xc(%rbp),%eax
shr    $0x18,%eax
lea    0xde0(%rip),%rsi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1050 <fprintf@plt>
cmpl   $0x73747874,-0xc(%rbp)
jne    1254 <dump+0xf4>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
lea    0xdc9(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
lea    0xdeb(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1320 <dump+0x1c0>
mov    -0xc(%rbp),%edi
call   1070 <stream_id@plt>
cmp    -0x18(%rbp),%eax
jne    131b <dump+0x1bb>
mov    -0x8(%rbp),%rdi
call   1080 <getle@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x32424147,-0x1c(%rbp)
je     12e7 <dump+0x187>
mov    0x2d2d(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
shr    $0x8,%ecx
mov    -0xc(%rbp),%r8d
shr    $0x10,%r8d
mov    -0xc(%rbp),%r9d
shr    $0x18,%r9d
mov    -0x1c(%rbp),%eax
lea    0xd51(%rip),%rsi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1316 <dump+0x1b6>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1030 <skip@plt>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1040 <dumpsub_gab2@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%eax
sub    %rcx,%rax
mov    %eax,-0x10(%rbp)
jmp    131b <dump+0x1bb>
jmp    1320 <dump+0x1c0>
jmp    1325 <dump+0x1c5>
mov    -0x10(%rbp),%eax
and    $0x1,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1030 <skip@plt>
jmp    117a <dump+0x1a>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1080 <getle@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1080 <getle@plt>
mov    %eax,%r13d
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
je     119d <dump+0x3d>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0xfffffffe,%r12d
mov    0x2e36(%rip),%rbp
xor    %r14d,%r14d
nopl   (%rax)
cmp    $0x46464952,%r15d
je     11c2 <dump+0x62>
cmp    $0x5453494c,%r15d
jne    11ef <dump+0x8f>
mov    %rbx,%rdi
call   1080 <getle@plt>
mov    %rbx,%rdi
call   1080 <getle@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1080 <getle@plt>
mov    %eax,%r13d
mov    %rbx,%rdi
call   1060 <feof@plt>
test   %rax,%rax
je     11b0 <dump+0x50>
jmp    118e <dump+0x2e>
cmp    $0x68727473,%r15d
jne    1269 <dump+0x109>
mov    %rbx,%rdi
call   1080 <getle@plt>
mov    %rbp,%r15
mov    %eax,%ebp
mov    (%r15),%edi
mov    %eax,%r8d
shr    $0x8,%r8d
mov    %eax,%r9d
shr    $0x10,%r9d
shr    $0x18,%eax
mov    %eax,(%rsp)
lea    0xddd(%rip),%rsi
mov    %r14d,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
cmp    $0x73747874,%ebp
mov    %r15,%rbp
jne    124e <dump+0xee>
mov    0x0(%rbp),%edi
lea    0xdd2(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r14d,%r12d
add    $0xfffffffc,%r13d
mov    0x0(%rbp),%edi
lea    0xdf3(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x1,%r14d
jmp    12d5 <dump+0x175>
mov    %r15d,%edi
call   1070 <stream_id@plt>
cmp    %r12d,%eax
jne    12d5 <dump+0x175>
mov    %rbx,%rdi
call   1080 <getle@plt>
cmp    $0x32424147,%eax
jne    12a6 <dump+0x146>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <skip@plt>
add    $0xfffffffb,%r13d
mov    %rbx,%rdi
mov    %r13d,%esi
call   1040 <dumpsub_gab2@plt>
sub    %eax,%r13d
jmp    12d5 <dump+0x175>
add    $0xfffffffc,%r13d
mov    0x0(%rbp),%edi
mov    %r15d,%ecx
shr    $0x8,%ecx
mov    %r15d,%r8d
shr    $0x10,%r8d
mov    %r15d,%r9d
shr    $0x18,%r9d
mov    %eax,(%rsp)
lea    0xd5e(%rip),%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r13d,%esi
and    $0x1,%esi
add    %r13d,%esi
mov    %rbx,%rdi
call   1030 <skip@plt>
jmp    11ca <dump+0x6a>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Stream %d is %c%c%c%c\00"
@.str.1 = [19 x i8] c" (subtitle stream)\00"
@.str.2 = [3 x i8] c".\0A\00"
@.str.3 = [41 x i8] c"Unknown subtitle chunk %c%c%c%c (%08x).\0A\00"
define void @dump(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %5
store i32 -2, i32* %6
br label %8
8: ; preds = %1, %23, %93
%9 = load i32*, i32** %2
%10 = call i32 @getle(i32* %9)
store i32 %10, i32* %3
%11 = load i32*, i32** %2
%12 = call i32 @getle(i32* %11)
store i32 %12, i32* %4
%13 = load i32*, i32** %2
%14 = call i64 @feof(i32* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %8
br label %101
17: ; preds = %8
%18 = load i32, i32* %3
%19 = icmp eq i32 %18, 1179011410
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 1414744396
br i1 %22, label %23, label %26
23: ; preds = %20, %17
%24 = load i32*, i32** %2
%25 = call i32 @getle(i32* %24)
br label %8
26: ; preds = %20
%27 = load i32, i32* %3
%28 = icmp eq i32 %27, 1752331379
br i1 %28, label %29, label %55
29: ; preds = %26
%30 = load i32*, i32** %2
%31 = call i32 @getle(i32* %30)
store i32 %31, i32* %3
%32 = load i32, i32* %4
%33 = sub i32 %32, 4
store i32 %33, i32* %4
%34 = load i32, i32* @stderr
%35 = load i32, i32* %5
%36 = load i32, i32* %3
%37 = load i32, i32* %3
%38 = lshr i32 %37, 8
%39 = load i32, i32* %3
%40 = lshr i32 %39, 16
%41 = load i32, i32* %3
%42 = lshr i32 %41, 24
%43 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %35, i32 %36, i32 %38, i32 %40, i32 %42)
%44 = load i32, i32* %3
%45 = icmp eq i32 %44, 1937012852
br i1 %45, label %46, label %50
46: ; preds = %29
%47 = load i32, i32* %5
store i32 %47, i32* %6
%48 = load i32, i32* @stderr
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %50
50: ; preds = %46, %29
%51 = load i32, i32* @stderr
%52 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 1
store i32 %54, i32* %5
br label %92
55: ; preds = %26
%56 = load i32, i32* %3
%57 = call i32 @stream_id(i32 %56)
%58 = load i32, i32* %6
%59 = icmp eq i32 %57, %58
br i1 %59, label %60, label %91
60: ; preds = %55
%61 = load i32*, i32** %2
%62 = call i32 @getle(i32* %61)
store i32 %62, i32* %7
%63 = load i32, i32* %4
%64 = sub i32 %63, 4
store i32 %64, i32* %4
%65 = load i32, i32* %7
%66 = icmp ne i32 %65, 843202887
br i1 %66, label %67, label %78
67: ; preds = %60
%68 = load i32, i32* @stderr
%69 = load i32, i32* %3
%70 = load i32, i32* %3
%71 = lshr i32 %70, 8
%72 = load i32, i32* %3
%73 = lshr i32 %72, 16
%74 = load i32, i32* %3
%75 = lshr i32 %74, 24
%76 = load i32, i32* %7
%77 = call i32 (i32, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %69, i32 %71, i32 %73, i32 %75, i32 %76)
br label %90
78: ; preds = %60
%79 = load i32*, i32** %2
%80 = call i32 @skip(i32* %79, i32 1)
%81 = load i32, i32* %4
%82 = sub i32 %81, 1
store i32 %82, i32* %4
%83 = load i32*, i32** %2
%84 = load i32, i32* %4
%85 = call i64 @dumpsub_gab2(i32* %83, i32 %84)
%86 = load i32, i32* %4
%87 = zext i32 %86 to i64
%88 = sub nsw i64 %87, %85
%89 = trunc i64 %88 to i32
store i32 %89, i32* %4
br label %90
90: ; preds = %78, %67
br label %91
91: ; preds = %90, %55
br label %92
92: ; preds = %91, %50
br label %93
93: ; preds = %92
%94 = load i32, i32* %4
%95 = and i32 %94, 1
%96 = load i32, i32* %4
%97 = add i32 %96, %95
store i32 %97, i32* %4
%98 = load i32*, i32** %2
%99 = load i32, i32* %4
%100 = call i32 @skip(i32* %98, i32 %99)
br label %8
101: ; preds = %16
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Stream %d is %c%c%c%c\00"
@.str.1 = [19 x i8] c" (subtitle stream)\00"
@.str.2 = [3 x i8] c".\0A\00"
@.str.3 = [41 x i8] c"Unknown subtitle chunk %c%c%c%c (%08x).\0A\00"
define void @dump(i32* %0) {
%2 = tail call i32 @getle(i32* %0)
%3 = tail call i32 @getle(i32* %0)
%4 = tail call i64 @feof(i32* %0)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %67
6: ; preds = %1, %56
%7 = phi i32 [ %64, %56 ], [ %3, %1 ]
%8 = phi i32 [ %63, %56 ], [ %2, %1 ]
%9 = phi i32 [ %59, %56 ], [ -2, %1 ]
%10 = phi i32 [ %58, %56 ], [ 0, %1 ]
br label %11
11: ; preds = %6, %14
%12 = phi i32 [ %7, %6 ], [ %17, %14 ]
%13 = phi i32 [ %8, %6 ], [ %16, %14 ]
switch i32 %13, label %37 [
i32 1414744396, label %14
i32 1179011410, label %14
i32 1752331379, label %20
]
14: ; preds = %11, %11
%15 = tail call i32 @getle(i32* %0)
%16 = tail call i32 @getle(i32* %0)
%17 = tail call i32 @getle(i32* %0)
%18 = tail call i64 @feof(i32* %0)
%19 = icmp eq i64 %18, 0
br i1 %19, label %11, label %67
20: ; preds = %11
%21 = tail call i32 @getle(i32* %0)
%22 = add i32 %12, -4
%23 = load i32, i32* @stderr
%24 = lshr i32 %21, 8
%25 = lshr i32 %21, 16
%26 = lshr i32 %21, 24
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %21, i32 %24, i32 %25, i32 %26)
%28 = icmp eq i32 %21, 1937012852
br i1 %28, label %29, label %32
29: ; preds = %20
%30 = load i32, i32* @stderr
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %29, %20
%33 = phi i32 [ %10, %29 ], [ %9, %20 ]
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%36 = add nsw i32 %10, 1
br label %56
37: ; preds = %11
%38 = tail call i32 @stream_id(i32 %13)
%39 = icmp eq i32 %38, %9
br i1 %39, label %40, label %56
40: ; preds = %37
%41 = tail call i32 @getle(i32* %0)
%42 = icmp eq i32 %41, 843202887
br i1 %42, label %50, label %43
43: ; preds = %40
%44 = add i32 %12, -4
%45 = load i32, i32* @stderr
%46 = lshr i32 %13, 8
%47 = lshr i32 %13, 16
%48 = lshr i32 %13, 24
%49 = tail call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.3, i64 0, i64 0), i32 %13, i32 %46, i32 %47, i32 %48, i32 %41)
br label %56
50: ; preds = %40
%51 = tail call i32 @skip(i32* %0, i32 1)
%52 = add i32 %12, -5
%53 = tail call i64 @dumpsub_gab2(i32* %0, i32 %52)
%54 = trunc i64 %53 to i32
%55 = sub i32 %52, %54
br label %56
56: ; preds = %43, %50, %32, %37
%57 = phi i32 [ %22, %32 ], [ %12, %37 ], [ %44, %43 ], [ %55, %50 ]
%58 = phi i32 [ %36, %32 ], [ %10, %37 ], [ %10, %43 ], [ %10, %50 ]
%59 = phi i32 [ %33, %32 ], [ %9, %37 ], [ %9, %43 ], [ %9, %50 ]
%60 = and i32 %57, 1
%61 = add i32 %60, %57
%62 = tail call i32 @skip(i32* %0, i32 %61)
%63 = tail call i32 @getle(i32* %0)
%64 = tail call i32 @getle(i32* %0)
%65 = tail call i64 @feof(i32* %0)
%66 = icmp eq i64 %65, 0
br i1 %66, label %6, label %67
67: ; preds = %56, %14, %1
ret void
}