#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 */

/* Variables and functions */
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *, char *);
char *optarg;
int sscanf(char const *, char *, char *, char *, char *, char *, char *,
           char *);
void read_mac(const char *mac_str, char *mac_bin) {
  if (sscanf(mac_str, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &mac_bin[0], &mac_bin[1],
             &mac_bin[2], &mac_bin[3], &mac_bin[4], &mac_bin[5]) != 6)
    error(1, 0, "bad mac: %s\n", optarg);
}


x86 assembly (clang, -O0):
<read_mac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x10(%rbp),%rcx
add    $0x1,%rcx
mov    -0x10(%rbp),%r8
add    $0x2,%r8
mov    -0x10(%rbp),%r9
add    $0x3,%r9
mov    -0x10(%rbp),%r10
add    $0x4,%r10
mov    -0x10(%rbp),%rax
add    $0x5,%rax
lea    0xe99(%rip),%rsi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <sscanf@plt>
cmp    $0x6,%eax
je     119b <read_mac+0x7b>
mov    0x2e73(%rip),%rax
mov    (%rax),%rcx
mov    $0x1,%edi
xor    %esi,%esi
lea    0xe88(%rip),%rdx
call   1040 <error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_mac>:
push   %rax
mov    %rsi,%rdx
lea    0x1(%rsi),%rcx
lea    0x2(%rsi),%r8
lea    0x3(%rsi),%r9
lea    0x4(%rsi),%r10
lea    0x5(%rsi),%rax
lea    0xec1(%rip),%rsi
push   %rax
push   %r10
call   1030 <sscanf@plt>
add    $0x10,%rsp
cmp    $0x6,%eax
jne    1152 <read_mac+0x32>
pop    %rax
ret
mov    0x2e9f(%rip),%rax
mov    (%rax),%rcx
lea    0xebb(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
pop    %rax
jmp    1040 <error@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx\00"
@.str.1 = [13 x i8] c"bad mac: %s\0A\00"
@optarg = global i8* null
define void @read_mac(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = load i8*, i8** %4
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8*, i8** %4
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 2
%12 = load i8*, i8** %4
%13 = getelementptr inbounds i8, i8* %12, i64 3
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 4
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 5
%18 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %9, i8* %11, i8* %13, i8* %15, i8* %17)
%19 = icmp ne i32 %18, 6
br i1 %19, label %20, label %23
20: ; preds = %2
%21 = load i8*, i8** @optarg
%22 = call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %23
23: ; preds = %20, %2
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"%hhx:%hhx:%hhx:%hhx:%hhx:%hhx\00"
@.str.1 = [13 x i8] c"bad mac: %s\0A\00"
@optarg = global i8* null
define void @read_mac(i8* nocapture %0, i8* %1) {
%3 = getelementptr inbounds i8, i8* %1, i64 1
%4 = getelementptr inbounds i8, i8* %1, i64 2
%5 = getelementptr inbounds i8, i8* %1, i64 3
%6 = getelementptr inbounds i8, i8* %1, i64 4
%7 = getelementptr inbounds i8, i8* %1, i64 5
%8 = tail call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7)
%9 = icmp eq i32 %8, 6
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i8*, i8** @optarg
%12 = tail call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %10, %2
ret void
}