#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*/ printf(char *, unsigned int, unsigned int, unsigned int,
                          unsigned int, unsigned int, unsigned int);
int /*<<< orphan*/ sscanf(char *, char *, unsigned int *, unsigned int *,
                          unsigned int *, unsigned int *, unsigned int *,
                          unsigned int *);
void parsemac(char *str, void *dest) {
  unsigned int karl[6];
  int i;
  sscanf(str, "%02x:%02x:%02x:%02x:%02x:%02x", &karl[0], &karl[1], &karl[2],
         &karl[3], &karl[4], &karl[5]);
  printf("%02x:%02x:%02x:%02x:%02x:%02x\n", karl[0], karl[1], karl[2], karl[3],
         karl[4], karl[5]);
  for (i = 0; i < 6; ++i)
    ((unsigned char *)dest)[i] = (unsigned char)karl[i];
}


x86 assembly (clang, -O0):
<parsemac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%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    0xe99(%rip),%rsi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <sscanf@plt>
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x24(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    -0x1c(%rbp),%eax
lea    0xe8e(%rip),%rdi
mov    %eax,(%rsp)
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
cmpl   $0x6,-0x34(%rbp)
jge    11cc <parsemac+0xac>
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    119f <parsemac+0x7f>
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    0xec8(%rip),%rsi
mov    %rsp,%rdx
push   %rax
push   %r10
call   1040 <sscanf@plt>
add    $0x10,%rsp
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    0x10(%rsp),%r9d
mov    0x14(%rsp),%eax
sub    $0x8,%rsp
lea    0xeb3(%rip),%rdi
push   %rax
call   1030 <printf@plt>
add    $0x10,%rsp
movdqa (%rsp),%xmm0
pand   0xe6e(%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)
add    $0x20,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [30 x i8] c"%02x:%02x:%02x:%02x:%02x:%02x\00"
@.str.1 = [31 x i8] c"%02x:%02x:%02x:%02x:%02x:%02x\0A\00"
define void @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 ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10)
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = load i32, i32* %7
%15 = load i32, i32* %8
%16 = load i32, i32* %9
%17 = load i32, i32* %10
%18 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %12, i32 %13, i32 %14, i32 %15, i32 %16, i32 %17)
%19 = bitcast [6 x i32]* %3 to <4 x i32>*
%20 = load <4 x i32>, <4 x i32>* %19
%21 = trunc <4 x i32> %20 to <4 x i8>
%22 = bitcast i8* %1 to <4 x i8>*
store <4 x i8> %21, <4 x i8>* %22
%23 = load i32, i32* %9
%24 = trunc i32 %23 to i8
%25 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %24, i8* %25
%26 = load i32, i32* %10
%27 = trunc i32 %26 to i8
%28 = getelementptr inbounds i8, i8* %1, i64 5
store i8 %27, i8* %28
ret void
}