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

/* Variables and functions */
int /*<<< orphan*/ LOG_DEBUG;
int /*<<< orphan*/ inet_ntoa(struct in_addr);
int /*<<< orphan*/ ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, ...);
void debug_ipv4(struct iphdr *ip) {
  syslog(LOG_DEBUG, "STARTING IPV4 LOG");
  syslog(LOG_DEBUG, "IP Version: %d", ip->version);
  syslog(LOG_DEBUG, "IP Header Length: %d", ip->ihl);
  syslog(LOG_DEBUG, "IP ID: %d", ip->id);
  syslog(LOG_DEBUG, "IP Total Length: %d", ntohs(ip->tot_len));
  syslog(LOG_DEBUG, "IP Protocol: %d", ip->protocol);
  syslog(LOG_DEBUG, "IP TTL: %d", ip->ttl);
  syslog(LOG_DEBUG, "IP SrcAddr: %s", inet_ntoa(*(struct in_addr *)&ip->saddr));
  syslog(LOG_DEBUG, "IP DstAddr: %s", inet_ntoa(*(struct in_addr *)&ip->daddr));
  syslog(LOG_DEBUG, "IP CheckSum: %dd", ip->check);
  syslog(LOG_DEBUG, "END OF IPV4 LOG");
}


x86 assembly (clang, -O0):
<debug_ipv4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%edi
lea    0xeb4(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x20(%rax),%edx
lea    0xea8(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x1c(%rax),%edx
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%edx
lea    0xe90(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%edi
call   1050 <ntohs@plt>
mov    -0x14(%rbp),%edi
mov    %eax,%edx
lea    0xe6f(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%edx
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%edx
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2dc5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
call   1030 <inet_ntoa@plt>
mov    -0x10(%rbp),%edi
mov    %eax,%edx
lea    0xe37(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2d9a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
call   1030 <inet_ntoa@plt>
mov    -0xc(%rbp),%edi
mov    %eax,%edx
lea    0xe1b(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
lea    0xe07(%rip),%rsi
mov    $0x0,%al
call   1040 <syslog@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<debug_ipv4>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    0x2ea2(%rip),%r14
mov    (%r14),%edi
lea    0xeb8(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
mov    (%r14),%edi
mov    0x20(%rbx),%edx
lea    0xeb6(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
mov    (%r14),%edi
mov    0x1c(%rbx),%edx
lea    0xeb1(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
mov    (%r14),%edi
mov    0x18(%rbx),%edx
lea    0xeb2(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
mov    (%r14),%ebp
mov    0x14(%rbx),%edi
call   1050 <ntohs@plt>
lea    0xea3(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <syslog@plt>
mov    (%r14),%edi
mov    0x10(%rbx),%edx
lea    0xe9f(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
mov    (%r14),%edi
mov    0xc(%rbx),%edx
lea    0xe9b(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
mov    (%r14),%ebp
mov    0x8(%rbx),%edi
call   1030 <inet_ntoa@plt>
lea    0xe8d(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <syslog@plt>
mov    (%r14),%ebp
mov    0x4(%rbx),%edi
call   1030 <inet_ntoa@plt>
lea    0xe7f(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <syslog@plt>
mov    (%r14),%edi
mov    (%rbx),%edx
lea    0xe77(%rip),%rsi
xor    %eax,%eax
call   1040 <syslog@plt>
mov    (%r14),%edi
lea    0xe77(%rip),%rsi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <syslog@plt>

LLVM IR (-O0):
%struct.iphdr = type { i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%struct.in_addr = type { i32 }
@LOG_DEBUG = global i32 0
@.str = [18 x i8] c"STARTING IPV4 LOG\00"
@.str.1 = [15 x i8] c"IP Version: %d\00"
@.str.2 = [21 x i8] c"IP Header Length: %d\00"
@.str.3 = [10 x i8] c"IP ID: %d\00"
@.str.4 = [20 x i8] c"IP Total Length: %d\00"
@.str.5 = [16 x i8] c"IP Protocol: %d\00"
@.str.6 = [11 x i8] c"IP TTL: %d\00"
@.str.7 = [15 x i8] c"IP SrcAddr: %s\00"
@.str.8 = [15 x i8] c"IP DstAddr: %s\00"
@.str.9 = [17 x i8] c"IP CheckSum: %dd\00"
@.str.10 = [16 x i8] c"END OF IPV4 LOG\00"
define void @debug_ipv4(%struct.iphdr* %0) {
%2 = alloca %struct.iphdr*
store %struct.iphdr* %0, %struct.iphdr** %2
%3 = load i32, i32* @LOG_DEBUG
%4 = call i32 (i32, i8*, ...) @syslog(i32 %3, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @LOG_DEBUG
%6 = load %struct.iphdr*, %struct.iphdr** %2
%7 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %6, i32 0, i32 8
%8 = load i32, i32* %7
%9 = call i32 (i32, i8*, ...) @syslog(i32 %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = load i32, i32* @LOG_DEBUG
%11 = load %struct.iphdr*, %struct.iphdr** %2
%12 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %11, i32 0, i32 7
%13 = load i32, i32* %12
%14 = call i32 (i32, i8*, ...) @syslog(i32 %10, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = load i32, i32* @LOG_DEBUG
%16 = load %struct.iphdr*, %struct.iphdr** %2
%17 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %16, i32 0, i32 6
%18 = load i32, i32* %17
%19 = call i32 (i32, i8*, ...) @syslog(i32 %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = load i32, i32* @LOG_DEBUG
%21 = load %struct.iphdr*, %struct.iphdr** %2
%22 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %21, i32 0, i32 5
%23 = load i32, i32* %22
%24 = call i32 @ntohs(i32 %23)
%25 = call i32 (i32, i8*, ...) @syslog(i32 %20, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %24)
%26 = load i32, i32* @LOG_DEBUG
%27 = load %struct.iphdr*, %struct.iphdr** %2
%28 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %27, i32 0, i32 4
%29 = load i32, i32* %28
%30 = call i32 (i32, i8*, ...) @syslog(i32 %26, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %29)
%31 = load i32, i32* @LOG_DEBUG
%32 = load %struct.iphdr*, %struct.iphdr** %2
%33 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %32, i32 0, i32 3
%34 = load i32, i32* %33
%35 = call i32 (i32, i8*, ...) @syslog(i32 %31, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %34)
%36 = load i32, i32* @LOG_DEBUG
%37 = load %struct.iphdr*, %struct.iphdr** %2
%38 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %37, i32 0, i32 2
%39 = bitcast i32* %38 to %struct.in_addr*
%40 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %39, i32 0, i32 0
%41 = load i32, i32* %40
%42 = call i32 @inet_ntoa(i32 %41)
%43 = call i32 (i32, i8*, ...) @syslog(i32 %36, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %42)
%44 = load i32, i32* @LOG_DEBUG
%45 = load %struct.iphdr*, %struct.iphdr** %2
%46 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %45, i32 0, i32 1
%47 = bitcast i32* %46 to %struct.in_addr*
%48 = getelementptr inbounds %struct.in_addr, %struct.in_addr* %47, i32 0, i32 0
%49 = load i32, i32* %48
%50 = call i32 @inet_ntoa(i32 %49)
%51 = call i32 (i32, i8*, ...) @syslog(i32 %44, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i32 %50)
%52 = load i32, i32* @LOG_DEBUG
%53 = load %struct.iphdr*, %struct.iphdr** %2
%54 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %53, i32 0, i32 0
%55 = load i32, i32* %54
%56 = call i32 (i32, i8*, ...) @syslog(i32 %52, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %55)
%57 = load i32, i32* @LOG_DEBUG
%58 = call i32 (i32, i8*, ...) @syslog(i32 %57, i8* getelementptr inbounds ([16 x i8], [16 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 }
@LOG_DEBUG = global i32 0
@.str = [18 x i8] c"STARTING IPV4 LOG\00"
@.str.1 = [15 x i8] c"IP Version: %d\00"
@.str.2 = [21 x i8] c"IP Header Length: %d\00"
@.str.3 = [10 x i8] c"IP ID: %d\00"
@.str.4 = [20 x i8] c"IP Total Length: %d\00"
@.str.5 = [16 x i8] c"IP Protocol: %d\00"
@.str.6 = [11 x i8] c"IP TTL: %d\00"
@.str.7 = [15 x i8] c"IP SrcAddr: %s\00"
@.str.8 = [15 x i8] c"IP DstAddr: %s\00"
@.str.9 = [17 x i8] c"IP CheckSum: %dd\00"
@.str.10 = [16 x i8] c"END OF IPV4 LOG\00"
define void @debug_ipv4(%struct.iphdr* nocapture %0) {
%2 = load i32, i32* @LOG_DEBUG
%3 = tail call i32 (i32, i8*, ...) @syslog(i32 %2, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @LOG_DEBUG
%5 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 8
%6 = load i32, i32* %5
%7 = tail call i32 (i32, i8*, ...) @syslog(i32 %4, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = load i32, i32* @LOG_DEBUG
%9 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 7
%10 = load i32, i32* %9
%11 = tail call i32 (i32, i8*, ...) @syslog(i32 %8, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = load i32, i32* @LOG_DEBUG
%13 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 6
%14 = load i32, i32* %13
%15 = tail call i32 (i32, i8*, ...) @syslog(i32 %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = load i32, i32* @LOG_DEBUG
%17 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 5
%18 = load i32, i32* %17
%19 = tail call i32 @ntohs(i32 %18)
%20 = tail call i32 (i32, i8*, ...) @syslog(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %19)
%21 = load i32, i32* @LOG_DEBUG
%22 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 4
%23 = load i32, i32* %22
%24 = tail call i32 (i32, i8*, ...) @syslog(i32 %21, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0), i32 %23)
%25 = load i32, i32* @LOG_DEBUG
%26 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 3
%27 = load i32, i32* %26
%28 = tail call i32 (i32, i8*, ...) @syslog(i32 %25, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i32 %27)
%29 = load i32, i32* @LOG_DEBUG
%30 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 2
%31 = load i32, i32* %30
%32 = tail call i32 @inet_ntoa(i32 %31)
%33 = tail call i32 (i32, i8*, ...) @syslog(i32 %29, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i32 %32)
%34 = load i32, i32* @LOG_DEBUG
%35 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 1
%36 = load i32, i32* %35
%37 = tail call i32 @inet_ntoa(i32 %36)
%38 = tail call i32 (i32, i8*, ...) @syslog(i32 %34, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i32 %37)
%39 = load i32, i32* @LOG_DEBUG
%40 = getelementptr inbounds %struct.iphdr, %struct.iphdr* %0, i64 0, i32 0
%41 = load i32, i32* %40
%42 = tail call i32 (i32, i8*, ...) @syslog(i32 %39, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %41)
%43 = load i32, i32* @LOG_DEBUG
%44 = tail call i32 (i32, i8*, ...) @syslog(i32 %43, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0))
ret void
}