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

/* Variables and functions */
int /*<<< orphan*/ crc32_add_bit(int /*<<< orphan*/, int);
uint32_t crc32_add_byte(uint32_t crc, uint8_t byte) {
  int i;
  crc = ~crc;
  for (i = 0; i < 8; i++) {
    crc = crc32_add_bit(crc, (byte >> i) & 1);
  }
  return ~crc;
}


x86 assembly (clang, -O0):
<crc32_add_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    115c <crc32_add_byte+0x4c>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%ecx
sar    %cl,%esi
and    $0x1,%esi
call   1030 <crc32_add_bit@plt>
mov    %eax,-0x4(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112e <crc32_add_byte+0x1e>
mov    -0x4(%rbp),%eax
xor    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crc32_add_byte>:
push   %rbx
mov    %esi,%ebx
not    %edi
and    $0x1,%esi
call   1030 <crc32_add_bit@plt>
mov    %ebx,%esi
shr    %esi
and    $0x1,%esi
mov    %eax,%edi
call   1030 <crc32_add_bit@plt>
mov    %ebx,%esi
shr    $0x2,%esi
and    $0x1,%esi
mov    %eax,%edi
call   1030 <crc32_add_bit@plt>
mov    %ebx,%esi
shr    $0x3,%esi
and    $0x1,%esi
mov    %eax,%edi
call   1030 <crc32_add_bit@plt>
mov    %ebx,%esi
shr    $0x4,%esi
and    $0x1,%esi
mov    %eax,%edi
call   1030 <crc32_add_bit@plt>
mov    %ebx,%esi
shr    $0x5,%esi
and    $0x1,%esi
mov    %eax,%edi
call   1030 <crc32_add_bit@plt>
mov    %ebx,%esi
shr    $0x6,%esi
and    $0x1,%esi
mov    %eax,%edi
call   1030 <crc32_add_bit@plt>
shr    $0x7,%ebx
and    $0x1,%ebx
mov    %eax,%edi
mov    %ebx,%esi
call   1030 <crc32_add_bit@plt>
not    %eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @crc32_add_byte(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* %3
%7 = xor i32 %6, -1
store i32 %7, i32* %3
store i32 0, i32* %5
br label %8
8: ; preds = %18, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = load i32, i32* %5
%15 = ashr i32 %13, %14
%16 = and i32 %15, 1
%17 = call i32 @crc32_add_bit(i32 %12, i32 %16)
store i32 %17, i32* %3
br label %18
18: ; preds = %11
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
br label %8
21: ; preds = %8
%22 = load i32, i32* %3
%23 = xor i32 %22, -1
ret i32 %23
}

LLVM IR (-O2):
define i32 @crc32_add_byte(i32 %0, i32 %1) {
%3 = xor i32 %0, -1
%4 = and i32 %1, 1
%5 = tail call i32 @crc32_add_bit(i32 %3, i32 %4)
%6 = lshr i32 %1, 1
%7 = and i32 %6, 1
%8 = tail call i32 @crc32_add_bit(i32 %5, i32 %7)
%9 = lshr i32 %1, 2
%10 = and i32 %9, 1
%11 = tail call i32 @crc32_add_bit(i32 %8, i32 %10)
%12 = lshr i32 %1, 3
%13 = and i32 %12, 1
%14 = tail call i32 @crc32_add_bit(i32 %11, i32 %13)
%15 = lshr i32 %1, 4
%16 = and i32 %15, 1
%17 = tail call i32 @crc32_add_bit(i32 %14, i32 %16)
%18 = lshr i32 %1, 5
%19 = and i32 %18, 1
%20 = tail call i32 @crc32_add_bit(i32 %17, i32 %19)
%21 = lshr i32 %1, 6
%22 = and i32 %21, 1
%23 = tail call i32 @crc32_add_bit(i32 %20, i32 %22)
%24 = lshr i32 %1, 7
%25 = and i32 %24, 1
%26 = tail call i32 @crc32_add_bit(i32 %23, i32 %25)
%27 = xor i32 %26, -1
ret i32 %27
}