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

/* Variables and functions */
int /*<<< orphan*/ memset(char **, int /*<<< orphan*/, int);
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned char, unsigned char,
                            unsigned char, unsigned char, unsigned char,
                            unsigned char);
char *printmac(unsigned char *mac) {
  static char macstring[18];
  memset(&macstring, 0, sizeof(macstring));
  (void)snprintf(macstring, sizeof(macstring), "%02x:%02x:%02x:%02x:%02x:%02x",
                 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  return (macstring);
}


x86 assembly (clang, -O0):
<printmac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f0d(%rip),%rdi
xor    %esi,%esi
mov    $0x12,%edx
call   1040 <memset@plt>
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
lea    0x2ed0(%rip),%rdi
mov    $0x12,%esi
lea    0xe84(%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>
lea    0x2e94(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printmac>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0x2f12(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x12,%edx
call   1040 <memset@plt>
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    0xe9e(%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):
@printmac.macstring = internal global [18 x i8] zeroinitializer
@.str = [30 x i8] c"%02x:%02x:%02x:%02x:%02x:%02x\00"
define i8* @printmac(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i32 @memset(i8** bitcast ([18 x i8]* @printmac.macstring to i8**), i32 0, i32 18)
%4 = load i8*, i8** %2
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = load i8*, i8** %2
%8 = getelementptr inbounds i8, i8* %7, i64 1
%9 = load i8, i8* %8
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i64 2
%12 = load i8, i8* %11
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 3
%15 = load i8, i8* %14
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i64 4
%18 = load i8, i8* %17
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i64 5
%21 = load i8, i8* %20
%22 = call i32 @snprintf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @printmac.macstring, i64 0, i64 0), i32 18, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8 zeroext %6, i8 zeroext %9, i8 zeroext %12, i8 zeroext %15, i8 zeroext %18, i8 zeroext %21)
ret i8* getelementptr inbounds ([18 x i8], [18 x i8]* @printmac.macstring, i64 0, i64 0)
}

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