#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 strCRC32add(int, char *, int);
int strCRC32end(int crc, int len) {
  char slen[4];
  int li;
  for (li = 0; li < 4; li) {
    slen[li++] = len;
    len >>= 8;
    if (len == 0)
      break;
  }
  crc = strCRC32add(crc, slen, li);
  crc ^= 0xFFFFFFFF;
  return crc;
}


x86 assembly (clang, -O0):
<strCRC32end>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    1167 <strCRC32end+0x57>
mov    -0x8(%rbp),%eax
mov    %al,%cl
mov    -0x10(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
cltq
mov    %cl,-0xc(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
sar    $0x8,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    115d <strCRC32end+0x4d>
jmp    1167 <strCRC32end+0x57>
jmp    1162 <strCRC32end+0x52>
jmp    1125 <strCRC32end+0x15>
mov    -0x4(%rbp),%edi
lea    -0xc(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   1030 <strCRC32add@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strCRC32end>:
push   %rax
mov    %esi,%eax
mov    %al,0x4(%rsp)
mov    $0x1,%edx
cmp    $0x100,%esi
jb     1155 <strCRC32end+0x45>
mov    %ah,0x5(%rsp)
mov    $0x2,%edx
cmp    $0x10000,%eax
jb     1155 <strCRC32end+0x45>
mov    %eax,%ecx
shr    $0x10,%ecx
mov    %cl,0x6(%rsp)
mov    $0x3,%edx
cmp    $0x1000000,%eax
jb     1155 <strCRC32end+0x45>
shr    $0x18,%eax
mov    %al,0x7(%rsp)
mov    $0x4,%edx
lea    0x4(%rsp),%rsi
call   1030 <strCRC32add@plt>
not    %eax
pop    %rcx
ret

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

LLVM IR (-O2):
define i32 @strCRC32end(i32 %0, i32 %1) {
%3 = alloca [4 x i8]
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%5 = trunc i32 %1 to i8
store i8 %5, i8* %4
%6 = icmp ult i32 %1, 256
br i1 %6, label %21, label %7
7: ; preds = %2
%8 = lshr i32 %1, 8
%9 = trunc i32 %8 to i8
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
store i8 %9, i8* %10
%11 = icmp ult i32 %1, 65536
br i1 %11, label %21, label %12
12: ; preds = %7
%13 = lshr i32 %1, 16
%14 = trunc i32 %13 to i8
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
store i8 %14, i8* %15
%16 = icmp ult i32 %1, 16777216
br i1 %16, label %21, label %17
17: ; preds = %12
%18 = lshr i32 %1, 24
%19 = trunc i32 %18 to i8
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
store i8 %19, i8* %20
br label %21
21: ; preds = %17, %12, %7, %2
%22 = phi i32 [ 1, %2 ], [ 2, %7 ], [ 3, %12 ], [ 4, %17 ]
%23 = call i32 @strCRC32add(i32 %0, i8* %4, i32 %22)
%24 = xor i32 %23, -1
ret i32 %24
}