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

/* Variables and functions */
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ malloc(int);
int open(char *, int, ...);
int /*<<< orphan*/ printUsage(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, scalar_t__ *, int);
int readDataBit(scalar_t__ *, int, int, int, int);
char *strerror(int /*<<< orphan*/);
int write(int, scalar_t__ *, int);
int main(int argc, char **argv) {
  if (argc != 4) {
    printUsage(argv[0]);
    return 1;
  }
  int inputFileWidth = atoi(argv[1]);
  if (inputFileWidth < 1) {
    printf("Error.  width value %s is invalid\n", argv[1]);
    return 2;
  }
  int inputFileFd;
  int outputFileFd;
  inputFileFd = open(argv[2], O_RDONLY);
  if (inputFileFd == -1) {
    printf("Error opening file %s\n", argv[3]);
    printf("Error = %s\n", strerror(errno));
    return 2;
  }
  printf("Opened file %s for reading\n", argv[3]);
  outputFileFd = open(argv[3], O_WRONLY | O_CREAT | O_TRUNC, 0644);
  if (outputFileFd == -1) {
    printf("Error opening the output file %s\n", argv[3]);
    printf("Error = %s\n", strerror(errno));
    goto error_close_input_file;
  }
  printf("Opened file %s for writing\n", argv[3]);
  off_t inputFileSizeBytes = lseek(inputFileFd, 0, SEEK_END);
  if (inputFileSizeBytes == -1) {
    printf("Error determining the file size of the input file\n");
    printf("  Error = %s\n", strerror(errno));
    goto error_close_output_files;
  }
  if (-1 == lseek(inputFileFd, 0, SEEK_SET)) {
    printf(
        "Error  determining the file size of the input file (rewind step)\n");
    printf("  Error = %s\n", strerror(errno));
    goto error_close_output_files;
  }
  printf("Input file size is %ld\n", inputFileSizeBytes);
  int inputFileHeight = inputFileSizeBytes / inputFileWidth;
  printf("Input file width x height (bytes) = %d x %d\n", inputFileWidth,
         inputFileHeight);
  uint8_t *inputFileData = (uint8_t *)malloc(inputFileSizeBytes);
  int bytesReadTotal = 0;
  while (bytesReadTotal < inputFileSizeBytes) {
    int br = read(inputFileFd, inputFileData + bytesReadTotal,
                  inputFileSizeBytes - bytesReadTotal);
    if (br == -1) {
      printf("Error reading the contents of the file at byte %d\n",
             bytesReadTotal);
      printf("  Error = %s\n", strerror(errno));
      goto error_close_output_files;
    }
    bytesReadTotal += br;
  }
  printf("Read %d bytes\n", bytesReadTotal);
  printf("What we read:\n");
  for (int row = 0; row < inputFileHeight; row++) {
    for (int col = 0; col < inputFileWidth * 8; col++) {
      if (readDataBit(inputFileData, inputFileWidth, inputFileHeight, col,
                      row)) {
        printf("#");
      } else {
        printf(" ");
      }
    }
    printf("\n");
  }
  printf("\n\nWhat we are going to write:\n");
  uint8_t curByteToWrite = 0;
  int bytesWritten = 0;
  int curBit = 0;
  for (int row = 0; row < inputFileWidth * 8; row++) {
    for (int col = 0; col < inputFileHeight; col++) {
      int readRow = col;
      int readCol = inputFileWidth * 8 - 1 - row;
      int bitRead = readDataBit(inputFileData, inputFileWidth, inputFileHeight,
                                readCol, readRow);
      if (bitRead) {
        printf("#");
      } else {
        printf(" ");
      }
      int bitsToShift = 7 - curBit;
      curByteToWrite += bitRead << bitsToShift;
      if (bitsToShift == 0) {
        if (1 != write(outputFileFd, &curByteToWrite, 1)) {
          printf("Error trying to write the byte %d\n", bytesWritten);
          printf("  Error = %s\n", strerror(errno));
          goto error_close_output_files;
        }
        curBit = 0;
        curByteToWrite = 0;
        bytesWritten++;
      } else {
        curBit++;
      }
    }
    printf("\n");
  }
  printf("Closing intput file\n");
  close(inputFileFd);
  printf("Closing output file\n");
  close(outputFileFd);
  return 0;
error_close_output_files:
  printf("Closing output file\n");
  close(outputFileFd);
error_close_input_file:
  printf("Closing intput file\n");
  close(outputFileFd);
  return 4;
}


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)
cmpl   $0x4,-0x8(%rbp)
je     11e8 <main+0x38>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   10a0 <printUsage@plt>
movl   $0x1,-0x4(%rbp)
jmp    172a <main+0x57a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jge    1224 <main+0x74>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    172a <main+0x57a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2d9d(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    128a <main+0xda>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %rax,%rsi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x2,-0x4(%rbp)
jmp    172a <main+0x57a>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
mov    0x2cf9(%rip),%rax
mov    (%rax),%esi
mov    0x2d40(%rip),%rax
or     (%rax),%esi
mov    0x2d2f(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1316 <main+0x166>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xd6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2cc7(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %rax,%rsi
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    170d <main+0x55d>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%edi
mov    0x2ca2(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    137e <main+0x1ce>
lea    0xd41(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2c5f(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %rax,%rsi
lea    0xd55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16f7 <main+0x547>
mov    -0x18(%rbp),%edi
mov    0x2c30(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1050 <lseek@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    13d2 <main+0x222>
lea    0xd2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2c0b(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %rax,%rsi
lea    0xd01(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16f7 <main+0x547>
mov    -0x20(%rbp),%esi
lea    0xd3b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xd35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    148d <main+0x2dd>
mov    -0x18(%rbp),%edi
mov    -0x30(%rbp),%rsi
movslq -0x34(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x20(%rbp),%edx
sub    -0x34(%rbp),%edx
call   1070 <read@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0xffffffff,-0x38(%rbp)
jne    147f <main+0x2cf>
mov    -0x34(%rbp),%esi
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2b5e(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %rax,%rsi
lea    0xc54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16f7 <main+0x547>
mov    -0x38(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    1414 <main+0x264>
mov    -0x34(%rbp),%esi
lea    0xcf8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xcf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1546 <main+0x396>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    $0x3,%ecx
cmp    %ecx,%eax
jge    152a <main+0x37a>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x40(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
call   1090 <readDataBit@plt>
cmp    $0x0,%eax
je     1509 <main+0x359>
lea    0xcb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1517 <main+0x367>
lea    0xc9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    151c <main+0x36c>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    14c6 <main+0x316>
lea    0xbe4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    14b3 <main+0x303>
lea    0xc64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    $0x3,%ecx
cmp    %ecx,%eax
jge    16bf <main+0x50f>
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    16a3 <main+0x4f3>
mov    -0x58(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x3,%eax
sub    $0x1,%eax
sub    -0x54(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x60(%rbp),%ecx
mov    -0x5c(%rbp),%r8d
call   1090 <readDataBit@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
je     15e0 <main+0x430>
lea    0xbd9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    15ee <main+0x43e>
lea    0xbc8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x7,%eax
sub    -0x50(%rbp),%eax
mov    %eax,-0x68(%rbp)
mov    -0x64(%rbp),%eax
mov    -0x68(%rbp),%ecx
shl    %cl,%eax
cltq
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
cmpl   $0x0,-0x68(%rbp)
jne    1687 <main+0x4d7>
mov    -0x1c(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     166a <main+0x4ba>
mov    -0x4c(%rbp),%esi
lea    0xb91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2973(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    %rax,%rsi
lea    0xa69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16f7 <main+0x547>
movl   $0x0,-0x50(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1690 <main+0x4e0>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1695 <main+0x4e5>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1589 <main+0x3d9>
lea    0xa6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1571 <main+0x3c1>
lea    0xb2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
lea    0xb2c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
jmp    172a <main+0x57a>
lea    0xb0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
lea    0xadf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
movl   $0x4,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
cmp    $0x4,%edi
jne    13bf <main+0x1ef>
mov    0x8(%rbx),%rbp
mov    %rbp,%rdi
call   10e0 <atoi@plt>
test   %eax,%eax
jle    13d1 <main+0x201>
mov    %eax,%r12d
mov    0x10(%rbx),%rdi
mov    0x2dc4(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   10d0 <open@plt>
mov    0x18(%rbx),%rsi
mov    %eax,0xc(%rsp)
cmp    $0xffffffff,%eax
je     13dd <main+0x20d>
lea    0xe0d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2d6d(%rip),%rax
mov    0x2db6(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x18(%rbx),%rdi
mov    0x2d9f(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
xor    %eax,%eax
call   10d0 <open@plt>
mov    %eax,%r14d
mov    0x18(%rbx),%rsi
cmp    $0xffffffff,%eax
je     1414 <main+0x244>
lea    0xe02(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2d54(%rip),%rax
mov    (%rax),%edx
mov    0xc(%rsp),%ebx
mov    %ebx,%edi
xor    %esi,%esi
call   1070 <lseek@plt>
cmp    $0xffffffff,%eax
je     1446 <main+0x276>
mov    %eax,%r15d
mov    0x2d12(%rip),%rax
mov    (%rax),%edx
xor    %ebp,%ebp
mov    %ebx,%edi
xor    %esi,%esi
call   1070 <lseek@plt>
cmp    $0xffffffff,%eax
je     1557 <main+0x387>
mov    %r14d,(%rsp)
lea    0xddb(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15d,%eax
cltd
idiv   %r12d
mov    %eax,%r14d
lea    0xdd8(%rip),%rdi
mov    %r12d,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15d,%edi
call   10a0 <malloc@plt>
mov    %rax,%r13
test   %r15d,%r15d
jle    132a <main+0x15a>
xor    %ebp,%ebp
movslq %ebp,%rax
lea    0x0(,%rax,8),%rsi
add    %r13,%rsi
mov    %r15d,%edx
sub    %eax,%edx
mov    %ebx,%edi
call   1090 <read@plt>
cmp    $0xffffffff,%eax
je     1572 <main+0x3a2>
add    %eax,%ebp
cmp    %ebp,%r15d
jg     1300 <main+0x130>
lea    0xde9(%rip),%rdi
xor    %ebx,%ebx
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe09(%rip),%rdi
call   1040 <puts@plt>
lea    0x0(,%r12,8),%eax
mov    %eax,0x4(%rsp)
test   %r14d,%r14d
jle    1452 <main+0x282>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
mov    $0x1,%r15d
cmovge %eax,%r15d
jmp    1386 <main+0x1b6>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
cmp    %r14d,%ebx
je     1452 <main+0x282>
test   %r12d,%r12d
jle    1370 <main+0x1a0>
xor    %ebp,%ebp
nopl   (%rax)
mov    %r13,%rdi
mov    %r12d,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
mov    %ebx,%r8d
call   10b0 <readDataBit@plt>
xor    %ecx,%ecx
test   %eax,%eax
setne  %cl
lea    (%rcx,%rcx,2),%edi
or     $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    %ebp,%r15d
jne    1390 <main+0x1c0>
jmp    1370 <main+0x1a0>
mov    (%rbx),%rdi
call   10c0 <printUsage@plt>
mov    $0x1,%eax
jmp    15d2 <main+0x402>
lea    0xc28(%rip),%rdi
mov    %rbp,%rsi
jmp    1403 <main+0x233>
lea    0xc3f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2bce(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xc96(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x2,%eax
jmp    15d2 <main+0x402>
lea    0xc3b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2b97(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xc5f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    15b9 <main+0x3e9>
lea    0xd94(%rip),%rdi
jmp    155e <main+0x38e>
lea    0xd01(%rip),%rdi
call   1040 <puts@plt>
test   %r12d,%r12d
jle    15e1 <main+0x411>
mov    0x4(%rsp),%eax
cmp    $0x2,%eax
mov    $0x1,%ecx
cmovge %eax,%ecx
mov    %ecx,0x14(%rsp)
xor    %ebp,%ebp
xor    %eax,%eax
movl   $0x0,0x8(%rsp)
movl   $0x0,0x10(%rsp)
jmp    14b1 <main+0x2e1>
mov    %rbp,%rbx
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x18(%rsp),%eax
add    $0x1,%eax
mov    %rbx,%rbp
cmp    0x14(%rsp),%eax
je     15e1 <main+0x411>
test   %r14d,%r14d
mov    %eax,0x18(%rsp)
jle    1490 <main+0x2c0>
not    %eax
add    0x4(%rsp),%eax
mov    %eax,0x1c(%rsp)
xor    %r15d,%r15d
jmp    14e3 <main+0x313>
nopl   0x0(%rax)
add    $0x1,%eax
mov    %eax,0x8(%rsp)
add    $0x1,%r15d
mov    %rbx,%rbp
cmp    %r15d,%r14d
je     1493 <main+0x2c3>
mov    %r13,%rdi
mov    %r12d,%esi
mov    %r14d,%edx
mov    0x1c(%rsp),%ecx
mov    %r15d,%r8d
call   10b0 <readDataBit@plt>
mov    %eax,%ebx
xor    %eax,%eax
test   %ebx,%ebx
setne  %al
lea    (%rax,%rax,2),%edi
or     $0x20,%edi
call   1030 <putchar@plt>
mov    $0x7,%cl
mov    0x8(%rsp),%eax
sub    %al,%cl
shl    %cl,%ebx
movslq %ebx,%rbx
add    %rbp,%rbx
mov    %rbx,0x20(%rsp)
cmp    $0x7,%eax
jne    14d0 <main+0x300>
mov    (%rsp),%edi
lea    0x20(%rsp),%rsi
mov    $0x1,%edx
call   1050 <write@plt>
cmp    $0x1,%eax
jne    1565 <main+0x395>
movq   $0x0,0x20(%rsp)
addl   $0x1,0x10(%rsp)
xor    %ebx,%ebx
movl   $0x0,0x8(%rsp)
jmp    14d7 <main+0x307>
lea    0xc42(%rip),%rdi
call   1040 <puts@plt>
jmp    1586 <main+0x3b6>
lea    0xbbd(%rip),%rdi
mov    0x10(%rsp),%esi
jmp    157b <main+0x3ab>
lea    0xb6e(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%rsp),%r14d
mov    0x2a33(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xaf9(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xbe0(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%edi
call   1080 <close@plt>
lea    0xbb8(%rip),%rdi
call   1040 <puts@plt>
mov    %r14d,%edi
call   1080 <close@plt>
mov    $0x4,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb90(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%edi
call   1080 <close@plt>
lea    0xb8f(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%edi
call   1080 <close@plt>
xor    %eax,%eax
jmp    15d2 <main+0x402>

LLVM IR (-O0):
@.str = [35 x i8] c"Error. width value %s is invalid\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [23 x i8] c"Error opening file %s\0A\00"
@.str.2 = [12 x i8] c"Error = %s\0A\00"
@errno = global i32 0
@.str.3 = [28 x i8] c"Opened file %s for reading\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.4 = [34 x i8] c"Error opening the output file %s\0A\00"
@.str.5 = [28 x i8] c"Opened file %s for writing\0A\00"
@SEEK_END = global i32 0
@.str.6 = [51 x i8] c"Error determining the file size of the input file\0A\00"
@.str.7 = [14 x i8] c" Error = %s\0A\00"
@SEEK_SET = global i32 0
@.str.8 = [66 x i8] c"Error determining the file size of the input file (rewind step)\0A\00"
@.str.9 = [24 x i8] c"Input file size is %ld\0A\00"
@.str.10 = [45 x i8] c"Input file width x height (bytes) = %d x %d\0A\00"
@.str.11 = [51 x i8] c"Error reading the contents of the file at byte %d\0A\00"
@.str.12 = [15 x i8] c"Read %d bytes\0A\00"
@.str.13 = [15 x i8] c"What we read:\0A\00"
@.str.14 = [2 x i8] c"#\00"
@.str.15 = [2 x i8] c" \00"
@.str.16 = [2 x i8] c"\0A\00"
@.str.17 = [31 x i8] c"\0A\0AWhat we are going to write:\0A\00"
@.str.18 = [35 x i8] c"Error trying to write the byte %d\0A\00"
@.str.19 = [21 x i8] c"Closing intput file\0A\00"
@.str.20 = [21 x i8] c"Closing output file\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i64
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%25 = load i32, i32* %4
%26 = icmp ne i32 %25, 4
br i1 %26, label %27, label %32
27: ; preds = %2
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 @printUsage(i8* %30)
store i32 1, i32* %3
br label %264
32: ; preds = %2
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 @atoi(i8* %35)
store i32 %36, i32* %6
%37 = load i32, i32* %6
%38 = icmp slt i32 %37, 1
br i1 %38, label %39, label %44
39: ; preds = %32
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %42)
store i32 2, i32* %3
br label %264
44: ; preds = %32
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 2
%47 = load i8*, i8** %46
%48 = load i32, i32* @O_RDONLY
%49 = call i32 (i8*, i32, ...) @open(i8* %47, i32 %48)
store i32 %49, i32* %7
%50 = load i32, i32* %7
%51 = icmp eq i32 %50, -1
br i1 %51, label %52, label %60
52: ; preds = %44
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 3
%55 = load i8*, i8** %54
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %55)
%57 = load i32, i32* @errno
%58 = call i8* @strerror(i32 %57)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %58)
store i32 2, i32* %3
br label %264
60: ; preds = %44
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 3
%63 = load i8*, i8** %62
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %63)
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 3
%67 = load i8*, i8** %66
%68 = load i32, i32* @O_WRONLY
%69 = load i32, i32* @O_CREAT
%70 = or i32 %68, %69
%71 = load i32, i32* @O_TRUNC
%72 = or i32 %70, %71
%73 = call i32 (i8*, i32, ...) @open(i8* %67, i32 %72, i32 420)
store i32 %73, i32* %8
%74 = load i32, i32* %8
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %84
76: ; preds = %60
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 3
%79 = load i8*, i8** %78
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %79)
%81 = load i32, i32* @errno
%82 = call i8* @strerror(i32 %81)
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %82)
br label %260
84: ; preds = %60
%85 = load i8**, i8*** %5
%86 = getelementptr inbounds i8*, i8** %85, i64 3
%87 = load i8*, i8** %86
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %87)
%89 = load i32, i32* %7
%90 = load i32, i32* @SEEK_END
%91 = call i32 @lseek(i32 %89, i32 0, i32 %90)
store i32 %91, i32* %9
%92 = load i32, i32* %9
%93 = icmp eq i32 %92, -1
br i1 %93, label %94, label %99
94: ; preds = %84
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0))
%96 = load i32, i32* @errno
%97 = call i8* @strerror(i32 %96)
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %97)
br label %256
99: ; preds = %84
%100 = load i32, i32* %7
%101 = load i32, i32* @SEEK_SET
%102 = call i32 @lseek(i32 %100, i32 0, i32 %101)
%103 = icmp eq i32 -1, %102
br i1 %103, label %104, label %109
104: ; preds = %99
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.8, i64 0, i64 0))
%106 = load i32, i32* @errno
%107 = call i8* @strerror(i32 %106)
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %107)
br label %256
109: ; preds = %99
%110 = load i32, i32* %9
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i32 %110)
%112 = load i32, i32* %9
%113 = load i32, i32* %6
%114 = sdiv i32 %112, %113
store i32 %114, i32* %10
%115 = load i32, i32* %6
%116 = load i32, i32* %10
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0), i32 %115, i32 %116)
%118 = load i32, i32* %9
%119 = call i64 @malloc(i32 %118)
%120 = inttoptr i64 %119 to i64*
store i64* %120, i64** %11
store i32 0, i32* %12
br label %121
121: ; preds = %143, %109
%122 = load i32, i32* %12
%123 = load i32, i32* %9
%124 = icmp slt i32 %122, %123
br i1 %124, label %125, label %147
125: ; preds = %121
%126 = load i32, i32* %7
%127 = load i64*, i64** %11
%128 = load i32, i32* %12
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds i64, i64* %127, i64 %129
%131 = load i32, i32* %9
%132 = load i32, i32* %12
%133 = sub nsw i32 %131, %132
%134 = call i32 @read(i32 %126, i64* %130, i32 %133)
store i32 %134, i32* %13
%135 = load i32, i32* %13
%136 = icmp eq i32 %135, -1
br i1 %136, label %137, label %143
137: ; preds = %125
%138 = load i32, i32* %12
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.11, i64 0, i64 0), i32 %138)
%140 = load i32, i32* @errno
%141 = call i8* @strerror(i32 %140)
%142 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %141)
br label %256
143: ; preds = %125
%144 = load i32, i32* %13
%145 = load i32, i32* %12
%146 = add nsw i32 %145, %144
store i32 %146, i32* %12
br label %121
147: ; preds = %121
%148 = load i32, i32* %12
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i32 %148)
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %14
br label %151
151: ; preds = %179, %147
%152 = load i32, i32* %14
%153 = load i32, i32* %10
%154 = icmp slt i32 %152, %153
br i1 %154, label %155, label %182
155: ; preds = %151
store i32 0, i32* %15
br label %156
156: ; preds = %174, %155
%157 = load i32, i32* %15
%158 = load i32, i32* %6
%159 = mul nsw i32 %158, 8
%160 = icmp slt i32 %157, %159
br i1 %160, label %161, label %177
161: ; preds = %156
%162 = load i64*, i64** %11
%163 = load i32, i32* %6
%164 = load i32, i32* %10
%165 = load i32, i32* %15
%166 = load i32, i32* %14
%167 = call i32 @readDataBit(i64* %162, i32 %163, i32 %164, i32 %165, i32 %166)
%168 = icmp ne i32 %167, 0
br i1 %168, label %169, label %171
169: ; preds = %161
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
br label %173
171: ; preds = %161
%172 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
br label %173
173: ; preds = %171, %169
br label %174
174: ; preds = %173
%175 = load i32, i32* %15
%176 = add nsw i32 %175, 1
store i32 %176, i32* %15
br label %156
177: ; preds = %156
%178 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
br label %179
179: ; preds = %177
%180 = load i32, i32* %14
%181 = add nsw i32 %180, 1
store i32 %181, i32* %14
br label %151
182: ; preds = %151
%183 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.17, i64 0, i64 0))
store i64 0, i64* %16
store i32 0, i32* %17
store i32 0, i32* %18
store i32 0, i32* %19
br label %184
184: ; preds = %246, %182
%185 = load i32, i32* %19
%186 = load i32, i32* %6
%187 = mul nsw i32 %186, 8
%188 = icmp slt i32 %185, %187
br i1 %188, label %189, label %249
189: ; preds = %184
store i32 0, i32* %20
br label %190
190: ; preds = %241, %189
%191 = load i32, i32* %20
%192 = load i32, i32* %10
%193 = icmp slt i32 %191, %192
br i1 %193, label %194, label %244
194: ; preds = %190
%195 = load i32, i32* %20
store i32 %195, i32* %21
%196 = load i32, i32* %6
%197 = mul nsw i32 %196, 8
%198 = sub nsw i32 %197, 1
%199 = load i32, i32* %19
%200 = sub nsw i32 %198, %199
store i32 %200, i32* %22
%201 = load i64*, i64** %11
%202 = load i32, i32* %6
%203 = load i32, i32* %10
%204 = load i32, i32* %22
%205 = load i32, i32* %21
%206 = call i32 @readDataBit(i64* %201, i32 %202, i32 %203, i32 %204, i32 %205)
store i32 %206, i32* %23
%207 = load i32, i32* %23
%208 = icmp ne i32 %207, 0
br i1 %208, label %209, label %211
209: ; preds = %194
%210 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.14, i64 0, i64 0))
br label %213
211: ; preds = %194
%212 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.15, i64 0, i64 0))
br label %213
213: ; preds = %211, %209
%214 = load i32, i32* %18
%215 = sub nsw i32 7, %214
store i32 %215, i32* %24
%216 = load i32, i32* %23
%217 = load i32, i32* %24
%218 = shl i32 %216, %217
%219 = sext i32 %218 to i64
%220 = load i64, i64* %16
%221 = add nsw i64 %220, %219
store i64 %221, i64* %16
%222 = load i32, i32* %24
%223 = icmp eq i32 %222, 0
br i1 %223, label %224, label %237
224: ; preds = %213
%225 = load i32, i32* %8
%226 = call i32 @write(i32 %225, i64* %16, i32 1)
%227 = icmp ne i32 1, %226
br i1 %227, label %228, label %234
228: ; preds = %224
%229 = load i32, i32* %17
%230 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.18, i64 0, i64 0), i32 %229)
%231 = load i32, i32* @errno
%232 = call i8* @strerror(i32 %231)
%233 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %232)
br label %256
234: ; preds = %224
store i32 0, i32* %18
store i64 0, i64* %16
%235 = load i32, i32* %17
%236 = add nsw i32 %235, 1
store i32 %236, i32* %17
br label %240
237: ; preds = %213
%238 = load i32, i32* %18
%239 = add nsw i32 %238, 1
store i32 %239, i32* %18
br label %240
240: ; preds = %237, %234
br label %241
241: ; preds = %240
%242 = load i32, i32* %20
%243 = add nsw i32 %242, 1
store i32 %243, i32* %20
br label %190
244: ; preds = %190
%245 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.16, i64 0, i64 0))
br label %246
246: ; preds = %244
%247 = load i32, i32* %19
%248 = add nsw i32 %247, 1
store i32 %248, i32* %19
br label %184
249: ; preds = %184
%250 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.19, i64 0, i64 0))
%251 = load i32, i32* %7
%252 = call i32 @close(i32 %251)
%253 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.20, i64 0, i64 0))
%254 = load i32, i32* %8
%255 = call i32 @close(i32 %254)
store i32 0, i32* %3
br label %264
256: ; preds = %228, %137, %104, %94
%257 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.20, i64 0, i64 0))
%258 = load i32, i32* %8
%259 = call i32 @close(i32 %258)
br label %260
260: ; preds = %256, %76
%261 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.19, i64 0, i64 0))
%262 = load i32, i32* %8
%263 = call i32 @close(i32 %262)
store i32 4, i32* %3
br label %264
264: ; preds = %260, %249, %52, %39, %27
%265 = load i32, i32* %3
ret i32 %265
}

LLVM IR (-O2):
@.str = [35 x i8] c"Error. width value %s is invalid\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [23 x i8] c"Error opening file %s\0A\00"
@.str.2 = [12 x i8] c"Error = %s\0A\00"
@errno = global i32 0
@.str.3 = [28 x i8] c"Opened file %s for reading\0A\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@.str.4 = [34 x i8] c"Error opening the output file %s\0A\00"
@.str.5 = [28 x i8] c"Opened file %s for writing\0A\00"
@SEEK_END = global i32 0
@.str.7 = [14 x i8] c" Error = %s\0A\00"
@SEEK_SET = global i32 0
@.str.9 = [24 x i8] c"Input file size is %ld\0A\00"
@.str.10 = [45 x i8] c"Input file width x height (bytes) = %d x %d\0A\00"
@.str.11 = [51 x i8] c"Error reading the contents of the file at byte %d\0A\00"
@.str.12 = [15 x i8] c"Read %d bytes\0A\00"
@.str.18 = [35 x i8] c"Error trying to write the byte %d\0A\00"
@str = [14 x i8] c"What we read:\00"
@str.21 = [30 x i8] c"\0A\0AWhat we are going to write:\00"
@str.24 = [20 x i8] c"Closing intput file\00"
@str.25 = [20 x i8] c"Closing output file\00"
@str.26 = [65 x i8] c"Error determining the file size of the input file (rewind step)\00"
@str.27 = [50 x i8] c"Error determining the file size of the input file\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = icmp eq i32 %0, 4
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 @printUsage(i8* %6)
br label %162
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = icmp slt i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %162
15: ; preds = %8
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = load i32, i32* @O_RDONLY
%19 = tail call i32 (i8*, i32, ...) @open(i8* %17, i32 %18)
%20 = icmp eq i32 %19, -1
%21 = getelementptr inbounds i8*, i8** %1, i64 3
%22 = load i8*, i8** %21
br i1 %20, label %23, label %28
23: ; preds = %15
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%25 = load i32, i32* @errno
%26 = tail call i8* @strerror(i32 %25)
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %26)
br label %162
28: ; preds = %15
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* %22)
%30 = load i8*, i8** %21
%31 = load i32, i32* @O_WRONLY
%32 = load i32, i32* @O_CREAT
%33 = or i32 %32, %31
%34 = load i32, i32* @O_TRUNC
%35 = or i32 %33, %34
%36 = tail call i32 (i8*, i32, ...) @open(i8* %30, i32 %35, i32 420)
%37 = icmp eq i32 %36, -1
%38 = load i8*, i8** %21
br i1 %37, label %39, label %44
39: ; preds = %28
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %38)
%41 = load i32, i32* @errno
%42 = tail call i8* @strerror(i32 %41)
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %42)
br label %159
44: ; preds = %28
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %38)
%46 = load i32, i32* @SEEK_END
%47 = tail call i32 @lseek(i32 %19, i32 0, i32 %46)
%48 = icmp eq i32 %47, -1
br i1 %48, label %49, label %51
49: ; preds = %44
%50 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.27, i64 0, i64 0))
br label %153
51: ; preds = %44
%52 = load i32, i32* @SEEK_SET
%53 = tail call i32 @lseek(i32 %19, i32 0, i32 %52)
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %57
55: ; preds = %51
%56 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str.26, i64 0, i64 0))
br label %153
57: ; preds = %51
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i32 %47)
%59 = sdiv i32 %47, %11
%60 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.10, i64 0, i64 0), i32 %11, i32 %59)
%61 = tail call i64 @malloc(i32 %47)
%62 = inttoptr i64 %61 to i64*
%63 = icmp sgt i32 %47, 0
br i1 %63, label %66, label %76
64: ; preds = %66
%65 = icmp sgt i32 %47, %73
br i1 %65, label %66, label %76
66: ; preds = %57, %64
%67 = phi i32 [ %73, %64 ], [ 0, %57 ]
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i64, i64* %62, i64 %68
%70 = sub nsw i32 %47, %67
%71 = tail call i32 @read(i32 %19, i64* %69, i32 %70)
%72 = icmp eq i32 %71, -1
%73 = add nsw i32 %71, %67
br i1 %72, label %74, label %64
74: ; preds = %66
%75 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.11, i64 0, i64 0), i32 %67)
br label %153
76: ; preds = %64, %57
%77 = phi i32 [ 0, %57 ], [ %73, %64 ]
%78 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.12, i64 0, i64 0), i32 %77)
%79 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
%80 = icmp sgt i32 %59, 0
%81 = shl i32 %11, 3
br i1 %80, label %82, label %87
82: ; preds = %76
%83 = icmp sgt i32 %11, 0
%84 = call i32 @llvm.smax.i32(i32 %81, i32 1)
br label %85
85: ; preds = %82, %92
%86 = phi i32 [ 0, %82 ], [ %94, %92 ]
br i1 %83, label %96, label %92
87: ; preds = %92, %76
%88 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.21, i64 0, i64 0))
%89 = icmp sgt i32 %11, 0
br i1 %89, label %90, label %148
90: ; preds = %87
%91 = call i32 @llvm.smax.i32(i32 %81, i32 1)
br label %104
92: ; preds = %96, %85
%93 = tail call i32 @putchar(i32 10)
%94 = add nuw nsw i32 %86, 1
%95 = icmp eq i32 %94, %59
br i1 %95, label %87, label %85
96: ; preds = %85, %96
%97 = phi i32 [ %102, %96 ], [ 0, %85 ]
%98 = tail call i32 @readDataBit(i64* %62, i32 %11, i32 %59, i32 %97, i32 %86)
%99 = icmp eq i32 %98, 0
%100 = select i1 %99, i32 32, i32 35
%101 = tail call i32 @putchar(i32 %100)
%102 = add nuw nsw i32 %97, 1
%103 = icmp eq i32 %102, %84
br i1 %103, label %92, label %96
104: ; preds = %90, %139
%105 = phi i64 [ 0, %90 ], [ %140, %139 ]
%106 = phi i32 [ 0, %90 ], [ %144, %139 ]
%107 = phi i32 [ 0, %90 ], [ %142, %139 ]
%108 = phi i32 [ 0, %90 ], [ %141, %139 ]
br i1 %80, label %109, label %139
109: ; preds = %104
%110 = xor i32 %106, -1
%111 = add i32 %81, %110
br label %112
112: ; preds = %109, %133
%113 = phi i64 [ %105, %109 ], [ %134, %133 ]
%114 = phi i32 [ 0, %109 ], [ %137, %133 ]
%115 = phi i32 [ %107, %109 ], [ %136, %133 ]
%116 = phi i32 [ %108, %109 ], [ %135, %133 ]
%117 = tail call i32 @readDataBit(i64* %62, i32 %11, i32 %59, i32 %111, i32 %114)
%118 = icmp eq i32 %117, 0
%119 = select i1 %118, i32 32, i32 35
%120 = tail call i32 @putchar(i32 %119)
%121 = sub nsw i32 7, %115
%122 = shl i32 %117, %121
%123 = sext i32 %122 to i64
%124 = add nsw i64 %113, %123
store i64 %124, i64* %3
%125 = icmp eq i32 %115, 7
br i1 %125, label %126, label %131
126: ; preds = %112
%127 = call i32 @write(i32 %36, i64* %3, i32 1)
%128 = icmp eq i32 %127, 1
br i1 %128, label %129, label %146
129: ; preds = %126
store i64 0, i64* %3
%130 = add nsw i32 %116, 1
br label %133
131: ; preds = %112
%132 = add nsw i32 %115, 1
br label %133
133: ; preds = %131, %129
%134 = phi i64 [ %124, %131 ], [ 0, %129 ]
%135 = phi i32 [ %116, %131 ], [ %130, %129 ]
%136 = phi i32 [ %132, %131 ], [ 0, %129 ]
%137 = add nuw nsw i32 %114, 1
%138 = icmp eq i32 %137, %59
br i1 %138, label %139, label %112
139: ; preds = %133, %104
%140 = phi i64 [ %105, %104 ], [ %134, %133 ]
%141 = phi i32 [ %108, %104 ], [ %135, %133 ]
%142 = phi i32 [ %107, %104 ], [ %136, %133 ]
%143 = tail call i32 @putchar(i32 10)
%144 = add nuw nsw i32 %106, 1
%145 = icmp eq i32 %144, %91
br i1 %145, label %148, label %104
146: ; preds = %126
%147 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.18, i64 0, i64 0), i32 %116)
br label %153
148: ; preds = %139, %87
%149 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.24, i64 0, i64 0))
%150 = tail call i32 @close(i32 %19)
%151 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.25, i64 0, i64 0))
%152 = tail call i32 @close(i32 %36)
br label %162
153: ; preds = %146, %74, %55, %49
%154 = load i32, i32* @errno
%155 = tail call i8* @strerror(i32 %154)
%156 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %155)
%157 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.25, i64 0, i64 0))
%158 = tail call i32 @close(i32 %36)
br label %159
159: ; preds = %153, %39
%160 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.24, i64 0, i64 0))
%161 = tail call i32 @close(i32 %36)
br label %162
162: ; preds = %13, %159, %148, %23, %5
%163 = phi i32 [ 1, %5 ], [ 2, %13 ], [ 2, %23 ], [ 4, %159 ], [ 0, %148 ]
ret i32 %163
}