#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 */
typedef int uint8_t;

/* Variables and functions */
scalar_t__ is_broadcast_ether_addr(int *);
scalar_t__ is_multicast_ether_addr(int *);
char const *lookup_vendor_str(int);
const char *ether_lookup_addr(uint8_t *mac) {
  if (is_multicast_ether_addr(mac)) {
    if (is_broadcast_ether_addr(mac))
      return "Broadcast";
    else
      return "Multicast";
  }
  return lookup_vendor_str((mac[0] << 16) | (mac[1] << 8) | mac[2]);
}


x86 assembly (clang, -O0):
<ether_lookup_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <is_multicast_ether_addr@plt>
cmp    $0x0,%rax
je     1182 <ether_lookup_addr+0x52>
mov    -0x10(%rbp),%rdi
call   1040 <is_broadcast_ether_addr@plt>
cmp    $0x0,%rax
je     1172 <ether_lookup_addr+0x42>
lea    0xe97(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a7 <ether_lookup_addr+0x77>
lea    0xe91(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a7 <ether_lookup_addr+0x77>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
shl    $0x10,%edi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
shl    $0x8,%eax
or     %eax,%edi
mov    -0x10(%rbp),%rax
or     0x8(%rax),%edi
call   1030 <lookup_vendor_str@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ether_lookup_addr>:
push   %rbx
mov    %rdi,%rbx
call   1050 <is_multicast_ether_addr@plt>
test   %rax,%rax
je     115d <ether_lookup_addr+0x2d>
mov    %rbx,%rdi
call   1040 <is_broadcast_ether_addr@plt>
test   %rax,%rax
lea    0xeba(%rip),%rcx
lea    0xea9(%rip),%rax
cmove  %rcx,%rax
pop    %rbx
ret
mov    (%rbx),%eax
mov    0x4(%rbx),%edi
shl    $0x10,%eax
shl    $0x8,%edi
or     %eax,%edi
or     0x8(%rbx),%edi
pop    %rbx
jmp    1030 <lookup_vendor_str@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"Broadcast\00"
@.str.1 = [10 x i8] c"Multicast\00"
define i8* @ether_lookup_addr(i32* %0) {
%2 = alloca i8*
%3 = alloca i32*
store i32* %0, i32** %3
%4 = load i32*, i32** %3
%5 = call i64 @is_multicast_ether_addr(i32* %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %1
%8 = load i32*, i32** %3
%9 = call i64 @is_broadcast_ether_addr(i32* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %2
br label %28
12: ; preds = %7
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %28
13: ; preds = %1
%14 = load i32*, i32** %3
%15 = getelementptr inbounds i32, i32* %14, i64 0
%16 = load i32, i32* %15
%17 = shl i32 %16, 16
%18 = load i32*, i32** %3
%19 = getelementptr inbounds i32, i32* %18, i64 1
%20 = load i32, i32* %19
%21 = shl i32 %20, 8
%22 = or i32 %17, %21
%23 = load i32*, i32** %3
%24 = getelementptr inbounds i32, i32* %23, i64 2
%25 = load i32, i32* %24
%26 = or i32 %22, %25
%27 = call i8* @lookup_vendor_str(i32 %26)
store i8* %27, i8** %2
br label %28
28: ; preds = %13, %12, %11
%29 = load i8*, i8** %2
ret i8* %29
}

LLVM IR (-O2):
@.str = [10 x i8] c"Broadcast\00"
@.str.1 = [10 x i8] c"Multicast\00"
define i8* @ether_lookup_addr(i32* %0) {
%2 = tail call i64 @is_multicast_ether_addr(i32* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %8, label %4
4: ; preds = %1
%5 = tail call i64 @is_broadcast_ether_addr(i32* %0)
%6 = icmp eq i64 %5, 0
%7 = select i1 %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0)
br label %19
8: ; preds = %1
%9 = load i32, i32* %0
%10 = shl i32 %9, 16
%11 = getelementptr inbounds i32, i32* %0, i64 1
%12 = load i32, i32* %11
%13 = shl i32 %12, 8
%14 = or i32 %13, %10
%15 = getelementptr inbounds i32, i32* %0, i64 2
%16 = load i32, i32* %15
%17 = or i32 %14, %16
%18 = tail call i8* @lookup_vendor_str(i32 %17)
br label %19
19: ; preds = %4, %8
%20 = phi i8* [ %18, %8 ], [ %7, %4 ]
ret i8* %20
}