#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 uint8_t;
typedef int uint32_t;
typedef int off_t;

/* Variables and functions */
int *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ PROT_READ;
int /*<<< orphan*/ assert(int);
int crc32_sz(int *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int *mmap(int /*<<< orphan*/ *, int, int /*<<< orphan*/, int /*<<< orphan*/,
          int, int /*<<< orphan*/);
int /*<<< orphan*/ munmap(int *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ putchar(int);
int reconstruct_data(int, int);
int /*<<< orphan*/ stderr;
scalar_t__ write_to(int, int *, int);
int reveal(int fd, int newfd, int mapfd, off_t st_size, off_t map_st_size) {
  uint32_t crc_32, file_size, bytes;
  uint8_t *addr, *map;
  uint8_t table_i, map_i;
  uint8_t buffer[4096];
  if (st_size != map_st_size) {
    fprintf(stderr, "Size of odirure and map files differ!\n");
    return -1;
  }
  addr = mmap(NULL, st_size, PROT_READ, MAP_SHARED, fd, 0);
  if (addr == MAP_FAILED) {
    perror("map");
    return -1;
  }
  map = mmap(NULL, map_st_size, PROT_READ, MAP_SHARED, mapfd, 0);
  if (map == MAP_FAILED) {
    perror("map");
    return -1;
  }
  crc_32 = *((uint32_t *)map);
  file_size = *((uint32_t *)addr);
  bytes = 0;
  if (((st_size - 4) * 2) - file_size > 1) {
    fprintf(stderr, "((size of odirure file - 4) * 2) "
                    "shall not differ from file_size by more than 1.\n");
    return -1;
  }
  int i;
  for (i = 4; i < st_size; i++) {
    table_i = (addr[i] & 0xF0) >> 4;
    map_i = (map[i] & 0xF0) >> 4;
    buffer[bytes++] = reconstruct_data(table_i, map_i);
    if (bytes == file_size)
      break;
    table_i = (addr[i] & 0x0F);
    map_i = (map[i] & 0x0F);
    buffer[bytes++] = reconstruct_data(table_i, map_i);
    assert(bytes <= 4096);
    if (bytes == 4096) {
      if (write_to(newfd, buffer, 4096))
        return -1;
      bytes = 0;
    }
  }
  if (crc_32 != crc32_sz(buffer, bytes)) {
    fprintf(stderr, "Checksum doesn't match: crc_32: %08x\n", crc_32);
    return -1;
  }
  printf("Remaining bytes: %u\n", bytes);
  for (i = 0; i < bytes; i++)
    putchar(buffer[i]);
  if (write_to(newfd, buffer, bytes))
    return -1;
  munmap(addr, st_size);
  munmap(map, map_st_size);
  return 0;
}


x86 assembly (clang, -O0):
<reveal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4050,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     11ea <reveal+0x4a>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
lea    0xe29(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14fa <reveal+0x35a>
mov    -0x14(%rbp),%esi
mov    0x2e04(%rip),%rax
mov    (%rax),%edx
mov    0x2deb(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    0x2daa(%rip),%rcx
cmp    (%rcx),%rax
jne    123f <reveal+0x9f>
lea    0xdf9(%rip),%rdi
call   10b0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14fa <reveal+0x35a>
mov    -0x18(%rbp),%esi
mov    0x2daf(%rip),%rax
mov    (%rax),%edx
mov    0x2d96(%rip),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%r8d
xor    %eax,%eax
mov    %eax,%edi
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    0x2d55(%rip),%rcx
cmp    (%rcx),%rax
jne    1294 <reveal+0xf4>
lea    0xda4(%rip),%rdi
call   10b0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14fa <reveal+0x35a>
mov    -0x38(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
shl    $0x1,%eax
sub    -0x20(%rbp),%eax
cmp    $0x1,%eax
jle    12e5 <reveal+0x145>
mov    0x2d07(%rip),%rax
mov    (%rax),%edi
lea    0xd59(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14fa <reveal+0x35a>
movl   $0x4,-0x4044(%rbp)
mov    -0x4044(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1416 <reveal+0x276>
mov    -0x30(%rbp),%rax
movslq -0x4044(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
and    $0xf0,%eax
sar    $0x4,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%rax
movslq -0x4044(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
and    $0xf0,%eax
sar    $0x4,%eax
mov    %eax,-0x40(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x40(%rbp),%esi
call   10c0 <reconstruct_data@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x24(%rbp)
cltq
mov    %ecx,-0x4040(%rbp,%rax,4)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    1362 <reveal+0x1c2>
jmp    1416 <reveal+0x276>
mov    -0x30(%rbp),%rax
movslq -0x4044(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
and    $0xf,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%rax
movslq -0x4044(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
and    $0xf,%eax
mov    %eax,-0x40(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x40(%rbp),%esi
call   10c0 <reconstruct_data@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x24(%rbp)
cltq
mov    %ecx,-0x4040(%rbp,%rax,4)
cmpl   $0x1000,-0x24(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
cmpl   $0x1000,-0x24(%rbp)
jne    13fd <reveal+0x25d>
mov    -0xc(%rbp),%edi
lea    -0x4040(%rbp),%rsi
mov    $0x1000,%edx
call   1060 <write_to@plt>
cmp    $0x0,%rax
je     13f6 <reveal+0x256>
movl   $0xffffffff,-0x4(%rbp)
jmp    14fa <reveal+0x35a>
movl   $0x0,-0x24(%rbp)
jmp    1402 <reveal+0x262>
mov    -0x4044(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4044(%rbp)
jmp    12ef <reveal+0x14f>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4048(%rbp)
lea    -0x4040(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10a0 <crc32_sz@plt>
mov    %eax,%ecx
mov    -0x4048(%rbp),%eax
cmp    %ecx,%eax
je     1464 <reveal+0x2c4>
mov    0x2b8b(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xc2c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14fa <reveal+0x35a>
mov    -0x24(%rbp),%esi
lea    0xc35(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4044(%rbp)
mov    -0x4044(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    14b3 <reveal+0x313>
movslq -0x4044(%rbp),%rax
mov    -0x4040(%rbp,%rax,4),%edi
call   1030 <putchar@plt>
mov    -0x4044(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4044(%rbp)
jmp    147d <reveal+0x2dd>
mov    -0xc(%rbp),%edi
lea    -0x4040(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1060 <write_to@plt>
cmp    $0x0,%rax
je     14db <reveal+0x33b>
movl   $0xffffffff,-0x4(%rbp)
jmp    14fa <reveal+0x35a>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1090 <munmap@plt>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1090 <munmap@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reveal>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4028,%rsp
mov    %esi,0x4(%rsp)
cmp    %r8d,%ecx
jne    1248 <reveal+0xa8>
mov    %ecx,%ebp
mov    %edx,%ebx
mov    %edi,%eax
mov    0x2e2d(%rip),%r13
mov    0x0(%r13),%edx
mov    0x2e12(%rip),%r15
mov    (%r15),%ecx
xor    %edi,%edi
mov    %ebp,%esi
mov    %eax,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    0x2dd9(%rip),%r14
cmp    (%r14),%rax
je     1347 <reveal+0x1a7>
mov    %rax,%r12
mov    0x0(%r13),%edx
mov    (%r15),%ecx
xor    %edi,%edi
mov    %ebp,%esi
mov    %ebx,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
cmp    (%r14),%rax
je     1347 <reveal+0x1a7>
mov    %rbp,%rcx
mov    %rax,%r13
mov    (%r12),%edx
lea    0x0(%rbp,%rbp,1),%eax
mov    %edx,0x8(%rsp)
sub    %edx,%eax
add    $0xfffffff8,%eax
cmp    $0x1,%eax
jle    1276 <reveal+0xd6>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
lea    0xde5(%rip),%rsi
jmp    1258 <reveal+0xb8>
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
lea    0xda8(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x4028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x0(%r13),%eax
mov    %eax,0xc(%rsp)
xor    %ebp,%ebp
mov    %rcx,0x10(%rsp)
cmp    $0x5,%ecx
jl     135e <reveal+0x1be>
mov    0x10(%rsp),%eax
mov    %rax,0x18(%rsp)
xor    %ebp,%ebp
mov    $0x4,%r14d
jmp    12bf <reveal+0x11f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14
cmp    %r14,0x18(%rsp)
je     135e <reveal+0x1be>
mov    (%r12,%r14,4),%edi
shr    $0x4,%edi
and    $0xf,%edi
mov    0x0(%r13,%r14,4),%esi
shr    $0x4,%esi
and    $0xf,%esi
call   10c0 <reconstruct_data@plt>
lea    0x1(%rbp),%r15d
movslq %ebp,%rcx
mov    %eax,0x20(%rsp,%rcx,4)
cmp    0x8(%rsp),%r15d
je     1358 <reveal+0x1b8>
mov    (%r12,%r14,4),%edi
and    $0xf,%edi
mov    0x0(%r13,%r14,4),%esi
and    $0xf,%esi
call   10c0 <reconstruct_data@plt>
lea    0x2(%rbp),%ebx
movslq %r15d,%rcx
mov    %eax,0x20(%rsp,%rcx,4)
xor    %edi,%edi
cmp    $0xfff,%ebp
setl   %dil
call   1070 <assert@plt>
mov    %ebx,%ebp
cmp    $0x1000,%ebx
jne    12b0 <reveal+0x110>
mov    0x4(%rsp),%edi
lea    0x20(%rsp),%rsi
mov    $0x1000,%edx
call   1060 <write_to@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     12b0 <reveal+0x110>
jmp    125f <reveal+0xbf>
lea    0xcd9(%rip),%rdi
call   10b0 <perror@plt>
jmp    125f <reveal+0xbf>
mov    0x8(%rsp),%eax
mov    %eax,%ebp
lea    0x20(%rsp),%rdi
mov    %ebp,%esi
call   10a0 <crc32_sz@plt>
mov    0xc(%rsp),%edx
cmp    %eax,%edx
jne    13e3 <reveal+0x243>
lea    0xd2a(%rip),%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
test   %ebp,%ebp
jle    13a2 <reveal+0x202>
mov    %ebp,%r14d
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    0x20(%rsp,%rbx,4),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1390 <reveal+0x1f0>
lea    0x20(%rsp),%rsi
mov    0x4(%rsp),%edi
mov    %ebp,%edx
call   1060 <write_to@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    1264 <reveal+0xc4>
mov    %r12,%rdi
mov    0x10(%rsp),%rbx
mov    %ebx,%esi
call   1090 <munmap@plt>
mov    %r13,%rdi
mov    %ebx,%esi
call   1090 <munmap@plt>
xor    %eax,%eax
jmp    1264 <reveal+0xc4>
mov    0x2be6(%rip),%rax
mov    (%rax),%edi
lea    0xc8a(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    125f <reveal+0xbf>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [39 x i8] c"Size of odirure and map files differ!\0A\00"
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i32* null
@.str.1 = [4 x i8] c"map\00"
@.str.2 = [82 x i8] c"((size of odirure file - 4) * 2) shall not differ from file_size by more than 1.\0A\00"
@.str.3 = [38 x i8] c"Checksum doesn't match: crc_32: %08x\0A\00"
@.str.4 = [21 x i8] c"Remaining bytes: %u\0A\00"
define i32 @reveal(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32
%18 = alloca i32
%19 = alloca [4096 x i32]
%20 = alloca i32
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%21 = load i32, i32* %10
%22 = load i32, i32* %11
%23 = icmp ne i32 %21, %22
br i1 %23, label %24, label %27
24: ; preds = %5
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %6
br label %171
27: ; preds = %5
%28 = load i32, i32* %10
%29 = load i32, i32* @PROT_READ
%30 = load i32, i32* @MAP_SHARED
%31 = load i32, i32* %7
%32 = call i32* @mmap(i32* null, i32 %28, i32 %29, i32 %30, i32 %31, i32 0)
store i32* %32, i32** %15
%33 = load i32*, i32** %15
%34 = load i32*, i32** @MAP_FAILED
%35 = icmp eq i32* %33, %34
br i1 %35, label %36, label %38
36: ; preds = %27
%37 = call i32 @perror(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %6
br label %171
38: ; preds = %27
%39 = load i32, i32* %11
%40 = load i32, i32* @PROT_READ
%41 = load i32, i32* @MAP_SHARED
%42 = load i32, i32* %9
%43 = call i32* @mmap(i32* null, i32 %39, i32 %40, i32 %41, i32 %42, i32 0)
store i32* %43, i32** %16
%44 = load i32*, i32** %16
%45 = load i32*, i32** @MAP_FAILED
%46 = icmp eq i32* %44, %45
br i1 %46, label %47, label %49
47: ; preds = %38
%48 = call i32 @perror(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %6
br label %171
49: ; preds = %38
%50 = load i32*, i32** %16
%51 = load i32, i32* %50
store i32 %51, i32* %12
%52 = load i32*, i32** %15
%53 = load i32, i32* %52
store i32 %53, i32* %13
store i32 0, i32* %14
%54 = load i32, i32* %10
%55 = sub nsw i32 %54, 4
%56 = mul nsw i32 %55, 2
%57 = load i32, i32* %13
%58 = sub nsw i32 %56, %57
%59 = icmp sgt i32 %58, 1
br i1 %59, label %60, label %63
60: ; preds = %49
%61 = load i32, i32* @stderr
%62 = call i32 (i32, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %6
br label %171
63: ; preds = %49
store i32 4, i32* %20
br label %64
64: ; preds = %128, %63
%65 = load i32, i32* %20
%66 = load i32, i32* %10
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %131
68: ; preds = %64
%69 = load i32*, i32** %15
%70 = load i32, i32* %20
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i32, i32* %69, i64 %71
%73 = load i32, i32* %72
%74 = and i32 %73, 240
%75 = ashr i32 %74, 4
store i32 %75, i32* %17
%76 = load i32*, i32** %16
%77 = load i32, i32* %20
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i32, i32* %76, i64 %78
%80 = load i32, i32* %79
%81 = and i32 %80, 240
%82 = ashr i32 %81, 4
store i32 %82, i32* %18
%83 = load i32, i32* %17
%84 = load i32, i32* %18
%85 = call i32 @reconstruct_data(i32 %83, i32 %84)
%86 = load i32, i32* %14
%87 = add nsw i32 %86, 1
store i32 %87, i32* %14
%88 = sext i32 %86 to i64
%89 = getelementptr inbounds [4096 x i32], [4096 x i32]* %19, i64 0, i64 %88
store i32 %85, i32* %89
%90 = load i32, i32* %14
%91 = load i32, i32* %13
%92 = icmp eq i32 %90, %91
br i1 %92, label %93, label %94
93: ; preds = %68
br label %131
94: ; preds = %68
%95 = load i32*, i32** %15
%96 = load i32, i32* %20
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i32, i32* %95, i64 %97
%99 = load i32, i32* %98
%100 = and i32 %99, 15
store i32 %100, i32* %17
%101 = load i32*, i32** %16
%102 = load i32, i32* %20
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds i32, i32* %101, i64 %103
%105 = load i32, i32* %104
%106 = and i32 %105, 15
store i32 %106, i32* %18
%107 = load i32, i32* %17
%108 = load i32, i32* %18
%109 = call i32 @reconstruct_data(i32 %107, i32 %108)
%110 = load i32, i32* %14
%111 = add nsw i32 %110, 1
store i32 %111, i32* %14
%112 = sext i32 %110 to i64
%113 = getelementptr inbounds [4096 x i32], [4096 x i32]* %19, i64 0, i64 %112
store i32 %109, i32* %113
%114 = load i32, i32* %14
%115 = icmp sle i32 %114, 4096
%116 = zext i1 %115 to i32
%117 = call i32 @assert(i32 %116)
%118 = load i32, i32* %14
%119 = icmp eq i32 %118, 4096
br i1 %119, label %120, label %127
120: ; preds = %94
%121 = load i32, i32* %8
%122 = getelementptr inbounds [4096 x i32], [4096 x i32]* %19, i64 0, i64 0
%123 = call i64 @write_to(i32 %121, i32* %122, i32 4096)
%124 = icmp ne i64 %123, 0
br i1 %124, label %125, label %126
125: ; preds = %120
store i32 -1, i32* %6
br label %171
126: ; preds = %120
store i32 0, i32* %14
br label %127
127: ; preds = %126, %94
br label %128
128: ; preds = %127
%129 = load i32, i32* %20
%130 = add nsw i32 %129, 1
store i32 %130, i32* %20
br label %64
131: ; preds = %93, %64
%132 = load i32, i32* %12
%133 = getelementptr inbounds [4096 x i32], [4096 x i32]* %19, i64 0, i64 0
%134 = load i32, i32* %14
%135 = call i32 @crc32_sz(i32* %133, i32 %134)
%136 = icmp ne i32 %132, %135
br i1 %136, label %137, label %141
137: ; preds = %131
%138 = load i32, i32* @stderr
%139 = load i32, i32* %12
%140 = call i32 (i32, i8*, ...) @fprintf(i32 %138, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %139)
store i32 -1, i32* %6
br label %171
141: ; preds = %131
%142 = load i32, i32* %14
%143 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %142)
store i32 0, i32* %20
br label %144
144: ; preds = %154, %141
%145 = load i32, i32* %20
%146 = load i32, i32* %14
%147 = icmp slt i32 %145, %146
br i1 %147, label %148, label %157
148: ; preds = %144
%149 = load i32, i32* %20
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds [4096 x i32], [4096 x i32]* %19, i64 0, i64 %150
%152 = load i32, i32* %151
%153 = call i32 @putchar(i32 %152)
br label %154
154: ; preds = %148
%155 = load i32, i32* %20
%156 = add nsw i32 %155, 1
store i32 %156, i32* %20
br label %144
157: ; preds = %144
%158 = load i32, i32* %8
%159 = getelementptr inbounds [4096 x i32], [4096 x i32]* %19, i64 0, i64 0
%160 = load i32, i32* %14
%161 = call i64 @write_to(i32 %158, i32* %159, i32 %160)
%162 = icmp ne i64 %161, 0
br i1 %162, label %163, label %164
163: ; preds = %157
store i32 -1, i32* %6
br label %171
164: ; preds = %157
%165 = load i32*, i32** %15
%166 = load i32, i32* %10
%167 = call i32 @munmap(i32* %165, i32 %166)
%168 = load i32*, i32** %16
%169 = load i32, i32* %11
%170 = call i32 @munmap(i32* %168, i32 %169)
store i32 0, i32* %6
br label %171
171: ; preds = %164, %163, %137, %125, %60, %47, %36, %24
%172 = load i32, i32* %6
ret i32 %172
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [39 x i8] c"Size of odirure and map files differ!\0A\00"
@PROT_READ = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i32* null
@.str.1 = [4 x i8] c"map\00"
@.str.2 = [82 x i8] c"((size of odirure file - 4) * 2) shall not differ from file_size by more than 1.\0A\00"
@.str.3 = [38 x i8] c"Checksum doesn't match: crc_32: %08x\0A\00"
@.str.4 = [21 x i8] c"Remaining bytes: %u\0A\00"
define i32 @reveal(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca [4096 x i32]
%7 = bitcast [4096 x i32]* %6 to i8*
%8 = icmp eq i32 %3, %4
br i1 %8, label %12, label %9
9: ; preds = %5
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %105
12: ; preds = %5
%13 = load i32, i32* @PROT_READ
%14 = load i32, i32* @MAP_SHARED
%15 = tail call i32* @mmap(i32* null, i32 %3, i32 %13, i32 %14, i32 %0, i32 0)
%16 = load i32*, i32** @MAP_FAILED
%17 = icmp eq i32* %15, %16
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = tail call i32 @perror(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %105
20: ; preds = %12
%21 = load i32, i32* @PROT_READ
%22 = load i32, i32* @MAP_SHARED
%23 = tail call i32* @mmap(i32* null, i32 %3, i32 %21, i32 %22, i32 %2, i32 0)
%24 = load i32*, i32** @MAP_FAILED
%25 = icmp eq i32* %23, %24
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = tail call i32 @perror(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %105
28: ; preds = %20
%29 = load i32, i32* %23
%30 = load i32, i32* %15
%31 = shl i32 %3, 1
%32 = add i32 %31, -8
%33 = sub i32 %32, %30
%34 = icmp sgt i32 %33, 1
br i1 %34, label %40, label %35
35: ; preds = %28
%36 = icmp sgt i32 %3, 4
br i1 %36, label %37, label %79
37: ; preds = %35
%38 = getelementptr inbounds [4096 x i32], [4096 x i32]* %6, i64 0, i64 0
%39 = zext i32 %3 to i64
br label %43
40: ; preds = %28
%41 = load i32, i32* @stderr
%42 = tail call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0))
br label %105
43: ; preds = %37, %75
%44 = phi i64 [ 4, %37 ], [ %77, %75 ]
%45 = phi i32 [ 0, %37 ], [ %76, %75 ]
%46 = getelementptr inbounds i32, i32* %15, i64 %44
%47 = load i32, i32* %46
%48 = lshr i32 %47, 4
%49 = and i32 %48, 15
%50 = getelementptr inbounds i32, i32* %23, i64 %44
%51 = load i32, i32* %50
%52 = lshr i32 %51, 4
%53 = and i32 %52, 15
%54 = call i32 @reconstruct_data(i32 %49, i32 %53)
%55 = add nsw i32 %45, 1
%56 = sext i32 %45 to i64
%57 = getelementptr inbounds [4096 x i32], [4096 x i32]* %6, i64 0, i64 %56
store i32 %54, i32* %57
%58 = icmp eq i32 %55, %30
br i1 %58, label %79, label %59
59: ; preds = %43
%60 = load i32, i32* %46
%61 = and i32 %60, 15
%62 = load i32, i32* %50
%63 = and i32 %62, 15
%64 = call i32 @reconstruct_data(i32 %61, i32 %63)
%65 = add nsw i32 %45, 2
%66 = sext i32 %55 to i64
%67 = getelementptr inbounds [4096 x i32], [4096 x i32]* %6, i64 0, i64 %66
store i32 %64, i32* %67
%68 = icmp slt i32 %45, 4095
%69 = zext i1 %68 to i32
%70 = call i32 @assert(i32 %69)
%71 = icmp eq i32 %65, 4096
br i1 %71, label %72, label %75
72: ; preds = %59
%73 = call i64 @write_to(i32 %1, i32* %38, i32 4096)
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %105
75: ; preds = %72, %59
%76 = phi i32 [ %65, %59 ], [ 0, %72 ]
%77 = add nuw nsw i64 %44, 1
%78 = icmp eq i64 %77, %39
br i1 %78, label %79, label %43
79: ; preds = %75, %43, %35
%80 = phi i32 [ 0, %35 ], [ %30, %43 ], [ %76, %75 ]
%81 = getelementptr inbounds [4096 x i32], [4096 x i32]* %6, i64 0, i64 0
%82 = call i32 @crc32_sz(i32* %81, i32 %80)
%83 = icmp eq i32 %29, %82
br i1 %83, label %87, label %84
84: ; preds = %79
%85 = load i32, i32* @stderr
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %29)
br label %105
87: ; preds = %79
%88 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %80)
%89 = icmp sgt i32 %80, 0
br i1 %89, label %90, label %99
90: ; preds = %87
%91 = zext i32 %80 to i64
br label %92
92: ; preds = %90, %92
%93 = phi i64 [ 0, %90 ], [ %97, %92 ]
%94 = getelementptr inbounds [4096 x i32], [4096 x i32]* %6, i64 0, i64 %93
%95 = load i32, i32* %94
%96 = call i32 @putchar(i32 %95)
%97 = add nuw nsw i64 %93, 1
%98 = icmp eq i64 %97, %91
br i1 %98, label %99, label %92
99: ; preds = %92, %87
%100 = call i64 @write_to(i32 %1, i32* %81, i32 %80)
%101 = icmp eq i64 %100, 0
br i1 %101, label %102, label %105
102: ; preds = %99
%103 = call i32 @munmap(i32* %15, i32 %3)
%104 = call i32 @munmap(i32* %23, i32 %3)
br label %105
105: ; preds = %72, %84, %102, %99, %40, %26, %18, %9
%106 = phi i32 [ -1, %9 ], [ -1, %18 ], [ -1, %26 ], [ -1, %40 ], [ -1, %84 ], [ 0, %102 ], [ -1, %99 ], [ -1, %72 ]
ret i32 %106
}