#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 */
int ccitt16(int *, int);
int /*<<< orphan*/ printf(char *, int);
void main() {
  int crc;
  int DATA[50];
  int *ptr = DATA;
  unsigned int i, m_w, m_z;
  m_w = 17;
  m_z = 31;
  for (i = 0; i < 50; i++, ptr++) {
    m_z = 36969 * (m_z & 65535) + (m_z >> 16);
    m_w = 18000 * (m_w & 65535) + (m_w >> 16);
    *ptr = (m_z << 16) + m_w;
  }
  int *numbers = DATA;
  crc = ccitt16(numbers, 50);
  printf("%08x\n", crc);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
lea    -0xd0(%rbp),%rax
mov    %rax,-0xd8(%rbp)
movl   $0x11,-0xe0(%rbp)
movl   $0x1f,-0xe4(%rbp)
movl   $0x0,-0xdc(%rbp)
cmpl   $0x32,-0xdc(%rbp)
jae    11e6 <main+0xc6>
mov    -0xe4(%rbp),%eax
and    $0xffff,%eax
imul   $0x9069,%eax,%eax
mov    -0xe4(%rbp),%ecx
shr    $0x10,%ecx
add    %ecx,%eax
mov    %eax,-0xe4(%rbp)
mov    -0xe0(%rbp),%eax
and    $0xffff,%eax
imul   $0x4650,%eax,%eax
mov    -0xe0(%rbp),%ecx
shr    $0x10,%ecx
add    %ecx,%eax
mov    %eax,-0xe0(%rbp)
mov    -0xe4(%rbp),%ecx
shl    $0x10,%ecx
add    -0xe0(%rbp),%ecx
mov    -0xd8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0xdc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xdc(%rbp)
mov    -0xd8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0xd8(%rbp)
jmp    1157 <main+0x37>
lea    -0xd0(%rbp),%rax
mov    %rax,-0xf0(%rbp)
mov    -0xf0(%rbp),%rdi
mov    $0x32,%esi
call   1040 <ccitt16@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xdee(%rip),%rdi
call   1030 <printf@plt>
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0xc8,%rsp
mov    $0x11,%eax
mov    $0x1f,%ecx
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzwl %cx,%esi
imul   $0x9069,%esi,%esi
shr    $0x10,%ecx
add    %esi,%ecx
movzwl %ax,%esi
imul   $0x4650,%esi,%esi
shr    $0x10,%eax
add    %esi,%eax
mov    %ecx,%esi
shl    $0x10,%esi
add    %eax,%esi
mov    %esi,(%rsp,%rdx,4)
movzwl %cx,%esi
imul   $0x9069,%esi,%esi
shr    $0x10,%ecx
add    %esi,%ecx
movzwl %ax,%esi
imul   $0x4650,%esi,%esi
shr    $0x10,%eax
add    %esi,%eax
mov    %ecx,%esi
shl    $0x10,%esi
add    %eax,%esi
mov    %esi,0x4(%rsp,%rdx,4)
add    $0x2,%rdx
cmp    $0x32,%edx
jne    1140 <main+0x20>
mov    %rsp,%rdi
mov    $0x32,%esi
call   1040 <ccitt16@plt>
lea    0xe56(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
add    $0xc8,%rsp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%08x\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca [50 x i32]
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
store i32* %8, i32** %3
store i32 17, i32* %5
store i32 31, i32* %6
store i32 0, i32* %4
br label %9
9: ; preds = %30, %0
%10 = load i32, i32* %4
%11 = icmp ult i32 %10, 50
br i1 %11, label %12, label %35
12: ; preds = %9
%13 = load i32, i32* %6
%14 = and i32 %13, 65535
%15 = mul i32 36969, %14
%16 = load i32, i32* %6
%17 = lshr i32 %16, 16
%18 = add i32 %15, %17
store i32 %18, i32* %6
%19 = load i32, i32* %5
%20 = and i32 %19, 65535
%21 = mul i32 18000, %20
%22 = load i32, i32* %5
%23 = lshr i32 %22, 16
%24 = add i32 %21, %23
store i32 %24, i32* %5
%25 = load i32, i32* %6
%26 = shl i32 %25, 16
%27 = load i32, i32* %5
%28 = add i32 %26, %27
%29 = load i32*, i32** %3
store i32 %28, i32* %29
br label %30
30: ; preds = %12
%31 = load i32, i32* %4
%32 = add i32 %31, 1
store i32 %32, i32* %4
%33 = load i32*, i32** %3
%34 = getelementptr inbounds i32, i32* %33, i32 1
store i32* %34, i32** %3
br label %9
35: ; preds = %9
%36 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
store i32* %36, i32** %7
%37 = load i32*, i32** %7
%38 = call i32 @ccitt16(i32* %37, i32 50)
store i32 %38, i32* %1
%39 = load i32, i32* %1
%40 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %39)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%08x\0A\00"
define void @main() {
%1 = alloca [50 x i32]
%2 = bitcast [50 x i32]* %1 to i8*
%3 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 0
br label %4
4: ; preds = %4, %0
%5 = phi i32* [ %3, %0 ], [ %31, %4 ]
%6 = phi i32 [ 31, %0 ], [ %23, %4 ]
%7 = phi i32 [ 17, %0 ], [ %27, %4 ]
%8 = phi i32 [ 0, %0 ], [ %30, %4 ]
%9 = and i32 %6, 65535
%10 = mul nuw i32 %9, 36969
%11 = lshr i32 %6, 16
%12 = add nuw i32 %10, %11
%13 = and i32 %7, 65535
%14 = mul nuw nsw i32 %13, 18000
%15 = lshr i32 %7, 16
%16 = add nuw nsw i32 %14, %15
%17 = shl i32 %12, 16
%18 = add i32 %17, %16
store i32 %18, i32* %5
%19 = getelementptr inbounds i32, i32* %5, i64 1
%20 = and i32 %12, 65535
%21 = mul nuw i32 %20, 36969
%22 = lshr i32 %12, 16
%23 = add nuw i32 %21, %22
%24 = and i32 %16, 65535
%25 = mul nuw nsw i32 %24, 18000
%26 = lshr i32 %16, 16
%27 = add nuw nsw i32 %25, %26
%28 = shl i32 %23, 16
%29 = add i32 %28, %27
store i32 %29, i32* %19
%30 = add nuw nsw i32 %8, 2
%31 = getelementptr inbounds i32, i32* %5, i64 2
%32 = icmp eq i32 %30, 50
br i1 %32, label %33, label %4
33: ; preds = %4
%34 = call i32 @ccitt16(i32* %3, i32 50)
%35 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %34)
ret void
}