#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
char getopt(int, char **, char *);
int /*<<< orphan*/ isdigit(char const);
int /*<<< orphan*/ isprint(char);
scalar_t__ malloc(int);
char *optarg;
int optind;
char optopt;
int /*<<< orphan*/ print_help();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char const *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char const *);
scalar_t__ system(char *);
int main(int argc, char **argv) {
  const char *baud_rate;
  int input_file_name;
  int output_file_name;
  char c;
  baud_rate = "9600";
  while ((c = getopt(argc, argv, "b:h")) != -1) {
    switch (c) {
    case 'b':
      baud_rate = optarg;
      ;
      break;
    case 'h':
      print_help();
      return 0;
      break;
    case '?':
      if (optopt == 'b')
        fprintf(stderr, "Option -%c requires an argument.\n", optopt);
      else if (isprint(optopt))
        fprintf(stderr, "Unknown option `-%c'.\n", optopt);
      else
        fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
      print_help();
      return 1;
    default:
      fprintf(stderr, "Bad state reached.\n");
      return 1;
    }
  }
  if (strlen(baud_rate) > 6) {
    fprintf(stderr, "Baud rate must be at most 6 digits long\n");
    return 1;
  }
  unsigned int i;
  for (i = 0; i < strlen(baud_rate); ++i) {
    if (!isdigit(baud_rate[i])) {
      fprintf(stderr, "Baud rate is not a number\n");
      return 1;
    }
  }
  int index = optind;
  if (index != argc - 2) {
    fprintf(stderr, "Incorrect number of arguments\n");
    return 1;
  }
  input_file_name = index;
  output_file_name = index + 1;
  FILE *in = fopen(argv[input_file_name], "r");
  if (in == NULL) {
    fprintf(stderr, "Could not open file %s\n", argv[input_file_name]);
    return 1;
  }
  FILE *out = fopen(argv[output_file_name], "w");
  if (out == NULL) {
    fprintf(stderr, "Could not open file %s\n", argv[output_file_name]);
    return 1;
  }
  char *system_command =
      (char *)malloc(20 + strlen(argv[output_file_name]) + strlen(baud_rate));
  strcpy(system_command, "stty -F ");
  strcat(system_command, argv[output_file_name]);
  strcat(system_command, " raw -echo ");
  strcat(system_command, baud_rate);
  if (system(system_command) != 0) {
    fprintf(stderr, "Could not set serial port options\n");
    return 1;
  }
  free(system_command);
  sleep(2);
  unsigned char buffer;
  while (fread(&buffer, 1, 1, in)) {
    fwrite(&buffer, 1, 1, out);
  }
  sleep(2);
  fclose(in);
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xde3(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdd6(%rip),%rdx
call   10e0 <getopt@plt>
mov    %al,-0x21(%rbp)
movsbl %al,%eax
cmp    $0xffffffff,%eax
je     1378 <main+0x178>
movsbl -0x21(%rbp),%eax
mov    %eax,-0x50(%rbp)
sub    $0x3f,%eax
je     12a0 <main+0xa0>
jmp    1258 <main+0x58>
mov    -0x50(%rbp),%eax
sub    $0x62,%eax
je     127a <main+0x7a>
jmp    1269 <main+0x69>
mov    -0x50(%rbp),%eax
sub    $0x68,%eax
je     128d <main+0x8d>
jmp    1350 <main+0x150>
mov    0x2d77(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    1373 <main+0x173>
mov    $0x0,%al
call   10f0 <print_help@plt>
movl   $0x0,-0x4(%rbp)
jmp    162d <main+0x42d>
mov    0x2d39(%rip),%rax
movsbl (%rax),%eax
cmp    $0x62,%eax
jne    12d9 <main+0xd9>
mov    0x2d0e(%rip),%rax
mov    (%rax),%edi
mov    0x2d1d(%rip),%rax
movsbl (%rax),%edx
lea    0xd3c(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    133d <main+0x13d>
mov    0x2d00(%rip),%rax
movsbl (%rax),%edi
call   10c0 <isprint@plt>
cmp    $0x0,%eax
je     1317 <main+0x117>
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
mov    0x2cdf(%rip),%rax
movsbl (%rax),%edx
lea    0xd20(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    1338 <main+0x138>
mov    0x2caa(%rip),%rax
mov    (%rax),%edi
mov    0x2cb9(%rip),%rax
movsbl (%rax),%edx
lea    0xd11(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
jmp    133d <main+0x13d>
mov    $0x0,%al
call   10f0 <print_help@plt>
movl   $0x1,-0x4(%rbp)
jmp    162d <main+0x42d>
mov    0x2c71(%rip),%rax
mov    (%rax),%edi
lea    0xd04(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    162d <main+0x42d>
jmp    1221 <main+0x21>
mov    -0x18(%rbp),%rdi
call   1080 <strlen@plt>
cmp    $0x6,%eax
jle    13ad <main+0x1ad>
mov    0x2c37(%rip),%rax
mov    (%rax),%edi
lea    0xcde(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    162d <main+0x42d>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <strlen@plt>
mov    %eax,%ecx
mov    -0x54(%rbp),%eax
cmp    %ecx,%eax
jae    141f <main+0x21f>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%eax
jne    140c <main+0x20c>
mov    0x2bd8(%rip),%rax
mov    (%rax),%edi
lea    0xca8(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    162d <main+0x42d>
jmp    1411 <main+0x211>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    13b4 <main+0x1b4>
mov    0x2bb2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
je     145f <main+0x25f>
mov    0x2b85(%rip),%rax
mov    (%rax),%edi
lea    0xc70(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    162d <main+0x42d>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xc5a(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    14c4 <main+0x2c4>
mov    0x2b2c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xc2c(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    162d <main+0x42d>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xc1e(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    151a <main+0x31a>
mov    0x2ad6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xbd6(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    162d <main+0x42d>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <strlen@plt>
add    $0x14,%eax
mov    %eax,-0x58(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <strlen@plt>
mov    -0x58(%rbp),%edi
add    %eax,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
lea    0xba4(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1100 <strcat@plt>
mov    -0x48(%rbp),%rdi
lea    0xb88(%rip),%rsi
call   1100 <strcat@plt>
mov    -0x48(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1100 <strcat@plt>
mov    -0x48(%rbp),%rdi
call   1090 <system@plt>
cmp    $0x0,%rax
je     15c0 <main+0x3c0>
mov    0x2a24(%rip),%rax
mov    (%rax),%edi
lea    0xb5f(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    162d <main+0x42d>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    $0x2,%edi
call   1120 <sleep@plt>
mov    -0x38(%rbp),%rcx
lea    -0x49(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1060 <fread@plt>
cmp    $0x0,%rax
je     160a <main+0x40a>
mov    -0x40(%rbp),%rcx
lea    -0x49(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1110 <fwrite@plt>
jmp    15d3 <main+0x3d3>
mov    $0x2,%edi
call   1120 <sleep@plt>
mov    -0x38(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x40(%rbp),%rdi
call   1070 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r12d
lea    0xded(%rip),%rdx
call   10f0 <getopt@plt>
cmp    $0xff,%al
je     1270 <main+0x70>
mov    0x2dd0(%rip),%rbp
lea    0xdd6(%rip),%r15
nop
movsbl %al,%eax
cmp    $0x62,%eax
jne    1250 <main+0x50>
mov    0x0(%rbp),%rbx
mov    %r12d,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   10f0 <getopt@plt>
cmp    $0xff,%al
jne    1230 <main+0x30>
jmp    1277 <main+0x77>
cmp    $0x3f,%eax
je     13a1 <main+0x1a1>
cmp    $0x68,%eax
jne    13c8 <main+0x1c8>
xor    %ebx,%ebx
xor    %eax,%eax
call   1100 <print_help@plt>
jmp    145d <main+0x25d>
lea    0xd89(%rip),%rbx
mov    %rbx,%rdi
call   1080 <strlen@plt>
cmp    $0x6,%eax
jle    1299 <main+0x99>
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
lea    0xde4(%rip),%rsi
jmp    13fc <main+0x1fc>
mov    %rbx,%rdi
call   1080 <strlen@plt>
test   %eax,%eax
je     12d4 <main+0xd4>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movsbl (%rbx,%rbp,1),%edi
call   1040 <isdigit@plt>
test   %eax,%eax
je     13ec <main+0x1ec>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%rbp
jb     12b0 <main+0xb0>
mov    0x2cfd(%rip),%rax
movslq (%rax),%r13
add    $0xfffffffe,%r12d
cmp    %r12d,%r13d
jne    13da <main+0x1da>
mov    (%r14,%r13,8),%rdi
lea    0xde5(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     1426 <main+0x226>
mov    %rax,%r15
mov    0x8(%r14,%r13,8),%rdi
add    $0x1,%r13
lea    0xdde(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     1426 <main+0x226>
mov    %rax,%r12
mov    (%r14,%r13,8),%rdi
call   1080 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1080 <strlen@plt>
lea    (%rax,%rbp,1),%edi
add    $0x14,%edi
call   10c0 <malloc@plt>
mov    %rax,%rbp
lea    0xda7(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcpy@plt>
mov    (%r14,%r13,8),%rsi
mov    %rbp,%rdi
call   1110 <strcat@plt>
lea    0xd95(%rip),%rsi
mov    %rbp,%rdi
call   1110 <strcat@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1110 <strcat@plt>
mov    %rbp,%rdi
call   1090 <system@plt>
test   %rax,%rax
je     146e <main+0x26e>
mov    0x2c32(%rip),%rax
mov    (%rax),%edi
lea    0xd6d(%rip),%rsi
jmp    13fc <main+0x1fc>
mov    0x2c38(%rip),%rbx
mov    (%rbx),%al
cmp    $0x62,%al
jne    1405 <main+0x205>
mov    0x2c13(%rip),%rax
mov    (%rax),%edi
lea    0xc4b(%rip),%rsi
mov    $0x62,%edx
jmp    144a <main+0x24a>
mov    0x2bf9(%rip),%rax
mov    (%rax),%edi
lea    0xc8c(%rip),%rsi
jmp    13fc <main+0x1fc>
mov    0x2be7(%rip),%rax
mov    (%rax),%edi
lea    0xcd2(%rip),%rsi
jmp    13fc <main+0x1fc>
mov    0x2bd5(%rip),%rax
mov    (%rax),%edi
lea    0xca5(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    1458 <main+0x258>
movsbl %al,%edi
call   10d0 <isprint@plt>
mov    0x2bb4(%rip),%rcx
mov    (%rcx),%edi
movsbl (%rbx),%edx
test   %eax,%eax
je     1443 <main+0x243>
lea    0xc07(%rip),%rsi
jmp    144a <main+0x24a>
mov    0x2b9b(%rip),%rax
mov    (%rax),%edi
mov    (%r14,%r13,8),%rdx
lea    0xca3(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    1458 <main+0x258>
lea    0xbf8(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
xor    %eax,%eax
call   1100 <print_help@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbp,%rdi
call   1030 <free@plt>
mov    $0x2,%edi
call   1120 <sleep@plt>
lea    0x7(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1060 <fread@plt>
test   %rax,%rax
je     14d7 <main+0x2d7>
lea    0x7(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl 0x7(%rsp),%edi
mov    %r12,%rsi
call   10a0 <fputc@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1060 <fread@plt>
test   %rax,%rax
jne    14b0 <main+0x2b0>
mov    $0x2,%edi
call   1120 <sleep@plt>
mov    %r15,%rdi
call   1070 <fclose@plt>
mov    %r12,%rdi
call   1070 <fclose@plt>
xor    %ebx,%ebx
jmp    145d <main+0x25d>

LLVM IR (-O0):
@.str = [5 x i8] c"9600\00"
@.str.1 = [4 x i8] c"b:h\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.2 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.3 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.4 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@.str.5 = [20 x i8] c"Bad state reached.\0A\00"
@.str.6 = [41 x i8] c"Baud rate must be at most 6 digits long\0A\00"
@.str.7 = [27 x i8] c"Baud rate is not a number\0A\00"
@optind = global i32 0
@.str.8 = [31 x i8] c"Incorrect number of arguments\0A\00"
@.str.9 = [2 x i8] c"r\00"
@.str.10 = [24 x i8] c"Could not open file %s\0A\00"
@.str.11 = [2 x i8] c"w\00"
@.str.12 = [9 x i8] c"stty -F \00"
@.str.13 = [12 x i8] c" raw -echo \00"
@.str.14 = [35 x i8] c"Could not set serial port options\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i8*
%15 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %6
br label %16
16: ; preds = %58, %2
%17 = load i32, i32* %4
%18 = load i8**, i8*** %5
%19 = call signext i8 @getopt(i32 %17, i8** %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
store i8 %19, i8* %9
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, -1
br i1 %21, label %22, label %59
22: ; preds = %16
%23 = load i8, i8* %9
%24 = sext i8 %23 to i32
switch i32 %24, label %55 [
i32 98, label %25
i32 104, label %27
i32 63, label %29
]
25: ; preds = %22
%26 = load i8*, i8** @optarg
store i8* %26, i8** %6
br label %58
27: ; preds = %22
%28 = call i32 (...) @print_help()
store i32 0, i32* %3
br label %183
29: ; preds = %22
%30 = load i8, i8* @optopt
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 98
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = load i32, i32* @stderr
%35 = load i8, i8* @optopt
%36 = sext i8 %35 to i32
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %36)
br label %53
38: ; preds = %29
%39 = load i8, i8* @optopt
%40 = call i32 @isprint(i8 signext %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %47
42: ; preds = %38
%43 = load i32, i32* @stderr
%44 = load i8, i8* @optopt
%45 = sext i8 %44 to i32
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %45)
br label %52
47: ; preds = %38
%48 = load i32, i32* @stderr
%49 = load i8, i8* @optopt
%50 = sext i8 %49 to i32
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %50)
br label %52
52: ; preds = %47, %42
br label %53
53: ; preds = %52, %33
%54 = call i32 (...) @print_help()
store i32 1, i32* %3
br label %183
55: ; preds = %22
%56 = load i32, i32* @stderr
%57 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %183
58: ; preds = %25
br label %16
59: ; preds = %16
%60 = load i8*, i8** %6
%61 = call i32 @strlen(i8* %60)
%62 = icmp sgt i32 %61, 6
br i1 %62, label %63, label %66
63: ; preds = %59
%64 = load i32, i32* @stderr
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %183
66: ; preds = %59
store i32 0, i32* %10
br label %67
67: ; preds = %84, %66
%68 = load i32, i32* %10
%69 = load i8*, i8** %6
%70 = call i32 @strlen(i8* %69)
%71 = icmp ult i32 %68, %70
br i1 %71, label %72, label %87
72: ; preds = %67
%73 = load i8*, i8** %6
%74 = load i32, i32* %10
%75 = zext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %73, i64 %75
%77 = load i8, i8* %76
%78 = call i32 @isdigit(i8 signext %77)
%79 = icmp ne i32 %78, 0
br i1 %79, label %83, label %80
80: ; preds = %72
%81 = load i32, i32* @stderr
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %183
83: ; preds = %72
br label %84
84: ; preds = %83
%85 = load i32, i32* %10
%86 = add i32 %85, 1
store i32 %86, i32* %10
br label %67
87: ; preds = %67
%88 = load i32, i32* @optind
store i32 %88, i32* %11
%89 = load i32, i32* %11
%90 = load i32, i32* %4
%91 = sub nsw i32 %90, 2
%92 = icmp ne i32 %89, %91
br i1 %92, label %93, label %96
93: ; preds = %87
%94 = load i32, i32* @stderr
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %3
br label %183
96: ; preds = %87
%97 = load i32, i32* %11
store i32 %97, i32* %7
%98 = load i32, i32* %11
%99 = add nsw i32 %98, 1
store i32 %99, i32* %8
%100 = load i8**, i8*** %5
%101 = load i32, i32* %7
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds i8*, i8** %100, i64 %102
%104 = load i8*, i8** %103
%105 = call i32* @fopen(i8* %104, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
store i32* %105, i32** %12
%106 = load i32*, i32** %12
%107 = icmp eq i32* %106, null
br i1 %107, label %108, label %116
108: ; preds = %96
%109 = load i32, i32* @stderr
%110 = load i8**, i8*** %5
%111 = load i32, i32* %7
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds i8*, i8** %110, i64 %112
%114 = load i8*, i8** %113
%115 = call i32 (i32, i8*, ...) @fprintf(i32 %109, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i8* %114)
store i32 1, i32* %3
br label %183
116: ; preds = %96
%117 = load i8**, i8*** %5
%118 = load i32, i32* %8
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds i8*, i8** %117, i64 %119
%121 = load i8*, i8** %120
%122 = call i32* @fopen(i8* %121, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
store i32* %122, i32** %13
%123 = load i32*, i32** %13
%124 = icmp eq i32* %123, null
br i1 %124, label %125, label %133
125: ; preds = %116
%126 = load i32, i32* @stderr
%127 = load i8**, i8*** %5
%128 = load i32, i32* %8
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds i8*, i8** %127, i64 %129
%131 = load i8*, i8** %130
%132 = call i32 (i32, i8*, ...) @fprintf(i32 %126, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i8* %131)
store i32 1, i32* %3
br label %183
133: ; preds = %116
%134 = load i8**, i8*** %5
%135 = load i32, i32* %8
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds i8*, i8** %134, i64 %136
%138 = load i8*, i8** %137
%139 = call i32 @strlen(i8* %138)
%140 = add nsw i32 20, %139
%141 = load i8*, i8** %6
%142 = call i32 @strlen(i8* %141)
%143 = add nsw i32 %140, %142
%144 = call i64 @malloc(i32 %143)
%145 = inttoptr i64 %144 to i8*
store i8* %145, i8** %14
%146 = load i8*, i8** %14
%147 = call i32 @strcpy(i8* %146, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0))
%148 = load i8*, i8** %14
%149 = load i8**, i8*** %5
%150 = load i32, i32* %8
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds i8*, i8** %149, i64 %151
%153 = load i8*, i8** %152
%154 = call i32 @strcat(i8* %148, i8* %153)
%155 = load i8*, i8** %14
%156 = call i32 @strcat(i8* %155, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
%157 = load i8*, i8** %14
%158 = load i8*, i8** %6
%159 = call i32 @strcat(i8* %157, i8* %158)
%160 = load i8*, i8** %14
%161 = call i64 @system(i8* %160)
%162 = icmp ne i64 %161, 0
br i1 %162, label %163, label %166
163: ; preds = %133
%164 = load i32, i32* @stderr
%165 = call i32 (i32, i8*, ...) @fprintf(i32 %164, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.14, i64 0, i64 0))
store i32 1, i32* %3
br label %183
166: ; preds = %133
%167 = load i8*, i8** %14
%168 = call i32 @free(i8* %167)
%169 = call i32 @sleep(i32 2)
br label %170
170: ; preds = %174, %166
%171 = load i32*, i32** %12
%172 = call i64 @fread(i8* %15, i32 1, i32 1, i32* %171)
%173 = icmp ne i64 %172, 0
br i1 %173, label %174, label %177
174: ; preds = %170
%175 = load i32*, i32** %13
%176 = call i32 @fwrite(i8* %15, i32 1, i32 1, i32* %175)
br label %170
177: ; preds = %170
%178 = call i32 @sleep(i32 2)
%179 = load i32*, i32** %12
%180 = call i32 @fclose(i32* %179)
%181 = load i32*, i32** %13
%182 = call i32 @fclose(i32* %181)
store i32 0, i32* %3
br label %183
183: ; preds = %177, %163, %125, %108, %93, %80, %63, %55, %53, %27
%184 = load i32, i32* %3
ret i32 %184
}

LLVM IR (-O2):
@.str = [5 x i8] c"9600\00"
@.str.1 = [4 x i8] c"b:h\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.2 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.3 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.4 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@.str.5 = [20 x i8] c"Bad state reached.\0A\00"
@.str.6 = [41 x i8] c"Baud rate must be at most 6 digits long\0A\00"
@.str.7 = [27 x i8] c"Baud rate is not a number\0A\00"
@optind = global i32 0
@.str.8 = [31 x i8] c"Incorrect number of arguments\0A\00"
@.str.9 = [2 x i8] c"r\00"
@.str.10 = [24 x i8] c"Could not open file %s\0A\00"
@.str.11 = [2 x i8] c"w\00"
@.str.12 = [9 x i8] c"stty -F \00"
@.str.13 = [12 x i8] c" raw -echo \00"
@.str.14 = [35 x i8] c"Could not set serial port options\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8
%4 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i8 %4, -1
br i1 %5, label %36, label %6
6: ; preds = %2, %9
%7 = phi i8 [ %11, %9 ], [ %4, %2 ]
%8 = sext i8 %7 to i32
switch i32 %8, label %33 [
i32 98, label %9
i32 104, label %13
i32 63, label %15
]
9: ; preds = %6
%10 = load i8*, i8** @optarg
%11 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i8 %11, -1
br i1 %12, label %36, label %6
13: ; preds = %6
%14 = tail call i32 (...) @print_help()
br label %121
15: ; preds = %6
%16 = load i8, i8* @optopt
%17 = icmp eq i8 %16, 98
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 98)
br label %31
21: ; preds = %15
%22 = tail call i32 @isprint(i8 signext %16)
%23 = icmp eq i32 %22, 0
%24 = load i32, i32* @stderr
%25 = load i8, i8* @optopt
%26 = sext i8 %25 to i32
br i1 %23, label %29, label %27
27: ; preds = %21
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %26)
br label %31
29: ; preds = %21
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %26)
br label %31
31: ; preds = %27, %29, %18
%32 = tail call i32 (...) @print_help()
br label %121
33: ; preds = %6
%34 = load i32, i32* @stderr
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %121
36: ; preds = %9, %2
%37 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %2 ], [ %10, %9 ]
%38 = tail call i32 @strlen(i8* %37)
%39 = icmp sgt i32 %38, 6
br i1 %39, label %43, label %40
40: ; preds = %36
%41 = tail call i32 @strlen(i8* %37)
%42 = icmp eq i32 %41, 0
br i1 %42, label %60, label %50
43: ; preds = %36
%44 = load i32, i32* @stderr
%45 = tail call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
br label %121
46: ; preds = %50
%47 = tail call i32 @strlen(i8* %37)
%48 = zext i32 %47 to i64
%49 = icmp ult i64 %56, %48
br i1 %49, label %50, label %60
50: ; preds = %40, %46
%51 = phi i64 [ %56, %46 ], [ 0, %40 ]
%52 = getelementptr inbounds i8, i8* %37, i64 %51
%53 = load i8, i8* %52
%54 = tail call i32 @isdigit(i8 signext %53)
%55 = icmp eq i32 %54, 0
%56 = add nuw nsw i64 %51, 1
br i1 %55, label %57, label %46
57: ; preds = %50
%58 = load i32, i32* @stderr
%59 = tail call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0))
br label %121
60: ; preds = %46, %40
%61 = load i32, i32* @optind
%62 = add nsw i32 %0, -2
%63 = icmp eq i32 %61, %62
br i1 %63, label %67, label %64
64: ; preds = %60
%65 = load i32, i32* @stderr
%66 = tail call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0))
br label %121
67: ; preds = %60
%68 = sext i32 %61 to i64
%69 = getelementptr inbounds i8*, i8** %1, i64 %68
%70 = load i8*, i8** %69
%71 = tail call i32* @fopen(i8* %70, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%72 = icmp eq i32* %71, null
br i1 %72, label %73, label %77
73: ; preds = %67
%74 = load i32, i32* @stderr
%75 = load i8*, i8** %69
%76 = tail call i32 (i32, i8*, ...) @fprintf(i32 %74, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i8* %75)
br label %121
77: ; preds = %67
%78 = add nsw i32 %61, 1
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8*, i8** %1, i64 %79
%81 = load i8*, i8** %80
%82 = tail call i32* @fopen(i8* %81, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%83 = icmp eq i32* %82, null
br i1 %83, label %84, label %88
84: ; preds = %77
%85 = load i32, i32* @stderr
%86 = load i8*, i8** %80
%87 = tail call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), i8* %86)
br label %121
88: ; preds = %77
%89 = load i8*, i8** %80
%90 = tail call i32 @strlen(i8* %89)
%91 = add nsw i32 %90, 20
%92 = tail call i32 @strlen(i8* %37)
%93 = add nsw i32 %91, %92
%94 = tail call i64 @malloc(i32 %93)
%95 = inttoptr i64 %94 to i8*
%96 = tail call i32 @strcpy(i8* %95, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.12, i64 0, i64 0))
%97 = load i8*, i8** %80
%98 = tail call i32 @strcat(i8* %95, i8* %97)
%99 = tail call i32 @strcat(i8* %95, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
%100 = tail call i32 @strcat(i8* %95, i8* %37)
%101 = tail call i64 @system(i8* %95)
%102 = icmp eq i64 %101, 0
br i1 %102, label %106, label %103
103: ; preds = %88
%104 = load i32, i32* @stderr
%105 = tail call i32 (i32, i8*, ...) @fprintf(i32 %104, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.14, i64 0, i64 0))
br label %121
106: ; preds = %88
%107 = tail call i32 @free(i8* %95)
%108 = tail call i32 @sleep(i32 2)
%109 = call i64 @fread(i8* %3, i32 1, i32 1, i32* %71)
%110 = icmp eq i64 %109, 0
br i1 %110, label %117, label %111
111: ; preds = %106, %111
%112 = load i8, i8* %3
%113 = sext i8 %112 to i32
%114 = tail call i32 @fputc(i32 %113, i32* %82)
%115 = call i64 @fread(i8* %3, i32 1, i32 1, i32* %71)
%116 = icmp eq i64 %115, 0
br i1 %116, label %117, label %111
117: ; preds = %111, %106
%118 = tail call i32 @sleep(i32 2)
%119 = tail call i32 @fclose(i32* %71)
%120 = tail call i32 @fclose(i32* %82)
br label %121
121: ; preds = %57, %73, %103, %117, %84, %64, %43, %33, %31, %13
%122 = phi i32 [ 1, %33 ], [ 1, %31 ], [ 0, %13 ], [ 1, %43 ], [ 1, %57 ], [ 1, %64 ], [ 1, %73 ], [ 1, %84 ], [ 1, %103 ], [ 0, %117 ]
ret i32 %122
}