#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 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 ip6_hdr {
  char ip6_src;
  char ip6_dst;
  char ip6_nxt;
};
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);
uint16_t tcp6_checksum(struct ip6_hdr iphdr, struct tcphdr tcphdr,
                       uint8_t *options, int opt_len) {
  uint32_t lvalue;
  char buf[IP_MAXPACKET], cvalue;
  char *ptr;
  int chksumlen = 0;
  ptr = &buf[0];
  memcpy(ptr, &iphdr.ip6_src, sizeof(iphdr.ip6_src));
  ptr += sizeof(iphdr.ip6_src);
  chksumlen += sizeof(iphdr.ip6_src);
  memcpy(ptr, &iphdr.ip6_dst, sizeof(iphdr.ip6_dst));
  ptr += sizeof(iphdr.ip6_dst);
  chksumlen += sizeof(iphdr.ip6_dst);
  lvalue = htonl(sizeof(tcphdr) + opt_len);
  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, options, opt_len * sizeof(uint8_t));
  ptr += opt_len;
  chksumlen += opt_len;
  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    0x2e8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,%ecx
mov    %rsp,%rax
mov    %rax,-0x38(%rbp)
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x60(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x40(%rbp)
movl   $0x0,-0x54(%rbp)
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x1,%edx
call   1050 <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   1050 <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   1050 <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
add    $0x2,%rsi
mov    $0x1,%edx
call   1050 <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   1050 <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   1050 <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   1050 <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   1050 <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   1050 <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   1050 <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   1050 <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   1050 <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   1050 <memcpy@plt>
mov    -0x60(%rbp),%rdi
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)
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,-0x50(%rbp)
mov    %rsp,-0x48(%rbp)
mov    %di,-0x30(%rbp)
shr    $0x10,%edi
mov    %dil,-0x2e(%rbp)
mov    %rsi,-0x40(%rbp)
mov    %rdx,-0x38(%rbp)
mov    0x2e92(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%r13
add    $0xf,%r14
and    $0xfffffffffffffff0,%r14
mov    %r13,%rbx
sub    %r14,%rbx
mov    %rbx,%rsp
lea    -0x30(%rbp),%rsi
mov    %rbx,%rdi
mov    $0x1,%edx
call   1050 <memcpy@plt>
lea    0x1(%rbx),%rdi
lea    -0x2f(%rbp),%rsi
mov    $0x1,%edx
call   1050 <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   1050 <memcpy@plt>
movw   $0x0,0x3(%rbx)
movb   $0x0,0x5(%rbx)
lea    0x6(%rbx),%rdi
lea    -0x2e(%rbp),%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
lea    0x7(%rbx),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
lea    0x8(%rbx),%rdi
lea    -0x3f(%rbp),%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
lea    0x9(%rbx),%rdi
lea    -0x3e(%rbp),%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
lea    0xa(%rbx),%rdi
lea    -0x3d(%rbp),%rsi
mov    $0x1,%edx
call   1050 <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   1050 <memcpy@plt>
lea    0xc(%rbx),%rdi
lea    -0x34(%rbp),%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
lea    0xd(%rbx),%rdi
lea    -0x33(%rbp),%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
neg    %r14
movw   $0x0,0xe(%r13,%r14,1)
lea    0x10(%rbx),%rdi
lea    -0x32(%rbp),%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
lea    0x11(%rbx),%rdi
mov    -0x50(%rbp),%rsi
mov    %r15d,%edx
call   1050 <memcpy@plt>
add    $0x11,%r15d
mov    %rbx,%rdi
mov    %r15d,%esi
call   1030 <checksum@plt>
mov    -0x48(%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, i8, 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
store i24 %0, i24* %7
%17 = bitcast %struct.ip6_hdr* %6 to i8*
%18 = bitcast i24* %7 to i8*
%19 = bitcast %struct.tcphdr* %8 to { i64, i64 }*
%20 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %19, i32 0, i32 0
store i64 %1, i64* %20
%21 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %19, i32 0, i32 1
store i64 %2, i64* %21
store i8* %3, i8** %9
store i32 %4, i32* %10
%22 = load i32, i32* @IP_MAXPACKET
%23 = zext i32 %22 to i64
%24 = call i8* @llvm.stacksave()
store i8* %24, i8** %12
%25 = alloca i8, i64 %23
store i64 %23, i64* %13
store i32 0, i32* %16
%26 = getelementptr inbounds i8, i8* %25, i64 0
store i8* %26, i8** %15
%27 = load i8*, i8** %15
%28 = getelementptr inbounds %struct.ip6_hdr, %struct.ip6_hdr* %6, i32 0, i32 0
%29 = call i32 @memcpy(i8* %27, i8* %28, i32 1)
%30 = load i8*, i8** %15
%31 = getelementptr inbounds i8, i8* %30, i64 1
store i8* %31, i8** %15
%32 = load i32, i32* %16
%33 = sext i32 %32 to i64
%34 = add i64 %33, 1
%35 = trunc i64 %34 to i32
store i32 %35, i32* %16
%36 = load i8*, i8** %15
%37 = getelementptr inbounds %struct.ip6_hdr, %struct.ip6_hdr* %6, i32 0, i32 1
%38 = call i32 @memcpy(i8* %36, i8* %37, i32 1)
%39 = load i8*, i8** %15
%40 = getelementptr inbounds i8, i8* %39, i64 1
store i8* %40, i8** %15
%41 = load i32, i32* %16
%42 = sext i32 %41 to i64
%43 = add i64 %42, 1
%44 = trunc i64 %43 to i32
store i32 %44, i32* %16
%45 = load i32, i32* %10
%46 = sext i32 %45 to i64
%47 = add i64 16, %46
%48 = trunc i64 %47 to i32
%49 = call signext i8 @htonl(i32 %48)
store i8 %49, i8* %11
%50 = load i8*, i8** %15
%51 = call i32 @memcpy(i8* %50, i8* %11, i32 1)
%52 = load i8*, i8** %15
%53 = getelementptr inbounds i8, i8* %52, i64 1
store i8* %53, i8** %15
%54 = load i32, i32* %16
%55 = sext i32 %54 to i64
%56 = add i64 %55, 1
%57 = trunc i64 %56 to i32
store i32 %57, i32* %16
%58 = load i8*, i8** %15
store i8 0, i8* %58
%59 = load i8*, i8** %15
%60 = getelementptr inbounds i8, i8* %59, i32 1
store i8* %60, i8** %15
%61 = load i8*, i8** %15
store i8 0, i8* %61
%62 = load i8*, i8** %15
%63 = getelementptr inbounds i8, i8* %62, i32 1
store i8* %63, i8** %15
%64 = load i8*, i8** %15
store i8 0, i8* %64
%65 = load i8*, i8** %15
%66 = getelementptr inbounds i8, i8* %65, i32 1
store i8* %66, i8** %15
%67 = load i32, i32* %16
%68 = add nsw i32 %67, 3
store i32 %68, i32* %16
%69 = load i8*, i8** %15
%70 = getelementptr inbounds %struct.ip6_hdr, %struct.ip6_hdr* %6, i32 0, i32 2
%71 = call i32 @memcpy(i8* %69, i8* %70, i32 1)
%72 = load i8*, i8** %15
%73 = getelementptr inbounds i8, i8* %72, i64 1
store i8* %73, i8** %15
%74 = load i32, i32* %16
%75 = sext i32 %74 to i64
%76 = add i64 %75, 1
%77 = trunc i64 %76 to i32
store i32 %77, i32* %16
%78 = load i8*, i8** %15
%79 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i32 0, i32 0
%80 = call i32 @memcpy(i8* %78, i8* %79, i32 1)
%81 = load i8*, i8** %15
%82 = getelementptr inbounds i8, i8* %81, i64 1
store i8* %82, i8** %15
%83 = load i32, i32* %16
%84 = sext i32 %83 to i64
%85 = add i64 %84, 1
%86 = trunc i64 %85 to i32
store i32 %86, i32* %16
%87 = load i8*, i8** %15
%88 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i32 0, i32 1
%89 = call i32 @memcpy(i8* %87, i8* %88, i32 1)
%90 = load i8*, i8** %15
%91 = getelementptr inbounds i8, i8* %90, i64 1
store i8* %91, i8** %15
%92 = load i32, i32* %16
%93 = sext i32 %92 to i64
%94 = add i64 %93, 1
%95 = trunc i64 %94 to i32
store i32 %95, i32* %16
%96 = load i8*, i8** %15
%97 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i32 0, i32 2
%98 = call i32 @memcpy(i8* %96, i8* %97, i32 1)
%99 = load i8*, i8** %15
%100 = getelementptr inbounds i8, i8* %99, i64 1
store i8* %100, i8** %15
%101 = load i32, i32* %16
%102 = sext i32 %101 to i64
%103 = add i64 %102, 1
%104 = trunc i64 %103 to i32
store i32 %104, i32* %16
%105 = load i8*, i8** %15
%106 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i32 0, i32 3
%107 = call i32 @memcpy(i8* %105, i8* %106, i32 1)
%108 = load i8*, i8** %15
%109 = getelementptr inbounds i8, i8* %108, i64 1
store i8* %109, i8** %15
%110 = load i32, i32* %16
%111 = sext i32 %110 to i64
%112 = add i64 %111, 1
%113 = trunc i64 %112 to i32
store i32 %113, i32* %16
%114 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i32 0, i32 4
%115 = load i32, i32* %114
%116 = shl i32 %115, 4
%117 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i32 0, i32 5
%118 = load i32, i32* %117
%119 = add nsw i32 %116, %118
%120 = trunc i32 %119 to i8
store i8 %120, i8* %14
%121 = load i8*, i8** %15
%122 = call i32 @memcpy(i8* %121, i8* %14, i32 1)
%123 = load i8*, i8** %15
%124 = getelementptr inbounds i8, i8* %123, i64 1
store i8* %124, i8** %15
%125 = load i32, i32* %16
%126 = sext i32 %125 to i64
%127 = add i64 %126, 1
%128 = trunc i64 %127 to i32
store i32 %128, i32* %16
%129 = load i8*, i8** %15
%130 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i32 0, i32 6
%131 = call i32 @memcpy(i8* %129, i8* %130, i32 1)
%132 = load i8*, i8** %15
%133 = getelementptr inbounds i8, i8* %132, i64 1
store i8* %133, i8** %15
%134 = load i32, i32* %16
%135 = sext i32 %134 to i64
%136 = add i64 %135, 1
%137 = trunc i64 %136 to i32
store i32 %137, i32* %16
%138 = load i8*, i8** %15
%139 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i32 0, i32 7
%140 = call i32 @memcpy(i8* %138, i8* %139, i32 1)
%141 = load i8*, i8** %15
%142 = getelementptr inbounds i8, i8* %141, i64 1
store i8* %142, i8** %15
%143 = load i32, i32* %16
%144 = sext i32 %143 to i64
%145 = add i64 %144, 1
%146 = trunc i64 %145 to i32
store i32 %146, i32* %16
%147 = load i8*, i8** %15
store i8 0, i8* %147
%148 = load i8*, i8** %15
%149 = getelementptr inbounds i8, i8* %148, i32 1
store i8* %149, i8** %15
%150 = load i8*, i8** %15
store i8 0, i8* %150
%151 = load i8*, i8** %15
%152 = getelementptr inbounds i8, i8* %151, i32 1
store i8* %152, i8** %15
%153 = load i32, i32* %16
%154 = add nsw i32 %153, 2
store i32 %154, i32* %16
%155 = load i8*, i8** %15
%156 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i32 0, i32 8
%157 = call i32 @memcpy(i8* %155, i8* %156, i32 1)
%158 = load i8*, i8** %15
%159 = getelementptr inbounds i8, i8* %158, i64 1
store i8* %159, i8** %15
%160 = load i32, i32* %16
%161 = sext i32 %160 to i64
%162 = add i64 %161, 1
%163 = trunc i64 %162 to i32
store i32 %163, i32* %16
%164 = load i8*, i8** %15
%165 = load i8*, i8** %9
%166 = load i32, i32* %10
%167 = sext i32 %166 to i64
%168 = mul i64 %167, 1
%169 = trunc i64 %168 to i32
%170 = call i32 @memcpy(i8* %164, i8* %165, i32 %169)
%171 = load i32, i32* %10
%172 = load i8*, i8** %15
%173 = sext i32 %171 to i64
%174 = getelementptr inbounds i8, i8* %172, i64 %173
store i8* %174, i8** %15
%175 = load i32, i32* %10
%176 = load i32, i32* %16
%177 = add nsw i32 %176, %175
store i32 %177, i32* %16
%178 = bitcast i8* %25 to i32*
%179 = load i32, i32* %16
%180 = call i32 @checksum(i32* %178, i32 %179)
%181 = load i8*, i8** %12
ret i32 %180
}

LLVM IR (-O2):
%struct.ip6_hdr = type { i8, i8, 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 = getelementptr inbounds %struct.ip6_hdr, %struct.ip6_hdr* %6, i64 0, i32 0
%19 = call i32 @memcpy(i8* %17, i8* %18, i32 1)
%20 = getelementptr inbounds i8, i8* %17, i64 1
%21 = getelementptr inbounds %struct.ip6_hdr, %struct.ip6_hdr* %6, i64 0, i32 1
%22 = call i32 @memcpy(i8* %20, i8* %21, i32 1)
%23 = getelementptr inbounds i8, i8* %17, i64 2
%24 = add i32 %4, 16
%25 = call signext i8 @htonl(i32 %24)
store i8 %25, i8* %9
%26 = call i32 @memcpy(i8* %23, i8* %9, i32 1)
%27 = getelementptr inbounds i8, i8* %17, i64 3
store i8 0, i8* %27
%28 = getelementptr inbounds i8, i8* %17, i64 4
store i8 0, i8* %28
%29 = getelementptr inbounds i8, i8* %17, i64 5
store i8 0, i8* %29
%30 = getelementptr inbounds i8, i8* %17, i64 6
%31 = getelementptr inbounds %struct.ip6_hdr, %struct.ip6_hdr* %6, i64 0, i32 2
%32 = call i32 @memcpy(i8* %30, i8* %31, i32 1)
%33 = getelementptr inbounds i8, i8* %17, i64 7
%34 = bitcast { i64, i64 }* %7 to i8*
%35 = call i32 @memcpy(i8* %33, i8* %34, i32 1)
%36 = getelementptr inbounds i8, i8* %17, i64 8
%37 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i64 0, i32 1
%38 = call i32 @memcpy(i8* %36, i8* %37, i32 1)
%39 = getelementptr inbounds i8, i8* %17, i64 9
%40 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i64 0, i32 2
%41 = call i32 @memcpy(i8* %39, i8* %40, i32 1)
%42 = getelementptr inbounds i8, i8* %17, i64 10
%43 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i64 0, i32 3
%44 = call i32 @memcpy(i8* %42, i8* %43, i32 1)
%45 = getelementptr inbounds i8, i8* %17, i64 11
%46 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i64 0, i32 4
%47 = load i32, i32* %46
%48 = shl i32 %47, 4
%49 = bitcast i64* %13 to i32*
%50 = load i32, i32* %49
%51 = add nsw i32 %48, %50
%52 = trunc i32 %51 to i8
store i8 %52, i8* %10
%53 = call i32 @memcpy(i8* %45, i8* %10, i32 1)
%54 = getelementptr inbounds i8, i8* %17, i64 12
%55 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i64 0, i32 6
%56 = call i32 @memcpy(i8* %54, i8* %55, i32 1)
%57 = getelementptr inbounds i8, i8* %17, i64 13
%58 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i64 0, i32 7
%59 = call i32 @memcpy(i8* %57, i8* %58, i32 1)
%60 = getelementptr inbounds i8, i8* %17, i64 14
store i8 0, i8* %60
%61 = getelementptr inbounds i8, i8* %17, i64 15
store i8 0, i8* %61
%62 = getelementptr inbounds i8, i8* %17, i64 16
%63 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %8, i64 0, i32 8
%64 = call i32 @memcpy(i8* %62, i8* %63, i32 1)
%65 = getelementptr inbounds i8, i8* %17, i64 17
%66 = call i32 @memcpy(i8* %65, i8* %3, i32 %4)
%67 = add nsw i32 %4, 17
%68 = bitcast i8* %17 to i32*
%69 = call i32 @checksum(i32* %68, i32 %67)
ret i32 %69
}