#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 short crc16_inet(int /*<<< orphan*/, unsigned char *, unsigned short);
int /*<<< orphan*/ printf(char *, unsigned short, unsigned short,
                          unsigned short);
unsigned char random();
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/);
int main() {
  unsigned char array[1024];
  unsigned char array1[1024 + 1];
  unsigned short i, sum, sum1;
  srandom(time(0));
  for (i = 0; i < 1024; ++i)
    array1[i + 1] = array[i] = random();
  for (i = 1; i < 1024; ++i) {
    sum = crc16_inet(0, array, i);
    sum1 = crc16_inet(0, array1 + 1, i);
    sum1 = sum1 >> 8 | sum1 << 8;
    if (sum != sum1)
      printf("[%d] - %02x - %02x\n", i, sum, sum1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
movw   $0x0,-0x822(%rbp)
movzwl -0x822(%rbp),%eax
cmp    $0x400,%eax
jge    11cc <main+0x7c>
mov    $0x0,%al
call   1060 <random@plt>
mov    %al,%cl
movzwl -0x822(%rbp),%eax
mov    %cl,-0x410(%rbp,%rax,1)
movzwl -0x822(%rbp),%eax
add    $0x1,%eax
cltq
mov    %cl,-0x820(%rbp,%rax,1)
mov    -0x822(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x822(%rbp)
jmp    1179 <main+0x29>
movw   $0x1,-0x822(%rbp)
movzwl -0x822(%rbp),%eax
cmp    $0x400,%eax
jge    1299 <main+0x149>
lea    -0x410(%rbp),%rsi
xor    %edi,%edi
movzwl -0x822(%rbp),%edx
call   1070 <crc16_inet@plt>
mov    %ax,-0x824(%rbp)
lea    -0x820(%rbp),%rsi
add    $0x1,%rsi
xor    %edi,%edi
movzwl -0x822(%rbp),%edx
call   1070 <crc16_inet@plt>
mov    %ax,-0x826(%rbp)
movzwl -0x826(%rbp),%eax
sar    $0x8,%eax
movzwl -0x826(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %ax,-0x826(%rbp)
movzwl -0x824(%rbp),%eax
movzwl -0x826(%rbp),%ecx
cmp    %ecx,%eax
je     127d <main+0x12d>
mov    -0x822(%rbp),%cx
mov    -0x824(%rbp),%ax
lea    0xd95(%rip),%rdi
movzwl %cx,%esi
movzwl %ax,%edx
movzwl -0x826(%rbp),%ecx
call   1040 <printf@plt>
jmp    1282 <main+0x132>
mov    -0x822(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x822(%rbp)
jmp    11d5 <main+0x85>
xor    %eax,%eax
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <random@plt>
mov    %al,(%rsp,%rbx,1)
mov    %al,0x401(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x400,%rbx
jne    1180 <main+0x30>
mov    $0x1,%bx
lea    0x401(%rsp),%r14
mov    %rsp,%r12
lea    0xe4c(%rip),%r15
jmp    11cd <main+0x7d>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebx
movzwl %bx,%eax
cmp    $0x400,%eax
je     1208 <main+0xb8>
movzwl %bx,%ebp
xor    %edi,%edi
mov    %r12,%rsi
mov    %ebp,%edx
call   1070 <crc16_inet@plt>
mov    %eax,%r13d
xor    %edi,%edi
mov    %r14,%rsi
mov    %ebp,%edx
call   1070 <crc16_inet@plt>
rol    $0x8,%ax
cmp    %ax,%r13w
je     11c0 <main+0x70>
movzwl %r13w,%edx
movzwl %ax,%ecx
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
jmp    11c0 <main+0x70>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"[%d] - %02x - %02x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca [1025 x i8]
%4 = alloca i16
%5 = alloca i16
%6 = alloca i16
store i32 0, i32* %1
%7 = call i32 @time(i32 0)
%8 = call i32 @srandom(i32 %7)
store i16 0, i16* %4
br label %9
9: ; preds = %23, %0
%10 = load i16, i16* %4
%11 = zext i16 %10 to i32
%12 = icmp slt i32 %11, 1024
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = call zeroext i8 (...) @random()
%15 = load i16, i16* %4
%16 = zext i16 %15 to i64
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %16
store i8 %14, i8* %17
%18 = load i16, i16* %4
%19 = zext i16 %18 to i32
%20 = add nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 %21
store i8 %14, i8* %22
br label %23
23: ; preds = %13
%24 = load i16, i16* %4
%25 = add i16 %24, 1
store i16 %25, i16* %4
br label %9
26: ; preds = %9
store i16 1, i16* %4
br label %27
27: ; preds = %58, %26
%28 = load i16, i16* %4
%29 = zext i16 %28 to i32
%30 = icmp slt i32 %29, 1024
br i1 %30, label %31, label %61
31: ; preds = %27
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%33 = load i16, i16* %4
%34 = call zeroext i16 @crc16_inet(i32 0, i8* %32, i16 zeroext %33)
store i16 %34, i16* %5
%35 = getelementptr inbounds [1025 x i8], [1025 x i8]* %3, i64 0, i64 0
%36 = getelementptr inbounds i8, i8* %35, i64 1
%37 = load i16, i16* %4
%38 = call zeroext i16 @crc16_inet(i32 0, i8* %36, i16 zeroext %37)
store i16 %38, i16* %6
%39 = load i16, i16* %6
%40 = zext i16 %39 to i32
%41 = ashr i32 %40, 8
%42 = load i16, i16* %6
%43 = zext i16 %42 to i32
%44 = shl i32 %43, 8
%45 = or i32 %41, %44
%46 = trunc i32 %45 to i16
store i16 %46, i16* %6
%47 = load i16, i16* %5
%48 = zext i16 %47 to i32
%49 = load i16, i16* %6
%50 = zext i16 %49 to i32
%51 = icmp ne i32 %48, %50
br i1 %51, label %52, label %57
52: ; preds = %31
%53 = load i16, i16* %4
%54 = load i16, i16* %5
%55 = load i16, i16* %6
%56 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i16 zeroext %53, i16 zeroext %54, i16 zeroext %55)
br label %57
57: ; preds = %52, %31
br label %58
58: ; preds = %57
%59 = load i16, i16* %4
%60 = add i16 %59, 1
store i16 %60, i16* %4
br label %27
61: ; preds = %27
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"[%d] - %02x - %02x\0A\00"
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = alloca [1025 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [1025 x i8], [1025 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @time(i32 0)
%6 = tail call i32 @srandom(i32 %5)
br label %9
7: ; preds = %9
%8 = getelementptr inbounds [1025 x i8], [1025 x i8]* %2, i64 0, i64 1
br label %16
9: ; preds = %0, %9
%10 = phi i64 [ 0, %0 ], [ %13, %9 ]
%11 = tail call zeroext i8 (...) @random()
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %10
store i8 %11, i8* %12
%13 = add nuw nsw i64 %10, 1
%14 = getelementptr inbounds [1025 x i8], [1025 x i8]* %2, i64 0, i64 %13
store i8 %11, i8* %14
%15 = icmp eq i64 %13, 1024
br i1 %15, label %7, label %9
16: ; preds = %7, %24
%17 = phi i16 [ 1, %7 ], [ %25, %24 ]
%18 = call zeroext i16 @crc16_inet(i32 0, i8* %3, i16 zeroext %17)
%19 = call zeroext i16 @crc16_inet(i32 0, i8* %8, i16 zeroext %17)
%20 = call i16 @llvm.bswap.i16(i16 %19)
%21 = icmp eq i16 %18, %20
br i1 %21, label %24, label %22
22: ; preds = %16
%23 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i16 zeroext %17, i16 zeroext %18, i16 zeroext %20)
br label %24
24: ; preds = %16, %22
%25 = add nuw nsw i16 %17, 1
%26 = icmp eq i16 %25, 1024
br i1 %26, label %27, label %16
27: ; preds = %24
ret i32 0
}