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

/* Variables and functions */
int /*<<< orphan*/ CHECK(int, int, int, int, int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int serial_close(int);
int serial_data_available(int);
int serial_open(char *, int, int /*<<< orphan*/);
int serial_read(int, char *, int);
int serial_read_byte(int);
int serial_write(int, char *, int);
int serial_write_byte(int, int);
int strcmp(char *, char *);
int strlen(char *);
int /*<<< orphan*/ time_sleep(double);
void ta() {
  int h, b, e;
  char *TEXT;
  char text[2048];
  printf("Serial link tests.\n");
  h = serial_open("/dev/ttyAMA0", 57600, 0);
  CHECK(10, 1, h, 0, 0, "serial open");
  time_sleep(0.1);
  b = serial_read(h, text, sizeof(text));
  b = serial_data_available(h);
  CHECK(10, 2, b, 0, 0, "serial data available");
  TEXT = "To be, or not to be, that is the question-Whether 'tis Nobler in the "
         "mind to sufferThe Slings and Arrows of outrageous Fortune,Or to take "
         "Arms against a Sea of troubles,";
  e = serial_write(h, TEXT, strlen(TEXT));
  CHECK(10, 3, e, 0, 0, "serial write");
  e = serial_write_byte(h, 0xAA);
  e = serial_write_byte(h, 0x55);
  e = serial_write_byte(h, 0x00);
  e = serial_write_byte(h, 0xFF);
  CHECK(10, 4, e, 0, 0, "serial write byte");
  time_sleep(0.1);
  b = serial_data_available(h);
  CHECK(10, 5, b, strlen(TEXT) + 4, 0, "serial data available");
  b = serial_read(h, text, strlen(TEXT));
  CHECK(10, 6, b, strlen(TEXT), 0, "serial read");
  if (b >= 0)
    text[b] = 0;
  CHECK(10, 7, strcmp(TEXT, text), 0, 0, "serial read");
  b = serial_read_byte(h);
  CHECK(10, 8, b, 0xAA, 0, "serial read byte");
  b = serial_read_byte(h);
  CHECK(10, 9, b, 0x55, 0, "serial read byte");
  b = serial_read_byte(h);
  CHECK(10, 10, b, 0x00, 0, "serial read byte");
  b = serial_read_byte(h);
  CHECK(10, 11, b, 0xFF, 0, "serial read byte");
  b = serial_data_available(h);
  CHECK(10, 12, b, 0, 0, "serial data availabe");
  e = serial_close(h);
  CHECK(10, 13, e, 0, 0, "serial close");
}


x86 assembly (clang, -O0):
<ta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x850,%rsp
lea    0xe36(%rip),%rdi
call   1050 <printf@plt>
lea    0xe3e(%rip),%rdi
mov    $0xe100,%esi
xor    %edx,%edx
call   1080 <serial_open@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0xa,%edi
mov    $0x1,%esi
xor    %r8d,%r8d
lea    0xe25(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
movsd  0xdec(%rip),%xmm0
call   10e0 <time_sleep@plt>
mov    -0x4(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x800,%edx
call   10d0 <serial_read@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
call   10b0 <serial_data_available@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0xa,%edi
mov    $0x2,%esi
xor    %r8d,%r8d
lea    0xde3(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
lea    0xdea(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x844(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x840(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x844(%rbp),%edi
mov    -0x840(%rbp),%rsi
mov    %eax,%edx
call   10c0 <serial_write@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edx
mov    $0xa,%edi
mov    $0x3,%esi
xor    %r8d,%r8d
lea    0xe45(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
mov    $0xaa,%esi
call   10a0 <serial_write_byte@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x55,%esi
call   10a0 <serial_write_byte@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   10a0 <serial_write_byte@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    $0xff,%esi
call   10a0 <serial_write_byte@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edx
mov    $0xa,%edi
mov    $0x4,%esi
xor    %r8d,%r8d
lea    0xdf6(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
movsd  0xce4(%rip),%xmm0
call   10e0 <time_sleep@plt>
mov    -0x4(%rbp),%edi
call   10b0 <serial_data_available@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x838(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x838(%rbp),%edx
mov    %eax,%ecx
add    $0x4,%ecx
mov    $0xa,%edi
mov    $0x5,%esi
xor    %r8d,%r8d
lea    0xcd8(%rip),%r9
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x834(%rbp)
lea    -0x820(%rbp),%rax
mov    %rax,-0x830(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x834(%rbp),%edi
mov    -0x830(%rbp),%rsi
mov    %eax,%edx
call   10d0 <serial_read@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x824(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x824(%rbp),%edx
mov    %eax,%ecx
mov    $0xa,%edi
mov    $0x6,%esi
xor    %r8d,%r8d
lea    0xd4d(%rip),%r9
call   1030 <CHECK@plt>
cmpl   $0x0,-0x8(%rbp)
jl     13e2 <ta+0x222>
movslq -0x8(%rbp),%rax
movb   $0x0,-0x820(%rbp,%rax,1)
mov    -0x18(%rbp),%rdi
lea    -0x820(%rbp),%rsi
call   1060 <strcmp@plt>
mov    %eax,%edx
mov    $0xa,%edi
mov    $0x7,%esi
xor    %r8d,%r8d
lea    0xd0c(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
call   1090 <serial_read_byte@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0xa,%edi
mov    $0x8,%esi
mov    $0xaa,%ecx
xor    %r8d,%r8d
lea    0xce9(%rip),%r9
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
call   1090 <serial_read_byte@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0xa,%edi
mov    $0x9,%esi
mov    $0x55,%ecx
xor    %r8d,%r8d
lea    0xcbd(%rip),%r9
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
call   1090 <serial_read_byte@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0xa,%esi
xor    %r8d,%r8d
lea    0xc9b(%rip),%r9
mov    %esi,%edi
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
call   1090 <serial_read_byte@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0xa,%edi
mov    $0xb,%esi
mov    $0xff,%ecx
xor    %r8d,%r8d
lea    0xc6a(%rip),%r9
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
call   10b0 <serial_data_available@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edx
mov    $0xa,%edi
mov    $0xc,%esi
xor    %r8d,%r8d
lea    0xc54(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
mov    -0x4(%rbp),%edi
call   1070 <serial_close@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edx
mov    $0xa,%edi
mov    $0xd,%esi
xor    %r8d,%r8d
lea    0xc3f(%rip),%r9
mov    %r8d,%ecx
call   1030 <CHECK@plt>
add    $0x850,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ta>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x800,%rsp
lea    0xf69(%rip),%rdi
call   1040 <puts@plt>
lea    0xe26(%rip),%rdi
mov    $0xe100,%esi
xor    %edx,%edx
call   1080 <serial_open@plt>
mov    %eax,%ebx
lea    0xe1e(%rip),%r9
mov    $0xa,%edi
mov    $0x1,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
movsd  0xdeb(%rip),%xmm0
call   10e0 <time_sleep@plt>
mov    %rsp,%r14
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x800,%edx
call   10d0 <serial_read@plt>
mov    %ebx,%edi
call   10b0 <serial_data_available@plt>
lea    0xde7(%rip),%r12
mov    $0xa,%edi
mov    $0x2,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %r12,%r9
call   1030 <CHECK@plt>
lea    0xddd(%rip),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %eax,%edx
call   10c0 <serial_write@plt>
lea    0xe6c(%rip),%r9
mov    $0xa,%edi
mov    $0x3,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
mov    %ebx,%edi
mov    $0xaa,%esi
call   10a0 <serial_write_byte@plt>
mov    %ebx,%edi
mov    $0x55,%esi
call   10a0 <serial_write_byte@plt>
mov    %ebx,%edi
xor    %esi,%esi
call   10a0 <serial_write_byte@plt>
mov    %ebx,%edi
mov    $0xff,%esi
call   10a0 <serial_write_byte@plt>
lea    0xe2f(%rip),%r9
mov    $0xa,%edi
mov    $0x4,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
movsd  0xd23(%rip),%xmm0
call   10e0 <time_sleep@plt>
mov    %ebx,%edi
call   10b0 <serial_data_available@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    0x4(%rax),%ecx
mov    $0xa,%edi
mov    $0x5,%esi
mov    %ebp,%edx
xor    %r8d,%r8d
mov    %r12,%r9
call   1030 <CHECK@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   10d0 <serial_read@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    0xdce(%rip),%r9
mov    $0xa,%edi
mov    $0x6,%esi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
test   %ebp,%ebp
js     1352 <ta+0x192>
mov    %ebp,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0xcde(%rip),%rdi
mov    %rsp,%rsi
call   1060 <strcmp@plt>
lea    0xd98(%rip),%r9
mov    $0xa,%edi
mov    $0x7,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
mov    %ebx,%edi
call   1090 <serial_read_byte@plt>
lea    0xd80(%rip),%r14
mov    $0xa,%edi
mov    $0x8,%esi
mov    %eax,%edx
mov    $0xaa,%ecx
xor    %r8d,%r8d
mov    %r14,%r9
call   1030 <CHECK@plt>
mov    %ebx,%edi
call   1090 <serial_read_byte@plt>
mov    $0xa,%edi
mov    $0x9,%esi
mov    %eax,%edx
mov    $0x55,%ecx
xor    %r8d,%r8d
mov    %r14,%r9
call   1030 <CHECK@plt>
mov    %ebx,%edi
call   1090 <serial_read_byte@plt>
mov    $0xa,%edi
mov    $0xa,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %r14,%r9
call   1030 <CHECK@plt>
mov    %ebx,%edi
call   1090 <serial_read_byte@plt>
mov    $0xa,%edi
mov    $0xb,%esi
mov    %eax,%edx
mov    $0xff,%ecx
xor    %r8d,%r8d
mov    %r14,%r9
call   1030 <CHECK@plt>
mov    %ebx,%edi
call   10b0 <serial_data_available@plt>
lea    0xd01(%rip),%r9
mov    $0xa,%edi
mov    $0xc,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
mov    %ebx,%edi
call   1070 <serial_close@plt>
lea    0xcf2(%rip),%r9
mov    $0xa,%edi
mov    $0xd,%esi
mov    %eax,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1030 <CHECK@plt>
add    $0x800,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Serial link tests.\0A\00"
@.str.1 = [13 x i8] c"/dev/ttyAMA0\00"
@.str.2 = [12 x i8] c"serial open\00"
@.str.3 = [22 x i8] c"serial data available\00"
@.str.4 = [170 x i8] c"To be, or not to be, that is the question-Whether 'tis Nobler in the mind to sufferThe Slings and Arrows of outrageous Fortune,Or to take Arms against a Sea of troubles,\00"
@.str.5 = [13 x i8] c"serial write\00"
@.str.6 = [18 x i8] c"serial write byte\00"
@.str.7 = [12 x i8] c"serial read\00"
@.str.8 = [17 x i8] c"serial read byte\00"
@.str.9 = [21 x i8] c"serial data availabe\00"
@.str.10 = [13 x i8] c"serial close\00"
define void @ta() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [2048 x i8]
%6 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @serial_open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 57600, i32 0)
store i32 %7, i32* %1
%8 = load i32, i32* %1
%9 = call i32 @CHECK(i32 10, i32 1, i32 %8, i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @time_sleep(double 1.000000e-01)
%11 = load i32, i32* %1
%12 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%13 = call i32 @serial_read(i32 %11, i8* %12, i32 2048)
store i32 %13, i32* %2
%14 = load i32, i32* %1
%15 = call i32 @serial_data_available(i32 %14)
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = call i32 @CHECK(i32 10, i32 2, i32 %16, i32 0, i32 0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
store i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.4, i64 0, i64 0), i8** %4
%18 = load i32, i32* %1
%19 = load i8*, i8** %4
%20 = load i8*, i8** %4
%21 = call i32 @strlen(i8* %20)
%22 = call i32 @serial_write(i32 %18, i8* %19, i32 %21)
store i32 %22, i32* %3
%23 = load i32, i32* %3
%24 = call i32 @CHECK(i32 10, i32 3, i32 %23, i32 0, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%25 = load i32, i32* %1
%26 = call i32 @serial_write_byte(i32 %25, i32 170)
store i32 %26, i32* %3
%27 = load i32, i32* %1
%28 = call i32 @serial_write_byte(i32 %27, i32 85)
store i32 %28, i32* %3
%29 = load i32, i32* %1
%30 = call i32 @serial_write_byte(i32 %29, i32 0)
store i32 %30, i32* %3
%31 = load i32, i32* %1
%32 = call i32 @serial_write_byte(i32 %31, i32 255)
store i32 %32, i32* %3
%33 = load i32, i32* %3
%34 = call i32 @CHECK(i32 10, i32 4, i32 %33, i32 0, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%35 = call i32 @time_sleep(double 1.000000e-01)
%36 = load i32, i32* %1
%37 = call i32 @serial_data_available(i32 %36)
store i32 %37, i32* %2
%38 = load i32, i32* %2
%39 = load i8*, i8** %4
%40 = call i32 @strlen(i8* %39)
%41 = add nsw i32 %40, 4
%42 = call i32 @CHECK(i32 10, i32 5, i32 %38, i32 %41, i32 0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%43 = load i32, i32* %1
%44 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%45 = load i8*, i8** %4
%46 = call i32 @strlen(i8* %45)
%47 = call i32 @serial_read(i32 %43, i8* %44, i32 %46)
store i32 %47, i32* %2
%48 = load i32, i32* %2
%49 = load i8*, i8** %4
%50 = call i32 @strlen(i8* %49)
%51 = call i32 @CHECK(i32 10, i32 6, i32 %48, i32 %50, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%52 = load i32, i32* %2
%53 = icmp sge i32 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %0
%55 = load i32, i32* %2
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 %56
store i8 0, i8* %57
br label %58
58: ; preds = %54, %0
%59 = load i8*, i8** %4
%60 = getelementptr inbounds [2048 x i8], [2048 x i8]* %5, i64 0, i64 0
%61 = call i32 @strcmp(i8* %59, i8* %60)
%62 = call i32 @CHECK(i32 10, i32 7, i32 %61, i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%63 = load i32, i32* %1
%64 = call i32 @serial_read_byte(i32 %63)
store i32 %64, i32* %2
%65 = load i32, i32* %2
%66 = call i32 @CHECK(i32 10, i32 8, i32 %65, i32 170, i32 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%67 = load i32, i32* %1
%68 = call i32 @serial_read_byte(i32 %67)
store i32 %68, i32* %2
%69 = load i32, i32* %2
%70 = call i32 @CHECK(i32 10, i32 9, i32 %69, i32 85, i32 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%71 = load i32, i32* %1
%72 = call i32 @serial_read_byte(i32 %71)
store i32 %72, i32* %2
%73 = load i32, i32* %2
%74 = call i32 @CHECK(i32 10, i32 10, i32 %73, i32 0, i32 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%75 = load i32, i32* %1
%76 = call i32 @serial_read_byte(i32 %75)
store i32 %76, i32* %2
%77 = load i32, i32* %2
%78 = call i32 @CHECK(i32 10, i32 11, i32 %77, i32 255, i32 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%79 = load i32, i32* %1
%80 = call i32 @serial_data_available(i32 %79)
store i32 %80, i32* %2
%81 = load i32, i32* %2
%82 = call i32 @CHECK(i32 10, i32 12, i32 %81, i32 0, i32 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
%83 = load i32, i32* %1
%84 = call i32 @serial_close(i32 %83)
store i32 %84, i32* %3
%85 = load i32, i32* %3
%86 = call i32 @CHECK(i32 10, i32 13, i32 %85, i32 0, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"/dev/ttyAMA0\00"
@.str.2 = [12 x i8] c"serial open\00"
@.str.3 = [22 x i8] c"serial data available\00"
@.str.4 = [170 x i8] c"To be, or not to be, that is the question-Whether 'tis Nobler in the mind to sufferThe Slings and Arrows of outrageous Fortune,Or to take Arms against a Sea of troubles,\00"
@.str.5 = [13 x i8] c"serial write\00"
@.str.6 = [18 x i8] c"serial write byte\00"
@.str.7 = [12 x i8] c"serial read\00"
@.str.8 = [17 x i8] c"serial read byte\00"
@.str.9 = [21 x i8] c"serial data availabe\00"
@.str.10 = [13 x i8] c"serial close\00"
@str = [19 x i8] c"Serial link tests.\00"
define void @ta() {
%1 = alloca [2048 x i8]
%2 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @serial_open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 57600, i32 0)
%5 = tail call i32 @CHECK(i32 10, i32 1, i32 %4, i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 @time_sleep(double 1.000000e-01)
%7 = call i32 @serial_read(i32 %4, i8* %2, i32 2048)
%8 = call i32 @serial_data_available(i32 %4)
%9 = call i32 @CHECK(i32 10, i32 2, i32 %8, i32 0, i32 0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 @strlen(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 @serial_write(i32 %4, i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.4, i64 0, i64 0), i32 %10)
%12 = call i32 @CHECK(i32 10, i32 3, i32 %11, i32 0, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 @serial_write_byte(i32 %4, i32 170)
%14 = call i32 @serial_write_byte(i32 %4, i32 85)
%15 = call i32 @serial_write_byte(i32 %4, i32 0)
%16 = call i32 @serial_write_byte(i32 %4, i32 255)
%17 = call i32 @CHECK(i32 10, i32 4, i32 %16, i32 0, i32 0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 @time_sleep(double 1.000000e-01)
%19 = call i32 @serial_data_available(i32 %4)
%20 = call i32 @strlen(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.4, i64 0, i64 0))
%21 = add nsw i32 %20, 4
%22 = call i32 @CHECK(i32 10, i32 5, i32 %19, i32 %21, i32 0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 @strlen(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.4, i64 0, i64 0))
%24 = call i32 @serial_read(i32 %4, i8* %2, i32 %23)
%25 = call i32 @strlen(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.4, i64 0, i64 0))
%26 = call i32 @CHECK(i32 10, i32 6, i32 %24, i32 %25, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%27 = icmp sgt i32 %24, -1
br i1 %27, label %28, label %31
28: ; preds = %0
%29 = zext i32 %24 to i64
%30 = getelementptr inbounds [2048 x i8], [2048 x i8]* %1, i64 0, i64 %29
store i8 0, i8* %30
br label %31
31: ; preds = %28, %0
%32 = call i32 @strcmp(i8* dereferenceable(170) getelementptr inbounds ([170 x i8], [170 x i8]* @.str.4, i64 0, i64 0), i8* %2)
%33 = call i32 @CHECK(i32 10, i32 7, i32 %32, i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
%34 = call i32 @serial_read_byte(i32 %4)
%35 = call i32 @CHECK(i32 10, i32 8, i32 %34, i32 170, i32 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%36 = call i32 @serial_read_byte(i32 %4)
%37 = call i32 @CHECK(i32 10, i32 9, i32 %36, i32 85, i32 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%38 = call i32 @serial_read_byte(i32 %4)
%39 = call i32 @CHECK(i32 10, i32 10, i32 %38, i32 0, i32 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%40 = call i32 @serial_read_byte(i32 %4)
%41 = call i32 @CHECK(i32 10, i32 11, i32 %40, i32 255, i32 0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%42 = call i32 @serial_data_available(i32 %4)
%43 = call i32 @CHECK(i32 10, i32 12, i32 %42, i32 0, i32 0, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
%44 = call i32 @serial_close(i32 %4)
%45 = call i32 @CHECK(i32 10, i32 13, i32 %44, i32 0, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0))
ret void
}