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

/* Variables and functions */
int /*<<< orphan*/ sscanf(char *, char *, int *);
void mac_to_char(char *mac, unsigned char *str) {
  int i;
  int v;
  for (i = 0; i < sizeof(str); i++) {
    sscanf(mac + 3 * i, "%2x", &v);
    str[i] = (char)v;
  }
}


x86 assembly (clang, -O0):
<mac_to_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    $0x8,%rax
jae    1170 <mac_to_char+0x60>
mov    -0x8(%rbp),%rdi
imul   $0x3,-0x14(%rbp),%eax
cltq
add    %rax,%rdi
lea    0xeb7(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <sscanf@plt>
mov    -0x18(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <mac_to_char+0x17>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mac_to_char>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xedb(%rip),%r15
lea    0x4(%rsp),%r12
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <sscanf@plt>
mov    0x4(%rsp),%al
mov    %al,(%r14)
lea    0x3(%rbx),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <sscanf@plt>
mov    0x4(%rsp),%al
mov    %al,0x1(%r14)
lea    0x6(%rbx),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <sscanf@plt>
mov    0x4(%rsp),%al
mov    %al,0x2(%r14)
lea    0x9(%rbx),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <sscanf@plt>
mov    0x4(%rsp),%al
mov    %al,0x3(%r14)
lea    0xc(%rbx),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <sscanf@plt>
mov    0x4(%rsp),%al
mov    %al,0x4(%r14)
lea    0xf(%rbx),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <sscanf@plt>
mov    0x4(%rsp),%al
mov    %al,0x5(%r14)
lea    0x12(%rbx),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <sscanf@plt>
mov    0x4(%rsp),%al
mov    %al,0x6(%r14)
add    $0x15,%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <sscanf@plt>
mov    0x4(%rsp),%al
mov    %al,0x7(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%2x\00"
define void @mac_to_char(i8* nocapture %0, i8* nocapture writeonly %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = load i32, i32* %3
%7 = trunc i32 %6 to i8
store i8 %7, i8* %1
%8 = getelementptr inbounds i8, i8* %0, i64 3
%9 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = load i32, i32* %3
%11 = trunc i32 %10 to i8
%12 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %11, i8* %12
%13 = getelementptr inbounds i8, i8* %0, i64 6
%14 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %3
%16 = trunc i32 %15 to i8
%17 = getelementptr inbounds i8, i8* %1, i64 2
store i8 %16, i8* %17
%18 = getelementptr inbounds i8, i8* %0, i64 9
%19 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%20 = load i32, i32* %3
%21 = trunc i32 %20 to i8
%22 = getelementptr inbounds i8, i8* %1, i64 3
store i8 %21, i8* %22
%23 = getelementptr inbounds i8, i8* %0, i64 12
%24 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%25 = load i32, i32* %3
%26 = trunc i32 %25 to i8
%27 = getelementptr inbounds i8, i8* %1, i64 4
store i8 %26, i8* %27
%28 = getelementptr inbounds i8, i8* %0, i64 15
%29 = call i32 @sscanf(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%30 = load i32, i32* %3
%31 = trunc i32 %30 to i8
%32 = getelementptr inbounds i8, i8* %1, i64 5
store i8 %31, i8* %32
%33 = getelementptr inbounds i8, i8* %0, i64 18
%34 = call i32 @sscanf(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%35 = load i32, i32* %3
%36 = trunc i32 %35 to i8
%37 = getelementptr inbounds i8, i8* %1, i64 6
store i8 %36, i8* %37
%38 = getelementptr inbounds i8, i8* %0, i64 21
%39 = call i32 @sscanf(i8* %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%40 = load i32, i32* %3
%41 = trunc i32 %40 to i8
%42 = getelementptr inbounds i8, i8* %1, i64 7
store i8 %41, i8* %42
ret void
}