#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 *, int *, int *, int *, int *, int *, int *);
int parseMAC(const char *macStr, unsigned char result[6]) {
  int values[6];
  if (6 != sscanf(macStr, "%x:%x:%x:%x:%x:%x", &values[0], &values[1],
                  &values[2], &values[3], &values[4], &values[5])) {
    return -1;
  }
  for (int i = 0; i < 6; ++i) {
    result[i] = (unsigned char)values[i];
  }
  return 0;
}


x86 assembly (clang, -O0):
<parseMAC>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    -0x30(%rbp),%rcx
add    $0x4,%rcx
lea    -0x30(%rbp),%r8
add    $0x8,%r8
lea    -0x30(%rbp),%r9
add    $0xc,%r9
lea    -0x30(%rbp),%r10
add    $0x10,%r10
lea    -0x30(%rbp),%rax
add    $0x14,%rax
lea    0xea9(%rip),%rsi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <sscanf@plt>
mov    %eax,%ecx
mov    $0x6,%eax
cmp    %ecx,%eax
je     1180 <parseMAC+0x70>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bb <parseMAC+0xab>
movl   $0x0,-0x34(%rbp)
cmpl   $0x6,-0x34(%rbp)
jge    11b4 <parseMAC+0xa4>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1187 <parseMAC+0x77>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseMAC>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
lea    0x4(%rsp),%rcx
lea    0x8(%rsp),%r8
lea    0xc(%rsp),%r9
lea    0x10(%rsp),%r10
lea    0x14(%rsp),%rax
lea    0xed8(%rip),%rsi
mov    %rsp,%rdx
push   %rax
push   %r10
call   1030 <sscanf@plt>
add    $0x10,%rsp
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    $0x6,%ecx
jne    117c <parseMAC+0x6c>
movdqa (%rsp),%xmm0
pand   0xea0(%rip),%xmm0
packuswb %xmm0,%xmm0
packuswb %xmm0,%xmm0
movd   %xmm0,(%rbx)
mov    0x10(%rsp),%al
mov    %al,0x4(%rbx)
mov    0x14(%rsp),%al
mov    %al,0x5(%rbx)
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"%x:%x:%x:%x:%x:%x\00"
define i32 @parseMAC(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [6 x i32]
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 0
%10 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 1
%11 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 2
%12 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 3
%13 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 4
%14 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 5
%15 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32* %9, i32* %10, i32* %11, i32* %12, i32* %13, i32* %14)
%16 = icmp ne i32 6, %15
br i1 %16, label %17, label %18
17: ; preds = %2
store i32 -1, i32* %3
br label %36
18: ; preds = %2
store i32 0, i32* %7
br label %19
19: ; preds = %32, %18
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 6
br i1 %21, label %22, label %35
22: ; preds = %19
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [6 x i32], [6 x i32]* %6, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = trunc i32 %26 to i8
%28 = load i8*, i8** %5
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
store i8 %27, i8* %31
br label %32
32: ; preds = %22
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %19
35: ; preds = %19
store i32 0, i32* %3
br label %36
36: ; preds = %35, %17
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [18 x i8] c"%x:%x:%x:%x:%x:%x\00"
define i32 @parseMAC(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = alloca [6 x i32]
%4 = bitcast [6 x i32]* %3 to i8*
%5 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 0
%6 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 1
%7 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 2
%8 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 3
%9 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 4
%10 = getelementptr inbounds [6 x i32], [6 x i32]* %3, i64 0, i64 5
%11 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10)
%12 = icmp eq i32 %11, 6
br i1 %12, label %13, label %24
13: ; preds = %2
%14 = bitcast [6 x i32]* %3 to <4 x i32>*
%15 = load <4 x i32>, <4 x i32>* %14
%16 = trunc <4 x i32> %15 to <4 x i8>
%17 = bitcast i8* %1 to <4 x i8>*
store <4 x i8> %16, <4 x i8>* %17
%18 = load i32, i32* %9
%19 = trunc i32 %18 to i8
%20 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %19, i8* %20
%21 = load i32, i32* %10
%22 = trunc i32 %21 to i8
%23 = getelementptr inbounds i8, i8* %1, i64 5
store i8 %22, i8* %23
br label %24
24: ; preds = %13, %2
%25 = phi i32 [ -1, %2 ], [ 0, %13 ]
ret i32 %25
}