#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 sockaddr_ll {
  int sll_family;
  int sll_ifindex;
  int sll_hatype;
  int sll_pkttype;
  int sll_halen;
  int /*<<< orphan*/ sll_addr;
  int /*<<< orphan*/ sll_protocol;
};

/* Variables and functions */
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ println_hex(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                               char);
void println_sockaddr_ll(char *leader, struct sockaddr_ll *addr) {
  if (leader != NULL) {
    printf(leader);
  }
  printf("family=%0d protocol=0x%0x ifindex=%d hatype=%d pkttype=%d halen=%d "
         "addr=",
         addr->sll_family, ntohs(addr->sll_protocol), addr->sll_ifindex,
         addr->sll_hatype, addr->sll_pkttype, addr->sll_halen);
  println_hex(NULL, addr->sll_addr, addr->sll_halen, ':');
}


x86 assembly (clang, -O0):
<println_sockaddr_ll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1156 <println_sockaddr_ll+0x26>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%edi
call   1050 <ntohs@plt>
mov    -0x14(%rbp),%esi
mov    %eax,%edx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8d
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%r9d
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%eax
lea    0xe6b(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%esi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%edx
xor    %eax,%eax
mov    %eax,%edi
mov    $0x3a,%ecx
call   1040 <println_hex@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<println_sockaddr_ll>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
test   %rdi,%rdi
je     1142 <println_sockaddr_ll+0x12>
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rbx),%ebp
mov    0x18(%rbx),%edi
call   1050 <ntohs@plt>
mov    0x4(%rbx),%ecx
mov    0x8(%rbx),%r8d
mov    0xc(%rbx),%r9d
mov    0x10(%rbx),%edx
mov    %edx,(%rsp)
lea    0xe9c(%rip),%rdi
mov    %ebp,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x10(%rbx),%edx
mov    0x14(%rbx),%esi
xor    %edi,%edi
mov    $0x3a,%ecx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <println_hex@plt>

LLVM IR (-O0):
%struct.sockaddr_ll = type { i32, i32, i32, i32, i32, i32, i32 }
@.str = [73 x i8] c"family=%0d protocol=0x%0x ifindex=%d hatype=%d pkttype=%d halen=%d addr=\00"
define void @println_sockaddr_ll(i8* %0, %struct.sockaddr_ll* %1) {
%3 = alloca i8*
%4 = alloca %struct.sockaddr_ll*
store i8* %0, i8** %3
store %struct.sockaddr_ll* %1, %struct.sockaddr_ll** %4
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i8*, i8** %3
%9 = call i32 (i8*, ...) @printf(i8* %8)
br label %10
10: ; preds = %7, %2
%11 = load %struct.sockaddr_ll*, %struct.sockaddr_ll** %4
%12 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = load %struct.sockaddr_ll*, %struct.sockaddr_ll** %4
%15 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %14, i32 0, i32 6
%16 = load i32, i32* %15
%17 = call i32 @ntohs(i32 %16)
%18 = load %struct.sockaddr_ll*, %struct.sockaddr_ll** %4
%19 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %18, i32 0, i32 1
%20 = load i32, i32* %19
%21 = load %struct.sockaddr_ll*, %struct.sockaddr_ll** %4
%22 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %21, i32 0, i32 2
%23 = load i32, i32* %22
%24 = load %struct.sockaddr_ll*, %struct.sockaddr_ll** %4
%25 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %24, i32 0, i32 3
%26 = load i32, i32* %25
%27 = load %struct.sockaddr_ll*, %struct.sockaddr_ll** %4
%28 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %27, i32 0, i32 4
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %17, i32 %20, i32 %23, i32 %26, i32 %29)
%31 = load %struct.sockaddr_ll*, %struct.sockaddr_ll** %4
%32 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %31, i32 0, i32 5
%33 = load i32, i32* %32
%34 = load %struct.sockaddr_ll*, %struct.sockaddr_ll** %4
%35 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %34, i32 0, i32 4
%36 = load i32, i32* %35
%37 = call i32 @println_hex(i32* null, i32 %33, i32 %36, i8 signext 58)
ret void
}

LLVM IR (-O2):
%struct.sockaddr_ll = type { i32, i32, i32, i32, i32, i32, i32 }
@.str = [73 x i8] c"family=%0d protocol=0x%0x ifindex=%d hatype=%d pkttype=%d halen=%d addr=\00"
define void @println_sockaddr_ll(i8* %0, %struct.sockaddr_ll* nocapture %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (i8*, ...) @printf(i8* %0)
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %1, i64 0, i32 0
%8 = load i32, i32* %7
%9 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %1, i64 0, i32 6
%10 = load i32, i32* %9
%11 = tail call i32 @ntohs(i32 %10)
%12 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %1, i64 0, i32 1
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %1, i64 0, i32 2
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %1, i64 0, i32 3
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %1, i64 0, i32 4
%19 = load i32, i32* %18
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %11, i32 %13, i32 %15, i32 %17, i32 %19)
%21 = getelementptr inbounds %struct.sockaddr_ll, %struct.sockaddr_ll* %1, i64 0, i32 5
%22 = load i32, i32* %21
%23 = load i32, i32* %18
%24 = tail call i32 @println_hex(i32* null, i32 %22, i32 %23, i8 signext 58)
ret void
}