#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 unsigned char *ucArgs;

/* Variables and functions */
int /*<<< orphan*/ SpiWrite(unsigned char *, int);
unsigned char *UINT16_TO_STREAM_f(unsigned char *, unsigned short);
long hci_data_send(unsigned char ucOpcode, unsigned char *ucArgs,
                   unsigned short usArgsLength, unsigned short usDataLength,
                   const unsigned char *ucTail, unsigned short usTailLength) {
  unsigned char *stream;
  stream = ((ucArgs) + (5));
  { *(stream)++ = (0x2); };
  { *(stream)++ = (ucOpcode); };
  { *(stream)++ = (usArgsLength); };
  stream =
      (UINT16_TO_STREAM_f(stream, usArgsLength + usDataLength + usTailLength));
  SpiWrite(ucArgs, (5) + usArgsLength + usDataLength + usTailLength);
  return (0);
}


x86 assembly (clang, -O0):
<hci_data_send>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %r9w,%ax
mov    %dil,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %dx,-0x12(%rbp)
mov    %cx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
mov    %ax,-0x22(%rbp)
mov    -0x10(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0x2,(%rax)
mov    -0x1(%rbp),%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
mov    -0x12(%rbp),%ax
mov    %al,%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
mov    -0x30(%rbp),%rdi
movzwl -0x12(%rbp),%eax
movzwl -0x14(%rbp),%ecx
add    %ecx,%eax
movzwl -0x22(%rbp),%ecx
add    %ecx,%eax
movzwl %ax,%esi
call   1030 <UINT16_TO_STREAM_f@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
movzwl -0x12(%rbp),%esi
add    $0x5,%esi
movzwl -0x14(%rbp),%eax
add    %eax,%esi
movzwl -0x22(%rbp),%eax
add    %eax,%esi
call   1040 <SpiWrite@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hci_data_send>:
push   %r15
push   %r14
push   %rbx
mov    %r9d,%r14d
mov    %ecx,%r15d
mov    %rsi,%rbx
movb   $0x2,0x5(%rsi)
mov    %dil,0x6(%rsi)
lea    0x8(%rsi),%rdi
mov    %dl,0x7(%rsi)
add    %edx,%r15d
lea    (%r15,%r14,1),%eax
movzwl %ax,%esi
call   1030 <UINT16_TO_STREAM_f@plt>
lea    (%r14,%r15,1),%esi
add    $0x5,%esi
mov    %rbx,%rdi
call   1040 <SpiWrite@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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