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

/* Variables and functions */
uint16_t get_end_partial_csum32(uint64_t sum, uint16_t *ptr16, uint32_t len) {
  if (len >= 2) {
    sum += *ptr16++;
    len -= 2;
  }
  if (len >= 1)
    sum += *(uint8_t *)ptr16;
  sum = ((sum >> 32) + (sum & 0xFFFFFFFF));
  sum = ((sum >> 16) + (sum & 0xFFFF));
  sum = ((sum >> 16) + (sum & 0xFFFF));
  return (uint16_t)sum;
}


x86 assembly (clang, -O0):
<get_end_partial_csum32>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x2,-0x14(%rbp)
jl     1138 <get_end_partial_csum32+0x38>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jl     1153 <get_end_partial_csum32+0x53>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
movslq -0x4(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    -0x4(%rbp),%ecx
and    $0xffffffff,%ecx
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
mov    -0x4(%rbp),%ecx
and    $0xffff,%ecx
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
mov    -0x4(%rbp),%ecx
and    $0xffff,%ecx
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_end_partial_csum32>:
ret

LLVM IR (-O0):
define i32 @get_end_partial_csum32(i32 %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = icmp sge i32 %7, 2
br i1 %8, label %9, label %17
9: ; preds = %3
%10 = load i32*, i32** %5
%11 = getelementptr inbounds i32, i32* %10, i32 1
store i32* %11, i32** %5
%12 = load i32, i32* %10
%13 = load i32, i32* %4
%14 = add nsw i32 %13, %12
store i32 %14, i32* %4
%15 = load i32, i32* %6
%16 = sub nsw i32 %15, 2
store i32 %16, i32* %6
br label %17
17: ; preds = %9, %3
%18 = load i32, i32* %6
%19 = icmp sge i32 %18, 1
br i1 %19, label %20, label %28
20: ; preds = %17
%21 = load i32*, i32** %5
%22 = bitcast i32* %21 to i64*
%23 = load i64, i64* %22
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = add nsw i64 %25, %23
%27 = trunc i64 %26 to i32
store i32 %27, i32* %4
br label %28
28: ; preds = %20, %17
%29 = load i32, i32* %4
%30 = ashr i32 %29, 32
%31 = load i32, i32* %4
%32 = and i32 %31, -1
%33 = add i32 %30, %32
store i32 %33, i32* %4
%34 = load i32, i32* %4
%35 = ashr i32 %34, 16
%36 = load i32, i32* %4
%37 = and i32 %36, 65535
%38 = add nsw i32 %35, %37
store i32 %38, i32* %4
%39 = load i32, i32* %4
%40 = ashr i32 %39, 16
%41 = load i32, i32* %4
%42 = and i32 %41, 65535
%43 = add nsw i32 %40, %42
store i32 %43, i32* %4
%44 = load i32, i32* %4
ret i32 %44
}

LLVM IR (-O2):
define i32 @get_end_partial_csum32(i32 %0, i32* nocapture readnone %1, i32 %2) {
ret i32 poison
}