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

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ close(int);
int open_port(char *, int);
int /*<<< orphan*/ perror(char *);
int write(int, char *, int);
int main(int argc, char **argv) {
  char data[7] = {'\n', 17, ' ', 5, ' ', 13, '\n'};
  int check;
  int writeport = open_port("/dev/ttymxc3", 9600);
  check = write(writeport, data, sizeof(data));
  if (check < 0) {
    perror("write");
  }
  close(writeport);
  (void)argc;
  (void)argv;
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xea4(%rip),%eax
mov    %eax,-0x17(%rbp)
mov    0xe9e(%rip),%ax
mov    %ax,-0x13(%rbp)
mov    0xe96(%rip),%al
mov    %al,-0x11(%rbp)
lea    0xe8d(%rip),%rdi
mov    $0x2580,%esi
call   1060 <open_port@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x17(%rbp),%rsi
mov    $0x7,%edx
call   1030 <write@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11b1 <main+0x71>
lea    0xe68(%rip),%rdi
call   1050 <perror@plt>
mov    -0x20(%rbp),%edi
call   1040 <close@plt>
mov    0x2e20(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0xa0d2005,0xb(%rsp)
0a
movl   $0x520110a,0x8(%rsp)
05
lea    0xeab(%rip),%rdi
mov    $0x2580,%esi
call   1060 <open_port@plt>
mov    %eax,%ebx
lea    0x8(%rsp),%rsi
mov    %eax,%edi
mov    $0x7,%edx
call   1030 <write@plt>
test   %eax,%eax
js     1193 <main+0x53>
mov    %ebx,%edi
call   1040 <close@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe7a(%rip),%rdi
call   1050 <perror@plt>
jmp    117d <main+0x3d>

LLVM IR (-O0):
@__const.main.data = [7 x i8] c"\0A\11 \05 \0D\0A"
@.str = [13 x i8] c"/dev/ttymxc3\00"
@.str.1 = [6 x i8] c"write\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [7 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [7 x i8]* %6 to i8*
%10 = call i32 @open_port(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 9600)
store i32 %10, i32* %8
%11 = load i32, i32* %8
%12 = getelementptr inbounds [7 x i8], [7 x i8]* %6, i64 0, i64 0
%13 = call i32 @write(i32 %11, i8* %12, i32 7)
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %2
%19 = load i32, i32* %8
%20 = call i32 @close(i32 %19)
%21 = load i32, i32* %4
%22 = load i8**, i8*** %5
%23 = load i32, i32* @EXIT_SUCCESS
ret i32 %23
}

LLVM IR (-O2):
@__const.main.data = [7 x i8] c"\0A\11 \05 \0D\0A"
@.str = [13 x i8] c"/dev/ttymxc3\00"
@.str.1 = [6 x i8] c"write\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [7 x i8]
%4 = getelementptr inbounds [7 x i8], [7 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @open_port(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 9600)
%6 = call i32 @write(i32 %5, i8* %4, i32 7)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %2
%11 = tail call i32 @close(i32 %5)
%12 = load i32, i32* @EXIT_SUCCESS
ret i32 %12
}