#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 /*<<< orphan*/ printf(char *, ...);
void make_16_bit_crc_tab(unsigned long poly) {
  unsigned long i, j, M;
  printf("unsigned short crc_table[256] = {\n");
  for (i = 0; i < 256; i++) {
    M = i;
    for (j = 8; j > 0; j--) {
      if (M & 1) {
        M ^= poly;
      }
      M >>= 1;
    }
    printf("%#lx,\n", M);
  }
  printf("};\n");
}


x86 assembly (clang, -O0):
<make_16_bit_crc_tab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x10(%rbp)
cmpq   $0x100,-0x10(%rbp)
jae    11b9 <make_16_bit_crc_tab+0xa9>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x8,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jbe    1196 <make_16_bit_crc_tab+0x86>
mov    -0x20(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     1179 <make_16_bit_crc_tab+0x69>
mov    -0x8(%rbp),%rax
xor    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1150 <make_16_bit_crc_tab+0x40>
mov    -0x20(%rbp),%rsi
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1132 <make_16_bit_crc_tab+0x22>
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_16_bit_crc_tab>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%r12
shr    %r12
lea    0xebc(%rip),%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
mov    %ebx,%eax
and    $0x1,%eax
neg    %rax
and    %r15,%rax
xor    %rbx,%rax
mov    %rax,%rcx
shl    $0x3e,%rcx
sar    $0x3f,%rcx
shr    $0x2,%rax
and    %r12,%rcx
xor    %rax,%rcx
mov    %ecx,%eax
and    $0x1,%eax
neg    %rax
and    %r15,%rax
xor    %rcx,%rax
mov    %rax,%rcx
shl    $0x3e,%rcx
sar    $0x3f,%rcx
shr    $0x2,%rax
and    %r12,%rcx
xor    %rax,%rcx
mov    %ecx,%eax
and    $0x1,%eax
neg    %rax
and    %r15,%rax
xor    %rcx,%rax
mov    %rax,%rcx
shl    $0x3e,%rcx
sar    $0x3f,%rcx
shr    $0x2,%rax
and    %r12,%rcx
xor    %rax,%rcx
mov    %ecx,%eax
and    $0x1,%eax
neg    %rax
and    %r15,%rax
xor    %rcx,%rax
mov    %rax,%rsi
shl    $0x3e,%rsi
sar    $0x3f,%rsi
shr    $0x2,%rax
and    %r12,%rsi
xor    %rax,%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    1150 <make_16_bit_crc_tab+0x30>
lea    0xe2b(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [35 x i8] c"unsigned short crc_table[256] = {\0A\00"
@.str.1 = [7 x i8] c"%#lx,\0A\00"
@.str.2 = [4 x i8] c"};\0A\00"
define void @make_16_bit_crc_tab(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i64 %0, i64* %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
store i64 0, i64* %3
br label %7
7: ; preds = %32, %1
%8 = load i64, i64* %3
%9 = icmp ult i64 %8, 256
br i1 %9, label %10, label %35
10: ; preds = %7
%11 = load i64, i64* %3
store i64 %11, i64* %5
store i64 8, i64* %4
br label %12
12: ; preds = %26, %10
%13 = load i64, i64* %4
%14 = icmp ugt i64 %13, 0
br i1 %14, label %15, label %29
15: ; preds = %12
%16 = load i64, i64* %5
%17 = and i64 %16, 1
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load i64, i64* %2
%21 = load i64, i64* %5
%22 = xor i64 %21, %20
store i64 %22, i64* %5
br label %23
23: ; preds = %19, %15
%24 = load i64, i64* %5
%25 = lshr i64 %24, 1
store i64 %25, i64* %5
br label %26
26: ; preds = %23
%27 = load i64, i64* %4
%28 = add i64 %27, -1
store i64 %28, i64* %4
br label %12
29: ; preds = %12
%30 = load i64, i64* %5
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %30)
br label %32
32: ; preds = %29
%33 = load i64, i64* %3
%34 = add i64 %33, 1
store i64 %34, i64* %3
br label %7
35: ; preds = %7
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%#lx,\0A\00"
@str = [34 x i8] c"unsigned short crc_table[256] = {\00"
@str.3 = [3 x i8] c"};\00"
define void @make_16_bit_crc_tab(i64 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%3 = lshr i64 %0, 1
%4 = lshr i64 %0, 1
%5 = lshr i64 %0, 1
%6 = lshr i64 %0, 1
br label %7
7: ; preds = %1, %7
%8 = phi i64 [ 0, %1 ], [ %46, %7 ]
%9 = and i64 %8, 1
%10 = icmp eq i64 %9, 0
%11 = select i1 %10, i64 0, i64 %0
%12 = xor i64 %11, %8
%13 = and i64 %12, 2
%14 = icmp eq i64 %13, 0
%15 = lshr i64 %12, 2
%16 = select i1 %14, i64 0, i64 %3
%17 = xor i64 %15, %16
%18 = and i64 %17, 1
%19 = icmp eq i64 %18, 0
%20 = select i1 %19, i64 0, i64 %0
%21 = xor i64 %20, %17
%22 = and i64 %21, 2
%23 = icmp eq i64 %22, 0
%24 = lshr i64 %21, 2
%25 = select i1 %23, i64 0, i64 %4
%26 = xor i64 %24, %25
%27 = and i64 %26, 1
%28 = icmp eq i64 %27, 0
%29 = select i1 %28, i64 0, i64 %0
%30 = xor i64 %29, %26
%31 = and i64 %30, 2
%32 = icmp eq i64 %31, 0
%33 = lshr i64 %30, 2
%34 = select i1 %32, i64 0, i64 %5
%35 = xor i64 %33, %34
%36 = and i64 %35, 1
%37 = icmp eq i64 %36, 0
%38 = select i1 %37, i64 0, i64 %0
%39 = xor i64 %38, %35
%40 = and i64 %39, 2
%41 = icmp eq i64 %40, 0
%42 = lshr i64 %39, 2
%43 = select i1 %41, i64 0, i64 %6
%44 = xor i64 %42, %43
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %44)
%46 = add nuw nsw i64 %8, 1
%47 = icmp eq i64 %46, 256
br i1 %47, label %48, label %7
48: ; preds = %7
%49 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.3, i64 0, i64 0))
ret void
}