#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 CoordString {
  long xyz;
  char *ByteString;
};

/* Variables and functions */
int /*<<< orphan*/ close(int);
int open_port(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ write(int, char *, int);
int Move(void) {
  union CoordString {
    long xyz;
    char ByteString[4];
  } x, y, z;
  int num;
  char TestMove[] = {'m', 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0};
  char term[] = "/dev/ttyd2";
  int SerialPort;
  SerialPort = open_port(term);
  if (!SerialPort)
    return 0;
  write(SerialPort, TestMove, 13);
  write(SerialPort, "\r", 1);
  sleep(1);
  close(SerialPort);
  return 0;
}


x86 assembly (clang, -O0):
<Move>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0xeb1(%rip),%rax
mov    %rax,-0x31(%rbp)
mov    0xeaf(%rip),%eax
mov    %eax,-0x29(%rbp)
mov    0xeaa(%rip),%al
mov    %al,-0x25(%rbp)
mov    0xea1(%rip),%rax
mov    %rax,-0x3c(%rbp)
mov    0xe9e(%rip),%ax
mov    %ax,-0x34(%rbp)
mov    0xe96(%rip),%al
mov    %al,-0x32(%rbp)
lea    -0x3c(%rbp),%rdi
call   1050 <open_port@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jne    11a6 <Move+0x66>
movl   $0x0,-0x4(%rbp)
jmp    11e4 <Move+0xa4>
mov    -0x40(%rbp),%edi
lea    -0x31(%rbp),%rsi
mov    $0xd,%edx
call   1030 <write@plt>
mov    -0x40(%rbp),%edi
lea    0xe57(%rip),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    -0x40(%rbp),%edi
call   1040 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Move>:
push   %rbx
sub    $0x20,%rsp
movabs $0x300000002,%rax
mov    %rax,0x15(%rsp)
movabs $0x2000000016d,%rax
mov    %rax,0x10(%rsp)
movabs $0x7974742f7665642f,%rax
74 74 79
mov    %rax,(%rsp)
movl   $0x326479,0x7(%rsp)
mov    %rsp,%rdi
call   1050 <open_port@plt>
test   %eax,%eax
je     11bc <Move+0x7c>
mov    %eax,%ebx
lea    0x10(%rsp),%rsi
mov    %eax,%edi
mov    $0xd,%edx
call   1030 <write@plt>
lea    0xe79(%rip),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
mov    %ebx,%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%union.CoordString = type { i64 }
@__const.Move.TestMove = [13 x i8] c"m\01\00\00\00\02\00\00\00\03\00\00\00"
@__const.Move.term = [11 x i8] c"/dev/ttyd2\00"
@.str = [2 x i8] c"\0D\00"
define i32 @Move() {
%1 = alloca i32
%2 = alloca %union.CoordString
%3 = alloca %union.CoordString
%4 = alloca %union.CoordString
%5 = alloca i32
%6 = alloca [13 x i8]
%7 = alloca [11 x i8]
%8 = alloca i32
%9 = bitcast [13 x i8]* %6 to i8*
%10 = bitcast [11 x i8]* %7 to i8*
%11 = getelementptr inbounds [11 x i8], [11 x i8]* %7, i64 0, i64 0
%12 = call i32 @open_port(i8* %11)
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %0
store i32 0, i32* %1
br label %25
16: ; preds = %0
%17 = load i32, i32* %8
%18 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 0
%19 = call i32 @write(i32 %17, i8* %18, i32 13)
%20 = load i32, i32* %8
%21 = call i32 @write(i32 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%22 = call i32 @sleep(i32 1)
%23 = load i32, i32* %8
%24 = call i32 @close(i32 %23)
store i32 0, i32* %1
br label %25
25: ; preds = %16, %15
%26 = load i32, i32* %1
ret i32 %26
}

LLVM IR (-O2):
@__const.Move.TestMove = [13 x i8] c"m\01\00\00\00\02\00\00\00\03\00\00\00"
@__const.Move.term = [11 x i8] c"/dev/ttyd2\00"
@.str = [2 x i8] c"\0D\00"
define i32 @Move() {
%1 = alloca [13 x i8]
%2 = alloca [11 x i8]
%3 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [11 x i8], [11 x i8]* %2, i64 0, i64 0
%5 = call i32 @open_port(i8* %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %0
%8 = call i32 @write(i32 %5, i8* %3, i32 13)
%9 = call i32 @write(i32 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%10 = call i32 @sleep(i32 1)
%11 = call i32 @close(i32 %5)
br label %12
12: ; preds = %0, %7
ret i32 0
}