#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);
long utilMac2MacStr(unsigned char *byMac, char *sBuf) {
  if (byMac == (0) || sBuf == (0))
    return (-1);
  sprintf(sBuf, "%02x:%02x:%02x:%02x:%02x:%02x", byMac[0], byMac[1], byMac[2],
          byMac[3], byMac[4], byMac[5]);
  return (0);
}


x86 assembly (clang, -O0):
<utilMac2MacStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1136 <utilMac2MacStr+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1143 <utilMac2MacStr+0x33>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11a2 <utilMac2MacStr+0x92>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%dl
mov    -0x10(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x10(%rbp),%rax
mov    0x2(%rax),%r8b
mov    -0x10(%rbp),%rax
mov    0x3(%rax),%r9b
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%r10b
mov    -0x10(%rbp),%rax
lea    0xe89(%rip),%rsi
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %r9b,%r9d
movzbl %r10b,%r10d
mov    %r10d,(%rsp)
movzbl 0x5(%rax),%eax
mov    %eax,0x8(%rsp)
call   1030 <sprintf@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utilMac2MacStr>:
mov    $0xffffffffffffffff,%rax
test   %rdi,%rdi
je     115b <utilMac2MacStr+0x4b>
test   %rsi,%rsi
je     115b <utilMac2MacStr+0x4b>
push   %rax
movzbl (%rdi),%edx
movzbl 0x1(%rdi),%ecx
movzbl 0x2(%rdi),%r8d
movzbl 0x3(%rdi),%r9d
movzbl 0x4(%rdi),%r11d
movzbl 0x5(%rdi),%eax
lea    0xebd(%rip),%r10
mov    %rsi,%rdi
mov    %r10,%rsi
push   %rax
push   %r11
call   1030 <sprintf@plt>
add    $0x10,%rsp
xor    %eax,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"%02x:%02x:%02x:%02x:%02x:%02x\00"
define i64 @utilMac2MacStr(i8* %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %4
%7 = icmp eq i8* %6, null
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i8*, i8** %5
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %8, %2
store i64 -1, i64* %3
br label %33
12: ; preds = %8
%13 = load i8*, i8** %5
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i64 2
%22 = load i8, i8* %21
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 3
%25 = load i8, i8* %24
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 4
%28 = load i8, i8* %27
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i64 5
%31 = load i8, i8* %30
%32 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8 zeroext %16, i8 zeroext %19, i8 zeroext %22, i8 zeroext %25, i8 zeroext %28, i8 zeroext %31)
store i64 0, i64* %3
br label %33
33: ; preds = %12, %11
%34 = load i64, i64* %3
ret i64 %34
}

LLVM IR (-O2):
@.str = [30 x i8] c"%02x:%02x:%02x:%02x:%02x:%02x\00"
define i64 @utilMac2MacStr(i8* %0, i8* writeonly %1) {
%3 = icmp eq i8* %0, null
%4 = icmp eq i8* %1, null
%5 = or i1 %3, %4
br i1 %5, label %19, label %6
6: ; preds = %2
%7 = load i8, i8* %0
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = getelementptr inbounds i8, i8* %0, i64 2
%11 = load i8, i8* %10
%12 = getelementptr inbounds i8, i8* %0, i64 3
%13 = load i8, i8* %12
%14 = getelementptr inbounds i8, i8* %0, i64 4
%15 = load i8, i8* %14
%16 = getelementptr inbounds i8, i8* %0, i64 5
%17 = load i8, i8* %16
%18 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8 zeroext %7, i8 zeroext %9, i8 zeroext %11, i8 zeroext %13, i8 zeroext %15, i8 zeroext %17)
br label %19
19: ; preds = %2, %6
%20 = phi i64 [ 0, %6 ], [ -1, %2 ]
ret i64 %20
}