#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 */
unsigned char *calloc(int, int);
int /*<<< orphan*/ sscanf(char *, char *, unsigned char *, unsigned char *,
                          unsigned char *, unsigned char *, unsigned char *,
                          unsigned char *);
unsigned char *parse_mac_addr(char *mac_str) {
  unsigned char *result = calloc(6, sizeof(unsigned char));
  sscanf(mac_str, "%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx", result, result + 1,
         result + 2, result + 3, result + 4, result + 5);
  return result;
}


x86 assembly (clang, -O0):
<parse_mac_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x6,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,-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    0xe8a(%rip),%rsi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <sscanf@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_mac_addr>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x6,%edi
mov    $0x1,%esi
call   1030 <calloc@plt>
mov    %rax,%rbx
lea    0x1(%rax),%rcx
lea    0x2(%rax),%r8
lea    0x3(%rax),%r9
lea    0x4(%rax),%r10
add    $0x5,%rax
lea    0xeac(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
push   %rax
push   %r10
call   1040 <sscanf@plt>
add    $0x10,%rsp
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [36 x i8] c"%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx\00"
define i8* @parse_mac_addr(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = call i8* @calloc(i32 6, i32 1)
store i8* %4, i8** %3
%5 = load i8*, i8** %2
%6 = load i8*, i8** %3
%7 = load i8*, i8** %3
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 2
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 3
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 4
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 5
%17 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %8, i8* %10, i8* %12, i8* %14, i8* %16)
%18 = load i8*, i8** %3
ret i8* %18
}

LLVM IR (-O2):
@.str = [36 x i8] c"%2hhx:%2hhx:%2hhx:%2hhx:%2hhx:%2hhx\00"
define i8* @parse_mac_addr(i8* nocapture %0) {
%2 = tail call dereferenceable_or_null(6) i8* @calloc(i32 6, i32 1)
%3 = getelementptr inbounds i8, i8* %2, i64 1
%4 = getelementptr inbounds i8, i8* %2, i64 2
%5 = getelementptr inbounds i8, i8* %2, i64 3
%6 = getelementptr inbounds i8, i8* %2, i64 4
%7 = getelementptr inbounds i8, i8* %2, i64 5
%8 = tail call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7)
ret i8* %2
}