#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*/ serialFlush(int);
int serialOpen(char *, int);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write(int, char *, int);
int initDataQSerial(void) {
  int i;
  int msglen;
  int dataq;
  char tmpmsg[128];
  dataq = serialOpen("/dev/ttyACM0", 4800);
  if (dataq == -1) {
    return (-1);
  }
  write(dataq, "stop\r", 5);
  usleep(10000);
  serialFlush(dataq);
  write(dataq, "slist 0 0\r", 10);
  usleep(20000);
  write(dataq, "slist 1 1\r", 10);
  usleep(20000);
  write(dataq, "slist 2 2\r", 10);
  usleep(20000);
  write(dataq, "slist 3 3\r", 10);
  usleep(20000);
  write(dataq, "slist 4 65535\r", 14);
  usleep(28000);
  write(dataq, "bin\r", 4);
  usleep(8000);
  write(dataq, "start\r", 6);
  usleep(12000);
  serialFlush(dataq);
  return (dataq);
}


x86 assembly (clang, -O0):
<initDataQSerial>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
lea    0xeae(%rip),%rdi
mov    $0x12c0,%esi
call   1030 <serialOpen@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    1175 <initDataQSerial+0x35>
movl   $0xffffffff,-0x4(%rbp)
jmp    127b <initDataQSerial+0x13b>
mov    -0x10(%rbp),%edi
lea    0xe8e(%rip),%rsi
mov    $0x5,%edx
call   1040 <write@plt>
mov    $0x2710,%edi
call   1060 <usleep@plt>
mov    -0x10(%rbp),%edi
call   1050 <serialFlush@plt>
mov    -0x10(%rbp),%edi
lea    0xe6e(%rip),%rsi
mov    $0xa,%edx
call   1040 <write@plt>
mov    $0x4e20,%edi
call   1060 <usleep@plt>
mov    -0x10(%rbp),%edi
lea    0xe5b(%rip),%rsi
mov    $0xa,%edx
call   1040 <write@plt>
mov    $0x4e20,%edi
call   1060 <usleep@plt>
mov    -0x10(%rbp),%edi
lea    0xe48(%rip),%rsi
mov    $0xa,%edx
call   1040 <write@plt>
mov    $0x4e20,%edi
call   1060 <usleep@plt>
mov    -0x10(%rbp),%edi
lea    0xe35(%rip),%rsi
mov    $0xa,%edx
call   1040 <write@plt>
mov    $0x4e20,%edi
call   1060 <usleep@plt>
mov    -0x10(%rbp),%edi
lea    0xe22(%rip),%rsi
mov    $0xe,%edx
call   1040 <write@plt>
mov    $0x6d60,%edi
call   1060 <usleep@plt>
mov    -0x10(%rbp),%edi
lea    0xe13(%rip),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
mov    $0x1f40,%edi
call   1060 <usleep@plt>
mov    -0x10(%rbp),%edi
lea    0xdfa(%rip),%rsi
mov    $0x6,%edx
call   1040 <write@plt>
mov    $0x2ee0,%edi
call   1060 <usleep@plt>
mov    -0x10(%rbp),%edi
call   1050 <serialFlush@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<initDataQSerial>:
push   %rbx
lea    0xeb8(%rip),%rdi
mov    $0x12c0,%esi
call   1030 <serialOpen@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     1253 <initDataQSerial+0x113>
lea    0xea9(%rip),%rsi
mov    %ebx,%edi
mov    $0x5,%edx
call   1040 <write@plt>
mov    $0x2710,%edi
call   1060 <usleep@plt>
mov    %ebx,%edi
call   1050 <serialFlush@plt>
lea    0xe8b(%rip),%rsi
mov    %ebx,%edi
mov    $0xa,%edx
call   1040 <write@plt>
mov    $0x4e20,%edi
call   1060 <usleep@plt>
lea    0xe79(%rip),%rsi
mov    %ebx,%edi
mov    $0xa,%edx
call   1040 <write@plt>
mov    $0x4e20,%edi
call   1060 <usleep@plt>
lea    0xe67(%rip),%rsi
mov    %ebx,%edi
mov    $0xa,%edx
call   1040 <write@plt>
mov    $0x4e20,%edi
call   1060 <usleep@plt>
lea    0xe55(%rip),%rsi
mov    %ebx,%edi
mov    $0xa,%edx
call   1040 <write@plt>
mov    $0x4e20,%edi
call   1060 <usleep@plt>
lea    0xe43(%rip),%rsi
mov    %ebx,%edi
mov    $0xe,%edx
call   1040 <write@plt>
mov    $0x6d60,%edi
call   1060 <usleep@plt>
lea    0xe35(%rip),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1040 <write@plt>
mov    $0x1f40,%edi
call   1060 <usleep@plt>
lea    0xe1d(%rip),%rsi
mov    %ebx,%edi
mov    $0x6,%edx
call   1040 <write@plt>
mov    $0x2ee0,%edi
call   1060 <usleep@plt>
mov    %ebx,%edi
call   1050 <serialFlush@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/dev/ttyACM0\00"
@.str.1 = [6 x i8] c"stop\0D\00"
@.str.2 = [11 x i8] c"slist 0 0\0D\00"
@.str.3 = [11 x i8] c"slist 1 1\0D\00"
@.str.4 = [11 x i8] c"slist 2 2\0D\00"
@.str.5 = [11 x i8] c"slist 3 3\0D\00"
@.str.6 = [15 x i8] c"slist 4 65535\0D\00"
@.str.7 = [5 x i8] c"bin\0D\00"
@.str.8 = [7 x i8] c"start\0D\00"
define i32 @initDataQSerial() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [128 x i8]
%6 = call i32 @serialOpen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 4800)
store i32 %6, i32* %4
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 -1, i32* %1
br label %40
10: ; preds = %0
%11 = load i32, i32* %4
%12 = call i32 @write(i32 %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%13 = call i32 @usleep(i32 10000)
%14 = load i32, i32* %4
%15 = call i32 @serialFlush(i32 %14)
%16 = load i32, i32* %4
%17 = call i32 @write(i32 %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 10)
%18 = call i32 @usleep(i32 20000)
%19 = load i32, i32* %4
%20 = call i32 @write(i32 %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 10)
%21 = call i32 @usleep(i32 20000)
%22 = load i32, i32* %4
%23 = call i32 @write(i32 %22, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 10)
%24 = call i32 @usleep(i32 20000)
%25 = load i32, i32* %4
%26 = call i32 @write(i32 %25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 10)
%27 = call i32 @usleep(i32 20000)
%28 = load i32, i32* %4
%29 = call i32 @write(i32 %28, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 14)
%30 = call i32 @usleep(i32 28000)
%31 = load i32, i32* %4
%32 = call i32 @write(i32 %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 4)
%33 = call i32 @usleep(i32 8000)
%34 = load i32, i32* %4
%35 = call i32 @write(i32 %34, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 6)
%36 = call i32 @usleep(i32 12000)
%37 = load i32, i32* %4
%38 = call i32 @serialFlush(i32 %37)
%39 = load i32, i32* %4
store i32 %39, i32* %1
br label %40
40: ; preds = %10, %9
%41 = load i32, i32* %1
ret i32 %41
}

LLVM IR (-O2):
@.str = [13 x i8] c"/dev/ttyACM0\00"
@.str.1 = [6 x i8] c"stop\0D\00"
@.str.2 = [11 x i8] c"slist 0 0\0D\00"
@.str.3 = [11 x i8] c"slist 1 1\0D\00"
@.str.4 = [11 x i8] c"slist 2 2\0D\00"
@.str.5 = [11 x i8] c"slist 3 3\0D\00"
@.str.6 = [15 x i8] c"slist 4 65535\0D\00"
@.str.7 = [5 x i8] c"bin\0D\00"
@.str.8 = [7 x i8] c"start\0D\00"
define i32 @initDataQSerial() {
%1 = tail call i32 @serialOpen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 4800)
%2 = icmp eq i32 %1, -1
br i1 %2, label %22, label %3
3: ; preds = %0
%4 = tail call i32 @write(i32 %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 5)
%5 = tail call i32 @usleep(i32 10000)
%6 = tail call i32 @serialFlush(i32 %1)
%7 = tail call i32 @write(i32 %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 10)
%8 = tail call i32 @usleep(i32 20000)
%9 = tail call i32 @write(i32 %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 10)
%10 = tail call i32 @usleep(i32 20000)
%11 = tail call i32 @write(i32 %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i32 10)
%12 = tail call i32 @usleep(i32 20000)
%13 = tail call i32 @write(i32 %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i32 10)
%14 = tail call i32 @usleep(i32 20000)
%15 = tail call i32 @write(i32 %1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i32 14)
%16 = tail call i32 @usleep(i32 28000)
%17 = tail call i32 @write(i32 %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i32 4)
%18 = tail call i32 @usleep(i32 8000)
%19 = tail call i32 @write(i32 %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 6)
%20 = tail call i32 @usleep(i32 12000)
%21 = tail call i32 @serialFlush(i32 %1)
br label %22
22: ; preds = %0, %3
ret i32 %1
}