#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 uint8_t;
typedef int /*<<< orphan*/ macstr;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int, int, int, int);
char *mac_to_str(uint8_t *mac) {
  static char macstr[20];
  snprintf(macstr, sizeof(macstr), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0],
           mac[1], mac[2], mac[3], mac[4], mac[5]);
  return macstr;
}


x86 assembly (clang, -O0):
<mac_to_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%r9d
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%r11d
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%r10d
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%eax
lea    0x2ef0(%rip),%rdi
mov    $0x14,%esi
lea    0xea4(%rip),%rdx
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1030 <snprintf@plt>
lea    0x2ecb(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mac_to_str>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%ecx
mov    0x4(%rdi),%r8d
mov    0x8(%rdi),%r9d
mov    0xc(%rdi),%r10d
mov    0x10(%rdi),%ebx
mov    0x14(%rdi),%eax
sub    $0x8,%rsp
lea    0x2f0d(%rip),%r14
lea    0xec6(%rip),%rdx
mov    %r14,%rdi
mov    $0x14,%esi
push   %rax
push   %rbx
push   %r10
call   1030 <snprintf@plt>
add    $0x20,%rsp
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@mac_to_str.macstr = internal global [20 x i8] zeroinitializer
@.str = [30 x i8] c"%02x:%02x:%02x:%02x:%02x:%02x\00"
define i8* @mac_to_str(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = getelementptr inbounds i32, i32* %3, i64 0
%5 = load i32, i32* %4
%6 = load i32*, i32** %2
%7 = getelementptr inbounds i32, i32* %6, i64 1
%8 = load i32, i32* %7
%9 = load i32*, i32** %2
%10 = getelementptr inbounds i32, i32* %9, i64 2
%11 = load i32, i32* %10
%12 = load i32*, i32** %2
%13 = getelementptr inbounds i32, i32* %12, i64 3
%14 = load i32, i32* %13
%15 = load i32*, i32** %2
%16 = getelementptr inbounds i32, i32* %15, i64 4
%17 = load i32, i32* %16
%18 = load i32*, i32** %2
%19 = getelementptr inbounds i32, i32* %18, i64 5
%20 = load i32, i32* %19
%21 = call i32 @snprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @mac_to_str.macstr, i64 0, i64 0), i32 20, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %8, i32 %11, i32 %14, i32 %17, i32 %20)
ret i8* getelementptr inbounds ([20 x i8], [20 x i8]* @mac_to_str.macstr, i64 0, i64 0)
}

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