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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write(int, char *, int);
void testEcho(int fd) {
  usleep(2000000);
  write(fd, "TEST MESSAGE: 1234567890!@#$%^&*()\n", 35);
  char ret[36];
  int rbytes = read(fd, ret, 35);
  ret[35] = 0;
  if (rbytes == -1)
    printf("testEcho: read() Failed!!!");
  if (!strcmp(ret, "TEST MESSAGE: 1234567890!@#$%^&*()\n"))
    printf("Arduino Test: PASSED.\n");
  else
    printf("Arduino Test: FAILED!!!\nMessage Recieved: %s\n", ret);
}


x86 assembly (clang, -O0):
<testEcho>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x1e8480,%edi
call   1070 <usleep@plt>
mov    -0x4(%rbp),%edi
lea    0xe91(%rip),%rsi
mov    $0x23,%edx
call   1030 <write@plt>
mov    -0x4(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x23,%edx
call   1050 <read@plt>
mov    %eax,-0x34(%rbp)
movb   $0x0,-0xd(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    11a9 <testEcho+0x59>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
lea    0xe4c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11d5 <testEcho+0x85>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e7 <testEcho+0x97>
lea    -0x30(%rbp),%rsi
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testEcho>:
push   %rbx
sub    $0x30,%rsp
mov    %edi,%ebx
mov    $0x1e8480,%edi
call   1080 <usleep@plt>
lea    0xe88(%rip),%rsi
mov    %ebx,%edi
mov    $0x23,%edx
call   1040 <write@plt>
mov    %rsp,%rsi
mov    %ebx,%edi
mov    $0x23,%edx
call   1060 <read@plt>
movb   $0x0,0x23(%rsp)
cmp    $0xffffffff,%eax
jne    11ab <testEcho+0x4b>
lea    0xe80(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe4e(%rip),%rsi
mov    %rsp,%rdi
mov    $0x24,%edx
call   1070 <bcmp@plt>
test   %eax,%eax
je     11da <testEcho+0x7a>
lea    0xe75(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x30,%rsp
pop    %rbx
ret
lea    0xe8c(%rip),%rdi
add    $0x30,%rsp
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"TEST MESSAGE: 1234567890!@#$%^&*()\0A\00"
@.str.1 = [27 x i8] c"testEcho: read() Failed!!!\00"
@.str.2 = [23 x i8] c"Arduino Test: PASSED.\0A\00"
@.str.3 = [46 x i8] c"Arduino Test: FAILED!!!\0AMessage Recieved: %s\0A\00"
define void @testEcho(i32 %0) {
%2 = alloca i32
%3 = alloca [36 x i8]
%4 = alloca i32
store i32 %0, i32* %2
%5 = call i32 @usleep(i32 2000000)
%6 = load i32, i32* %2
%7 = call i32 @write(i32 %6, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 35)
%8 = load i32, i32* %2
%9 = getelementptr inbounds [36 x i8], [36 x i8]* %3, i64 0, i64 0
%10 = call i32 @read(i32 %8, i8* %9, i32 35)
store i32 %10, i32* %4
%11 = getelementptr inbounds [36 x i8], [36 x i8]* %3, i64 0, i64 35
store i8 0, i8* %11
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %1
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %1
%17 = getelementptr inbounds [36 x i8], [36 x i8]* %3, i64 0, i64 0
%18 = call i32 @strcmp(i8* %17, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%19 = icmp ne i32 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %25
22: ; preds = %16
%23 = getelementptr inbounds [36 x i8], [36 x i8]* %3, i64 0, i64 0
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %22, %20
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"TEST MESSAGE: 1234567890!@#$%^&*()\0A\00"
@.str.1 = [27 x i8] c"testEcho: read() Failed!!!\00"
@.str.3 = [46 x i8] c"Arduino Test: FAILED!!!\0AMessage Recieved: %s\0A\00"
@str = [22 x i8] c"Arduino Test: PASSED.\00"
define void @testEcho(i32 %0) {
%2 = alloca [36 x i8]
%3 = tail call i32 @usleep(i32 2000000)
%4 = tail call i32 @write(i32 %0, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 35)
%5 = getelementptr inbounds [36 x i8], [36 x i8]* %2, i64 0, i64 0
%6 = call i32 @read(i32 %0, i8* %5, i32 35)
%7 = getelementptr inbounds [36 x i8], [36 x i8]* %2, i64 0, i64 35
store i8 0, i8* %7
%8 = icmp eq i32 %6, -1
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %1
%12 = call i32 @bcmp(i8* dereferenceable(36) %5, i8* dereferenceable(36) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i64 36)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %18
16: ; preds = %11
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i8* %5)
br label %18
18: ; preds = %16, %14
ret void
}