#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ ClearReceiveBuffer(int);
int Initial_SerialPort(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ read(int, unsigned char *, int);
int write(int, ...);
int main(int argc, char *argv[]) {
  int fd;
  char *data_file_name;
  char packet_data[128];
  char frame_data[128 + 1 + 2 + 1];
  unsigned char tmp;
  FILE *datafile;
  int complete, retry_num, pack_counter, read_number, write_number, i;
  unsigned short crc_value;
  unsigned char ack_id;
  unsigned int checksum = 0;
  if (argc == 1) {
    printf("Usage %s <uart device> <file to transfer>\n", argv[0]);
    printf("     Example %s /dev/ttyS0 myfile.bin\n", argv[0]);
    return 0;
  }
  printf("Opening Uart %s... ", argv[1]);
  if ((fd = Initial_SerialPort(argv[1])) == -1) {
    perror("Failed!\n");
    return -1;
  }
  printf("Done\n");
  data_file_name = argv[2];
  if ((datafile = fopen(data_file_name, "rb")) == NULL) {
    perror("Can't open file!");
    return -1;
  }
  pack_counter = 0;
  complete = 0;
  retry_num = 0;
  ClearReceiveBuffer(fd);
  while ((read(fd, &ack_id, 1)) <= 0)
    ;
  printf("%c\r\n", ack_id);
  ack_id = 0x06;
  while (!complete) {
    switch (ack_id) {
    case 0x06:
      retry_num = 0;
      checksum = 0;
      pack_counter++;
      read_number = fread(packet_data, sizeof(char), 128, datafile);
      if (read_number > 0) {
        if (read_number < 128) {
          printf("Start filling the last frame!\r\n");
          for (; read_number < 128; read_number++)
            packet_data[read_number] = 0x00;
        }
        frame_data[0] = 0x01;
        frame_data[1] = (char)pack_counter;
        frame_data[2] = (char)(255 - frame_data[1]);
        for (i = 0; i < 128; i++) {
          frame_data[i + 3] = packet_data[i];
          checksum += packet_data[i];
        }
        checksum = checksum % 256;
        frame_data[128 + 3] = (unsigned char)(checksum);
        write_number = write(fd, frame_data, 128 + 4);
        printf("wait for ACK,%d,%d,...", pack_counter, write_number);
        while (1) {
          while ((read(fd, &ack_id, 1)) <= 0)
            ;
          if (ack_id == 0x06) {
            printf("Ok!       \r");
            break;
          } else if (ack_id == 0x15) {
            printf("Error! NAK\r");
            break;
          } else
            printf("Skip!     \r");
        }
      } else {
        ack_id = 0x04;
        complete = 1;
        printf("Waiting for complete ACK ...");
        while (ack_id != 0x06) {
          ack_id = 0x04;
          write_number = write(fd, &ack_id, 1);
          while ((read(fd, &ack_id, 1)) <= 0)
            ;
        }
        printf("OK\r");
        printf("Sending file complete\r\n");
      }
      break;
    case 0x15:
      if (retry_num++ > 10) {
        printf("Retry too many times,Quit!\r\n");
        complete = 1;
      } else {
        write_number = write(fd, frame_data, 128 + 4);
        printf("Retry for ACK,%d,%d...", pack_counter, write_number);
        while (1) {
          while ((read(fd, &ack_id, 1)) <= 0)
            ;
          if (ack_id == 0x06) {
            printf("Ok!       \r");
            break;
          } else if (ack_id == 0x15) {
            printf("Error! NAK\r");
            break;
          } else
            printf("Skip!     \r");
        }
      }
      break;
    default:
      printf("Fatal Error!\r\n");
      complete = 1;
      break;
    }
  }
  fclose(datafile);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x160(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1203 <main+0x63>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1731 <main+0x591>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <Initial_SerialPort@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    124a <main+0xaa>
lea    0xe2d(%rip),%rdi
call   10c0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1731 <main+0x591>
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe06(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x140(%rbp)
cmp    $0x0,%rax
jne    129d <main+0xfd>
lea    0xdec(%rip),%rdi
call   10c0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1731 <main+0x591>
movl   $0x0,-0x14c(%rbp)
movl   $0x0,-0x144(%rbp)
movl   $0x0,-0x148(%rbp)
mov    -0x14(%rbp),%edi
call   1060 <ClearReceiveBuffer@plt>
mov    -0x14(%rbp),%edi
lea    -0x15b(%rbp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
cmp    $0x0,%rax
jg     12e6 <main+0x146>
jmp    12c3 <main+0x123>
movzbl -0x15b(%rbp),%esi
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movb   $0x6,-0x15b(%rbp)
cmpl   $0x0,-0x144(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    131b <main+0x17b>
jmp    1716 <main+0x576>
movzbl -0x15b(%rbp),%eax
mov    %eax,-0x164(%rbp)
sub    $0x6,%eax
je     134a <main+0x1aa>
jmp    1336 <main+0x196>
mov    -0x164(%rbp),%eax
sub    $0x15,%eax
je     15fc <main+0x45c>
jmp    16f9 <main+0x559>
movl   $0x0,-0x148(%rbp)
movl   $0x0,-0x160(%rbp)
mov    -0x14c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14c(%rbp)
lea    -0xa0(%rbp),%rdi
mov    -0x140(%rbp),%rcx
mov    $0x1,%esi
mov    $0x80,%edx
call   1030 <fread@plt>
mov    %eax,-0x150(%rbp)
cmpl   $0x0,-0x150(%rbp)
jle    1561 <main+0x3c1>
cmpl   $0x80,-0x150(%rbp)
jge    13f3 <main+0x253>
lea    0xcda(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x80,-0x150(%rbp)
jge    13ee <main+0x24e>
movslq -0x150(%rbp),%rax
movb   $0x0,-0xa0(%rbp,%rax,1)
mov    -0x150(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x150(%rbp)
jmp    13bb <main+0x21b>
jmp    13f3 <main+0x253>
movb   $0x1,-0x130(%rbp)
mov    -0x14c(%rbp),%eax
mov    %al,-0x12f(%rbp)
movsbl -0x12f(%rbp),%ecx
mov    $0xff,%eax
sub    %ecx,%eax
mov    %al,-0x12e(%rbp)
movl   $0x0,-0x158(%rbp)
cmpl   $0x80,-0x158(%rbp)
jge    1483 <main+0x2e3>
movslq -0x158(%rbp),%rax
mov    -0xa0(%rbp,%rax,1),%cl
mov    -0x158(%rbp),%eax
add    $0x3,%eax
cltq
mov    %cl,-0x130(%rbp,%rax,1)
movslq -0x158(%rbp),%rax
movsbl -0xa0(%rbp,%rax,1),%eax
ff
add    -0x160(%rbp),%eax
mov    %eax,-0x160(%rbp)
mov    -0x158(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x158(%rbp)
jmp    1424 <main+0x284>
mov    -0x160(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x160(%rbp)
mov    -0x160(%rbp),%eax
mov    %al,-0xad(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x130(%rbp),%rsi
mov    $0x84,%edx
mov    $0x0,%al
call   1040 <write@plt>
mov    %eax,-0x154(%rbp)
mov    -0x14c(%rbp),%esi
mov    -0x154(%rbp),%edx
lea    0xbdf(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    14db <main+0x33b>
mov    -0x14(%rbp),%edi
lea    -0x15b(%rbp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
cmp    $0x0,%rax
jg     14fe <main+0x35e>
jmp    14db <main+0x33b>
movzbl -0x15b(%rbp),%eax
cmp    $0x6,%eax
jne    1521 <main+0x381>
lea    0xbb0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    155c <main+0x3bc>
movzbl -0x15b(%rbp),%eax
cmp    $0x15,%eax
jne    1544 <main+0x3a4>
lea    0xb99(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    155c <main+0x3bc>
lea    0xb92(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1557 <main+0x3b7>
jmp    14d6 <main+0x336>
jmp    15f7 <main+0x457>
movb   $0x4,-0x15b(%rbp)
movl   $0x1,-0x144(%rbp)
lea    0xb70(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movzbl -0x15b(%rbp),%eax
cmp    $0x6,%eax
je     15db <main+0x43b>
movb   $0x4,-0x15b(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x15b(%rbp),%rsi
mov    $0x1,%edx
mov    $0x0,%al
call   1040 <write@plt>
mov    %eax,-0x154(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x15b(%rbp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
cmp    $0x0,%rax
jg     15d6 <main+0x436>
jmp    15b3 <main+0x413>
jmp    1580 <main+0x3e0>
lea    0xb24(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    0xb1a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1711 <main+0x571>
mov    -0x148(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x148(%rbp)
cmp    $0xa,%eax
jle    1633 <main+0x493>
lea    0xb05(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x144(%rbp)
jmp    16f4 <main+0x554>
mov    -0x14(%rbp),%edi
lea    -0x130(%rbp),%rsi
mov    $0x84,%edx
mov    $0x0,%al
call   1040 <write@plt>
mov    %eax,-0x154(%rbp)
mov    -0x14c(%rbp),%esi
mov    -0x154(%rbp),%edx
lea    0xadd(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    166e <main+0x4ce>
mov    -0x14(%rbp),%edi
lea    -0x15b(%rbp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
cmp    $0x0,%rax
jg     1691 <main+0x4f1>
jmp    166e <main+0x4ce>
movzbl -0x15b(%rbp),%eax
cmp    $0x6,%eax
jne    16b4 <main+0x514>
lea    0xa1d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    16ef <main+0x54f>
movzbl -0x15b(%rbp),%eax
cmp    $0x15,%eax
jne    16d7 <main+0x537>
lea    0xa06(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    16ef <main+0x54f>
lea    0x9ff(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    16ea <main+0x54a>
jmp    1669 <main+0x4c9>
jmp    16f4 <main+0x554>
jmp    1711 <main+0x571>
lea    0xa56(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x144(%rbp)
jmp    1302 <main+0x162>
mov    -0x140(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%rbp
cmp    $0x1,%edi
jne    1204 <main+0x44>
mov    0x0(%rbp),%rsi
lea    0xe1c(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x0(%rbp),%rsi
lea    0xe33(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    17d1 <main+0x611>
mov    0x8(%rbp),%rsi
lea    0xe43(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x8(%rbp),%rdi
call   10c0 <Initial_SerialPort@plt>
cmp    $0xffffffff,%eax
je     17e5 <main+0x625>
mov    %eax,%ebx
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
mov    0x10(%rbp),%rdi
lea    0xe2e(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
je     17ee <main+0x62e>
mov    %ebx,%edi
call   1070 <ClearReceiveBuffer@plt>
lea    0x7(%rsp),%rbp
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
test   %rax,%rax
jle    1260 <main+0xa0>
movzbl 0x7(%rsp),%esi
lea    0xe03(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
movb   $0x6,0x7(%rsp)
mov    $0x6,%al
lea    0x7(%rsp),%rbp
lea    0xe1d(%rip),%r15
xor    %r12d,%r12d
xor    %r14d,%r14d
jmp    12c8 <main+0x108>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xde8(%rip),%rdi
mov    %r12d,%r13d
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x7(%rsp),%al
mov    %r13d,%r12d
cmp    $0x15,%al
je     1680 <main+0x4c0>
cmp    $0x6,%al
jne    172c <main+0x56c>
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    $0x80,%edx
mov    0x8(%rsp),%rcx
call   1040 <fread@plt>
test   %eax,%eax
jle    1738 <main+0x578>
mov    %eax,%r14d
lea    0x1(%r12),%r13d
cmp    $0x7f,%eax
ja     1330 <main+0x170>
lea    0xe26(%rip),%rdi
call   1030 <puts@plt>
mov    %r14d,%eax
lea    (%rsp,%rax,1),%rdi
add    $0x10,%rdi
mov    $0x7f,%edx
sub    %r14d,%edx
add    $0x1,%rdx
xor    %esi,%esi
call   1090 <memset@plt>
movb   $0x1,0x90(%rsp)
01
mov    %r13b,0x91(%rsp)
mov    $0xfe,%al
sub    %r12b,%al
mov    %al,0x92(%rsp)
movaps 0x80(%rsp),%xmm0
lea    0x93(%rsp),%rax
movups %xmm0,0x70(%rax)
movaps 0x70(%rsp),%xmm0
movups %xmm0,0x60(%rax)
movaps 0x60(%rsp),%xmm0
movups %xmm0,0x50(%rax)
movaps 0x50(%rsp),%xmm0
movups %xmm0,0x40(%rax)
movaps 0x10(%rsp),%xmm0
movaps 0x20(%rsp),%xmm1
movdqa 0x30(%rsp),%xmm2
movaps 0x40(%rsp),%xmm3
movups %xmm3,0x30(%rax)
movdqu %xmm2,0x20(%rax)
movups %xmm1,0x10(%rax)
movups %xmm0,(%rax)
movd   0x14(%rsp),%xmm0
movdqa 0x10(%rsp),%xmm4
movdqa 0x20(%rsp),%xmm3
movdqa 0x30(%rsp),%xmm1
movdqa 0x40(%rsp),%xmm9
pxor   %xmm2,%xmm2
punpcklbw %xmm2,%xmm4
punpcklwd %xmm2,%xmm4
punpcklbw %xmm2,%xmm0
punpcklwd %xmm2,%xmm0
movq   0x18(%rsp),%xmm6
movd   0x1c(%rsp),%xmm5
punpcklbw %xmm2,%xmm6
punpcklwd %xmm2,%xmm6
paddd  %xmm4,%xmm6
punpcklbw %xmm2,%xmm5
punpcklwd %xmm2,%xmm5
paddd  %xmm0,%xmm5
movd   0x24(%rsp),%xmm7
punpcklbw %xmm2,%xmm3
punpcklwd %xmm2,%xmm3
punpcklbw %xmm2,%xmm7
punpcklwd %xmm2,%xmm7
movq   0x28(%rsp),%xmm4
movd   0x2c(%rsp),%xmm0
punpcklbw %xmm2,%xmm4
punpcklwd %xmm2,%xmm4
paddd  %xmm3,%xmm4
paddd  %xmm6,%xmm4
punpcklbw %xmm2,%xmm0
punpcklwd %xmm2,%xmm0
paddd  %xmm7,%xmm0
paddd  %xmm5,%xmm0
movd   0x34(%rsp),%xmm3
punpcklbw %xmm2,%xmm1
punpcklwd %xmm2,%xmm1
punpcklbw %xmm2,%xmm3
punpcklwd %xmm2,%xmm3
movq   0x38(%rsp),%xmm5
movd   0x3c(%rsp),%xmm6
punpcklbw %xmm2,%xmm5
punpcklwd %xmm2,%xmm5
paddd  %xmm1,%xmm5
punpcklbw %xmm2,%xmm6
punpcklwd %xmm2,%xmm6
paddd  %xmm3,%xmm6
movd   0x44(%rsp),%xmm3
punpcklbw %xmm2,%xmm9
punpcklwd %xmm2,%xmm9
paddd  %xmm5,%xmm9
paddd  %xmm4,%xmm9
punpcklbw %xmm2,%xmm3
punpcklwd %xmm2,%xmm3
paddd  %xmm6,%xmm3
paddd  %xmm0,%xmm3
movq   0x48(%rsp),%xmm1
movd   0x4c(%rsp),%xmm0
punpcklbw %xmm2,%xmm1
punpcklwd %xmm2,%xmm1
punpcklbw %xmm2,%xmm0
punpcklwd %xmm2,%xmm0
movdqa 0x50(%rsp),%xmm4
movd   0x54(%rsp),%xmm5
punpcklbw %xmm2,%xmm4
punpcklwd %xmm2,%xmm4
paddd  %xmm1,%xmm4
punpcklbw %xmm2,%xmm5
punpcklwd %xmm2,%xmm5
paddd  %xmm0,%xmm5
movq   0x58(%rsp),%xmm6
movd   0x5c(%rsp),%xmm7
punpcklbw %xmm2,%xmm6
punpcklwd %xmm2,%xmm6
paddd  %xmm4,%xmm6
punpcklbw %xmm2,%xmm7
punpcklwd %xmm2,%xmm7
paddd  %xmm5,%xmm7
movdqa 0x60(%rsp),%xmm1
movd   0x64(%rsp),%xmm8
punpcklbw %xmm2,%xmm1
punpcklwd %xmm2,%xmm1
paddd  %xmm6,%xmm1
paddd  %xmm9,%xmm1
punpcklbw %xmm2,%xmm8
punpcklwd %xmm2,%xmm8
paddd  %xmm7,%xmm8
paddd  %xmm3,%xmm8
movq   0x68(%rsp),%xmm0
movd   0x6c(%rsp),%xmm3
punpcklbw %xmm2,%xmm0
punpcklwd %xmm2,%xmm0
punpcklbw %xmm2,%xmm3
punpcklwd %xmm2,%xmm3
movdqa 0x70(%rsp),%xmm4
movd   0x74(%rsp),%xmm5
punpcklbw %xmm2,%xmm4
punpcklwd %xmm2,%xmm4
paddd  %xmm0,%xmm4
punpcklbw %xmm2,%xmm5
punpcklwd %xmm2,%xmm5
paddd  %xmm3,%xmm5
movq   0x78(%rsp),%xmm0
movd   0x7c(%rsp),%xmm3
punpcklbw %xmm2,%xmm0
punpcklwd %xmm2,%xmm0
paddd  %xmm4,%xmm0
punpcklbw %xmm2,%xmm3
punpcklwd %xmm2,%xmm3
paddd  %xmm5,%xmm3
movdqa 0x80(%rsp),%xmm4
movd   0x84(%rsp),%xmm5
punpcklbw %xmm2,%xmm4
punpcklwd %xmm2,%xmm4
paddd  %xmm0,%xmm4
punpcklbw %xmm2,%xmm5
punpcklwd %xmm2,%xmm5
paddd  %xmm3,%xmm5
movq   0x88(%rsp),%xmm0
movd   0x8c(%rsp),%xmm3
punpcklbw %xmm2,%xmm0
punpcklwd %xmm2,%xmm0
paddd  %xmm4,%xmm0
paddd  %xmm1,%xmm0
punpcklbw %xmm2,%xmm3
punpcklwd %xmm2,%xmm3
paddd  %xmm5,%xmm3
paddd  %xmm8,%xmm3
paddd  %xmm0,%xmm3
pshufd $0xee,%xmm3,%xmm0
paddd  %xmm3,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%eax
mov    %al,0x113(%rsp)
mov    %ebx,%edi
lea    0x90(%rsp),%rsi
mov    $0x84,%edx
xor    %eax,%eax
call   1050 <write@plt>
lea    0xa56(%rip),%rdi
mov    %r13d,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <printf@plt>
xchg   %ax,%ax
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
test   %rax,%rax
jle    1640 <main+0x480>
movzbl 0x7(%rsp),%eax
cmp    $0x6,%al
je     1700 <main+0x540>
cmp    $0x15,%al
je     1710 <main+0x550>
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1640 <main+0x480>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0xa,%r14d
jg     17b2 <main+0x5f2>
add    $0x1,%r14d
mov    %ebx,%edi
lea    0x90(%rsp),%rsi
mov    $0x84,%edx
xor    %eax,%eax
call   1050 <write@plt>
lea    0xa39(%rip),%rdi
mov    %r12d,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <printf@plt>
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
test   %rax,%rax
jle    16c0 <main+0x500>
movzbl 0x7(%rsp),%eax
cmp    $0x6,%al
je     12b0 <main+0xf0>
cmp    $0x15,%al
je     1720 <main+0x560>
mov    %r15,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    16c0 <main+0x500>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %r14d,%r14d
lea    0x995(%rip),%rdi
jmp    12ba <main+0xfa>
nop
xor    %r14d,%r14d
lea    0x991(%rip),%rdi
jmp    12ba <main+0xfa>
nop
lea    0x984(%rip),%rdi
jmp    12b7 <main+0xf7>
lea    0xa1f(%rip),%rdi
jmp    17b9 <main+0x5f9>
movb   $0x4,0x7(%rsp)
lea    0x97f(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
cmpb   $0x6,0x7(%rsp)
je     179b <main+0x5db>
lea    0x7(%rsp),%rbp
nopw   0x0(%rax,%rax,1)
movb   $0x4,0x7(%rsp)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
xor    %eax,%eax
call   1050 <write@plt>
cs nopw 0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   10b0 <read@plt>
test   %rax,%rax
jle    1780 <main+0x5c0>
cmpb   $0x6,0x7(%rsp)
jne    1760 <main+0x5a0>
lea    0x93e(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0x96c(%rip),%rdi
jmp    17b9 <main+0x5f9>
lea    0x947(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%rdi
call   1060 <fclose@plt>
mov    %ebx,%edi
call   10a0 <close@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x87a(%rip),%rdi
jmp    17f5 <main+0x635>
lea    0x87d(%rip),%rdi
call   10e0 <perror@plt>
mov    $0xffffffff,%ebx
jmp    17d1 <main+0x611>

LLVM IR (-O0):
@.str = [43 x i8] c"Usage %s <uart device> <file to transfer>\0A\00"
@.str.1 = [39 x i8] c" Example %s /dev/ttyS0 myfile.bin\0A\00"
@.str.2 = [20 x i8] c"Opening Uart %s... \00"
@.str.3 = [9 x i8] c"Failed!\0A\00"
@.str.4 = [6 x i8] c"Done\0A\00"
@.str.5 = [3 x i8] c"rb\00"
@.str.6 = [17 x i8] c"Can't open file!\00"
@.str.7 = [5 x i8] c"%c\0D\0A\00"
@.str.8 = [32 x i8] c"Start filling the last frame!\0D\0A\00"
@.str.9 = [23 x i8] c"wait for ACK,%d,%d,...\00"
@.str.10 = [12 x i8] c"Ok! \0D\00"
@.str.11 = [12 x i8] c"Error! NAK\0D\00"
@.str.12 = [12 x i8] c"Skip! \0D\00"
@.str.13 = [29 x i8] c"Waiting for complete ACK ...\00"
@.str.14 = [4 x i8] c"OK\0D\00"
@.str.15 = [24 x i8] c"Sending file complete\0D\0A\00"
@.str.16 = [29 x i8] c"Retry too many times,Quit!\0D\0A\00"
@.str.17 = [23 x i8] c"Retry for ACK,%d,%d...\00"
@.str.18 = [15 x i8] c"Fatal Error!\0D\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [128 x i8]
%9 = alloca [132 x i8]
%10 = alloca i8
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i16
%19 = alloca i8
%20 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %20
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %32
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %26)
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %30)
store i32 0, i32* %3
br label %229
32: ; preds = %2
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %35)
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
%40 = call i32 @Initial_SerialPort(i8* %39)
store i32 %40, i32* %6
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %44
42: ; preds = %32
%43 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %229
44: ; preds = %32
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 2
%48 = load i8*, i8** %47
store i8* %48, i8** %7
%49 = load i8*, i8** %7
%50 = call i32* @fopen(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
store i32* %50, i32** %11
%51 = icmp eq i32* %50, null
br i1 %51, label %52, label %54
52: ; preds = %44
%53 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %3
br label %229
54: ; preds = %44
store i32 0, i32* %14
store i32 0, i32* %12
store i32 0, i32* %13
%55 = load i32, i32* %6
%56 = call i32 @ClearReceiveBuffer(i32 %55)
br label %57
57: ; preds = %61, %54
%58 = load i32, i32* %6
%59 = call i64 @read(i32 %58, i8* %19, i32 1)
%60 = icmp sle i64 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %57
br label %57
62: ; preds = %57
%63 = load i8, i8* %19
%64 = zext i8 %63 to i32
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %64)
store i8 6, i8* %19
br label %66
66: ; preds = %223, %62
%67 = load i32, i32* %12
%68 = icmp ne i32 %67, 0
%69 = xor i1 %68, true
br i1 %69, label %70, label %224
70: ; preds = %66
%71 = load i8, i8* %19
%72 = zext i8 %71 to i32
switch i32 %72, label %221 [
i32 6, label %73
i32 21, label %184
]
73: ; preds = %70
store i32 0, i32* %13
store i32 0, i32* %20
%74 = load i32, i32* %14
%75 = add nsw i32 %74, 1
store i32 %75, i32* %14
%76 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 0
%77 = load i32*, i32** %11
%78 = call i32 @fread(i8* %76, i32 1, i32 128, i32* %77)
store i32 %78, i32* %15
%79 = load i32, i32* %15
%80 = icmp sgt i32 %79, 0
br i1 %80, label %81, label %165
81: ; preds = %73
%82 = load i32, i32* %15
%83 = icmp slt i32 %82, 128
br i1 %83, label %84, label %97
84: ; preds = %81
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.8, i64 0, i64 0))
br label %86
86: ; preds = %93, %84
%87 = load i32, i32* %15
%88 = icmp slt i32 %87, 128
br i1 %88, label %89, label %96
89: ; preds = %86
%90 = load i32, i32* %15
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 %91
store i8 0, i8* %92
br label %93
93: ; preds = %89
%94 = load i32, i32* %15
%95 = add nsw i32 %94, 1
store i32 %95, i32* %15
br label %86
96: ; preds = %86
br label %97
97: ; preds = %96, %81
%98 = getelementptr inbounds [132 x i8], [132 x i8]* %9, i64 0, i64 0
store i8 1, i8* %98
%99 = load i32, i32* %14
%100 = trunc i32 %99 to i8
%101 = getelementptr inbounds [132 x i8], [132 x i8]* %9, i64 0, i64 1
store i8 %100, i8* %101
%102 = getelementptr inbounds [132 x i8], [132 x i8]* %9, i64 0, i64 1
%103 = load i8, i8* %102
%104 = sext i8 %103 to i32
%105 = sub nsw i32 255, %104
%106 = trunc i32 %105 to i8
%107 = getelementptr inbounds [132 x i8], [132 x i8]* %9, i64 0, i64 2
store i8 %106, i8* %107
store i32 0, i32* %17
br label %108
108: ; preds = %127, %97
%109 = load i32, i32* %17
%110 = icmp slt i32 %109, 128
br i1 %110, label %111, label %130
111: ; preds = %108
%112 = load i32, i32* %17
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 %113
%115 = load i8, i8* %114
%116 = load i32, i32* %17
%117 = add nsw i32 %116, 3
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds [132 x i8], [132 x i8]* %9, i64 0, i64 %118
store i8 %115, i8* %119
%120 = load i32, i32* %17
%121 = sext i32 %120 to i64
%122 = getelementptr inbounds [128 x i8], [128 x i8]* %8, i64 0, i64 %121
%123 = load i8, i8* %122
%124 = sext i8 %123 to i32
%125 = load i32, i32* %20
%126 = add i32 %125, %124
store i32 %126, i32* %20
br label %127
127: ; preds = %111
%128 = load i32, i32* %17
%129 = add nsw i32 %128, 1
store i32 %129, i32* %17
br label %108
130: ; preds = %108
%131 = load i32, i32* %20
%132 = urem i32 %131, 256
store i32 %132, i32* %20
%133 = load i32, i32* %20
%134 = trunc i32 %133 to i8
%135 = getelementptr inbounds [132 x i8], [132 x i8]* %9, i64 0, i64 131
store i8 %134, i8* %135
%136 = load i32, i32* %6
%137 = getelementptr inbounds [132 x i8], [132 x i8]* %9, i64 0, i64 0
%138 = call i32 (i32, ...) @write(i32 %136, i8* %137, i32 132)
store i32 %138, i32* %16
%139 = load i32, i32* %14
%140 = load i32, i32* %16
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %139, i32 %140)
br label %142
142: ; preds = %130, %163
br label %143
143: ; preds = %147, %142
%144 = load i32, i32* %6
%145 = call i64 @read(i32 %144, i8* %19, i32 1)
%146 = icmp sle i64 %145, 0
br i1 %146, label %147, label %148
147: ; preds = %143
br label %143
148: ; preds = %143
%149 = load i8, i8* %19
%150 = zext i8 %149 to i32
%151 = icmp eq i32 %150, 6
br i1 %151, label %152, label %154
152: ; preds = %148
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %164
154: ; preds = %148
%155 = load i8, i8* %19
%156 = zext i8 %155 to i32
%157 = icmp eq i32 %156, 21
br i1 %157, label %158, label %160
158: ; preds = %154
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
br label %164
160: ; preds = %154
%161 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
br label %162
162: ; preds = %160
br label %163
163: ; preds = %162
br label %142
164: ; preds = %158, %152
br label %183
165: ; preds = %73
store i8 4, i8* %19
store i32 1, i32* %12
%166 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0))
br label %167
167: ; preds = %179, %165
%168 = load i8, i8* %19
%169 = zext i8 %168 to i32
%170 = icmp ne i32 %169, 6
br i1 %170, label %171, label %180
171: ; preds = %167
store i8 4, i8* %19
%172 = load i32, i32* %6
%173 = call i32 (i32, ...) @write(i32 %172, i8* %19, i32 1)
store i32 %173, i32* %16
br label %174
174: ; preds = %178, %171
%175 = load i32, i32* %6
%176 = call i64 @read(i32 %175, i8* %19, i32 1)
%177 = icmp sle i64 %176, 0
br i1 %177, label %178, label %179
178: ; preds = %174
br label %174
179: ; preds = %174
br label %167
180: ; preds = %167
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0))
%182 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.15, i64 0, i64 0))
br label %183
183: ; preds = %180, %164
br label %223
184: ; preds = %70
%185 = load i32, i32* %13
%186 = add nsw i32 %185, 1
store i32 %186, i32* %13
%187 = icmp sgt i32 %185, 10
br i1 %187, label %188, label %190
188: ; preds = %184
%189 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.16, i64 0, i64 0))
store i32 1, i32* %12
br label %220
190: ; preds = %184
%191 = load i32, i32* %6
%192 = getelementptr inbounds [132 x i8], [132 x i8]* %9, i64 0, i64 0
%193 = call i32 (i32, ...) @write(i32 %191, i8* %192, i32 132)
store i32 %193, i32* %16
%194 = load i32, i32* %14
%195 = load i32, i32* %16
%196 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0), i32 %194, i32 %195)
br label %197
197: ; preds = %190, %218
br label %198
198: ; preds = %202, %197
%199 = load i32, i32* %6
%200 = call i64 @read(i32 %199, i8* %19, i32 1)
%201 = icmp sle i64 %200, 0
br i1 %201, label %202, label %203
202: ; preds = %198
br label %198
203: ; preds = %198
%204 = load i8, i8* %19
%205 = zext i8 %204 to i32
%206 = icmp eq i32 %205, 6
br i1 %206, label %207, label %209
207: ; preds = %203
%208 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0))
br label %219
209: ; preds = %203
%210 = load i8, i8* %19
%211 = zext i8 %210 to i32
%212 = icmp eq i32 %211, 21
br i1 %212, label %213, label %215
213: ; preds = %209
%214 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0))
br label %219
215: ; preds = %209
%216 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
br label %217
217: ; preds = %215
br label %218
218: ; preds = %217
br label %197
219: ; preds = %213, %207
br label %220
220: ; preds = %219, %188
br label %223
221: ; preds = %70
%222 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.18, i64 0, i64 0))
store i32 1, i32* %12
br label %223
223: ; preds = %221, %220, %183
br label %66
224: ; preds = %66
%225 = load i32*, i32** %11
%226 = call i32 @fclose(i32* %225)
%227 = load i32, i32* %6
%228 = call i32 @close(i32 %227)
store i32 0, i32* %3
br label %229
229: ; preds = %224, %52, %42, %23
%230 = load i32, i32* %3
ret i32 %230
}

LLVM IR (-O2):
@.str = [43 x i8] c"Usage %s <uart device> <file to transfer>\0A\00"
@.str.1 = [39 x i8] c" Example %s /dev/ttyS0 myfile.bin\0A\00"
@.str.2 = [20 x i8] c"Opening Uart %s... \00"
@.str.3 = [9 x i8] c"Failed!\0A\00"
@.str.5 = [3 x i8] c"rb\00"
@.str.6 = [17 x i8] c"Can't open file!\00"
@.str.7 = [5 x i8] c"%c\0D\0A\00"
@.str.9 = [23 x i8] c"wait for ACK,%d,%d,...\00"
@.str.10 = [12 x i8] c"Ok! \0D\00"
@.str.11 = [12 x i8] c"Error! NAK\0D\00"
@.str.12 = [12 x i8] c"Skip! \0D\00"
@.str.13 = [29 x i8] c"Waiting for complete ACK ...\00"
@.str.14 = [4 x i8] c"OK\0D\00"
@.str.17 = [23 x i8] c"Retry for ACK,%d,%d...\00"
@str = [5 x i8] c"Done\00"
@str.19 = [28 x i8] c"Retry too many times,Quit!\0D\00"
@str.20 = [23 x i8] c"Sending file complete\0D\00"
@str.21 = [31 x i8] c"Start filling the last frame!\0D\00"
@str.22 = [14 x i8] c"Fatal Error!\0D\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [128 x i8]
%4 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%5 = alloca [132 x i8]
%6 = alloca i8
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [132 x i8], [132 x i8]* %5, i64 0, i64 0
%9 = icmp eq i32 %0, 1
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8*, i8** %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %1
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %277
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = load i8*, i8** %16
%20 = tail call i32 @Initial_SerialPort(i8* %19)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %24
22: ; preds = %15
%23 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
br label %277
24: ; preds = %15
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = tail call i32* @fopen(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0))
br label %277
32: ; preds = %24
%33 = tail call i32 @ClearReceiveBuffer(i32 %20)
br label %34
34: ; preds = %34, %32
%35 = call i64 @read(i32 %20, i8* %6, i32 1)
%36 = icmp slt i64 %35, 1
br i1 %36, label %34, label %37
37: ; preds = %34
%38 = load i8, i8* %6
%39 = zext i8 %38 to i32
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 %39)
store i8 6, i8* %6
%41 = getelementptr inbounds [132 x i8], [132 x i8]* %5, i64 0, i64 1
%42 = getelementptr inbounds [132 x i8], [132 x i8]* %5, i64 0, i64 2
%43 = getelementptr inbounds [132 x i8], [132 x i8]* %5, i64 0, i64 131
%44 = getelementptr inbounds [132 x i8], [132 x i8]* %5, i64 0, i64 3
%45 = bitcast [128 x i8]* %3 to <4 x i8>*
%46 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 4
%47 = bitcast i8* %46 to <4 x i8>*
%48 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 8
%49 = bitcast i8* %48 to <4 x i8>*
%50 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 12
%51 = bitcast i8* %50 to <4 x i8>*
%52 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 16
%53 = bitcast i8* %52 to <4 x i8>*
%54 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 20
%55 = bitcast i8* %54 to <4 x i8>*
%56 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 24
%57 = bitcast i8* %56 to <4 x i8>*
%58 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 28
%59 = bitcast i8* %58 to <4 x i8>*
%60 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 32
%61 = bitcast i8* %60 to <4 x i8>*
%62 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 36
%63 = bitcast i8* %62 to <4 x i8>*
%64 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 40
%65 = bitcast i8* %64 to <4 x i8>*
%66 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 44
%67 = bitcast i8* %66 to <4 x i8>*
%68 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 48
%69 = bitcast i8* %68 to <4 x i8>*
%70 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 52
%71 = bitcast i8* %70 to <4 x i8>*
%72 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 56
%73 = bitcast i8* %72 to <4 x i8>*
%74 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 60
%75 = bitcast i8* %74 to <4 x i8>*
%76 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 64
%77 = bitcast i8* %76 to <4 x i8>*
%78 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 68
%79 = bitcast i8* %78 to <4 x i8>*
%80 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 72
%81 = bitcast i8* %80 to <4 x i8>*
%82 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 76
%83 = bitcast i8* %82 to <4 x i8>*
%84 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 80
%85 = bitcast i8* %84 to <4 x i8>*
%86 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 84
%87 = bitcast i8* %86 to <4 x i8>*
%88 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 88
%89 = bitcast i8* %88 to <4 x i8>*
%90 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 92
%91 = bitcast i8* %90 to <4 x i8>*
%92 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 96
%93 = bitcast i8* %92 to <4 x i8>*
%94 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 100
%95 = bitcast i8* %94 to <4 x i8>*
%96 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 104
%97 = bitcast i8* %96 to <4 x i8>*
%98 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 108
%99 = bitcast i8* %98 to <4 x i8>*
%100 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 112
%101 = bitcast i8* %100 to <4 x i8>*
%102 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 116
%103 = bitcast i8* %102 to <4 x i8>*
%104 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 120
%105 = bitcast i8* %104 to <4 x i8>*
%106 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 124
%107 = bitcast i8* %106 to <4 x i8>*
br label %108
108: ; preds = %266, %37
%109 = phi i8 [ 6, %37 ], [ %271, %266 ]
%110 = phi i32 [ 0, %37 ], [ %269, %266 ]
%111 = phi i32 [ 0, %37 ], [ %268, %266 ]
switch i8 %109, label %272 [
i8 6, label %112
i8 21, label %250
]
112: ; preds = %108
%113 = add nsw i32 %110, 1
%114 = call i32 @fread(i8* %7, i32 1, i32 128, i32* %28)
%115 = icmp sgt i32 %114, 0
br i1 %115, label %116, label %236
116: ; preds = %112
%117 = icmp ult i32 %114, 128
br i1 %117, label %118, label %125
118: ; preds = %116
%119 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.21, i64 0, i64 0))
%120 = zext i32 %114 to i64
%121 = getelementptr [128 x i8], [128 x i8]* %3, i64 0, i64 %120
%122 = sub nuw nsw i32 127, %114
%123 = zext i32 %122 to i64
%124 = add nuw nsw i64 %123, 1
br label %125
125: ; preds = %118, %116
store i8 1, i8* %8
%126 = trunc i32 %113 to i8
store i8 %126, i8* %41
%127 = trunc i32 %110 to i8
%128 = sub i8 -2, %127
store i8 %128, i8* %42
%129 = load <4 x i8>, <4 x i8>* %45
%130 = load <4 x i8>, <4 x i8>* %47
%131 = zext <4 x i8> %129 to <4 x i32>
%132 = zext <4 x i8> %130 to <4 x i32>
%133 = load <4 x i8>, <4 x i8>* %49
%134 = load <4 x i8>, <4 x i8>* %51
%135 = zext <4 x i8> %133 to <4 x i32>
%136 = zext <4 x i8> %134 to <4 x i32>
%137 = add nuw nsw <4 x i32> %131, %135
%138 = add nuw nsw <4 x i32> %132, %136
%139 = load <4 x i8>, <4 x i8>* %53
%140 = load <4 x i8>, <4 x i8>* %55
%141 = zext <4 x i8> %139 to <4 x i32>
%142 = zext <4 x i8> %140 to <4 x i32>
%143 = add nuw nsw <4 x i32> %137, %141
%144 = add nuw nsw <4 x i32> %138, %142
%145 = load <4 x i8>, <4 x i8>* %57
%146 = load <4 x i8>, <4 x i8>* %59
%147 = zext <4 x i8> %145 to <4 x i32>
%148 = zext <4 x i8> %146 to <4 x i32>
%149 = add nuw nsw <4 x i32> %143, %147
%150 = add nuw nsw <4 x i32> %144, %148
%151 = load <4 x i8>, <4 x i8>* %61
%152 = load <4 x i8>, <4 x i8>* %63
%153 = zext <4 x i8> %151 to <4 x i32>
%154 = zext <4 x i8> %152 to <4 x i32>
%155 = add nuw nsw <4 x i32> %149, %153
%156 = add nuw nsw <4 x i32> %150, %154
%157 = load <4 x i8>, <4 x i8>* %65
%158 = load <4 x i8>, <4 x i8>* %67
%159 = zext <4 x i8> %157 to <4 x i32>
%160 = zext <4 x i8> %158 to <4 x i32>
%161 = add nuw nsw <4 x i32> %155, %159
%162 = add nuw nsw <4 x i32> %156, %160
%163 = load <4 x i8>, <4 x i8>* %69
%164 = load <4 x i8>, <4 x i8>* %71
%165 = zext <4 x i8> %163 to <4 x i32>
%166 = zext <4 x i8> %164 to <4 x i32>
%167 = add nuw nsw <4 x i32> %161, %165
%168 = add nuw nsw <4 x i32> %162, %166
%169 = load <4 x i8>, <4 x i8>* %73
%170 = load <4 x i8>, <4 x i8>* %75
%171 = zext <4 x i8> %169 to <4 x i32>
%172 = zext <4 x i8> %170 to <4 x i32>
%173 = add <4 x i32> %167, %171
%174 = add <4 x i32> %168, %172
%175 = load <4 x i8>, <4 x i8>* %77
%176 = load <4 x i8>, <4 x i8>* %79
%177 = zext <4 x i8> %175 to <4 x i32>
%178 = zext <4 x i8> %176 to <4 x i32>
%179 = add <4 x i32> %173, %177
%180 = add <4 x i32> %174, %178
%181 = load <4 x i8>, <4 x i8>* %81
%182 = load <4 x i8>, <4 x i8>* %83
%183 = zext <4 x i8> %181 to <4 x i32>
%184 = zext <4 x i8> %182 to <4 x i32>
%185 = add <4 x i32> %179, %183
%186 = add <4 x i32> %180, %184
%187 = load <4 x i8>, <4 x i8>* %85
%188 = load <4 x i8>, <4 x i8>* %87
%189 = zext <4 x i8> %187 to <4 x i32>
%190 = zext <4 x i8> %188 to <4 x i32>
%191 = add <4 x i32> %185, %189
%192 = add <4 x i32> %186, %190
%193 = load <4 x i8>, <4 x i8>* %89
%194 = load <4 x i8>, <4 x i8>* %91
%195 = zext <4 x i8> %193 to <4 x i32>
%196 = zext <4 x i8> %194 to <4 x i32>
%197 = add <4 x i32> %191, %195
%198 = add <4 x i32> %192, %196
%199 = load <4 x i8>, <4 x i8>* %93
%200 = load <4 x i8>, <4 x i8>* %95
%201 = zext <4 x i8> %199 to <4 x i32>
%202 = zext <4 x i8> %200 to <4 x i32>
%203 = add <4 x i32> %197, %201
%204 = add <4 x i32> %198, %202
%205 = load <4 x i8>, <4 x i8>* %97
%206 = load <4 x i8>, <4 x i8>* %99
%207 = zext <4 x i8> %205 to <4 x i32>
%208 = zext <4 x i8> %206 to <4 x i32>
%209 = add <4 x i32> %203, %207
%210 = add <4 x i32> %204, %208
%211 = load <4 x i8>, <4 x i8>* %101
%212 = load <4 x i8>, <4 x i8>* %103
%213 = zext <4 x i8> %211 to <4 x i32>
%214 = zext <4 x i8> %212 to <4 x i32>
%215 = add <4 x i32> %209, %213
%216 = add <4 x i32> %210, %214
%217 = load <4 x i8>, <4 x i8>* %105
%218 = load <4 x i8>, <4 x i8>* %107
%219 = zext <4 x i8> %217 to <4 x i32>
%220 = zext <4 x i8> %218 to <4 x i32>
%221 = add <4 x i32> %215, %219
%222 = add <4 x i32> %216, %220
%223 = add <4 x i32> %222, %221
%224 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %223)
%225 = trunc i32 %224 to i8
store i8 %225, i8* %43
%226 = call i32 (i32, ...) @write(i32 %20, i8* %8, i32 132)
%227 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %113, i32 %226)
br label %228
228: ; preds = %231, %125
%229 = call i64 @read(i32 %20, i8* %6, i32 1)
%230 = icmp slt i64 %229, 1
br i1 %230, label %231, label %232
231: ; preds = %228, %234
br label %228
232: ; preds = %228
%233 = load i8, i8* %6
switch i8 %233, label %234 [
i8 6, label %266
i8 21, label %264
]
234: ; preds = %232
%235 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
br label %231
236: ; preds = %112
store i8 4, i8* %6
%237 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.13, i64 0, i64 0))
%238 = load i8, i8* %6
%239 = icmp eq i8 %238, 6
br i1 %239, label %248, label %243
240: ; preds = %245
%241 = load i8, i8* %6
%242 = icmp eq i8 %241, 6
br i1 %242, label %248, label %243
243: ; preds = %236, %240
store i8 4, i8* %6
%244 = call i32 (i32, ...) @write(i32 %20, i8* %6, i32 1)
br label %245
245: ; preds = %245, %243
%246 = call i64 @read(i32 %20, i8* %6, i32 1)
%247 = icmp slt i64 %246, 1
br i1 %247, label %245, label %240
248: ; preds = %240, %236
%249 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0))
br label %272
250: ; preds = %108
%251 = add nsw i32 %111, 1
%252 = icmp sgt i32 %111, 10
br i1 %252, label %272, label %253
253: ; preds = %250
%254 = call i32 (i32, ...) @write(i32 %20, i8* %8, i32 132)
%255 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.17, i64 0, i64 0), i32 %110, i32 %254)
br label %256
256: ; preds = %259, %253
%257 = call i64 @read(i32 %20, i8* %6, i32 1)
%258 = icmp slt i64 %257, 1
br i1 %258, label %259, label %260
259: ; preds = %256, %262
br label %256
260: ; preds = %256
%261 = load i8, i8* %6
switch i8 %261, label %262 [
i8 6, label %266
i8 21, label %265
]
262: ; preds = %260
%263 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
br label %259
264: ; preds = %232
br label %266
265: ; preds = %260
br label %266
266: ; preds = %260, %232, %265, %264
%267 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), %264 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), %265 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), %232 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), %260 ]
%268 = phi i32 [ 0, %264 ], [ %251, %265 ], [ 0, %232 ], [ %251, %260 ]
%269 = phi i32 [ %113, %264 ], [ %110, %265 ], [ %113, %232 ], [ %110, %260 ]
%270 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %267)
%271 = load i8, i8* %6
br label %108
272: ; preds = %108, %250, %248
%273 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.20, i64 0, i64 0), %248 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @str.19, i64 0, i64 0), %250 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.22, i64 0, i64 0), %108 ]
%274 = call i32 @puts(i8* dereferenceable(1) %273)
%275 = call i32 @fclose(i32* %28)
%276 = call i32 @close(i32 %20)
br label %277
277: ; preds = %272, %30, %22, %10
%278 = phi i32 [ 0, %10 ], [ -1, %22 ], [ -1, %30 ], [ 0, %272 ]
ret i32 %278
}