#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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char const,
                           unsigned char const, unsigned char const,
                           unsigned char const, unsigned char const,
                           unsigned char const);
char *hwaddr_to_str(const unsigned char *hwaddr) {
  static char hw_buf[18] = {0};
  memset(hw_buf, 0, 18);
  sprintf(hw_buf, "%02x:%02x:%02x:%02x:%02x:%02x", hwaddr[0], hwaddr[1],
          hwaddr[2], hwaddr[3], hwaddr[4], hwaddr[5]);
  return hw_buf;
}


x86 assembly (clang, -O0):
<hwaddr_to_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0x2f0d(%rip),%rdi
xor    %esi,%esi
mov    $0x12,%edx
call   1030 <memset@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%dl
mov    -0x8(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x8(%rbp),%rax
mov    0x2(%rax),%r8b
mov    -0x8(%rbp),%rax
mov    0x3(%rax),%r9b
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%r10b
mov    -0x8(%rbp),%rax
lea    0x2ed1(%rip),%rdi
lea    0xe8a(%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   1040 <sprintf@plt>
lea    0x2ea0(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@hwaddr_to_str.hw_buf = internal global [18 x i8] zeroinitializer
@.str = [30 x i8] c"%02x:%02x:%02x:%02x:%02x:%02x\00"
define i8* @hwaddr_to_str(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i32 @memset(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @hwaddr_to_str.hw_buf, i64 0, i64 0), 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 @sprintf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @hwaddr_to_str.hw_buf, i64 0, i64 0), 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]* @hwaddr_to_str.hw_buf, i64 0, i64 0)
}

LLVM IR (-O2):
@hwaddr_to_str.hw_buf = internal global [18 x i8] zeroinitializer
@.str = [30 x i8] c"%02x:%02x:%02x:%02x:%02x:%02x\00"
define i8* @hwaddr_to_str(i8* nocapture %0) {
%2 = tail call i32 @memset(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @hwaddr_to_str.hw_buf, i64 0, i64 0), 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 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @hwaddr_to_str.hw_buf, i64 0, i64 0), i8* dereferenceable(1) 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]* @hwaddr_to_str.hw_buf, i64 0, i64 0)
}