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

/* Variables and functions */
int htons(int /*<<< orphan*/);
char *inet_ntoa(struct in_addr);
int /*<<< orphan*/ printf(char *, ...);
void printIPHeader(struct iphdr *iph) {
  printf("\n\n/**********IPHEADER**********/\n");
  printf("iphdr.ihl = %d\n", iph->ihl);
  printf("iphdr.version = %d\n", iph->version);
  printf("iphdr.tos = %d\n", iph->tos);
  printf("iphdr.tot_len = %d\n", htons(iph->tot_len));
  printf("iphdr.frag_off = %d\n", iph->frag_off);
  printf("iphdr.ttl = %d\n", iph->ttl);
  printf("iphdr.protocol = %d\n", iph->protocol);
  printf("Source IP Address: %s\n", inet_ntoa(*(struct in_addr *)&iph->saddr));
  printf("Destination IP Address: %s\n",
         inet_ntoa(*(struct in_addr *)&iph->daddr));
  printf("/***************************/\n\n");
}


x86 assembly (clang, -O0):
<printIPHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x20(%rax),%edi
call   1040 <htons@plt>
mov    %eax,%esi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%esi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%esi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%esi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x1c(%rax),%edi
call   1030 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%edi
call   1030 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printIPHeader>:
push   %rbx
mov    %rdi,%rbx
lea    0xf6a(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%esi
lea    0xea7(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rbx),%esi
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rbx),%esi
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x20(%rbx),%edi
call   1050 <htons@plt>
lea    0xea3(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rbx),%esi
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rbx),%esi
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x14(%rbx),%esi
lea    0xea7(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x1c(%rbx),%edi
call   1040 <inet_ntoa@plt>
lea    0xea6(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rbx),%edi
call   1040 <inet_ntoa@plt>
lea    0xea4(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xed0(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
%struct.iphdr = type { i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.in_addr = type { i32 }
@.str = [34 x i8] c"\0A\0A/**********IPHEADER**********/\0A\00"
@.str.1 = [16 x i8] c"iphdr.ihl = %d\0A\00"
@.str.2 = [20 x i8] c"iphdr.version = %d\0A\00"
@.str.3 = [16 x i8] c"iphdr.tos = %d\0A\00"
@.str.4 = [20 x i8] c"iphdr.tot_len = %d\0A\00"
@.str.5 = [21 x i8] c"iphdr.frag_off = %d\0A\00"
@.str.6 = [16 x i8] c"iphdr.ttl = %d\0A\00"
@.str.7 = [21 x i8] c"iphdr.protocol = %d\0A\00"
@.str.8 = [23 x i8] c"Source IP Address: %s\0A\00"
@.str.9 = [28 x i8] c"Destination IP Address: %s\0A\00"
@.str.10 = [32 x i8] c"/***************************/\0A\0A\00"
define void @printIPHeader(%struct.iphdr* %0) {
%2 = alloca %struct.iphdr*
store %struct.iphdr* %0, %struct.iphdr** %2
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%4 = load %struct.iphdr*, %struct.iphdr** %2
%5 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %4, i32 0, i32 0
%6 = load i32, i32* %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = load %struct.iphdr*, %struct.iphdr** %2
%9 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %8, i32 0, i32 1
%10 = load i32, i32* %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = load %struct.iphdr*, %struct.iphdr** %2
%13 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %12, i32 0, i32 2
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = load %struct.iphdr*, %struct.iphdr** %2
%17 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %16, i32 0, i32 8
%18 = load i32, i32* %17
%19 = call i32 @htons(i32 %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = load %struct.iphdr*, %struct.iphdr** %2
%22 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %21, i32 0, i32 3
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%25 = load %struct.iphdr*, %struct.iphdr** %2
%26 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %25, i32 0, i32 4
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %27)
%29 = load %struct.iphdr*, %struct.iphdr** %2
%30 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %29, i32 0, i32 5
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %31)
%33 = load %struct.iphdr*, %struct.iphdr** %2
%34 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %33, i32 0, i32 7
%35 = bitcast i32* %34 to %struct.in_addr*
%36 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %35, i32 0, i32 0
%37 = load i32, i32* %36
%38 = call i8* @inet_ntoa(i32 %37)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %38)
%40 = load %struct.iphdr*, %struct.iphdr** %2
%41 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %40, i32 0, i32 6
%42 = bitcast i32* %41 to %struct.in_addr*
%43 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %42, i32 0, i32 0
%44 = load i32, i32* %43
%45 = call i8* @inet_ntoa(i32 %44)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), i8* %45)
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.iphdr = type { i32, i32, i32, i32, i32, i32, i32, i32, i32 }
@.str.1 = [16 x i8] c"iphdr.ihl = %d\0A\00"
@.str.2 = [20 x i8] c"iphdr.version = %d\0A\00"
@.str.3 = [16 x i8] c"iphdr.tos = %d\0A\00"
@.str.4 = [20 x i8] c"iphdr.tot_len = %d\0A\00"
@.str.5 = [21 x i8] c"iphdr.frag_off = %d\0A\00"
@.str.6 = [16 x i8] c"iphdr.ttl = %d\0A\00"
@.str.7 = [21 x i8] c"iphdr.protocol = %d\0A\00"
@.str.8 = [23 x i8] c"Source IP Address: %s\0A\00"
@.str.9 = [28 x i8] c"Destination IP Address: %s\0A\00"
@str = [33 x i8] c"\0A\0A/**********IPHEADER**********/\00"
@str.11 = [31 x i8] c"/***************************/\0A\00"
define void @printIPHeader(%struct.iphdr* nocapture %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%3 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 0
%4 = load i32, i32* %3
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 1
%7 = load i32, i32* %6
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 2
%10 = load i32, i32* %9
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 8
%13 = load i32, i32* %12
%14 = tail call i32 @htons(i32 %13)
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 3
%17 = load i32, i32* %16
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 4
%20 = load i32, i32* %19
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 5
%23 = load i32, i32* %22
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 7
%26 = load i32, i32* %25
%27 = tail call i8* @inet_ntoa(i32 %26)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 6
%30 = load i32, i32* %29
%31 = tail call i8* @inet_ntoa(i32 %30)
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0), i8* %31)
%33 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.11, i64 0, i64 0))
ret void
}