#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;
  int /*<<< orphan*/ window;
  scalar_t__ res2;
  scalar_t__ ack_seq;
  int /*<<< orphan*/ seq;
  int /*<<< orphan*/ source;
};

/* Variables and functions */
int /*<<< orphan*/ htonl(int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ random();
void setupTcpHeader(struct tcphdr *tcpH) {
  tcpH->source = htons(1337);
  tcpH->seq = random();
  tcpH->ack_seq = 0;
  tcpH->res2 = 0;
  tcpH->doff = 5;
  tcpH->syn = 1;
  tcpH->window = htonl(65535);
  tcpH->check = 0;
  tcpH->urg_ptr = 0;
}


x86 assembly (clang, -O0):
<setupTcpHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x539,%edi
call   1030 <htons@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x34(%rax)
mov    $0x0,%al
call   1050 <random@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x30(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,0x28(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,0x20(%rax)
mov    -0x8(%rbp),%rax
movl   $0x5,(%rax)
mov    -0x8(%rbp),%rax
movl   $0x1,0x4(%rax)
mov    $0xffff,%edi
call   1040 <htonl@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,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):
<setupTcpHeader>:
push   %rbx
mov    %rdi,%rbx
mov    $0x539,%edi
call   1030 <htons@plt>
mov    %eax,0x34(%rbx)
xor    %eax,%eax
call   1050 <random@plt>
mov    %eax,0x30(%rbx)
xorps  %xmm0,%xmm0
movups %xmm0,0x20(%rbx)
movabs $0x100000005,%rax
mov    %rax,(%rbx)
mov    $0xffff,%edi
call   1040 <htonl@plt>
mov    %eax,0x18(%rbx)
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
%struct.tcphdr = type { i32, i32, i64, i64, i32, i64, i64, i32, i32 }
define void @setupTcpHeader(%struct.tcphdr* %0) {
%2 = alloca %struct.tcphdr*
store %struct.tcphdr* %0, %struct.tcphdr** %2
%3 = call i32 @htons(i32 1337)
%4 = load %struct.tcphdr*, %struct.tcphdr** %2
%5 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %4, i32 0, i32 8
store i32 %3, i32* %5
%6 = call i32 (...) @random()
%7 = load %struct.tcphdr*, %struct.tcphdr** %2
%8 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %7, i32 0, i32 7
store i32 %6, i32* %8
%9 = load %struct.tcphdr*, %struct.tcphdr** %2
%10 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %9, i32 0, i32 6
store i64 0, i64* %10
%11 = load %struct.tcphdr*, %struct.tcphdr** %2
%12 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %11, i32 0, i32 5
store i64 0, i64* %12
%13 = load %struct.tcphdr*, %struct.tcphdr** %2
%14 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %13, i32 0, i32 0
store i32 5, i32* %14
%15 = load %struct.tcphdr*, %struct.tcphdr** %2
%16 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %15, i32 0, i32 1
store i32 1, i32* %16
%17 = call i32 @htonl(i32 65535)
%18 = load %struct.tcphdr*, %struct.tcphdr** %2
%19 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %18, i32 0, i32 4
store i32 %17, i32* %19
%20 = load %struct.tcphdr*, %struct.tcphdr** %2
%21 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %20, i32 0, i32 3
store i64 0, i64* %21
%22 = load %struct.tcphdr*, %struct.tcphdr** %2
%23 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %22, i32 0, i32 2
store i64 0, i64* %23
ret void
}

LLVM IR (-O2):
%struct.tcphdr = type { i32, i32, i64, i64, i32, i64, i64, i32, i32 }
define void @setupTcpHeader(%struct.tcphdr* nocapture writeonly %0) {
%2 = tail call i32 @htons(i32 1337)
%3 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %0, i64 0, i32 8
store i32 %2, i32* %3
%4 = tail call i32 (...) @random()
%5 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %0, i64 0, i32 7
store i32 %4, i32* %5
%6 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %0, i64 0, i32 5
%7 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %0, i64 0, i32 0
%8 = bitcast i64* %6 to i8*
store i32 5, i32* %7
%9 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %0, i64 0, i32 1
store i32 1, i32* %9
%10 = tail call i32 @htonl(i32 65535)
%11 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %0, i64 0, i32 4
store i32 %10, i32* %11
%12 = getelementptr inbounds %struct.tcphdr, %struct.tcphdr* %0, i64 0, i32 2
%13 = bitcast i64* %12 to i8*
ret void
}