#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 long reflect_32(unsigned long);
unsigned long build_crc_table(int index) {
  int i;
  unsigned long rb;
  rb = reflect_32(index);
  for (i = 0; i < 8; i++) {
    if (rb & 0x80000000L)
      rb = (rb << 1) ^ 0x1EDC6F41L;
    else
      rb <<= 1;
  }
  return (reflect_32(rb));
}


x86 assembly (clang, -O0):
<build_crc_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rdi
call   1030 <reflect_32@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    1187 <build_crc_table+0x77>
movabs $0x80000000,%rax
and    -0x10(%rbp),%rax
cmp    $0x0,%rax
je     1168 <build_crc_table+0x58>
mov    -0x10(%rbp),%rax
shl    $0x1,%rax
xor    $0x1edc6f41,%rax
mov    %rax,-0x10(%rbp)
jmp    1174 <build_crc_table+0x64>
mov    -0x10(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1179 <build_crc_table+0x69>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    112f <build_crc_table+0x1f>
mov    -0x10(%rbp),%rdi
call   1030 <reflect_32@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<build_crc_table>:
push   %rax
movslq %edi,%rdi
call   1030 <reflect_32@plt>
lea    (%rax,%rax,1),%rcx
mov    %rcx,%rdx
xor    $0x1edc6f41,%rdx
test   $0x80000000,%eax
cmove  %rcx,%rdx
mov    %rdx,%rax
add    %rdx,%rax
mov    %rax,%rcx
xor    $0x1edc6f41,%rcx
test   $0x80000000,%edx
cmove  %rax,%rcx
mov    %rcx,%rax
add    %rcx,%rax
mov    %rax,%rdx
xor    $0x1edc6f41,%rdx
test   $0x80000000,%ecx
cmove  %rax,%rdx
mov    %rdx,%rax
add    %rdx,%rax
mov    %rax,%rcx
xor    $0x1edc6f41,%rcx
test   $0x80000000,%edx
cmove  %rax,%rcx
mov    %rcx,%rax
add    %rcx,%rax
mov    %rax,%rdx
xor    $0x1edc6f41,%rdx
test   $0x80000000,%ecx
cmove  %rax,%rdx
mov    %rdx,%rax
add    %rdx,%rax
mov    %rax,%rcx
xor    $0x1edc6f41,%rcx
test   $0x80000000,%edx
cmove  %rax,%rcx
mov    %rcx,%rax
add    %rcx,%rax
mov    %rax,%rdx
xor    $0x1edc6f41,%rdx
test   $0x80000000,%ecx
cmove  %rax,%rdx
mov    %rdx,%rax
add    %rdx,%rax
mov    %rax,%rdi
xor    $0x1edc6f41,%rdi
test   $0x80000000,%edx
cmove  %rax,%rdi
pop    %rax
jmp    1030 <reflect_32@plt>

LLVM IR (-O0):
define i64 @build_crc_table(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = sext i32 %5 to i64
%7 = call i64 @reflect_32(i64 %6)
store i64 %7, i64* %4
store i32 0, i32* %3
br label %8
8: ; preds = %23, %1
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %26
11: ; preds = %8
%12 = load i64, i64* %4
%13 = and i64 %12, 2147483648
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i64, i64* %4
%17 = shl i64 %16, 1
%18 = xor i64 %17, 517762881
store i64 %18, i64* %4
br label %22
19: ; preds = %11
%20 = load i64, i64* %4
%21 = shl i64 %20, 1
store i64 %21, i64* %4
br label %22
22: ; preds = %19, %15
br label %23
23: ; preds = %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %8
26: ; preds = %8
%27 = load i64, i64* %4
%28 = call i64 @reflect_32(i64 %27)
ret i64 %28
}

LLVM IR (-O2):
define i64 @build_crc_table(i32 %0) {
%2 = sext i32 %0 to i64
%3 = tail call i64 @reflect_32(i64 %2)
%4 = and i64 %3, 2147483648
%5 = icmp eq i64 %4, 0
%6 = shl i64 %3, 1
%7 = xor i64 %6, 517762881
%8 = select i1 %5, i64 %6, i64 %7
%9 = and i64 %8, 2147483648
%10 = icmp eq i64 %9, 0
%11 = shl i64 %8, 1
%12 = xor i64 %11, 517762881
%13 = select i1 %10, i64 %11, i64 %12
%14 = and i64 %13, 2147483648
%15 = icmp eq i64 %14, 0
%16 = shl i64 %13, 1
%17 = xor i64 %16, 517762881
%18 = select i1 %15, i64 %16, i64 %17
%19 = and i64 %18, 2147483648
%20 = icmp eq i64 %19, 0
%21 = shl i64 %18, 1
%22 = xor i64 %21, 517762881
%23 = select i1 %20, i64 %21, i64 %22
%24 = and i64 %23, 2147483648
%25 = icmp eq i64 %24, 0
%26 = shl i64 %23, 1
%27 = xor i64 %26, 517762881
%28 = select i1 %25, i64 %26, i64 %27
%29 = and i64 %28, 2147483648
%30 = icmp eq i64 %29, 0
%31 = shl i64 %28, 1
%32 = xor i64 %31, 517762881
%33 = select i1 %30, i64 %31, i64 %32
%34 = and i64 %33, 2147483648
%35 = icmp eq i64 %34, 0
%36 = shl i64 %33, 1
%37 = xor i64 %36, 517762881
%38 = select i1 %35, i64 %36, i64 %37
%39 = and i64 %38, 2147483648
%40 = icmp eq i64 %39, 0
%41 = shl i64 %38, 1
%42 = xor i64 %41, 517762881
%43 = select i1 %40, i64 %41, i64 %42
%44 = tail call i64 @reflect_32(i64 %43)
ret i64 %44
}