#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 ether_header {
  int /*<<< orphan*/ ether_type;
  int /*<<< orphan*/ *ether_shost;
  int /*<<< orphan*/ *ether_dhost;
};

/* Variables and functions */
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ jlog(int, char *, int /*<<< orphan*/, ...);
void inet_print_ethernet(void *data) {
  struct ether_header *hd;
  hd = data;
  jlog(0x08, "inet]> ether_dhost: %02x:%02x:%02x:%02x:%02x:%02x",
       hd->ether_dhost[0], hd->ether_dhost[1], hd->ether_dhost[2],
       hd->ether_dhost[3], hd->ether_dhost[4], hd->ether_dhost[5]);
  jlog(0x08, "inet]> ether_shost: %02x:%02x:%02x:%02x:%02x:%02x",
       hd->ether_shost[0], hd->ether_shost[1], hd->ether_shost[2],
       hd->ether_shost[3], hd->ether_shost[4], hd->ether_shost[5]);
  jlog(0x08, "inet]> ether_type: %x", htons(hd->ether_type));
}


x86 assembly (clang, -O0):
<inet_print_ethernet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    0x4(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    0x8(%rax),%r8d
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    0xc(%rax),%r9d
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    0x10(%rax),%r10d
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    0x14(%rax),%eax
mov    $0x8,%edi
lea    0xe7c(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1040 <jlog@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x4(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x8(%rax),%r8d
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0xc(%rax),%r9d
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x10(%rax),%r10d
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x14(%rax),%eax
mov    $0x8,%edi
lea    0xe4f(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1040 <jlog@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1030 <htons@plt>
mov    %eax,%edx
mov    $0x8,%edi
lea    0xe59(%rip),%rsi
mov    $0x0,%al
call   1040 <jlog@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_print_ethernet>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x10(%rdi),%rax
mov    (%rax),%edx
mov    0x4(%rax),%ecx
mov    0x8(%rax),%r8d
mov    0xc(%rax),%r9d
mov    0x10(%rax),%r10d
mov    0x14(%rax),%r11d
lea    0xeb9(%rip),%rsi
mov    $0x8,%edi
xor    %eax,%eax
push   %r11
push   %r10
call   1040 <jlog@plt>
add    $0x10,%rsp
mov    0x8(%r14),%rax
mov    (%rax),%edx
mov    0x4(%rax),%ecx
mov    0x8(%rax),%r8d
mov    0xc(%rax),%r9d
mov    0x10(%rax),%r10d
mov    0x14(%rax),%ebx
lea    0xeb8(%rip),%rsi
mov    $0x8,%edi
xor    %eax,%eax
push   %rbx
push   %r10
call   1040 <jlog@plt>
add    $0x10,%rsp
mov    (%r14),%edi
call   1030 <htons@plt>
lea    0xec8(%rip),%rsi
mov    $0x8,%edi
mov    %eax,%edx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <jlog@plt>

LLVM IR (-O0):
%struct.ether_header = type { i32, i32*, i32* }
@.str = [50 x i8] c"inet]> ether_dhost: %02x:%02x:%02x:%02x:%02x:%02x\00"
@.str.1 = [50 x i8] c"inet]> ether_shost: %02x:%02x:%02x:%02x:%02x:%02x\00"
@.str.2 = [22 x i8] c"inet]> ether_type: %x\00"
define void @inet_print_ethernet(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.ether_header*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = bitcast i8* %4 to %struct.ether_header*
store %struct.ether_header* %5, %struct.ether_header** %3
%6 = load %struct.ether_header*, %struct.ether_header** %3
%7 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %6, i32 0, i32 2
%8 = load i32*, i32** %7
%9 = getelementptr inbounds i32, i32* %8, i64 0
%10 = load i32, i32* %9
%11 = load %struct.ether_header*, %struct.ether_header** %3
%12 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %11, i32 0, i32 2
%13 = load i32*, i32** %12
%14 = getelementptr inbounds i32, i32* %13, i64 1
%15 = load i32, i32* %14
%16 = load %struct.ether_header*, %struct.ether_header** %3
%17 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %16, i32 0, i32 2
%18 = load i32*, i32** %17
%19 = getelementptr inbounds i32, i32* %18, i64 2
%20 = load i32, i32* %19
%21 = load %struct.ether_header*, %struct.ether_header** %3
%22 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %21, i32 0, i32 2
%23 = load i32*, i32** %22
%24 = getelementptr inbounds i32, i32* %23, i64 3
%25 = load i32, i32* %24
%26 = load %struct.ether_header*, %struct.ether_header** %3
%27 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %26, i32 0, i32 2
%28 = load i32*, i32** %27
%29 = getelementptr inbounds i32, i32* %28, i64 4
%30 = load i32, i32* %29
%31 = load %struct.ether_header*, %struct.ether_header** %3
%32 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %31, i32 0, i32 2
%33 = load i32*, i32** %32
%34 = getelementptr inbounds i32, i32* %33, i64 5
%35 = load i32, i32* %34
%36 = call i32 (i32, i8*, i32, ...) @jlog(i32 8, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %15, i32 %20, i32 %25, i32 %30, i32 %35)
%37 = load %struct.ether_header*, %struct.ether_header** %3
%38 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %37, i32 0, i32 1
%39 = load i32*, i32** %38
%40 = getelementptr inbounds i32, i32* %39, i64 0
%41 = load i32, i32* %40
%42 = load %struct.ether_header*, %struct.ether_header** %3
%43 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %42, i32 0, i32 1
%44 = load i32*, i32** %43
%45 = getelementptr inbounds i32, i32* %44, i64 1
%46 = load i32, i32* %45
%47 = load %struct.ether_header*, %struct.ether_header** %3
%48 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %47, i32 0, i32 1
%49 = load i32*, i32** %48
%50 = getelementptr inbounds i32, i32* %49, i64 2
%51 = load i32, i32* %50
%52 = load %struct.ether_header*, %struct.ether_header** %3
%53 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %52, i32 0, i32 1
%54 = load i32*, i32** %53
%55 = getelementptr inbounds i32, i32* %54, i64 3
%56 = load i32, i32* %55
%57 = load %struct.ether_header*, %struct.ether_header** %3
%58 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %57, i32 0, i32 1
%59 = load i32*, i32** %58
%60 = getelementptr inbounds i32, i32* %59, i64 4
%61 = load i32, i32* %60
%62 = load %struct.ether_header*, %struct.ether_header** %3
%63 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %62, i32 0, i32 1
%64 = load i32*, i32** %63
%65 = getelementptr inbounds i32, i32* %64, i64 5
%66 = load i32, i32* %65
%67 = call i32 (i32, i8*, i32, ...) @jlog(i32 8, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %41, i32 %46, i32 %51, i32 %56, i32 %61, i32 %66)
%68 = load %struct.ether_header*, %struct.ether_header** %3
%69 = getelementptr inbounds %struct.ether_header, %struct.ether_header* %68, i32 0, i32 0
%70 = load i32, i32* %69
%71 = call i32 @htons(i32 %70)
%72 = call i32 (i32, i8*, i32, ...) @jlog(i32 8, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %71)
ret void
}

LLVM IR (-O2):
@.str = [50 x i8] c"inet]> ether_dhost: %02x:%02x:%02x:%02x:%02x:%02x\00"
@.str.1 = [50 x i8] c"inet]> ether_shost: %02x:%02x:%02x:%02x:%02x:%02x\00"
@.str.2 = [22 x i8] c"inet]> ether_type: %x\00"
define void @inet_print_ethernet(i8* nocapture %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 16
%3 = bitcast i8* %2 to i32**
%4 = load i32*, i32** %3
%5 = load i32, i32* %4
%6 = getelementptr inbounds i32, i32* %4, i64 1
%7 = load i32, i32* %6
%8 = getelementptr inbounds i32, i32* %4, i64 2
%9 = load i32, i32* %8
%10 = getelementptr inbounds i32, i32* %4, i64 3
%11 = load i32, i32* %10
%12 = getelementptr inbounds i32, i32* %4, i64 4
%13 = load i32, i32* %12
%14 = getelementptr inbounds i32, i32* %4, i64 5
%15 = load i32, i32* %14
%16 = tail call i32 (i32, i8*, i32, ...) @jlog(i32 8, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %7, i32 %9, i32 %11, i32 %13, i32 %15)
%17 = getelementptr inbounds i8, i8* %0, i64 8
%18 = bitcast i8* %17 to i32**
%19 = load i32*, i32** %18
%20 = load i32, i32* %19
%21 = getelementptr inbounds i32, i32* %19, i64 1
%22 = load i32, i32* %21
%23 = getelementptr inbounds i32, i32* %19, i64 2
%24 = load i32, i32* %23
%25 = getelementptr inbounds i32, i32* %19, i64 3
%26 = load i32, i32* %25
%27 = getelementptr inbounds i32, i32* %19, i64 4
%28 = load i32, i32* %27
%29 = getelementptr inbounds i32, i32* %19, i64 5
%30 = load i32, i32* %29
%31 = tail call i32 (i32, i8*, i32, ...) @jlog(i32 8, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %22, i32 %24, i32 %26, i32 %28, i32 %30)
%32 = bitcast i8* %0 to i32*
%33 = load i32, i32* %32
%34 = tail call i32 @htons(i32 %33)
%35 = tail call i32 (i32, i8*, i32, ...) @jlog(i32 8, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %34)
ret void
}