#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 strlen(char *);
unsigned long ShbIpcCrc32GetCrc(char *pcString, unsigned long aulCrcTable[]) {
  unsigned long ulCrc;
  int iIndex;
  ulCrc = 0xFFFFFFFF;
  for (iIndex = 0; iIndex < strlen(pcString); iIndex++) {
    ulCrc = ((ulCrc >> 8) & 0x00FFFFFF) ^
            aulCrcTable[(ulCrc ^ pcString[iIndex]) & 0xFF];
  }
  return (ulCrc ^ 0xFFFFFFFF);
}


x86 assembly (clang, -O0):
<ShbIpcCrc32GetCrc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xffffffff,%eax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    118f <ShbIpcCrc32GetCrc+0x7f>
mov    -0x18(%rbp),%rax
shr    $0x8,%rax
and    $0xffffff,%rax
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rdx
mov    -0x8(%rbp),%rsi
movslq -0x1c(%rbp),%rdi
movsbq (%rsi,%rdi,1),%rsi
xor    %rsi,%rdx
and    $0xff,%rdx
xor    (%rcx,%rdx,8),%rax
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1130 <ShbIpcCrc32GetCrc+0x20>
movabs $0xffffffff,%rax
xor    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ShbIpcCrc32GetCrc>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1030 <strlen@plt>
test   %eax,%eax
jle    116a <ShbIpcCrc32GetCrc+0x5a>
mov    $0xffffffff,%r12d
xor    %r13d,%r13d
mov    $0xffffffff,%ebx
cs nopw 0x0(%rax,%rax,1)
movzbl %bl,%eax
shr    $0x8,%ebx
movzbl (%r15,%r13,1),%ecx
xor    %rcx,%rax
xor    (%r14,%rax,8),%rbx
add    $0x1,%r13
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%r13
jl     1140 <ShbIpcCrc32GetCrc+0x30>
xor    %r12,%rbx
jmp    116c <ShbIpcCrc32GetCrc+0x5c>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @ShbIpcCrc32GetCrc(i8* %0, i64* %1) {
%3 = alloca i8*
%4 = alloca i64*
%5 = alloca i64
%6 = alloca i32
store i8* %0, i8** %3
store i64* %1, i64** %4
store i64 4294967295, i64* %5
store i32 0, i32* %6
br label %7
7: ; preds = %29, %2
%8 = load i32, i32* %6
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %32
12: ; preds = %7
%13 = load i64, i64* %5
%14 = lshr i64 %13, 8
%15 = and i64 %14, 16777215
%16 = load i64*, i64** %4
%17 = load i64, i64* %5
%18 = load i8*, i8** %3
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i64
%24 = xor i64 %17, %23
%25 = and i64 %24, 255
%26 = getelementptr inbounds i64, i64* %16, i64 %25
%27 = load i64, i64* %26
%28 = xor i64 %15, %27
store i64 %28, i64* %5
br label %29
29: ; preds = %12
%30 = load i32, i32* %6
%31 = add nsw i32 %30, 1
store i32 %31, i32* %6
br label %7
32: ; preds = %7
%33 = load i64, i64* %5
%34 = xor i64 %33, 4294967295
ret i64 %34
}

LLVM IR (-O2):
define i64 @ShbIpcCrc32GetCrc(i8* %0, i64* nocapture %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %24
5: ; preds = %2, %5
%6 = phi i64 [ %18, %5 ], [ 0, %2 ]
%7 = phi i64 [ %17, %5 ], [ 4294967295, %2 ]
%8 = lshr i64 %7, 8
%9 = and i64 %8, 16777215
%10 = getelementptr inbounds i8, i8* %0, i64 %6
%11 = load i8, i8* %10
%12 = zext i8 %11 to i64
%13 = and i64 %7, 255
%14 = xor i64 %13, %12
%15 = getelementptr inbounds i64, i64* %1, i64 %14
%16 = load i64, i64* %15
%17 = xor i64 %16, %9
%18 = add nuw nsw i64 %6, 1
%19 = tail call i32 @strlen(i8* %0)
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %18, %20
br i1 %21, label %5, label %22
22: ; preds = %5
%23 = xor i64 %17, 4294967295
br label %24
24: ; preds = %22, %2
%25 = phi i64 [ 0, %2 ], [ %23, %22 ]
ret i64 %25
}