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

/* Variables and functions */
int /*<<< orphan*/ error(int, int /*<<< orphan*/, char *);
int sscanf(char *, char *, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *);
void read_MAC(uint8_t *mac_addr, char *mac) {
  if (sscanf(mac, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &mac_addr[0], &mac_addr[1],
             &mac_addr[2], &mac_addr[3], &mac_addr[4], &mac_addr[5]) != 6)
    error(1, 0, "sscanf");
}


x86 assembly (clang, -O0):
<read_MAC>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x8(%rbp),%rcx
add    $0x4,%rcx
mov    -0x8(%rbp),%r8
add    $0x8,%r8
mov    -0x8(%rbp),%r9
add    $0xc,%r9
mov    -0x8(%rbp),%r10
add    $0x10,%r10
mov    -0x8(%rbp),%rax
add    $0x14,%rax
lea    0xe99(%rip),%rsi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <sscanf@plt>
cmp    $0x6,%eax
je     1191 <read_MAC+0x71>
mov    $0x1,%edi
xor    %esi,%esi
lea    0xe92(%rip),%rdx
call   1040 <error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_MAC>:
push   %rax
mov    %rsi,%rax
mov    %rdi,%rdx
lea    0x4(%rdi),%rcx
lea    0x8(%rdi),%r8
lea    0xc(%rdi),%r9
lea    0x10(%rdi),%r10
lea    0x14(%rdi),%r11
lea    0xebe(%rip),%rsi
mov    %rax,%rdi
push   %r11
push   %r10
call   1030 <sscanf@plt>
add    $0x10,%rsp
cmp    $0x6,%eax
jne    1159 <read_MAC+0x39>
pop    %rax
ret
lea    0xebe(%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 = [7 x i8] c"sscanf\00"
define void @read_MAC(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = load i32*, i32** %3
%7 = getelementptr inbounds i32, i32* %6, i64 0
%8 = load i32*, i32** %3
%9 = getelementptr inbounds i32, i32* %8, i64 1
%10 = load i32*, i32** %3
%11 = getelementptr inbounds i32, i32* %10, i64 2
%12 = load i32*, i32** %3
%13 = getelementptr inbounds i32, i32* %12, i64 3
%14 = load i32*, i32** %3
%15 = getelementptr inbounds i32, i32* %14, i64 4
%16 = load i32*, i32** %3
%17 = getelementptr inbounds i32, i32* %16, i64 5
%18 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32* %7, i32* %9, i32* %11, i32* %13, i32* %15, i32* %17)
%19 = icmp ne i32 %18, 6
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 @error(i32 1, i32 0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %2
ret void
}

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