#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 int uint8_t;
typedef scalar_t__ uint16_t;
typedef int /*<<< orphan*/ test3;
typedef int /*<<< orphan*/ test2;
typedef int /*<<< orphan*/ test1;
typedef int /*<<< orphan*/ test0;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
scalar_t__ crc16(int *, size_t);
int main(void) {
  uint8_t test0[] = {0};
  size_t test0_size = sizeof(test0) / sizeof(uint8_t);
  uint16_t test0_crc = crc16(test0, test0_size);
  assert(0 == test0_crc);
  uint8_t test1[] = {1};
  size_t test1_size = sizeof(test1) / sizeof(uint8_t);
  uint16_t test1_crc = crc16(test1, test1_size);
  assert(0xd175 == test1_crc);
  uint8_t test2[] = {0x47, 1, 5, 0, 0, 0, 0, 0, 1};
  size_t test2_size = sizeof(test2) / sizeof(uint8_t);
  uint16_t test2_crc = crc16(test2, test2_size);
  assert(0xfcbe == test2_crc);
  uint8_t test3[] = {'a', 'b', 'c'};
  size_t test3_size = sizeof(test3) / sizeof(uint8_t);
  uint16_t test3_crc = crc16(test3, test3_size);
  assert(0x713c == test3_crc);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
movq   $0x1,-0x10(%rbp)
lea    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <crc16@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    0xe7c(%rip),%eax
mov    %eax,-0x1c(%rbp)
movq   $0x1,-0x28(%rbp)
lea    -0x1c(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <crc16@plt>
mov    %rax,-0x30(%rbp)
mov    $0xd175,%eax
cmp    -0x30(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x24,%edx
call   1030 <memset@plt>
movl   $0x47,-0x60(%rbp)
movl   $0x1,-0x5c(%rbp)
movl   $0x5,-0x58(%rbp)
movl   $0x1,-0x40(%rbp)
movq   $0x9,-0x68(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x68(%rbp),%rsi
call   1050 <crc16@plt>
mov    %rax,-0x70(%rbp)
mov    $0xfcbe,%eax
cmp    -0x70(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    0xdec(%rip),%rax
mov    %rax,-0x7c(%rbp)
mov    0xdea(%rip),%eax
mov    %eax,-0x74(%rbp)
movq   $0x3,-0x88(%rbp)
lea    -0x7c(%rbp),%rdi
mov    -0x88(%rbp),%rsi
call   1050 <crc16@plt>
mov    %rax,-0x90(%rbp)
mov    $0x713c,%eax
cmp    -0x90(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x48,%rsp
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rdi
mov    $0x1,%esi
call   1040 <crc16@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1030 <assert@plt>
movl   $0x1,0x8(%rsp)
lea    0x8(%rsp),%rdi
mov    $0x1,%esi
call   1040 <crc16@plt>
xor    %edi,%edi
cmp    $0xd175,%rax
sete   %dil
call   1030 <assert@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movabs $0x100000047,%rax
mov    %rax,0x20(%rsp)
movl   $0x5,0x28(%rsp)
movl   $0x1,0x40(%rsp)
lea    0x20(%rsp),%rdi
mov    $0x9,%esi
call   1040 <crc16@plt>
xor    %edi,%edi
cmp    $0xfcbe,%rax
sete   %dil
call   1030 <assert@plt>
mov    0xe45(%rip),%eax
mov    %eax,0x18(%rsp)
mov    0xe32(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x3,%esi
call   1040 <crc16@plt>
xor    %edi,%edi
cmp    $0x713c,%rax
sete   %dil
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x48,%rsp
ret

LLVM IR (-O0):
@__const.main.test1 = [1 x i32] [i32 1]
@__const.main.test3 = [3 x i32] [i32 97, i32 98, i32 99]
define i32 @main() {
%1 = alloca i32
%2 = alloca [1 x i32]
%3 = alloca i64
%4 = alloca i64
%5 = alloca [1 x i32]
%6 = alloca i64
%7 = alloca i64
%8 = alloca [9 x i32]
%9 = alloca i64
%10 = alloca i64
%11 = alloca [3 x i32]
%12 = alloca i64
%13 = alloca i64
store i32 0, i32* %1
%14 = bitcast [1 x i32]* %2 to i8*
store i64 1, i64* %3
%15 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
%16 = load i64, i64* %3
%17 = call i64 @crc16(i32* %15, i64 %16)
store i64 %17, i64* %4
%18 = load i64, i64* %4
%19 = icmp eq i64 0, %18
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = bitcast [1 x i32]* %5 to i8*
store i64 1, i64* %6
%23 = getelementptr inbounds [1 x i32], [1 x i32]* %5, i64 0, i64 0
%24 = load i64, i64* %6
%25 = call i64 @crc16(i32* %23, i64 %24)
store i64 %25, i64* %7
%26 = load i64, i64* %7
%27 = icmp eq i64 53621, %26
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = bitcast [9 x i32]* %8 to i8*
%31 = bitcast i8* %30 to [9 x i32]*
%32 = getelementptr inbounds [9 x i32], [9 x i32]* %31, i32 0, i32 0
store i32 71, i32* %32
%33 = getelementptr inbounds [9 x i32], [9 x i32]* %31, i32 0, i32 1
store i32 1, i32* %33
%34 = getelementptr inbounds [9 x i32], [9 x i32]* %31, i32 0, i32 2
store i32 5, i32* %34
%35 = getelementptr inbounds [9 x i32], [9 x i32]* %31, i32 0, i32 8
store i32 1, i32* %35
store i64 9, i64* %9
%36 = getelementptr inbounds [9 x i32], [9 x i32]* %8, i64 0, i64 0
%37 = load i64, i64* %9
%38 = call i64 @crc16(i32* %36, i64 %37)
store i64 %38, i64* %10
%39 = load i64, i64* %10
%40 = icmp eq i64 64702, %39
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
%43 = bitcast [3 x i32]* %11 to i8*
store i64 3, i64* %12
%44 = getelementptr inbounds [3 x i32], [3 x i32]* %11, i64 0, i64 0
%45 = load i64, i64* %12
%46 = call i64 @crc16(i32* %44, i64 %45)
store i64 %46, i64* %13
%47 = load i64, i64* %13
%48 = icmp eq i64 28988, %47
%49 = zext i1 %48 to i32
%50 = call i32 @assert(i32 %49)
ret i32 0
}

LLVM IR (-O2):
@__const.main.test3 = [3 x i32] [i32 97, i32 98, i32 99]
define i32 @main() {
%1 = alloca [1 x i32]
%2 = alloca [1 x i32]
%3 = alloca [9 x i32]
%4 = alloca [3 x i32]
%5 = bitcast [1 x i32]* %1 to i8*
%6 = getelementptr inbounds [1 x i32], [1 x i32]* %1, i64 0, i64 0
store i32 0, i32* %6
%7 = call i64 @crc16(i32* %6, i64 1)
%8 = icmp eq i64 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = bitcast [1 x i32]* %2 to i8*
%12 = getelementptr inbounds [1 x i32], [1 x i32]* %2, i64 0, i64 0
store i32 1, i32* %12
%13 = call i64 @crc16(i32* %12, i64 1)
%14 = icmp eq i64 %13, 53621
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = bitcast [9 x i32]* %3 to i8*
%18 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 0
store i32 71, i32* %18
%19 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 1
store i32 1, i32* %19
%20 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 2
store i32 5, i32* %20
%21 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 8
store i32 1, i32* %21
%22 = call i64 @crc16(i32* %18, i64 9)
%23 = icmp eq i64 %22, 64702
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = bitcast [3 x i32]* %4 to i8*
%27 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%28 = call i64 @crc16(i32* %27, i64 3)
%29 = icmp eq i64 %28, 28988
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
ret i32 0
}