#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_update_bit(int /*<<< orphan*/, int);
uint32_t crc32_update_byte(uint32_t remainder, uint8_t next_byte) {
  for (int j = 0; j < 8; j++, next_byte >>= 1)
    remainder = crc32_update_bit(remainder, next_byte & 1);
  return remainder;
}


x86 assembly (clang, -O0):
<crc32_update_byte>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    1157 <crc32_update_byte+0x47>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
and    $0x1,%esi
call   1030 <crc32_update_bit@plt>
mov    %eax,-0x4(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1125 <crc32_update_byte+0x15>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

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

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

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