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

/* Variables and functions */
int /*<<< orphan*/ MAP_SHARED;
int O_RDWR;
int O_SYNC;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(unsigned long *, unsigned long, int,
                         int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned long *);
int /*<<< orphan*/ fwrite(void *, unsigned long, int, int /*<<< orphan*/ *);
scalar_t__ malloc(unsigned long);
void *mmap(int /*<<< orphan*/, unsigned long, int, int /*<<< orphan*/, int,
           unsigned long);
int /*<<< orphan*/ munmap(void *, unsigned long);
int open(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  off_t mfpTarget = 0x40E10000;
  void *mfp_map_base, *mfp_virt_base;
  int fd, func;
  unsigned long *buff;
  int i;
  FILE *dumpFile;
  if (argc < 2) {
    printf("Usage: %s set/get/cmp file\n", argv[0]);
    return 0;
  }
  if (!strcmp(argv[1], "set"))
    func = 0;
  else if (!strcmp(argv[1], "cmp"))
    func = 2;
  else
    func = 1;
  if (func == 1)
    dumpFile = fopen(argv[2], "wb");
  else
    dumpFile = fopen(argv[2], "rb");
  if (!dumpFile) {
    printf("'%s' open failed.\n", argv[2]);
    return 0;
  }
  fd = open("/dev/mem", O_RDWR | O_SYNC);
  if (!fd) {
    printf("/dev/mem open failed.\n");
    return 0;
  }
  mfp_map_base = mmap(0, 16384UL, PROT_READ | PROT_WRITE, MAP_SHARED, fd,
                      mfpTarget & ~(16384UL - 1));
  if (mfp_map_base == (void *)-1) {
    printf("mmap fail\n");
    return 0;
  }
  printf("MFP Memory mapped at address %p.\n", mfp_map_base);
  mfp_virt_base = mfp_map_base + (mfpTarget & (16384UL - 1));
  printf("Init, mfp virtual base at %p (phys=0x%X)\n", mfp_virt_base,
         mfpTarget);
  if (func == 0)
    fread(mfp_virt_base, 16384UL, 1, dumpFile);
  else if (func == 1)
    fwrite(mfp_virt_base, 16384UL, 1, dumpFile);
  else {
    buff = (unsigned long *)malloc(16384UL);
    if (!buff) {
      printf("alloc fail\n");
      return 0;
    }
    fread(buff, 16384UL, 1, dumpFile);
    printf("num\taddr\tfile\tMFP\n");
    for (i = 0; i < (16384UL / 4); i++)
      if (*(buff + i) != *(((unsigned long *)mfp_virt_base) + i))
        printf("%i:\t%04x\t%08x\t%08x\n", i, i * 4, *(buff + i),
               *(((unsigned long *)mfp_virt_base) + i));
    free(buff);
  }
  fclose(dumpFile);
  munmap(mfp_map_base, 16384UL);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x40e10000,-0x18(%rbp)
40
cmpl   $0x2,-0x8(%rbp)
jge    11f9 <main+0x49>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    14eb <main+0x33b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe14(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1222 <main+0x72>
movl   $0x0,-0x30(%rbp)
jmp    1257 <main+0xa7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdef(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    124b <main+0x9b>
movl   $0x2,-0x30(%rbp)
jmp    1252 <main+0xa2>
movl   $0x1,-0x30(%rbp)
jmp    1257 <main+0xa7>
cmpl   $0x1,-0x30(%rbp)
jne    127e <main+0xce>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdb4(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x48(%rbp)
jmp    1296 <main+0xe6>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd9a(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    12c3 <main+0x113>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xd7a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    14eb <main+0x33b>
mov    0x2d0e(%rip),%rax
mov    (%rax),%esi
mov    0x2cfd(%rip),%rax
or     (%rax),%esi
lea    0xd61(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jne    1308 <main+0x158>
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    14eb <main+0x33b>
mov    0x2ce9(%rip),%rax
mov    (%rax),%edx
mov    0x2ca8(%rip),%rax
or     (%rax),%edx
mov    0x2cc7(%rip),%rax
mov    (%rax),%ecx
mov    -0x2c(%rbp),%r8d
mov    -0x18(%rbp),%r9
and    $0xffffffffffffc000,%r9
xor    %edi,%edi
mov    $0x4000,%esi
call   1060 <mmap@plt>
mov    %rax,-0x20(%rbp)
mov    $0xffffffffffffffff,%rax
cmp    %rax,-0x20(%rbp)
jne    136d <main+0x1bd>
lea    0xd03(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    14eb <main+0x33b>
mov    -0x20(%rbp),%rsi
lea    0xcf0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
and    $0x3fff,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xce6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x0,-0x30(%rbp)
jne    13d1 <main+0x221>
mov    -0x28(%rbp),%rdi
mov    -0x48(%rbp),%rcx
mov    $0x4000,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
jmp    14d4 <main+0x324>
cmpl   $0x1,-0x30(%rbp)
jne    13f7 <main+0x247>
mov    -0x28(%rbp),%rdi
mov    -0x48(%rbp),%rcx
mov    $0x4000,%esi
mov    $0x1,%edx
call   10d0 <fwrite@plt>
jmp    14cf <main+0x31f>
mov    $0x4000,%edi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    142a <main+0x27a>
lea    0xc9d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    14eb <main+0x33b>
mov    -0x38(%rbp),%rdi
mov    -0x48(%rbp),%rcx
mov    $0x4000,%esi
mov    $0x1,%edx
call   1040 <fread@plt>
lea    0xc78(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x3c(%rbp)
movslq -0x3c(%rbp),%rax
cmp    $0x1000,%rax
jae    14c6 <main+0x316>
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    -0x28(%rbp),%rcx
movslq -0x3c(%rbp),%rdx
cmp    (%rcx,%rdx,8),%rax
je     14b3 <main+0x303>
mov    -0x3c(%rbp),%esi
mov    -0x3c(%rbp),%edx
shl    $0x2,%edx
mov    -0x38(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rcx
mov    -0x28(%rbp),%rax
movslq -0x3c(%rbp),%rdi
mov    (%rax,%rdi,8),%r8
lea    0xc27(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    14b8 <main+0x308>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1456 <main+0x2a6>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
jmp    14d4 <main+0x324>
mov    -0x48(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
mov    $0x4000,%esi
call   10a0 <munmap@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     11e2 <main+0x22>
mov    (%rbx),%rsi
lea    0xe23(%rip),%rdi
jmp    12ee <main+0x12e>
mov    0x8(%rbx),%rbp
lea    0xe2f(%rip),%rsi
mov    %rbp,%rdi
call   1090 <strcmp@plt>
mov    %eax,%r15d
test   %eax,%eax
je     121b <main+0x5b>
lea    0xe1d(%rip),%rsi
mov    %rbp,%rdi
call   1090 <strcmp@plt>
test   %eax,%eax
je     121b <main+0x5b>
mov    $0x1,%bpl
lea    0xe0b(%rip),%rsi
jmp    1224 <main+0x64>
lea    0xe05(%rip),%rsi
xor    %ebp,%ebp
mov    0x10(%rbx),%rdi
call   10d0 <fopen@plt>
test   %rax,%rax
je     12e3 <main+0x123>
mov    %rax,%r14
mov    0x2d98(%rip),%rax
mov    0x2d89(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xdeb(%rip),%rdi
call   10c0 <open@plt>
test   %eax,%eax
je     1306 <main+0x146>
mov    0x2d92(%rip),%rcx
mov    0x2d53(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2d70(%rip),%rcx
mov    (%rcx),%ecx
mov    $0x4000,%esi
mov    $0x40e10000,%r9d
xor    %edi,%edi
mov    %eax,%r8d
call   1070 <mmap@plt>
cmp    $0xffffffffffffffff,%rax
je     1314 <main+0x154>
mov    %rax,%r12
lea    0xda7(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xdb8(%rip),%rdi
mov    $0x40e10000,%edx
mov    %r12,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
test   %r15d,%r15d
je     1322 <main+0x162>
test   %bpl,%bpl
je     1339 <main+0x179>
mov    $0x4000,%esi
mov    %r12,%rdi
mov    $0x1,%edx
mov    %r14,%rcx
call   10e0 <fwrite@plt>
jmp    13b6 <main+0x1f6>
mov    0x10(%rbx),%rsi
lea    0xd3c(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd99(%rip),%rdi
call   1040 <puts@plt>
jmp    12f5 <main+0x135>
lea    0xdbe(%rip),%rdi
call   1040 <puts@plt>
jmp    12f5 <main+0x135>
mov    $0x4000,%esi
mov    %r12,%rdi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fread@plt>
jmp    13b6 <main+0x1f6>
mov    $0x4000,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     13d0 <main+0x210>
mov    %rax,%r13
mov    $0x4000,%esi
mov    %rax,%rdi
mov    $0x1,%edx
mov    %r14,%rcx
call   1050 <fread@plt>
lea    0xd5c(%rip),%rdi
call   1040 <puts@plt>
lea    0xd1b(%rip),%r15
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    1390 <main+0x1d0>
nopl   (%rax)
add    $0x1,%rbp
add    $0x4,%ebx
cmp    $0x1000,%rbp
je     13ae <main+0x1ee>
mov    0x0(%r13,%rbp,8),%rcx
mov    (%r12,%rbp,8),%r8
cmp    %r8,%rcx
je     1380 <main+0x1c0>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1380 <main+0x1c0>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    $0x4000,%esi
mov    %r12,%rdi
call   10b0 <munmap@plt>
jmp    12f5 <main+0x135>
lea    0xce5(%rip),%rdi
call   1040 <puts@plt>
jmp    12f5 <main+0x135>

LLVM IR (-O0):
@.str = [28 x i8] c"Usage: %s set/get/cmp file\0A\00"
@.str.1 = [4 x i8] c"set\00"
@.str.2 = [4 x i8] c"cmp\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [3 x i8] c"rb\00"
@.str.5 = [19 x i8] c"'%s' open failed.\0A\00"
@.str.6 = [9 x i8] c"/dev/mem\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@.str.7 = [23 x i8] c"/dev/mem open failed.\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.8 = [11 x i8] c"mmap fail\0A\00"
@.str.9 = [34 x i8] c"MFP Memory mapped at address %p.\0A\00"
@.str.10 = [42 x i8] c"Init, mfp virtual base at %p (phys=0x%X)\0A\00"
@.str.11 = [12 x i8] c"alloc fail\0A\00"
@.str.12 = [19 x i8] c"num\09addr\09file\09MFP\0A\00"
@.str.13 = [20 x i8] c"%i:\09%04x\09%08x\09%08x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64*
%12 = alloca i32
%13 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 1088487424, i64* %6
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 2
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %19)
store i32 0, i32* %3
br label %162
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %21
store i32 0, i32* %10
br label %37
28: ; preds = %21
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @strcmp(i8* %31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp ne i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %28
store i32 2, i32* %10
br label %36
35: ; preds = %28
store i32 1, i32* %10
br label %36
36: ; preds = %35, %34
br label %37
37: ; preds = %36, %27
%38 = load i32, i32* %10
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %45
40: ; preds = %37
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call i32* @fopen(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %44, i32** %13
br label %50
45: ; preds = %37
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 2
%48 = load i8*, i8** %47
%49 = call i32* @fopen(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %49, i32** %13
br label %50
50: ; preds = %45, %40
%51 = load i32*, i32** %13
%52 = icmp ne i32* %51, null
br i1 %52, label %58, label %53
53: ; preds = %50
%54 = load i8**, i8*** %5
%55 = getelementptr inbounds i8*, i8** %54, i64 2
%56 = load i8*, i8** %55
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %56)
store i32 0, i32* %3
br label %162
58: ; preds = %50
%59 = load i32, i32* @O_RDWR
%60 = load i32, i32* @O_SYNC
%61 = or i32 %59, %60
%62 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %61)
store i32 %62, i32* %9
%63 = load i32, i32* %9
%64 = icmp ne i32 %63, 0
br i1 %64, label %67, label %65
65: ; preds = %58
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %3
br label %162
67: ; preds = %58
%68 = load i32, i32* @PROT_READ
%69 = load i32, i32* @PROT_WRITE
%70 = or i32 %68, %69
%71 = load i32, i32* @MAP_SHARED
%72 = load i32, i32* %9
%73 = load i64, i64* %6
%74 = and i64 %73, -16384
%75 = call i8* @mmap(i32 0, i64 16384, i32 %70, i32 %71, i32 %72, i64 %74)
store i8* %75, i8** %7
%76 = load i8*, i8** %7
%77 = icmp eq i8* %76, inttoptr (i64 -1 to i8*)
br i1 %77, label %78, label %80
78: ; preds = %67
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %3
br label %162
80: ; preds = %67
%81 = load i8*, i8** %7
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i8* %81)
%83 = load i8*, i8** %7
%84 = load i64, i64* %6
%85 = and i64 %84, 16383
%86 = getelementptr i8, i8* %83, i64 %85
store i8* %86, i8** %8
%87 = load i8*, i8** %8
%88 = load i64, i64* %6
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.10, i64 0, i64 0), i8* %87, i64 %88)
%90 = load i32, i32* %10
%91 = icmp eq i32 %90, 0
br i1 %91, label %92, label %97
92: ; preds = %80
%93 = load i8*, i8** %8
%94 = bitcast i8* %93 to i64*
%95 = load i32*, i32** %13
%96 = call i32 @fread(i64* %94, i64 16384, i32 1, i32* %95)
br label %157
97: ; preds = %80
%98 = load i32, i32* %10
%99 = icmp eq i32 %98, 1
br i1 %99, label %100, label %104
100: ; preds = %97
%101 = load i8*, i8** %8
%102 = load i32*, i32** %13
%103 = call i32 @fwrite(i8* %101, i64 16384, i32 1, i32* %102)
br label %156
104: ; preds = %97
%105 = call i64 @malloc(i64 16384)
%106 = inttoptr i64 %105 to i64*
store i64* %106, i64** %11
%107 = load i64*, i64** %11
%108 = icmp ne i64* %107, null
br i1 %108, label %111, label %109
109: ; preds = %104
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
store i32 0, i32* %3
br label %162
111: ; preds = %104
%112 = load i64*, i64** %11
%113 = load i32*, i32** %13
%114 = call i32 @fread(i64* %112, i64 16384, i32 1, i32* %113)
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %12
br label %116
116: ; preds = %150, %111
%117 = load i32, i32* %12
%118 = sext i32 %117 to i64
%119 = icmp ult i64 %118, 4096
br i1 %119, label %120, label %153
120: ; preds = %116
%121 = load i64*, i64** %11
%122 = load i32, i32* %12
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i64, i64* %121, i64 %123
%125 = load i64, i64* %124
%126 = load i8*, i8** %8
%127 = bitcast i8* %126 to i64*
%128 = load i32, i32* %12
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds i64, i64* %127, i64 %129
%131 = load i64, i64* %130
%132 = icmp ne i64 %125, %131
br i1 %132, label %133, label %149
133: ; preds = %120
%134 = load i32, i32* %12
%135 = load i32, i32* %12
%136 = mul nsw i32 %135, 4
%137 = load i64*, i64** %11
%138 = load i32, i32* %12
%139 = sext i32 %138 to i64
%140 = getelementptr inbounds i64, i64* %137, i64 %139
%141 = load i64, i64* %140
%142 = load i8*, i8** %8
%143 = bitcast i8* %142 to i64*
%144 = load i32, i32* %12
%145 = sext i32 %144 to i64
%146 = getelementptr inbounds i64, i64* %143, i64 %145
%147 = load i64, i64* %146
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i32 %134, i32 %136, i64 %141, i64 %147)
br label %149
149: ; preds = %133, %120
br label %150
150: ; preds = %149
%151 = load i32, i32* %12
%152 = add nsw i32 %151, 1
store i32 %152, i32* %12
br label %116
153: ; preds = %116
%154 = load i64*, i64** %11
%155 = call i32 @free(i64* %154)
br label %156
156: ; preds = %153, %100
br label %157
157: ; preds = %156, %92
%158 = load i32*, i32** %13
%159 = call i32 @fclose(i32* %158)
%160 = load i8*, i8** %7
%161 = call i32 @munmap(i8* %160, i64 16384)
br label %162
162: ; preds = %157, %109, %78, %65, %53, %16
%163 = load i32, i32* %3
ret i32 %163
}

LLVM IR (-O2):
@.str = [28 x i8] c"Usage: %s set/get/cmp file\0A\00"
@.str.1 = [4 x i8] c"set\00"
@.str.2 = [4 x i8] c"cmp\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [3 x i8] c"rb\00"
@.str.5 = [19 x i8] c"'%s' open failed.\0A\00"
@.str.6 = [9 x i8] c"/dev/mem\00"
@O_RDWR = global i32 0
@O_SYNC = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.9 = [34 x i8] c"MFP Memory mapped at address %p.\0A\00"
@.str.10 = [42 x i8] c"Init, mfp virtual base at %p (phys=0x%X)\0A\00"
@.str.13 = [20 x i8] c"%i:\09%04x\09%08x\09%08x\0A\00"
@str = [22 x i8] c"/dev/mem open failed.\00"
@str.14 = [11 x i8] c"alloc fail\00"
@str.15 = [18 x i8] c"num\09addr\09file\09MFP\00"
@str.16 = [10 x i8] c"mmap fail\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %82
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %7
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %7, %12
br label %16
16: ; preds = %12, %15
%17 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), %15 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), %12 ]
%18 = phi i1 [ false, %15 ], [ true, %12 ]
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32* @fopen(i8* %20, i8* %17)
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %27
23: ; preds = %16
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i8* %25)
br label %82
27: ; preds = %16
%28 = load i32, i32* @O_RDWR
%29 = load i32, i32* @O_SYNC
%30 = or i32 %29, %28
%31 = tail call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %30)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %27
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %82
35: ; preds = %27
%36 = load i32, i32* @PROT_READ
%37 = load i32, i32* @PROT_WRITE
%38 = or i32 %37, %36
%39 = load i32, i32* @MAP_SHARED
%40 = tail call i8* @mmap(i32 0, i64 16384, i32 %38, i32 %39, i32 %31, i64 1088487424)
%41 = icmp eq i8* %40, inttoptr (i64 -1 to i8*)
br i1 %41, label %42, label %44
42: ; preds = %35
%43 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.16, i64 0, i64 0))
br label %82
44: ; preds = %35
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i8* %40)
%46 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.10, i64 0, i64 0), i8* %40, i64 1088487424)
br i1 %11, label %47, label %50
47: ; preds = %44
%48 = bitcast i8* %40 to i64*
%49 = tail call i32 @fread(i64* %48, i64 16384, i32 1, i32* %21)
br label %79
50: ; preds = %44
br i1 %18, label %51, label %53
51: ; preds = %50
%52 = tail call i32 @fwrite(i8* %40, i64 16384, i32 1, i32* %21)
br label %79
53: ; preds = %50
%54 = tail call i64 @malloc(i64 16384)
%55 = inttoptr i64 %54 to i64*
%56 = icmp eq i64 %54, 0
br i1 %56, label %57, label %59
57: ; preds = %53
%58 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.14, i64 0, i64 0))
br label %82
59: ; preds = %53
%60 = tail call i32 @fread(i64* %55, i64 16384, i32 1, i32* %21)
%61 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.15, i64 0, i64 0))
%62 = bitcast i8* %40 to i64*
br label %63
63: ; preds = %59, %74
%64 = phi i64 [ 0, %59 ], [ %75, %74 ]
%65 = trunc i64 %64 to i32
%66 = getelementptr inbounds i64, i64* %55, i64 %64
%67 = load i64, i64* %66
%68 = getelementptr inbounds i64, i64* %62, i64 %64
%69 = load i64, i64* %68
%70 = icmp eq i64 %67, %69
br i1 %70, label %74, label %71
71: ; preds = %63
%72 = shl nuw nsw i32 %65, 2
%73 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i32 %65, i32 %72, i64 %67, i64 %69)
br label %74
74: ; preds = %63, %71
%75 = add nuw nsw i64 %64, 1
%76 = icmp eq i64 %75, 4096
br i1 %76, label %77, label %63
77: ; preds = %74
%78 = tail call i32 @free(i64* %55)
br label %79
79: ; preds = %51, %77, %47
%80 = tail call i32 @fclose(i32* %21)
%81 = tail call i32 @munmap(i8* %40, i64 16384)
br label %82
82: ; preds = %79, %57, %42, %33, %23, %4
ret i32 0
}