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

/* Variables and functions */
scalar_t__ chunk_load(int /*<<< orphan*/ *, int);
int dispchar(char);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ fs_load(int /*<<< orphan*/ *, char);
scalar_t__ fs_load_pre17(int /*<<< orphan*/ *);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int fs_loadall(const char *fname) {
  FILE *fd;
  uint8_t hdr[8];
  uint8_t fver;
  fd = fopen(fname, "r");
  if (fd == NULL) {
    printf("can't open metadata file\n");
    return -1;
  }
  if (fread(hdr, 1, 8, fd) != 8) {
    printf("can't read metadata header\n");
    fclose(fd);
    return -1;
  }
  printf("# header: %c%c%c%c%c%c%c%c (%02X%02X%02X%02X%02X%02X%02X%02X)\n",
         dispchar(hdr[0]), dispchar(hdr[1]), dispchar(hdr[2]), dispchar(hdr[3]),
         dispchar(hdr[4]), dispchar(hdr[5]), dispchar(hdr[6]), dispchar(hdr[7]),
         hdr[0], hdr[1], hdr[2], hdr[3], hdr[4], hdr[5], hdr[6], hdr[7]);
  if (memcmp(hdr, "MFSM NEW", 8) == 0) {
    printf("empty file\n");
  } else if (memcmp(hdr,
                    "MFS"
                    "M ",
                    5) == 0 &&
             hdr[5] >= '1' && hdr[5] <= '9' && hdr[6] == '.' && hdr[7] >= '0' &&
             hdr[7] <= '9') {
    fver = ((hdr[5] - '0') << 4) + (hdr[7] - '0');
    if (fver < 0x17) {
      if (fs_load_pre17(fd) < 0) {
        printf("error reading metadata (structure)\n");
        fclose(fd);
        return -1;
      }
      if (chunk_load(fd, 0x10) < 0) {
        printf("error reading metadata (chunks)\n");
        fclose(fd);
        return -1;
      }
    } else {
      if (fs_load(fd, fver) < 0) {
        fclose(fd);
        return -1;
      }
    }
  } else {
    printf("wrong metadata header (old version ?)\n");
    fclose(fd);
    return -1;
  }
  if (ferror(fd) != 0) {
    printf("error reading metadata\n");
    fclose(fd);
    return -1;
  }
  fclose(fd);
  return 0;
}


x86 assembly (clang, -O0):
<fs_loadall>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %rdi,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11f1 <fs_loadall+0x51>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0xffffffff,-0x2c(%rbp)
jmp    14ea <fs_loadall+0x34a>
lea    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rcx
mov    $0x1,%esi
mov    $0x8,%edx
call   1050 <fread@plt>
cmp    $0x8,%eax
je     1234 <fs_loadall+0x94>
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0xffffffff,-0x2c(%rbp)
jmp    14ea <fs_loadall+0x34a>
movsbl -0x48(%rbp),%edi
call   10a0 <dispchar@plt>
mov    %eax,-0x70(%rbp)
movsbl -0x47(%rbp),%edi
call   10a0 <dispchar@plt>
mov    %eax,-0x6c(%rbp)
movsbl -0x46(%rbp),%edi
call   10a0 <dispchar@plt>
mov    %eax,-0x68(%rbp)
movsbl -0x45(%rbp),%edi
call   10a0 <dispchar@plt>
mov    %eax,-0x64(%rbp)
movsbl -0x44(%rbp),%edi
call   10a0 <dispchar@plt>
mov    %eax,-0x60(%rbp)
movsbl -0x43(%rbp),%edi
call   10a0 <dispchar@plt>
mov    %eax,-0x5c(%rbp)
movsbl -0x42(%rbp),%edi
call   10a0 <dispchar@plt>
mov    %eax,-0x58(%rbp)
movsbl -0x41(%rbp),%edi
call   10a0 <dispchar@plt>
mov    -0x70(%rbp),%esi
mov    -0x6c(%rbp),%edx
mov    -0x68(%rbp),%ecx
mov    -0x64(%rbp),%r8d
mov    -0x60(%rbp),%r9d
mov    %eax,%edi
mov    -0x5c(%rbp),%eax
mov    %edi,-0x54(%rbp)
movsbl -0x48(%rbp),%r13d
movsbl -0x47(%rbp),%r12d
movsbl -0x46(%rbp),%r15d
movsbl -0x45(%rbp),%r14d
movsbl -0x44(%rbp),%ebx
movsbl -0x43(%rbp),%r11d
movsbl -0x42(%rbp),%r10d
movsbl -0x41(%rbp),%edi
mov    %edi,-0x50(%rbp)
lea    0xd5e(%rip),%rdi
mov    %eax,(%rsp)
mov    -0x58(%rbp),%eax
mov    %eax,0x8(%rsp)
mov    -0x54(%rbp),%eax
mov    %eax,0x10(%rsp)
mov    -0x50(%rbp),%eax
mov    %r13d,0x18(%rsp)
mov    %r12d,0x20(%rsp)
mov    %r15d,0x28(%rsp)
mov    %r14d,0x30(%rsp)
mov    %ebx,0x38(%rsp)
mov    %r11d,0x40(%rsp)
mov    %r10d,0x48(%rsp)
mov    %eax,0x50(%rsp)
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x48(%rbp),%rdi
lea    0xd51(%rip),%rsi
mov    $0x8,%edx
call   1080 <memcmp@plt>
cmp    $0x0,%rax
jne    134d <fs_loadall+0x1ad>
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    14a4 <fs_loadall+0x304>
lea    -0x48(%rbp),%rdi
lea    0xd34(%rip),%rsi
mov    $0x5,%edx
call   1080 <memcmp@plt>
cmp    $0x0,%rax
jne    147c <fs_loadall+0x2dc>
movsbl -0x43(%rbp),%eax
cmp    $0x31,%eax
jl     147c <fs_loadall+0x2dc>
movsbl -0x43(%rbp),%eax
cmp    $0x39,%eax
jg     147c <fs_loadall+0x2dc>
movsbl -0x42(%rbp),%eax
cmp    $0x2e,%eax
jne    147c <fs_loadall+0x2dc>
movsbl -0x41(%rbp),%eax
cmp    $0x30,%eax
jl     147c <fs_loadall+0x2dc>
movsbl -0x41(%rbp),%eax
cmp    $0x39,%eax
jg     147c <fs_loadall+0x2dc>
movsbl -0x43(%rbp),%eax
sub    $0x30,%eax
shl    $0x4,%eax
movsbl -0x41(%rbp),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %al,-0x49(%rbp)
movsbl -0x49(%rbp),%eax
cmp    $0x17,%eax
jge    1446 <fs_loadall+0x2a6>
mov    -0x40(%rbp),%rdi
call   1030 <fs_load_pre17@plt>
cmp    $0x0,%rax
jge    1406 <fs_loadall+0x266>
lea    0xca8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0xffffffff,-0x2c(%rbp)
jmp    14ea <fs_loadall+0x34a>
mov    -0x40(%rbp),%rdi
mov    $0x10,%esi
call   10c0 <chunk_load@plt>
cmp    $0x0,%rax
jge    1441 <fs_loadall+0x2a1>
lea    0xc91(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0xffffffff,-0x2c(%rbp)
jmp    14ea <fs_loadall+0x34a>
jmp    1477 <fs_loadall+0x2d7>
mov    -0x40(%rbp),%rdi
movsbl -0x49(%rbp),%esi
call   1090 <fs_load@plt>
cmp    $0x0,%rax
jge    1472 <fs_loadall+0x2d2>
mov    -0x40(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0xffffffff,-0x2c(%rbp)
jmp    14ea <fs_loadall+0x34a>
jmp    1477 <fs_loadall+0x2d7>
jmp    149f <fs_loadall+0x2ff>
lea    0xc54(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0xffffffff,-0x2c(%rbp)
jmp    14ea <fs_loadall+0x34a>
jmp    14a4 <fs_loadall+0x304>
mov    -0x40(%rbp),%rdi
call   1040 <ferror@plt>
cmp    $0x0,%rax
je     14da <fs_loadall+0x33a>
lea    0xc40(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0xffffffff,-0x2c(%rbp)
jmp    14ea <fs_loadall+0x34a>
mov    -0x40(%rbp),%rdi
call   1060 <fclose@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

x86 assembly (clang, -O2):
<fs_loadall>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0xf2d(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     136b <fs_loadall+0x1bb>
mov    %rax,%rbx
lea    0x4(%rsp),%rdi
mov    $0x1,%esi
mov    $0x8,%edx
mov    %rax,%rcx
call   1060 <fread@plt>
cmp    $0x8,%eax
jne    1379 <fs_loadall+0x1c9>
movsbl 0x4(%rsp),%edi
mov    %rdi,0x40(%rsp)
call   10b0 <dispchar@plt>
mov    %eax,0x1c(%rsp)
movsbl 0x5(%rsp),%edi
mov    %rdi,0x38(%rsp)
call   10b0 <dispchar@plt>
mov    %eax,0x18(%rsp)
movsbl 0x6(%rsp),%edi
mov    %rdi,0x30(%rsp)
call   10b0 <dispchar@plt>
mov    %eax,0x14(%rsp)
movsbl 0x7(%rsp),%ebp
mov    %ebp,%edi
call   10b0 <dispchar@plt>
mov    %eax,0x10(%rsp)
movsbl 0x8(%rsp),%r13d
mov    %r13d,%edi
call   10b0 <dispchar@plt>
mov    %eax,0xc(%rsp)
movsbl 0x9(%rsp),%r15d
mov    %r15d,%edi
call   10b0 <dispchar@plt>
mov    %rax,0x28(%rsp)
movsbl 0xa(%rsp),%r14d
mov    %r14d,%edi
call   10b0 <dispchar@plt>
mov    %rax,0x20(%rsp)
movsbl 0xb(%rsp),%r12d
mov    %r12d,%edi
call   10b0 <dispchar@plt>
mov    %eax,%r10d
sub    $0x8,%rsp
lea    0xd6d(%rip),%rdi
mov    0x24(%rsp),%esi
mov    0x20(%rsp),%edx
mov    0x1c(%rsp),%ecx
mov    0x18(%rsp),%r8d
mov    0x14(%rsp),%r9d
xor    %eax,%eax
push   %r12
push   %r14
push   %r15
push   %r13
push   %rbp
push   0x60(%rsp)
push   0x70(%rsp)
push   0x80(%rsp)
push   %r10
push   0x70(%rsp)
push   0x80(%rsp)
call   1080 <printf@plt>
add    $0x60,%rsp
lea    0xd5f(%rip),%rsi
lea    0x4(%rsp),%rdi
mov    $0x8,%edx
call   1090 <memcmp@plt>
test   %rax,%rax
je     1382 <fs_loadall+0x1d2>
lea    0xd49(%rip),%rsi
lea    0x4(%rsp),%rdi
mov    $0x5,%edx
call   1090 <memcmp@plt>
test   %rax,%rax
jne    1390 <fs_loadall+0x1e0>
mov    0x9(%rsp),%al
cmp    $0x31,%al
jl     1390 <fs_loadall+0x1e0>
cmp    $0x39,%al
jg     1390 <fs_loadall+0x1e0>
cmpb   $0x2e,0xa(%rsp)
jne    1390 <fs_loadall+0x1e0>
mov    0xb(%rsp),%cl
cmp    $0x30,%cl
jl     1390 <fs_loadall+0x1e0>
cmp    $0x39,%cl
jg     1390 <fs_loadall+0x1e0>
shl    $0x4,%al
add    %cl,%al
add    $0xd0,%al
cmp    $0x16,%al
jg     1399 <fs_loadall+0x1e9>
mov    %rbx,%rdi
call   1030 <fs_load_pre17@plt>
test   %rax,%rax
js     13ea <fs_loadall+0x23a>
mov    %rbx,%rdi
mov    $0x10,%esi
call   10d0 <chunk_load@plt>
test   %rax,%rax
jns    13a9 <fs_loadall+0x1f9>
lea    0xd22(%rip),%rdi
jmp    13bd <fs_loadall+0x20d>
lea    0xd82(%rip),%rdi
call   1040 <puts@plt>
jmp    13ca <fs_loadall+0x21a>
lea    0xd59(%rip),%rdi
jmp    13bd <fs_loadall+0x20d>
lea    0xd45(%rip),%rdi
call   1040 <puts@plt>
jmp    13a9 <fs_loadall+0x1f9>
lea    0xcb7(%rip),%rdi
jmp    13bd <fs_loadall+0x20d>
movsbl %al,%esi
mov    %rbx,%rdi
call   10a0 <fs_load@plt>
test   %rax,%rax
js     13c2 <fs_loadall+0x212>
mov    %rbx,%rdi
call   1050 <ferror@plt>
test   %rax,%rax
je     13de <fs_loadall+0x22e>
lea    0xcb7(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1070 <fclose@plt>
mov    $0xffffffff,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   1070 <fclose@plt>
xor    %eax,%eax
jmp    13cf <fs_loadall+0x21f>
lea    0xcba(%rip),%rdi
jmp    13bd <fs_loadall+0x20d>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [26 x i8] c"can't open metadata file\0A\00"
@.str.2 = [28 x i8] c"can't read metadata header\0A\00"
@.str.3 = [63 x i8] c"# header: %c%c%c%c%c%c%c%c (%02X%02X%02X%02X%02X%02X%02X%02X)\0A\00"
@.str.4 = [9 x i8] c"MFSM NEW\00"
@.str.5 = [12 x i8] c"empty file\0A\00"
@.str.6 = [6 x i8] c"MFSM \00"
@.str.7 = [36 x i8] c"error reading metadata (structure)\0A\00"
@.str.8 = [33 x i8] c"error reading metadata (chunks)\0A\00"
@.str.9 = [39 x i8] c"wrong metadata header (old version ?)\0A\00"
@.str.10 = [24 x i8] c"error reading metadata\0A\00"
define i32 @fs_loadall(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [8 x i8]
%6 = alloca i8
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %4
%9 = load i32*, i32** %4
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
br label %164
13: ; preds = %1
%14 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%15 = load i32*, i32** %4
%16 = call i32 @fread(i8* %14, i32 1, i32 8, i32* %15)
%17 = icmp ne i32 %16, 8
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32*, i32** %4
%21 = call i32 @fclose(i32* %20)
store i32 -1, i32* %2
br label %164
22: ; preds = %13
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%24 = load i8, i8* %23
%25 = call i32 @dispchar(i8 signext %24)
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 1
%27 = load i8, i8* %26
%28 = call i32 @dispchar(i8 signext %27)
%29 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 2
%30 = load i8, i8* %29
%31 = call i32 @dispchar(i8 signext %30)
%32 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 3
%33 = load i8, i8* %32
%34 = call i32 @dispchar(i8 signext %33)
%35 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 4
%36 = load i8, i8* %35
%37 = call i32 @dispchar(i8 signext %36)
%38 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 5
%39 = load i8, i8* %38
%40 = call i32 @dispchar(i8 signext %39)
%41 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 6
%42 = load i8, i8* %41
%43 = call i32 @dispchar(i8 signext %42)
%44 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 7
%45 = load i8, i8* %44
%46 = call i32 @dispchar(i8 signext %45)
%47 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 1
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 2
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 3
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 4
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 5
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 6
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 7
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0), i32 %25, i32 %28, i32 %31, i32 %34, i32 %37, i32 %40, i32 %43, i32 %46, i32 %49, i32 %52, i32 %55, i32 %58, i32 %61, i32 %64, i32 %67, i32 %70)
%72 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%73 = call i64 @memcmp(i8* %72, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 8)
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %22
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %153
77: ; preds = %22
%78 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%79 = call i64 @memcmp(i8* %78, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 5)
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %148
81: ; preds = %77
%82 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 5
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = icmp sge i32 %84, 49
br i1 %85, label %86, label %148
86: ; preds = %81
%87 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 5
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = icmp sle i32 %89, 57
br i1 %90, label %91, label %148
91: ; preds = %86
%92 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 6
%93 = load i8, i8* %92
%94 = sext i8 %93 to i32
%95 = icmp eq i32 %94, 46
br i1 %95, label %96, label %148
96: ; preds = %91
%97 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 7
%98 = load i8, i8* %97
%99 = sext i8 %98 to i32
%100 = icmp sge i32 %99, 48
br i1 %100, label %101, label %148
101: ; preds = %96
%102 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 7
%103 = load i8, i8* %102
%104 = sext i8 %103 to i32
%105 = icmp sle i32 %104, 57
br i1 %105, label %106, label %148
106: ; preds = %101
%107 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 5
%108 = load i8, i8* %107
%109 = sext i8 %108 to i32
%110 = sub nsw i32 %109, 48
%111 = shl i32 %110, 4
%112 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 7
%113 = load i8, i8* %112
%114 = sext i8 %113 to i32
%115 = sub nsw i32 %114, 48
%116 = add nsw i32 %111, %115
%117 = trunc i32 %116 to i8
store i8 %117, i8* %6
%118 = load i8, i8* %6
%119 = sext i8 %118 to i32
%120 = icmp slt i32 %119, 23
br i1 %120, label %121, label %138
121: ; preds = %106
%122 = load i32*, i32** %4
%123 = call i64 @fs_load_pre17(i32* %122)
%124 = icmp slt i64 %123, 0
br i1 %124, label %125, label %129
125: ; preds = %121
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%127 = load i32*, i32** %4
%128 = call i32 @fclose(i32* %127)
store i32 -1, i32* %2
br label %164
129: ; preds = %121
%130 = load i32*, i32** %4
%131 = call i64 @chunk_load(i32* %130, i32 16)
%132 = icmp slt i64 %131, 0
br i1 %132, label %133, label %137
133: ; preds = %129
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
%135 = load i32*, i32** %4
%136 = call i32 @fclose(i32* %135)
store i32 -1, i32* %2
br label %164
137: ; preds = %129
br label %147
138: ; preds = %106
%139 = load i32*, i32** %4
%140 = load i8, i8* %6
%141 = call i64 @fs_load(i32* %139, i8 signext %140)
%142 = icmp slt i64 %141, 0
br i1 %142, label %143, label %146
143: ; preds = %138
%144 = load i32*, i32** %4
%145 = call i32 @fclose(i32* %144)
store i32 -1, i32* %2
br label %164
146: ; preds = %138
br label %147
147: ; preds = %146, %137
br label %152
148: ; preds = %101, %96, %91, %86, %81, %77
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0))
%150 = load i32*, i32** %4
%151 = call i32 @fclose(i32* %150)
store i32 -1, i32* %2
br label %164
152: ; preds = %147
br label %153
153: ; preds = %152, %75
%154 = load i32*, i32** %4
%155 = call i64 @ferror(i32* %154)
%156 = icmp ne i64 %155, 0
br i1 %156, label %157, label %161
157: ; preds = %153
%158 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0))
%159 = load i32*, i32** %4
%160 = call i32 @fclose(i32* %159)
store i32 -1, i32* %2
br label %164
161: ; preds = %153
%162 = load i32*, i32** %4
%163 = call i32 @fclose(i32* %162)
store i32 0, i32* %2
br label %164
164: ; preds = %161, %157, %148, %143, %133, %125, %18, %11
%165 = load i32, i32* %2
ret i32 %165
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.3 = [63 x i8] c"# header: %c%c%c%c%c%c%c%c (%02X%02X%02X%02X%02X%02X%02X%02X)\0A\00"
@.str.4 = [9 x i8] c"MFSM NEW\00"
@.str.6 = [6 x i8] c"MFSM \00"
@str = [38 x i8] c"wrong metadata header (old version ?)\00"
@str.11 = [23 x i8] c"error reading metadata\00"
@str.12 = [32 x i8] c"error reading metadata (chunks)\00"
@str.13 = [35 x i8] c"error reading metadata (structure)\00"
@str.14 = [11 x i8] c"empty file\00"
@str.15 = [27 x i8] c"can't read metadata header\00"
@str.16 = [25 x i8] c"can't open metadata file\00"
define i32 @fs_loadall(i8* nocapture %0) {
%2 = alloca [8 x i8]
%3 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.16, i64 0, i64 0))
br label %100
8: ; preds = %1
%9 = call i32 @fread(i8* %3, i32 1, i32 8, i32* %4)
%10 = icmp eq i32 %9, 8
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.15, i64 0, i64 0))
%13 = tail call i32 @fclose(i32* %4)
br label %100
14: ; preds = %8
%15 = load i8, i8* %3
%16 = tail call i32 @dispchar(i8 signext %15)
%17 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 1
%18 = load i8, i8* %17
%19 = tail call i32 @dispchar(i8 signext %18)
%20 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 2
%21 = load i8, i8* %20
%22 = tail call i32 @dispchar(i8 signext %21)
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 3
%24 = load i8, i8* %23
%25 = tail call i32 @dispchar(i8 signext %24)
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 4
%27 = load i8, i8* %26
%28 = tail call i32 @dispchar(i8 signext %27)
%29 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 5
%30 = load i8, i8* %29
%31 = tail call i32 @dispchar(i8 signext %30)
%32 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 6
%33 = load i8, i8* %32
%34 = tail call i32 @dispchar(i8 signext %33)
%35 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 7
%36 = load i8, i8* %35
%37 = tail call i32 @dispchar(i8 signext %36)
%38 = sext i8 %15 to i32
%39 = sext i8 %18 to i32
%40 = sext i8 %21 to i32
%41 = sext i8 %24 to i32
%42 = sext i8 %27 to i32
%43 = sext i8 %30 to i32
%44 = sext i8 %33 to i32
%45 = sext i8 %36 to i32
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.3, i64 0, i64 0), i32 %16, i32 %19, i32 %22, i32 %25, i32 %28, i32 %31, i32 %34, i32 %37, i32 %38, i32 %39, i32 %40, i32 %41, i32 %42, i32 %43, i32 %44, i32 %45)
%47 = call i64 @memcmp(i8* %3, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 8)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %14
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.14, i64 0, i64 0))
br label %92
51: ; preds = %14
%52 = call i64 @memcmp(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i32 5)
%53 = icmp eq i64 %52, 0
%54 = load i8, i8* %29
%55 = icmp sgt i8 %54, 48
%56 = select i1 %53, i1 %55, i1 false
%57 = icmp slt i8 %54, 58
%58 = select i1 %56, i1 %57, i1 false
%59 = load i8, i8* %32
%60 = icmp eq i8 %59, 46
%61 = select i1 %58, i1 %60, i1 false
%62 = load i8, i8* %35
%63 = icmp sgt i8 %62, 47
%64 = select i1 %61, i1 %63, i1 false
%65 = icmp slt i8 %62, 58
%66 = select i1 %64, i1 %65, i1 false
br i1 %66, label %67, label %89
67: ; preds = %51
%68 = shl i8 %54, 4
%69 = add i8 %68, -48
%70 = add i8 %69, %62
%71 = icmp slt i8 %70, 23
br i1 %71, label %72, label %84
72: ; preds = %67
%73 = call i64 @fs_load_pre17(i32* %4)
%74 = icmp slt i64 %73, 0
br i1 %74, label %75, label %78
75: ; preds = %72
%76 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.13, i64 0, i64 0))
%77 = call i32 @fclose(i32* %4)
br label %100
78: ; preds = %72
%79 = call i64 @chunk_load(i32* %4, i32 16)
%80 = icmp slt i64 %79, 0
br i1 %80, label %81, label %92
81: ; preds = %78
%82 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.12, i64 0, i64 0))
%83 = call i32 @fclose(i32* %4)
br label %100
84: ; preds = %67
%85 = call i64 @fs_load(i32* %4, i8 signext %70)
%86 = icmp slt i64 %85, 0
br i1 %86, label %87, label %92
87: ; preds = %84
%88 = call i32 @fclose(i32* %4)
br label %100
89: ; preds = %51
%90 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%91 = call i32 @fclose(i32* %4)
br label %100
92: ; preds = %84, %78, %49
%93 = call i64 @ferror(i32* %4)
%94 = icmp eq i64 %93, 0
br i1 %94, label %98, label %95
95: ; preds = %92
%96 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.11, i64 0, i64 0))
%97 = call i32 @fclose(i32* %4)
br label %100
98: ; preds = %92
%99 = call i32 @fclose(i32* %4)
br label %100
100: ; preds = %98, %95, %89, %87, %81, %75, %11, %6
%101 = phi i32 [ -1, %6 ], [ -1, %11 ], [ -1, %95 ], [ 0, %98 ], [ -1, %75 ], [ -1, %81 ], [ -1, %87 ], [ -1, %89 ]
ret i32 %101
}