#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct ifaddrs {
  int /*<<< orphan*/ ifa_name;
  TYPE_1__ *ifa_addr;
  struct ifaddrs *ifa_next;
};
struct TYPE_2__ {
  scalar_t__ sa_family;
};

/* Variables and functions */
scalar_t__ AF_PACKET;
int /*<<< orphan*/ strcmp(int /*<<< orphan*/, int /*<<< orphan*/);
struct ifaddrs *find_mac_addr(struct ifaddrs *ifaddr, struct ifaddrs *pattern) {
  if (!ifaddr)
    return NULL;
  for (; ifaddr != NULL; ifaddr = ifaddr->ifa_next) {
    if (ifaddr->ifa_addr->sa_family == AF_PACKET &&
        !strcmp(ifaddr->ifa_name, pattern->ifa_name))
      return ifaddr;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<find_mac_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1138 <find_mac_addr+0x28>
movq   $0x0,-0x8(%rbp)
jmp    11a8 <find_mac_addr+0x98>
jmp    113d <find_mac_addr+0x2d>
cmpq   $0x0,-0x10(%rbp)
je     11a0 <find_mac_addr+0x90>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    0x2e86(%rip),%rcx
cmp    (%rcx),%rax
jne    118a <find_mac_addr+0x7a>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    118a <find_mac_addr+0x7a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11a8 <find_mac_addr+0x98>
jmp    118f <find_mac_addr+0x7f>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x10(%rbp)
jmp    113d <find_mac_addr+0x2d>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_mac_addr>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     1155 <find_mac_addr+0x45>
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2eb9(%rip),%r15
mov    (%r15),%rax
jmp    1139 <find_mac_addr+0x29>
nopl   0x0(%rax)
mov    0x10(%rbx),%rbx
test   %rbx,%rbx
je     1155 <find_mac_addr+0x45>
mov    0x8(%rbx),%rcx
cmp    %rax,(%rcx)
jne    1130 <find_mac_addr+0x20>
mov    (%rbx),%edi
mov    (%r14),%esi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1157 <find_mac_addr+0x47>
mov    (%r15),%rax
jmp    1130 <find_mac_addr+0x20>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.ifaddrs = type { i32, %struct.TYPE_2__*, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i64 }
@AF_PACKET = global i64 0
define %struct.ifaddrs* @find_mac_addr(%struct.ifaddrs* %0, %struct.ifaddrs* %1) {
%3 = alloca %struct.ifaddrs*
%4 = alloca %struct.ifaddrs*
%5 = alloca %struct.ifaddrs*
store %struct.ifaddrs* %0, %struct.ifaddrs** %4
store %struct.ifaddrs* %1, %struct.ifaddrs** %5
%6 = load %struct.ifaddrs*, %struct.ifaddrs** %4
%7 = icmp ne %struct.ifaddrs* %6, null
br i1 %7, label %9, label %8
8: ; preds = %2
store %struct.ifaddrs* null, %struct.ifaddrs** %3
br label %38
9: ; preds = %2
br label %10
10: ; preds = %33, %9
%11 = load %struct.ifaddrs*, %struct.ifaddrs** %4
%12 = icmp ne %struct.ifaddrs* %11, null
br i1 %12, label %13, label %37
13: ; preds = %10
%14 = load %struct.ifaddrs*, %struct.ifaddrs** %4
%15 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %14, i32 0, i32 1
%16 = load %struct.TYPE_2__*, %struct.TYPE_2__** %15
%17 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %16, i32 0, i32 0
%18 = load i64, i64* %17
%19 = load i64, i64* @AF_PACKET
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %32
21: ; preds = %13
%22 = load %struct.ifaddrs*, %struct.ifaddrs** %4
%23 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %22, i32 0, i32 0
%24 = load i32, i32* %23
%25 = load %struct.ifaddrs*, %struct.ifaddrs** %5
%26 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %25, i32 0, i32 0
%27 = load i32, i32* %26
%28 = call i32 @strcmp(i32 %24, i32 %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %21
%31 = load %struct.ifaddrs*, %struct.ifaddrs** %4
store %struct.ifaddrs* %31, %struct.ifaddrs** %3
br label %38
32: ; preds = %21, %13
br label %33
33: ; preds = %32
%34 = load %struct.ifaddrs*, %struct.ifaddrs** %4
%35 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %34, i32 0, i32 2
%36 = load %struct.ifaddrs*, %struct.ifaddrs** %35
store %struct.ifaddrs* %36, %struct.ifaddrs** %4
br label %10
37: ; preds = %10
store %struct.ifaddrs* null, %struct.ifaddrs** %3
br label %38
38: ; preds = %37, %30, %8
%39 = load %struct.ifaddrs*, %struct.ifaddrs** %3
ret %struct.ifaddrs* %39
}

LLVM IR (-O2):
%struct.ifaddrs = type { i32, %struct.TYPE_2__*, %struct.ifaddrs* }
%struct.TYPE_2__ = type { i64 }
@AF_PACKET = global i64 0
define %struct.ifaddrs* @find_mac_addr(%struct.ifaddrs* %0, %struct.ifaddrs* nocapture %1) {
%3 = icmp eq %struct.ifaddrs* %0, null
br i1 %3, label %27, label %4
4: ; preds = %2
%5 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %1, i64 0, i32 0
%6 = load i64, i64* @AF_PACKET
br label %7
7: ; preds = %4, %22
%8 = phi i64 [ %6, %4 ], [ %23, %22 ]
%9 = phi %struct.ifaddrs* [ %0, %4 ], [ %25, %22 ]
%10 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %9, i64 0, i32 1
%11 = load %struct.TYPE_2__*, %struct.TYPE_2__** %10
%12 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i64 0, i32 0
%13 = load i64, i64* %12
%14 = icmp eq i64 %13, %8
br i1 %14, label %15, label %22
15: ; preds = %7
%16 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %9, i64 0, i32 0
%17 = load i32, i32* %16
%18 = load i32, i32* %5
%19 = tail call i32 @strcmp(i32 %17, i32 %18)
%20 = icmp eq i32 %19, 0
%21 = load i64, i64* @AF_PACKET
br i1 %20, label %27, label %22
22: ; preds = %7, %15
%23 = phi i64 [ %8, %7 ], [ %21, %15 ]
%24 = getelementptr inbounds %struct.ifaddrs, %struct.ifaddrs* %9, i64 0, i32 2
%25 = load %struct.ifaddrs*, %struct.ifaddrs** %24
%26 = icmp eq %struct.ifaddrs* %25, null
br i1 %26, label %27, label %7
27: ; preds = %15, %22, %2
%28 = phi %struct.ifaddrs* [ null, %2 ], [ %9, %15 ], [ null, %22 ]
ret %struct.ifaddrs* %28
}