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

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ puts(char const *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, char **argv) {
  int status;
  if (argc > 1) {
    status = 0;
    while (--argc) {
      const char *fn = *++argv;
      FILE *fp = fopen(fn, "rb");
      if (fp) {
        unsigned char fsmap[0x200];
        if (fread(fsmap, sizeof fsmap, 1, fp) == 1) {
          puts(fn);
          unsigned char *sptr = fsmap;
          unsigned char *eptr = fsmap + fsmap[0x1FE];
          unsigned char *lptr = fsmap + 0x100;
          while (sptr < eptr) {
            uint32_t start = *sptr++;
            start |= (*sptr++ << 8);
            start |= (*sptr++ << 16);
            uint32_t len = *lptr++;
            len |= (*lptr++ << 8);
            len |= (*lptr++ << 16);
            if (len > 0)
              printf("%06X %06X (%d)\n", start, len, len);
          }
        } else {
          fprintf(stderr, "fsmap: unable to read fsmap from %s: %s\n", fn,
                  strerror(errno));
          status = 3;
        }
      } else {
        fprintf(stderr, "fsmap: unable to open %s for reading: %s\n", fn,
                strerror(errno));
        status = 2;
      }
    }
  } else {
    fputs("Usage: fsmap <dat-file> [ ... ]\n", stderr);
    status = 1;
  }
  return status;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    140e <main+0x29e>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     1409 <main+0x299>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     13b9 <main+0x249>
lea    -0x230(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x200,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    1369 <main+0x1f9>
mov    -0x20(%rbp),%rdi
call   1030 <puts@plt>
lea    -0x230(%rbp),%rax
mov    %rax,-0x238(%rbp)
lea    -0x230(%rbp),%rax
movzbl -0x32(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x240(%rbp)
lea    -0x230(%rbp),%rax
add    $0x100,%rax
mov    %rax,-0x248(%rbp)
mov    -0x238(%rbp),%rax
cmp    -0x240(%rbp),%rax
jae    1364 <main+0x1f4>
mov    -0x238(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x238(%rbp)
movzbl (%rax),%eax
mov    %eax,-0x24c(%rbp)
mov    -0x238(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x238(%rbp)
movzbl (%rax),%eax
shl    $0x8,%eax
or     -0x24c(%rbp),%eax
mov    %eax,-0x24c(%rbp)
mov    -0x238(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x238(%rbp)
movzbl (%rax),%eax
shl    $0x10,%eax
or     -0x24c(%rbp),%eax
mov    %eax,-0x24c(%rbp)
mov    -0x248(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x248(%rbp)
movzbl (%rax),%eax
mov    %eax,-0x250(%rbp)
mov    -0x248(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x248(%rbp)
movzbl (%rax),%eax
shl    $0x8,%eax
or     -0x250(%rbp),%eax
mov    %eax,-0x250(%rbp)
mov    -0x248(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x248(%rbp)
movzbl (%rax),%eax
shl    $0x10,%eax
or     -0x250(%rbp),%eax
mov    %eax,-0x250(%rbp)
cmpl   $0x0,-0x250(%rbp)
jle    135f <main+0x1ef>
mov    -0x24c(%rbp),%esi
mov    -0x250(%rbp),%edx
mov    -0x250(%rbp),%ecx
lea    0xca9(%rip),%rdi
call   1050 <printf@plt>
jmp    1248 <main+0xd8>
jmp    13b4 <main+0x244>
mov    0x2c70(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x25c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x258(%rbp)
mov    0x2c4e(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x25c(%rbp),%edi
mov    -0x258(%rbp),%rdx
mov    %rax,%rcx
lea    0xc6b(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x3,-0x14(%rbp)
jmp    1404 <main+0x294>
mov    0x2c20(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x26c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x268(%rbp)
mov    0x2bfe(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x26c(%rbp),%edi
mov    -0x268(%rbp),%rdx
mov    %rax,%rcx
lea    0xc44(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x2,-0x14(%rbp)
jmp    119a <main+0x2a>
jmp    142a <main+0x2ba>
mov    0x2bcb(%rip),%rax
mov    (%rax),%esi
lea    0xc48(%rip),%rdi
call   1060 <fputs@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
cmp    $0x2,%edi
jl     12d3 <main+0x163>
mov    %rsi,%r13
mov    %edi,%r14d
add    $0xffffffff,%r14d
xor    %ebp,%ebp
lea    0xe63(%rip),%rbx
jmp    11e0 <main+0x70>
nop
mov    0x2e39(%rip),%rax
mov    (%rax),%r15d
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %r15d,%edi
lea    0xe7a(%rip),%rsi
mov    %r12,%rdx
mov    %rax,%rcx
call   1070 <fprintf@plt>
mov    $0x2,%ebp
add    $0x8,%r13
add    $0xffffffff,%r14d
je     12ed <main+0x17d>
mov    0x8(%r13),%r12
mov    %r12,%rdi
mov    %rbx,%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11a0 <main+0x30>
lea    0x10(%rsp),%rdi
mov    $0x200,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    1290 <main+0x120>
mov    %r12,%rdi
call   1030 <puts@plt>
movzbl 0x20e(%rsp),%eax
test   %rax,%rax
je     11d2 <main+0x62>
mov    %ebp,0xc(%rsp)
mov    %rbx,%r15
lea    (%rsp,%rax,1),%r12
add    $0x10,%r12
lea    0x10(%rsp),%rbx
jmp    1250 <main+0xe0>
nop
add    $0x3,%rbx
add    $0xffffffffffffff03,%rbp
cmp    %r12,%rbp
jae    12c7 <main+0x157>
lea    0x100(%rbx),%rbp
movzwl 0x100(%rbx),%eax
movzbl 0x102(%rbx),%ecx
shl    $0x10,%ecx
or     %eax,%ecx
je     1240 <main+0xd0>
movzwl (%rbx),%eax
movzbl 0x2(%rbx),%esi
shl    $0x10,%esi
or     %eax,%esi
lea    0xd84(%rip),%rdi
mov    %ecx,%edx
call   1050 <printf@plt>
jmp    1240 <main+0xd0>
nopl   0x0(%rax,%rax,1)
mov    0x2d49(%rip),%rax
mov    (%rax),%r15d
mov    0x2d37(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    %r15d,%edi
lea    0xd61(%rip),%rsi
mov    %r12,%rdx
mov    %rax,%rcx
call   1070 <fprintf@plt>
mov    $0x3,%ebp
jmp    11d2 <main+0x62>
mov    %r15,%rbx
mov    0xc(%rsp),%ebp
jmp    11d2 <main+0x62>
mov    0x2d06(%rip),%rax
mov    (%rax),%esi
lea    0xd83(%rip),%rdi
call   1060 <fputs@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [16 x i8] c"%06X %06X (%d)\0A\00"
@stderr = global i32 0
@.str.2 = [41 x i8] c"fsmap: unable to read fsmap from %s: %s\0A\00"
@errno = global i32 0
@.str.3 = [42 x i8] c"fsmap: unable to open %s for reading: %s\0A\00"
@.str.4 = [33 x i8] c"Usage: fsmap <dat-file> [ ... ]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca [512 x i8]
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 1
br i1 %16, label %17, label %112
17: ; preds = %2
store i32 0, i32* %6
br label %18
18: ; preds = %110, %17
%19 = load i32, i32* %4
%20 = add nsw i32 %19, -1
store i32 %20, i32* %4
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %111
22: ; preds = %18
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i32 1
store i8** %24, i8*** %5
%25 = load i8*, i8** %24
store i8* %25, i8** %7
%26 = load i8*, i8** %7
%27 = call i32* @fopen(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %27, i32** %8
%28 = load i32*, i32** %8
%29 = icmp ne i32* %28, null
br i1 %29, label %30, label %104
30: ; preds = %22
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%32 = load i32*, i32** %8
%33 = call i32 @fread(i8* %31, i32 512, i32 1, i32* %32)
%34 = icmp eq i32 %33, 1
br i1 %34, label %35, label %97
35: ; preds = %30
%36 = load i8*, i8** %7
%37 = call i32 @puts(i8* %36)
%38 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
store i8* %38, i8** %10
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%40 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 510
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %39, i64 %43
store i8* %44, i8** %11
%45 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%46 = getelementptr inbounds i8, i8* %45, i64 256
store i8* %46, i8** %12
br label %47
47: ; preds = %95, %35
%48 = load i8*, i8** %10
%49 = load i8*, i8** %11
%50 = icmp ult i8* %48, %49
br i1 %50, label %51, label %96
51: ; preds = %47
%52 = load i8*, i8** %10
%53 = getelementptr inbounds i8, i8* %52, i32 1
store i8* %53, i8** %10
%54 = load i8, i8* %52
%55 = zext i8 %54 to i32
store i32 %55, i32* %13
%56 = load i8*, i8** %10
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %10
%58 = load i8, i8* %56
%59 = zext i8 %58 to i32
%60 = shl i32 %59, 8
%61 = load i32, i32* %13
%62 = or i32 %61, %60
store i32 %62, i32* %13
%63 = load i8*, i8** %10
%64 = getelementptr inbounds i8, i8* %63, i32 1
store i8* %64, i8** %10
%65 = load i8, i8* %63
%66 = zext i8 %65 to i32
%67 = shl i32 %66, 16
%68 = load i32, i32* %13
%69 = or i32 %68, %67
store i32 %69, i32* %13
%70 = load i8*, i8** %12
%71 = getelementptr inbounds i8, i8* %70, i32 1
store i8* %71, i8** %12
%72 = load i8, i8* %70
%73 = zext i8 %72 to i32
store i32 %73, i32* %14
%74 = load i8*, i8** %12
%75 = getelementptr inbounds i8, i8* %74, i32 1
store i8* %75, i8** %12
%76 = load i8, i8* %74
%77 = zext i8 %76 to i32
%78 = shl i32 %77, 8
%79 = load i32, i32* %14
%80 = or i32 %79, %78
store i32 %80, i32* %14
%81 = load i8*, i8** %12
%82 = getelementptr inbounds i8, i8* %81, i32 1
store i8* %82, i8** %12
%83 = load i8, i8* %81
%84 = zext i8 %83 to i32
%85 = shl i32 %84, 16
%86 = load i32, i32* %14
%87 = or i32 %86, %85
store i32 %87, i32* %14
%88 = load i32, i32* %14
%89 = icmp sgt i32 %88, 0
br i1 %89, label %90, label %95
90: ; preds = %51
%91 = load i32, i32* %13
%92 = load i32, i32* %14
%93 = load i32, i32* %14
%94 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %91, i32 %92, i32 %93)
br label %95
95: ; preds = %90, %51
br label %47
96: ; preds = %47
br label %103
97: ; preds = %30
%98 = load i32, i32* @stderr
%99 = load i8*, i8** %7
%100 = load i32, i32* @errno
%101 = call i8* @strerror(i32 %100)
%102 = call i32 @fprintf(i32 %98, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %99, i8* %101)
store i32 3, i32* %6
br label %103
103: ; preds = %97, %96
br label %110
104: ; preds = %22
%105 = load i32, i32* @stderr
%106 = load i8*, i8** %7
%107 = load i32, i32* @errno
%108 = call i8* @strerror(i32 %107)
%109 = call i32 @fprintf(i32 %105, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %106, i8* %108)
store i32 2, i32* %6
br label %110
110: ; preds = %104, %103
br label %18
111: ; preds = %18
br label %115
112: ; preds = %2
%113 = load i32, i32* @stderr
%114 = call i32 @fputs(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %113)
store i32 1, i32* %6
br label %115
115: ; preds = %112, %111
%116 = load i32, i32* %6
ret i32 %116
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [16 x i8] c"%06X %06X (%d)\0A\00"
@stderr = global i32 0
@.str.2 = [41 x i8] c"fsmap: unable to read fsmap from %s: %s\0A\00"
@errno = global i32 0
@.str.3 = [42 x i8] c"fsmap: unable to open %s for reading: %s\0A\00"
@.str.4 = [33 x i8] c"Usage: fsmap <dat-file> [ ... ]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %77
5: ; preds = %2
%6 = add nsw i32 %0, -1
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 510
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 256
br label %10
10: ; preds = %5, %73
%11 = phi i32 [ %6, %5 ], [ %75, %73 ]
%12 = phi i8** [ %1, %5 ], [ %14, %73 ]
%13 = phi i32 [ 0, %5 ], [ %74, %73 ]
%14 = getelementptr inbounds i8*, i8** %12, i64 1
%15 = load i8*, i8** %14
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %68, label %18
18: ; preds = %10
%19 = call i32 @fread(i8* %7, i32 512, i32 1, i32* %16)
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %61
21: ; preds = %18
%22 = call i32 @puts(i8* dereferenceable(1) %15)
%23 = load i8, i8* %8
%24 = zext i8 %23 to i64
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %24
%26 = icmp eq i8 %23, 0
br i1 %26, label %66, label %27
27: ; preds = %21, %59
%28 = phi i8* [ %39, %59 ], [ %9, %21 ]
%29 = phi i8* [ %30, %59 ], [ %7, %21 ]
%30 = getelementptr inbounds i8, i8* %29, i64 3
%31 = getelementptr inbounds i8, i8* %28, i64 1
%32 = load i8, i8* %28
%33 = zext i8 %32 to i32
%34 = getelementptr inbounds i8, i8* %28, i64 2
%35 = load i8, i8* %31
%36 = zext i8 %35 to i32
%37 = shl nuw nsw i32 %36, 8
%38 = or i32 %37, %33
%39 = getelementptr inbounds i8, i8* %28, i64 3
%40 = load i8, i8* %34
%41 = zext i8 %40 to i32
%42 = shl nuw nsw i32 %41, 16
%43 = or i32 %38, %42
%44 = icmp eq i32 %43, 0
br i1 %44, label %59, label %45
45: ; preds = %27
%46 = getelementptr inbounds i8, i8* %29, i64 1
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = shl nuw nsw i32 %48, 8
%50 = load i8, i8* %29
%51 = zext i8 %50 to i32
%52 = or i32 %49, %51
%53 = getelementptr inbounds i8, i8* %29, i64 2
%54 = load i8, i8* %53
%55 = zext i8 %54 to i32
%56 = shl nuw nsw i32 %55, 16
%57 = or i32 %52, %56
%58 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %57, i32 %43, i32 %43)
br label %59
59: ; preds = %45, %27
%60 = icmp ult i8* %30, %25
br i1 %60, label %27, label %66
61: ; preds = %18
%62 = load i32, i32* @stderr
%63 = load i32, i32* @errno
%64 = call i8* @strerror(i32 %63)
%65 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %15, i8* %64)
br label %66
66: ; preds = %59, %21, %61
%67 = phi i32 [ 3, %61 ], [ %13, %21 ], [ %13, %59 ]
br label %73
68: ; preds = %10
%69 = load i32, i32* @stderr
%70 = load i32, i32* @errno
%71 = call i8* @strerror(i32 %70)
%72 = call i32 @fprintf(i32 %69, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i8* %15, i8* %71)
br label %73
73: ; preds = %68, %66
%74 = phi i32 [ %67, %66 ], [ 2, %68 ]
%75 = add nsw i32 %11, -1
%76 = icmp eq i32 %75, 0
br i1 %76, label %80, label %10
77: ; preds = %2
%78 = load i32, i32* @stderr
%79 = tail call i32 @fputs(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %78)
br label %80
80: ; preds = %73, %77
%81 = phi i32 [ 1, %77 ], [ %74, %73 ]
ret i32 %81
}