#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 uint32_t;

/* Variables and functions */
uint32_t __simplePNG_single_byte_crc(uint32_t initial_crc, uint8_t data) {
  uint32_t poly = 0xedb88320;
  uint32_t new_crc = initial_crc ^ data;
  for (size_t b = 0; b < 8; b++) {
    uint8_t lsb_active = new_crc & 0x01;
    if (lsb_active)
      new_crc = (new_crc >> 1) ^ poly;
    else
      new_crc = new_crc >> 1;
  }
  return new_crc;
}


x86 assembly (clang, -O0):
<__simplePNG_single_byte_crc>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0xedb88320,-0xc(%rbp)
mov    -0x4(%rbp),%eax
xor    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x8,-0x18(%rbp)
jae    1170 <__simplePNG_single_byte_crc+0x70>
mov    -0x10(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1151 <__simplePNG_single_byte_crc+0x51>
mov    -0x10(%rbp),%eax
sar    $0x1,%eax
xor    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    115a <__simplePNG_single_byte_crc+0x5a>
mov    -0x10(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115f <__simplePNG_single_byte_crc+0x5f>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1122 <__simplePNG_single_byte_crc+0x22>
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<__simplePNG_single_byte_crc>:
xor    %esi,%edi
mov    %edi,%eax
sar    %eax
mov    %eax,%ecx
xor    $0xedb88320,%ecx
test   $0x1,%dil
cmove  %eax,%ecx
mov    %ecx,%eax
sar    %eax
mov    %eax,%edx
xor    $0xedb88320,%edx
test   $0x1,%cl
cmove  %eax,%edx
mov    %edx,%eax
sar    %eax
mov    %eax,%ecx
xor    $0xedb88320,%ecx
test   $0x1,%dl
cmove  %eax,%ecx
mov    %ecx,%eax
sar    %eax
mov    %eax,%edx
xor    $0xedb88320,%edx
test   $0x1,%cl
cmove  %eax,%edx
mov    %edx,%eax
sar    %eax
mov    %eax,%ecx
xor    $0xedb88320,%ecx
test   $0x1,%dl
cmove  %eax,%ecx
mov    %ecx,%eax
sar    %eax
mov    %eax,%edx
xor    $0xedb88320,%edx
test   $0x1,%cl
cmove  %eax,%edx
mov    %edx,%eax
sar    %eax
mov    %eax,%ecx
xor    $0xedb88320,%ecx
test   $0x1,%dl
cmove  %eax,%ecx
mov    %ecx,%edx
sar    %edx
mov    %edx,%eax
xor    $0xedb88320,%eax
test   $0x1,%cl
cmove  %edx,%eax
ret

LLVM IR (-O0):
define i32 @__simplePNG_single_byte_crc(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 -306674912, i32* %5
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = xor i32 %9, %10
store i32 %11, i32* %6
store i64 0, i64* %7
br label %12
12: ; preds = %29, %2
%13 = load i64, i64* %7
%14 = icmp ult i64 %13, 8
br i1 %14, label %15, label %32
15: ; preds = %12
%16 = load i32, i32* %6
%17 = and i32 %16, 1
store i32 %17, i32* %8
%18 = load i32, i32* %8
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = load i32, i32* %6
%22 = ashr i32 %21, 1
%23 = load i32, i32* %5
%24 = xor i32 %22, %23
store i32 %24, i32* %6
br label %28
25: ; preds = %15
%26 = load i32, i32* %6
%27 = ashr i32 %26, 1
store i32 %27, i32* %6
br label %28
28: ; preds = %25, %20
br label %29
29: ; preds = %28
%30 = load i64, i64* %7
%31 = add i64 %30, 1
store i64 %31, i64* %7
br label %12
32: ; preds = %12
%33 = load i32, i32* %6
ret i32 %33
}

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