#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;
typedef scalar_t__ uint32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int fread(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/ *);
scalar_t__ fseek(int /*<<< orphan*/ *, scalar_t__, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int get_be32(int /*<<< orphan*/ *);
int /*<<< orphan*/ memcmp(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ msg_error(char *);
int /*<<< orphan*/ msg_perror(char const *);
int /*<<< orphan*/ nrg_check_footer(int /*<<< orphan*/ *, scalar_t__ *);
int /*<<< orphan*/ nrg_parse_cuesx(int /*<<< orphan*/ *, char const *,
                                   scalar_t__, int);
int /*<<< orphan*/ nrg_parse_daoix(int /*<<< orphan*/ *, char const *,
                                   scalar_t__, int);
int nrg_parse_sinf(int /*<<< orphan*/ *, char const *, scalar_t__,
                   int /*<<< orphan*/, int);
bool nrg_parse_and_add_tracks(FILE *f, const char *fn) {
  uint32_t hdr_off;
  if (!nrg_check_footer(f, &hdr_off)) {
    msg_error("Failed to parse NRG5 footer\n");
    return false;
  }
  long file_end = ftell(f);
  if (file_end < 0) {
    msg_perror(fn);
    return false;
  }
  uint8_t sess_nr = 0;
  int prev_sess_tracks = 0;
  for (;;) {
    uint8_t chdr[8];
    if (fseek(f, hdr_off, SEEK_SET) < 0 || fread(chdr, 1, 8, f) != 8) {
      msg_perror(fn);
      return false;
    }
    if (!memcmp(chdr, "END!\0\0\0\0", 8))
      break;
    uint32_t chunklen = get_be32(chdr + 4);
    hdr_off += 8;
    if (hdr_off + chunklen >= (uint32_t)file_end) {
      msg_error("Corrupt NRG5 footer\n");
      return false;
    }
    switch (get_be32(chdr)) {
    case ((((uint32_t)'C') << 24) | (((uint32_t)'U') << 16) |
          (((uint32_t)'E') << 8) | 'S'):
      if (!nrg_parse_cuesx(f, fn, chunklen, false))
        return false;
      break;
    case ((((uint32_t)'D') << 24) | (((uint32_t)'A') << 16) |
          (((uint32_t)'O') << 8) | 'I'):
      if (!nrg_parse_daoix(f, fn, chunklen, false))
        return false;
      break;
    case ((((uint32_t)'C') << 24) | (((uint32_t)'U') << 16) |
          (((uint32_t)'E') << 8) | 'X'):
      if (!nrg_parse_cuesx(f, fn, chunklen, true))
        return false;
      break;
    case ((((uint32_t)'D') << 24) | (((uint32_t)'A') << 16) |
          (((uint32_t)'O') << 8) | 'X'):
      if (!nrg_parse_daoix(f, fn, chunklen, true))
        return false;
      break;
    case ((((uint32_t)'S') << 24) | (((uint32_t)'I') << 16) |
          (((uint32_t)'N') << 8) | 'F'): {
      int sess_tracks =
          nrg_parse_sinf(f, fn, chunklen, sess_nr, prev_sess_tracks);
      if (sess_tracks < 0)
        return false;
      prev_sess_tracks += sess_tracks;
      sess_nr++;
    } break;
    case ((((uint32_t)'E') << 24) | (((uint32_t)'T') << 16) |
          (((uint32_t)'N') << 8) | 'F'):
    case ((((uint32_t)'E') << 24) | (((uint32_t)'T') << 16) |
          (((uint32_t)'N') << 8) | '2'):
    case ((((uint32_t)'M') << 24) | (((uint32_t)'T') << 16) |
          (((uint32_t)'Y') << 8) | 'P'):
      break;
    case ((((uint32_t)'E') << 24) | (((uint32_t)'N') << 16) |
          (((uint32_t)'D') << 8) | '!'):
      msg_error("Broken END! chunk found\n");
      return false;
    }
    hdr_off += chunklen;
  }
  return true;
}


x86 assembly (clang, -O0):
<nrg_parse_and_add_tracks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   10a0 <nrg_check_footer@plt>
cmp    $0x0,%eax
jne    11ee <nrg_parse_and_add_tracks+0x3e>
lea    0xe23(%rip),%rdi
call   10b0 <msg_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    14d7 <nrg_parse_and_add_tracks+0x327>
mov    -0x10(%rbp),%rdi
call   1060 <ftell@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jge    121b <nrg_parse_and_add_tracks+0x6b>
mov    -0x18(%rbp),%rdi
call   10d0 <msg_perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    14d7 <nrg_parse_and_add_tracks+0x327>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x2da8(%rip),%rax
mov    (%rax),%edx
call   1090 <fseek@plt>
cmp    $0x0,%rax
jl     1269 <nrg_parse_and_add_tracks+0xb9>
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x8,%edx
call   1040 <fread@plt>
cmp    $0x8,%eax
je     127e <nrg_parse_and_add_tracks+0xce>
mov    -0x18(%rbp),%rdi
call   10d0 <msg_perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    14d7 <nrg_parse_and_add_tracks+0x327>
lea    -0x50(%rbp),%rdi
lea    0xdc2(%rip),%rsi
mov    $0x8,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%eax
jne    12a1 <nrg_parse_and_add_tracks+0xf1>
jmp    14d0 <nrg_parse_and_add_tracks+0x320>
lea    -0x50(%rbp),%rdi
add    $0x10,%rdi
call   1030 <get_be32@plt>
cltq
mov    %rax,-0x58(%rbp)
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    -0x58(%rbp),%rax
cmp    -0x28(%rbp),%rax
jl     12ea <nrg_parse_and_add_tracks+0x13a>
lea    0xd44(%rip),%rdi
call   10b0 <msg_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    14d7 <nrg_parse_and_add_tracks+0x327>
lea    -0x50(%rbp),%rdi
call   1030 <get_be32@plt>
mov    %eax,%ecx
mov    %ecx,-0x60(%rbp)
sub    $0x43554553,%eax
je     13a0 <nrg_parse_and_add_tracks+0x1f0>
jmp    1308 <nrg_parse_and_add_tracks+0x158>
mov    -0x60(%rbp),%eax
sub    $0x43554558,%eax
je     13fa <nrg_parse_and_add_tracks+0x24a>
jmp    131b <nrg_parse_and_add_tracks+0x16b>
mov    -0x60(%rbp),%eax
sub    $0x44414f49,%eax
je     13cd <nrg_parse_and_add_tracks+0x21d>
jmp    132e <nrg_parse_and_add_tracks+0x17e>
mov    -0x60(%rbp),%eax
sub    $0x44414f58,%eax
je     142a <nrg_parse_and_add_tracks+0x27a>
jmp    1341 <nrg_parse_and_add_tracks+0x191>
mov    -0x60(%rbp),%eax
sub    $0x454e4421,%eax
je     14a7 <nrg_parse_and_add_tracks+0x2f7>
jmp    1354 <nrg_parse_and_add_tracks+0x1a4>
mov    -0x60(%rbp),%eax
sub    $0x45544e32,%eax
je     14a2 <nrg_parse_and_add_tracks+0x2f2>
jmp    1367 <nrg_parse_and_add_tracks+0x1b7>
mov    -0x60(%rbp),%eax
sub    $0x45544e46,%eax
je     14a2 <nrg_parse_and_add_tracks+0x2f2>
jmp    137a <nrg_parse_and_add_tracks+0x1ca>
mov    -0x60(%rbp),%eax
sub    $0x4d545950,%eax
je     14a2 <nrg_parse_and_add_tracks+0x2f2>
jmp    138d <nrg_parse_and_add_tracks+0x1dd>
mov    -0x60(%rbp),%eax
sub    $0x53494e46,%eax
je     145a <nrg_parse_and_add_tracks+0x2aa>
jmp    14bf <nrg_parse_and_add_tracks+0x30f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x58(%rbp),%rdx
xor    %ecx,%ecx
call   1080 <nrg_parse_cuesx@plt>
cmp    $0x0,%eax
jne    13c8 <nrg_parse_and_add_tracks+0x218>
movl   $0x0,-0x4(%rbp)
jmp    14d7 <nrg_parse_and_add_tracks+0x327>
jmp    14bf <nrg_parse_and_add_tracks+0x30f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x58(%rbp),%rdx
xor    %ecx,%ecx
call   10c0 <nrg_parse_daoix@plt>
cmp    $0x0,%eax
jne    13f5 <nrg_parse_and_add_tracks+0x245>
movl   $0x0,-0x4(%rbp)
jmp    14d7 <nrg_parse_and_add_tracks+0x327>
jmp    14bf <nrg_parse_and_add_tracks+0x30f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    $0x1,%ecx
call   1080 <nrg_parse_cuesx@plt>
cmp    $0x0,%eax
jne    1425 <nrg_parse_and_add_tracks+0x275>
movl   $0x0,-0x4(%rbp)
jmp    14d7 <nrg_parse_and_add_tracks+0x327>
jmp    14bf <nrg_parse_and_add_tracks+0x30f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    $0x1,%ecx
call   10c0 <nrg_parse_daoix@plt>
cmp    $0x0,%eax
jne    1455 <nrg_parse_and_add_tracks+0x2a5>
movl   $0x0,-0x4(%rbp)
jmp    14d7 <nrg_parse_and_add_tracks+0x327>
jmp    14bf <nrg_parse_and_add_tracks+0x30f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    -0x30(%rbp),%r8d
call   1070 <nrg_parse_sinf@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
jge    148b <nrg_parse_and_add_tracks+0x2db>
movl   $0x0,-0x4(%rbp)
jmp    14d7 <nrg_parse_and_add_tracks+0x327>
mov    -0x5c(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    14bf <nrg_parse_and_add_tracks+0x30f>
jmp    14bf <nrg_parse_and_add_tracks+0x30f>
lea    0xb84(%rip),%rdi
call   10b0 <msg_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    14d7 <nrg_parse_and_add_tracks+0x327>
mov    -0x58(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1229 <nrg_parse_and_add_tracks+0x79>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nrg_parse_and_add_tracks>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rsi
call   10a0 <nrg_check_footer@plt>
test   %eax,%eax
je     121b <nrg_parse_and_add_tracks+0x6b>
mov    %rbx,%rdi
call   1060 <ftell@plt>
test   %rax,%rax
js     1389 <nrg_parse_and_add_tracks+0x1d9>
mov    %rax,%r15
mov    (%rsp),%rsi
mov    0x2df1(%rip),%r12
mov    (%r12),%edx
mov    %rbx,%rdi
call   1090 <fseek@plt>
test   %rax,%rax
js     1389 <nrg_parse_and_add_tracks+0x1d9>
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%rbp
movl   $0x0,0x8(%rsp)
jmp    1264 <nrg_parse_and_add_tracks+0xb4>
lea    0xdde(%rip),%rdi
call   10b0 <msg_error@plt>
jmp    1391 <nrg_parse_and_add_tracks+0x1e1>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
xor    %ecx,%ecx
call   1080 <nrg_parse_cuesx@plt>
test   %eax,%eax
je     1391 <nrg_parse_and_add_tracks+0x1e1>
add    (%rsp),%r13
mov    %r13,(%rsp)
mov    (%r12),%edx
mov    %rbx,%rdi
mov    %r13,%rsi
call   1090 <fseek@plt>
test   %rax,%rax
js     1389 <nrg_parse_and_add_tracks+0x1d9>
mov    %rbp,%rdi
mov    $0x1,%esi
mov    $0x8,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x8,%eax
jne    1389 <nrg_parse_and_add_tracks+0x1d9>
mov    %rbp,%rdi
lea    0xdbf(%rip),%rsi
mov    $0x8,%edx
call   1050 <memcmp@plt>
test   %eax,%eax
je     13a2 <nrg_parse_and_add_tracks+0x1f2>
lea    0x20(%rsp),%rdi
call   1030 <get_be32@plt>
movslq %eax,%r13
mov    (%rsp),%rax
lea    0x8(%rax),%rcx
mov    %rcx,(%rsp)
add    %r13,%rax
add    $0x8,%rax
cmp    %r15,%rax
jge    13a9 <nrg_parse_and_add_tracks+0x1f9>
mov    %rbp,%rdi
call   1030 <get_be32@plt>
cmp    $0x44414f57,%eax
jg     1310 <nrg_parse_and_add_tracks+0x160>
cmp    $0x43554553,%eax
je     122c <nrg_parse_and_add_tracks+0x7c>
cmp    $0x43554558,%eax
je     1347 <nrg_parse_and_add_tracks+0x197>
cmp    $0x44414f49,%eax
jne    1244 <nrg_parse_and_add_tracks+0x94>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
xor    %ecx,%ecx
call   10c0 <nrg_parse_daoix@plt>
jmp    123c <nrg_parse_and_add_tracks+0x8c>
nopl   0x0(%rax,%rax,1)
cmp    $0x44414f58,%eax
je     135a <nrg_parse_and_add_tracks+0x1aa>
cmp    $0x53494e46,%eax
jne    1372 <nrg_parse_and_add_tracks+0x1c2>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%r8d
call   1070 <nrg_parse_sinf@plt>
test   %eax,%eax
js     1391 <nrg_parse_and_add_tracks+0x1e1>
add    %eax,0xc(%rsp)
addl   $0x1,0x8(%rsp)
jmp    1244 <nrg_parse_and_add_tracks+0x94>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
mov    $0x1,%ecx
jmp    1237 <nrg_parse_and_add_tracks+0x87>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
mov    $0x1,%ecx
call   10c0 <nrg_parse_daoix@plt>
jmp    123c <nrg_parse_and_add_tracks+0x8c>
cmp    $0x454e4421,%eax
jne    1244 <nrg_parse_and_add_tracks+0x94>
lea    0xcae(%rip),%rdi
jmp    1222 <nrg_parse_and_add_tracks+0x72>
mov    %r14,%rdi
call   10d0 <msg_perror@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%eax
jmp    1393 <nrg_parse_and_add_tracks+0x1e3>
lea    0xc6d(%rip),%rdi
jmp    1222 <nrg_parse_and_add_tracks+0x72>

LLVM IR (-O0):
@.str = [29 x i8] c"Failed to parse NRG5 footer\0A\00"
@SEEK_SET = global i32 0
@.str.1 = [9 x i8] c"END!\00\00\00\00\00"
@.str.2 = [21 x i8] c"Corrupt NRG5 footer\0A\00"
@.str.3 = [25 x i8] c"Broken END! chunk found\0A\00"
define i32 @nrg_parse_and_add_tracks(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca [8 x i32]
%11 = alloca i64
%12 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
%13 = load i32*, i32** %4
%14 = call i32 @nrg_check_footer(i32* %13, i64* %6)
%15 = icmp ne i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %2
%17 = call i32 @msg_error(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %119
18: ; preds = %2
%19 = load i32*, i32** %4
%20 = call i64 @ftell(i32* %19)
store i64 %20, i64* %7
%21 = load i64, i64* %7
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = load i8*, i8** %5
%25 = call i32 @msg_perror(i8* %24)
store i32 0, i32* %3
br label %119
26: ; preds = %18
store i32 0, i32* %8
store i32 0, i32* %9
br label %27
27: ; preds = %114, %26
%28 = load i32*, i32** %4
%29 = load i64, i64* %6
%30 = load i32, i32* @SEEK_SET
%31 = call i64 @fseek(i32* %28, i64 %29, i32 %30)
%32 = icmp slt i64 %31, 0
br i1 %32, label %38, label %33
33: ; preds = %27
%34 = getelementptr inbounds [8 x i32], [8 x i32]* %10, i64 0, i64 0
%35 = load i32*, i32** %4
%36 = call i32 @fread(i32* %34, i32 1, i32 8, i32* %35)
%37 = icmp ne i32 %36, 8
br i1 %37, label %38, label %41
38: ; preds = %33, %27
%39 = load i8*, i8** %5
%40 = call i32 @msg_perror(i8* %39)
store i32 0, i32* %3
br label %119
41: ; preds = %33
%42 = getelementptr inbounds [8 x i32], [8 x i32]* %10, i64 0, i64 0
%43 = call i32 @memcmp(i32* %42, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%44 = icmp ne i32 %43, 0
br i1 %44, label %46, label %45
45: ; preds = %41
br label %118
46: ; preds = %41
%47 = getelementptr inbounds [8 x i32], [8 x i32]* %10, i64 0, i64 0
%48 = getelementptr inbounds i32, i32* %47, i64 4
%49 = call i32 @get_be32(i32* %48)
%50 = sext i32 %49 to i64
store i64 %50, i64* %11
%51 = load i64, i64* %6
%52 = add nsw i64 %51, 8
store i64 %52, i64* %6
%53 = load i64, i64* %6
%54 = load i64, i64* %11
%55 = add nsw i64 %53, %54
%56 = load i64, i64* %7
%57 = icmp sge i64 %55, %56
br i1 %57, label %58, label %60
58: ; preds = %46
%59 = call i32 @msg_error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %119
60: ; preds = %46
%61 = getelementptr inbounds [8 x i32], [8 x i32]* %10, i64 0, i64 0
%62 = call i32 @get_be32(i32* %61)
switch i32 %62, label %114 [
i32 1129661779, label %63
i32 1145130825, label %71
i32 1129661784, label %79
i32 1145130840, label %87
i32 1397313094, label %95
i32 1163152966, label %111
i32 1163152946, label %111
i32 1297373520, label %111
i32 1162757153, label %112
]
63: ; preds = %60
%64 = load i32*, i32** %4
%65 = load i8*, i8** %5
%66 = load i64, i64* %11
%67 = call i32 @nrg_parse_cuesx(i32* %64, i8* %65, i64 %66, i32 0)
%68 = icmp ne i32 %67, 0
br i1 %68, label %70, label %69
69: ; preds = %63
store i32 0, i32* %3
br label %119
70: ; preds = %63
br label %114
71: ; preds = %60
%72 = load i32*, i32** %4
%73 = load i8*, i8** %5
%74 = load i64, i64* %11
%75 = call i32 @nrg_parse_daoix(i32* %72, i8* %73, i64 %74, i32 0)
%76 = icmp ne i32 %75, 0
br i1 %76, label %78, label %77
77: ; preds = %71
store i32 0, i32* %3
br label %119
78: ; preds = %71
br label %114
79: ; preds = %60
%80 = load i32*, i32** %4
%81 = load i8*, i8** %5
%82 = load i64, i64* %11
%83 = call i32 @nrg_parse_cuesx(i32* %80, i8* %81, i64 %82, i32 1)
%84 = icmp ne i32 %83, 0
br i1 %84, label %86, label %85
85: ; preds = %79
store i32 0, i32* %3
br label %119
86: ; preds = %79
br label %114
87: ; preds = %60
%88 = load i32*, i32** %4
%89 = load i8*, i8** %5
%90 = load i64, i64* %11
%91 = call i32 @nrg_parse_daoix(i32* %88, i8* %89, i64 %90, i32 1)
%92 = icmp ne i32 %91, 0
br i1 %92, label %94, label %93
93: ; preds = %87
store i32 0, i32* %3
br label %119
94: ; preds = %87
br label %114
95: ; preds = %60
%96 = load i32*, i32** %4
%97 = load i8*, i8** %5
%98 = load i64, i64* %11
%99 = load i32, i32* %8
%100 = load i32, i32* %9
%101 = call i32 @nrg_parse_sinf(i32* %96, i8* %97, i64 %98, i32 %99, i32 %100)
store i32 %101, i32* %12
%102 = load i32, i32* %12
%103 = icmp slt i32 %102, 0
br i1 %103, label %104, label %105
104: ; preds = %95
store i32 0, i32* %3
br label %119
105: ; preds = %95
%106 = load i32, i32* %12
%107 = load i32, i32* %9
%108 = add nsw i32 %107, %106
store i32 %108, i32* %9
%109 = load i32, i32* %8
%110 = add nsw i32 %109, 1
store i32 %110, i32* %8
br label %114
111: ; preds = %60, %60, %60
br label %114
112: ; preds = %60
%113 = call i32 @msg_error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %119
114: ; preds = %60, %111, %105, %94, %86, %78, %70
%115 = load i64, i64* %11
%116 = load i64, i64* %6
%117 = add nsw i64 %116, %115
store i64 %117, i64* %6
br label %27
118: ; preds = %45
store i32 1, i32* %3
br label %119
119: ; preds = %118, %112, %104, %93, %85, %77, %69, %58, %38, %23, %16
%120 = load i32, i32* %3
ret i32 %120
}

LLVM IR (-O2):
@.str = [29 x i8] c"Failed to parse NRG5 footer\0A\00"
@SEEK_SET = global i32 0
@.str.1 = [9 x i8] c"END!\00\00\00\00\00"
@.str.2 = [21 x i8] c"Corrupt NRG5 footer\0A\00"
@.str.3 = [25 x i8] c"Broken END! chunk found\0A\00"
define i32 @nrg_parse_and_add_tracks(i32* %0, i8* %1) {
%3 = alloca i64
%4 = alloca [8 x i32]
%5 = bitcast i64* %3 to i8*
%6 = call i32 @nrg_check_footer(i32* %0, i64* %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @msg_error(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %74
10: ; preds = %2
%11 = call i64 @ftell(i32* %0)
%12 = icmp slt i64 %11, 0
br i1 %12, label %22, label %13
13: ; preds = %10
%14 = bitcast [8 x i32]* %4 to i8*
%15 = load i64, i64* %3
%16 = load i32, i32* @SEEK_SET
%17 = call i64 @fseek(i32* %0, i64 %15, i32 %16)
%18 = icmp slt i64 %17, 0
br i1 %18, label %29, label %19
19: ; preds = %13
%20 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 0
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %4, i64 0, i64 4
br label %24
22: ; preds = %10
%23 = call i32 @msg_perror(i8* %1)
br label %74
24: ; preds = %19, %65
%25 = phi i32 [ 0, %19 ], [ %67, %65 ]
%26 = phi i32 [ 0, %19 ], [ %66, %65 ]
%27 = call i32 @fread(i32* %20, i32 1, i32 8, i32* %0)
%28 = icmp eq i32 %27, 8
br i1 %28, label %31, label %29
29: ; preds = %65, %24, %13
%30 = call i32 @msg_perror(i8* %1)
br label %64
31: ; preds = %24
%32 = call i32 @memcmp(i32* %20, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 8)
%33 = icmp eq i32 %32, 0
br i1 %33, label %73, label %34
34: ; preds = %31
%35 = call i32 @get_be32(i32* %21)
%36 = sext i32 %35 to i64
%37 = load i64, i64* %3
%38 = add nsw i64 %37, 8
store i64 %38, i64* %3
%39 = add nsw i64 %38, %36
%40 = icmp slt i64 %39, %11
br i1 %40, label %43, label %41
41: ; preds = %34
%42 = call i32 @msg_error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %64
43: ; preds = %34
%44 = call i32 @get_be32(i32* %20)
switch i32 %44, label %65 [
i32 1129661779, label %45
i32 1145130825, label %48
i32 1129661784, label %51
i32 1145130840, label %54
i32 1397313094, label %57
i32 1162757153, label %62
]
45: ; preds = %43
%46 = call i32 @nrg_parse_cuesx(i32* %0, i8* %1, i64 %36, i32 0)
%47 = icmp eq i32 %46, 0
br i1 %47, label %64, label %65
48: ; preds = %43
%49 = call i32 @nrg_parse_daoix(i32* %0, i8* %1, i64 %36, i32 0)
%50 = icmp eq i32 %49, 0
br i1 %50, label %64, label %65
51: ; preds = %43
%52 = call i32 @nrg_parse_cuesx(i32* %0, i8* %1, i64 %36, i32 1)
%53 = icmp eq i32 %52, 0
br i1 %53, label %64, label %65
54: ; preds = %43
%55 = call i32 @nrg_parse_daoix(i32* %0, i8* %1, i64 %36, i32 1)
%56 = icmp eq i32 %55, 0
br i1 %56, label %64, label %65
57: ; preds = %43
%58 = call i32 @nrg_parse_sinf(i32* %0, i8* %1, i64 %36, i32 %26, i32 %25)
%59 = icmp slt i32 %58, 0
%60 = add nsw i32 %58, %25
%61 = add nsw i32 %26, 1
br i1 %59, label %64, label %65
62: ; preds = %43
%63 = call i32 @msg_error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %64
64: ; preds = %57, %45, %48, %51, %54, %29, %41, %62
br label %74
65: ; preds = %43, %45, %48, %51, %54, %57
%66 = phi i32 [ %26, %43 ], [ %61, %57 ], [ %26, %54 ], [ %26, %51 ], [ %26, %48 ], [ %26, %45 ]
%67 = phi i32 [ %25, %43 ], [ %60, %57 ], [ %25, %54 ], [ %25, %51 ], [ %25, %48 ], [ %25, %45 ]
%68 = load i64, i64* %3
%69 = add nsw i64 %68, %36
store i64 %69, i64* %3
%70 = load i32, i32* @SEEK_SET
%71 = call i64 @fseek(i32* %0, i64 %69, i32 %70)
%72 = icmp slt i64 %71, 0
br i1 %72, label %29, label %24
73: ; preds = %31
br label %74
74: ; preds = %64, %22, %73, %8
%75 = phi i32 [ 0, %8 ], [ 0, %22 ], [ 1, %73 ], [ 0, %64 ]
ret i32 %75
}