#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 short);
unsigned short hci_command_send(unsigned short usOpcode, unsigned char *pucBuff,
                                unsigned char ucArgsLength) {
  unsigned char *stream;
  stream = (pucBuff + (5));
  { *(stream)++ = (0x1); };
  stream = (UINT16_TO_STREAM_f(stream, usOpcode));
  { *(stream)++ = (ucArgsLength); };
  SpiWrite(pucBuff, ucArgsLength + (4));
  return (0);
}


x86 assembly (clang, -O0):
<hci_command_send>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %di,%cx
mov    %cx,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%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   $0x1,(%rax)
mov    -0x20(%rbp),%rdi
movzwl -0x2(%rbp),%esi
call   1030 <UINT16_TO_STREAM_f@plt>
mov    %rax,-0x20(%rbp)
mov    -0x11(%rbp),%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
mov    -0x10(%rbp),%rdi
movzbl -0x11(%rbp),%eax
add    $0x4,%eax
movzbl %al,%esi
call   1040 <SpiWrite@plt>
xor    %eax,%eax
movzwl %ax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hci_command_send>:
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,%r14
mov    %edi,%esi
lea    0x6(%r14),%rdi
movb   $0x1,0x5(%r14)
call   1030 <UINT16_TO_STREAM_f@plt>
mov    %bl,(%rax)
add    $0x4,%bl
movzbl %bl,%esi
mov    %r14,%rdi
call   1040 <SpiWrite@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define zeroext i16 @hci_command_send(i16 zeroext %0, i8* %1, i8 zeroext %2) {
%4 = alloca i16
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8*
store i16 %0, i16* %4
store i8* %1, i8** %5
store i8 %2, i8* %6
%8 = load i8*, i8** %5
%9 = getelementptr inbounds i8, i8* %8, i64 5
store i8* %9, i8** %7
%10 = load i8*, i8** %7
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %7
store i8 1, i8* %10
%12 = load i8*, i8** %7
%13 = load i16, i16* %4
%14 = call i8* @UINT16_TO_STREAM_f(i8* %12, i16 zeroext %13)
store i8* %14, i8** %7
%15 = load i8, i8* %6
%16 = load i8*, i8** %7
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %7
store i8 %15, i8* %16
%18 = load i8*, i8** %5
%19 = load i8, i8* %6
%20 = zext i8 %19 to i32
%21 = add nsw i32 %20, 4
%22 = trunc i32 %21 to i8
%23 = call i32 @SpiWrite(i8* %18, i8 zeroext %22)
ret i16 0
}

LLVM IR (-O2):
define zeroext i16 @hci_command_send(i16 zeroext %0, i8* %1, i8 zeroext %2) {
%4 = getelementptr inbounds i8, i8* %1, i64 5
%5 = getelementptr inbounds i8, i8* %1, i64 6
store i8 1, i8* %4
%6 = tail call i8* @UINT16_TO_STREAM_f(i8* %5, i16 zeroext %0)
store i8 %2, i8* %6
%7 = add i8 %2, 4
%8 = tail call i32 @SpiWrite(i8* %1, i8 zeroext %7)
ret i16 0
}