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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
void checksum(uint32_t *result, const void *_data, uint32_t _data_len) {
  assert(!(_data_len & 1));
  const uint16_t *data = _data;
  uint32_t len = _data_len / 2;
  while (len-- > 0) {
    *result += *data++;
  }
}


x86 assembly (clang, -O0):
<checksum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x24(%rbp)
cmp    $0x0,%eax
jle    1183 <checksum+0x73>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
jmp    1151 <checksum+0x41>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checksum>:
push   %r15
push   %r14
push   %rbx
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %edx,%edi
not    %edi
and    $0x1,%edi
call   1030 <assert@plt>
cmp    $0x2,%ebx
jl     1152 <checksum+0x42>
shr    %ebx
mov    (%r15),%eax
add    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
add    (%r14),%eax
add    $0x4,%r14
mov    %eax,(%r15)
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     1140 <checksum+0x30>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @checksum(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 i32, i32* %6
%10 = and i32 %9, 1
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i8*, i8** %5
%16 = bitcast i8* %15 to i32*
store i32* %16, i32** %7
%17 = load i32, i32* %6
%18 = sdiv i32 %17, 2
store i32 %18, i32* %8
br label %19
19: ; preds = %23, %3
%20 = load i32, i32* %8
%21 = add nsw i32 %20, -1
store i32 %21, i32* %8
%22 = icmp sgt i32 %20, 0
br i1 %22, label %23, label %30
23: ; preds = %19
%24 = load i32*, i32** %7
%25 = getelementptr inbounds i32, i32* %24, i32 1
store i32* %25, i32** %7
%26 = load i32, i32* %24
%27 = load i32*, i32** %4
%28 = load i32, i32* %27
%29 = add nsw i32 %28, %26
store i32 %29, i32* %27
br label %19
30: ; preds = %19
ret void
}

LLVM IR (-O2):
define void @checksum(i32* nocapture %0, i8* nocapture %1, i32 %2) {
%4 = and i32 %2, 1
%5 = xor i32 %4, 1
%6 = tail call i32 @assert(i32 %5)
%7 = icmp sgt i32 %2, 1
br i1 %7, label %8, label %21
8: ; preds = %3
%9 = lshr i32 %2, 1
%10 = bitcast i8* %1 to i32*
%11 = load i32, i32* %0
br label %12
12: ; preds = %8, %12
%13 = phi i32 [ %19, %12 ], [ %11, %8 ]
%14 = phi i32 [ %16, %12 ], [ %9, %8 ]
%15 = phi i32* [ %17, %12 ], [ %10, %8 ]
%16 = add nsw i32 %14, -1
%17 = getelementptr inbounds i32, i32* %15, i64 1
%18 = load i32, i32* %15
%19 = add nsw i32 %13, %18
store i32 %19, i32* %0
%20 = icmp ugt i32 %14, 1
br i1 %20, label %12, label %21
21: ; preds = %12, %3
ret void
}