#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*/ time_t;
struct tm {
  int dummy;
};
struct timeval {
  int tv_usec;
  int tv_sec;
};
typedef int ssize_t;

/* Variables and functions */
int B115200;
int B230400;
int B9600;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ TCIOFLUSH;
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int getopt(int, char **, char *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
struct tm *localtime(int /*<<< orphan*/ *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ print_app_usage();
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ set_interface_attribs(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int strlen(char *);
int /*<<< orphan*/ tcflush(int, int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char **argv) {
  struct timeval now_time;
  struct timeval prev_send_time;
  struct tm *timeinfo;
  time_t now_to_print;
  char time_buffer[30];
  long int tdiff = 0;
  int send_lock = 1;
  int send_counter = 0;
  char serial_dev[20] = "/dev/ttyS0";
  int interval_ms = 100;
  int word_rate = 1000 / interval_ms;
  int duration_s = 1;
  int baud_rate = 115200;
  int print_status_enabled = 0;
  int pattern_override = 0;
  int end_time_s = 0;
  int temp_int = 0;
  int word_len = 26;
  float bandwidth = 0.0;
  char tx_word[42 + 1] = "";
  char tx_word_prev[42 + 1] = "";
  char rx_buff[50] = "";
  char rx_char = '\0';
  int rx_buff_i = 0;
  ssize_t rx_len = -1;
  int rx_status = 0;
  int tx_count = 0;
  int rx_count = 0;
  extern char *optarg;
  extern int optind;
  int opt_char;
  while ((opt_char = getopt(argc, argv, "hvT:N:b:p:d:")) != -1) {
    switch (opt_char) {
    case 'v':
      print_status_enabled = 1;
      break;
    case 'd':
      if (strlen(optarg) < 20 - 1) {
        strcpy(serial_dev, optarg);
      } else {
        printf("ERROR str too long: %s\n", optarg);
        exit(1);
      }
      break;
    case 'T':
      interval_ms = atoi(optarg);
      if ((interval_ms > 1000) || (interval_ms < 1)) {
        print_app_usage();
        exit(1);
      }
      break;
    case 'N':
      duration_s = atoi(optarg);
      break;
    case 'b':
      baud_rate = atoi(optarg);
      if ((baud_rate != 9600) && (baud_rate != 115200) &&
          (baud_rate != 230400)) {
        print_app_usage();
        exit(1);
      }
      break;
    case 'p':
      if ((strlen(optarg) <= 42 - 2) & (strlen(optarg) > 0)) {
        strcpy(tx_word, optarg);
        sprintf(tx_word, "%s\n", tx_word);
        pattern_override = 1;
        word_len = strlen(tx_word) + 1;
      } else {
        print_app_usage();
        exit(1);
      }
      break;
    case 'h':
      print_app_usage();
      exit(1);
      break;
    case '?':
    default:
      print_app_usage();
      printf("ERROR bad input %c\n", opt_char);
      exit(1);
      break;
    }
  }
  if (print_status_enabled)
    printf("Opening Port %s\n", serial_dev);
  int fd0 = open(serial_dev, O_RDWR);
  if (fd0 < 0) {
    printf("Error opening port, %d, %s\n", fd0, strerror(errno));
    exit(1);
  }
  switch (baud_rate) {
  case (9600):
    temp_int = B9600;
    break;
  case (115200):
    temp_int = B115200;
    break;
  case (230400):
    temp_int = B230400;
    break;
  default:
    printf("ERROR Baud rate");
    exit(1);
    break;
  }
  set_interface_attribs(fd0, temp_int, 0);
  tcflush(fd0, TCIOFLUSH);
  sleep(1);
  bandwidth =
      100.0 * (10.0 / 8.0 * word_len * 1000.0 / interval_ms) / baud_rate;
  if (print_status_enabled) {
    printf("Transmitting %.1f WPS at %d baud, %.1f %% BW\n",
           1000.0 / interval_ms, baud_rate, bandwidth);
    if (pattern_override != 0)
      printf("Pattern: %s", tx_word);
  }
  now_to_print = time(NULL);
  timeinfo = localtime(&now_to_print);
  strftime(time_buffer, 9, "%H:%M:%S", timeinfo);
  if (print_status_enabled)
    printf("Start %s, Duration %d s\n", time_buffer, duration_s);
  gettimeofday(&prev_send_time, NULL);
  gettimeofday(&now_time, NULL);
  while (now_time.tv_usec > 200) {
    gettimeofday(&now_time, NULL);
  }
  end_time_s = now_time.tv_sec + duration_s;
  while (now_time.tv_sec < end_time_s + 2) {
    if (send_lock == 0) {
      strcpy(tx_word_prev, tx_word);
      if (pattern_override == 0) {
        sprintf(tx_word, "#%02x,a0a0,a0a0,a0a0,a0a0,cc\n", send_counter);
      }
      write(fd0, tx_word, strlen(tx_word));
      send_lock = 1;
      send_counter = (send_counter + 1) % 100;
      tx_count++;
    }
    tdiff = (now_time.tv_sec - prev_send_time.tv_sec) * 1000000 +
            (now_time.tv_usec - prev_send_time.tv_usec);
    if ((tdiff > interval_ms * 1000) && (now_time.tv_sec < end_time_s)) {
      send_lock = 0;
      prev_send_time = now_time;
    }
    while (1) {
      if (rx_status != 0)
        break;
      rx_len = read(fd0, &rx_char, sizeof(char));
      if (rx_len == -1) {
        rx_status = -3;
        break;
      } else if (rx_len == 0)
        break;
      else if (rx_len > 0) {
        if (rx_char == tx_word[0])
          rx_buff_i = 0;
        rx_buff[rx_buff_i] = rx_char;
        if (rx_char == '\n') {
          rx_buff[rx_buff_i + 1] = '\0';
          rx_status = 1;
          if ((rx_count % word_rate == 0) && (print_status_enabled)) {
            printf(".");
            fflush(stdout);
          }
        }
        rx_buff_i++;
        if (rx_buff_i > 50 - 1) {
          rx_buff_i = 0;
          rx_status = -2;
        }
      }
    }
    if (rx_status == 1) {
      if (0 == strcmp(tx_word, rx_buff)) {
        rx_status = 0;
        rx_count++;
      } else if (0 == strcmp(tx_word_prev, rx_buff)) {
        rx_status = 0;
        rx_count++;
      } else {
        rx_status = -1;
      }
      rx_buff_i = 0;
    }
    if (rx_status < 0) {
      if (print_status_enabled) {
        printf("\nERROR Rx Detected, %d:%s!=%s\n", rx_status, tx_word, rx_buff);
        fflush(stdout);
      }
      rx_status = 0;
    }
    gettimeofday(&now_time, NULL);
    if ((now_time.tv_sec > end_time_s) && (rx_count == tx_count))
      break;
  }
  now_to_print = time(NULL);
  timeinfo = localtime(&now_to_print);
  strftime(time_buffer, 9, "%H:%M:%S", timeinfo);
  if (print_status_enabled)
    printf("\nEnd %s\n", time_buffer);
  if (tx_count != rx_count) {
    printf("Test FAILED, %s TX (%d) != RX (%d) words\n", serial_dev, tx_count,
           rx_count);
    exit(1);
  } else {
    printf("Test SUCCESS, %s RX = %d words, %d chars\n", serial_dev, rx_count,
           rx_count * strlen(tx_word));
  }
  close(fd0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x58(%rbp)
movl   $0x1,-0x5c(%rbp)
movl   $0x0,-0x60(%rbp)
mov    0xe5a(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xe57(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0xe55(%rip),%eax
mov    %eax,-0x70(%rbp)
movl   $0x64,-0x84(%rbp)
mov    $0x3e8,%eax
cltd
idivl  -0x84(%rbp)
mov    %eax,-0x88(%rbp)
movl   $0x1,-0x8c(%rbp)
movl   $0x1c200,-0x90(%rbp)
movl   $0x0,-0x94(%rbp)
movl   $0x0,-0x98(%rbp)
movl   $0x0,-0x9c(%rbp)
movl   $0x0,-0xa0(%rbp)
movl   $0x1a,-0xa4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xa8(%rbp)
ff
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0x2b,%edx
call   10b0 <memset@plt>
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x2b,%edx
call   10b0 <memset@plt>
lea    -0x150(%rbp),%rdi
xor    %esi,%esi
mov    $0x32,%edx
call   10b0 <memset@plt>
movb   $0x0,-0x151(%rbp)
movl   $0x0,-0x158(%rbp)
movl   $0xffffffff,-0x15c(%rbp)
ff ff ff
movl   $0x0,-0x160(%rbp)
movl   $0x0,-0x164(%rbp)
movl   $0x0,-0x168(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xd69(%rip),%rdx
call   1140 <getopt@plt>
mov    %eax,-0x16c(%rbp)
cmp    $0xffffffff,%eax
je     160e <main+0x39e>
mov    -0x16c(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x178(%rbp)
sub    $0x37,%eax
ja     15e4 <main+0x374>
mov    -0x178(%rbp),%rax
lea    0xc38(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x94(%rbp)
jmp    1609 <main+0x399>
mov    0x2bc9(%rip),%rax
mov    (%rax),%rdi
call   1060 <strlen@plt>
cmp    $0x13,%eax
jge    1430 <main+0x1c0>
lea    -0x80(%rbp),%rdi
mov    0x2bad(%rip),%rax
mov    (%rax),%rsi
call   1040 <strcpy@plt>
jmp    1452 <main+0x1e2>
mov    0x2b99(%rip),%rax
mov    (%rax),%rsi
lea    0xce0(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
jmp    1609 <main+0x399>
mov    0x2b72(%rip),%rax
mov    (%rax),%rdi
call   1150 <atoi@plt>
mov    %eax,-0x84(%rbp)
cmpl   $0x3e8,-0x84(%rbp)
jg     1489 <main+0x219>
cmpl   $0x1,-0x84(%rbp)
jge    149a <main+0x22a>
mov    $0x0,%al
call   1110 <print_app_usage@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
jmp    1609 <main+0x399>
mov    0x2b2a(%rip),%rax
mov    (%rax),%rdi
call   1150 <atoi@plt>
mov    %eax,-0x8c(%rbp)
jmp    1609 <main+0x399>
mov    0x2b10(%rip),%rax
mov    (%rax),%rdi
call   1150 <atoi@plt>
mov    %eax,-0x90(%rbp)
cmpl   $0x2580,-0x90(%rbp)
je     150f <main+0x29f>
cmpl   $0x1c200,-0x90(%rbp)
je     150f <main+0x29f>
cmpl   $0x38400,-0x90(%rbp)
je     150f <main+0x29f>
mov    $0x0,%al
call   1110 <print_app_usage@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
jmp    1609 <main+0x399>
mov    0x2ab5(%rip),%rax
mov    (%rax),%rdi
call   1060 <strlen@plt>
cmp    $0x28,%eax
setle  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x17c(%rbp)
mov    0x2a95(%rip),%rax
mov    (%rax),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x17c(%rbp),%eax
cmp    $0x0,%ecx
setg   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     15b8 <main+0x348>
lea    -0xe0(%rbp),%rdi
mov    0x2a60(%rip),%rax
mov    (%rax),%rsi
call   1040 <strcpy@plt>
lea    -0xe0(%rbp),%rdi
lea    -0xe0(%rbp),%rdx
lea    0xbe9(%rip),%rsi
mov    $0x0,%al
call   1160 <sprintf@plt>
movl   $0x1,-0x98(%rbp)
lea    -0xe0(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    15c9 <main+0x359>
mov    $0x0,%al
call   1110 <print_app_usage@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
jmp    1609 <main+0x399>
mov    $0x0,%al
call   1110 <print_app_usage@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
jmp    15e4 <main+0x374>
mov    $0x0,%al
call   1110 <print_app_usage@plt>
mov    -0x16c(%rbp),%esi
lea    0xb41(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
jmp    139d <main+0x12d>
cmpl   $0x0,-0x94(%rbp)
je     162d <main+0x3bd>
lea    -0x80(%rbp),%rsi
lea    0xb27(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    0x29b0(%rip),%rax
mov    (%rax),%esi
call   1130 <open@plt>
mov    %eax,-0x170(%rbp)
cmpl   $0x0,-0x170(%rbp)
jge    168d <main+0x41d>
mov    -0x170(%rbp),%eax
mov    %eax,-0x180(%rbp)
mov    0x2963(%rip),%rax
mov    (%rax),%edi
call   1180 <strerror@plt>
mov    -0x180(%rbp),%esi
mov    %rax,%rdx
lea    0xae2(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    -0x90(%rbp),%eax
mov    %eax,-0x184(%rbp)
sub    $0x2580,%eax
je     16d5 <main+0x465>
jmp    16a9 <main+0x439>
mov    -0x184(%rbp),%eax
sub    $0x1c200,%eax
je     16e9 <main+0x479>
jmp    16bf <main+0x44f>
mov    -0x184(%rbp),%eax
sub    $0x38400,%eax
je     16fd <main+0x48d>
jmp    1711 <main+0x4a1>
mov    0x2904(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa0(%rbp)
jmp    1729 <main+0x4b9>
mov    0x28c0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa0(%rbp)
jmp    1729 <main+0x4b9>
mov    0x289c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa0(%rbp)
jmp    1729 <main+0x4b9>
lea    0xa62(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    -0x170(%rbp),%edi
mov    -0xa0(%rbp),%esi
xor    %edx,%edx
call   1070 <set_interface_attribs@plt>
mov    -0x170(%rbp),%edi
mov    0x2877(%rip),%rax
mov    (%rax),%esi
call   1080 <tcflush@plt>
mov    $0x1,%edi
call   1190 <sleep@plt>
cvtsi2sdl -0xa4(%rbp),%xmm0
ff
movsd  0x8a6(%rip),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x892(%rip),%xmm0
mulsd  %xmm0,%xmm1
cvtsi2sdl -0x84(%rbp),%xmm0
ff
divsd  %xmm0,%xmm1
movsd  0x872(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x90(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xa8(%rbp)
ff
cmpl   $0x0,-0x94(%rbp)
je     1812 <main+0x5a2>
cvtsi2sdl -0x84(%rbp),%xmm1
ff
movsd  0x841(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0x90(%rbp),%esi
movss  -0xa8(%rbp),%xmm1
ff
cvtss2sd %xmm1,%xmm1
lea    0x9a6(%rip),%rdi
mov    $0x2,%al
call   1090 <printf@plt>
cmpl   $0x0,-0x98(%rbp)
je     180d <main+0x59d>
lea    -0xe0(%rbp),%rsi
lea    0x9b2(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
jmp    1812 <main+0x5a2>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <time@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x2c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x28(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x9,%esi
lea    0x985(%rip),%rdx
call   1120 <strftime@plt>
cmpl   $0x0,-0x94(%rbp)
je     1869 <main+0x5f9>
lea    -0x50(%rbp),%rsi
mov    -0x8c(%rbp),%edx
lea    0x96b(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <gettimeofday@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <gettimeofday@plt>
cmpl   $0xc8,-0x18(%rbp)
jle    18a2 <main+0x632>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <gettimeofday@plt>
jmp    1883 <main+0x613>
mov    -0x14(%rbp),%eax
add    -0x8c(%rbp),%eax
mov    %eax,-0x9c(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x9c(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    1c42 <main+0x9d2>
cmpl   $0x0,-0x5c(%rbp)
jne    1968 <main+0x6f8>
lea    -0x110(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1040 <strcpy@plt>
cmpl   $0x0,-0x98(%rbp)
jne    1907 <main+0x697>
lea    -0xe0(%rbp),%rdi
mov    -0x60(%rbp),%edx
lea    0x8e6(%rip),%rsi
mov    $0x0,%al
call   1160 <sprintf@plt>
mov    -0x170(%rbp),%eax
mov    %eax,-0x194(%rbp)
lea    -0xe0(%rbp),%rax
mov    %rax,-0x190(%rbp)
lea    -0xe0(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x194(%rbp),%edi
mov    -0x190(%rbp),%rsi
mov    %eax,%edx
call   1050 <write@plt>
movl   $0x1,-0x5c(%rbp)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x60(%rbp)
mov    -0x164(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x164(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x1c(%rbp),%eax
imul   $0xf4240,%eax,%eax
mov    -0x18(%rbp),%ecx
sub    -0x20(%rbp),%ecx
add    %ecx,%eax
cltq
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
imul   $0x3e8,-0x84(%rbp),%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jle    19ba <main+0x74a>
mov    -0x14(%rbp),%eax
cmp    -0x9c(%rbp),%eax
jge    19ba <main+0x74a>
movl   $0x0,-0x5c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    19bf <main+0x74f>
cmpl   $0x0,-0x160(%rbp)
je     19d1 <main+0x761>
jmp    1b12 <main+0x8a2>
mov    -0x170(%rbp),%edi
lea    -0x151(%rbp),%rsi
mov    $0x1,%edx
call   10d0 <read@plt>
mov    %eax,-0x15c(%rbp)
cmpl   $0xffffffff,-0x15c(%rbp)
jne    1a0a <main+0x79a>
movl   $0xfffffffd,-0x160(%rbp)
ff ff ff
jmp    1b12 <main+0x8a2>
cmpl   $0x0,-0x15c(%rbp)
jne    1a1c <main+0x7ac>
jmp    1b12 <main+0x8a2>
cmpl   $0x0,-0x15c(%rbp)
jle    1b03 <main+0x893>
movsbl -0x151(%rbp),%eax
movsbl -0xe0(%rbp),%ecx
cmp    %ecx,%eax
jne    1a49 <main+0x7d9>
movl   $0x0,-0x158(%rbp)
mov    -0x151(%rbp),%cl
movslq -0x158(%rbp),%rax
mov    %cl,-0x150(%rbp,%rax,1)
movsbl -0x151(%rbp),%eax
cmp    $0xa,%eax
jne    1ace <main+0x85e>
mov    -0x158(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,-0x150(%rbp,%rax,1)
movl   $0x1,-0x160(%rbp)
mov    -0x168(%rbp),%eax
cltd
idivl  -0x88(%rbp)
cmp    $0x0,%edx
jne    1ac9 <main+0x859>
cmpl   $0x0,-0x94(%rbp)
je     1ac9 <main+0x859>
lea    0x750(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    0x24f6(%rip),%rax
mov    (%rax),%edi
call   1100 <fflush@plt>
jmp    1ace <main+0x85e>
mov    -0x158(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x158(%rbp)
cmpl   $0x31,-0x158(%rbp)
jle    1afe <main+0x88e>
movl   $0x0,-0x158(%rbp)
movl   $0xfffffffe,-0x160(%rbp)
ff ff ff
jmp    1b03 <main+0x893>
jmp    1b08 <main+0x898>
jmp    1b0d <main+0x89d>
jmp    19bf <main+0x74f>
cmpl   $0x1,-0x160(%rbp)
jne    1bb6 <main+0x946>
lea    -0xe0(%rbp),%rdi
lea    -0x150(%rbp),%rsi
call   10e0 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1b5e <main+0x8ee>
movl   $0x0,-0x160(%rbp)
mov    -0x168(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x168(%rbp)
jmp    1bac <main+0x93c>
lea    -0x110(%rbp),%rdi
lea    -0x150(%rbp),%rsi
call   10e0 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1b9d <main+0x92d>
movl   $0x0,-0x160(%rbp)
mov    -0x168(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x168(%rbp)
jmp    1ba7 <main+0x937>
movl   $0xffffffff,-0x160(%rbp)
ff ff ff
jmp    1bac <main+0x93c>
movl   $0x0,-0x158(%rbp)
cmpl   $0x0,-0x160(%rbp)
jge    1c0a <main+0x99a>
cmpl   $0x0,-0x94(%rbp)
je     1c00 <main+0x990>
mov    -0x160(%rbp),%esi
lea    -0xe0(%rbp),%rdx
lea    -0x150(%rbp),%rcx
lea    0x61b(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    0x23bf(%rip),%rax
mov    (%rax),%edi
call   1100 <fflush@plt>
movl   $0x0,-0x160(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <gettimeofday@plt>
mov    -0x14(%rbp),%eax
cmp    -0x9c(%rbp),%eax
jle    1c3d <main+0x9cd>
mov    -0x168(%rbp),%eax
cmp    -0x164(%rbp),%eax
jne    1c3d <main+0x9cd>
jmp    1c42 <main+0x9d2>
jmp    18b1 <main+0x641>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <time@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x2c(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x28(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x9,%esi
lea    0x555(%rip),%rdx
call   1120 <strftime@plt>
cmpl   $0x0,-0x94(%rbp)
je     1c93 <main+0xa23>
lea    -0x50(%rbp),%rsi
lea    0x599(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x164(%rbp),%eax
cmp    -0x168(%rbp),%eax
je     1ccd <main+0xa5d>
lea    -0x80(%rbp),%rsi
mov    -0x164(%rbp),%edx
mov    -0x168(%rbp),%ecx
lea    0x572(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0x1a0(%rbp)
mov    -0x168(%rbp),%eax
mov    %eax,-0x198(%rbp)
mov    -0x168(%rbp),%eax
mov    %eax,-0x1a4(%rbp)
lea    -0xe0(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x1a4(%rbp),%ecx
mov    -0x1a0(%rbp),%rsi
mov    -0x198(%rbp),%edx
imul   %eax,%ecx
lea    0x53f(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    -0x170(%rbp),%edi
call   10c0 <close@plt>
xor    %eax,%eax
add    $0x1b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x148,%rsp
mov    %rsi,%rbx
mov    %edi,%r13d
movapd 0xe41(%rip),%xmm0
movapd %xmm0,0x60(%rsp)
movl   $0x0,0x70(%rsp)
xorpd  %xmm0,%xmm0
movupd %xmm0,0x9b(%rsp)
movapd %xmm0,0x90(%rsp)
movapd %xmm0,0x80(%rsp)
movupd %xmm0,0x12b(%rsp)
movapd %xmm0,0x120(%rsp)
movapd %xmm0,0x110(%rsp)
movapd %xmm0,0xd0(%rsp)
movapd %xmm0,0xc0(%rsp)
movapd %xmm0,0xb0(%rsp)
movw   $0x0,0xe0(%rsp)
movb   $0x0,0xb(%rsp)
mov    $0x1a,%ebp
movl   $0x1c200,0xc(%rsp)
mov    $0x1,%eax
mov    %rax,0x18(%rsp)
movl   $0x64,0x24(%rsp)
lea    0xcf9(%rip),%r14
xor    %edx,%edx
movl   $0x0,0x3c(%rsp)
mov    %rsi,0x28(%rsp)
jmp    1350 <main+0xe0>
mov    0x2c91(%rip),%rax
mov    (%rax),%rdi
call   1150 <atoi@plt>
mov    %rax,0x18(%rsp)
mov    %r15d,%edx
nop
mov    %edx,%r15d
mov    %r13d,%edi
mov    %rbx,%rsi
lea    0xd84(%rip),%rdx
call   1140 <getopt@plt>
mov    %eax,%r12d
lea    -0x4e(%r12),%eax
cmp    $0x28,%eax
ja     149a <main+0x22a>
movslq (%r14,%rax,4),%rcx
add    %r14,%rcx
mov    $0x1,%edx
jmp    *%rcx
mov    0x2c45(%rip),%rax
mov    (%rax),%rdi
call   1150 <atoi@plt>
mov    %eax,0x24(%rsp)
mov    %eax,%ecx
add    $0xfffffc17,%ecx
mov    %r15d,%edx
cmp    $0xfffffc17,%ecx
ja     1350 <main+0xe0>
jmp    1a2d <main+0x7bd>
mov    0x2c1a(%rip),%rbp
mov    0x0(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%ebx
mov    0x0(%rbp),%rdi
call   1070 <strlen@plt>
cmp    $0x28,%ebx
jg     1a2d <main+0x7bd>
test   %eax,%eax
jle    1a2d <main+0x7bd>
mov    0x2bee(%rip),%rax
mov    (%rax),%rsi
lea    0x80(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strcpy@plt>
mov    %rbx,%rdi
lea    0xd47(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1160 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %eax,%ebp
add    $0x1,%ebp
movl   $0x1,0x3c(%rsp)
jmp    148d <main+0x21d>
mov    0x2ba9(%rip),%rax
mov    (%rax),%rdi
call   1150 <atoi@plt>
mov    %r15d,%edx
mov    %eax,0xc(%rsp)
cmp    $0x2580,%eax
je     1350 <main+0xe0>
mov    %r15d,%edx
cmpl   $0x1c200,0xc(%rsp)
je     1350 <main+0xe0>
mov    %r15d,%edx
cmpl   $0x38400,0xc(%rsp)
je     1350 <main+0xe0>
jmp    1a2d <main+0x7bd>
mov    0x2b61(%rip),%rbx
mov    (%rbx),%rdi
call   1070 <strlen@plt>
mov    (%rbx),%rsi
cmp    $0x12,%eax
jg     1a60 <main+0x7f0>
lea    0x60(%rsp),%rdi
call   1050 <strcpy@plt>
mov    %r15d,%edx
mov    0x28(%rsp),%rbx
jmp    1350 <main+0xe0>
cmp    $0xffffffff,%r12d
jne    1a3e <main+0x7ce>
mov    %ebp,%ebx
test   %r15d,%r15d
je     14be <main+0x24e>
lea    0xc6b(%rip),%rdi
lea    0x60(%rsp),%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    0x2b23(%rip),%rax
mov    (%rax),%esi
lea    0x60(%rsp),%rdi
call   1130 <open@plt>
mov    %eax,%r12d
test   %eax,%eax
mov    0x18(%rsp),%r13
mov    0x24(%rsp),%r14d
mov    0xc(%rsp),%ebp
js     1a78 <main+0x808>
cmp    $0x2580,%ebp
je     150f <main+0x29f>
cmp    $0x38400,%ebp
je     1518 <main+0x2a8>
cmp    $0x1c200,%ebp
jne    1ac6 <main+0x856>
mov    0x2aa3(%rip),%rax
jmp    151f <main+0x2af>
mov    0x2aca(%rip),%rax
jmp    151f <main+0x2af>
mov    0x2a81(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
xor    %edx,%edx
call   1080 <set_interface_attribs@plt>
mov    0x2a8e(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
call   1090 <tcflush@plt>
mov    $0x1,%edi
call   1190 <sleep@plt>
test   %r15d,%r15d
je     1606 <main+0x396>
cvtsi2sd %r14d,%xmm1
cvtsi2sd %ebx,%xmm2
mulsd  0xaa0(%rip),%xmm2
movsd  0xaa0(%rip),%xmm0
mulsd  %xmm0,%xmm2
divsd  %xmm1,%xmm2
mulsd  0xa98(%rip),%xmm2
cvtsi2sd %ebp,%xmm3
divsd  %xmm3,%xmm2
cvtsd2ss %xmm2,%xmm2
divsd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
lea    0xbc4(%rip),%rdi
mov    %ebp,%esi
mov    $0x2,%al
call   10a0 <printf@plt>
cmpl   $0x0,0x3c(%rsp)
je     15bc <main+0x34c>
lea    0xbdb(%rip),%rdi
lea    0x80(%rsp),%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
xor    %edi,%edi
call   10f0 <time@plt>
mov    %eax,0x14(%rsp)
lea    0x14(%rsp),%rdi
call   1040 <localtime@plt>
lea    0xbbc(%rip),%rdx
lea    0xf0(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x9,%esi
mov    %rax,%rcx
call   1120 <strftime@plt>
lea    0xba6(%rip),%rdi
mov    %rbx,%rsi
mov    %r13d,%edx
xor    %eax,%eax
call   10a0 <printf@plt>
jmp    1637 <main+0x3c7>
xor    %edi,%edi
call   10f0 <time@plt>
mov    %eax,0x14(%rsp)
lea    0x14(%rsp),%rdi
call   1040 <localtime@plt>
lea    0xb72(%rip),%rdx
lea    0xf0(%rsp),%rdi
mov    $0x9,%esi
mov    %rax,%rcx
call   1120 <strftime@plt>
mov    %r12d,0x40(%rsp)
lea    0x50(%rsp),%rdi
xor    %esi,%esi
call   10b0 <gettimeofday@plt>
lea    0x30(%rsp),%rdi
xor    %esi,%esi
call   10b0 <gettimeofday@plt>
cmpl   $0xc9,0x30(%rsp)
jl     1684 <main+0x414>
lea    0x30(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
xor    %esi,%esi
call   10b0 <gettimeofday@plt>
cmpl   $0xc8,0x30(%rsp)
jg     1670 <main+0x400>
test   %r15d,%r15d
sete   0x13(%rsp)
mov    0x34(%rsp),%r12d
lea    (%r12,%r13,1),%eax
mov    %eax,0x44(%rsp)
lea    (%r12,%r13,1),%eax
add    $0x2,%eax
mov    %eax,0x5c(%rsp)
imul   $0x3e8,%r14d,%eax
mov    %eax,0x24(%rsp)
movl   $0x1,0xc(%rsp)
xor    %eax,%eax
mov    %rax,0x48(%rsp)
movl   $0x0,0x18(%rsp)
xor    %r14d,%r14d
movl   $0x0,0x38(%rsp)
movl   $0x0,0x28(%rsp)
nopl   0x0(%rax)
cmp    0x5c(%rsp),%r12d
mov    0x40(%rsp),%r13d
jge    198b <main+0x71b>
cmpl   $0x0,0xc(%rsp)
je     1710 <main+0x4a0>
lea    0x80(%rsp),%rbp
jmp    1788 <main+0x518>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x110(%rsp),%rdi
lea    0x80(%rsp),%rbp
mov    %rbp,%rsi
call   1050 <strcpy@plt>
cmpl   $0x0,0x3c(%rsp)
jne    1745 <main+0x4d5>
mov    %rbp,%rdi
lea    0xa7d(%rip),%rsi
mov    0x48(%rsp),%rdx
xor    %eax,%eax
call   1160 <sprintf@plt>
mov    %rbp,%rdi
call   1070 <strlen@plt>
mov    %r13d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1060 <write@plt>
mov    0x48(%rsp),%rdx
add    $0x1,%edx
movslq %edx,%rdx
imul   $0x51eb851f,%rdx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%edx
mov    %rdx,0x48(%rsp)
addl   $0x1,0x38(%rsp)
lea    0xb(%rsp),%rbx
mov    %r12d,%eax
sub    0x54(%rsp),%eax
mov    0x30(%rsp),%ecx
sub    0x50(%rsp),%ecx
imul   $0xf4240,%eax,%eax
add    %eax,%ecx
mov    $0x1,%eax
cmp    0x24(%rsp),%ecx
jle    17c2 <main+0x552>
cmp    0x44(%rsp),%r12d
jge    17c2 <main+0x552>
mov    0x30(%rsp),%rax
mov    %rax,0x50(%rsp)
xor    %eax,%eax
mov    %eax,0xc(%rsp)
test   %r15d,%r15d
setne  %al
imul   $0xcccccccd,0x28(%rsp),%ecx
cc
add    $0x19999998,%ecx
ror    %ecx
cmp    $0x19999999,%ecx
setb   %r12b
and    %al,%r12b
nopl   0x0(%rax)
test   %r14d,%r14d
jne    18b0 <main+0x640>
mov    %r13d,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   10d0 <read@plt>
cmp    $0xffffffff,%eax
je     1900 <main+0x690>
test   %eax,%eax
je     191b <main+0x6ab>
xor    %r14d,%r14d
test   %eax,%eax
jle    17f0 <main+0x580>
movzbl 0xb(%rsp),%eax
xor    %r14d,%r14d
cmp    0x80(%rsp),%al
mov    0x18(%rsp),%ecx
cmove  %r14d,%ecx
mov    %ecx,0x18(%rsp)
movslq %ecx,%rbp
mov    %al,0xb0(%rsp,%rbp,1)
add    $0x1,%rbp
cmp    $0xa,%al
jne    1879 <main+0x609>
movb   $0x0,0xb0(%rsp,%rbp,1)
mov    $0x1,%r14d
test   %r12b,%r12b
je     1879 <main+0x609>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    0x2746(%rip),%rax
mov    (%rax),%edi
call   1100 <fflush@plt>
cmpl   $0x31,0x18(%rsp)
mov    $0x0,%eax
cmovge %eax,%ebp
mov    $0xfffffffe,%eax
cmovge %eax,%r14d
mov    %ebp,%eax
mov    %ebp,0x18(%rsp)
lea    0x80(%rsp),%rbp
jmp    17f0 <main+0x580>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x1,%r14d
jne    1906 <main+0x696>
mov    %rbp,%rdi
lea    0xb0(%rsp),%rbx
mov    %rbx,%rsi
call   10e0 <strcmp@plt>
test   %rax,%rax
je     194c <main+0x6dc>
lea    0x110(%rsp),%rdi
mov    %rbx,%rsi
call   10e0 <strcmp@plt>
xor    %ecx,%ecx
xor    %r14d,%r14d
test   %rax,%rax
sete   %cl
setne  %r14b
neg    %r14d
add    %ecx,0x28(%rsp)
movl   $0x0,0x18(%rsp)
jmp    1906 <main+0x696>
xchg   %ax,%ax
mov    $0xfffffffd,%r14d
test   %r14d,%r14d
setns  %cl
mov    $0x0,%eax
cmovns %r14d,%eax
or     0x13(%rsp),%cl
je     1920 <main+0x6b0>
mov    %eax,%r14d
jmp    195c <main+0x6ec>
lea    0x8ad(%rip),%rdi
mov    %r14d,%esi
mov    %rbp,%rdx
lea    0xb0(%rsp),%rcx
xor    %eax,%eax
call   10a0 <printf@plt>
mov    0x2675(%rip),%rax
mov    (%rax),%edi
call   1100 <fflush@plt>
jmp    1959 <main+0x6e9>
addl   $0x1,0x28(%rsp)
movl   $0x0,0x18(%rsp)
xor    %r14d,%r14d
lea    0x30(%rsp),%rdi
xor    %esi,%esi
call   10b0 <gettimeofday@plt>
mov    0x34(%rsp),%r12d
cmp    0x44(%rsp),%r12d
jle    16e0 <main+0x470>
mov    0x38(%rsp),%eax
mov    %eax,%r13d
cmp    %eax,0x28(%rsp)
jne    16e0 <main+0x470>
jmp    1990 <main+0x720>
mov    0x28(%rsp),%r13d
xor    %edi,%edi
call   10f0 <time@plt>
mov    %eax,0x14(%rsp)
lea    0x14(%rsp),%rdi
call   1040 <localtime@plt>
lea    0x7e8(%rip),%rdx
lea    0xf0(%rsp),%rdi
mov    $0x9,%esi
mov    %rax,%rcx
call   1120 <strftime@plt>
test   %r15d,%r15d
je     19dc <main+0x76c>
lea    0x826(%rip),%rdi
lea    0xf0(%rsp),%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    0x38(%rsp),%ebx
cmp    %r13d,%ebx
jne    1aa4 <main+0x834>
lea    0x80(%rsp),%rdi
call   1070 <strlen@plt>
imul   %ebx,%eax
lea    0x826(%rip),%rdi
lea    0x60(%rsp),%rsi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   10a0 <printf@plt>
mov    0x40(%rsp),%edi
call   10c0 <close@plt>
xor    %eax,%eax
add    $0x148,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1110 <print_app_usage@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
xor    %eax,%eax
call   1110 <print_app_usage@plt>
lea    0x6bd(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
lea    0x68a(%rip),%rdi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
mov    0x2549(%rip),%rax
mov    (%rax),%edi
call   1180 <strerror@plt>
lea    0x6a1(%rip),%rdi
mov    %r12d,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   10a0 <printf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
lea    0x751(%rip),%rdi
lea    0x60(%rsp),%rsi
mov    %ebx,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   10a0 <printf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>
lea    0x67d(%rip),%rdi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    $0x1,%edi
call   1170 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
%struct.tm = type { i32 }
@__const.main.serial_dev = [20 x i8] c"/dev/ttyS0\00\00\00\00\00\00\00\00\00\00"
@.str = [13 x i8] c"hvT:N:b:p:d:\00"
@optarg = external global i8*
@.str.1 = [24 x i8] c"ERROR str too long: %s\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [20 x i8] c"ERROR bad input %c\0A\00"
@.str.4 = [17 x i8] c"Opening Port %s\0A\00"
@O_RDWR = global i32 0
@.str.5 = [28 x i8] c"Error opening port, %d, %s\0A\00"
@errno = global i32 0
@B9600 = global i32 0
@B115200 = global i32 0
@B230400 = global i32 0
@.str.6 = [16 x i8] c"ERROR Baud rate\00"
@TCIOFLUSH = global i32 0
@.str.7 = [46 x i8] c"Transmitting %.1f WPS at %d baud, %.1f %% BW\0A\00"
@.str.8 = [12 x i8] c"Pattern: %s\00"
@.str.9 = [9 x i8] c"%H:%M:%S\00"
@.str.10 = [25 x i8] c"Start %s, Duration %d s\0A\00"
@.str.11 = [30 x i8] c"#%02x,a0a0,a0a0,a0a0,a0a0,cc\0A\00"
@.str.12 = [2 x i8] c".\00"
@stdout = global i32 0
@.str.13 = [31 x i8] c"\0AERROR Rx Detected, %d:%s!=%s\0A\00"
@.str.14 = [9 x i8] c"\0AEnd %s\0A\00"
@.str.15 = [42 x i8] c"Test FAILED, %s TX (%d) != RX (%d) words\0A\00"
@.str.16 = [42 x i8] c"Test SUCCESS, %s RX = %d words, %d chars\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = alloca %struct.tm*
%9 = alloca i32
%10 = alloca [30 x i8]
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
%14 = alloca [20 x i8]
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca float
%25 = alloca [43 x i8]
%26 = alloca [43 x i8]
%27 = alloca [50 x i8]
%28 = alloca i8
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
%33 = alloca i32
%34 = alloca i32
%35 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %11
store i32 1, i32* %12
store i32 0, i32* %13
%36 = bitcast [20 x i8]* %14 to i8*
store i32 100, i32* %15
%37 = load i32, i32* %15
%38 = sdiv i32 1000, %37
store i32 %38, i32* %16
store i32 1, i32* %17
store i32 115200, i32* %18
store i32 0, i32* %19
store i32 0, i32* %20
store i32 0, i32* %21
store i32 0, i32* %22
store i32 26, i32* %23
store float 0.000000e+00, float* %24
%39 = bitcast [43 x i8]* %25 to i8*
%40 = bitcast [43 x i8]* %26 to i8*
%41 = bitcast [50 x i8]* %27 to i8*
store i8 0, i8* %28
store i32 0, i32* %29
store i32 -1, i32* %30
store i32 0, i32* %31
store i32 0, i32* %32
store i32 0, i32* %33
br label %42
42: ; preds = %127, %2
%43 = load i32, i32* %4
%44 = load i8**, i8*** %5
%45 = call i32 @getopt(i32 %43, i8** %44, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 %45, i32* %34
%46 = icmp ne i32 %45, -1
br i1 %46, label %47, label %128
47: ; preds = %42
%48 = load i32, i32* %34
switch i32 %48, label %122 [
i32 118, label %49
i32 100, label %50
i32 84, label %63
i32 78, label %75
i32 98, label %78
i32 112, label %93
i32 104, label %118
i32 63, label %121
]
49: ; preds = %47
store i32 1, i32* %19
br label %127
50: ; preds = %47
%51 = load i8*, i8** @optarg
%52 = call i32 @strlen(i8* %51)
%53 = icmp slt i32 %52, 19
br i1 %53, label %54, label %58
54: ; preds = %50
%55 = getelementptr inbounds [20 x i8], [20 x i8]* %14, i64 0, i64 0
%56 = load i8*, i8** @optarg
%57 = call i32 @strcpy(i8* %55, i8* %56)
br label %62
58: ; preds = %50
%59 = load i8*, i8** @optarg
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %59)
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %54
br label %127
63: ; preds = %47
%64 = load i8*, i8** @optarg
%65 = call i32 @atoi(i8* %64)
store i32 %65, i32* %15
%66 = load i32, i32* %15
%67 = icmp sgt i32 %66, 1000
br i1 %67, label %71, label %68
68: ; preds = %63
%69 = load i32, i32* %15
%70 = icmp slt i32 %69, 1
br i1 %70, label %71, label %74
71: ; preds = %68, %63
%72 = call i32 (...) @print_app_usage()
%73 = call i32 @exit(i32 1)
unreachable
74: ; preds = %68
br label %127
75: ; preds = %47
%76 = load i8*, i8** @optarg
%77 = call i32 @atoi(i8* %76)
store i32 %77, i32* %17
br label %127
78: ; preds = %47
%79 = load i8*, i8** @optarg
%80 = call i32 @atoi(i8* %79)
store i32 %80, i32* %18
%81 = load i32, i32* %18
%82 = icmp ne i32 %81, 9600
br i1 %82, label %83, label %92
83: ; preds = %78
%84 = load i32, i32* %18
%85 = icmp ne i32 %84, 115200
br i1 %85, label %86, label %92
86: ; preds = %83
%87 = load i32, i32* %18
%88 = icmp ne i32 %87, 230400
br i1 %88, label %89, label %92
89: ; preds = %86
%90 = call i32 (...) @print_app_usage()
%91 = call i32 @exit(i32 1)
unreachable
92: ; preds = %86, %83, %78
br label %127
93: ; preds = %47
%94 = load i8*, i8** @optarg
%95 = call i32 @strlen(i8* %94)
%96 = icmp sle i32 %95, 40
%97 = zext i1 %96 to i32
%98 = load i8*, i8** @optarg
%99 = call i32 @strlen(i8* %98)
%100 = icmp sgt i32 %99, 0
%101 = zext i1 %100 to i32
%102 = and i32 %97, %101
%103 = icmp ne i32 %102, 0
br i1 %103, label %104, label %114
104: ; preds = %93
%105 = getelementptr inbounds [43 x i8], [43 x i8]* %25, i64 0, i64 0
%106 = load i8*, i8** @optarg
%107 = call i32 @strcpy(i8* %105, i8* %106)
%108 = getelementptr inbounds [43 x i8], [43 x i8]* %25, i64 0, i64 0
%109 = getelementptr inbounds [43 x i8], [43 x i8]* %25, i64 0, i64 0
%110 = call i32 (i8*, i8*, ...) @sprintf(i8* %108, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %109)
store i32 1, i32* %20
%111 = getelementptr inbounds [43 x i8], [43 x i8]* %25, i64 0, i64 0
%112 = call i32 @strlen(i8* %111)
%113 = add nsw i32 %112, 1
store i32 %113, i32* %23
br label %117
114: ; preds = %93
%115 = call i32 (...) @print_app_usage()
%116 = call i32 @exit(i32 1)
unreachable
117: ; preds = %104
br label %127
118: ; preds = %47
%119 = call i32 (...) @print_app_usage()
%120 = call i32 @exit(i32 1)
unreachable
121: ; preds = %47
br label %122
122: ; preds = %47, %121
%123 = call i32 (...) @print_app_usage()
%124 = load i32, i32* %34
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %124)
%126 = call i32 @exit(i32 1)
unreachable
127: ; preds = %117, %92, %75, %74, %62, %49
br label %42
128: ; preds = %42
%129 = load i32, i32* %19
%130 = icmp ne i32 %129, 0
br i1 %130, label %131, label %134
131: ; preds = %128
%132 = getelementptr inbounds [20 x i8], [20 x i8]* %14, i64 0, i64 0
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %132)
br label %134
134: ; preds = %131, %128
%135 = getelementptr inbounds [20 x i8], [20 x i8]* %14, i64 0, i64 0
%136 = load i32, i32* @O_RDWR
%137 = call i32 @open(i8* %135, i32 %136)
store i32 %137, i32* %35
%138 = load i32, i32* %35
%139 = icmp slt i32 %138, 0
br i1 %139, label %140, label %146
140: ; preds = %134
%141 = load i32, i32* %35
%142 = load i32, i32* @errno
%143 = call i8* @strerror(i32 %142)
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %141, i8* %143)
%145 = call i32 @exit(i32 1)
unreachable
146: ; preds = %134
%147 = load i32, i32* %18
switch i32 %147, label %154 [
i32 9600, label %148
i32 115200, label %150
i32 230400, label %152
]
148: ; preds = %146
%149 = load i32, i32* @B9600
store i32 %149, i32* %22
br label %157
150: ; preds = %146
%151 = load i32, i32* @B115200
store i32 %151, i32* %22
br label %157
152: ; preds = %146
%153 = load i32, i32* @B230400
store i32 %153, i32* %22
br label %157
154: ; preds = %146
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%156 = call i32 @exit(i32 1)
unreachable
157: ; preds = %152, %150, %148
%158 = load i32, i32* %35
%159 = load i32, i32* %22
%160 = call i32 @set_interface_attribs(i32 %158, i32 %159, i32 0)
%161 = load i32, i32* %35
%162 = load i32, i32* @TCIOFLUSH
%163 = call i32 @tcflush(i32 %161, i32 %162)
%164 = call i32 @sleep(i32 1)
%165 = load i32, i32* %23
%166 = sitofp i32 %165 to double
%167 = fmul double 1.250000e+00, %166
%168 = fmul double %167, 1.000000e+03
%169 = load i32, i32* %15
%170 = sitofp i32 %169 to double
%171 = fdiv double %168, %170
%172 = fmul double 1.000000e+02, %171
%173 = load i32, i32* %18
%174 = sitofp i32 %173 to double
%175 = fdiv double %172, %174
%176 = fptrunc double %175 to float
store float %176, float* %24
%177 = load i32, i32* %19
%178 = icmp ne i32 %177, 0
br i1 %178, label %179, label %193
179: ; preds = %157
%180 = load i32, i32* %15
%181 = sitofp i32 %180 to double
%182 = fdiv double 1.000000e+03, %181
%183 = load i32, i32* %18
%184 = load float, float* %24
%185 = fpext float %184 to double
%186 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), double %182, i32 %183, double %185)
%187 = load i32, i32* %20
%188 = icmp ne i32 %187, 0
br i1 %188, label %189, label %192
189: ; preds = %179
%190 = getelementptr inbounds [43 x i8], [43 x i8]* %25, i64 0, i64 0
%191 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %190)
br label %192
192: ; preds = %189, %179
br label %193
193: ; preds = %192, %157
%194 = call i32 @time(i32* null)
store i32 %194, i32* %9
%195 = call %struct.tm* @localtime(i32* %9)
store %struct.tm* %195, %struct.tm** %8
%196 = getelementptr inbounds [30 x i8], [30 x i8]* %10, i64 0, i64 0
%197 = load %struct.tm*, %struct.tm** %8
%198 = call i32 @strftime(i8* %196, i32 9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), %struct.tm* %197)
%199 = load i32, i32* %19
%200 = icmp ne i32 %199, 0
br i1 %200, label %201, label %205
201: ; preds = %193
%202 = getelementptr inbounds [30 x i8], [30 x i8]* %10, i64 0, i64 0
%203 = load i32, i32* %17
%204 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i8* %202, i32 %203)
br label %205
205: ; preds = %201, %193
%206 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%207 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
br label %208
208: ; preds = %212, %205
%209 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%210 = load i32, i32* %209
%211 = icmp sgt i32 %210, 200
br i1 %211, label %212, label %214
212: ; preds = %208
%213 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
br label %208
214: ; preds = %208
%215 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%216 = load i32, i32* %215
%217 = load i32, i32* %17
%218 = add nsw i32 %216, %217
store i32 %218, i32* %21
br label %219
219: ; preds = %384, %214
%220 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%221 = load i32, i32* %220
%222 = load i32, i32* %21
%223 = add nsw i32 %222, 2
%224 = icmp slt i32 %221, %223
br i1 %224, label %225, label %385
225: ; preds = %219
%226 = load i32, i32* %12
%227 = icmp eq i32 %226, 0
br i1 %227, label %228, label %249
228: ; preds = %225
%229 = getelementptr inbounds [43 x i8], [43 x i8]* %26, i64 0, i64 0
%230 = getelementptr inbounds [43 x i8], [43 x i8]* %25, i64 0, i64 0
%231 = call i32 @strcpy(i8* %229, i8* %230)
%232 = load i32, i32* %20
%233 = icmp eq i32 %232, 0
br i1 %233, label %234, label %238
234: ; preds = %228
%235 = getelementptr inbounds [43 x i8], [43 x i8]* %25, i64 0, i64 0
%236 = load i32, i32* %13
%237 = call i32 (i8*, i8*, ...) @sprintf(i8* %235, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i32 %236)
br label %238
238: ; preds = %234, %228
%239 = load i32, i32* %35
%240 = getelementptr inbounds [43 x i8], [43 x i8]* %25, i64 0, i64 0
%241 = getelementptr inbounds [43 x i8], [43 x i8]* %25, i64 0, i64 0
%242 = call i32 @strlen(i8* %241)
%243 = call i32 @write(i32 %239, i8* %240, i32 %242)
store i32 1, i32* %12
%244 = load i32, i32* %13
%245 = add nsw i32 %244, 1
%246 = srem i32 %245, 100
store i32 %246, i32* %13
%247 = load i32, i32* %32
%248 = add nsw i32 %247, 1
store i32 %248, i32* %32
br label %249
249: ; preds = %238, %225
%250 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%251 = load i32, i32* %250
%252 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%253 = load i32, i32* %252
%254 = sub nsw i32 %251, %253
%255 = mul nsw i32 %254, 1000000
%256 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 0
%257 = load i32, i32* %256
%258 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%259 = load i32, i32* %258
%260 = sub nsw i32 %257, %259
%261 = add nsw i32 %255, %260
%262 = sext i32 %261 to i64
store i64 %262, i64* %11
%263 = load i64, i64* %11
%264 = load i32, i32* %15
%265 = mul nsw i32 %264, 1000
%266 = sext i32 %265 to i64
%267 = icmp sgt i64 %263, %266
br i1 %267, label %268, label %276
268: ; preds = %249
%269 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%270 = load i32, i32* %269
%271 = load i32, i32* %21
%272 = icmp slt i32 %270, %271
br i1 %272, label %273, label %276
273: ; preds = %268
store i32 0, i32* %12
%274 = bitcast %struct.timeval* %7 to i8*
%275 = bitcast %struct.timeval* %6 to i8*
br label %276
276: ; preds = %273, %268, %249
br label %277
277: ; preds = %276, %336
%278 = load i32, i32* %31
%279 = icmp ne i32 %278, 0
br i1 %279, label %280, label %281
280: ; preds = %277
br label %337
281: ; preds = %277
%282 = load i32, i32* %35
%283 = call i32 @read(i32 %282, i8* %28, i32 1)
store i32 %283, i32* %30
%284 = load i32, i32* %30
%285 = icmp eq i32 %284, -1
br i1 %285, label %286, label %287
286: ; preds = %281
store i32 -3, i32* %31
br label %337
287: ; preds = %281
%288 = load i32, i32* %30
%289 = icmp eq i32 %288, 0
br i1 %289, label %290, label %291
290: ; preds = %287
br label %337
291: ; preds = %287
%292 = load i32, i32* %30
%293 = icmp sgt i32 %292, 0
br i1 %293, label %294, label %334
294: ; preds = %291
%295 = load i8, i8* %28
%296 = sext i8 %295 to i32
%297 = getelementptr inbounds [43 x i8], [43 x i8]* %25, i64 0, i64 0
%298 = load i8, i8* %297
%299 = sext i8 %298 to i32
%300 = icmp eq i32 %296, %299
br i1 %300, label %301, label %302
301: ; preds = %294
store i32 0, i32* %29
br label %302
302: ; preds = %301, %294
%303 = load i8, i8* %28
%304 = load i32, i32* %29
%305 = sext i32 %304 to i64
%306 = getelementptr inbounds [50 x i8], [50 x i8]* %27, i64 0, i64 %305
store i8 %303, i8* %306
%307 = load i8, i8* %28
%308 = sext i8 %307 to i32
%309 = icmp eq i32 %308, 10
br i1 %309, label %310, label %327
310: ; preds = %302
%311 = load i32, i32* %29
%312 = add nsw i32 %311, 1
%313 = sext i32 %312 to i64
%314 = getelementptr inbounds [50 x i8], [50 x i8]* %27, i64 0, i64 %313
store i8 0, i8* %314
store i32 1, i32* %31
%315 = load i32, i32* %33
%316 = load i32, i32* %16
%317 = srem i32 %315, %316
%318 = icmp eq i32 %317, 0
br i1 %318, label %319, label %326
319: ; preds = %310
%320 = load i32, i32* %19
%321 = icmp ne i32 %320, 0
br i1 %321, label %322, label %326
322: ; preds = %319
%323 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%324 = load i32, i32* @stdout
%325 = call i32 @fflush(i32 %324)
br label %326
326: ; preds = %322, %319, %310
br label %327
327: ; preds = %326, %302
%328 = load i32, i32* %29
%329 = add nsw i32 %328, 1
store i32 %329, i32* %29
%330 = load i32, i32* %29
%331 = icmp sgt i32 %330, 49
br i1 %331, label %332, label %333
332: ; preds = %327
store i32 0, i32* %29
store i32 -2, i32* %31
br label %333
333: ; preds = %332, %327
br label %334
334: ; preds = %333, %291
br label %335
335: ; preds = %334
br label %336
336: ; preds = %335
br label %277
337: ; preds = %290, %286, %280
%338 = load i32, i32* %31
%339 = icmp eq i32 %338, 1
br i1 %339, label %340, label %359
340: ; preds = %337
%341 = getelementptr inbounds [43 x i8], [43 x i8]* %25, i64 0, i64 0
%342 = getelementptr inbounds [50 x i8], [50 x i8]* %27, i64 0, i64 0
%343 = call i64 @strcmp(i8* %341, i8* %342)
%344 = icmp eq i64 0, %343
br i1 %344, label %345, label %348
345: ; preds = %340
store i32 0, i32* %31
%346 = load i32, i32* %33
%347 = add nsw i32 %346, 1
store i32 %347, i32* %33
br label %358
348: ; preds = %340
%349 = getelementptr inbounds [43 x i8], [43 x i8]* %26, i64 0, i64 0
%350 = getelementptr inbounds [50 x i8], [50 x i8]* %27, i64 0, i64 0
%351 = call i64 @strcmp(i8* %349, i8* %350)
%352 = icmp eq i64 0, %351
br i1 %352, label %353, label %356
353: ; preds = %348
store i32 0, i32* %31
%354 = load i32, i32* %33
%355 = add nsw i32 %354, 1
store i32 %355, i32* %33
br label %357
356: ; preds = %348
store i32 -1, i32* %31
br label %357
357: ; preds = %356, %353
br label %358
358: ; preds = %357, %345
store i32 0, i32* %29
br label %359
359: ; preds = %358, %337
%360 = load i32, i32* %31
%361 = icmp slt i32 %360, 0
br i1 %361, label %362, label %373
362: ; preds = %359
%363 = load i32, i32* %19
%364 = icmp ne i32 %363, 0
br i1 %364, label %365, label %372
365: ; preds = %362
%366 = load i32, i32* %31
%367 = getelementptr inbounds [43 x i8], [43 x i8]* %25, i64 0, i64 0
%368 = getelementptr inbounds [50 x i8], [50 x i8]* %27, i64 0, i64 0
%369 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0), i32 %366, i8* %367, i8* %368)
%370 = load i32, i32* @stdout
%371 = call i32 @fflush(i32 %370)
br label %372
372: ; preds = %365, %362
store i32 0, i32* %31
br label %373
373: ; preds = %372, %359
%374 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%375 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i32 0, i32 1
%376 = load i32, i32* %375
%377 = load i32, i32* %21
%378 = icmp sgt i32 %376, %377
br i1 %378, label %379, label %384
379: ; preds = %373
%380 = load i32, i32* %33
%381 = load i32, i32* %32
%382 = icmp eq i32 %380, %381
br i1 %382, label %383, label %384
383: ; preds = %379
br label %385
384: ; preds = %379, %373
br label %219
385: ; preds = %383, %219
%386 = call i32 @time(i32* null)
store i32 %386, i32* %9
%387 = call %struct.tm* @localtime(i32* %9)
store %struct.tm* %387, %struct.tm** %8
%388 = getelementptr inbounds [30 x i8], [30 x i8]* %10, i64 0, i64 0
%389 = load %struct.tm*, %struct.tm** %8
%390 = call i32 @strftime(i8* %388, i32 9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), %struct.tm* %389)
%391 = load i32, i32* %19
%392 = icmp ne i32 %391, 0
br i1 %392, label %393, label %396
393: ; preds = %385
%394 = getelementptr inbounds [30 x i8], [30 x i8]* %10, i64 0, i64 0
%395 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), i8* %394)
br label %396
396: ; preds = %393, %385
%397 = load i32, i32* %32
%398 = load i32, i32* %33
%399 = icmp ne i32 %397, %398
br i1 %399, label %400, label %406
400: ; preds = %396
%401 = getelementptr inbounds [20 x i8], [20 x i8]* %14, i64 0, i64 0
%402 = load i32, i32* %32
%403 = load i32, i32* %33
%404 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.15, i64 0, i64 0), i8* %401, i32 %402, i32 %403)
%405 = call i32 @exit(i32 1)
unreachable
406: ; preds = %396
%407 = getelementptr inbounds [20 x i8], [20 x i8]* %14, i64 0, i64 0
%408 = load i32, i32* %33
%409 = load i32, i32* %33
%410 = getelementptr inbounds [43 x i8], [43 x i8]* %25, i64 0, i64 0
%411 = call i32 @strlen(i8* %410)
%412 = mul nsw i32 %409, %411
%413 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.16, i64 0, i64 0), i8* %407, i32 %408, i32 %412)
br label %414
414: ; preds = %406
%415 = load i32, i32* %35
%416 = call i32 @close(i32 %415)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.tm = type { i32 }
@__const.main.serial_dev = [20 x i8] c"/dev/ttyS0\00\00\00\00\00\00\00\00\00\00"
@.str = [13 x i8] c"hvT:N:b:p:d:\00"
@optarg = external global i8*
@.str.1 = [24 x i8] c"ERROR str too long: %s\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [20 x i8] c"ERROR bad input %c\0A\00"
@.str.4 = [17 x i8] c"Opening Port %s\0A\00"
@O_RDWR = global i32 0
@.str.5 = [28 x i8] c"Error opening port, %d, %s\0A\00"
@errno = global i32 0
@B9600 = global i32 0
@B115200 = global i32 0
@B230400 = global i32 0
@.str.6 = [16 x i8] c"ERROR Baud rate\00"
@TCIOFLUSH = global i32 0
@.str.7 = [46 x i8] c"Transmitting %.1f WPS at %d baud, %.1f %% BW\0A\00"
@.str.8 = [12 x i8] c"Pattern: %s\00"
@.str.9 = [9 x i8] c"%H:%M:%S\00"
@.str.10 = [25 x i8] c"Start %s, Duration %d s\0A\00"
@.str.11 = [30 x i8] c"#%02x,a0a0,a0a0,a0a0,a0a0,cc\0A\00"
@stdout = global i32 0
@.str.13 = [31 x i8] c"\0AERROR Rx Detected, %d:%s!=%s\0A\00"
@.str.14 = [9 x i8] c"\0AEnd %s\0A\00"
@.str.15 = [42 x i8] c"Test FAILED, %s TX (%d) != RX (%d) words\0A\00"
@.str.16 = [42 x i8] c"Test SUCCESS, %s RX = %d words, %d chars\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to %struct.timeval*
%5 = alloca i64
%6 = bitcast i64* %5 to %struct.timeval*
%7 = alloca i32
%8 = alloca [30 x i8]
%9 = alloca [20 x i8]
%10 = alloca [43 x i8]
%11 = alloca [43 x i8]
%12 = alloca [50 x i8]
%13 = alloca i8
%14 = bitcast i64* %3 to i8*
%15 = bitcast i64* %5 to i8*
%16 = bitcast i32* %7 to i8*
%17 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%19 = getelementptr inbounds [43 x i8], [43 x i8]* %10, i64 0, i64 0
%20 = getelementptr inbounds [43 x i8], [43 x i8]* %11, i64 0, i64 0
%21 = getelementptr inbounds [50 x i8], [50 x i8]* %12, i64 0, i64 0
store i8 0, i8* %13
br label %22
22: ; preds = %54, %2
%23 = phi i32 [ 100, %2 ], [ %55, %54 ]
%24 = phi i32 [ 1, %2 ], [ %56, %54 ]
%25 = phi i32 [ 115200, %2 ], [ %57, %54 ]
%26 = phi i32 [ 0, %2 ], [ %58, %54 ]
%27 = phi i32 [ 0, %2 ], [ %59, %54 ]
%28 = phi i32 [ 26, %2 ], [ %60, %54 ]
%29 = call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
switch i32 %29, label %84 [
i32 -1, label %88
i32 118, label %54
i32 100, label %30
i32 84, label %40
i32 78, label %48
i32 98, label %51
i32 112, label %64
i32 104, label %81
]
30: ; preds = %22
%31 = load i8*, i8** @optarg
%32 = call i32 @strlen(i8* %31)
%33 = icmp slt i32 %32, 19
%34 = load i8*, i8** @optarg
br i1 %33, label %35, label %37
35: ; preds = %30
%36 = call i32 @strcpy(i8* %18, i8* %34)
br label %54
37: ; preds = %30
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* %34)
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %22
%41 = load i8*, i8** @optarg
%42 = call i32 @atoi(i8* %41)
%43 = add i32 %42, -1001
%44 = icmp ult i32 %43, -1000
br i1 %44, label %45, label %54
45: ; preds = %40
%46 = call i32 (...) @print_app_usage()
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %22
%49 = load i8*, i8** @optarg
%50 = call i32 @atoi(i8* %49)
br label %54
51: ; preds = %22
%52 = load i8*, i8** @optarg
%53 = call i32 @atoi(i8* %52)
switch i32 %53, label %61 [
i32 230400, label %54
i32 115200, label %54
i32 9600, label %54
]
54: ; preds = %51, %51, %51, %22, %40, %72, %48, %35
%55 = phi i32 [ %23, %72 ], [ %23, %51 ], [ %23, %48 ], [ %42, %40 ], [ %23, %35 ], [ %23, %22 ], [ %23, %51 ], [ %23, %51 ]
%56 = phi i32 [ %24, %72 ], [ %24, %51 ], [ %50, %48 ], [ %24, %40 ], [ %24, %35 ], [ %24, %22 ], [ %24, %51 ], [ %24, %51 ]
%57 = phi i32 [ %25, %72 ], [ %53, %51 ], [ %25, %48 ], [ %25, %40 ], [ %25, %35 ], [ %25, %22 ], [ %53, %51 ], [ %53, %51 ]
%58 = phi i32 [ %26, %72 ], [ %26, %51 ], [ %26, %48 ], [ %26, %40 ], [ %26, %35 ], [ 1, %22 ], [ %26, %51 ], [ %26, %51 ]
%59 = phi i32 [ 1, %72 ], [ %27, %51 ], [ %27, %48 ], [ %27, %40 ], [ %27, %35 ], [ %27, %22 ], [ %27, %51 ], [ %27, %51 ]
%60 = phi i32 [ %77, %72 ], [ %28, %51 ], [ %28, %48 ], [ %28, %40 ], [ %28, %35 ], [ %28, %22 ], [ %28, %51 ], [ %28, %51 ]
br label %22
61: ; preds = %51
%62 = call i32 (...) @print_app_usage()
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %22
%65 = load i8*, i8** @optarg
%66 = call i32 @strlen(i8* %65)
%67 = icmp slt i32 %66, 41
%68 = load i8*, i8** @optarg
%69 = call i32 @strlen(i8* %68)
%70 = icmp sgt i32 %69, 0
%71 = and i1 %67, %70
br i1 %71, label %72, label %78
72: ; preds = %64
%73 = load i8*, i8** @optarg
%74 = call i32 @strcpy(i8* %19, i8* %73)
%75 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%76 = call i32 @strlen(i8* %19)
%77 = add nsw i32 %76, 1
br label %54
78: ; preds = %64
%79 = call i32 (...) @print_app_usage()
%80 = call i32 @exit(i32 1)
unreachable
81: ; preds = %22
%82 = call i32 (...) @print_app_usage()
%83 = call i32 @exit(i32 1)
unreachable
84: ; preds = %22
%85 = call i32 (...) @print_app_usage()
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%87 = call i32 @exit(i32 1)
unreachable
88: ; preds = %22
%89 = icmp ne i32 %26, 0
br i1 %89, label %90, label %92
90: ; preds = %88
%91 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* %18)
br label %92
92: ; preds = %90, %88
%93 = load i32, i32* @O_RDWR
%94 = call i32 @open(i8* %18, i32 %93)
%95 = icmp slt i32 %94, 0
br i1 %95, label %96, label %101
96: ; preds = %92
%97 = load i32, i32* @errno
%98 = call i8* @strerror(i32 %97)
%99 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %94, i8* %98)
%100 = call i32 @exit(i32 1)
unreachable
101: ; preds = %92
switch i32 %25, label %104 [
i32 9600, label %107
i32 115200, label %102
i32 230400, label %103
]
102: ; preds = %101
br label %107
103: ; preds = %101
br label %107
104: ; preds = %101
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%106 = call i32 @exit(i32 1)
unreachable
107: ; preds = %101, %103, %102
%108 = phi i32* [ @B230400, %103 ], [ @B115200, %102 ], [ @B9600, %101 ]
%109 = load i32, i32* %108
%110 = call i32 @set_interface_attribs(i32 %94, i32 %109, i32 0)
%111 = load i32, i32* @TCIOFLUSH
%112 = call i32 @tcflush(i32 %94, i32 %111)
%113 = call i32 @sleep(i32 1)
%114 = sitofp i32 %23 to double
br i1 %89, label %115, label %135
115: ; preds = %107
%116 = sitofp i32 %28 to double
%117 = fmul double %116, 1.250000e+00
%118 = fmul double %117, 1.000000e+03
%119 = fdiv double %118, %114
%120 = fmul double %119, 1.000000e+02
%121 = sitofp i32 %25 to double
%122 = fdiv double %120, %121
%123 = fptrunc double %122 to float
%124 = fdiv double 1.000000e+03, %114
%125 = fpext float %123 to double
%126 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), double %124, i32 %25, double %125)
%127 = icmp eq i32 %27, 0
br i1 %127, label %130, label %128
128: ; preds = %115
%129 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* %19)
br label %130
130: ; preds = %128, %115
%131 = call i32 @time(i32* null)
store i32 %131, i32* %7
%132 = call %struct.tm* @localtime(i32* %7)
%133 = call i32 @strftime(i8* %17, i32 9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), %struct.tm* %132)
%134 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i8* %17, i32 %24)
br label %139
135: ; preds = %107
%136 = call i32 @time(i32* null)
store i32 %136, i32* %7
%137 = call %struct.tm* @localtime(i32* %7)
%138 = call i32 @strftime(i8* %17, i32 9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), %struct.tm* %137)
br label %139
139: ; preds = %135, %130
%140 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%141 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%142 = bitcast i64* %3 to i32*
%143 = load i32, i32* %142
%144 = icmp sgt i32 %143, 200
br i1 %144, label %145, label %149
145: ; preds = %139, %145
%146 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%147 = load i32, i32* %142
%148 = icmp sgt i32 %147, 200
br i1 %148, label %145, label %149
149: ; preds = %145, %139
%150 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%151 = load i32, i32* %150
%152 = add nsw i32 %151, %24
%153 = add nsw i32 %152, 2
%154 = icmp eq i32 %27, 0
%155 = getelementptr inbounds %struct.timeval, %struct.timeval* %6, i64 0, i32 1
%156 = bitcast i64* %5 to i32*
%157 = mul nsw i32 %23, 1000
%158 = xor i1 %89, true
br label %159
159: ; preds = %253, %149
%160 = phi i32 [ %151, %149 ], [ %258, %253 ]
%161 = phi i32 [ 1, %149 ], [ %196, %253 ]
%162 = phi i32 [ 0, %149 ], [ %181, %253 ]
%163 = phi i32 [ 0, %149 ], [ %255, %253 ]
%164 = phi i32 [ 0, %149 ], [ %256, %253 ]
%165 = phi i32 [ 0, %149 ], [ %182, %253 ]
%166 = phi i32 [ 0, %149 ], [ %254, %253 ]
%167 = icmp slt i32 %160, %153
br i1 %167, label %168, label %262
168: ; preds = %159
%169 = icmp eq i32 %161, 0
br i1 %169, label %170, label %180
170: ; preds = %168
%171 = call i32 @strcpy(i8* %20, i8* %19)
br i1 %154, label %172, label %174
172: ; preds = %170
%173 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0), i32 %162)
br label %174
174: ; preds = %172, %170
%175 = call i32 @strlen(i8* %19)
%176 = call i32 @write(i32 %94, i8* %19, i32 %175)
%177 = add nsw i32 %162, 1
%178 = srem i32 %177, 100
%179 = add nsw i32 %165, 1
br label %180
180: ; preds = %174, %168
%181 = phi i32 [ %178, %174 ], [ %162, %168 ]
%182 = phi i32 [ %179, %174 ], [ %165, %168 ]
%183 = load i32, i32* %155
%184 = sub nsw i32 %160, %183
%185 = mul nsw i32 %184, 1000000
%186 = load i32, i32* %142
%187 = load i32, i32* %156
%188 = sub i32 %186, %187
%189 = add nsw i32 %188, %185
%190 = icmp sgt i32 %189, %157
%191 = icmp slt i32 %160, %152
%192 = select i1 %190, i1 %191, i1 false
br i1 %192, label %193, label %195
193: ; preds = %180
%194 = load i64, i64* %3
store i64 %194, i64* %5
br label %195
195: ; preds = %193, %180
%196 = phi i32 [ 0, %193 ], [ 1, %180 ]
%197 = srem i32 %166, 10
%198 = icmp eq i32 %197, 0
%199 = select i1 %198, i1 %89, i1 false
br label %200
200: ; preds = %225, %195
%201 = phi i32 [ %228, %225 ], [ %163, %195 ]
%202 = phi i32 [ %229, %225 ], [ %164, %195 ]
br label %203
203: ; preds = %200, %207
%204 = phi i32 [ 0, %207 ], [ %202, %200 ]
switch i32 %204, label %242 [
i32 0, label %205
i32 1, label %230
]
205: ; preds = %203
%206 = call i32 @read(i32 %94, i8* %13, i32 1)
switch i32 %206, label %207 [
i32 -1, label %242
i32 0, label %253
]
207: ; preds = %205
%208 = icmp sgt i32 %206, 0
br i1 %208, label %209, label %203
209: ; preds = %207
%210 = load i8, i8* %13
%211 = load i8, i8* %19
%212 = icmp eq i8 %210, %211
%213 = select i1 %212, i32 0, i32 %201
%214 = sext i32 %213 to i64
%215 = getelementptr inbounds [50 x i8], [50 x i8]* %12, i64 0, i64 %214
store i8 %210, i8* %215
%216 = icmp eq i8 %210, 10
%217 = add nsw i32 %213, 1
br i1 %216, label %218, label %225
218: ; preds = %209
%219 = sext i32 %217 to i64
%220 = getelementptr inbounds [50 x i8], [50 x i8]* %12, i64 0, i64 %219
store i8 0, i8* %220
br i1 %199, label %221, label %225
221: ; preds = %218
%222 = call i32 @putchar(i32 46)
%223 = load i32, i32* @stdout
%224 = call i32 @fflush(i32 %223)
br label %225
225: ; preds = %209, %218, %221
%226 = phi i32 [ 1, %218 ], [ 1, %221 ], [ 0, %209 ]
%227 = icmp sgt i32 %213, 48
%228 = select i1 %227, i32 0, i32 %217
%229 = select i1 %227, i32 -2, i32 %226
br label %200
230: ; preds = %203
%231 = call i64 @strcmp(i8* %19, i8* %21)
%232 = icmp eq i64 %231, 0
br i1 %232, label %233, label %235
233: ; preds = %230
%234 = add nsw i32 %166, 1
br label %253
235: ; preds = %230
%236 = call i64 @strcmp(i8* %20, i8* %21)
%237 = icmp eq i64 %236, 0
%238 = xor i1 %237, true
%239 = sext i1 %238 to i32
%240 = zext i1 %237 to i32
%241 = add nsw i32 %166, %240
br label %242
242: ; preds = %203, %205, %235
%243 = phi i32 [ 0, %235 ], [ %201, %205 ], [ %201, %203 ]
%244 = phi i32 [ %239, %235 ], [ %204, %203 ], [ -3, %205 ]
%245 = phi i32 [ %241, %235 ], [ %166, %205 ], [ %166, %203 ]
%246 = icmp sgt i32 %244, -1
%247 = select i1 %246, i1 true, i1 %158
%248 = select i1 %246, i32 %244, i32 0
br i1 %247, label %253, label %249
249: ; preds = %242
%250 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.13, i64 0, i64 0), i32 %244, i8* %19, i8* %21)
%251 = load i32, i32* @stdout
%252 = call i32 @fflush(i32 %251)
br label %253
253: ; preds = %205, %233, %242, %249
%254 = phi i32 [ %245, %242 ], [ %245, %249 ], [ %234, %233 ], [ %166, %205 ]
%255 = phi i32 [ %243, %242 ], [ %243, %249 ], [ 0, %233 ], [ %201, %205 ]
%256 = phi i32 [ %248, %242 ], [ 0, %249 ], [ 0, %233 ], [ %206, %205 ]
%257 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%258 = load i32, i32* %150
%259 = icmp sgt i32 %258, %152
%260 = icmp eq i32 %254, %182
%261 = select i1 %259, i1 %260, i1 false
br i1 %261, label %262, label %159
262: ; preds = %253, %159
%263 = phi i32 [ %165, %159 ], [ %182, %253 ]
%264 = phi i32 [ %166, %159 ], [ %182, %253 ]
%265 = call i32 @time(i32* null)
store i32 %265, i32* %7
%266 = call %struct.tm* @localtime(i32* %7)
%267 = call i32 @strftime(i8* %17, i32 9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), %struct.tm* %266)
br i1 %89, label %268, label %270
268: ; preds = %262
%269 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0), i8* %17)
br label %270
270: ; preds = %268, %262
%271 = icmp eq i32 %263, %264
br i1 %271, label %275, label %272
272: ; preds = %270
%273 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.15, i64 0, i64 0), i8* %18, i32 %263, i32 %264)
%274 = call i32 @exit(i32 1)
unreachable
275: ; preds = %270
%276 = call i32 @strlen(i8* %19)
%277 = mul nsw i32 %276, %263
%278 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.16, i64 0, i64 0), i8* %18, i32 %263, i32 %277)
%279 = call i32 @close(i32 %94)
ret i32 0
}