#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 */

/* Variables and functions */
void *calloc(int, unsigned long);
int /*<<< orphan*/ setInt(void *, unsigned long, int);
int /*<<< orphan*/ setLong(void *, unsigned long, unsigned long);
void *buildTCP_checksum(unsigned long index, unsigned long checksum) {
  unsigned long size = sizeof(int);
  size += sizeof(long) * 2;
  void *pkg = calloc(1, size);
  unsigned long offset = 0;
  setInt(pkg, offset, 20);
  offset += sizeof(int);
  setLong(pkg, offset, index);
  offset += sizeof(long);
  setLong(pkg, offset, checksum);
  return pkg;
}


x86 assembly (clang, -O0):
<buildTCP_checksum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x4,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
mov    $0x1,%edi
call   1050 <calloc@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x14,%edx
call   1040 <setInt@plt>
mov    -0x28(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1030 <setLong@plt>
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1030 <setLong@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<buildTCP_checksum>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x14,%esi
mov    $0x1,%edi
call   1050 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1040 <setInt@plt>
mov    $0x4,%esi
mov    %rbx,%rdi
mov    %r15,%rdx
call   1030 <setLong@plt>
mov    $0xc,%esi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1030 <setLong@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @buildTCP_checksum(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
store i64 4, i64* %5
%8 = load i64, i64* %5
%9 = add i64 %8, 16
store i64 %9, i64* %5
%10 = load i64, i64* %5
%11 = call i8* @calloc(i32 1, i64 %10)
store i8* %11, i8** %6
store i64 0, i64* %7
%12 = load i8*, i8** %6
%13 = load i64, i64* %7
%14 = call i32 @setInt(i8* %12, i64 %13, i32 20)
%15 = load i64, i64* %7
%16 = add i64 %15, 4
store i64 %16, i64* %7
%17 = load i8*, i8** %6
%18 = load i64, i64* %7
%19 = load i64, i64* %3
%20 = call i32 @setLong(i8* %17, i64 %18, i64 %19)
%21 = load i64, i64* %7
%22 = add i64 %21, 8
store i64 %22, i64* %7
%23 = load i8*, i8** %6
%24 = load i64, i64* %7
%25 = load i64, i64* %4
%26 = call i32 @setLong(i8* %23, i64 %24, i64 %25)
%27 = load i8*, i8** %6
ret i8* %27
}

LLVM IR (-O2):
define i8* @buildTCP_checksum(i64 %0, i64 %1) {
%3 = tail call i8* @calloc(i32 1, i64 20)
%4 = tail call i32 @setInt(i8* %3, i64 0, i32 20)
%5 = tail call i32 @setLong(i8* %3, i64 4, i64 %0)
%6 = tail call i32 @setLong(i8* %3, i64 12, i64 %1)
ret i8* %3
}