#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*/ SpiWrite(unsigned char *, unsigned char);
unsigned char *UINT16_TO_STREAM_f(unsigned char *, unsigned char);
void hci_data_command_send(unsigned short usOpcode, unsigned char *pucBuff,
                           unsigned char ucArgsLength,
                           unsigned short ucDataLength) {
  unsigned char *stream = (pucBuff + (5));
  { *(stream)++ = (0x2); };
  { *(stream)++ = (usOpcode); };
  { *(stream)++ = (ucArgsLength); };
  stream = (UINT16_TO_STREAM_f(stream, ucArgsLength + ucDataLength));
  SpiWrite(pucBuff, ucArgsLength + ucDataLength + (5));
  return;
}


x86 assembly (clang, -O0):
<hci_data_command_send>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cx,%ax
mov    %dl,%cl
mov    %di,%dx
mov    %dx,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %cl,-0x11(%rbp)
mov    %ax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x2,(%rax)
mov    -0x2(%rbp),%ax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x11(%rbp),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%rdi
movzbl -0x11(%rbp),%eax
movzwl -0x14(%rbp),%ecx
add    %ecx,%eax
movzbl %al,%esi
call   1030 <UINT16_TO_STREAM_f@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
movzbl -0x11(%rbp),%eax
movzwl -0x14(%rbp),%ecx
add    %ecx,%eax
add    $0x5,%eax
movzbl %al,%esi
call   1040 <SpiWrite@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hci_data_command_send>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
movb   $0x2,0x5(%rsi)
mov    %dil,0x6(%rsi)
lea    0x8(%rsi),%rdi
mov    %dl,0x7(%rsi)
add    %dl,%cl
movzbl %cl,%ebp
mov    %ebp,%esi
call   1030 <UINT16_TO_STREAM_f@plt>
add    $0x5,%bpl
movzbl %bpl,%esi
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <SpiWrite@plt>

LLVM IR (-O0):
define void @hci_data_command_send(i16 zeroext %0, i8* %1, i8 zeroext %2, i16 zeroext %3) {
%5 = alloca i16
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i16
%9 = alloca i8*
store i16 %0, i16* %5
store i8* %1, i8** %6
store i8 %2, i8* %7
store i16 %3, i16* %8
%10 = load i8*, i8** %6
%11 = getelementptr inbounds i8, i8* %10, i64 5
store i8* %11, i8** %9
%12 = load i8*, i8** %9
%13 = getelementptr inbounds i8, i8* %12, i32 1
store i8* %13, i8** %9
store i8 2, i8* %12
%14 = load i16, i16* %5
%15 = trunc i16 %14 to i8
%16 = load i8*, i8** %9
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %9
store i8 %15, i8* %16
%18 = load i8, i8* %7
%19 = load i8*, i8** %9
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %9
store i8 %18, i8* %19
%21 = load i8*, i8** %9
%22 = load i8, i8* %7
%23 = zext i8 %22 to i32
%24 = load i16, i16* %8
%25 = zext i16 %24 to i32
%26 = add nsw i32 %23, %25
%27 = trunc i32 %26 to i8
%28 = call i8* @UINT16_TO_STREAM_f(i8* %21, i8 zeroext %27)
store i8* %28, i8** %9
%29 = load i8*, i8** %6
%30 = load i8, i8* %7
%31 = zext i8 %30 to i32
%32 = load i16, i16* %8
%33 = zext i16 %32 to i32
%34 = add nsw i32 %31, %33
%35 = add nsw i32 %34, 5
%36 = trunc i32 %35 to i8
%37 = call i32 @SpiWrite(i8* %29, i8 zeroext %36)
ret void
}

LLVM IR (-O2):
define void @hci_data_command_send(i16 zeroext %0, i8* %1, i8 zeroext %2, i16 zeroext %3) {
%5 = getelementptr inbounds i8, i8* %1, i64 5
%6 = getelementptr inbounds i8, i8* %1, i64 6
store i8 2, i8* %5
%7 = trunc i16 %0 to i8
%8 = getelementptr inbounds i8, i8* %1, i64 7
store i8 %7, i8* %6
%9 = getelementptr inbounds i8, i8* %1, i64 8
store i8 %2, i8* %8
%10 = trunc i16 %3 to i8
%11 = add i8 %10, %2
%12 = tail call i8* @UINT16_TO_STREAM_f(i8* %9, i8 zeroext %11)
%13 = add i8 %11, 5
%14 = tail call i32 @SpiWrite(i8* %1, i8 zeroext %13)
ret void
}