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

/* Variables and functions */
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ lseek(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ nand_calculate_ecc(int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, int /*<<< orphan*/ *, int);
int strtol(char *, int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ useage();
int /*<<< orphan*/ write(int, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  uint32_t start_address, size;
  char *nand_image;
  uint32_t pagenumber, pages;
  int nand_fd;
  uint32_t i, j;
  uint8_t page_data[2048 + 64];
  uint8_t ecc_data[3];
  if (argc != 4) {
    useage();
    exit(1);
  }
  nand_image = argv[1];
  start_address = strtol(argv[2], NULL, 0);
  size = strtol(argv[3], NULL, 0);
  nand_fd = open(nand_image, O_RDWR);
  if (nand_fd < 0) {
    printf("Can not open nand image %s \n", nand_image);
    exit(1);
  }
  if (start_address >= 0x10000000) {
    printf("start_address can no be more than 0x%x \n", 0x10000000);
    exit(1);
  }
  if ((start_address % 2048) != 0) {
    printf("start_address should be aligned to page boundary \n");
    exit(1);
  }
  if (size == 0) {
    printf("size can no be zero \n");
    exit(1);
  }
  if ((size % 2048) != 0) {
    printf("size should be aligned to page boundary \n");
    exit(1);
  }
  pagenumber = start_address / 2048;
  pages = size / 2048;
  for (i = 0; i < pages; i++) {
    lseek(nand_fd, pagenumber * (2048 + 64), SEEK_SET);
    read(nand_fd, page_data, 2048 + 64);
    for (j = 0; j < 2048 / 256; j++) {
      nand_calculate_ecc(page_data + j * 256, ecc_data);
      memcpy(page_data + 2048 + 0x28 + j * 3, ecc_data, 3);
    }
    lseek(nand_fd, pagenumber * (2048 + 64), SEEK_SET);
    write(nand_fd, page_data, 2048 + 64);
    pagenumber++;
  }
  close(nand_fd);
  return (1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11e4 <main+0x34>
mov    $0x0,%al
call   10d0 <useage@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1080 <strtol@plt>
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2dc1(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1257 <main+0xa7>
mov    -0x20(%rbp),%rsi
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
cmpl   $0x10000000,-0x14(%rbp)
jl     1281 <main+0xd1>
lea    0xdb2(%rip),%rdi
mov    $0x10000000,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x14(%rbp),%eax
mov    $0x800,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     12ad <main+0xfd>
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
cmpl   $0x0,-0x18(%rbp)
jne    12cf <main+0x11f>
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x18(%rbp),%eax
mov    $0x800,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     12fb <main+0x14b>
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x14(%rbp),%eax
mov    $0x800,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
mov    $0x800,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    140d <main+0x25d>
mov    -0x2c(%rbp),%edi
imul   $0x840,-0x24(%rbp),%esi
mov    0x2c9d(%rip),%rax
mov    (%rax),%edx
call   1050 <lseek@plt>
mov    -0x2c(%rbp),%edi
lea    -0x2140(%rbp),%rsi
mov    $0x840,%edx
call   1070 <read@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x8,-0x34(%rbp)
jge    13ca <main+0x21a>
lea    -0x2140(%rbp),%rdi
mov    -0x34(%rbp),%eax
shl    $0x8,%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
lea    -0x214c(%rbp),%rsi
call   10a0 <nand_calculate_ecc@plt>
lea    -0x2140(%rbp),%rdi
add    $0x2000,%rdi
add    $0xa0,%rdi
imul   $0x3,-0x34(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
lea    -0x214c(%rbp),%rsi
mov    $0x3,%edx
call   1090 <memcpy@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    135d <main+0x1ad>
mov    -0x2c(%rbp),%edi
imul   $0x840,-0x24(%rbp),%esi
mov    0x2bfd(%rip),%rax
mov    (%rax),%edx
call   1050 <lseek@plt>
mov    -0x2c(%rbp),%edi
lea    -0x2140(%rbp),%rsi
mov    $0x840,%edx
call   1030 <write@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    131e <main+0x16e>
mov    -0x2c(%rbp),%edi
call   1060 <close@plt>
mov    $0x1,%eax
add    $0x2150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2118,%rsp
cmp    $0x4,%edi
jne    1417 <main+0x257>
mov    %rsi,%rbx
mov    0x8(%rsi),%r14
mov    0x10(%rsi),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <strtol@plt>
mov    %eax,%r15d
mov    0x18(%rbx),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <strtol@plt>
mov    %eax,%ebp
mov    0x2de1(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   10c0 <open@plt>
test   %eax,%eax
js     1428 <main+0x268>
cmp    $0x10000000,%r15d
jge    1443 <main+0x283>
test   $0x7ff,%r15d
jne    1460 <main+0x2a0>
test   %ebp,%ebp
je     1469 <main+0x2a9>
test   $0x7ff,%ebp
jne    1472 <main+0x2b2>
mov    %eax,%ebx
lea    0x7ff(%rbp),%r13d
test   %ebp,%ebp
cmovns %ebp,%r13d
cmp    $0x800,%ebp
jl     13f9 <main+0x239>
sar    $0xb,%r13d
lea    0x7ff(%r15),%eax
test   %r15d,%r15d
cmovns %r15d,%eax
sar    $0xb,%eax
imul   $0x840,%eax,%ebp
mov    0x2d54(%rip),%r14
lea    0x10(%rsp),%r15
lea    0x4(%rsp),%r12
xchg   %ax,%ax
mov    (%r14),%edx
mov    %ebx,%edi
mov    %ebp,%esi
call   1060 <lseek@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x840,%edx
call   1080 <read@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   10b0 <nand_calculate_ecc@plt>
lea    0x20b0(%rsp),%rdi
mov    %r12,%rsi
mov    $0x3,%edx
call   10a0 <memcpy@plt>
lea    0x410(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <nand_calculate_ecc@plt>
lea    0x20bc(%rsp),%rdi
mov    %r12,%rsi
mov    $0x3,%edx
call   10a0 <memcpy@plt>
lea    0x810(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <nand_calculate_ecc@plt>
lea    0x20c8(%rsp),%rdi
mov    %r12,%rsi
mov    $0x3,%edx
call   10a0 <memcpy@plt>
lea    0xc10(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <nand_calculate_ecc@plt>
lea    0x20d4(%rsp),%rdi
mov    %r12,%rsi
mov    $0x3,%edx
call   10a0 <memcpy@plt>
lea    0x1010(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <nand_calculate_ecc@plt>
lea    0x20e0(%rsp),%rdi
mov    %r12,%rsi
mov    $0x3,%edx
call   10a0 <memcpy@plt>
lea    0x1410(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <nand_calculate_ecc@plt>
lea    0x20ec(%rsp),%rdi
mov    %r12,%rsi
mov    $0x3,%edx
call   10a0 <memcpy@plt>
lea    0x1810(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <nand_calculate_ecc@plt>
lea    0x20f8(%rsp),%rdi
mov    %r12,%rsi
mov    $0x3,%edx
call   10a0 <memcpy@plt>
lea    0x1c10(%rsp),%rdi
mov    %r12,%rsi
call   10b0 <nand_calculate_ecc@plt>
lea    0x2104(%rsp),%rdi
mov    %r12,%rsi
mov    $0x3,%edx
call   10a0 <memcpy@plt>
mov    (%r14),%edx
mov    %ebx,%edi
mov    %ebp,%esi
call   1060 <lseek@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x840,%edx
call   1040 <write@plt>
add    $0x840,%ebp
add    $0xffffffff,%r13d
jne    1290 <main+0xd0>
mov    %ebx,%edi
call   1070 <close@plt>
mov    $0x1,%eax
add    $0x2118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   10e0 <useage@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xbd1(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xbd3(%rip),%rdi
mov    $0x10000000,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xc1d(%rip),%rdi
jmp    1479 <main+0x2b9>
lea    0xbff(%rip),%rdi
jmp    1479 <main+0x2b9>
lea    0xbcd(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@O_RDWR = global i32 0
@.str = [29 x i8] c"Can not open nand image %s \0A\00"
@.str.1 = [41 x i8] c"start_address can no be more than 0x%x \0A\00"
@.str.2 = [51 x i8] c"start_address should be aligned to page boundary \0A\00"
@.str.3 = [22 x i8] c"size can no be zero \0A\00"
@.str.4 = [42 x i8] c"size should be aligned to page boundary \0A\00"
@SEEK_SET = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [2112 x i32]
%15 = alloca [3 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 4
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = call i32 (...) @useage()
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
store i8* %24, i8** %8
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @strtol(i8* %27, i32* null, i32 0)
store i32 %28, i32* %6
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 3
%31 = load i8*, i8** %30
%32 = call i32 @strtol(i8* %31, i32* null, i32 0)
store i32 %32, i32* %7
%33 = load i8*, i8** %8
%34 = load i32, i32* @O_RDWR
%35 = call i32 @open(i8* %33, i32 %34)
store i32 %35, i32* %11
%36 = load i32, i32* %11
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %21
%39 = load i8*, i8** %8
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %39)
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %21
%43 = load i32, i32* %6
%44 = icmp sge i32 %43, 268435456
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 268435456)
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %42
%49 = load i32, i32* %6
%50 = srem i32 %49, 2048
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %48
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %48
%56 = load i32, i32* %7
%57 = icmp eq i32 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %55
%62 = load i32, i32* %7
%63 = srem i32 %62, 2048
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %68
65: ; preds = %61
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%67 = call i32 @exit(i32 1)
unreachable
68: ; preds = %61
%69 = load i32, i32* %6
%70 = sdiv i32 %69, 2048
store i32 %70, i32* %9
%71 = load i32, i32* %7
%72 = sdiv i32 %71, 2048
store i32 %72, i32* %10
store i32 0, i32* %12
br label %73
73: ; preds = %120, %68
%74 = load i32, i32* %12
%75 = load i32, i32* %10
%76 = icmp slt i32 %74, %75
br i1 %76, label %77, label %123
77: ; preds = %73
%78 = load i32, i32* %11
%79 = load i32, i32* %9
%80 = mul nsw i32 %79, 2112
%81 = load i32, i32* @SEEK_SET
%82 = call i32 @lseek(i32 %78, i32 %80, i32 %81)
%83 = load i32, i32* %11
%84 = getelementptr inbounds [2112 x i32], [2112 x i32]* %14, i64 0, i64 0
%85 = call i32 @read(i32 %83, i32* %84, i32 2112)
store i32 0, i32* %13
br label %86
86: ; preds = %106, %77
%87 = load i32, i32* %13
%88 = icmp slt i32 %87, 8
br i1 %88, label %89, label %109
89: ; preds = %86
%90 = getelementptr inbounds [2112 x i32], [2112 x i32]* %14, i64 0, i64 0
%91 = load i32, i32* %13
%92 = mul nsw i32 %91, 256
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds i32, i32* %90, i64 %93
%95 = getelementptr inbounds [3 x i32], [3 x i32]* %15, i64 0, i64 0
%96 = call i32 @nand_calculate_ecc(i32* %94, i32* %95)
%97 = getelementptr inbounds [2112 x i32], [2112 x i32]* %14, i64 0, i64 0
%98 = getelementptr inbounds i32, i32* %97, i64 2048
%99 = getelementptr inbounds i32, i32* %98, i64 40
%100 = load i32, i32* %13
%101 = mul nsw i32 %100, 3
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i32, i32* %99, i64 %102
%104 = getelementptr inbounds [3 x i32], [3 x i32]* %15, i64 0, i64 0
%105 = call i32 @memcpy(i32* %103, i32* %104, i32 3)
br label %106
106: ; preds = %89
%107 = load i32, i32* %13
%108 = add nsw i32 %107, 1
store i32 %108, i32* %13
br label %86
109: ; preds = %86
%110 = load i32, i32* %11
%111 = load i32, i32* %9
%112 = mul nsw i32 %111, 2112
%113 = load i32, i32* @SEEK_SET
%114 = call i32 @lseek(i32 %110, i32 %112, i32 %113)
%115 = load i32, i32* %11
%116 = getelementptr inbounds [2112 x i32], [2112 x i32]* %14, i64 0, i64 0
%117 = call i32 @write(i32 %115, i32* %116, i32 2112)
%118 = load i32, i32* %9
%119 = add nsw i32 %118, 1
store i32 %119, i32* %9
br label %120
120: ; preds = %109
%121 = load i32, i32* %12
%122 = add nsw i32 %121, 1
store i32 %122, i32* %12
br label %73
123: ; preds = %73
%124 = load i32, i32* %11
%125 = call i32 @close(i32 %124)
ret i32 1
}

LLVM IR (-O2):
@O_RDWR = global i32 0
@.str = [29 x i8] c"Can not open nand image %s \0A\00"
@.str.1 = [41 x i8] c"start_address can no be more than 0x%x \0A\00"
@SEEK_SET = global i32 0
@str = [41 x i8] c"size should be aligned to page boundary \00"
@str.5 = [21 x i8] c"size can no be zero \00"
@str.6 = [50 x i8] c"start_address should be aligned to page boundary \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2112 x i32]
%4 = alloca [3 x i32]
%5 = bitcast [2112 x i32]* %3 to i8*
%6 = bitcast [3 x i32]* %4 to i8*
%7 = icmp eq i32 %0, 4
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = tail call i32 (...) @useage()
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32 @strtol(i8* nocapture %15, i32* null, i32 0)
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = tail call i32 @strtol(i8* nocapture %18, i32* null, i32 0)
%20 = load i32, i32* @O_RDWR
%21 = tail call i32 @open(i8* %13, i32 %20)
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %11
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %13)
%25 = tail call i32 @exit(i32 1)
unreachable
26: ; preds = %11
%27 = icmp sgt i32 %16, 268435455
br i1 %27, label %28, label %31
28: ; preds = %26
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 268435456)
%30 = tail call i32 @exit(i32 1)
unreachable
31: ; preds = %26
%32 = and i32 %16, 2047
%33 = icmp eq i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.6, i64 0, i64 0))
%36 = tail call i32 @exit(i32 1)
unreachable
37: ; preds = %31
%38 = icmp eq i32 %19, 0
br i1 %38, label %39, label %42
39: ; preds = %37
%40 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0))
%41 = tail call i32 @exit(i32 1)
unreachable
42: ; preds = %37
%43 = and i32 %19, 2047
%44 = icmp eq i32 %43, 0
br i1 %44, label %48, label %45
45: ; preds = %42
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%47 = tail call i32 @exit(i32 1)
unreachable
48: ; preds = %42
%49 = sdiv i32 %19, 2048
%50 = icmp sgt i32 %19, 2047
br i1 %50, label %51, label %99
51: ; preds = %48
%52 = sdiv i32 %16, 2048
%53 = getelementptr inbounds [2112 x i32], [2112 x i32]* %3, i64 0, i64 0
%54 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%55 = getelementptr inbounds [2112 x i32], [2112 x i32]* %3, i64 0, i64 2088
%56 = getelementptr inbounds [2112 x i32], [2112 x i32]* %3, i64 0, i64 256
%57 = getelementptr inbounds [2112 x i32], [2112 x i32]* %3, i64 0, i64 2091
%58 = getelementptr inbounds [2112 x i32], [2112 x i32]* %3, i64 0, i64 512
%59 = getelementptr inbounds [2112 x i32], [2112 x i32]* %3, i64 0, i64 2094
%60 = getelementptr inbounds [2112 x i32], [2112 x i32]* %3, i64 0, i64 768
%61 = getelementptr inbounds [2112 x i32], [2112 x i32]* %3, i64 0, i64 2097
%62 = getelementptr inbounds [2112 x i32], [2112 x i32]* %3, i64 0, i64 1024
%63 = getelementptr inbounds [2112 x i32], [2112 x i32]* %3, i64 0, i64 2100
%64 = getelementptr inbounds [2112 x i32], [2112 x i32]* %3, i64 0, i64 1280
%65 = getelementptr inbounds [2112 x i32], [2112 x i32]* %3, i64 0, i64 2103
%66 = getelementptr inbounds [2112 x i32], [2112 x i32]* %3, i64 0, i64 1536
%67 = getelementptr inbounds [2112 x i32], [2112 x i32]* %3, i64 0, i64 2106
%68 = getelementptr inbounds [2112 x i32], [2112 x i32]* %3, i64 0, i64 1792
%69 = getelementptr inbounds [2112 x i32], [2112 x i32]* %3, i64 0, i64 2109
br label %70
70: ; preds = %51, %70
%71 = phi i32 [ 0, %51 ], [ %97, %70 ]
%72 = phi i32 [ %52, %51 ], [ %96, %70 ]
%73 = mul nsw i32 %72, 2112
%74 = load i32, i32* @SEEK_SET
%75 = call i32 @lseek(i32 %21, i32 %73, i32 %74)
%76 = call i32 @read(i32 %21, i32* %53, i32 2112)
%77 = call i32 @nand_calculate_ecc(i32* %53, i32* %54)
%78 = call i32 @memcpy(i32* %55, i32* %54, i32 3)
%79 = call i32 @nand_calculate_ecc(i32* %56, i32* %54)
%80 = call i32 @memcpy(i32* %57, i32* %54, i32 3)
%81 = call i32 @nand_calculate_ecc(i32* %58, i32* %54)
%82 = call i32 @memcpy(i32* %59, i32* %54, i32 3)
%83 = call i32 @nand_calculate_ecc(i32* %60, i32* %54)
%84 = call i32 @memcpy(i32* %61, i32* %54, i32 3)
%85 = call i32 @nand_calculate_ecc(i32* %62, i32* %54)
%86 = call i32 @memcpy(i32* %63, i32* %54, i32 3)
%87 = call i32 @nand_calculate_ecc(i32* %64, i32* %54)
%88 = call i32 @memcpy(i32* %65, i32* %54, i32 3)
%89 = call i32 @nand_calculate_ecc(i32* %66, i32* %54)
%90 = call i32 @memcpy(i32* %67, i32* %54, i32 3)
%91 = call i32 @nand_calculate_ecc(i32* %68, i32* %54)
%92 = call i32 @memcpy(i32* %69, i32* %54, i32 3)
%93 = load i32, i32* @SEEK_SET
%94 = call i32 @lseek(i32 %21, i32 %73, i32 %93)
%95 = call i32 @write(i32 %21, i32* %53, i32 2112)
%96 = add nsw i32 %72, 1
%97 = add nuw nsw i32 %71, 1
%98 = icmp eq i32 %97, %49
br i1 %98, label %99, label %70
99: ; preds = %70, %48
%100 = call i32 @close(i32 %21)
ret i32 1
}