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

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, int, int, int, int, int, int);
char *fh_net_hwtoa(uint8_t *hwaddr) {
  static char b[32 * 10];
  static int buf_index = 0;
  register char *src, *dst;
  register int i = buf_index++ % 10;
  src = (char *)hwaddr;
  dst = (char *)b + i * 32;
  sprintf(dst, "%02X:%02X:%02X:%02X:%02X:%02X", (((int)src[0]) & 0xff),
          (((int)src[1]) & 0xff), (((int)src[2]) & 0xff),
          (((int)src[3]) & 0xff), (((int)src[4]) & 0xff),
          (((int)src[5]) & 0xff));
  return dst;
}


x86 assembly (clang, -O0):
<fh_net_hwtoa>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x305e(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x3053(%rip)
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
shl    $0x5,%eax
movslq %eax,%rcx
lea    0x2ef0(%rip),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
movsbl (%rax),%edx
and    $0xff,%edx
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%ecx
and    $0xff,%ecx
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%r8d
and    $0xff,%r8d
mov    -0x10(%rbp),%rax
movsbl 0x3(%rax),%r9d
and    $0xff,%r9d
mov    -0x10(%rbp),%rax
movsbl 0x4(%rax),%r10d
and    $0xff,%r10d
mov    -0x10(%rbp),%rax
movsbl 0x5(%rax),%eax
and    $0xff,%eax
lea    0xe46(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <sprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fh_net_hwtoa>:
push   %rbx
movslq 0x3068(%rip),%rax
lea    0x1(%rax),%ecx
mov    %ecx,0x305f(%rip)
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
shl    $0x5,%eax
cltq
lea    0x2ef8(%rip),%rbx
add    %rax,%rbx
movzbl (%rdi),%edx
movzbl 0x1(%rdi),%ecx
movzbl 0x2(%rdi),%r8d
movzbl 0x3(%rdi),%r9d
movzbl 0x4(%rdi),%r10d
movzbl 0x5(%rdi),%eax
lea    0xe94(%rip),%rsi
mov    %rbx,%rdi
push   %rax
push   %r10
call   1030 <sprintf@plt>
add    $0x10,%rsp
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@fh_net_hwtoa.b = internal global [320 x i8] zeroinitializer
@fh_net_hwtoa.buf_index = internal global i32 0
@.str = [30 x i8] c"%02X:%02X:%02X:%02X:%02X:%02X\00"
define i8* @fh_net_hwtoa(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i32* %0, i32** %2
%6 = load i32, i32* @fh_net_hwtoa.buf_index
%7 = add nsw i32 %6, 1
store i32 %7, i32* @fh_net_hwtoa.buf_index
%8 = srem i32 %6, 10
store i32 %8, i32* %5
%9 = load i32*, i32** %2
%10 = bitcast i32* %9 to i8*
store i8* %10, i8** %3
%11 = load i32, i32* %5
%12 = mul nsw i32 %11, 32
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* getelementptr inbounds ([320 x i8], [320 x i8]* @fh_net_hwtoa.b, i64 0, i64 0), i64 %13
store i8* %14, i8** %4
%15 = load i8*, i8** %4
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = and i32 %19, 255
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 1
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = and i32 %24, 255
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 2
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = and i32 %29, 255
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i64 3
%33 = load i8, i8* %32
%34 = sext i8 %33 to i32
%35 = and i32 %34, 255
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i64 4
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = and i32 %39, 255
%41 = load i8*, i8** %3
%42 = getelementptr inbounds i8, i8* %41, i64 5
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = and i32 %44, 255
%46 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %25, i32 %30, i32 %35, i32 %40, i32 %45)
%47 = load i8*, i8** %4
ret i8* %47
}

LLVM IR (-O2):
@fh_net_hwtoa.b = internal global [320 x i8] zeroinitializer
@fh_net_hwtoa.buf_index = internal unnamed_addr global i32 0
@.str = [30 x i8] c"%02X:%02X:%02X:%02X:%02X:%02X\00"
define i8* @fh_net_hwtoa(i32* nocapture %0) {
%2 = load i32, i32* @fh_net_hwtoa.buf_index
%3 = add nsw i32 %2, 1
store i32 %3, i32* @fh_net_hwtoa.buf_index
%4 = srem i32 %2, 10
%5 = bitcast i32* %0 to i8*
%6 = shl nsw i32 %4, 5
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [320 x i8], [320 x i8]* @fh_net_hwtoa.b, i64 0, i64 %7
%9 = load i8, i8* %5
%10 = zext i8 %9 to i32
%11 = getelementptr inbounds i8, i8* %5, i64 1
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = getelementptr inbounds i8, i8* %5, i64 2
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = getelementptr inbounds i8, i8* %5, i64 3
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = getelementptr inbounds i32, i32* %0, i64 1
%21 = bitcast i32* %20 to i8*
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = getelementptr inbounds i8, i8* %5, i64 5
%25 = load i8, i8* %24
%26 = zext i8 %25 to i32
%27 = tail call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %13, i32 %16, i32 %19, i32 %23, i32 %26)
ret i8* %8
}