#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 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) {
  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));
  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);
  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    0x2e93(%rip),%rax
mov    (%rax),%eax
mov    %eax,%ecx
mov    %rsp,%rax
mov    %rax,-0x30(%rbp)
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x58(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x38(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
movslq -0x4c(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0x8(%rbp),%rsi
add    $0x1,%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
movslq -0x4c(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x4c(%rbp)
mov    $0x10,%edi
call   1040 <htonl@plt>
mov    %al,-0x21(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0x21(%rbp),%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
movslq -0x4c(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0x8(%rbp),%rsi
add    $0x2,%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
movslq -0x4c(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
movslq -0x4c(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0x20(%rbp),%rsi
add    $0x1,%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
movslq -0x4c(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0x20(%rbp),%rsi
add    $0x2,%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
movslq -0x4c(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0x20(%rbp),%rsi
add    $0x3,%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
movslq -0x4c(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x4c(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x4,%eax
add    -0x18(%rbp),%eax
mov    %al,-0x39(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0x39(%rbp),%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
movslq -0x4c(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0x20(%rbp),%rsi
add    $0xc,%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
movslq -0x4c(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0x20(%rbp),%rsi
add    $0xd,%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
movslq -0x4c(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rdi
lea    -0x20(%rbp),%rsi
add    $0xe,%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
mov    -0x58(%rbp),%rdi
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
movslq -0x4c(%rbp),%rax
add    $0x1,%rax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%esi
call   1030 <checksum@plt>
mov    -0x30(%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    $0x18,%rsp
mov    %rsp,%r15
mov    %di,-0x30(%rbp)
shr    $0x10,%edi
mov    %dil,-0x2e(%rbp)
mov    %rsi,-0x40(%rbp)
mov    %rdx,-0x38(%rbp)
mov    0x2e9a(%rip),%rax
mov    (%rax),%r12d
mov    %rsp,%r13
add    $0xf,%r12
and    $0xfffffffffffffff0,%r12
mov    %r13,%rbx
sub    %r12,%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),%r14
mov    $0x10,%edi
call   1040 <htonl@plt>
mov    %al,-0x2a(%rbp)
lea    -0x2a(%rbp),%rsi
mov    %r14,%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    %r12
movw   $0x0,0xe(%r13,%r12,1)
lea    0x10(%rbx),%rdi
lea    -0x32(%rbp),%rsi
mov    $0x1,%edx
call   1050 <memcpy@plt>
mov    %rbx,%rdi
mov    $0x11,%esi
call   1030 <checksum@plt>
mov    %r15,%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) {
%4 = alloca %struct.ip6_hdr
%5 = alloca i24
%6 = alloca %struct.tcphdr
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8
%11 = alloca i8*
%12 = alloca i32
store i24 %0, i24* %5
%13 = bitcast %struct.ip6_hdr* %4 to i8*
%14 = bitcast i24* %5 to i8*
%15 = bitcast %struct.tcphdr* %6 to { i64, i64 }*
%16 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %15, i32 0, i32 0
store i64 %1, i64* %16
%17 = getelementptr inbounds { i64, i64 }, { i64, i64 }* %15, i32 0, i32 1
store i64 %2, i64* %17
%18 = load i32, i32* @IP_MAXPACKET
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %8
%21 = alloca i8, i64 %19
store i64 %19, i64* %9
store i32 0, i32* %12
%22 = getelementptr inbounds i8, i8* %21, i64 0
store i8* %22, i8** %11
%23 = load i8*, i8** %11
%24 = getelementptr inbounds %struct.ip6_hdr, %struct.ip6_hdr* %4, i32 0, i32 0
%25 = call i32 @memcpy(i8* %23, i8* %24, i32 1)
%26 = load i8*, i8** %11
%27 = getelementptr inbounds i8, i8* %26, i64 1
store i8* %27, i8** %11
%28 = load i32, i32* %12
%29 = sext i32 %28 to i64
%30 = add i64 %29, 1
%31 = trunc i64 %30 to i32
store i32 %31, i32* %12
%32 = load i8*, i8** %11
%33 = getelementptr inbounds %struct.ip6_hdr, %struct.ip6_hdr* %4, i32 0, i32 1
%34 = call i32 @memcpy(i8* %32, i8* %33, i32 1)
%35 = load i8*, i8** %11
%36 = getelementptr inbounds i8, i8* %35, i64 1
store i8* %36, i8** %11
%37 = load i32, i32* %12
%38 = sext i32 %37 to i64
%39 = add i64 %38, 1
%40 = trunc i64 %39 to i32
store i32 %40, i32* %12
%41 = call signext i8 @htonl(i32 16)
store i8 %41, i8* %7
%42 = load i8*, i8** %11
%43 = call i32 @memcpy(i8* %42, i8* %7, i32 1)
%44 = load i8*, i8** %11
%45 = getelementptr inbounds i8, i8* %44, i64 1
store i8* %45, i8** %11
%46 = load i32, i32* %12
%47 = sext i32 %46 to i64
%48 = add i64 %47, 1
%49 = trunc i64 %48 to i32
store i32 %49, i32* %12
%50 = load i8*, i8** %11
store i8 0, i8* %50
%51 = load i8*, i8** %11
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %11
%53 = load i8*, i8** %11
store i8 0, i8* %53
%54 = load i8*, i8** %11
%55 = getelementptr inbounds i8, i8* %54, i32 1
store i8* %55, i8** %11
%56 = load i8*, i8** %11
store i8 0, i8* %56
%57 = load i8*, i8** %11
%58 = getelementptr inbounds i8, i8* %57, i32 1
store i8* %58, i8** %11
%59 = load i32, i32* %12
%60 = add nsw i32 %59, 3
store i32 %60, i32* %12
%61 = load i8*, i8** %11
%62 = getelementptr inbounds %struct.ip6_hdr, %struct.ip6_hdr* %4, i32 0, i32 2
%63 = call i32 @memcpy(i8* %61, i8* %62, i32 1)
%64 = load i8*, i8** %11
%65 = getelementptr inbounds i8, i8* %64, i64 1
store i8* %65, i8** %11
%66 = load i32, i32* %12
%67 = sext i32 %66 to i64
%68 = add i64 %67, 1
%69 = trunc i64 %68 to i32
store i32 %69, i32* %12
%70 = load i8*, i8** %11
%71 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %6, i32 0, i32 0
%72 = call i32 @memcpy(i8* %70, i8* %71, i32 1)
%73 = load i8*, i8** %11
%74 = getelementptr inbounds i8, i8* %73, i64 1
store i8* %74, i8** %11
%75 = load i32, i32* %12
%76 = sext i32 %75 to i64
%77 = add i64 %76, 1
%78 = trunc i64 %77 to i32
store i32 %78, i32* %12
%79 = load i8*, i8** %11
%80 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %6, i32 0, i32 1
%81 = call i32 @memcpy(i8* %79, i8* %80, i32 1)
%82 = load i8*, i8** %11
%83 = getelementptr inbounds i8, i8* %82, i64 1
store i8* %83, i8** %11
%84 = load i32, i32* %12
%85 = sext i32 %84 to i64
%86 = add i64 %85, 1
%87 = trunc i64 %86 to i32
store i32 %87, i32* %12
%88 = load i8*, i8** %11
%89 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %6, i32 0, i32 2
%90 = call i32 @memcpy(i8* %88, i8* %89, i32 1)
%91 = load i8*, i8** %11
%92 = getelementptr inbounds i8, i8* %91, i64 1
store i8* %92, i8** %11
%93 = load i32, i32* %12
%94 = sext i32 %93 to i64
%95 = add i64 %94, 1
%96 = trunc i64 %95 to i32
store i32 %96, i32* %12
%97 = load i8*, i8** %11
%98 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %6, i32 0, i32 3
%99 = call i32 @memcpy(i8* %97, i8* %98, i32 1)
%100 = load i8*, i8** %11
%101 = getelementptr inbounds i8, i8* %100, i64 1
store i8* %101, i8** %11
%102 = load i32, i32* %12
%103 = sext i32 %102 to i64
%104 = add i64 %103, 1
%105 = trunc i64 %104 to i32
store i32 %105, i32* %12
%106 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %6, i32 0, i32 4
%107 = load i32, i32* %106
%108 = shl i32 %107, 4
%109 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %6, i32 0, i32 5
%110 = load i32, i32* %109
%111 = add nsw i32 %108, %110
%112 = trunc i32 %111 to i8
store i8 %112, i8* %10
%113 = load i8*, i8** %11
%114 = call i32 @memcpy(i8* %113, i8* %10, i32 1)
%115 = load i8*, i8** %11
%116 = getelementptr inbounds i8, i8* %115, i64 1
store i8* %116, i8** %11
%117 = load i32, i32* %12
%118 = sext i32 %117 to i64
%119 = add i64 %118, 1
%120 = trunc i64 %119 to i32
store i32 %120, i32* %12
%121 = load i8*, i8** %11
%122 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %6, i32 0, i32 6
%123 = call i32 @memcpy(i8* %121, i8* %122, i32 1)
%124 = load i8*, i8** %11
%125 = getelementptr inbounds i8, i8* %124, i64 1
store i8* %125, i8** %11
%126 = load i32, i32* %12
%127 = sext i32 %126 to i64
%128 = add i64 %127, 1
%129 = trunc i64 %128 to i32
store i32 %129, i32* %12
%130 = load i8*, i8** %11
%131 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %6, i32 0, i32 7
%132 = call i32 @memcpy(i8* %130, i8* %131, i32 1)
%133 = load i8*, i8** %11
%134 = getelementptr inbounds i8, i8* %133, i64 1
store i8* %134, i8** %11
%135 = load i32, i32* %12
%136 = sext i32 %135 to i64
%137 = add i64 %136, 1
%138 = trunc i64 %137 to i32
store i32 %138, i32* %12
%139 = load i8*, i8** %11
store i8 0, i8* %139
%140 = load i8*, i8** %11
%141 = getelementptr inbounds i8, i8* %140, i32 1
store i8* %141, i8** %11
%142 = load i8*, i8** %11
store i8 0, i8* %142
%143 = load i8*, i8** %11
%144 = getelementptr inbounds i8, i8* %143, i32 1
store i8* %144, i8** %11
%145 = load i32, i32* %12
%146 = add nsw i32 %145, 2
store i32 %146, i32* %12
%147 = load i8*, i8** %11
%148 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %6, i32 0, i32 8
%149 = call i32 @memcpy(i8* %147, i8* %148, i32 1)
%150 = load i8*, i8** %11
%151 = getelementptr inbounds i8, i8* %150, i64 1
store i8* %151, i8** %11
%152 = load i32, i32* %12
%153 = sext i32 %152 to i64
%154 = add i64 %153, 1
%155 = trunc i64 %154 to i32
store i32 %155, i32* %12
%156 = bitcast i8* %21 to i32*
%157 = load i32, i32* %12
%158 = call i32 @checksum(i32* %156, i32 %157)
%159 = load i8*, i8** %8
ret i32 %158
}

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