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

/* Variables and functions */
int /*<<< orphan*/ crc8_dvb_s2(int /*<<< orphan*/, int /*<<< orphan*/ const);
uint8_t crc8_dvb_s2_update(uint8_t crc, const void *data, uint32_t length) {
  const uint8_t *p = (const uint8_t *)data;
  const uint8_t *pend = p + length;
  for (; p != pend; p++) {
    crc = crc8_dvb_s2(crc, *p);
  }
  return crc;
}


x86 assembly (clang, -O0):
<crc8_dvb_s2_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
je     116d <crc8_dvb_s2_update+0x5d>
mov    -0x4(%rbp),%edi
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
call   1030 <crc8_dvb_s2@plt>
mov    %eax,-0x4(%rbp)
mov    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
jmp    113d <crc8_dvb_s2_update+0x2d>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crc8_dvb_s2_update>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%eax
movslq %edx,%r15
shl    $0x2,%r15
test   %r15,%r15
je     1144 <crc8_dvb_s2_update+0x34>
mov    %rsi,%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,1),%esi
mov    %eax,%edi
call   1030 <crc8_dvb_s2@plt>
add    $0x4,%rbx
cmp    %rbx,%r15
jne    1130 <crc8_dvb_s2_update+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @crc8_dvb_s2_update(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %5
%10 = bitcast i8* %9 to i32*
store i32* %10, i32** %7
%11 = load i32*, i32** %7
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %11, i64 %13
store i32* %14, i32** %8
br label %15
15: ; preds = %24, %3
%16 = load i32*, i32** %7
%17 = load i32*, i32** %8
%18 = icmp ne i32* %16, %17
br i1 %18, label %19, label %27
19: ; preds = %15
%20 = load i32, i32* %4
%21 = load i32*, i32** %7
%22 = load i32, i32* %21
%23 = call i32 @crc8_dvb_s2(i32 %20, i32 %22)
store i32 %23, i32* %4
br label %24
24: ; preds = %19
%25 = load i32*, i32** %7
%26 = getelementptr inbounds i32, i32* %25, i32 1
store i32* %26, i32** %7
br label %15
27: ; preds = %15
%28 = load i32, i32* %4
ret i32 %28
}

LLVM IR (-O2):
define i32 @crc8_dvb_s2_update(i32 %0, i8* %1, i32 %2) {
%4 = bitcast i8* %1 to i32*
%5 = sext i32 %2 to i64
%6 = getelementptr inbounds i32, i32* %4, i64 %5
%7 = icmp eq i32* %6, %4
br i1 %7, label %15, label %8
8: ; preds = %3, %8
%9 = phi i32 [ %12, %8 ], [ %0, %3 ]
%10 = phi i32* [ %13, %8 ], [ %4, %3 ]
%11 = load i32, i32* %10
%12 = tail call i32 @crc8_dvb_s2(i32 %9, i32 %11)
%13 = getelementptr inbounds i32, i32* %10, i64 1
%14 = icmp eq i32* %13, %6
br i1 %14, label %15, label %8
15: ; preds = %8, %3
%16 = phi i32 [ %0, %3 ], [ %12, %8 ]
ret i32 %16
}