#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*/ sprintf(char *, char *, unsigned char, unsigned char,
                           unsigned char, unsigned char, unsigned char,
                           unsigned char);
char *convert_mac(unsigned char *ptr) {
  static char buff[64];
  sprintf(buff, "%02X:%02X:%02X:%02X:%02X:%02X", (ptr[0] & 0xFF),
          (ptr[1] & 0xFF), (ptr[2] & 0xFF), (ptr[3] & 0xFF), (ptr[4] & 0xFF),
          (ptr[5] & 0xFF));
  return (buff);
}


x86 assembly (clang, -O0):
<convert_mac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
and    $0xff,%eax
mov    %al,%dl
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%eax
and    $0xff,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
movzbl 0x2(%rax),%eax
and    $0xff,%eax
mov    %al,%r8b
mov    -0x8(%rbp),%rax
movzbl 0x3(%rax),%eax
and    $0xff,%eax
mov    %al,%r9b
mov    -0x8(%rbp),%rax
movzbl 0x4(%rax),%eax
and    $0xff,%eax
mov    %al,%r10b
mov    -0x8(%rbp),%rax
movzbl 0x5(%rax),%eax
and    $0xff,%eax
lea    0x2ec3(%rip),%rdi
lea    0xe7c(%rip),%rsi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %r9b,%r9d
movzbl %r10b,%r10d
mov    %r10d,(%rsp)
movzbl %al,%eax
mov    %eax,0x8(%rsp)
call   1030 <sprintf@plt>
lea    0x2e93(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_mac>:
push   %r14
push   %rbx
push   %rax
movzbl (%rdi),%edx
movzbl 0x1(%rdi),%ecx
movzbl 0x2(%rdi),%r8d
movzbl 0x3(%rdi),%r9d
movzbl 0x4(%rdi),%eax
movzbl 0x5(%rdi),%ebx
lea    0x2f0c(%rip),%r14
lea    0xec5(%rip),%rsi
mov    %r14,%rdi
push   %rbx
push   %rax
call   1030 <sprintf@plt>
add    $0x10,%rsp
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@convert_mac.buff = internal global [64 x i8] zeroinitializer
@.str = [30 x i8] c"%02X:%02X:%02X:%02X:%02X:%02X\00"
define i8* @convert_mac(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = getelementptr inbounds i8, i8* %3, i64 0
%5 = load i8, i8* %4
%6 = zext i8 %5 to i32
%7 = and i32 %6, 255
%8 = trunc i32 %7 to i8
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i64 1
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = and i32 %12, 255
%14 = trunc i32 %13 to i8
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 2
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = and i32 %18, 255
%20 = trunc i32 %19 to i8
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i64 3
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = and i32 %24, 255
%26 = trunc i32 %25 to i8
%27 = load i8*, i8** %2
%28 = getelementptr inbounds i8, i8* %27, i64 4
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = and i32 %30, 255
%32 = trunc i32 %31 to i8
%33 = load i8*, i8** %2
%34 = getelementptr inbounds i8, i8* %33, i64 5
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = and i32 %36, 255
%38 = trunc i32 %37 to i8
%39 = call i32 @sprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @convert_mac.buff, i64 0, i64 0), i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8 zeroext %8, i8 zeroext %14, i8 zeroext %20, i8 zeroext %26, i8 zeroext %32, i8 zeroext %38)
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @convert_mac.buff, i64 0, i64 0)
}

LLVM IR (-O2):
@convert_mac.buff = internal global [64 x i8] zeroinitializer
@.str = [30 x i8] c"%02X:%02X:%02X:%02X:%02X:%02X\00"
define i8* @convert_mac(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = getelementptr inbounds i8, i8* %0, i64 1
%4 = load i8, i8* %3
%5 = getelementptr inbounds i8, i8* %0, i64 2
%6 = load i8, i8* %5
%7 = getelementptr inbounds i8, i8* %0, i64 3
%8 = load i8, i8* %7
%9 = getelementptr inbounds i8, i8* %0, i64 4
%10 = load i8, i8* %9
%11 = getelementptr inbounds i8, i8* %0, i64 5
%12 = load i8, i8* %11
%13 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @convert_mac.buff, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8 zeroext %2, i8 zeroext %4, i8 zeroext %6, i8 zeroext %8, i8 zeroext %10, i8 zeroext %12)
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @convert_mac.buff, i64 0, i64 0)
}