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

/* Variables and functions */
uint64_t get_start_partial_csum32(uint16_t **ptr, uint32_t *len) {
  uint64_t csum = 0;
  if (*len < 2)
    return 0;
  if ((uint64_t)(*ptr) & 0x03) {
    csum = *(*ptr)++;
    *len -= 2;
  }
  return csum;
}


x86 assembly (clang, -O0):
<get_start_partial_csum32>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0x2,(%rax)
jge    112c <get_start_partial_csum32+0x2c>
movl   $0x0,-0x4(%rbp)
jmp    1166 <get_start_partial_csum32+0x66>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
and    $0x3,%eax
cmp    $0x0,%eax
je     1160 <get_start_partial_csum32+0x60>
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x4,%rdx
mov    %rdx,(%rcx)
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
sub    $0x2,%ecx
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_start_partial_csum32>:
mov    (%rsi),%ecx
xor    %eax,%eax
cmp    $0x2,%ecx
jl     111f <get_start_partial_csum32+0x1f>
mov    (%rdi),%rdx
test   $0x3,%dl
je     111f <get_start_partial_csum32+0x1f>
lea    0x4(%rdx),%rax
mov    %rax,(%rdi)
mov    (%rdx),%eax
add    $0xfffffffe,%ecx
mov    %ecx,(%rsi)
ret

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

LLVM IR (-O2):
define i32 @get_start_partial_csum32(i32** nocapture %0, i32* nocapture %1) {
%3 = load i32, i32* %1
%4 = icmp slt i32 %3, 2
br i1 %4, label %14, label %5
5: ; preds = %2
%6 = load i32*, i32** %0
%7 = ptrtoint i32* %6 to i64
%8 = and i64 %7, 3
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %5
%11 = getelementptr inbounds i32, i32* %6, i64 1
store i32* %11, i32** %0
%12 = load i32, i32* %6
%13 = add nsw i32 %3, -2
store i32 %13, i32* %1
br label %14
14: ; preds = %5, %10, %2
%15 = phi i32 [ 0, %2 ], [ %12, %10 ], [ 0, %5 ]
ret i32 %15
}