#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 sscanf(char const *, char *, unsigned char *, unsigned char *,
           unsigned char *, unsigned char *, unsigned char *, unsigned char *,
           ...);
int parse_eui64(const char *eui, unsigned char *eui_r) {
  int n;
  n = sscanf(eui, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
             &eui_r[0], &eui_r[1], &eui_r[2], &eui_r[3], &eui_r[4], &eui_r[5],
             &eui_r[6], &eui_r[7]);
  if (n == 8)
    return 0;
  n = sscanf(eui, "%02hhx-%02hhx-%02hhx-%02hhx-%02hhx-%02hhx-%02hhx-%02hhx",
             &eui_r[0], &eui_r[1], &eui_r[2], &eui_r[3], &eui_r[4], &eui_r[5],
             &eui_r[6], &eui_r[7]);
  if (n == 8)
    return 0;
  n = sscanf(eui, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx", &eui_r[0],
             &eui_r[1], &eui_r[2], &eui_r[5], &eui_r[6], &eui_r[7]);
  if (n == 6) {
    eui_r[3] = 0xFF;
    eui_r[4] = 0xFE;
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<parse_eui64>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x48,%rsp
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
mov    -0x20(%rbp),%r8
add    $0x2,%r8
mov    -0x20(%rbp),%r9
add    $0x3,%r9
mov    -0x20(%rbp),%rbx
add    $0x4,%rbx
mov    -0x20(%rbp),%r11
add    $0x5,%r11
mov    -0x20(%rbp),%r10
add    $0x6,%r10
mov    -0x20(%rbp),%rax
add    $0x7,%rax
lea    0xe98(%rip),%rsi
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
mov    $0x0,%al
call   1030 <sscanf@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x8,-0x24(%rbp)
jne    119b <parse_eui64+0x8b>
movl   $0x0,-0xc(%rbp)
jmp    128c <parse_eui64+0x17c>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
mov    -0x20(%rbp),%r8
add    $0x2,%r8
mov    -0x20(%rbp),%r9
add    $0x3,%r9
mov    -0x20(%rbp),%rbx
add    $0x4,%rbx
mov    -0x20(%rbp),%r11
add    $0x5,%r11
mov    -0x20(%rbp),%r10
add    $0x6,%r10
mov    -0x20(%rbp),%rax
add    $0x7,%rax
lea    0xe56(%rip),%rsi
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
mov    $0x0,%al
call   1030 <sscanf@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x8,-0x24(%rbp)
jne    1215 <parse_eui64+0x105>
movl   $0x0,-0xc(%rbp)
jmp    128c <parse_eui64+0x17c>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x20(%rbp),%rcx
add    $0x1,%rcx
mov    -0x20(%rbp),%r8
add    $0x2,%r8
mov    -0x20(%rbp),%r9
add    $0x5,%r9
mov    -0x20(%rbp),%r10
add    $0x6,%r10
mov    -0x20(%rbp),%rax
add    $0x7,%rax
lea    0xdc2(%rip),%rsi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1030 <sscanf@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x6,-0x24(%rbp)
jne    1285 <parse_eui64+0x175>
mov    -0x20(%rbp),%rax
movb   $0xff,0x3(%rax)
mov    -0x20(%rbp),%rax
movb   $0xfe,0x4(%rax)
movl   $0x0,-0xc(%rbp)
jmp    128c <parse_eui64+0x17c>
movl   $0xffffffff,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_eui64>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %rdi,%r12
lea    0x1(%rsi),%rcx
lea    0x2(%rsi),%r8
lea    0x3(%rsi),%r9
lea    0x4(%rsi),%r10
lea    0x5(%rsi),%r13
lea    0x6(%rsi),%rbp
lea    0x7(%rsi),%r15
lea    0xeb9(%rip),%rsi
xor    %r14d,%r14d
mov    %rbx,%rdx
mov    %rcx,0x18(%rsp)
mov    %r8,0x10(%rsp)
mov    %r9,0x8(%rsp)
xor    %eax,%eax
push   %r15
mov    %rbp,0x28(%rsp)
push   %rbp
push   %r13
mov    %r10,0x18(%rsp)
push   %r10
call   1030 <sscanf@plt>
add    $0x20,%rsp
cmp    $0x8,%eax
je     1204 <parse_eui64+0xf4>
lea    0xeb0(%rip),%rsi
xor    %r14d,%r14d
mov    %r12,%rdi
mov    %rbx,%rdx
mov    0x18(%rsp),%rcx
mov    0x10(%rsp),%r8
mov    0x8(%rsp),%r9
xor    %eax,%eax
push   %r15
push   0x28(%rsp)
push   %r13
push   0x18(%rsp)
call   1030 <sscanf@plt>
add    $0x20,%rsp
cmp    $0x8,%eax
je     1204 <parse_eui64+0xf4>
lea    0xe4b(%rip),%rsi
mov    %r12,%rdi
mov    %rbx,%rdx
mov    0x18(%rsp),%rcx
mov    0x10(%rsp),%r8
mov    %r13,%r9
xor    %eax,%eax
push   %r15
push   0x28(%rsp)
call   1030 <sscanf@plt>
add    $0x10,%rsp
mov    $0xffffffff,%r14d
cmp    $0x6,%eax
jne    1204 <parse_eui64+0xf4>
mov    0x8(%rsp),%rax
movb   $0xff,(%rax)
mov    (%rsp),%rax
movb   $0xfe,(%rax)
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [56 x i8] c"%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\00"
@.str.1 = [56 x i8] c"%02hhx-%02hhx-%02hhx-%02hhx-%02hhx-%02hhx-%02hhx-%02hhx\00"
@.str.2 = [42 x i8] c"%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\00"
define i32 @parse_eui64(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8*, i8** %5
%11 = getelementptr inbounds i8, i8* %10, i64 1
%12 = load i8*, i8** %5
%13 = getelementptr inbounds i8, i8* %12, i64 2
%14 = load i8*, i8** %5
%15 = getelementptr inbounds i8, i8* %14, i64 3
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i64 4
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 5
%20 = load i8*, i8** %5
%21 = getelementptr inbounds i8, i8* %20, i64 6
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i64 7
%24 = call i32 (i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, ...) @sscanf(i8* %7, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %9, i8* %11, i8* %13, i8* %15, i8* %17, i8* %19, i8* %21, i8* %23)
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = icmp eq i32 %25, 8
br i1 %26, label %27, label %28
27: ; preds = %2
store i32 0, i32* %3
br label %73
28: ; preds = %2
%29 = load i8*, i8** %4
%30 = load i8*, i8** %5
%31 = getelementptr inbounds i8, i8* %30, i64 0
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i64 1
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i64 2
%36 = load i8*, i8** %5
%37 = getelementptr inbounds i8, i8* %36, i64 3
%38 = load i8*, i8** %5
%39 = getelementptr inbounds i8, i8* %38, i64 4
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i64 5
%42 = load i8*, i8** %5
%43 = getelementptr inbounds i8, i8* %42, i64 6
%44 = load i8*, i8** %5
%45 = getelementptr inbounds i8, i8* %44, i64 7
%46 = call i32 (i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, ...) @sscanf(i8* %29, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i8* %31, i8* %33, i8* %35, i8* %37, i8* %39, i8* %41, i8* %43, i8* %45)
store i32 %46, i32* %6
%47 = load i32, i32* %6
%48 = icmp eq i32 %47, 8
br i1 %48, label %49, label %50
49: ; preds = %28
store i32 0, i32* %3
br label %73
50: ; preds = %28
%51 = load i8*, i8** %4
%52 = load i8*, i8** %5
%53 = getelementptr inbounds i8, i8* %52, i64 0
%54 = load i8*, i8** %5
%55 = getelementptr inbounds i8, i8* %54, i64 1
%56 = load i8*, i8** %5
%57 = getelementptr inbounds i8, i8* %56, i64 2
%58 = load i8*, i8** %5
%59 = getelementptr inbounds i8, i8* %58, i64 5
%60 = load i8*, i8** %5
%61 = getelementptr inbounds i8, i8* %60, i64 6
%62 = load i8*, i8** %5
%63 = getelementptr inbounds i8, i8* %62, i64 7
%64 = call i32 (i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, ...) @sscanf(i8* %51, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %53, i8* %55, i8* %57, i8* %59, i8* %61, i8* %63)
store i32 %64, i32* %6
%65 = load i32, i32* %6
%66 = icmp eq i32 %65, 6
br i1 %66, label %67, label %72
67: ; preds = %50
%68 = load i8*, i8** %5
%69 = getelementptr inbounds i8, i8* %68, i64 3
store i8 -1, i8* %69
%70 = load i8*, i8** %5
%71 = getelementptr inbounds i8, i8* %70, i64 4
store i8 -2, i8* %71
store i32 0, i32* %3
br label %73
72: ; preds = %50
store i32 -1, i32* %3
br label %73
73: ; preds = %72, %67, %49, %27
%74 = load i32, i32* %3
ret i32 %74
}

LLVM IR (-O2):
@.str = [56 x i8] c"%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\00"
@.str.1 = [56 x i8] c"%02hhx-%02hhx-%02hhx-%02hhx-%02hhx-%02hhx-%02hhx-%02hhx\00"
@.str.2 = [42 x i8] c"%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\00"
define i32 @parse_eui64(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 = getelementptr inbounds i8, i8* %1, i64 6
%9 = getelementptr inbounds i8, i8* %1, i64 7
%10 = tail call i32 (i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7, i8* %8, i8* %9)
%11 = icmp eq i32 %10, 8
br i1 %11, label %19, label %12
12: ; preds = %2
%13 = tail call i32 (i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7, i8* %8, i8* %9)
%14 = icmp eq i32 %13, 8
br i1 %14, label %19, label %15
15: ; preds = %12
%16 = tail call i32 (i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, ...) @sscanf(i8* %0, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %3, i8* %4, i8* %7, i8* %8, i8* %9)
%17 = icmp eq i32 %16, 6
br i1 %17, label %18, label %19
18: ; preds = %15
store i8 -1, i8* %5
store i8 -2, i8* %6
br label %19
19: ; preds = %15, %12, %2, %18
%20 = phi i32 [ 0, %18 ], [ 0, %2 ], [ 0, %12 ], [ -1, %15 ]
ret i32 %20
}