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

/* Variables and functions */
int /*<<< orphan*/ __simplePNG_single_byte_crc(int /*<<< orphan*/,
                                               int /*<<< orphan*/ const);
uint32_t __simplePNG_get_crc(uint32_t initial_crc, uint8_t const *data,
                             size_t size) {
  uint32_t new_crc = initial_crc;
  for (size_t i = 0; i < size; i++)
    new_crc = __simplePNG_single_byte_crc(new_crc, data[i]);
  return new_crc;
}


x86 assembly (clang, -O0):
<__simplePNG_get_crc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1166 <__simplePNG_get_crc+0x56>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
call   1030 <__simplePNG_single_byte_crc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1131 <__simplePNG_get_crc+0x21>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__simplePNG_get_crc>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%eax
test   %rdx,%rdx
je     1144 <__simplePNG_get_crc+0x34>
mov    %rdx,%r15
mov    %rsi,%r14
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14,%rbx,4),%esi
mov    %eax,%edi
call   1030 <__simplePNG_single_byte_crc@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1130 <__simplePNG_get_crc+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @__simplePNG_get_crc(i32 %0, i32* nocapture %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %5, label %7
5: ; preds = %7, %3
%6 = phi i32 [ %0, %3 ], [ %12, %7 ]
ret i32 %6
7: ; preds = %3, %7
%8 = phi i64 [ %13, %7 ], [ 0, %3 ]
%9 = phi i32 [ %12, %7 ], [ %0, %3 ]
%10 = getelementptr inbounds i32, i32* %1, i64 %8
%11 = load i32, i32* %10
%12 = tail call i32 @__simplePNG_single_byte_crc(i32 %9, i32 %11)
%13 = add nuw i64 %8, 1
%14 = icmp eq i64 %13, %2
br i1 %14, label %5, label %7
}