#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 __u32;

/* Variables and functions */
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_RDWR;
int PROT_READ;
int PROT_WRITE;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWUSR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
unsigned char *mmap(int /*<<< orphan*/, int, int, int /*<<< orphan*/, int,
                    int /*<<< orphan*/);
int /*<<< orphan*/ munmap(unsigned char *, int);
int open(char *, int /*<<< orphan*/, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, unsigned char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
char *strerror(int /*<<< orphan*/);
int strtoul(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  int regfd, ifd;
  int bytes;
  unsigned char *regspace;
  __u32 start = 0;
  if (argc < 2 || argc > 3 || (argc >= 2 && !strcmp(argv[1], "--help"))) {
    printf("Loads a binary dump of the tl880's registers\n");
    printf("Usage: %s reg_file [start_addr]\n", argv[0]);
    return -1;
  }
  if (argc == 3) {
    start = (strtoul(argv[2], NULL, 16) >> 2) << 2;
  }
  if ((regfd = open("/dev/tl880/reg0", O_RDWR)) < 0) {
    perror("Unable to open /dev/tl880/reg0");
    return -1;
  }
  printf("Mapping register space\n");
  if (!(regspace = mmap(0, 0x00100000, PROT_READ | PROT_WRITE, MAP_SHARED,
                        regfd, 0))) {
    perror("Failed to mmap register space");
    close(regfd);
    return -1;
  }
  printf("Opening register dump\n");
  if ((ifd = open(argv[1], O_RDONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) <
      0) {
    fprintf(stderr, "Failed to open output file %s: %s\n", argv[1],
            strerror(errno));
    munmap(regspace, 0x00100000);
    close(regfd);
    return -1;
  }
  printf("Writing register space\n");
  if ((bytes = read(ifd, regspace + start, 0x0040000)) == -1) {
    perror("Failed to load register dump");
    munmap(regspace, 0x00100000);
    close(regfd);
    close(ifd);
    return -1;
  }
  printf("Read %i bytes\n", bytes);
  close(ifd);
  printf("Unmapping register space\n");
  munmap(regspace, 0x00100000);
  close(regfd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     1208 <main+0x58>
cmpl   $0x3,-0x8(%rbp)
jg     1208 <main+0x58>
cmpl   $0x2,-0x8(%rbp)
jl     1237 <main+0x87>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe06(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1237 <main+0x87>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1466 <main+0x2b6>
cmpl   $0x3,-0x8(%rbp)
jne    1260 <main+0xb0>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   10c0 <strtoul@plt>
sar    $0x2,%eax
shl    $0x2,%eax
mov    %eax,-0x2c(%rbp)
mov    0x2d71(%rip),%rax
mov    (%rax),%esi
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   10a0 <open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    129b <main+0xeb>
lea    0xdcc(%rip),%rdi
call   10b0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1466 <main+0x2b6>
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d48(%rip),%rax
mov    (%rax),%edx
mov    0x2cdf(%rip),%rax
or     (%rax),%edx
mov    0x2d26(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
xor    %r9d,%r9d
mov    $0x100000,%esi
mov    %r9d,%edi
call   1030 <mmap@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1306 <main+0x156>
lea    0xda0(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1466 <main+0x2b6>
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2cad(%rip),%rax
mov    (%rax),%esi
mov    0x2c64(%rip),%rax
mov    (%rax),%edx
mov    0x2c93(%rip),%rax
or     (%rax),%edx
mov    0x2c6a(%rip),%rax
or     (%rax),%edx
mov    0x2c59(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   10a0 <open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    13ba <main+0x20a>
mov    0x2c55(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    0x2c35(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%rdx
mov    %rax,%rcx
lea    0xd2f(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    $0x100000,%esi
call   1090 <munmap@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1466 <main+0x2b6>
lea    0xd24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x28(%rbp),%rsi
movslq -0x2c(%rbp),%rax
add    %rax,%rsi
mov    $0x40000,%edx
call   1060 <read@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
jne    1422 <main+0x272>
lea    0xd0a(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x28(%rbp),%rdi
mov    $0x100000,%esi
call   1090 <munmap@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
mov    -0x18(%rbp),%edi
call   1050 <close@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1466 <main+0x2b6>
mov    -0x1c(%rbp),%esi
lea    0xcee(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%edi
call   1050 <close@plt>
lea    0xce7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    $0x100000,%esi
call   1090 <munmap@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    -0x4(%rbp),%eax
cmp    $0xfffffffe,%eax
jb     1206 <main+0x46>
mov    0x8(%rbx),%rdi
lea    0xe20(%rip),%rsi
call   1080 <strcmp@plt>
test   %eax,%eax
je     1206 <main+0x46>
cmp    $0x3,%ebp
jne    1233 <main+0x73>
mov    0x10(%rbx),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   10d0 <strtoul@plt>
and    $0xfffffffc,%eax
movslq %eax,%r12
jmp    1236 <main+0x76>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%rsi
lea    0xdeb(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r12d,%r12d
mov    0x2d9b(%rip),%rax
mov    (%rax),%esi
lea    0xdf1(%rip),%rdi
xor    %eax,%eax
call   10b0 <open@plt>
test   %eax,%eax
js     1396 <main+0x1d6>
mov    %eax,%r14d
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d8d(%rip),%rax
mov    0x2d26(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d6b(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    $0x100000,%esi
mov    %r14d,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
test   %rax,%rax
je     13a7 <main+0x1e7>
mov    %rax,%r15
lea    0xe54(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rbx),%rdi
mov    0x2cdc(%rip),%rax
mov    0x2d0d(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2d0a(%rip),%rax
mov    0x2cdb(%rip),%rcx
or     (%rcx),%edx
mov    (%rax),%esi
mov    0x2cc8(%rip),%rax
or     (%rax),%edx
xor    %eax,%eax
call   10b0 <open@plt>
test   %eax,%eax
js     134d <main+0x18d>
mov    %eax,%ebp
lea    0xe20(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rsi
add    %r12,%rsi
mov    %ebp,%edi
mov    $0x40000,%edx
call   1070 <read@plt>
cmp    $0xffffffff,%eax
je     13b5 <main+0x1f5>
lea    0xd90(%rip),%rdi
xor    %ebx,%ebx
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
call   1060 <close@plt>
lea    0xdf7(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    $0x100000,%esi
call   10a0 <munmap@plt>
mov    %r14d,%edi
call   1060 <close@plt>
jmp    1228 <main+0x68>
mov    0x2c64(%rip),%rax
mov    (%rax),%ebp
mov    0x8(%rbx),%rbx
mov    0x2c4f(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
lea    0xcf6(%rip),%rsi
mov    %ebp,%edi
mov    %rbx,%rdx
mov    %rax,%rcx
call   1090 <fprintf@plt>
mov    %r15,%rdi
mov    $0x100000,%esi
call   10a0 <munmap@plt>
mov    %r14d,%edi
call   1060 <close@plt>
jmp    1223 <main+0x63>
lea    0xc8b(%rip),%rdi
call   10c0 <perror@plt>
jmp    1223 <main+0x63>
lea    0xc99(%rip),%rdi
call   10c0 <perror@plt>
jmp    1389 <main+0x1c9>
lea    0xccc(%rip),%rdi
call   10c0 <perror@plt>
mov    %r15,%rdi
mov    $0x100000,%esi
call   10a0 <munmap@plt>
mov    %r14d,%edi
call   1060 <close@plt>
mov    %ebp,%edi
jmp    138c <main+0x1cc>

LLVM IR (-O0):
@.str = [7 x i8] c"--help\00"
@.str.1 = [46 x i8] c"Loads a binary dump of the tl880's registers\0A\00"
@.str.2 = [33 x i8] c"Usage: %s reg_file [start_addr]\0A\00"
@.str.3 = [16 x i8] c"/dev/tl880/reg0\00"
@O_RDWR = global i32 0
@.str.4 = [31 x i8] c"Unable to open /dev/tl880/reg0\00"
@.str.5 = [24 x i8] c"Mapping register space\0A\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.6 = [30 x i8] c"Failed to mmap register space\00"
@.str.7 = [23 x i8] c"Opening register dump\0A\00"
@O_RDONLY = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@stderr = global i32 0
@.str.8 = [35 x i8] c"Failed to open output file %s: %s\0A\00"
@errno = global i32 0
@.str.9 = [24 x i8] c"Writing register space\0A\00"
@.str.10 = [29 x i8] c"Failed to load register dump\00"
@.str.11 = [15 x i8] c"Read %i bytes\0A\00"
@.str.12 = [26 x i8] c"Unmapping register space\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %10
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %25, label %13
13: ; preds = %2
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 3
br i1 %15, label %25, label %16
16: ; preds = %13
%17 = load i32, i32* %4
%18 = icmp sge i32 %17, 2
br i1 %18, label %19, label %31
19: ; preds = %16
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %19, %13, %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 0
%29 = load i8*, i8** %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %29)
store i32 -1, i32* %3
br label %114
31: ; preds = %19, %16
%32 = load i32, i32* %4
%33 = icmp eq i32 %32, 3
br i1 %33, label %34, label %41
34: ; preds = %31
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32 @strtoul(i8* %37, i32* null, i32 16)
%39 = ashr i32 %38, 2
%40 = shl i32 %39, 2
store i32 %40, i32* %10
br label %41
41: ; preds = %34, %31
%42 = load i32, i32* @O_RDWR
%43 = call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %42)
store i32 %43, i32* %6
%44 = icmp slt i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %114
47: ; preds = %41
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%49 = load i32, i32* @PROT_READ
%50 = load i32, i32* @PROT_WRITE
%51 = or i32 %49, %50
%52 = load i32, i32* @MAP_SHARED
%53 = load i32, i32* %6
%54 = call i8* @mmap(i32 0, i32 1048576, i32 %51, i32 %52, i32 %53, i32 0)
store i8* %54, i8** %9
%55 = icmp ne i8* %54, null
br i1 %55, label %60, label %56
56: ; preds = %47
%57 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%58 = load i32, i32* %6
%59 = call i32 @close(i32 %58)
store i32 -1, i32* %3
br label %114
60: ; preds = %47
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 1
%64 = load i8*, i8** %63
%65 = load i32, i32* @O_RDONLY
%66 = load i32, i32* @S_IRUSR
%67 = load i32, i32* @S_IWUSR
%68 = or i32 %66, %67
%69 = load i32, i32* @S_IRGRP
%70 = or i32 %68, %69
%71 = load i32, i32* @S_IROTH
%72 = or i32 %70, %71
%73 = call i32 (i8*, i32, ...) @open(i8* %64, i32 %65, i32 %72)
store i32 %73, i32* %7
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %87
75: ; preds = %60
%76 = load i32, i32* @stderr
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 1
%79 = load i8*, i8** %78
%80 = load i32, i32* @errno
%81 = call i8* @strerror(i32 %80)
%82 = call i32 @fprintf(i32 %76, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i8* %79, i8* %81)
%83 = load i8*, i8** %9
%84 = call i32 @munmap(i8* %83, i32 1048576)
%85 = load i32, i32* %6
%86 = call i32 @close(i32 %85)
store i32 -1, i32* %3
br label %114
87: ; preds = %60
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0))
%89 = load i32, i32* %7
%90 = load i8*, i8** %9
%91 = load i32, i32* %10
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8, i8* %90, i64 %92
%94 = call i32 @read(i32 %89, i8* %93, i32 262144)
store i32 %94, i32* %8
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %104
96: ; preds = %87
%97 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
%98 = load i8*, i8** %9
%99 = call i32 @munmap(i8* %98, i32 1048576)
%100 = load i32, i32* %6
%101 = call i32 @close(i32 %100)
%102 = load i32, i32* %7
%103 = call i32 @close(i32 %102)
store i32 -1, i32* %3
br label %114
104: ; preds = %87
%105 = load i32, i32* %8
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0), i32 %105)
%107 = load i32, i32* %7
%108 = call i32 @close(i32 %107)
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.12, i64 0, i64 0))
%110 = load i8*, i8** %9
%111 = call i32 @munmap(i8* %110, i32 1048576)
%112 = load i32, i32* %6
%113 = call i32 @close(i32 %112)
store i32 0, i32* %3
br label %114
114: ; preds = %104, %96, %75, %56, %45, %25
%115 = load i32, i32* %3
ret i32 %115
}

LLVM IR (-O2):
@.str = [7 x i8] c"--help\00"
@.str.2 = [33 x i8] c"Usage: %s reg_file [start_addr]\0A\00"
@.str.3 = [16 x i8] c"/dev/tl880/reg0\00"
@O_RDWR = global i32 0
@.str.4 = [31 x i8] c"Unable to open /dev/tl880/reg0\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@.str.6 = [30 x i8] c"Failed to mmap register space\00"
@O_RDONLY = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@stderr = global i32 0
@.str.8 = [35 x i8] c"Failed to open output file %s: %s\0A\00"
@errno = global i32 0
@.str.10 = [29 x i8] c"Failed to load register dump\00"
@.str.11 = [15 x i8] c"Read %i bytes\0A\00"
@str = [45 x i8] c"Loads a binary dump of the tl880's registers\00"
@str.13 = [23 x i8] c"Mapping register space\00"
@str.14 = [22 x i8] c"Opening register dump\00"
@str.15 = [23 x i8] c"Writing register space\00"
@str.16 = [25 x i8] c"Unmapping register space\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = add i32 %0, -4
%4 = icmp ult i32 %3, -2
br i1 %4, label %10, label %5
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %7, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %5, %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str, i64 0, i64 0))
%12 = load i8*, i8** %1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %12)
br label %77
14: ; preds = %5
%15 = icmp eq i32 %0, 3
br i1 %15, label %16, label %22
16: ; preds = %14
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = tail call i32 @strtoul(i8* nocapture %18, i32* null, i32 16)
%20 = and i32 %19, -4
%21 = sext i32 %20 to i64
br label %22
22: ; preds = %16, %14
%23 = phi i64 [ %21, %16 ], [ 0, %14 ]
%24 = load i32, i32* @O_RDWR
%25 = tail call i32 (i8*, i32, ...) @open(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = tail call i32 @perror(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
br label %77
29: ; preds = %22
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.13, i64 0, i64 0))
%31 = load i32, i32* @PROT_READ
%32 = load i32, i32* @PROT_WRITE
%33 = or i32 %32, %31
%34 = load i32, i32* @MAP_SHARED
%35 = tail call i8* @mmap(i32 0, i32 1048576, i32 %33, i32 %34, i32 %25, i32 0)
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %40
37: ; preds = %29
%38 = tail call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%39 = tail call i32 @close(i32 %25)
br label %77
40: ; preds = %29
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.14, i64 0, i64 0))
%42 = load i8*, i8** %6
%43 = load i32, i32* @O_RDONLY
%44 = load i32, i32* @S_IRUSR
%45 = load i32, i32* @S_IWUSR
%46 = or i32 %45, %44
%47 = load i32, i32* @S_IRGRP
%48 = or i32 %46, %47
%49 = load i32, i32* @S_IROTH
%50 = or i32 %48, %49
%51 = tail call i32 (i8*, i32, ...) @open(i8* %42, i32 %43, i32 %50)
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %61
53: ; preds = %40
%54 = load i32, i32* @stderr
%55 = load i8*, i8** %6
%56 = load i32, i32* @errno
%57 = tail call i8* @strerror(i32 %56)
%58 = tail call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), i8* %55, i8* %57)
%59 = tail call i32 @munmap(i8* %35, i32 1048576)
%60 = tail call i32 @close(i32 %25)
br label %77
61: ; preds = %40
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.15, i64 0, i64 0))
%63 = getelementptr inbounds i8, i8* %35, i64 %23
%64 = tail call i32 @read(i32 %51, i8* %63, i32 262144)
%65 = icmp eq i32 %64, -1
br i1 %65, label %66, label %71
66: ; preds = %61
%67 = tail call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
%68 = tail call i32 @munmap(i8* %35, i32 1048576)
%69 = tail call i32 @close(i32 %25)
%70 = tail call i32 @close(i32 %51)
br label %77
71: ; preds = %61
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0), i32 %64)
%73 = tail call i32 @close(i32 %51)
%74 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.16, i64 0, i64 0))
%75 = tail call i32 @munmap(i8* %35, i32 1048576)
%76 = tail call i32 @close(i32 %25)
br label %77
77: ; preds = %71, %66, %53, %37, %27, %10
%78 = phi i32 [ -1, %10 ], [ -1, %27 ], [ -1, %53 ], [ -1, %66 ], [ 0, %71 ], [ -1, %37 ]
ret i32 %78
}