#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;
struct timespec {
  scalar_t__ tv_nsec;
  scalar_t__ tv_sec;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
scalar_t__ EOF;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ encode_chunk(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                int /*<<< orphan*/ *, int, int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fread(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
int fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int fwrite(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ gen_encoding_matrix(int /*<<< orphan*/ *, int, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ write_metadata(int, int, int, int /*<<< orphan*/ *);
void encode_file(char *file, int nativeBlockNum, int parityBlockNum) {
  int chunkSize = 1;
  int totalSize;
  FILE *fp_in;
  FILE *fp_out;
  if ((fp_in = fopen(file, "rb")) == NULL) {
    printf("Can not open source file!\n");
    exit(0);
  }
  fseek(fp_in, 0L, SEEK_END);
  totalSize = ftell(fp_in);
  chunkSize = (totalSize / nativeBlockNum) + (totalSize % nativeBlockNum != 0);
  uint8_t *dataBuf;
  uint8_t *codeBuf;
  int dataSize = nativeBlockNum * chunkSize * sizeof(uint8_t);
  int codeSize = parityBlockNum * chunkSize * sizeof(uint8_t);
  dataBuf = (uint8_t *)malloc(nativeBlockNum * chunkSize * sizeof(uint8_t));
  memset(dataBuf, 0, dataSize);
  codeBuf = (uint8_t *)malloc(parityBlockNum * chunkSize * sizeof(uint8_t));
  memset(codeBuf, 0, codeSize);
  int i;
  for (i = 0; i < nativeBlockNum; i++) {
    if (fseek(fp_in, i * chunkSize, SEEK_SET) == -1) {
      printf("fseek error!\n");
      exit(0);
    }
    if (fread(dataBuf + i * chunkSize, sizeof(uint8_t), chunkSize, fp_in) ==
        EOF) {
      printf("fread error!\n");
      exit(0);
    }
  }
  fclose(fp_in);
  struct timespec total_start, total_end;
  struct timespec step_end;
  double stepTime;
  double totalTime;
  clock_gettime(CLOCK_REALTIME, &total_start);
  uint8_t *encodingMatrix;
  encodingMatrix =
      (uint8_t *)malloc(parityBlockNum * nativeBlockNum * sizeof(uint8_t));
  gen_encoding_matrix(encodingMatrix, parityBlockNum, nativeBlockNum);
  clock_gettime(CLOCK_REALTIME, &step_end);
  encode_chunk(dataBuf, encodingMatrix, codeBuf, nativeBlockNum, parityBlockNum,
               chunkSize);
  clock_gettime(CLOCK_REALTIME, &total_end);
  stepTime =
      (double)(step_end.tv_sec - total_start.tv_sec) * 1000 +
      (double)(step_end.tv_nsec - total_start.tv_nsec) / (double)1000000L;
  totalTime =
      (double)(total_end.tv_sec - total_start.tv_sec) * 1000 +
      (double)(total_end.tv_nsec - total_start.tv_nsec) / (double)1000000L;
  printf("Encoding matrix generation time: %fms\n", stepTime);
  printf("Matrix multiplication time: %fms\n", totalTime - stepTime);
  printf("Total CPU encoding time: %fms\n", totalTime);
  write_metadata(totalSize, parityBlockNum, nativeBlockNum, encodingMatrix);
  char output_file_name[100];
  for (i = 0; i < nativeBlockNum; i++) {
    sprintf(output_file_name, "_%d_", i);
    strcat(output_file_name, file);
    if ((fp_out = fopen(output_file_name, "wb")) == NULL) {
      printf("Can not open source file!\n");
      exit(0);
    }
    if (fwrite(dataBuf + i * chunkSize, sizeof(uint8_t), chunkSize, fp_out) !=
        sizeof(uint8_t) * chunkSize) {
      printf("fwrite error!\n");
      exit(0);
    }
    fclose(fp_out);
  }
  for (i = 0; i < parityBlockNum; i++) {
    sprintf(output_file_name, "_%d_", i + nativeBlockNum);
    strcat(output_file_name, file);
    if ((fp_out = fopen(output_file_name, "wb")) == NULL) {
      printf("Can not open source file!\n");
      exit(0);
    }
    if (fwrite(codeBuf + i * chunkSize, sizeof(uint8_t), chunkSize, fp_out) !=
        sizeof(uint8_t) * chunkSize) {
      printf("fwrite error!\n");
      exit(0);
    }
    fclose(fp_out);
  }
  free(dataBuf);
  free(codeBuf);
  free(encodingMatrix);
}


x86 assembly (clang, -O0):
<encode_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xdd9(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    125f <encode_file+0x4f>
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %edi,%edi
call   1110 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    0x2d7e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10c0 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <ftell@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,-0x104(%rbp)
mov    -0x18(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    -0x104(%rbp),%eax
cmp    $0x0,%edx
setne  %cl
and    $0x1,%cl
movzbl %cl,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,-0x40(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x3c(%rbp),%edx
xor    %esi,%esi
call   1080 <memset@plt>
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%edx
xor    %esi,%esi
call   1080 <memset@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    13bd <encode_file+0x1ad>
mov    -0x20(%rbp),%rdi
mov    -0x44(%rbp),%esi
imul   -0x14(%rbp),%esi
mov    0x2c95(%rip),%rax
mov    (%rax),%edx
call   10c0 <fseek@plt>
cmp    $0xffffffff,%eax
jne    1360 <encode_file+0x150>
lea    0xcdc(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %edi,%edi
call   1110 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    -0x44(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    $0x4,%esi
call   1040 <fread@plt>
mov    0x2c54(%rip),%rcx
cmp    (%rcx),%rax
jne    13aa <encode_file+0x19a>
lea    0xca0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %edi,%edi
call   1110 <exit@plt>
jmp    13af <encode_file+0x19f>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    131d <encode_file+0x10d>
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
mov    0x2bfb(%rip),%rax
mov    (%rax),%edi
lea    -0x58(%rbp),%rsi
call   1050 <clock_gettime@plt>
mov    -0x10(%rbp),%eax
imul   -0xc(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1130 <gen_encoding_matrix@plt>
mov    0x2bbc(%rip),%rax
mov    (%rax),%edi
lea    -0x78(%rbp),%rsi
call   1050 <clock_gettime@plt>
mov    -0x30(%rbp),%rdi
mov    -0x90(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
mov    -0x14(%rbp),%r9d
call   10e0 <encode_chunk@plt>
mov    0x2b8b(%rip),%rax
mov    (%rax),%edi
lea    -0x68(%rbp),%rsi
call   1050 <clock_gettime@plt>
mov    -0x70(%rbp),%rax
sub    -0x50(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    -0x78(%rbp),%rax
sub    -0x58(%rbp),%rax
cvtsi2sd %rax,%xmm1
movsd  0xb9e(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  0xb8a(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
mov    -0x60(%rbp),%rax
sub    -0x50(%rbp),%rax
cvtsi2sd %rax,%xmm0
mov    -0x68(%rbp),%rax
sub    -0x58(%rbp),%rax
cvtsi2sd %rax,%xmm1
movsd  0xb63(%rip),%xmm2
divsd  %xmm2,%xmm1
movsd  0xb4f(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
lea    0xb7d(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movsd  -0x88(%rbp),%xmm0
ff
subsd  -0x80(%rbp),%xmm0
lea    0xb89(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
movsd  -0x88(%rbp),%xmm0
ff
lea    0xb95(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x90(%rbp),%rcx
call   1090 <write_metadata@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    15ed <encode_file+0x3dd>
lea    -0x100(%rbp),%rdi
mov    -0x44(%rbp),%edx
lea    0xb74(%rip),%rsi
call   1100 <sprintf@plt>
lea    -0x100(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10f0 <strcat@plt>
lea    -0x100(%rbp),%rdi
lea    0xb56(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1589 <encode_file+0x379>
lea    0xa98(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %edi,%edi
call   1110 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    -0x44(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x14(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    $0x4,%esi
call   1120 <fwrite@plt>
cltq
movslq -0x14(%rbp),%rcx
shl    $0x2,%rcx
cmp    %rcx,%rax
je     15d6 <encode_file+0x3c6>
lea    0xaf2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %edi,%edi
call   1110 <exit@plt>
mov    -0x28(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1521 <encode_file+0x311>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    16c3 <encode_file+0x4b3>
lea    -0x100(%rbp),%rdi
mov    -0x44(%rbp),%edx
add    -0xc(%rbp),%edx
lea    0xa9e(%rip),%rsi
call   1100 <sprintf@plt>
lea    -0x100(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10f0 <strcat@plt>
lea    -0x100(%rbp),%rdi
lea    0xa80(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    165f <encode_file+0x44f>
lea    0x9c2(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %edi,%edi
call   1110 <exit@plt>
mov    -0x38(%rbp),%rdi
mov    -0x44(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x14(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    $0x4,%esi
call   1120 <fwrite@plt>
cltq
movslq -0x14(%rbp),%rcx
shl    $0x2,%rcx
cmp    %rcx,%rax
je     16ac <encode_file+0x49c>
lea    0xa1c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %edi,%edi
call   1110 <exit@plt>
mov    -0x28(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    15f4 <encode_file+0x3e4>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x90(%rbp),%rdi
call   1030 <free@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %edx,%ebx
mov    %esi,%r15d
lea    0xdd3(%rip),%rsi
mov    %rdi,0x48(%rsp)
call   10e0 <fopen@plt>
test   %rax,%rax
je     15f6 <encode_file+0x3d6>
mov    %rax,%r12
mov    0x2d8e(%rip),%rax
mov    (%rax),%edx
xor    %ebp,%ebp
mov    %r12,%rdi
xor    %esi,%esi
call   10d0 <fseek@plt>
mov    %r12,%rdi
call   10b0 <ftell@plt>
mov    %eax,0x3c(%rsp)
cltd
idiv   %r15d
mov    %eax,%r13d
cmp    $0x1,%edx
sbb    $0xffffffff,%r13d
lea    0x0(,%r15,4),%r14d
mov    %r14d,0x20(%rsp)
imul   %r13d,%r14d
mov    %ebx,0x14(%rsp)
imul   %r13d,%ebx
shl    $0x2,%ebx
mov    %r14d,%edi
call   10c0 <malloc@plt>
mov    %rax,0x18(%rsp)
mov    %rax,%rdi
xor    %esi,%esi
mov    %r14d,%edx
call   1090 <memset@plt>
mov    %ebx,%edi
call   10c0 <malloc@plt>
mov    %rax,0x30(%rsp)
mov    %rax,%rdi
xor    %esi,%esi
mov    %ebx,%edx
call   1090 <memset@plt>
mov    %r13d,0x4(%rsp)
movslq %r13d,%rax
mov    %rax,0x28(%rsp)
mov    %r15d,%eax
mov    %rax,0x40(%rsp)
test   %r15d,%r15d
jle    135d <encode_file+0x13d>
mov    0x28(%rsp),%rax
lea    0x0(,%rax,4),%rax
mov    %rax,0x8(%rsp)
mov    0x40(%rsp),%r13
mov    0x18(%rsp),%rbx
mov    0x4(%rsp),%r14d
nopl   0x0(%rax,%rax,1)
mov    0x2cb9(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
mov    %ebp,%esi
call   10d0 <fseek@plt>
cmp    $0xffffffff,%eax
je     1608 <encode_file+0x3e8>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    %r14d,%edx
mov    %r12,%rcx
call   1050 <fread@plt>
mov    0x2c9a(%rip),%rcx
cmp    (%rcx),%rax
je     1611 <encode_file+0x3f1>
add    0x8(%rsp),%rbx
add    %r14d,%ebp
add    $0xffffffffffffffff,%r13
jne    1310 <encode_file+0xf0>
mov    %r12,%rdi
call   1070 <fclose@plt>
mov    0x2c5c(%rip),%r14
mov    (%r14),%edi
lea    0x70(%rsp),%rsi
call   1060 <clock_gettime@plt>
mov    0x14(%rsp),%ebp
mov    0x20(%rsp),%edi
imul   %ebp,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1140 <gen_encoding_matrix@plt>
mov    (%r14),%edi
lea    0x50(%rsp),%rsi
call   1060 <clock_gettime@plt>
mov    0x18(%rsp),%rdi
mov    %rbx,%rsi
mov    0x30(%rsp),%rdx
mov    %r15d,%ecx
mov    %ebp,%r8d
mov    0x4(%rsp),%r9d
call   10f0 <encode_chunk@plt>
mov    (%r14),%edi
lea    0x60(%rsp),%rsi
call   1060 <clock_gettime@plt>
mov    0x50(%rsp),%rax
mov    0x58(%rsp),%rcx
mov    0x78(%rsp),%rdx
sub    %rdx,%rcx
cvtsi2sd %rcx,%xmm0
mov    0x70(%rsp),%rcx
sub    %rcx,%rax
cvtsi2sd %rax,%xmm4
movsd  0xc04(%rip),%xmm1
divsd  %xmm1,%xmm4
movsd  0xc00(%rip),%xmm2
mulsd  %xmm2,%xmm0
mov    0x68(%rsp),%rax
sub    %rdx,%rax
cvtsi2sd %rax,%xmm5
mov    0x60(%rsp),%rax
sub    %rcx,%rax
cvtsi2sd %rax,%xmm3
addsd  %xmm4,%xmm0
movsd  %xmm0,0x20(%rsp)
divsd  %xmm1,%xmm3
mulsd  %xmm2,%xmm5
addsd  %xmm3,%xmm5
movsd  %xmm5,0x8(%rsp)
lea    0xbca(%rip),%rdi
mov    $0x1,%al
call   1080 <printf@plt>
movsd  0x8(%rsp),%xmm0
subsd  0x20(%rsp),%xmm0
lea    0xbd7(%rip),%rdi
mov    $0x1,%al
call   1080 <printf@plt>
lea    0xbeb(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1080 <printf@plt>
mov    0x3c(%rsp),%edi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %rbx,0x8(%rsp)
mov    %rbx,%rcx
call   10a0 <write_metadata@plt>
test   %r15d,%r15d
jle    152e <encode_file+0x30e>
mov    0x28(%rsp),%rax
lea    0x0(,%rax,4),%r14
xor    %ebp,%ebp
lea    0x80(%rsp),%r13
mov    0x18(%rsp),%r12
nopl   0x0(%rax)
mov    %r13,%rdi
lea    0xbb1(%rip),%rsi
mov    %ebp,%edx
call   1110 <sprintf@plt>
mov    %r13,%rdi
mov    0x48(%rsp),%rsi
call   1100 <strcat@plt>
mov    %r13,%rdi
lea    0xb98(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     15f6 <encode_file+0x3d6>
mov    %rax,%rbx
mov    %r12,%rdi
mov    $0x4,%esi
mov    0x4(%rsp),%edx
mov    %rax,%rcx
call   1130 <fwrite@plt>
cltq
cmp    %rax,%r14
jne    15ff <encode_file+0x3df>
mov    %rbx,%rdi
call   1070 <fclose@plt>
add    $0x1,%rbp
add    %r14,%r12
cmp    %rbp,0x40(%rsp)
jne    14c0 <encode_file+0x2a0>
mov    0x14(%rsp),%eax
test   %eax,%eax
mov    0x28(%rsp),%r12
jle    15c6 <encode_file+0x3a6>
shl    $0x2,%r12
mov    %eax,%r13d
lea    0x80(%rsp),%rbp
mov    0x30(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
lea    0xb11(%rip),%rsi
mov    %r15d,%edx
call   1110 <sprintf@plt>
mov    %rbp,%rdi
mov    0x48(%rsp),%rsi
call   1100 <strcat@plt>
mov    %rbp,%rdi
lea    0xaf7(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     15f6 <encode_file+0x3d6>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x4,%esi
mov    0x4(%rsp),%edx
mov    %rax,%rcx
call   1130 <fwrite@plt>
cltq
cmp    %rax,%r12
jne    15ff <encode_file+0x3df>
mov    %rbx,%rdi
call   1070 <fclose@plt>
add    $0x1,%r15d
add    %r12,%r14
add    $0xffffffffffffffff,%r13
jne    1560 <encode_file+0x340>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    0x30(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xaae(%rip),%rdi
jmp    1618 <encode_file+0x3f8>
lea    0xa7d(%rip),%rdi
jmp    1618 <encode_file+0x3f8>
lea    0xa8f(%rip),%rdi
jmp    1618 <encode_file+0x3f8>
lea    0xa79(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1120 <exit@plt>

LLVM IR (-O0):
%struct.timespec = type { i64, i64 }
@.str = [3 x i8] c"rb\00"
@.str.1 = [27 x i8] c"Can not open source file!\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.2 = [14 x i8] c"fseek error!\0A\00"
@EOF = global i64 0
@.str.3 = [14 x i8] c"fread error!\0A\00"
@CLOCK_REALTIME = global i32 0
@.str.4 = [39 x i8] c"Encoding matrix generation time: %fms\0A\00"
@.str.5 = [34 x i8] c"Matrix multiplication time: %fms\0A\00"
@.str.6 = [31 x i8] c"Total CPU encoding time: %fms\0A\00"
@.str.7 = [5 x i8] c"_%d_\00"
@.str.8 = [3 x i8] c"wb\00"
@.str.9 = [15 x i8] c"fwrite error!\0A\00"
define void @encode_file(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%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 %struct.timespec
%17 = alloca %struct.timespec
%18 = alloca %struct.timespec
%19 = alloca double
%20 = alloca double
%21 = alloca i32*
%22 = alloca [100 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 1, i32* %7
%23 = load i8*, i8** %4
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %24, i32** %9
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %29
26: ; preds = %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @exit(i32 0)
unreachable
29: ; preds = %3
%30 = load i32*, i32** %9
%31 = load i32, i32* @SEEK_END
%32 = call i32 @fseek(i32* %30, i32 0, i32 %31)
%33 = load i32*, i32** %9
%34 = call i32 @ftell(i32* %33)
store i32 %34, i32* %8
%35 = load i32, i32* %8
%36 = load i32, i32* %5
%37 = sdiv i32 %35, %36
%38 = load i32, i32* %8
%39 = load i32, i32* %5
%40 = srem i32 %38, %39
%41 = icmp ne i32 %40, 0
%42 = zext i1 %41 to i32
%43 = add nsw i32 %37, %42
store i32 %43, i32* %7
%44 = load i32, i32* %5
%45 = load i32, i32* %7
%46 = mul nsw i32 %44, %45
%47 = sext i32 %46 to i64
%48 = mul i64 %47, 4
%49 = trunc i64 %48 to i32
store i32 %49, i32* %13
%50 = load i32, i32* %6
%51 = load i32, i32* %7
%52 = mul nsw i32 %50, %51
%53 = sext i32 %52 to i64
%54 = mul i64 %53, 4
%55 = trunc i64 %54 to i32
store i32 %55, i32* %14
%56 = load i32, i32* %5
%57 = load i32, i32* %7
%58 = mul nsw i32 %56, %57
%59 = sext i32 %58 to i64
%60 = mul i64 %59, 4
%61 = trunc i64 %60 to i32
%62 = call i64 @malloc(i32 %61)
%63 = inttoptr i64 %62 to i32*
store i32* %63, i32** %11
%64 = load i32*, i32** %11
%65 = load i32, i32* %13
%66 = call i32 @memset(i32* %64, i32 0, i32 %65)
%67 = load i32, i32* %6
%68 = load i32, i32* %7
%69 = mul nsw i32 %67, %68
%70 = sext i32 %69 to i64
%71 = mul i64 %70, 4
%72 = trunc i64 %71 to i32
%73 = call i64 @malloc(i32 %72)
%74 = inttoptr i64 %73 to i32*
store i32* %74, i32** %12
%75 = load i32*, i32** %12
%76 = load i32, i32* %14
%77 = call i32 @memset(i32* %75, i32 0, i32 %76)
store i32 0, i32* %15
br label %78
78: ; preds = %109, %29
%79 = load i32, i32* %15
%80 = load i32, i32* %5
%81 = icmp slt i32 %79, %80
br i1 %81, label %82, label %112
82: ; preds = %78
%83 = load i32*, i32** %9
%84 = load i32, i32* %15
%85 = load i32, i32* %7
%86 = mul nsw i32 %84, %85
%87 = load i32, i32* @SEEK_SET
%88 = call i32 @fseek(i32* %83, i32 %86, i32 %87)
%89 = icmp eq i32 %88, -1
br i1 %89, label %90, label %93
90: ; preds = %82
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%92 = call i32 @exit(i32 0)
unreachable
93: ; preds = %82
%94 = load i32*, i32** %11
%95 = load i32, i32* %15
%96 = load i32, i32* %7
%97 = mul nsw i32 %95, %96
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds i32, i32* %94, i64 %98
%100 = load i32, i32* %7
%101 = load i32*, i32** %9
%102 = call i64 @fread(i32* %99, i32 4, i32 %100, i32* %101)
%103 = load i64, i64* @EOF
%104 = icmp eq i64 %102, %103
br i1 %104, label %105, label %108
105: ; preds = %93
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%107 = call i32 @exit(i32 0)
unreachable
108: ; preds = %93
br label %109
109: ; preds = %108
%110 = load i32, i32* %15
%111 = add nsw i32 %110, 1
store i32 %111, i32* %15
br label %78
112: ; preds = %78
%113 = load i32*, i32** %9
%114 = call i32 @fclose(i32* %113)
%115 = load i32, i32* @CLOCK_REALTIME
%116 = call i32 @clock_gettime(i32 %115, %struct.timespec* %16)
%117 = load i32, i32* %6
%118 = load i32, i32* %5
%119 = mul nsw i32 %117, %118
%120 = sext i32 %119 to i64
%121 = mul i64 %120, 4
%122 = trunc i64 %121 to i32
%123 = call i64 @malloc(i32 %122)
%124 = inttoptr i64 %123 to i32*
store i32* %124, i32** %21
%125 = load i32*, i32** %21
%126 = load i32, i32* %6
%127 = load i32, i32* %5
%128 = call i32 @gen_encoding_matrix(i32* %125, i32 %126, i32 %127)
%129 = load i32, i32* @CLOCK_REALTIME
%130 = call i32 @clock_gettime(i32 %129, %struct.timespec* %18)
%131 = load i32*, i32** %11
%132 = load i32*, i32** %21
%133 = load i32*, i32** %12
%134 = load i32, i32* %5
%135 = load i32, i32* %6
%136 = load i32, i32* %7
%137 = call i32 @encode_chunk(i32* %131, i32* %132, i32* %133, i32 %134, i32 %135, i32 %136)
%138 = load i32, i32* @CLOCK_REALTIME
%139 = call i32 @clock_gettime(i32 %138, %struct.timespec* %17)
%140 = getelementptr inbounds %struct.timespec, %struct.timespec* %18, i32 0, i32 1
%141 = load i64, i64* %140
%142 = getelementptr inbounds %struct.timespec, %struct.timespec* %16, i32 0, i32 1
%143 = load i64, i64* %142
%144 = sub nsw i64 %141, %143
%145 = sitofp i64 %144 to double
%146 = getelementptr inbounds %struct.timespec, %struct.timespec* %18, i32 0, i32 0
%147 = load i64, i64* %146
%148 = getelementptr inbounds %struct.timespec, %struct.timespec* %16, i32 0, i32 0
%149 = load i64, i64* %148
%150 = sub nsw i64 %147, %149
%151 = sitofp i64 %150 to double
%152 = fdiv double %151, 1.000000e+06
%153 = call double @llvm.fmuladd.f64(double %145, double 1.000000e+03, double %152)
store double %153, double* %19
%154 = getelementptr inbounds %struct.timespec, %struct.timespec* %17, i32 0, i32 1
%155 = load i64, i64* %154
%156 = getelementptr inbounds %struct.timespec, %struct.timespec* %16, i32 0, i32 1
%157 = load i64, i64* %156
%158 = sub nsw i64 %155, %157
%159 = sitofp i64 %158 to double
%160 = getelementptr inbounds %struct.timespec, %struct.timespec* %17, i32 0, i32 0
%161 = load i64, i64* %160
%162 = getelementptr inbounds %struct.timespec, %struct.timespec* %16, i32 0, i32 0
%163 = load i64, i64* %162
%164 = sub nsw i64 %161, %163
%165 = sitofp i64 %164 to double
%166 = fdiv double %165, 1.000000e+06
%167 = call double @llvm.fmuladd.f64(double %159, double 1.000000e+03, double %166)
store double %167, double* %20
%168 = load double, double* %19
%169 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), double %168)
%170 = load double, double* %20
%171 = load double, double* %19
%172 = fsub double %170, %171
%173 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), double %172)
%174 = load double, double* %20
%175 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), double %174)
%176 = load i32, i32* %8
%177 = load i32, i32* %6
%178 = load i32, i32* %5
%179 = load i32*, i32** %21
%180 = call i32 @write_metadata(i32 %176, i32 %177, i32 %178, i32* %179)
store i32 0, i32* %15
br label %181
181: ; preds = %219, %112
%182 = load i32, i32* %15
%183 = load i32, i32* %5
%184 = icmp slt i32 %182, %183
br i1 %184, label %185, label %222
185: ; preds = %181
%186 = getelementptr inbounds [100 x i8], [100 x i8]* %22, i64 0, i64 0
%187 = load i32, i32* %15
%188 = call i32 @sprintf(i8* %186, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %187)
%189 = getelementptr inbounds [100 x i8], [100 x i8]* %22, i64 0, i64 0
%190 = load i8*, i8** %4
%191 = call i32 @strcat(i8* %189, i8* %190)
%192 = getelementptr inbounds [100 x i8], [100 x i8]* %22, i64 0, i64 0
%193 = call i32* @fopen(i8* %192, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
store i32* %193, i32** %10
%194 = icmp eq i32* %193, null
br i1 %194, label %195, label %198
195: ; preds = %185
%196 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%197 = call i32 @exit(i32 0)
unreachable
198: ; preds = %185
%199 = load i32*, i32** %11
%200 = load i32, i32* %15
%201 = load i32, i32* %7
%202 = mul nsw i32 %200, %201
%203 = sext i32 %202 to i64
%204 = getelementptr inbounds i32, i32* %199, i64 %203
%205 = load i32, i32* %7
%206 = load i32*, i32** %10
%207 = call i32 @fwrite(i32* %204, i32 4, i32 %205, i32* %206)
%208 = sext i32 %207 to i64
%209 = load i32, i32* %7
%210 = sext i32 %209 to i64
%211 = mul i64 4, %210
%212 = icmp ne i64 %208, %211
br i1 %212, label %213, label %216
213: ; preds = %198
%214 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%215 = call i32 @exit(i32 0)
unreachable
216: ; preds = %198
%217 = load i32*, i32** %10
%218 = call i32 @fclose(i32* %217)
br label %219
219: ; preds = %216
%220 = load i32, i32* %15
%221 = add nsw i32 %220, 1
store i32 %221, i32* %15
br label %181
222: ; preds = %181
store i32 0, i32* %15
br label %223
223: ; preds = %263, %222
%224 = load i32, i32* %15
%225 = load i32, i32* %6
%226 = icmp slt i32 %224, %225
br i1 %226, label %227, label %266
227: ; preds = %223
%228 = getelementptr inbounds [100 x i8], [100 x i8]* %22, i64 0, i64 0
%229 = load i32, i32* %15
%230 = load i32, i32* %5
%231 = add nsw i32 %229, %230
%232 = call i32 @sprintf(i8* %228, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %231)
%233 = getelementptr inbounds [100 x i8], [100 x i8]* %22, i64 0, i64 0
%234 = load i8*, i8** %4
%235 = call i32 @strcat(i8* %233, i8* %234)
%236 = getelementptr inbounds [100 x i8], [100 x i8]* %22, i64 0, i64 0
%237 = call i32* @fopen(i8* %236, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
store i32* %237, i32** %10
%238 = icmp eq i32* %237, null
br i1 %238, label %239, label %242
239: ; preds = %227
%240 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%241 = call i32 @exit(i32 0)
unreachable
242: ; preds = %227
%243 = load i32*, i32** %12
%244 = load i32, i32* %15
%245 = load i32, i32* %7
%246 = mul nsw i32 %244, %245
%247 = sext i32 %246 to i64
%248 = getelementptr inbounds i32, i32* %243, i64 %247
%249 = load i32, i32* %7
%250 = load i32*, i32** %10
%251 = call i32 @fwrite(i32* %248, i32 4, i32 %249, i32* %250)
%252 = sext i32 %251 to i64
%253 = load i32, i32* %7
%254 = sext i32 %253 to i64
%255 = mul i64 4, %254
%256 = icmp ne i64 %252, %255
br i1 %256, label %257, label %260
257: ; preds = %242
%258 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%259 = call i32 @exit(i32 0)
unreachable
260: ; preds = %242
%261 = load i32*, i32** %10
%262 = call i32 @fclose(i32* %261)
br label %263
263: ; preds = %260
%264 = load i32, i32* %15
%265 = add nsw i32 %264, 1
store i32 %265, i32* %15
br label %223
266: ; preds = %223
%267 = load i32*, i32** %11
%268 = call i32 @free(i32* %267)
%269 = load i32*, i32** %12
%270 = call i32 @free(i32* %269)
%271 = load i32*, i32** %21
%272 = call i32 @free(i32* %271)
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i64, i64 }
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@EOF = global i64 0
@CLOCK_REALTIME = global i32 0
@.str.4 = [39 x i8] c"Encoding matrix generation time: %fms\0A\00"
@.str.5 = [34 x i8] c"Matrix multiplication time: %fms\0A\00"
@.str.6 = [31 x i8] c"Total CPU encoding time: %fms\0A\00"
@.str.7 = [5 x i8] c"_%d_\00"
@.str.8 = [3 x i8] c"wb\00"
@str.11 = [14 x i8] c"fwrite error!\00"
@str.13 = [13 x i8] c"fread error!\00"
@str.14 = [13 x i8] c"fseek error!\00"
@str.15 = [26 x i8] c"Can not open source file!\00"
define void @encode_file(i8* %0, i32 %1, i32 %2) {
%4 = alloca %struct.timespec
%5 = alloca %struct.timespec
%6 = alloca %struct.timespec
%7 = alloca [100 x i8]
%8 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %3
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.15, i64 0, i64 0))
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %3
%14 = load i32, i32* @SEEK_END
%15 = tail call i32 @fseek(i32* %8, i32 0, i32 %14)
%16 = tail call i32 @ftell(i32* %8)
%17 = sdiv i32 %16, %1
%18 = srem i32 %16, %1
%19 = icmp ne i32 %18, 0
%20 = zext i1 %19 to i32
%21 = add nsw i32 %17, %20
%22 = shl i32 %1, 2
%23 = mul i32 %22, %21
%24 = shl i32 %2, 2
%25 = mul i32 %24, %21
%26 = tail call i64 @malloc(i32 %23)
%27 = inttoptr i64 %26 to i32*
%28 = tail call i32 @memset(i32* %27, i32 0, i32 %23)
%29 = tail call i64 @malloc(i32 %25)
%30 = inttoptr i64 %29 to i32*
%31 = tail call i32 @memset(i32* %30, i32 0, i32 %25)
%32 = icmp sgt i32 %1, 0
br i1 %32, label %33, label %57
33: ; preds = %13
%34 = sext i32 %21 to i64
%35 = zext i32 %1 to i64
br label %38
36: ; preds = %48
%37 = icmp eq i64 %53, %35
br i1 %37, label %57, label %38
38: ; preds = %33, %36
%39 = phi i64 [ 0, %33 ], [ %53, %36 ]
%40 = mul nsw i64 %39, %34
%41 = load i32, i32* @SEEK_SET
%42 = trunc i64 %40 to i32
%43 = tail call i32 @fseek(i32* %8, i32 %42, i32 %41)
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %48
45: ; preds = %38
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.14, i64 0, i64 0))
%47 = tail call i32 @exit(i32 0)
unreachable
48: ; preds = %38
%49 = getelementptr inbounds i32, i32* %27, i64 %40
%50 = tail call i64 @fread(i32* %49, i32 4, i32 %21, i32* %8)
%51 = load i64, i64* @EOF
%52 = icmp eq i64 %50, %51
%53 = add nuw nsw i64 %39, 1
br i1 %52, label %54, label %36
54: ; preds = %48
%55 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.13, i64 0, i64 0))
%56 = tail call i32 @exit(i32 0)
unreachable
57: ; preds = %36, %13
%58 = tail call i32 @fclose(i32* %8)
%59 = bitcast %struct.timespec* %4 to i8*
%60 = bitcast %struct.timespec* %5 to i8*
%61 = bitcast %struct.timespec* %6 to i8*
%62 = load i32, i32* @CLOCK_REALTIME
%63 = call i32 @clock_gettime(i32 %62, %struct.timespec* %4)
%64 = mul i32 %22, %2
%65 = call i64 @malloc(i32 %64)
%66 = inttoptr i64 %65 to i32*
%67 = call i32 @gen_encoding_matrix(i32* %66, i32 %2, i32 %1)
%68 = load i32, i32* @CLOCK_REALTIME
%69 = call i32 @clock_gettime(i32 %68, %struct.timespec* %6)
%70 = call i32 @encode_chunk(i32* %27, i32* %66, i32* %30, i32 %1, i32 %2, i32 %21)
%71 = load i32, i32* @CLOCK_REALTIME
%72 = call i32 @clock_gettime(i32 %71, %struct.timespec* %5)
%73 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 1
%74 = load i64, i64* %73
%75 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 1
%76 = load i64, i64* %75
%77 = sub nsw i64 %74, %76
%78 = sitofp i64 %77 to double
%79 = getelementptr inbounds %struct.timespec, %struct.timespec* %6, i64 0, i32 0
%80 = load i64, i64* %79
%81 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 0
%82 = load i64, i64* %81
%83 = sub nsw i64 %80, %82
%84 = sitofp i64 %83 to double
%85 = fdiv double %84, 1.000000e+06
%86 = call double @llvm.fmuladd.f64(double %78, double 1.000000e+03, double %85)
%87 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 1
%88 = load i64, i64* %87
%89 = sub nsw i64 %88, %76
%90 = sitofp i64 %89 to double
%91 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
%92 = load i64, i64* %91
%93 = sub nsw i64 %92, %82
%94 = sitofp i64 %93 to double
%95 = fdiv double %94, 1.000000e+06
%96 = call double @llvm.fmuladd.f64(double %90, double 1.000000e+03, double %95)
%97 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), double %86)
%98 = fsub double %96, %86
%99 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), double %98)
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), double %96)
%101 = call i32 @write_metadata(i32 %16, i32 %2, i32 %1, i32* %66)
%102 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
br i1 %32, label %103, label %107
103: ; preds = %57
%104 = sext i32 %21 to i64
%105 = shl nsw i64 %104, 2
%106 = zext i32 %1 to i64
br label %113
107: ; preds = %132, %57
%108 = icmp sgt i32 %2, 0
br i1 %108, label %109, label %160
109: ; preds = %107
%110 = sext i32 %21 to i64
%111 = shl nsw i64 %110, 2
%112 = zext i32 %2 to i64
br label %136
113: ; preds = %103, %132
%114 = phi i64 [ 0, %103 ], [ %134, %132 ]
%115 = trunc i64 %114 to i32
%116 = call i32 @sprintf(i8* %102, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %115)
%117 = call i32 @strcat(i8* %102, i8* %0)
%118 = call i32* @fopen(i8* %102, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%119 = icmp eq i32* %118, null
br i1 %119, label %120, label %123
120: ; preds = %113
%121 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.15, i64 0, i64 0))
%122 = call i32 @exit(i32 0)
unreachable
123: ; preds = %113
%124 = mul nsw i64 %114, %104
%125 = getelementptr inbounds i32, i32* %27, i64 %124
%126 = call i32 @fwrite(i32* %125, i32 4, i32 %21, i32* %118)
%127 = sext i32 %126 to i64
%128 = icmp eq i64 %105, %127
br i1 %128, label %132, label %129
129: ; preds = %123
%130 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.11, i64 0, i64 0))
%131 = call i32 @exit(i32 0)
unreachable
132: ; preds = %123
%133 = call i32 @fclose(i32* %118)
%134 = add nuw nsw i64 %114, 1
%135 = icmp eq i64 %134, %106
br i1 %135, label %107, label %113
136: ; preds = %109, %156
%137 = phi i64 [ 0, %109 ], [ %158, %156 ]
%138 = trunc i64 %137 to i32
%139 = add i32 %138, %1
%140 = call i32 @sprintf(i8* %102, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %139)
%141 = call i32 @strcat(i8* %102, i8* %0)
%142 = call i32* @fopen(i8* %102, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%143 = icmp eq i32* %142, null
br i1 %143, label %144, label %147
144: ; preds = %136
%145 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.15, i64 0, i64 0))
%146 = call i32 @exit(i32 0)
unreachable
147: ; preds = %136
%148 = mul nsw i64 %137, %110
%149 = getelementptr inbounds i32, i32* %30, i64 %148
%150 = call i32 @fwrite(i32* %149, i32 4, i32 %21, i32* %142)
%151 = sext i32 %150 to i64
%152 = icmp eq i64 %111, %151
br i1 %152, label %156, label %153
153: ; preds = %147
%154 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.11, i64 0, i64 0))
%155 = call i32 @exit(i32 0)
unreachable
156: ; preds = %147
%157 = call i32 @fclose(i32* %142)
%158 = add nuw nsw i64 %137, 1
%159 = icmp eq i64 %158, %112
br i1 %159, label %160, label %136
160: ; preds = %156, %107
%161 = call i32 @free(i32* %27)
%162 = call i32 @free(i32* %30)
%163 = call i32 @free(i32* %66)
ret void
}