#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 int uint16_t;
typedef int /*<<< orphan*/ testdata;

/* Variables and functions */
int CRCCCITT(int *, int, int, int);
int /*<<< orphan*/ printf(char *, int);
void crc_test(void) {
  uint8_t testdata[] = {0x25, 0x3b, 0x05, 0x3f, 0x21,
                        0x00, 0x00, 0x00, 0x00, 0x00};
  uint16_t crc = CRCCCITT(testdata, sizeof(testdata), 0xffff, 0xffff);
  printf("crc test: %04x", crc);
}


x86 assembly (clang, -O0):
<crc_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1040 <memset@plt>
movl   $0x25,-0x30(%rbp)
movl   $0x3b,-0x2c(%rbp)
movl   $0x5,-0x28(%rbp)
movl   $0x3f,-0x24(%rbp)
movl   $0x21,-0x20(%rbp)
lea    -0x30(%rbp),%rdi
mov    $0x28,%esi
mov    $0xffff,%ecx
mov    %ecx,%edx
call   1050 <CRCCCITT@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%esi
lea    0xe73(%rip),%rdi
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crc_test>:
sub    $0x28,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x21,0x10(%rsp)
mov    %rsp,%rdi
mov    $0x28,%esi
mov    $0xffff,%edx
mov    $0xffff,%ecx
call   1040 <CRCCCITT@plt>
lea    0xeaa(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"crc test: %04x\00"
define void @crc_test() {
%1 = alloca [10 x i32]
%2 = alloca i32
%3 = bitcast [10 x i32]* %1 to i8*
%4 = bitcast i8* %3 to [10 x i32]*
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i32 0, i32 0
store i32 37, i32* %5
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i32 0, i32 1
store i32 59, i32* %6
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i32 0, i32 2
store i32 5, i32* %7
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i32 0, i32 3
store i32 63, i32* %8
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i32 0, i32 4
store i32 33, i32* %9
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%11 = call i32 @CRCCCITT(i32* %10, i32 40, i32 65535, i32 65535)
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %12)
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"crc test: %04x\00"
define void @crc_test() {
%1 = alloca [10 x i32]
%2 = bitcast [10 x i32]* %1 to i8*
%3 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
%4 = bitcast i32* %3 to i8*
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 0
%6 = bitcast [10 x i32]* %1 to <4 x i32>*
store <4 x i32> <i32 37, i32 59, i32 5, i32 63>, <4 x i32>* %6
%7 = getelementptr inbounds [10 x i32], [10 x i32]* %1, i64 0, i64 4
store i32 33, i32* %7
%8 = call i32 @CRCCCITT(i32* %5, i32 40, i32 65535, i32 65535)
%9 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %8)
ret void
}