#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 uint32_t;
typedef int /*<<< orphan*/ poly_bits_32;

/* Variables and functions */
scalar_t__ malloc(int);
uint32_t *crc32_init_table() {
  uint32_t poly32 = 0, *table32 = 0, part32 = 0;
  uint8_t poly_bits_32[] = {0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26};
  uint32_t i, j;
  for (i = 0; i < sizeof(poly_bits_32); i++)
    poly32 |= (uint32_t)(1) << (31 - poly_bits_32[i]);
  table32 = (uint32_t *)malloc(sizeof(uint32_t) * 256);
  for (i = 0; i < 256; i++) {
    part32 = (uint32_t)i;
    for (j = 0; j < 8; j++)
      part32 = (part32 & 1) ? (part32 >> 1) ^ poly32 : (part32 >> 1);
    table32[i] = part32;
  }
  return table32;
}


x86 assembly (clang, -O0):
<crc32_init_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xeb7(%rip),%rsi
mov    $0x38,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x54(%rbp)
movslq -0x54(%rbp),%rax
cmp    $0x38,%rax
jae    1190 <crc32_init_table+0x70>
movslq -0x54(%rbp),%rax
mov    $0x1f,%ecx
sub    -0x50(%rbp,%rax,4),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    115a <crc32_init_table+0x3a>
mov    $0x400,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x100,-0x54(%rbp)
jge    1222 <crc32_init_table+0x102>
mov    -0x54(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x58(%rbp)
cmpl   $0x8,-0x58(%rbp)
jge    1206 <crc32_init_table+0xe6>
mov    -0x14(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11e9 <crc32_init_table+0xc9>
mov    -0x14(%rbp),%eax
sar    $0x1,%eax
xor    -0x4(%rbp),%eax
mov    %eax,-0x5c(%rbp)
jmp    11f2 <crc32_init_table+0xd2>
mov    -0x14(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    11bf <crc32_init_table+0x9f>
mov    -0x14(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11a5 <crc32_init_table+0x85>
mov    -0x10(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crc32_init_table>:
push   %rax
mov    $0x400,%edi
call   1030 <malloc@plt>
movdqa 0xedd(%rip),%xmm0
mov    $0xc,%ecx
movdqa 0xee0(%rip),%xmm1
movdqa 0xee8(%rip),%xmm2
movdqa 0xef0(%rip),%xmm3
movdqa 0xef8(%rip),%xmm4
nopl   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm5
paddd  %xmm1,%xmm5
movdqa %xmm0,%xmm6
psrad  $0x8,%xmm6
psrad  $0x8,%xmm5
movdqu %xmm6,-0x30(%rax,%rcx,4)
movdqu %xmm5,-0x20(%rax,%rcx,4)
movdqa %xmm0,%xmm5
paddd  %xmm2,%xmm5
movdqa %xmm0,%xmm6
paddd  %xmm3,%xmm6
psrad  $0x8,%xmm5
psrad  $0x8,%xmm6
movdqu %xmm5,-0x10(%rax,%rcx,4)
movdqu %xmm6,(%rax,%rcx,4)
paddd  %xmm4,%xmm0
add    $0x10,%rcx
cmp    $0x10c,%rcx
jne    1150 <crc32_init_table+0x40>
pop    %rcx
ret

LLVM IR (-O0):
@__const.crc32_init_table.poly_bits_32 = [14 x i32] [i32 0, i32 1, i32 2, i32 4, i32 5, i32 7, i32 8, i32 10, i32 11, i32 12, i32 16, i32 22, i32 23, i32 26]
define i32* @crc32_init_table() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca [14 x i32]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32* null, i32** %2
store i32 0, i32* %3
%7 = bitcast [14 x i32]* %4 to i8*
store i32 0, i32* %5
br label %8
8: ; preds = %21, %0
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = icmp ult i64 %10, 56
br i1 %11, label %12, label %24
12: ; preds = %8
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [14 x i32], [14 x i32]* %4, i64 0, i64 %14
%16 = load i32, i32* %15
%17 = sub nsw i32 31, %16
%18 = shl i32 1, %17
%19 = load i32, i32* %1
%20 = or i32 %19, %18
store i32 %20, i32* %1
br label %21
21: ; preds = %12
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %8
24: ; preds = %8
%25 = call i64 @malloc(i32 1024)
%26 = inttoptr i64 %25 to i32*
store i32* %26, i32** %2
store i32 0, i32* %5
br label %27
27: ; preds = %58, %24
%28 = load i32, i32* %5
%29 = icmp slt i32 %28, 256
br i1 %29, label %30, label %61
30: ; preds = %27
%31 = load i32, i32* %5
store i32 %31, i32* %3
store i32 0, i32* %6
br label %32
32: ; preds = %49, %30
%33 = load i32, i32* %6
%34 = icmp slt i32 %33, 8
br i1 %34, label %35, label %52
35: ; preds = %32
%36 = load i32, i32* %3
%37 = and i32 %36, 1
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %35
%40 = load i32, i32* %3
%41 = ashr i32 %40, 1
%42 = load i32, i32* %1
%43 = xor i32 %41, %42
br label %47
44: ; preds = %35
%45 = load i32, i32* %3
%46 = ashr i32 %45, 1
br label %47
47: ; preds = %44, %39
%48 = phi i32 [ %43, %39 ], [ %46, %44 ]
store i32 %48, i32* %3
br label %49
49: ; preds = %47
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
store i32 %51, i32* %6
br label %32
52: ; preds = %32
%53 = load i32, i32* %3
%54 = load i32*, i32** %2
%55 = load i32, i32* %5
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i32, i32* %54, i64 %56
store i32 %53, i32* %57
br label %58
58: ; preds = %52
%59 = load i32, i32* %5
%60 = add nsw i32 %59, 1
store i32 %60, i32* %5
br label %27
61: ; preds = %27
%62 = load i32*, i32** %2
ret i32* %62
}

LLVM IR (-O2):
define i32* @crc32_init_table() {
%1 = tail call i64 @malloc(i32 1024)
%2 = inttoptr i64 %1 to i32*
br label %3
3: ; preds = %3, %0
%4 = phi i64 [ 0, %0 ], [ %22, %3 ]
%5 = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %0 ], [ %23, %3 ]
%6 = add <4 x i32> %5, <i32 4, i32 4, i32 4, i32 4>
%7 = ashr <4 x i32> %5, <i32 8, i32 8, i32 8, i32 8>
%8 = ashr <4 x i32> %6, <i32 8, i32 8, i32 8, i32 8>
%9 = getelementptr inbounds i32, i32* %2, i64 %4
%10 = bitcast i32* %9 to <4 x i32>*
store <4 x i32> %7, <4 x i32>* %10
%11 = getelementptr inbounds i32, i32* %9, i64 4
%12 = bitcast i32* %11 to <4 x i32>*
store <4 x i32> %8, <4 x i32>* %12
%13 = or i64 %4, 8
%14 = add <4 x i32> %5, <i32 8, i32 8, i32 8, i32 8>
%15 = add <4 x i32> %5, <i32 12, i32 12, i32 12, i32 12>
%16 = ashr <4 x i32> %14, <i32 8, i32 8, i32 8, i32 8>
%17 = ashr <4 x i32> %15, <i32 8, i32 8, i32 8, i32 8>
%18 = getelementptr inbounds i32, i32* %2, i64 %13
%19 = bitcast i32* %18 to <4 x i32>*
store <4 x i32> %16, <4 x i32>* %19
%20 = getelementptr inbounds i32, i32* %18, i64 4
%21 = bitcast i32* %20 to <4 x i32>*
store <4 x i32> %17, <4 x i32>* %21
%22 = add nuw nsw i64 %4, 16
%23 = add <4 x i32> %5, <i32 16, i32 16, i32 16, i32 16>
%24 = icmp eq i64 %22, 256
br i1 %24, label %25, label %3
25: ; preds = %3
ret i32* %2
}