#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 int crc16(int, char *, unsigned int);
int /*<<< orphan*/ send_data(int, char *, unsigned int);
void send_manual_data(int fd, char *buf, unsigned int size) {
  unsigned int crc_checksum;
  crc_checksum = crc16(0xffff, buf, size);
  buf[size++] = (char)(crc_checksum & 0xff);
  buf[size++] = (char)((crc_checksum >> 8) & 0xff);
  send_data(fd, buf, size);
}


x86 assembly (clang, -O0):
<send_manual_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    $0xffff,%edi
call   1040 <crc16@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
and    $0xff,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
shr    $0x8,%eax
and    $0xff,%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x14(%rbp)
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <send_data@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_manual_data>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebx
mov    %rsi,%rbp
mov    %edi,%r14d
mov    $0xffff,%edi
call   1040 <crc16@plt>
lea    0x1(%rbx),%ecx
mov    %ebx,%edx
mov    %al,0x0(%rbp,%rdx,1)
add    $0x2,%ebx
mov    %ah,0x0(%rbp,%rcx,1)
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %ebx,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <send_data@plt>

LLVM IR (-O0):
define void @send_manual_data(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%8 = load i8*, i8** %5
%9 = load i32, i32* %6
%10 = call i32 @crc16(i32 65535, i8* %8, i32 %9)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = and i32 %11, 255
%13 = trunc i32 %12 to i8
%14 = load i8*, i8** %5
%15 = load i32, i32* %6
%16 = add i32 %15, 1
store i32 %16, i32* %6
%17 = zext i32 %15 to i64
%18 = getelementptr inbounds i8, i8* %14, i64 %17
store i8 %13, i8* %18
%19 = load i32, i32* %7
%20 = lshr i32 %19, 8
%21 = and i32 %20, 255
%22 = trunc i32 %21 to i8
%23 = load i8*, i8** %5
%24 = load i32, i32* %6
%25 = add i32 %24, 1
store i32 %25, i32* %6
%26 = zext i32 %24 to i64
%27 = getelementptr inbounds i8, i8* %23, i64 %26
store i8 %22, i8* %27
%28 = load i32, i32* %4
%29 = load i8*, i8** %5
%30 = load i32, i32* %6
%31 = call i32 @send_data(i32 %28, i8* %29, i32 %30)
ret void
}

LLVM IR (-O2):
define void @send_manual_data(i32 %0, i8* %1, i32 %2) {
%4 = tail call i32 @crc16(i32 65535, i8* %1, i32 %2)
%5 = trunc i32 %4 to i8
%6 = add i32 %2, 1
%7 = zext i32 %2 to i64
%8 = getelementptr inbounds i8, i8* %1, i64 %7
store i8 %5, i8* %8
%9 = lshr i32 %4, 8
%10 = trunc i32 %9 to i8
%11 = add i32 %2, 2
%12 = zext i32 %6 to i64
%13 = getelementptr inbounds i8, i8* %1, i64 %12
store i8 %10, i8* %13
%14 = tail call i32 @send_data(i32 %0, i8* %1, i32 %11)
ret void
}