#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 */
struct termios {
  int c_cflag;
  int *c_cc;
};
typedef int /*<<< orphan*/ config1;
typedef int /*<<< orphan*/ config;

/* Variables and functions */
int B57600;
int CLOCAL;
int CREAD;
int CS8;
int CSTOPB;
int O_NOCTTY;
int O_RDWR;
int /*<<< orphan*/ TCIFLUSH;
int /*<<< orphan*/ TCIOFLUSH;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ memset(struct termios *, int /*<<< orphan*/, int);
int open(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, unsigned char *, int);
int /*<<< orphan*/ tcflush(int, int /*<<< orphan*/);
int /*<<< orphan*/ tcgetattr(int, struct termios *);
scalar_t__ tcsetattr(int, int /*<<< orphan*/, struct termios *);
int /*<<< orphan*/ write(int, unsigned char *, int);
int main(int argc, char *argv[]) {
  int fd;
  int i;
  unsigned char send_byte = 0x55;
  unsigned char recv_byte = 0;
  struct termios config, config1;
  if (argc < 2) {
    printf("Missing device file name in program argument list\n");
    return 1;
  }
  printf("Device selected is %s\n", argv[1]);
  fd = open(argv[1], O_RDWR | O_NOCTTY);
  if (fd == -1) {
    printf("Dev file open failed\n");
    return 1;
  }
  memset(&config, 0, sizeof(config));
  memset(&config1, 0, sizeof(config1));
  config.c_cflag = CSTOPB;
  config.c_cflag |= B57600 | CS8 | CREAD | CLOCAL;
  config.c_cc[VMIN] = 1;
  config.c_cc[VTIME] = 0;
  tcflush(fd, TCIFLUSH);
  if (tcsetattr(fd, TCSANOW, &config)) {
    printf("Error in setting terminal configs\n");
    return 1;
  }
  tcgetattr(fd, &config1);
  printf("Requested config c_cflag is 0x%x\n", config.c_cflag);
  printf("Actual set c_cflag is 0x%x\n", config1.c_cflag);
  write(fd, &send_byte, 1);
  write(fd, &send_byte, 1);
  write(fd, &send_byte, 1);
  write(fd, &send_byte, 1);
  tcflush(fd, TCIOFLUSH);
  for (i = 0; i <= 10; i++) {
    write(fd, &send_byte, 1);
    read(fd, &recv_byte, 1);
    printf("Send => 0x%x\n", send_byte);
    printf("Recv <= 0x%x\n", recv_byte);
    tcflush(fd, TCIOFLUSH);
  }
  if (recv_byte == 0x55)
    printf("Success: ST NFC Device woken up !!\n");
  else
    printf("Error: ST NFC Device NOT woken !!\n");
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x55,-0x19(%rbp)
movb   $0x0,-0x1a(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11d2 <main+0x42>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    142e <main+0x29e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2df1(%rip),%rax
mov    (%rax),%esi
mov    0x2da8(%rip),%rax
or     (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    122e <main+0x9e>
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    142e <main+0x29e>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
mov    0x2d33(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d5f(%rip),%rax
mov    (%rax),%eax
mov    0x2d66(%rip),%rcx
or     (%rcx),%eax
mov    0x2d65(%rip),%rcx
or     (%rcx),%eax
mov    0x2d04(%rip),%rcx
or     (%rcx),%eax
or     -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
mov    0x2d39(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x28(%rbp),%rax
mov    0x2cf4(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x14(%rbp),%edi
mov    0x2cf8(%rip),%rax
mov    (%rax),%esi
call   1040 <tcflush@plt>
mov    -0x14(%rbp),%edi
mov    0x2d17(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   10a0 <tcsetattr@plt>
cmp    $0x0,%rax
je     12f8 <main+0x168>
lea    0xd7b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    142e <main+0x29e>
mov    -0x14(%rbp),%edi
lea    -0x40(%rbp),%rsi
call   1090 <tcgetattr@plt>
mov    -0x30(%rbp),%esi
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%esi
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x14(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x14(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x14(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x14(%rbp),%edi
mov    0x2c2c(%rip),%rax
mov    (%rax),%esi
call   1040 <tcflush@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jg     13f1 <main+0x261>
mov    -0x14(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x14(%rbp),%edi
lea    -0x1a(%rbp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
movzbl -0x19(%rbp),%esi
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movzbl -0x1a(%rbp),%esi
lea    0xd04(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
mov    0x2bc4(%rip),%rax
mov    (%rax),%esi
call   1040 <tcflush@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1382 <main+0x1f2>
movzbl -0x1a(%rbp),%eax
cmp    $0x55,%eax
jne    1411 <main+0x281>
lea    0xcd8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    141f <main+0x28f>
lea    0xce9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movb   $0x55,0x7(%rsp)
movb   $0x0,0x6(%rsp)
cmp    $0x1,%edi
jg     11c9 <main+0x29>
lea    0xf29(%rip),%rdi
jmp    12b9 <main+0x119>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0xe29(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rbx),%rdi
mov    0x2dff(%rip),%rax
mov    0x2db8(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
call   10c0 <open@plt>
cmp    $0xffffffff,%eax
je     12b2 <main+0x112>
mov    %eax,%ebx
lea    0x8(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1070 <memset@plt>
lea    0x18(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1070 <memset@plt>
mov    0x2d58(%rip),%rax
mov    0x2d89(%rip),%rcx
mov    (%rcx),%ecx
mov    0x2d90(%rip),%rdx
mov    0x2d91(%rip),%rsi
mov    0x2d32(%rip),%rdi
or     (%rax),%ecx
or     (%rdx),%ecx
or     (%rsi),%ecx
or     (%rdi),%ecx
mov    %ecx,0x8(%rsp)
mov    0x10(%rsp),%rax
mov    0x2d62(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x1,(%rax,%rcx,4)
mov    0x2d21(%rip),%rcx
mov    (%rcx),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    0x2d28(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1050 <tcflush@plt>
mov    0x2d48(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    %r14,%rdx
call   10b0 <tcsetattr@plt>
test   %rax,%rax
je     12d2 <main+0x132>
lea    0xe06(%rip),%rdi
jmp    12b9 <main+0x119>
lea    0xe1f(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x18(%rsp),%rsi
mov    %ebx,%edi
call   10a0 <tcgetattr@plt>
mov    0x8(%rsp),%esi
lea    0xd2e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rsp),%esi
lea    0xd3e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x7(%rsp),%rbp
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    0x2c56(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1050 <tcflush@plt>
mov    $0xb,%r14d
lea    0x6(%rsp),%r15
lea    0xcf0(%rip),%r12
lea    0xcf7(%rip),%r13
nopl   0x0(%rax)
mov    %ebx,%edi
lea    0x7(%rsp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1090 <read@plt>
mov    %r12,%rdi
mov    $0x55,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movzbl 0x6(%rsp),%ebp
movzbl %bpl,%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2be7(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   1050 <tcflush@plt>
add    $0xffffffff,%r14d
jne    1370 <main+0x1d0>
cmp    $0x55,%bpl
lea    0xcc0(%rip),%rax
lea    0xc97(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
call   1080 <close@plt>
xor    %eax,%eax
jmp    12c3 <main+0x123>

LLVM IR (-O0):
%struct.termios = type { i32, i32* }
@.str = [51 x i8] c"Missing device file name in program argument list\0A\00"
@.str.1 = [23 x i8] c"Device selected is %s\0A\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@.str.2 = [22 x i8] c"Dev file open failed\0A\00"
@CSTOPB = global i32 0
@B57600 = global i32 0
@CS8 = global i32 0
@CREAD = global i32 0
@CLOCAL = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCIFLUSH = global i32 0
@TCSANOW = global i32 0
@.str.3 = [35 x i8] c"Error in setting terminal configs\0A\00"
@.str.4 = [34 x i8] c"Requested config c_cflag is 0x%x\0A\00"
@.str.5 = [28 x i8] c"Actual set c_cflag is 0x%x\0A\00"
@TCIOFLUSH = global i32 0
@.str.6 = [14 x i8] c"Send => 0x%x\0A\00"
@.str.7 = [14 x i8] c"Recv <= 0x%x\0A\00"
@.str.8 = [36 x i8] c"Success: ST NFC Device woken up !!\0A\00"
@.str.9 = [35 x i8] c"Error: ST NFC Device NOT woken !!\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca i8
%10 = alloca %struct.termios
%11 = alloca %struct.termios
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 85, i8* %8
store i8 0, i8* %9
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %115
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = load i32, i32* @O_RDWR
%25 = load i32, i32* @O_NOCTTY
%26 = or i32 %24, %25
%27 = call i32 @open(i8* %23, i32 %26)
store i32 %27, i32* %6
%28 = load i32, i32* %6
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %32
30: ; preds = %16
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %115
32: ; preds = %16
%33 = call i32 @memset(%struct.termios* %10, i32 0, i32 16)
%34 = call i32 @memset(%struct.termios* %11, i32 0, i32 16)
%35 = load i32, i32* @CSTOPB
%36 = getelementptr inbounds %struct.termios, %struct.termios* %10, i32 0, i32 0
store i32 %35, i32* %36
%37 = load i32, i32* @B57600
%38 = load i32, i32* @CS8
%39 = or i32 %37, %38
%40 = load i32, i32* @CREAD
%41 = or i32 %39, %40
%42 = load i32, i32* @CLOCAL
%43 = or i32 %41, %42
%44 = getelementptr inbounds %struct.termios, %struct.termios* %10, i32 0, i32 0
%45 = load i32, i32* %44
%46 = or i32 %45, %43
store i32 %46, i32* %44
%47 = getelementptr inbounds %struct.termios, %struct.termios* %10, i32 0, i32 1
%48 = load i32*, i32** %47
%49 = load i64, i64* @VMIN
%50 = getelementptr inbounds i32, i32* %48, i64 %49
store i32 1, i32* %50
%51 = getelementptr inbounds %struct.termios, %struct.termios* %10, i32 0, i32 1
%52 = load i32*, i32** %51
%53 = load i64, i64* @VTIME
%54 = getelementptr inbounds i32, i32* %52, i64 %53
store i32 0, i32* %54
%55 = load i32, i32* %6
%56 = load i32, i32* @TCIFLUSH
%57 = call i32 @tcflush(i32 %55, i32 %56)
%58 = load i32, i32* %6
%59 = load i32, i32* @TCSANOW
%60 = call i64 @tcsetattr(i32 %58, i32 %59, %struct.termios* %10)
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %32
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %115
64: ; preds = %32
%65 = load i32, i32* %6
%66 = call i32 @tcgetattr(i32 %65, %struct.termios* %11)
%67 = getelementptr inbounds %struct.termios, %struct.termios* %10, i32 0, i32 0
%68 = load i32, i32* %67
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %68)
%70 = getelementptr inbounds %struct.termios, %struct.termios* %11, i32 0, i32 0
%71 = load i32, i32* %70
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %71)
%73 = load i32, i32* %6
%74 = call i32 @write(i32 %73, i8* %8, i32 1)
%75 = load i32, i32* %6
%76 = call i32 @write(i32 %75, i8* %8, i32 1)
%77 = load i32, i32* %6
%78 = call i32 @write(i32 %77, i8* %8, i32 1)
%79 = load i32, i32* %6
%80 = call i32 @write(i32 %79, i8* %8, i32 1)
%81 = load i32, i32* %6
%82 = load i32, i32* @TCIOFLUSH
%83 = call i32 @tcflush(i32 %81, i32 %82)
store i32 0, i32* %7
br label %84
84: ; preds = %101, %64
%85 = load i32, i32* %7
%86 = icmp sle i32 %85, 10
br i1 %86, label %87, label %104
87: ; preds = %84
%88 = load i32, i32* %6
%89 = call i32 @write(i32 %88, i8* %8, i32 1)
%90 = load i32, i32* %6
%91 = call i32 @read(i32 %90, i8* %9, i32 1)
%92 = load i8, i8* %8
%93 = zext i8 %92 to i32
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %93)
%95 = load i8, i8* %9
%96 = zext i8 %95 to i32
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %96)
%98 = load i32, i32* %6
%99 = load i32, i32* @TCIOFLUSH
%100 = call i32 @tcflush(i32 %98, i32 %99)
br label %101
101: ; preds = %87
%102 = load i32, i32* %7
%103 = add nsw i32 %102, 1
store i32 %103, i32* %7
br label %84
104: ; preds = %84
%105 = load i8, i8* %9
%106 = zext i8 %105 to i32
%107 = icmp eq i32 %106, 85
br i1 %107, label %108, label %110
108: ; preds = %104
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
br label %112
110: ; preds = %104
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0))
br label %112
112: ; preds = %110, %108
%113 = load i32, i32* %6
%114 = call i32 @close(i32 %113)
store i32 0, i32* %3
br label %115
115: ; preds = %112, %62, %30, %14
%116 = load i32, i32* %3
ret i32 %116
}

LLVM IR (-O2):
%struct.termios = type { i32, i32* }
@.str.1 = [23 x i8] c"Device selected is %s\0A\00"
@O_RDWR = global i32 0
@O_NOCTTY = global i32 0
@CSTOPB = global i32 0
@B57600 = global i32 0
@CS8 = global i32 0
@CREAD = global i32 0
@CLOCAL = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCIFLUSH = global i32 0
@TCSANOW = global i32 0
@.str.4 = [34 x i8] c"Requested config c_cflag is 0x%x\0A\00"
@.str.5 = [28 x i8] c"Actual set c_cflag is 0x%x\0A\00"
@TCIOFLUSH = global i32 0
@.str.6 = [14 x i8] c"Send => 0x%x\0A\00"
@.str.7 = [14 x i8] c"Recv <= 0x%x\0A\00"
@str = [34 x i8] c"Error: ST NFC Device NOT woken !!\00"
@str.10 = [35 x i8] c"Success: ST NFC Device woken up !!\00"
@str.11 = [34 x i8] c"Error in setting terminal configs\00"
@str.12 = [21 x i8] c"Dev file open failed\00"
@str.13 = [50 x i8] c"Missing device file name in program argument list\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca %struct.termios
%6 = alloca %struct.termios
store i8 85, i8* %3
store i8 0, i8* %4
%7 = bitcast %struct.termios* %5 to i8*
%8 = bitcast %struct.termios* %6 to i8*
%9 = icmp slt i32 %0, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.13, i64 0, i64 0))
br label %80
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %13
%17 = load i32, i32* @O_RDWR
%18 = load i32, i32* @O_NOCTTY
%19 = or i32 %18, %17
%20 = tail call i32 @open(i8* %16, i32 %19)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %24
22: ; preds = %12
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.12, i64 0, i64 0))
br label %80
24: ; preds = %12
%25 = call i32 @memset(%struct.termios* %5, i32 0, i32 16)
%26 = call i32 @memset(%struct.termios* %6, i32 0, i32 16)
%27 = load i32, i32* @CSTOPB
%28 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 0
%29 = load i32, i32* @B57600
%30 = load i32, i32* @CS8
%31 = load i32, i32* @CREAD
%32 = load i32, i32* @CLOCAL
%33 = or i32 %29, %27
%34 = or i32 %33, %30
%35 = or i32 %34, %31
%36 = or i32 %35, %32
store i32 %36, i32* %28
%37 = getelementptr inbounds %struct.termios, %struct.termios* %5, i64 0, i32 1
%38 = load i32*, i32** %37
%39 = load i64, i64* @VMIN
%40 = getelementptr inbounds i32, i32* %38, i64 %39
store i32 1, i32* %40
%41 = load i64, i64* @VTIME
%42 = getelementptr inbounds i32, i32* %38, i64 %41
store i32 0, i32* %42
%43 = load i32, i32* @TCIFLUSH
%44 = call i32 @tcflush(i32 %20, i32 %43)
%45 = load i32, i32* @TCSANOW
%46 = call i64 @tcsetattr(i32 %20, i32 %45, %struct.termios* %5)
%47 = icmp eq i64 %46, 0
br i1 %47, label %50, label %48
48: ; preds = %24
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.11, i64 0, i64 0))
br label %80
50: ; preds = %24
%51 = call i32 @tcgetattr(i32 %20, %struct.termios* %6)
%52 = load i32, i32* %28
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %52)
%54 = getelementptr inbounds %struct.termios, %struct.termios* %6, i64 0, i32 0
%55 = load i32, i32* %54
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %55)
%57 = call i32 @write(i32 %20, i8* %3, i32 1)
%58 = call i32 @write(i32 %20, i8* %3, i32 1)
%59 = call i32 @write(i32 %20, i8* %3, i32 1)
%60 = call i32 @write(i32 %20, i8* %3, i32 1)
%61 = load i32, i32* @TCIOFLUSH
%62 = call i32 @tcflush(i32 %20, i32 %61)
br label %63
63: ; preds = %50, %63
%64 = phi i32 [ 0, %50 ], [ %73, %63 ]
%65 = call i32 @write(i32 %20, i8* %3, i32 1)
%66 = call i32 @read(i32 %20, i8* %4, i32 1)
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 85)
%68 = load i8, i8* %4
%69 = zext i8 %68 to i32
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i32 %69)
%71 = load i32, i32* @TCIOFLUSH
%72 = call i32 @tcflush(i32 %20, i32 %71)
%73 = add nuw nsw i32 %64, 1
%74 = icmp eq i32 %73, 11
br i1 %74, label %75, label %63
75: ; preds = %63
%76 = icmp eq i8 %68, 85
%77 = select i1 %76, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @str.10, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0)
%78 = call i32 @puts(i8* dereferenceable(1) %77)
%79 = call i32 @close(i32 %20)
br label %80
80: ; preds = %75, %48, %22, %10
%81 = phi i32 [ 1, %10 ], [ 1, %22 ], [ 1, %48 ], [ 0, %75 ]
ret i32 %81
}