#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 dummy;
};
struct iphdr {
  int ihl;
  int version;
  int tot_len;
  int ttl;
  int protocol;
  scalar_t__ check;
  scalar_t__ frag_off;
  int /*<<< orphan*/ id;
  scalar_t__ tos;
};

/* Variables and functions */
int /*<<< orphan*/ htonl(int);
void setupIpHeader(struct iphdr *ipH) {
  ipH->ihl = 5;
  ipH->version = 4;
  ipH->tos = 0;
  ipH->tot_len = sizeof(struct iphdr) + sizeof(struct tcphdr);
  ipH->id = htonl(54321);
  ipH->frag_off = 0;
  ipH->ttl = 255;
  ipH->protocol = 6;
  ipH->check = 0;
}


x86 assembly (clang, -O0):
<setupIpHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movl   $0x5,(%rax)
mov    -0x8(%rbp),%rax
movl   $0x4,0x4(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,0x30(%rax)
mov    -0x8(%rbp),%rax
movl   $0x3c,0x8(%rax)
mov    $0xd431,%edi
call   1030 <htonl@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x28(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,0x20(%rax)
mov    -0x8(%rbp),%rax
movl   $0xff,0xc(%rax)
mov    -0x8(%rbp),%rax
movl   $0x6,0x10(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,0x18(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setupIpHeader>:
push   %rbx
mov    %rdi,%rbx
movq   $0x0,0x30(%rdi)
mov    $0xd431,%edi
call   1030 <htonl@plt>
mov    %eax,0x28(%rbx)
movaps 0xed0(%rip),%xmm0
movups %xmm0,(%rbx)
movl   $0x6,0x10(%rbx)
xorps  %xmm0,%xmm0
movups %xmm0,0x18(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
%struct.iphdr = type { i32, i32, i32, i32, i32, i64, i64, i32, i64 }
define void @setupIpHeader(%struct.iphdr* %0) {
%2 = alloca %struct.iphdr*
store %struct.iphdr* %0, %struct.iphdr** %2
%3 = load %struct.iphdr*, %struct.iphdr** %2
%4 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %3, i32 0, i32 0
store i32 5, i32* %4
%5 = load %struct.iphdr*, %struct.iphdr** %2
%6 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %5, i32 0, i32 1
store i32 4, i32* %6
%7 = load %struct.iphdr*, %struct.iphdr** %2
%8 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %7, i32 0, i32 8
store i64 0, i64* %8
%9 = load %struct.iphdr*, %struct.iphdr** %2
%10 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %9, i32 0, i32 2
store i32 60, i32* %10
%11 = call i32 @htonl(i32 54321)
%12 = load %struct.iphdr*, %struct.iphdr** %2
%13 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %12, i32 0, i32 7
store i32 %11, i32* %13
%14 = load %struct.iphdr*, %struct.iphdr** %2
%15 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %14, i32 0, i32 6
store i64 0, i64* %15
%16 = load %struct.iphdr*, %struct.iphdr** %2
%17 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %16, i32 0, i32 3
store i32 255, i32* %17
%18 = load %struct.iphdr*, %struct.iphdr** %2
%19 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %18, i32 0, i32 4
store i32 6, i32* %19
%20 = load %struct.iphdr*, %struct.iphdr** %2
%21 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %20, i32 0, i32 5
store i64 0, i64* %21
ret void
}

LLVM IR (-O2):
%struct.iphdr = type { i32, i32, i32, i32, i32, i64, i64, i32, i64 }
define void @setupIpHeader(%struct.iphdr* nocapture writeonly %0) {
%2 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 8
store i64 0, i64* %2
%3 = tail call i32 @htonl(i32 54321)
%4 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 7
store i32 %3, i32* %4
%5 = bitcast %struct.iphdr* %0 to <4 x i32>*
store <4 x i32> <i32 5, i32 4, i32 60, i32 255>, <4 x i32>* %5
%6 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 4
store i32 6, i32* %6
%7 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 5
%8 = bitcast i64* %7 to <2 x i64>*
store <2 x i64> zeroinitializer, <2 x i64>* %8
ret void
}