#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 unsigned char uint8_t;

/* Variables and functions */
uint8_t crc8_dvb_s2(uint8_t crc, unsigned char a) {
  crc ^= a;
  for (int ii = 0; ii < 8; ++ii) {
    if (crc & 0x80) {
      crc = (crc << 1) ^ 0xD5;
    } else {
      crc = crc << 1;
    }
  }
  return crc;
}


x86 assembly (clang, -O0):
<crc8_dvb_s2>:
push   %rbp
mov    %rsp,%rbp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movzbl -0x2(%rbp),%ecx
movzbl -0x1(%rbp),%eax
xor    %ecx,%eax
mov    %al,-0x1(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x8,-0x8(%rbp)
jge    1171 <crc8_dvb_s2+0x71>
movzbl -0x1(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1154 <crc8_dvb_s2+0x54>
movzbl -0x1(%rbp),%eax
shl    $0x1,%eax
xor    $0xd5,%eax
mov    %al,-0x1(%rbp)
jmp    115e <crc8_dvb_s2+0x5e>
movzbl -0x1(%rbp),%eax
shl    $0x1,%eax
mov    %al,-0x1(%rbp)
jmp    1163 <crc8_dvb_s2+0x63>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1124 <crc8_dvb_s2+0x24>
movzbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<crc8_dvb_s2>:
xor    %esi,%edi
lea    (%rdi,%rdi,1),%eax
movzbl %al,%ecx
xor    $0xd5,%al
test   %dil,%dil
movzbl %al,%eax
cmovns %ecx,%eax
lea    (%rax,%rax,1),%ecx
movzbl %cl,%edx
xor    $0xd5,%cl
test   %al,%al
movzbl %cl,%eax
cmovns %edx,%eax
lea    (%rax,%rax,1),%ecx
movzbl %cl,%edx
xor    $0xd5,%cl
test   %al,%al
movzbl %cl,%eax
cmovns %edx,%eax
lea    (%rax,%rax,1),%ecx
movzbl %cl,%edx
xor    $0xd5,%cl
test   %al,%al
movzbl %cl,%eax
cmovns %edx,%eax
lea    (%rax,%rax,1),%ecx
movzbl %cl,%edx
xor    $0xd5,%cl
test   %al,%al
movzbl %cl,%eax
cmovns %edx,%eax
lea    (%rax,%rax,1),%ecx
movzbl %cl,%edx
xor    $0xd5,%cl
test   %al,%al
movzbl %cl,%eax
cmovns %edx,%eax
lea    (%rax,%rax,1),%ecx
movzbl %cl,%edx
xor    $0xd5,%cl
test   %al,%al
movzbl %cl,%eax
cmovns %edx,%eax
lea    (%rax,%rax,1),%ecx
movzbl %cl,%edx
xor    $0xd5,%cl
test   %al,%al
movzbl %cl,%eax
cmovns %edx,%eax
ret

LLVM IR (-O0):
define zeroext i8 @crc8_dvb_s2(i8 zeroext %0, i8 zeroext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
store i8 %0, i8* %3
store i8 %1, i8* %4
%6 = load i8, i8* %4
%7 = zext i8 %6 to i32
%8 = load i8, i8* %3
%9 = zext i8 %8 to i32
%10 = xor i32 %9, %7
%11 = trunc i32 %10 to i8
store i8 %11, i8* %3
store i32 0, i32* %5
br label %12
12: ; preds = %32, %2
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 8
br i1 %14, label %15, label %35
15: ; preds = %12
%16 = load i8, i8* %3
%17 = zext i8 %16 to i32
%18 = and i32 %17, 128
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %15
%21 = load i8, i8* %3
%22 = zext i8 %21 to i32
%23 = shl i32 %22, 1
%24 = xor i32 %23, 213
%25 = trunc i32 %24 to i8
store i8 %25, i8* %3
br label %31
26: ; preds = %15
%27 = load i8, i8* %3
%28 = zext i8 %27 to i32
%29 = shl i32 %28, 1
%30 = trunc i32 %29 to i8
store i8 %30, i8* %3
br label %31
31: ; preds = %26, %20
br label %32
32: ; preds = %31
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %12
35: ; preds = %12
%36 = load i8, i8* %3
ret i8 %36
}

LLVM IR (-O2):
define zeroext i8 @crc8_dvb_s2(i8 zeroext %0, i8 zeroext %1) {
%3 = xor i8 %1, %0
%4 = icmp sgt i8 %3, -1
%5 = shl i8 %3, 1
%6 = xor i8 %5, -43
%7 = select i1 %4, i8 %5, i8 %6
%8 = icmp sgt i8 %7, -1
%9 = shl i8 %7, 1
%10 = xor i8 %9, -43
%11 = select i1 %8, i8 %9, i8 %10
%12 = icmp sgt i8 %11, -1
%13 = shl i8 %11, 1
%14 = xor i8 %13, -43
%15 = select i1 %12, i8 %13, i8 %14
%16 = icmp sgt i8 %15, -1
%17 = shl i8 %15, 1
%18 = xor i8 %17, -43
%19 = select i1 %16, i8 %17, i8 %18
%20 = icmp sgt i8 %19, -1
%21 = shl i8 %19, 1
%22 = xor i8 %21, -43
%23 = select i1 %20, i8 %21, i8 %22
%24 = icmp sgt i8 %23, -1
%25 = shl i8 %23, 1
%26 = xor i8 %25, -43
%27 = select i1 %24, i8 %25, i8 %26
%28 = icmp sgt i8 %27, -1
%29 = shl i8 %27, 1
%30 = xor i8 %29, -43
%31 = select i1 %28, i8 %29, i8 %30
%32 = icmp sgt i8 %31, -1
%33 = shl i8 %31, 1
%34 = xor i8 %33, -43
%35 = select i1 %32, i8 %33, i8 %34
ret i8 %35
}