#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned char, unsigned char,
                            unsigned char, unsigned char, unsigned char,
                            unsigned char);
char *mac2string(unsigned char *mac_address) {
  char *mac_string = (char *)malloc(sizeof(char) * 18);
  snprintf(mac_string, 18, "%02X:%02X:%02X:%02X:%02X:%02X", *mac_address,
           *(mac_address + 1), *(mac_address + 2), *(mac_address + 3),
           *(mac_address + 4), *(mac_address + 5));
  return mac_string;
}


x86 assembly (clang, -O0):
<mac2string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x12,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x8(%rbp),%rax
mov    0x1(%rax),%r8b
mov    -0x8(%rbp),%rax
mov    0x2(%rax),%r9b
mov    -0x8(%rbp),%rax
mov    0x3(%rax),%r11b
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%r10b
mov    -0x8(%rbp),%rax
mov    $0x12,%esi
lea    0xe8c(%rip),%rdx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %r9b,%r9d
movzbl %r11b,%r11d
mov    %r11d,(%rsp)
movzbl %r10b,%r10d
mov    %r10d,0x8(%rsp)
movzbl 0x5(%rax),%eax
mov    %eax,0x10(%rsp)
call   1030 <snprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mac2string>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x12,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
movzbl (%rbx),%ecx
movzbl 0x1(%rbx),%r8d
movzbl 0x2(%rbx),%r9d
movzbl 0x3(%rbx),%r10d
movzbl 0x4(%rbx),%eax
movzbl 0x5(%rbx),%ebx
sub    $0x8,%rsp
lea    0xea7(%rip),%rdx
mov    %r14,%rdi
mov    $0x12,%esi
push   %rbx
push   %rax
push   %r10
call   1030 <snprintf@plt>
add    $0x20,%rsp
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [30 x i8] c"%02X:%02X:%02X:%02X:%02X:%02X\00"
define i8* @mac2string(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = call i64 @malloc(i32 18)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = load i8*, i8** %2
%8 = load i8, i8* %7
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = load i8, i8* %10
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 2
%14 = load i8, i8* %13
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 3
%17 = load i8, i8* %16
%18 = load i8*, i8** %2
%19 = getelementptr inbounds i8, i8* %18, i64 4
%20 = load i8, i8* %19
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i64 5
%23 = load i8, i8* %22
%24 = call i32 @snprintf(i8* %6, i32 18, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8 zeroext %8, i8 zeroext %11, i8 zeroext %14, i8 zeroext %17, i8 zeroext %20, i8 zeroext %23)
%25 = load i8*, i8** %3
ret i8* %25
}

LLVM IR (-O2):
@.str = [30 x i8] c"%02X:%02X:%02X:%02X:%02X:%02X\00"
define i8* @mac2string(i8* nocapture %0) {
%2 = tail call i64 @malloc(i32 18)
%3 = inttoptr i64 %2 to i8*
%4 = load i8, i8* %0
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = getelementptr inbounds i8, i8* %0, i64 2
%8 = load i8, i8* %7
%9 = getelementptr inbounds i8, i8* %0, i64 3
%10 = load i8, i8* %9
%11 = getelementptr inbounds i8, i8* %0, i64 4
%12 = load i8, i8* %11
%13 = getelementptr inbounds i8, i8* %0, i64 5
%14 = load i8, i8* %13
%15 = tail call i32 @snprintf(i8* %3, i32 18, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8 zeroext %4, i8 zeroext %6, i8 zeroext %8, i8 zeroext %10, i8 zeroext %12, i8 zeroext %14)
ret i8* %3
}