#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 uint8_t;
typedef int /*<<< orphan*/ packet;

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ TCSBRKP;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ ioctl(int, int /*<<< orphan*/, int);
int open_serial(char *);
int /*<<< orphan*/ write(int, int const *, int);
int main(int argc, char *argv[]) {
  const static uint8_t packet[] = {0,    0xda, 0x01, 0x02, 0x03,
                                   0x04, 0xde, 0xff, 0x34};
  int fd = open_serial(argv[1]);
  ioctl(fd, TCSBRKP, 1);
  write(fd, packet, sizeof(packet));
  close(fd);
  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    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <open_serial@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
mov    $0x1,%edx
call   1040 <ioctl@plt>
mov    -0x14(%rbp),%edi
lea    0xe7a(%rip),%rsi
mov    $0x24,%edx
call   1030 <write@plt>
mov    -0x14(%rbp),%edi
call   1050 <close@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x8(%rsi),%rdi
call   1060 <open_serial@plt>
mov    %eax,%ebx
mov    0x2e9d(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
mov    $0x1,%edx
call   1040 <ioctl@plt>
lea    0xe98(%rip),%rsi
mov    %ebx,%edi
mov    $0x24,%edx
call   1030 <write@plt>
mov    %ebx,%edi
call   1050 <close@plt>
mov    0x2e56(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@main.packet = internal constant [9 x i32] [i32 0, i32 218, i32 1, i32 2, i32 3, i32 4, i32 222, i32 255, i32 52]
@TCSBRKP = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = call i32 @open_serial(i8* %9)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = load i32, i32* @TCSBRKP
%13 = call i32 @ioctl(i32 %11, i32 %12, i32 1)
%14 = load i32, i32* %6
%15 = call i32 @write(i32 %14, i32* getelementptr inbounds ([9 x i32], [9 x i32]* @main.packet, i64 0, i64 0), i32 36)
%16 = load i32, i32* %6
%17 = call i32 @close(i32 %16)
%18 = load i32, i32* @EXIT_SUCCESS
ret i32 %18
}

LLVM IR (-O2):
@main.packet = internal constant [9 x i32] [i32 0, i32 218, i32 1, i32 2, i32 3, i32 4, i32 222, i32 255, i32 52]
@TCSBRKP = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @open_serial(i8* %4)
%6 = load i32, i32* @TCSBRKP
%7 = tail call i32 @ioctl(i32 %5, i32 %6, i32 1)
%8 = tail call i32 @write(i32 %5, i32* getelementptr inbounds ([9 x i32], [9 x i32]* @main.packet, i64 0, i64 0), i32 36)
%9 = tail call i32 @close(i32 %5)
%10 = load i32, i32* @EXIT_SUCCESS
ret i32 %10
}