#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 */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
typedef char uint8_t;
typedef char uint32_t;
typedef int /*<<< orphan*/ uint16_t;
typedef int /*<<< orphan*/ tcphdr;
struct tcphdr {
  char th_sport;
  char th_dport;
  char th_seq;
  char th_ack;
  int th_off;
  int th_x2;
  char th_flags;
  char th_win;
  char th_urp;
};
struct TYPE_4__ {
  char s6_addr;
};
struct TYPE_3__ {
  char s6_addr;
};
struct ip6_hdr {
  char ip6_nxt;
  TYPE_2__ ip6_dst;
  TYPE_1__ ip6_src;
};
typedef int /*<<< orphan*/ lvalue;
typedef int /*<<< orphan*/ cvalue;

/* Variables and functions */
int IP_MAXPACKET;
int /*<<< orphan*/ checksum(int /*<<< orphan*/ *, int);
char htonl(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
uint16_t tcp6_checksum(struct ip6_hdr iphdr, struct tcphdr tcphdr,
                       uint8_t *payload, int payloadlen) {
  uint32_t lvalue;
  char buf[IP_MAXPACKET], cvalue;
  char *ptr;
  int chksumlen = 0;
  int i;
  memset(buf, 0, IP_MAXPACKET * sizeof(uint8_t));
  ptr = &buf[0];
  memcpy(ptr, &iphdr.ip6_src.s6_addr, sizeof(iphdr.ip6_src.s6_addr));
  ptr += sizeof(iphdr.ip6_src.s6_addr);
  chksumlen += sizeof(iphdr.ip6_src.s6_addr);
  memcpy(ptr, &iphdr.ip6_dst.s6_addr, sizeof(iphdr.ip6_dst.s6_addr));
  ptr += sizeof(iphdr.ip6_dst.s6_addr);
  chksumlen += sizeof(iphdr.ip6_dst.s6_addr);
  lvalue = htonl(sizeof(tcphdr) + payloadlen);
  memcpy(ptr, &lvalue, sizeof(lvalue));
  ptr += sizeof(lvalue);
  chksumlen += sizeof(lvalue);
  *ptr = 0;
  ptr++;
  *ptr = 0;
  ptr++;
  *ptr = 0;
  ptr++;
  chksumlen += 3;
  memcpy(ptr, &iphdr.ip6_nxt, sizeof(iphdr.ip6_nxt));
  ptr += sizeof(iphdr.ip6_nxt);
  chksumlen += sizeof(iphdr.ip6_nxt);
  memcpy(ptr, &tcphdr.th_sport, sizeof(tcphdr.th_sport));
  ptr += sizeof(tcphdr.th_sport);
  chksumlen += sizeof(tcphdr.th_sport);
  memcpy(ptr, &tcphdr.th_dport, sizeof(tcphdr.th_dport));
  ptr += sizeof(tcphdr.th_dport);
  chksumlen += sizeof(tcphdr.th_dport);
  memcpy(ptr, &tcphdr.th_seq, sizeof(tcphdr.th_seq));
  ptr += sizeof(tcphdr.th_seq);
  chksumlen += sizeof(tcphdr.th_seq);
  memcpy(ptr, &tcphdr.th_ack, sizeof(tcphdr.th_ack));
  ptr += sizeof(tcphdr.th_ack);
  chksumlen += sizeof(tcphdr.th_ack);
  cvalue = (tcphdr.th_off << 4) + tcphdr.th_x2;
  memcpy(ptr, &cvalue, sizeof(cvalue));
  ptr += sizeof(cvalue);
  chksumlen += sizeof(cvalue);
  memcpy(ptr, &tcphdr.th_flags, sizeof(tcphdr.th_flags));
  ptr += sizeof(tcphdr.th_flags);
  chksumlen += sizeof(tcphdr.th_flags);
  memcpy(ptr, &tcphdr.th_win, sizeof(tcphdr.th_win));
  ptr += sizeof(tcphdr.th_win);
  chksumlen += sizeof(tcphdr.th_win);
  *ptr = 0;
  ptr++;
  *ptr = 0;
  ptr++;
  chksumlen += 2;
  memcpy(ptr, &tcphdr.th_urp, sizeof(tcphdr.th_urp));
  ptr += sizeof(tcphdr.th_urp);
  chksumlen += sizeof(tcphdr.th_urp);
  memcpy(ptr, payload, payloadlen * sizeof(uint8_t));
  ptr += payloadlen;
  chksumlen += payloadlen;
  i = 0;
  while (((payloadlen + i) % 2) != 0) {
    i++;
    chksumlen++;
    ptr++;
  }
  return checksum((uint16_t *)buf, chksumlen);
}


x86 assembly (clang, -O0):
<tcp6_checksum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %di,%ax
mov    %ax,-0xc(%rbp)
shr    $0x10,%edi
mov    %dil,%al
mov    %al,-0xa(%rbp)
mov    -0xa(%rbp),%al
mov    %al,-0x6(%rbp)
mov    -0xc(%rbp),%ax
mov    %ax,-0x8(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x60(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x54(%rbp)
mov    0x2e48(%rip),%rax
movslq (%rax),%rax
shl    $0x0,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x60(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x8(%rbp),%rsi
add    $0x2,%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
movslq -0x54(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x8(%rbp),%rsi
add    $0x1,%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
movslq -0x54(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x54(%rbp)
movslq -0x2c(%rbp),%rax
add    $0x10,%rax
mov    %eax,%edi
call   1040 <htonl@plt>
mov    %al,-0x2d(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x2d(%rbp),%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
movslq -0x54(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x54(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
movslq -0x54(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
movslq -0x54(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x20(%rbp),%rsi
add    $0x1,%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
movslq -0x54(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x20(%rbp),%rsi
add    $0x2,%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
movslq -0x54(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x20(%rbp),%rsi
add    $0x3,%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
movslq -0x54(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x54(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x4,%eax
add    -0x18(%rbp),%eax
mov    %al,-0x41(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x41(%rbp),%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
movslq -0x54(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x20(%rbp),%rsi
add    $0xc,%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
movslq -0x54(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x20(%rbp),%rsi
add    $0xd,%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
movslq -0x54(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x54(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x20(%rbp),%rsi
add    $0xe,%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
movslq -0x54(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x2c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    -0x2c(%rbp),%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x2c(%rbp),%eax
add    -0x54(%rbp),%eax
mov    %eax,-0x54(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x2c(%rbp),%eax
add    -0x58(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     14d5 <tcp6_checksum+0x395>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    149b <tcp6_checksum+0x35b>
mov    -0x60(%rbp),%rdi
mov    -0x54(%rbp),%esi
call   1030 <checksum@plt>
mov    -0x38(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tcp6_checksum>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8d,%r15d
mov    %rcx,-0x48(%rbp)
mov    %rsp,-0x50(%rbp)
mov    %di,-0x30(%rbp)
shr    $0x10,%edi
mov    %dil,-0x2e(%rbp)
mov    %rsi,-0x40(%rbp)
mov    %rdx,-0x38(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%r13d
mov    %rsp,%r14
add    $0xf,%r13
and    $0xfffffffffffffff0,%r13
mov    %r14,%rbx
sub    %r13,%rbx
mov    %rbx,%rsp
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    -0x2e(%rbp),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1060 <memcpy@plt>
lea    0x1(%rbx),%rdi
lea    -0x2f(%rbp),%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
lea    0x2(%rbx),%r12
lea    0x10(%r15),%edi
call   1040 <htonl@plt>
mov    %al,-0x2a(%rbp)
lea    -0x2a(%rbp),%rsi
mov    %r12,%rdi
mov    $0x1,%edx
call   1060 <memcpy@plt>
movw   $0x0,0x3(%rbx)
movb   $0x0,0x5(%rbx)
lea    0x6(%rbx),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
lea    0x7(%rbx),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
lea    0x8(%rbx),%rdi
lea    -0x3f(%rbp),%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
lea    0x9(%rbx),%rdi
lea    -0x3e(%rbp),%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
lea    0xa(%rbx),%rdi
lea    -0x3d(%rbp),%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
lea    0xb(%rbx),%rdi
mov    -0x3c(%rbp),%eax
shl    $0x4,%eax
add    -0x38(%rbp),%eax
mov    %al,-0x29(%rbp)
lea    -0x29(%rbp),%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
lea    0xc(%rbx),%rdi
lea    -0x34(%rbp),%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
lea    0xd(%rbx),%rdi
lea    -0x33(%rbp),%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
neg    %r13
movw   $0x0,0xe(%r14,%r13,1)
lea    0x10(%rbx),%rdi
lea    -0x32(%rbp),%rsi
mov    $0x1,%edx
call   1060 <memcpy@plt>
lea    0x11(%rbx),%rdi
mov    -0x48(%rbp),%rsi
mov    %r15d,%edx
call   1060 <memcpy@plt>
mov    %r15d,%eax
and    $0x1,%eax
cmp    $0x1,%eax
sbb    $0x0,%r15d
add    $0x12,%r15d
mov    %rbx,%rdi
mov    %r15d,%esi
call   1030 <checksum@plt>
mov    -0x50(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ip6_hdr = type { i8, %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i8 }
%struct.TYPE_3__ = type { i8 }
%struct.tcphdr = type { i8, i8, i8, i8, i32, i32, i8, i8, i8 }
@IP_MAXPACKET = global i32 0
define i32 @tcp6_checksum(i24 %0, i64 %1, i64 %2, i8* %3, i32 %4) {
%6 = alloca %struct.ip6_hdr
%7 = alloca i24
%8 = alloca %struct.tcphdr
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i8
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i32
store i24 %0, i24* %7
%18 = bitcast %struct.ip6_hdr* %6 to i8*
%19 = bitcast i24* %7 to i8*
%20 = bitcast %struct.tcphdr* %8 to { i64, i64 }*
%21 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %20, i32 0, i32 0
store i64 %1, i64* %21
%22 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %20, i32 0, i32 1
store i64 %2, i64* %22
store i8* %3, i8** %9
store i32 %4, i32* %10
%23 = load i32, i32* @IP_MAXPACKET
%24 = zext i32 %23 to i64
%25 = call i8* @llvm.stacksave()
store i8* %25, i8** %12
%26 = alloca i8, i64 %24
store i64 %24, i64* %13
store i32 0, i32* %16
%27 = load i32, i32* @IP_MAXPACKET
%28 = sext i32 %27 to i64
%29 = mul i64 %28, 1
%30 = trunc i64 %29 to i32
%31 = call i32 @memset(i8* %26, i32 0, i32 %30)
%32 = getelementptr inbounds i8, i8* %26, i64 0
store i8* %32, i8** %15
%33 = load i8*, i8** %15
%34 = getelementptr inbounds %struct.ip6_hdr, %struct.ip6_hdr* %6, i32 0, i32 2
%35 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %34, i32 0, i32 0
%36 = call i32 @memcpy(i8* %33, i8* %35, i32 1)
%37 = load i8*, i8** %15
%38 = getelementptr inbounds i8, i8* %37, i64 1
store i8* %38, i8** %15
%39 = load i32, i32* %16
%40 = sext i32 %39 to i64
%41 = add i64 %40, 1
%42 = trunc i64 %41 to i32
store i32 %42, i32* %16
%43 = load i8*, i8** %15
%44 = getelementptr inbounds %struct.ip6_hdr, %struct.ip6_hdr* %6, i32 0, i32 1
%45 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %44, i32 0, i32 0
%46 = call i32 @memcpy(i8* %43, i8* %45, i32 1)
%47 = load i8*, i8** %15
%48 = getelementptr inbounds i8, i8* %47, i64 1
store i8* %48, i8** %15
%49 = load i32, i32* %16
%50 = sext i32 %49 to i64
%51 = add i64 %50, 1
%52 = trunc i64 %51 to i32
store i32 %52, i32* %16
%53 = load i32, i32* %10
%54 = sext i32 %53 to i64
%55 = add i64 16, %54
%56 = trunc i64 %55 to i32
%57 = call signext i8 @htonl(i32 %56)
store i8 %57, i8* %11
%58 = load i8*, i8** %15
%59 = call i32 @memcpy(i8* %58, i8* %11, i32 1)
%60 = load i8*, i8** %15
%61 = getelementptr inbounds i8, i8* %60, i64 1
store i8* %61, i8** %15
%62 = load i32, i32* %16
%63 = sext i32 %62 to i64
%64 = add i64 %63, 1
%65 = trunc i64 %64 to i32
store i32 %65, i32* %16
%66 = load i8*, i8** %15
store i8 0, i8* %66
%67 = load i8*, i8** %15
%68 = getelementptr inbounds i8, i8* %67, i32 1
store i8* %68, i8** %15
%69 = load i8*, i8** %15
store i8 0, i8* %69
%70 = load i8*, i8** %15
%71 = getelementptr inbounds i8, i8* %70, i32 1
store i8* %71, i8** %15
%72 = load i8*, i8** %15
store i8 0, i8* %72
%73 = load i8*, i8** %15
%74 = getelementptr inbounds i8, i8* %73, i32 1
store i8* %74, i8** %15
%75 = load i32, i32* %16
%76 = add nsw i32 %75, 3
store i32 %76, i32* %16
%77 = load i8*, i8** %15
%78 = getelementptr inbounds %struct.ip6_hdr, %struct.ip6_hdr* %6, i32 0, i32 0
%79 = call i32 @memcpy(i8* %77, i8* %78, i32 1)
%80 = load i8*, i8** %15
%81 = getelementptr inbounds i8, i8* %80, i64 1
store i8* %81, i8** %15
%82 = load i32, i32* %16
%83 = sext i32 %82 to i64
%84 = add i64 %83, 1
%85 = trunc i64 %84 to i32
store i32 %85, i32* %16
%86 = load i8*, i8** %15
%87 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i32 0, i32 0
%88 = call i32 @memcpy(i8* %86, i8* %87, i32 1)
%89 = load i8*, i8** %15
%90 = getelementptr inbounds i8, i8* %89, i64 1
store i8* %90, i8** %15
%91 = load i32, i32* %16
%92 = sext i32 %91 to i64
%93 = add i64 %92, 1
%94 = trunc i64 %93 to i32
store i32 %94, i32* %16
%95 = load i8*, i8** %15
%96 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i32 0, i32 1
%97 = call i32 @memcpy(i8* %95, i8* %96, i32 1)
%98 = load i8*, i8** %15
%99 = getelementptr inbounds i8, i8* %98, i64 1
store i8* %99, i8** %15
%100 = load i32, i32* %16
%101 = sext i32 %100 to i64
%102 = add i64 %101, 1
%103 = trunc i64 %102 to i32
store i32 %103, i32* %16
%104 = load i8*, i8** %15
%105 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i32 0, i32 2
%106 = call i32 @memcpy(i8* %104, i8* %105, i32 1)
%107 = load i8*, i8** %15
%108 = getelementptr inbounds i8, i8* %107, i64 1
store i8* %108, i8** %15
%109 = load i32, i32* %16
%110 = sext i32 %109 to i64
%111 = add i64 %110, 1
%112 = trunc i64 %111 to i32
store i32 %112, i32* %16
%113 = load i8*, i8** %15
%114 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i32 0, i32 3
%115 = call i32 @memcpy(i8* %113, i8* %114, i32 1)
%116 = load i8*, i8** %15
%117 = getelementptr inbounds i8, i8* %116, i64 1
store i8* %117, i8** %15
%118 = load i32, i32* %16
%119 = sext i32 %118 to i64
%120 = add i64 %119, 1
%121 = trunc i64 %120 to i32
store i32 %121, i32* %16
%122 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i32 0, i32 4
%123 = load i32, i32* %122
%124 = shl i32 %123, 4
%125 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i32 0, i32 5
%126 = load i32, i32* %125
%127 = add nsw i32 %124, %126
%128 = trunc i32 %127 to i8
store i8 %128, i8* %14
%129 = load i8*, i8** %15
%130 = call i32 @memcpy(i8* %129, i8* %14, i32 1)
%131 = load i8*, i8** %15
%132 = getelementptr inbounds i8, i8* %131, i64 1
store i8* %132, i8** %15
%133 = load i32, i32* %16
%134 = sext i32 %133 to i64
%135 = add i64 %134, 1
%136 = trunc i64 %135 to i32
store i32 %136, i32* %16
%137 = load i8*, i8** %15
%138 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i32 0, i32 6
%139 = call i32 @memcpy(i8* %137, i8* %138, i32 1)
%140 = load i8*, i8** %15
%141 = getelementptr inbounds i8, i8* %140, i64 1
store i8* %141, i8** %15
%142 = load i32, i32* %16
%143 = sext i32 %142 to i64
%144 = add i64 %143, 1
%145 = trunc i64 %144 to i32
store i32 %145, i32* %16
%146 = load i8*, i8** %15
%147 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i32 0, i32 7
%148 = call i32 @memcpy(i8* %146, i8* %147, i32 1)
%149 = load i8*, i8** %15
%150 = getelementptr inbounds i8, i8* %149, i64 1
store i8* %150, i8** %15
%151 = load i32, i32* %16
%152 = sext i32 %151 to i64
%153 = add i64 %152, 1
%154 = trunc i64 %153 to i32
store i32 %154, i32* %16
%155 = load i8*, i8** %15
store i8 0, i8* %155
%156 = load i8*, i8** %15
%157 = getelementptr inbounds i8, i8* %156, i32 1
store i8* %157, i8** %15
%158 = load i8*, i8** %15
store i8 0, i8* %158
%159 = load i8*, i8** %15
%160 = getelementptr inbounds i8, i8* %159, i32 1
store i8* %160, i8** %15
%161 = load i32, i32* %16
%162 = add nsw i32 %161, 2
store i32 %162, i32* %16
%163 = load i8*, i8** %15
%164 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i32 0, i32 8
%165 = call i32 @memcpy(i8* %163, i8* %164, i32 1)
%166 = load i8*, i8** %15
%167 = getelementptr inbounds i8, i8* %166, i64 1
store i8* %167, i8** %15
%168 = load i32, i32* %16
%169 = sext i32 %168 to i64
%170 = add i64 %169, 1
%171 = trunc i64 %170 to i32
store i32 %171, i32* %16
%172 = load i8*, i8** %15
%173 = load i8*, i8** %9
%174 = load i32, i32* %10
%175 = sext i32 %174 to i64
%176 = mul i64 %175, 1
%177 = trunc i64 %176 to i32
%178 = call i32 @memcpy(i8* %172, i8* %173, i32 %177)
%179 = load i32, i32* %10
%180 = load i8*, i8** %15
%181 = sext i32 %179 to i64
%182 = getelementptr inbounds i8, i8* %180, i64 %181
store i8* %182, i8** %15
%183 = load i32, i32* %10
%184 = load i32, i32* %16
%185 = add nsw i32 %184, %183
store i32 %185, i32* %16
store i32 0, i32* %17
br label %186
186: ; preds = %192, %5
%187 = load i32, i32* %10
%188 = load i32, i32* %17
%189 = add nsw i32 %187, %188
%190 = srem i32 %189, 2
%191 = icmp ne i32 %190, 0
br i1 %191, label %192, label %199
192: ; preds = %186
%193 = load i32, i32* %17
%194 = add nsw i32 %193, 1
store i32 %194, i32* %17
%195 = load i32, i32* %16
%196 = add nsw i32 %195, 1
store i32 %196, i32* %16
%197 = load i8*, i8** %15
%198 = getelementptr inbounds i8, i8* %197, i32 1
store i8* %198, i8** %15
br label %186
199: ; preds = %186
%200 = bitcast i8* %26 to i32*
%201 = load i32, i32* %16
%202 = call i32 @checksum(i32* %200, i32 %201)
%203 = load i8*, i8** %12
ret i32 %202
}

LLVM IR (-O2):
%struct.ip6_hdr = type { i8, %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i8 }
%struct.TYPE_3__ = type { i8 }
%struct.tcphdr = type { i8, i8, i8, i8, i32, i32, i8, i8, i8 }
@IP_MAXPACKET = global i32 0
define i32 @tcp6_checksum(i24 %0, i64 %1, i64 %2, i8* %3, i32 %4) {
%6 = alloca %struct.ip6_hdr
%7 = alloca { i64, i64 }
%8 = bitcast { i64, i64 }* %7 to %struct.tcphdr*
%9 = alloca i8
%10 = alloca i8
%11 = bitcast %struct.ip6_hdr* %6 to i24*
store i24 %0, i24* %11
%12 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %7, i64 0, i32 0
store i64 %1, i64* %12
%13 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %7, i64 0, i32 1
store i64 %2, i64* %13
%14 = load i32, i32* @IP_MAXPACKET
%15 = zext i32 %14 to i64
%16 = tail call i8* @llvm.stacksave()
%17 = alloca i8, i64 %15
%18 = load i32, i32* @IP_MAXPACKET
%19 = call i32 @memset(i8* %17, i32 0, i32 %18)
%20 = getelementptr inbounds %struct.ip6_hdr, %struct.ip6_hdr* %6, i64 0, i32 2, i32 0
%21 = call i32 @memcpy(i8* %17, i8* %20, i32 1)
%22 = getelementptr inbounds i8, i8* %17, i64 1
%23 = getelementptr inbounds %struct.ip6_hdr, %struct.ip6_hdr* %6, i64 0, i32 1, i32 0
%24 = call i32 @memcpy(i8* %22, i8* %23, i32 1)
%25 = getelementptr inbounds i8, i8* %17, i64 2
%26 = add i32 %4, 16
%27 = call signext i8 @htonl(i32 %26)
store i8 %27, i8* %9
%28 = call i32 @memcpy(i8* %25, i8* %9, i32 1)
%29 = getelementptr inbounds i8, i8* %17, i64 3
store i8 0, i8* %29
%30 = getelementptr inbounds i8, i8* %17, i64 4
store i8 0, i8* %30
%31 = getelementptr inbounds i8, i8* %17, i64 5
store i8 0, i8* %31
%32 = getelementptr inbounds i8, i8* %17, i64 6
%33 = getelementptr inbounds %struct.ip6_hdr, %struct.ip6_hdr* %6, i64 0, i32 0
%34 = call i32 @memcpy(i8* %32, i8* %33, i32 1)
%35 = getelementptr inbounds i8, i8* %17, i64 7
%36 = bitcast { i64, i64 }* %7 to i8*
%37 = call i32 @memcpy(i8* %35, i8* %36, i32 1)
%38 = getelementptr inbounds i8, i8* %17, i64 8
%39 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i64 0, i32 1
%40 = call i32 @memcpy(i8* %38, i8* %39, i32 1)
%41 = getelementptr inbounds i8, i8* %17, i64 9
%42 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i64 0, i32 2
%43 = call i32 @memcpy(i8* %41, i8* %42, i32 1)
%44 = getelementptr inbounds i8, i8* %17, i64 10
%45 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i64 0, i32 3
%46 = call i32 @memcpy(i8* %44, i8* %45, i32 1)
%47 = getelementptr inbounds i8, i8* %17, i64 11
%48 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i64 0, i32 4
%49 = load i32, i32* %48
%50 = shl i32 %49, 4
%51 = bitcast i64* %13 to i32*
%52 = load i32, i32* %51
%53 = add nsw i32 %50, %52
%54 = trunc i32 %53 to i8
store i8 %54, i8* %10
%55 = call i32 @memcpy(i8* %47, i8* %10, i32 1)
%56 = getelementptr inbounds i8, i8* %17, i64 12
%57 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i64 0, i32 6
%58 = call i32 @memcpy(i8* %56, i8* %57, i32 1)
%59 = getelementptr inbounds i8, i8* %17, i64 13
%60 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i64 0, i32 7
%61 = call i32 @memcpy(i8* %59, i8* %60, i32 1)
%62 = getelementptr inbounds i8, i8* %17, i64 14
store i8 0, i8* %62
%63 = getelementptr inbounds i8, i8* %17, i64 15
store i8 0, i8* %63
%64 = getelementptr inbounds i8, i8* %17, i64 16
%65 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i64 0, i32 8
%66 = call i32 @memcpy(i8* %64, i8* %65, i32 1)
%67 = getelementptr inbounds i8, i8* %17, i64 17
%68 = call i32 @memcpy(i8* %67, i8* %3, i32 %4)
%69 = and i32 %4, 1
%70 = icmp eq i32 %69, 0
%71 = select i1 %70, i32 17, i32 18
%72 = add i32 %71, %4
%73 = bitcast i8* %17 to i32*
%74 = call i32 @checksum(i32* %73, i32 %72)
ret i32 %74
}