#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 */
struct tcphdr {
  int doff;
  int syn;
  scalar_t__ urg_ptr;
  scalar_t__ check;
  void *window;
  scalar_t__ urg;
  scalar_t__ ack;
  scalar_t__ psh;
  scalar_t__ rst;
  scalar_t__ fin;
  void *ack_seq;
  void *seq;
  void *dest;
  void *source;
};

/* Variables and functions */
void *htonl(int);
void *htons(int);
void getMeATCPHeader(struct tcphdr *tcph, int mPort, int tPort) {
  tcph->source = htons(mPort);
  tcph->dest = htons(tPort);
  tcph->seq = htonl(1234 - 1);
  tcph->ack_seq = htonl(0);
  tcph->doff = 5;
  tcph->fin = 0;
  tcph->syn = 1;
  tcph->rst = 0;
  tcph->psh = 0;
  tcph->ack = 0;
  tcph->urg = 0;
  tcph->window = htons(42900);
  tcph->check = 0;
  tcph->urg_ptr = 0;
}


x86 assembly (clang, -O0):
<getMeATCPHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <htons@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x60(%rax)
mov    -0x10(%rbp),%edi
call   1030 <htons@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x58(%rax)
mov    $0x4d1,%edi
call   1040 <htonl@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x50(%rax)
xor    %edi,%edi
call   1040 <htonl@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x48(%rax)
mov    -0x8(%rbp),%rax
movl   $0x5,(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,0x40(%rax)
mov    -0x8(%rbp),%rax
movl   $0x1,0x4(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,0x38(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,0x30(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,0x28(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,0x20(%rax)
mov    $0xa794,%edi
call   1030 <htons@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,0x10(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,0x8(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getMeATCPHeader>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rdi,%rbx
mov    %esi,%edi
call   1030 <htons@plt>
mov    %rax,0x60(%rbx)
mov    %ebp,%edi
call   1030 <htons@plt>
mov    %rax,0x58(%rbx)
mov    $0x4d1,%edi
call   1040 <htonl@plt>
mov    %rax,0x50(%rbx)
xor    %edi,%edi
call   1040 <htonl@plt>
mov    %rax,0x48(%rbx)
movabs $0x100000005,%rax
mov    %rax,(%rbx)
movq   $0x0,0x40(%rbx)
xorps  %xmm0,%xmm0
movups %xmm0,0x20(%rbx)
movups %xmm0,0x30(%rbx)
mov    $0xa794,%edi
call   1030 <htons@plt>
mov    %rax,0x18(%rbx)
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.tcphdr = type { i32, i32, i64, i64, i8*, i64, i64, i64, i64, i64, i8*, i8*, i8*, i8* }
define void @getMeATCPHeader(%struct.tcphdr* %0, i32 %1, i32 %2) {
%4 = alloca %struct.tcphdr*
%5 = alloca i32
%6 = alloca i32
store %struct.tcphdr* %0, %struct.tcphdr** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
%8 = call i8* @htons(i32 %7)
%9 = load %struct.tcphdr*, %struct.tcphdr** %4
%10 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %9, i32 0, i32 13
store i8* %8, i8** %10
%11 = load i32, i32* %6
%12 = call i8* @htons(i32 %11)
%13 = load %struct.tcphdr*, %struct.tcphdr** %4
%14 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %13, i32 0, i32 12
store i8* %12, i8** %14
%15 = call i8* @htonl(i32 1233)
%16 = load %struct.tcphdr*, %struct.tcphdr** %4
%17 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %16, i32 0, i32 11
store i8* %15, i8** %17
%18 = call i8* @htonl(i32 0)
%19 = load %struct.tcphdr*, %struct.tcphdr** %4
%20 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %19, i32 0, i32 10
store i8* %18, i8** %20
%21 = load %struct.tcphdr*, %struct.tcphdr** %4
%22 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %21, i32 0, i32 0
store i32 5, i32* %22
%23 = load %struct.tcphdr*, %struct.tcphdr** %4
%24 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %23, i32 0, i32 9
store i64 0, i64* %24
%25 = load %struct.tcphdr*, %struct.tcphdr** %4
%26 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %25, i32 0, i32 1
store i32 1, i32* %26
%27 = load %struct.tcphdr*, %struct.tcphdr** %4
%28 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %27, i32 0, i32 8
store i64 0, i64* %28
%29 = load %struct.tcphdr*, %struct.tcphdr** %4
%30 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %29, i32 0, i32 7
store i64 0, i64* %30
%31 = load %struct.tcphdr*, %struct.tcphdr** %4
%32 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %31, i32 0, i32 6
store i64 0, i64* %32
%33 = load %struct.tcphdr*, %struct.tcphdr** %4
%34 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %33, i32 0, i32 5
store i64 0, i64* %34
%35 = call i8* @htons(i32 42900)
%36 = load %struct.tcphdr*, %struct.tcphdr** %4
%37 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %36, i32 0, i32 4
store i8* %35, i8** %37
%38 = load %struct.tcphdr*, %struct.tcphdr** %4
%39 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %38, i32 0, i32 3
store i64 0, i64* %39
%40 = load %struct.tcphdr*, %struct.tcphdr** %4
%41 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %40, i32 0, i32 2
store i64 0, i64* %41
ret void
}

LLVM IR (-O2):
%struct.tcphdr = type { i32, i32, i64, i64, i8*, i64, i64, i64, i64, i64, i8*, i8*, i8*, i8* }
define void @getMeATCPHeader(%struct.tcphdr* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = tail call i8* @htons(i32 %1)
%5 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %0, i64 0, i32 13
store i8* %4, i8** %5
%6 = tail call i8* @htons(i32 %2)
%7 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %0, i64 0, i32 12
store i8* %6, i8** %7
%8 = tail call i8* @htonl(i32 1233)
%9 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %0, i64 0, i32 11
store i8* %8, i8** %9
%10 = tail call i8* @htonl(i32 0)
%11 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %0, i64 0, i32 10
store i8* %10, i8** %11
%12 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %0, i64 0, i32 0
store i32 5, i32* %12
%13 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %0, i64 0, i32 9
store i64 0, i64* %13
%14 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %0, i64 0, i32 1
store i32 1, i32* %14
%15 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %0, i64 0, i32 5
%16 = bitcast i64* %15 to i8*
%17 = tail call i8* @htons(i32 42900)
%18 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %0, i64 0, i32 4
store i8* %17, i8** %18
%19 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %0, i64 0, i32 2
%20 = bitcast i64* %19 to i8*
ret void
}