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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int atoi(char *);
int *calloc(int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ *freopen(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, int, int);
int read_value(int /*<<< orphan*/, int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  if (freopen(NULL, "rb", stdin) == NULL) {
    perror("freopen");
    exit(EXIT_FAILURE);
  }
  int offset = atoi(argv[1]);
  int track_count = argc - 2;
  int length[track_count];
  int total_length = 0;
  for (int i = 0; i < track_count; i++) {
    length[i] = atoi(argv[i + 2]) * 588;
    total_length += length[i];
  }
  length[track_count - 1] -= 5 * 588;
  uint32_t *crc = calloc(track_count, sizeof(uint32_t));
  if (crc == NULL) {
    fprintf(stderr, "Unable to allocate memory.\n");
    exit(EXIT_FAILURE);
  }
  uint32_t *crc450 = calloc(track_count, sizeof(uint32_t));
  if (crc450 == NULL) {
    fprintf(stderr, "Unable to allocate memory.\n");
    free(crc);
    exit(EXIT_FAILURE);
  }
  int track = 0;
  int di = 5 * 588 - 1 + offset;
  int ti = 5 * 588 - 1;
  for (int i = 0; i < di; i++) {
    uint32_t value;
    int r = read_value(stdin, &value);
    if (r == 0) {
      fprintf(stderr, "Unexpected EOF.\n");
      exit(EXIT_FAILURE);
    } else if (r < 0) {
      perror("read_value");
      exit(EXIT_FAILURE);
    }
  }
  while (1) {
    if (ti == length[track]) {
      ti = 0;
      printf("%03u: %08x, %08x\n", track, crc[track], crc450[track]);
      track += 1;
      if (track == track_count)
        break;
    }
    uint32_t value;
    int r = read_value(stdin, &value);
    if (r == 0) {
      fprintf(stderr, "Unexpected EOF.\n");
      exit(EXIT_FAILURE);
    } else if (r < 0) {
      perror("read_value");
      exit(EXIT_FAILURE);
    }
    crc[track] += value * (ti + 1);
    if (ti >= 450 * 588 && ti < 451 * 588) {
      crc450[track] += value * (ti - 450 * 588 + 1);
    }
    di += 1;
    ti += 1;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e3b(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%edi
lea    0xe46(%rip),%rsi
call   1060 <freopen@plt>
cmp    $0x0,%rax
jne    11e3 <main+0x53>
lea    0xe33(%rip),%rdi
call   1090 <perror@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0xfffffffe,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1281 <main+0xf1>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   10a0 <atoi@plt>
mov    %eax,%ecx
mov    -0x68(%rbp),%rax
imul   $0x24c,%ecx,%edx
movslq -0x30(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1231 <main+0xa1>
mov    -0x68(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
sub    $0xb7c,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%edi
mov    $0x4,%esi
call   1070 <calloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    12d9 <main+0x149>
mov    0x2d1b(%rip),%rax
mov    (%rax),%edi
lea    0xd45(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2cfe(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x18(%rbp),%edi
mov    $0x4,%esi
call   1070 <calloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    1321 <main+0x191>
mov    0x2cdc(%rip),%rax
mov    (%rax),%edi
lea    0xd06(%rip),%rsi
call   1080 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    0x2cb6(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x14(%rbp),%eax
add    $0xb7b,%eax
mov    %eax,-0x48(%rbp)
movl   $0xb7b,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x48(%rbp),%eax
jge    13cb <main+0x23b>
mov    0x2c94(%rip),%rax
mov    (%rax),%edi
lea    -0x54(%rbp),%rsi
call   1040 <read_value@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x0,-0x58(%rbp)
jne    138f <main+0x1ff>
mov    0x2c65(%rip),%rax
mov    (%rax),%edi
lea    0xcab(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2c48(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
cmpl   $0x0,-0x58(%rbp)
jge    13b3 <main+0x223>
lea    0xc98(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c24(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
jmp    13b8 <main+0x228>
jmp    13bd <main+0x22d>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1341 <main+0x1b1>
jmp    13d0 <main+0x240>
jmp    13d5 <main+0x245>
mov    -0x68(%rbp),%rcx
mov    -0x4c(%rbp),%eax
movslq -0x44(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jne    1434 <main+0x2a4>
movl   $0x0,-0x4c(%rbp)
mov    -0x44(%rbp),%esi
mov    -0x38(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xc33(%rip),%rdi
call   1050 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    142f <main+0x29f>
jmp    1509 <main+0x379>
jmp    1434 <main+0x2a4>
mov    0x2bad(%rip),%rax
mov    (%rax),%edi
lea    -0x5c(%rbp),%rsi
call   1040 <read_value@plt>
mov    %eax,-0x60(%rbp)
cmpl   $0x0,-0x60(%rbp)
jne    1476 <main+0x2e6>
mov    0x2b7e(%rip),%rax
mov    (%rax),%edi
lea    0xbc4(%rip),%rsi
call   1080 <fprintf@plt>
mov    0x2b61(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
cmpl   $0x0,-0x60(%rbp)
jge    149a <main+0x30a>
lea    0xbb1(%rip),%rdi
call   1090 <perror@plt>
mov    0x2b3d(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
jmp    149f <main+0x30f>
mov    -0x5c(%rbp),%edx
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
imul   %eax,%edx
mov    -0x38(%rbp),%rax
movslq -0x44(%rbp),%rcx
add    (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
cmpl   $0x40998,-0x4c(%rbp)
jl     14f2 <main+0x362>
cmpl   $0x40be4,-0x4c(%rbp)
jge    14f2 <main+0x362>
mov    -0x5c(%rbp),%edx
mov    -0x4c(%rbp),%eax
sub    $0x40998,%eax
add    $0x1,%eax
imul   %eax,%edx
mov    -0x40(%rbp),%rax
movslq -0x44(%rbp),%rcx
add    (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    13d0 <main+0x240>
mov    0x2ab8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
mov    %edi,%r15d
mov    0x2e3a(%rip),%rax
mov    (%rax),%edx
lea    0xe49(%rip),%rsi
xor    %edi,%edi
call   1060 <freopen@plt>
test   %rax,%rax
je     138e <main+0x1fe>
mov    0x8(%r14),%rdi
call   10a0 <atoi@plt>
mov    %eax,%r12d
lea    -0x2(%r15),%r13d
mov    %rsp,%rcx
lea    0xf(,%r13,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,%rsp
cmp    $0x3,%r15d
mov    %rcx,-0x40(%rbp)
jl     1220 <main+0x90>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    0x10(%r14,%rbx,8),%rdi
call   10a0 <atoi@plt>
mov    -0x40(%rbp),%rcx
imul   $0x24c,%eax,%eax
mov    %eax,(%rcx,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1200 <main+0x70>
movslq %r15d,%rax
addl   $0xfffff484,-0xc(%rcx,%rax,4)
ff
mov    %r13d,%edi
mov    $0x4,%esi
call   1070 <calloc@plt>
test   %rax,%rax
je     1397 <main+0x207>
mov    %rax,%r15
mov    %r13d,%edi
mov    $0x4,%esi
call   1070 <calloc@plt>
mov    %rax,-0x38(%rbp)
test   %rax,%rax
je     13ae <main+0x21e>
cmp    $0xfffff486,%r12d
jl     12a4 <main+0x114>
add    $0xb7a,%r12d
xor    %ebx,%ebx
test   %r12d,%r12d
cmovg  %r12d,%ebx
add    $0x1,%ebx
lea    -0x4c(%rbp),%r12
xchg   %ax,%ax
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
mov    %r12,%rsi
call   1040 <read_value@plt>
test   %eax,%eax
je     135d <main+0x1cd>
js     1374 <main+0x1e4>
add    $0xffffffff,%ebx
jne    1280 <main+0xf0>
mov    %r13,-0x48(%rbp)
mov    $0xb7b,%eax
xor    %r13d,%r13d
mov    0x2d31(%rip),%rbx
nopw   0x0(%rax,%rax,1)
movslq %r13d,%r12
mov    %eax,%r14d
mov    -0x40(%rbp),%rcx
cmp    (%rcx,%r12,4),%eax
jne    12fb <main+0x16b>
mov    (%r15,%r12,4),%edx
mov    -0x38(%rbp),%rax
mov    (%rax,%r12,4),%ecx
lea    0xd60(%rip),%rdi
mov    %r12d,%esi
call   1050 <printf@plt>
add    $0x1,%r12d
xor    %r14d,%r14d
mov    %r12d,%r13d
cmp    -0x48(%rbp),%r12d
je     1345 <main+0x1b5>
mov    (%rbx),%edi
lea    -0x2c(%rbp),%rsi
call   1040 <read_value@plt>
test   %eax,%eax
je     135d <main+0x1cd>
js     1374 <main+0x1e4>
mov    -0x2c(%rbp),%ecx
lea    0x1(%r14),%eax
mov    %ecx,%esi
imul   %eax,%esi
movslq %r13d,%rdx
add    %esi,(%r15,%rdx,4)
lea    -0x40998(%r14),%esi
cmp    $0x24b,%esi
ja     12c0 <main+0x130>
add    $0xfffbf669,%r14d
imul   %r14d,%ecx
mov    -0x38(%rbp),%rsi
add    %ecx,(%rsi,%rdx,4)
jmp    12c0 <main+0x130>
mov    0x2c7c(%rip),%rax
mov    (%rax),%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c74(%rip),%rax
mov    (%rax),%edi
lea    0xcba(%rip),%rsi
call   1080 <fprintf@plt>
jmp    1380 <main+0x1f0>
lea    0xcbd(%rip),%rdi
call   1090 <perror@plt>
mov    0x2c49(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
lea    0xc6e(%rip),%rdi
jmp    137b <main+0x1eb>
mov    0x2c3a(%rip),%rax
mov    (%rax),%edi
lea    0xc64(%rip),%rsi
call   1080 <fprintf@plt>
jmp    1380 <main+0x1f0>
mov    0x2c23(%rip),%rax
mov    (%rax),%edi
lea    0xc4d(%rip),%rsi
call   1080 <fprintf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
jmp    1380 <main+0x1f0>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@stdin = global i32 0
@.str.1 = [8 x i8] c"freopen\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.2 = [28 x i8] c"Unable to allocate memory.\0A\00"
@.str.3 = [17 x i8] c"Unexpected EOF.\0A\00"
@.str.4 = [11 x i8] c"read_value\00"
@.str.5 = [18 x i8] c"%03u: %08x, %08x\0A\00"
@EXIT_SUCCESS = 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 i64
%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 i32
%20 = alloca i32
%21 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%22 = load i32, i32* @stdin
%23 = call i32* @freopen(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %29
25: ; preds = %2
%26 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %2
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %6
%34 = load i32, i32* %4
%35 = sub nsw i32 %34, 2
store i32 %35, i32* %7
%36 = load i32, i32* %7
%37 = zext i32 %36 to i64
%38 = call i8* @llvm.stacksave()
store i8* %38, i8** %8
%39 = alloca i32, i64 %37
store i64 %37, i64* %9
store i32 0, i32* %10
store i32 0, i32* %11
br label %40
40: ; preds = %62, %29
%41 = load i32, i32* %11
%42 = load i32, i32* %7
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %65
44: ; preds = %40
%45 = load i8**, i8*** %5
%46 = load i32, i32* %11
%47 = add nsw i32 %46, 2
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8*, i8** %45, i64 %48
%50 = load i8*, i8** %49
%51 = call i32 @atoi(i8* %50)
%52 = mul nsw i32 %51, 588
%53 = load i32, i32* %11
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i32, i32* %39, i64 %54
store i32 %52, i32* %55
%56 = load i32, i32* %11
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i32, i32* %39, i64 %57
%59 = load i32, i32* %58
%60 = load i32, i32* %10
%61 = add nsw i32 %60, %59
store i32 %61, i32* %10
br label %62
62: ; preds = %44
%63 = load i32, i32* %11
%64 = add nsw i32 %63, 1
store i32 %64, i32* %11
br label %40
65: ; preds = %40
%66 = load i32, i32* %7
%67 = sub nsw i32 %66, 1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i32, i32* %39, i64 %68
%70 = load i32, i32* %69
%71 = sub nsw i32 %70, 2940
store i32 %71, i32* %69
%72 = load i32, i32* %7
%73 = call i32* @calloc(i32 %72, i32 4)
store i32* %73, i32** %12
%74 = load i32*, i32** %12
%75 = icmp eq i32* %74, null
br i1 %75, label %76, label %81
76: ; preds = %65
%77 = load i32, i32* @stderr
%78 = call i32 @fprintf(i32 %77, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%79 = load i32, i32* @EXIT_FAILURE
%80 = call i32 @exit(i32 %79)
unreachable
81: ; preds = %65
%82 = load i32, i32* %7
%83 = call i32* @calloc(i32 %82, i32 4)
store i32* %83, i32** %13
%84 = load i32*, i32** %13
%85 = icmp eq i32* %84, null
br i1 %85, label %86, label %93
86: ; preds = %81
%87 = load i32, i32* @stderr
%88 = call i32 @fprintf(i32 %87, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%89 = load i32*, i32** %12
%90 = call i32 @free(i32* %89)
%91 = load i32, i32* @EXIT_FAILURE
%92 = call i32 @exit(i32 %91)
unreachable
93: ; preds = %81
store i32 0, i32* %14
%94 = load i32, i32* %6
%95 = add nsw i32 2939, %94
store i32 %95, i32* %15
store i32 2939, i32* %16
store i32 0, i32* %17
br label %96
96: ; preds = %119, %93
%97 = load i32, i32* %17
%98 = load i32, i32* %15
%99 = icmp slt i32 %97, %98
br i1 %99, label %100, label %122
100: ; preds = %96
%101 = load i32, i32* @stdin
%102 = call i32 @read_value(i32 %101, i32* %18)
store i32 %102, i32* %19
%103 = load i32, i32* %19
%104 = icmp eq i32 %103, 0
br i1 %104, label %105, label %110
105: ; preds = %100
%106 = load i32, i32* @stderr
%107 = call i32 @fprintf(i32 %106, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%108 = load i32, i32* @EXIT_FAILURE
%109 = call i32 @exit(i32 %108)
unreachable
110: ; preds = %100
%111 = load i32, i32* %19
%112 = icmp slt i32 %111, 0
br i1 %112, label %113, label %117
113: ; preds = %110
%114 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%115 = load i32, i32* @EXIT_FAILURE
%116 = call i32 @exit(i32 %115)
unreachable
117: ; preds = %110
br label %118
118: ; preds = %117
br label %119
119: ; preds = %118
%120 = load i32, i32* %17
%121 = add nsw i32 %120, 1
store i32 %121, i32* %17
br label %96
122: ; preds = %96
br label %123
123: ; preds = %197, %122
br label %124
124: ; preds = %123
%125 = load i32, i32* %16
%126 = load i32, i32* %14
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds i32, i32* %39, i64 %127
%129 = load i32, i32* %128
%130 = icmp eq i32 %125, %129
br i1 %130, label %131, label %151
131: ; preds = %124
store i32 0, i32* %16
%132 = load i32, i32* %14
%133 = load i32*, i32** %12
%134 = load i32, i32* %14
%135 = sext i32 %134 to i64
%136 = getelementptr inbounds i32, i32* %133, i64 %135
%137 = load i32, i32* %136
%138 = load i32*, i32** %13
%139 = load i32, i32* %14
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i32, i32* %138, i64 %140
%142 = load i32, i32* %141
%143 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %132, i32 %137, i32 %142)
%144 = load i32, i32* %14
%145 = add nsw i32 %144, 1
store i32 %145, i32* %14
%146 = load i32, i32* %14
%147 = load i32, i32* %7
%148 = icmp eq i32 %146, %147
br i1 %148, label %149, label %150
149: ; preds = %131
br label %202
150: ; preds = %131
br label %151
151: ; preds = %150, %124
%152 = load i32, i32* @stdin
%153 = call i32 @read_value(i32 %152, i32* %20)
store i32 %153, i32* %21
%154 = load i32, i32* %21
%155 = icmp eq i32 %154, 0
br i1 %155, label %156, label %161
156: ; preds = %151
%157 = load i32, i32* @stderr
%158 = call i32 @fprintf(i32 %157, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%159 = load i32, i32* @EXIT_FAILURE
%160 = call i32 @exit(i32 %159)
unreachable
161: ; preds = %151
%162 = load i32, i32* %21
%163 = icmp slt i32 %162, 0
br i1 %163, label %164, label %168
164: ; preds = %161
%165 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%166 = load i32, i32* @EXIT_FAILURE
%167 = call i32 @exit(i32 %166)
unreachable
168: ; preds = %161
br label %169
169: ; preds = %168
%170 = load i32, i32* %20
%171 = load i32, i32* %16
%172 = add nsw i32 %171, 1
%173 = mul nsw i32 %170, %172
%174 = load i32*, i32** %12
%175 = load i32, i32* %14
%176 = sext i32 %175 to i64
%177 = getelementptr inbounds i32, i32* %174, i64 %176
%178 = load i32, i32* %177
%179 = add nsw i32 %178, %173
store i32 %179, i32* %177
%180 = load i32, i32* %16
%181 = icmp sge i32 %180, 264600
br i1 %181, label %182, label %197
182: ; preds = %169
%183 = load i32, i32* %16
%184 = icmp slt i32 %183, 265188
br i1 %184, label %185, label %197
185: ; preds = %182
%186 = load i32, i32* %20
%187 = load i32, i32* %16
%188 = sub nsw i32 %187, 264600
%189 = add nsw i32 %188, 1
%190 = mul nsw i32 %186, %189
%191 = load i32*, i32** %13
%192 = load i32, i32* %14
%193 = sext i32 %192 to i64
%194 = getelementptr inbounds i32, i32* %191, i64 %193
%195 = load i32, i32* %194
%196 = add nsw i32 %195, %190
store i32 %196, i32* %194
br label %197
197: ; preds = %185, %182, %169
%198 = load i32, i32* %15
%199 = add nsw i32 %198, 1
store i32 %199, i32* %15
%200 = load i32, i32* %16
%201 = add nsw i32 %200, 1
store i32 %201, i32* %16
br label %123
202: ; preds = %149
%203 = load i32, i32* @EXIT_SUCCESS
store i32 %203, i32* %3
%204 = load i8*, i8** %8
%205 = load i32, i32* %3
ret i32 %205
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@stdin = global i32 0
@.str.1 = [8 x i8] c"freopen\00"
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str.2 = [28 x i8] c"Unable to allocate memory.\0A\00"
@.str.3 = [17 x i8] c"Unexpected EOF.\0A\00"
@.str.4 = [11 x i8] c"read_value\00"
@.str.5 = [18 x i8] c"%03u: %08x, %08x\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = load i32, i32* @stdin
%6 = tail call i32* @freopen(i32* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
%16 = add i32 %0, -2
%17 = zext i32 %16 to i64
%18 = alloca i32, i64 %17
%19 = icmp sgt i32 %0, 2
br i1 %19, label %28, label %20
20: ; preds = %28, %12
%21 = add nsw i32 %0, -3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %18, i64 %22
%24 = load i32, i32* %23
%25 = add nsw i32 %24, -2940
store i32 %25, i32* %23
%26 = tail call i32* @calloc(i32 %16, i32 4)
%27 = icmp eq i32* %26, null
br i1 %27, label %38, label %43
28: ; preds = %12, %28
%29 = phi i64 [ %36, %28 ], [ 0, %12 ]
%30 = add nuw nsw i64 %29, 2
%31 = getelementptr inbounds i8*, i8** %1, i64 %30
%32 = load i8*, i8** %31
%33 = tail call i32 @atoi(i8* %32)
%34 = mul nsw i32 %33, 588
%35 = getelementptr inbounds i32, i32* %18, i64 %29
store i32 %34, i32* %35
%36 = add nuw nsw i64 %29, 1
%37 = icmp eq i64 %36, %17
br i1 %37, label %20, label %28
38: ; preds = %20
%39 = load i32, i32* @stderr
%40 = tail call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%41 = load i32, i32* @EXIT_FAILURE
%42 = tail call i32 @exit(i32 %41)
unreachable
43: ; preds = %20
%44 = tail call i32* @calloc(i32 %16, i32 4)
%45 = icmp eq i32* %44, null
br i1 %45, label %46, label %52
46: ; preds = %43
%47 = load i32, i32* @stderr
%48 = tail call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%49 = tail call i32 @free(i32* %26)
%50 = load i32, i32* @EXIT_FAILURE
%51 = tail call i32 @exit(i32 %50)
unreachable
52: ; preds = %43
%53 = icmp sgt i32 %15, -2939
br i1 %53, label %54, label %58
54: ; preds = %52
%55 = bitcast i32* %3 to i8*
%56 = add i32 %15, 2938
%57 = call i32 @llvm.smax.i32(i32 %56, i32 0)
br label %60
58: ; preds = %76, %52
%59 = bitcast i32* %4 to i8*
br label %79
60: ; preds = %54, %76
%61 = phi i32 [ 0, %54 ], [ %77, %76 ]
%62 = load i32, i32* @stdin
%63 = call i32 @read_value(i32 %62, i32* %3)
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %70
65: ; preds = %60
%66 = load i32, i32* @stderr
%67 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%68 = load i32, i32* @EXIT_FAILURE
%69 = call i32 @exit(i32 %68)
unreachable
70: ; preds = %60
%71 = icmp slt i32 %63, 0
br i1 %71, label %72, label %76
72: ; preds = %70
%73 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%74 = load i32, i32* @EXIT_FAILURE
%75 = call i32 @exit(i32 %74)
unreachable
76: ; preds = %70
%77 = add nuw i32 %61, 1
%78 = icmp eq i32 %61, %57
br i1 %78, label %58, label %60
79: ; preds = %58, %127
%80 = phi i32 [ %95, %127 ], [ 0, %58 ]
%81 = phi i32 [ %113, %127 ], [ 2939, %58 ]
%82 = sext i32 %80 to i64
%83 = getelementptr inbounds i32, i32* %18, i64 %82
%84 = load i32, i32* %83
%85 = icmp eq i32 %81, %84
br i1 %85, label %86, label %94
86: ; preds = %79
%87 = getelementptr inbounds i32, i32* %26, i64 %82
%88 = load i32, i32* %87
%89 = getelementptr inbounds i32, i32* %44, i64 %82
%90 = load i32, i32* %89
%91 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i32 %80, i32 %88, i32 %90)
%92 = add nsw i32 %80, 1
%93 = icmp eq i32 %92, %16
br i1 %93, label %128, label %94
94: ; preds = %86, %79
%95 = phi i32 [ %92, %86 ], [ %80, %79 ]
%96 = phi i32 [ 0, %86 ], [ %81, %79 ]
%97 = load i32, i32* @stdin
%98 = call i32 @read_value(i32 %97, i32* %4)
%99 = icmp eq i32 %98, 0
br i1 %99, label %100, label %105
100: ; preds = %94
%101 = load i32, i32* @stderr
%102 = call i32 @fprintf(i32 %101, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%103 = load i32, i32* @EXIT_FAILURE
%104 = call i32 @exit(i32 %103)
unreachable
105: ; preds = %94
%106 = icmp slt i32 %98, 0
br i1 %106, label %107, label %111
107: ; preds = %105
%108 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%109 = load i32, i32* @EXIT_FAILURE
%110 = call i32 @exit(i32 %109)
unreachable
111: ; preds = %105
%112 = load i32, i32* %4
%113 = add nsw i32 %96, 1
%114 = mul nsw i32 %112, %113
%115 = sext i32 %95 to i64
%116 = getelementptr inbounds i32, i32* %26, i64 %115
%117 = load i32, i32* %116
%118 = add nsw i32 %117, %114
store i32 %118, i32* %116
%119 = add i32 %96, -264600
%120 = icmp ult i32 %119, 588
br i1 %120, label %121, label %127
121: ; preds = %111
%122 = add nsw i32 %96, -264599
%123 = mul nsw i32 %112, %122
%124 = getelementptr inbounds i32, i32* %44, i64 %115
%125 = load i32, i32* %124
%126 = add nsw i32 %125, %123
store i32 %126, i32* %124
br label %127
127: ; preds = %121, %111
br label %79
128: ; preds = %86
%129 = load i32, i32* @EXIT_SUCCESS
ret i32 %129
}