#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_iflag;
  int c_lflag;
  scalar_t__ *c_cc;
  int /*<<< orphan*/ c_oflag;
};
typedef int /*<<< orphan*/ speed_t;

/* Variables and functions */
int /*<<< orphan*/ B9600;
int CLOCAL;
int CREAD;
int CRTSCTS;
int CS8;
int CSIZE;
int CSTOPB;
int ECHO;
int ECHOE;
int ICANON;
int ISIG;
int IXANY;
int IXOFF;
int IXON;
int /*<<< orphan*/ OPOST;
int O_NONBLOCK;
int O_RDWR;
int PARENB;
int /*<<< orphan*/ TCSANOW;
size_t VMIN;
size_t VTIME;
int /*<<< orphan*/ cfsetispeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ cfsetospeed(struct termios *, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int open(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int read(int, char *, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdin;
char *strcat(char *, char *);
int strlen(char *);
int /*<<< orphan*/ tcsetattr(int, int /*<<< orphan*/, struct termios *);
int write(int, ...);
void sendCommand(char command) {
  struct termios toptions;
  int port = open("/dev/ttyACM0", O_RDWR | O_NONBLOCK);
  if (port == -1) {
    printf("\nCommunication with Arduino failed");
    return;
  }
  speed_t brate = B9600;
  cfsetispeed(&toptions, brate);
  cfsetospeed(&toptions, brate);
  toptions.c_cflag &= ~PARENB;
  toptions.c_cflag &= ~CSTOPB;
  toptions.c_cflag &= ~CSIZE;
  toptions.c_cflag |= CS8;
  toptions.c_cflag &= ~CRTSCTS;
  toptions.c_cflag |= CREAD | CLOCAL;
  toptions.c_iflag &= ~(IXON | IXOFF | IXANY);
  toptions.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
  toptions.c_oflag &= ~OPOST;
  toptions.c_cc[VMIN] = 0;
  toptions.c_cc[VTIME] = 0;
  tcsetattr(port, TCSANOW, &toptions);
  int resp = 0, len = 0;
  if (command == 'S') {
    printf("Enter the message: ");
    char text[33];
    getchar();
    fgets(text, 32, stdin);
    char *cmd = strcat(&command, text);
    len = strlen(cmd);
    printf("\nSending the command %s", cmd);
    resp = write(port, cmd, len);
  } else {
    char cmd[1];
    cmd[0] = command;
    len = strlen(cmd);
    printf("\nSending the command %c", command);
    resp = write(port, &cmd, len);
  }
  if (resp != len) {
    printf("\nwhole command was not written");
    close(port);
    return;
  }
  printf("\nWaiting...");
  sleep(1);
  printf("\nReading response");
  int maxLen = 20;
  char buffer[maxLen + 1];
  char charRead[1];
  int i = 0;
  while (i < maxLen && charRead[0] != '\n') {
    resp = read(port, charRead, 1);
    if (resp == -1) {
      printf("could not read the response from arduino");
      close(port);
      return;
    } else if (resp == 0) {
      printf("\n    no response yet");
      sleep(1);
      continue;
    }
    buffer[i++] = charRead[0];
  }
  buffer[i] = '\n';
  printf("\nRead: ");
  puts(buffer);
  close(port);
}


x86 assembly (clang, -O0):
<sendCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    0x2df0(%rip),%rax
mov    (%rax),%esi
mov    0x2dd7(%rip),%rax
or     (%rax),%esi
lea    0xdf6(%rip),%rdi
call   10d0 <open@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    122f <sendCommand+0x4f>
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    15de <sendCommand+0x3fe>
mov    0x2d5a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%esi
lea    -0x28(%rbp),%rdi
call   10e0 <cfsetispeed@plt>
mov    -0x30(%rbp),%esi
lea    -0x28(%rbp),%rdi
call   1050 <cfsetospeed@plt>
mov    0x2d5e(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2ccc(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2cf2(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2cf0(%rip),%rax
mov    (%rax),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2ca1(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2cd7(%rip),%rax
mov    (%rax),%eax
mov    0x2c76(%rip),%rcx
or     (%rcx),%eax
or     -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    0x2cf7(%rip),%rax
mov    (%rax),%eax
mov    0x2d0e(%rip),%rcx
or     (%rcx),%eax
mov    0x2c85(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    0x2c63(%rip),%rax
mov    (%rax),%eax
mov    0x2cb2(%rip),%rcx
or     (%rcx),%eax
mov    0x2ca1(%rip),%rcx
or     (%rcx),%eax
mov    0x2c90(%rip),%rcx
or     (%rcx),%eax
xor    $0xffffffff,%eax
and    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    0x2cae(%rip),%rax
mov    (%rax),%eax
xor    $0xffffffff,%eax
and    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2c48(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    0x2c12(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x2c(%rbp),%edi
mov    0x2c55(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   10c0 <tcsetattr@plt>
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movsbl -0x1(%rbp),%eax
cmp    $0x53,%eax
jne    13f5 <sendCommand+0x215>
lea    0xca8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   10b0 <getchar@plt>
lea    -0x60(%rbp),%rdi
mov    0x2c2f(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   10a0 <fgets@plt>
lea    -0x60(%rbp),%rsi
lea    -0x1(%rbp),%rdi
call   10f0 <strcat@plt>
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x38(%rbp)
mov    -0x68(%rbp),%rsi
lea    0xc6f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    -0x68(%rbp),%rsi
mov    -0x38(%rbp),%edx
mov    $0x0,%al
call   1040 <write@plt>
mov    %eax,-0x34(%rbp)
jmp    142d <sendCommand+0x24d>
mov    -0x1(%rbp),%al
mov    %al,-0x69(%rbp)
lea    -0x69(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x38(%rbp)
movsbl -0x1(%rbp),%esi
lea    0xc4a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    -0x38(%rbp),%edx
lea    -0x69(%rbp),%rsi
mov    $0x0,%al
call   1040 <write@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x38(%rbp),%eax
je     1454 <sendCommand+0x274>
lea    0xc34(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x2c(%rbp),%edi
call   1080 <close@plt>
jmp    15de <sendCommand+0x3fe>
lea    0xc38(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x99(%rbp)
call   1070 <printf@plt>
mov    $0x1,%edi
call   1100 <sleep@plt>
mov    -0x99(%rbp),%al
lea    0xc20(%rip),%rdi
call   1070 <printf@plt>
movl   $0x14,-0x70(%rbp)
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
mov    %rcx,-0x78(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x98(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x80(%rbp)
movl   $0x0,-0x88(%rbp)
mov    -0x88(%rbp),%ecx
xor    %eax,%eax
cmp    -0x70(%rbp),%ecx
mov    %al,-0x9a(%rbp)
jge    14eb <sendCommand+0x30b>
movsbl -0x81(%rbp),%eax
cmp    $0xa,%eax
setne  %al
mov    %al,-0x9a(%rbp)
mov    -0x9a(%rbp),%al
test   $0x1,%al
jne    14fe <sendCommand+0x31e>
jmp    1599 <sendCommand+0x3b9>
mov    -0x2c(%rbp),%edi
lea    -0x81(%rbp),%rsi
mov    $0x1,%edx
call   1090 <read@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    1544 <sendCommand+0x364>
lea    0xb8b(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x2c(%rbp),%edi
call   1080 <close@plt>
movl   $0x1,-0x8c(%rbp)
jmp    15d7 <sendCommand+0x3f7>
cmpl   $0x0,-0x34(%rbp)
jne    156b <sendCommand+0x38b>
lea    0xb85(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x1,%edi
call   1100 <sleep@plt>
jmp    14c1 <sendCommand+0x2e1>
jmp    1570 <sendCommand+0x390>
mov    -0x98(%rbp),%rax
mov    -0x81(%rbp),%dl
mov    -0x88(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x88(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    14c1 <sendCommand+0x2e1>
mov    -0x98(%rbp),%rax
movslq -0x88(%rbp),%rcx
movb   $0xa,(%rax,%rcx,1)
lea    0xb3d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x98(%rbp),%rdi
call   1030 <puts@plt>
mov    -0x2c(%rbp),%edi
call   1080 <close@plt>
movl   $0x0,-0x8c(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendCommand>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %edi,%r14d
mov    %r14b,-0x29(%rbp)
mov    0x2de9(%rip),%rax
mov    0x2dd2(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xdef(%rip),%rdi
call   10d0 <open@plt>
cmp    $0xffffffff,%eax
je     1383 <sendCommand+0x1a3>
mov    %eax,%r12d
mov    0x2d67(%rip),%rax
mov    (%rax),%ebx
lea    -0x58(%rbp),%r15
mov    %r15,%rdi
mov    %ebx,%esi
call   10e0 <cfsetispeed@plt>
mov    %r15,%rdi
mov    %ebx,%esi
call   1050 <cfsetospeed@plt>
mov    0x2d6e(%rip),%rax
mov    (%rax),%eax
mov    0x2ce5(%rip),%rcx
or     (%rcx),%eax
mov    0x2d14(%rip),%rcx
or     (%rcx),%eax
not    %eax
and    -0x58(%rbp),%eax
mov    0x2d16(%rip),%rcx
or     (%rcx),%eax
mov    0x2ccd(%rip),%rcx
mov    (%rcx),%ecx
not    %ecx
and    %eax,%ecx
mov    0x2d08(%rip),%rax
mov    0x2ca9(%rip),%rdx
or     (%rax),%ecx
or     (%rdx),%ecx
mov    %ecx,-0x58(%rbp)
mov    0x2d2b(%rip),%rax
mov    0x2d44(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2cb9(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,-0x54(%rbp)
mov    0x2c9b(%rip),%rax
mov    0x2cec(%rip),%rcx
mov    (%rcx),%ecx
or     (%rax),%ecx
mov    0x2cd9(%rip),%rax
or     (%rax),%ecx
mov    0x2cc8(%rip),%rax
or     (%rax),%ecx
not    %ecx
and    %ecx,-0x50(%rbp)
mov    0x2cea(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,-0x40(%rbp)
mov    -0x48(%rbp),%rax
mov    0x2c88(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2c56(%rip),%rcx
mov    (%rcx),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    0x2c9c(%rip),%rax
mov    (%rax),%esi
mov    %r12d,%edi
mov    %r15,%rdx
call   10c0 <tcsetattr@plt>
cmp    $0x53,%r14b
jne    139f <sendCommand+0x1bf>
lea    0xd02(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   10b0 <getchar@plt>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edx
lea    -0x80(%rbp),%r14
mov    %r14,%rdi
mov    $0x20,%esi
call   10a0 <fgets@plt>
lea    -0x29(%rbp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   10f0 <strcat@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %eax,%r15d
lea    0xccd(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    13c4 <sendCommand+0x1e4>
lea    0xc83(%rip),%rdi
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <printf@plt>
mov    %r14b,-0x80(%rbp)
lea    -0x80(%rbp),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %eax,%r15d
movsbl %r14b,%esi
lea    0xc9f(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   1040 <write@plt>
cmp    %r15d,%eax
jne    1471 <sendCommand+0x291>
lea    0xcaf(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   1100 <sleep@plt>
lea    0xca3(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rsp,-0x38(%rbp)
mov    %rsp,%r14
add    $0xffffffffffffffe0,%r14
mov    %r14,%rsp
lea    -0x80(%rbp),%rbx
lea    0xcbe(%rip),%r15
xor    %r13d,%r13d
nop
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1090 <read@plt>
test   %eax,%eax
jne    1450 <sendCommand+0x270>
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%edi
call   1100 <sleep@plt>
cmpb   $0xa,-0x80(%rbp)
jne    1420 <sendCommand+0x240>
jmp    1489 <sendCommand+0x2a9>
cmp    $0xffffffff,%eax
je     14ab <sendCommand+0x2cb>
movzbl -0x80(%rbp),%ecx
lea    0x1(%r13),%rax
mov    %cl,(%r14,%r13,1)
cmp    $0x12,%r13
ja     148c <sendCommand+0x2ac>
mov    %rax,%r13
cmp    $0xa,%cl
jne    1420 <sendCommand+0x240>
jmp    148c <sendCommand+0x2ac>
lea    0xbfc(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12d,%edi
call   1080 <close@plt>
jmp    14c8 <sendCommand+0x2e8>
mov    %r13,%rax
cltq
movb   $0xa,(%r14,%rax,1)
lea    0xc55(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
jmp    14b9 <sendCommand+0x2d9>
lea    0xbff(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    -0x38(%rbp),%rbx
mov    %r12d,%edi
call   1080 <close@plt>
mov    %rbx,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.termios = type { i32, i32, i32, i64*, i32 }
@.str = [13 x i8] c"/dev/ttyACM0\00"
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [35 x i8] c"\0ACommunication with Arduino failed\00"
@B9600 = global i32 0
@PARENB = global i32 0
@CSTOPB = global i32 0
@CSIZE = global i32 0
@CS8 = global i32 0
@CRTSCTS = global i32 0
@CREAD = global i32 0
@CLOCAL = global i32 0
@IXON = global i32 0
@IXOFF = global i32 0
@IXANY = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ISIG = global i32 0
@OPOST = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCSANOW = global i32 0
@.str.2 = [20 x i8] c"Enter the message: \00"
@stdin = global i32 0
@.str.3 = [24 x i8] c"\0ASending the command %s\00"
@.str.4 = [24 x i8] c"\0ASending the command %c\00"
@.str.5 = [31 x i8] c"\0Awhole command was not written\00"
@.str.6 = [12 x i8] c"\0AWaiting...\00"
@.str.7 = [18 x i8] c"\0AReading response\00"
@.str.8 = [41 x i8] c"could not read the response from arduino\00"
@.str.9 = [21 x i8] c"\0A no response yet\00"
@.str.10 = [8 x i8] c"\0ARead: \00"
define void @sendCommand(i8 signext %0) {
%2 = alloca i8
%3 = alloca %struct.termios
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [33 x i8]
%9 = alloca i8*
%10 = alloca [1 x i8]
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
%14 = alloca [1 x i8]
%15 = alloca i32
%16 = alloca i32
store i8 %0, i8* %2
%17 = load i32, i32* @O_RDWR
%18 = load i32, i32* @O_NONBLOCK
%19 = or i32 %17, %18
%20 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %19)
store i32 %20, i32* %4
%21 = load i32, i32* %4
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %25
23: ; preds = %1
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %190
25: ; preds = %1
%26 = load i32, i32* @B9600
store i32 %26, i32* %5
%27 = load i32, i32* %5
%28 = call i32 @cfsetispeed(%struct.termios* %3, i32 %27)
%29 = load i32, i32* %5
%30 = call i32 @cfsetospeed(%struct.termios* %3, i32 %29)
%31 = load i32, i32* @PARENB
%32 = xor i32 %31, -1
%33 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%34 = load i32, i32* %33
%35 = and i32 %34, %32
store i32 %35, i32* %33
%36 = load i32, i32* @CSTOPB
%37 = xor i32 %36, -1
%38 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%39 = load i32, i32* %38
%40 = and i32 %39, %37
store i32 %40, i32* %38
%41 = load i32, i32* @CSIZE
%42 = xor i32 %41, -1
%43 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%44 = load i32, i32* %43
%45 = and i32 %44, %42
store i32 %45, i32* %43
%46 = load i32, i32* @CS8
%47 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%48 = load i32, i32* %47
%49 = or i32 %48, %46
store i32 %49, i32* %47
%50 = load i32, i32* @CRTSCTS
%51 = xor i32 %50, -1
%52 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%53 = load i32, i32* %52
%54 = and i32 %53, %51
store i32 %54, i32* %52
%55 = load i32, i32* @CREAD
%56 = load i32, i32* @CLOCAL
%57 = or i32 %55, %56
%58 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 0
%59 = load i32, i32* %58
%60 = or i32 %59, %57
store i32 %60, i32* %58
%61 = load i32, i32* @IXON
%62 = load i32, i32* @IXOFF
%63 = or i32 %61, %62
%64 = load i32, i32* @IXANY
%65 = or i32 %63, %64
%66 = xor i32 %65, -1
%67 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 1
%68 = load i32, i32* %67
%69 = and i32 %68, %66
store i32 %69, i32* %67
%70 = load i32, i32* @ICANON
%71 = load i32, i32* @ECHO
%72 = or i32 %70, %71
%73 = load i32, i32* @ECHOE
%74 = or i32 %72, %73
%75 = load i32, i32* @ISIG
%76 = or i32 %74, %75
%77 = xor i32 %76, -1
%78 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 2
%79 = load i32, i32* %78
%80 = and i32 %79, %77
store i32 %80, i32* %78
%81 = load i32, i32* @OPOST
%82 = xor i32 %81, -1
%83 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 4
%84 = load i32, i32* %83
%85 = and i32 %84, %82
store i32 %85, i32* %83
%86 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 3
%87 = load i64*, i64** %86
%88 = load i64, i64* @VMIN
%89 = getelementptr inbounds i64, i64* %87, i64 %88
store i64 0, i64* %89
%90 = getelementptr inbounds %struct.termios, %struct.termios* %3, i32 0, i32 3
%91 = load i64*, i64** %90
%92 = load i64, i64* @VTIME
%93 = getelementptr inbounds i64, i64* %91, i64 %92
store i64 0, i64* %93
%94 = load i32, i32* %4
%95 = load i32, i32* @TCSANOW
%96 = call i32 @tcsetattr(i32 %94, i32 %95, %struct.termios* %3)
store i32 0, i32* %6
store i32 0, i32* %7
%97 = load i8, i8* %2
%98 = sext i8 %97 to i32
%99 = icmp eq i32 %98, 83
br i1 %99, label %100, label %116
100: ; preds = %25
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%102 = call i32 (...) @getchar()
%103 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 0
%104 = load i32, i32* @stdin
%105 = call i32 @fgets(i8* %103, i32 32, i32 %104)
%106 = getelementptr inbounds [33 x i8], [33 x i8]* %8, i64 0, i64 0
%107 = call i8* @strcat(i8* %2, i8* %106)
store i8* %107, i8** %9
%108 = load i8*, i8** %9
%109 = call i32 @strlen(i8* %108)
store i32 %109, i32* %7
%110 = load i8*, i8** %9
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %110)
%112 = load i32, i32* %4
%113 = load i8*, i8** %9
%114 = load i32, i32* %7
%115 = call i32 (i32, ...) @write(i32 %112, i8* %113, i32 %114)
store i32 %115, i32* %6
br label %127
116: ; preds = %25
%117 = load i8, i8* %2
%118 = getelementptr inbounds [1 x i8], [1 x i8]* %10, i64 0, i64 0
store i8 %117, i8* %118
%119 = getelementptr inbounds [1 x i8], [1 x i8]* %10, i64 0, i64 0
%120 = call i32 @strlen(i8* %119)
store i32 %120, i32* %7
%121 = load i8, i8* %2
%122 = sext i8 %121 to i32
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %122)
%124 = load i32, i32* %4
%125 = load i32, i32* %7
%126 = call i32 (i32, ...) @write(i32 %124, [1 x i8]* %10, i32 %125)
store i32 %126, i32* %6
br label %127
127: ; preds = %116, %100
%128 = load i32, i32* %6
%129 = load i32, i32* %7
%130 = icmp ne i32 %128, %129
br i1 %130, label %131, label %135
131: ; preds = %127
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%133 = load i32, i32* %4
%134 = call i32 @close(i32 %133)
br label %190
135: ; preds = %127
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%137 = call i32 @sleep(i32 1)
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
store i32 20, i32* %11
%139 = load i32, i32* %11
%140 = add nsw i32 %139, 1
%141 = zext i32 %140 to i64
%142 = call i8* @llvm.stacksave()
store i8* %142, i8** %12
%143 = alloca i8, i64 %141
store i64 %141, i64* %13
store i32 0, i32* %15
br label %144
144: ; preds = %172, %168, %135
%145 = load i32, i32* %15
%146 = load i32, i32* %11
%147 = icmp slt i32 %145, %146
br i1 %147, label %148, label %153
148: ; preds = %144
%149 = getelementptr inbounds [1 x i8], [1 x i8]* %14, i64 0, i64 0
%150 = load i8, i8* %149
%151 = sext i8 %150 to i32
%152 = icmp ne i32 %151, 10
br label %153
153: ; preds = %148, %144
%154 = phi i1 [ false, %144 ], [ %152, %148 ]
br i1 %154, label %155, label %179
155: ; preds = %153
%156 = load i32, i32* %4
%157 = getelementptr inbounds [1 x i8], [1 x i8]* %14, i64 0, i64 0
%158 = call i32 @read(i32 %156, i8* %157, i32 1)
store i32 %158, i32* %6
%159 = load i32, i32* %6
%160 = icmp eq i32 %159, -1
br i1 %160, label %161, label %165
161: ; preds = %155
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
%163 = load i32, i32* %4
%164 = call i32 @close(i32 %163)
store i32 1, i32* %16
br label %187
165: ; preds = %155
%166 = load i32, i32* %6
%167 = icmp eq i32 %166, 0
br i1 %167, label %168, label %171
168: ; preds = %165
%169 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
%170 = call i32 @sleep(i32 1)
br label %144
171: ; preds = %165
br label %172
172: ; preds = %171
%173 = getelementptr inbounds [1 x i8], [1 x i8]* %14, i64 0, i64 0
%174 = load i8, i8* %173
%175 = load i32, i32* %15
%176 = add nsw i32 %175, 1
store i32 %176, i32* %15
%177 = sext i32 %175 to i64
%178 = getelementptr inbounds i8, i8* %143, i64 %177
store i8 %174, i8* %178
br label %144
179: ; preds = %153
%180 = load i32, i32* %15
%181 = sext i32 %180 to i64
%182 = getelementptr inbounds i8, i8* %143, i64 %181
store i8 10, i8* %182
%183 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
%184 = call i32 @puts(i8* %143)
%185 = load i32, i32* %4
%186 = call i32 @close(i32 %185)
store i32 0, i32* %16
br label %187
187: ; preds = %179, %161
%188 = load i8*, i8** %12
%189 = load i32, i32* %16
switch i32 %189, label %191 [
i32 0, label %190
i32 1, label %190
]
190: ; preds = %23, %131, %187, %187
ret void
191: ; preds = %187
unreachable
}

LLVM IR (-O2):
%struct.termios = type { i32, i32, i32, i64*, i32 }
@.str = [13 x i8] c"/dev/ttyACM0\00"
@O_RDWR = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [35 x i8] c"\0ACommunication with Arduino failed\00"
@B9600 = global i32 0
@PARENB = global i32 0
@CSTOPB = global i32 0
@CSIZE = global i32 0
@CS8 = global i32 0
@CRTSCTS = global i32 0
@CREAD = global i32 0
@CLOCAL = global i32 0
@IXON = global i32 0
@IXOFF = global i32 0
@IXANY = global i32 0
@ICANON = global i32 0
@ECHO = global i32 0
@ECHOE = global i32 0
@ISIG = global i32 0
@OPOST = global i32 0
@VMIN = global i64 0
@VTIME = global i64 0
@TCSANOW = global i32 0
@.str.2 = [20 x i8] c"Enter the message: \00"
@stdin = global i32 0
@.str.3 = [24 x i8] c"\0ASending the command %s\00"
@.str.4 = [24 x i8] c"\0ASending the command %c\00"
@.str.5 = [31 x i8] c"\0Awhole command was not written\00"
@.str.6 = [12 x i8] c"\0AWaiting...\00"
@.str.7 = [18 x i8] c"\0AReading response\00"
@.str.8 = [41 x i8] c"could not read the response from arduino\00"
@.str.9 = [21 x i8] c"\0A no response yet\00"
@.str.10 = [8 x i8] c"\0ARead: \00"
define void @sendCommand(i8 signext %0) {
%2 = alloca i8
%3 = alloca %struct.termios
%4 = alloca [33 x i8]
%5 = alloca [1 x i8]
%6 = alloca [1 x i8]
store i8 %0, i8* %2
%7 = bitcast %struct.termios* %3 to i8*
%8 = load i32, i32* @O_RDWR
%9 = load i32, i32* @O_NONBLOCK
%10 = or i32 %9, %8
%11 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %129
15: ; preds = %1
%16 = load i32, i32* @B9600
%17 = call i32 @cfsetispeed(%struct.termios* %3, i32 %16)
%18 = call i32 @cfsetospeed(%struct.termios* %3, i32 %16)
%19 = load i32, i32* @PARENB
%20 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 0
%21 = load i32, i32* %20
%22 = load i32, i32* @CSTOPB
%23 = or i32 %19, %22
%24 = load i32, i32* @CSIZE
%25 = or i32 %23, %24
%26 = xor i32 %25, -1
%27 = and i32 %21, %26
%28 = load i32, i32* @CS8
%29 = or i32 %28, %27
%30 = load i32, i32* @CRTSCTS
%31 = xor i32 %30, -1
%32 = and i32 %29, %31
%33 = load i32, i32* @CREAD
%34 = load i32, i32* @CLOCAL
%35 = or i32 %33, %32
%36 = or i32 %35, %34
store i32 %36, i32* %20
%37 = load i32, i32* @IXON
%38 = load i32, i32* @IXOFF
%39 = or i32 %38, %37
%40 = load i32, i32* @IXANY
%41 = or i32 %39, %40
%42 = xor i32 %41, -1
%43 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 1
%44 = load i32, i32* %43
%45 = and i32 %44, %42
store i32 %45, i32* %43
%46 = load i32, i32* @ICANON
%47 = load i32, i32* @ECHO
%48 = or i32 %47, %46
%49 = load i32, i32* @ECHOE
%50 = or i32 %48, %49
%51 = load i32, i32* @ISIG
%52 = or i32 %50, %51
%53 = xor i32 %52, -1
%54 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 2
%55 = load i32, i32* %54
%56 = and i32 %55, %53
store i32 %56, i32* %54
%57 = load i32, i32* @OPOST
%58 = xor i32 %57, -1
%59 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 4
%60 = load i32, i32* %59
%61 = and i32 %60, %58
store i32 %61, i32* %59
%62 = getelementptr inbounds %struct.termios, %struct.termios* %3, i64 0, i32 3
%63 = load i64*, i64** %62
%64 = load i64, i64* @VMIN
%65 = getelementptr inbounds i64, i64* %63, i64 %64
store i64 0, i64* %65
%66 = load i64, i64* @VTIME
%67 = getelementptr inbounds i64, i64* %63, i64 %66
store i64 0, i64* %67
%68 = load i32, i32* @TCSANOW
%69 = call i32 @tcsetattr(i32 %11, i32 %68, %struct.termios* %3)
%70 = icmp eq i8 %0, 83
br i1 %70, label %71, label %81
71: ; preds = %15
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%73 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%74 = call i32 (...) @getchar()
%75 = load i32, i32* @stdin
%76 = call i32 @fgets(i8* %73, i32 32, i32 %75)
%77 = call i8* @strcat(i8* %2, i8* %73)
%78 = call i32 @strlen(i8* %2)
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %2)
%80 = call i32 (i32, ...) @write(i32 %11, i8* %2, i32 %78)
br label %87
81: ; preds = %15
%82 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
store i8 %0, i8* %82
%83 = call i32 @strlen(i8* %82)
%84 = sext i8 %0 to i32
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %84)
%86 = call i32 (i32, ...) @write(i32 %11, [1 x i8]* %5, i32 %83)
br label %87
87: ; preds = %81, %71
%88 = phi i32 [ %78, %71 ], [ %83, %81 ]
%89 = phi i32 [ %80, %71 ], [ %86, %81 ]
%90 = icmp eq i32 %89, %88
br i1 %90, label %94, label %91
91: ; preds = %87
%92 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%93 = call i32 @close(i32 %11)
br label %129
94: ; preds = %87
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%96 = call i32 @sleep(i32 1)
%97 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0))
%98 = call i8* @llvm.stacksave()
%99 = alloca [21 x i8]
%100 = getelementptr inbounds [21 x i8], [21 x i8]* %99, i64 0, i64 0
%101 = getelementptr inbounds [1 x i8], [1 x i8]* %6, i64 0, i64 0
br label %102
102: ; preds = %94, %113
%103 = phi i64 [ 0, %94 ], [ %115, %113 ]
br label %104
104: ; preds = %102, %108
%105 = call i32 @read(i32 %11, i8* %101, i32 1)
switch i32 %105, label %113 [
i32 -1, label %106
i32 0, label %108
]
106: ; preds = %104
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
br label %127
108: ; preds = %104
%109 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
%110 = call i32 @sleep(i32 1)
%111 = load i8, i8* %101
%112 = icmp eq i8 %111, 10
br i1 %112, label %120, label %104
113: ; preds = %104
%114 = load i8, i8* %101
%115 = add nuw nsw i64 %103, 1
%116 = getelementptr inbounds [21 x i8], [21 x i8]* %99, i64 0, i64 %103
store i8 %114, i8* %116
%117 = icmp ult i64 %103, 19
%118 = icmp ne i8 %114, 10
%119 = select i1 %117, i1 %118, i1 false
br i1 %119, label %102, label %120
120: ; preds = %113, %108
%121 = phi i64 [ %103, %108 ], [ %115, %113 ]
%122 = shl i64 %121, 32
%123 = ashr exact i64 %122, 32
%124 = getelementptr inbounds [21 x i8], [21 x i8]* %99, i64 0, i64 %123
store i8 10, i8* %124
%125 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
%126 = call i32 @puts(i8* %100)
br label %127
127: ; preds = %120, %106
%128 = call i32 @close(i32 %11)
br label %129
129: ; preds = %91, %127, %13
ret void
}