#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 */
unsigned char genchecksum(unsigned char *, int);
int /*<<< orphan*/ usleep(int);
int /*<<< orphan*/ write(int, unsigned char *, int);
void sendcommand(int fd, unsigned char marker, unsigned char *frame,
                 int framelength) {
  unsigned char markerframe[1];
  unsigned char checksum[1];
  markerframe[0] = marker;
  write(fd, markerframe, 1);
  usleep(20 * 1000);
  write(fd, frame, framelength);
  checksum[0] = genchecksum(frame, framelength);
  write(fd, checksum, 1);
}


x86 assembly (clang, -O0):
<sendcommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x5(%rbp),%al
mov    %al,-0x15(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x15(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x4e20,%edi
call   1050 <usleep@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <write@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <genchecksum@plt>
mov    %al,-0x16(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x16(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendcommand>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r14d
mov    %rdx,%rbp
mov    %edi,%ebx
mov    %sil,0xf(%rsp)
lea    0xf(%rsp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x4e20,%edi
call   1050 <usleep@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1030 <write@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
call   1040 <genchecksum@plt>
mov    %al,0xe(%rsp)
lea    0xe(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @sendcommand(i32 %0, i8 zeroext %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8
%7 = alloca i8*
%8 = alloca i32
%9 = alloca [1 x i8]
%10 = alloca [1 x i8]
store i32 %0, i32* %5
store i8 %1, i8* %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = load i8, i8* %6
%12 = getelementptr inbounds [1 x i8], [1 x i8]* %9, i64 0, i64 0
store i8 %11, i8* %12
%13 = load i32, i32* %5
%14 = getelementptr inbounds [1 x i8], [1 x i8]* %9, i64 0, i64 0
%15 = call i32 @write(i32 %13, i8* %14, i32 1)
%16 = call i32 @usleep(i32 20000)
%17 = load i32, i32* %5
%18 = load i8*, i8** %7
%19 = load i32, i32* %8
%20 = call i32 @write(i32 %17, i8* %18, i32 %19)
%21 = load i8*, i8** %7
%22 = load i32, i32* %8
%23 = call zeroext i8 @genchecksum(i8* %21, i32 %22)
%24 = getelementptr inbounds [1 x i8], [1 x i8]* %10, i64 0, i64 0
store i8 %23, i8* %24
%25 = load i32, i32* %5
%26 = getelementptr inbounds [1 x i8], [1 x i8]* %10, i64 0, i64 0
%27 = call i32 @write(i32 %25, i8* %26, i32 1)
ret void
}

LLVM IR (-O2):
define void @sendcommand(i32 %0, i8 zeroext %1, i8* %2, i32 %3) {
%5 = alloca [1 x i8]
%6 = alloca [1 x i8]
%7 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
%8 = getelementptr inbounds [1 x i8], [1 x i8]* %6, i64 0, i64 0
store i8 %1, i8* %7
%9 = call i32 @write(i32 %0, i8* %7, i32 1)
%10 = tail call i32 @usleep(i32 20000)
%11 = tail call i32 @write(i32 %0, i8* %2, i32 %3)
%12 = tail call zeroext i8 @genchecksum(i8* %2, i32 %3)
store i8 %12, i8* %8
%13 = call i32 @write(i32 %0, i8* %8, i32 1)
ret void
}