#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_addr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
struct ether_addr *ether_aton(char const *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
void parse_mac(struct ether_addr *ea, const char *str) {
  const struct ether_addr *tmp;
  tmp = ether_aton(str);
  if (!tmp) {
    fprintf(stderr, "Invalid MAC address %s\n", str);
    exit(EXIT_FAILURE);
  }
  *ea = *tmp;
}


x86 assembly (clang, -O0):
<parse_mac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <ether_aton@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    117f <parse_mac+0x4f>
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe94(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%ecx
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_mac>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <ether_aton@plt>
test   %rax,%rax
je     1153 <parse_mac+0x23>
mov    (%rax),%eax
mov    %eax,(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
mov    %r14,%rdx
call   1030 <fprintf@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
%struct.ether_addr = type { i32 }
@stderr = global i32 0
@.str = [24 x i8] c"Invalid MAC address %s\0A\00"
@EXIT_FAILURE = global i32 0
define void @parse_mac(%struct.ether_addr* %0, i8* %1) {
%3 = alloca %struct.ether_addr*
%4 = alloca i8*
%5 = alloca %struct.ether_addr*
store %struct.ether_addr* %0, %struct.ether_addr** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call %struct.ether_addr* @ether_aton(i8* %6)
store %struct.ether_addr* %7, %struct.ether_addr** %5
%8 = load %struct.ether_addr*, %struct.ether_addr** %5
%9 = icmp ne %struct.ether_addr* %8, null
br i1 %9, label %16, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %4
%13 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %2
%17 = load %struct.ether_addr*, %struct.ether_addr** %3
%18 = load %struct.ether_addr*, %struct.ether_addr** %5
%19 = bitcast %struct.ether_addr* %17 to i8*
%20 = bitcast %struct.ether_addr* %18 to i8*
ret void
}

LLVM IR (-O2):
%struct.ether_addr = type { i32 }
@stderr = global i32 0
@.str = [24 x i8] c"Invalid MAC address %s\0A\00"
@EXIT_FAILURE = global i32 0
define void @parse_mac(%struct.ether_addr* nocapture writeonly %0, i8* %1) {
%3 = tail call %struct.ether_addr* @ether_aton(i8* %1)
%4 = icmp eq %struct.ether_addr* %3, null
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %1)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = getelementptr %struct.ether_addr, %struct.ether_addr* %3, i64 0, i32 0
%12 = getelementptr %struct.ether_addr, %struct.ether_addr* %0, i64 0, i32 0
%13 = load i32, i32* %11
store i32 %13, i32* %12
ret void
}