#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*/ snprintf(char *, int, char *, unsigned char const,
                            unsigned char const, unsigned char const,
                            unsigned char const, unsigned char const,
                            unsigned char const, unsigned char const,
                            unsigned char const);
const char *format_eui64(const unsigned char *eui) {
  static char buf[4][28];
  static int i = 0;
  i = (i + 1) % 4;
  snprintf(buf[i], 28, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", eui[0],
           eui[1], eui[2], eui[3], eui[4], eui[5], eui[6], eui[7]);
  return buf[i];
}


x86 assembly (clang, -O0):
<format_eui64>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %rdi,-0x18(%rbp)
mov    0x2f8b(%rip),%eax
add    $0x1,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,0x2f7a(%rip)
movslq 0x2f73(%rip),%rax
lea    0x2efc(%rip),%rdi
imul   $0x1c,%rax,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    0x1(%rax),%r8b
mov    -0x18(%rbp),%rax
mov    0x2(%rax),%r9b
mov    -0x18(%rbp),%rax
mov    0x3(%rax),%r14b
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%bl
mov    -0x18(%rbp),%rax
mov    0x5(%rax),%r11b
mov    -0x18(%rbp),%rax
mov    0x6(%rax),%r10b
mov    -0x18(%rbp),%rax
mov    $0x1c,%esi
lea    0xe70(%rip),%rdx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %r9b,%r9d
movzbl %r14b,%r14d
mov    %r14d,(%rsp)
movzbl %bl,%ebx
mov    %ebx,0x8(%rsp)
movzbl %r11b,%r11d
mov    %r11d,0x10(%rsp)
movzbl %r10b,%r10d
mov    %r10d,0x18(%rsp)
movzbl 0x7(%rax),%eax
mov    %eax,0x20(%rsp)
call   1030 <snprintf@plt>
movslq 0x2ee0(%rip),%rcx
lea    0x2e69(%rip),%rax
imul   $0x1c,%rcx,%rcx
add    %rcx,%rax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_eui64>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2f92(%rip),%eax
lea    0x1(%rax),%ecx
lea    0x4(%rax),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
and    $0xfffffffc,%edx
neg    %edx
lea    (%rax,%rdx,1),%ecx
add    $0x1,%ecx
mov    %ecx,0x2f76(%rip)
lea    (%rcx,%rcx,8),%rax
lea    (%rax,%rax,2),%rax
add    %rcx,%rax
lea    0x2ef4(%rip),%r14
add    %r14,%rax
movzbl (%rdi),%ecx
movzbl 0x1(%rdi),%r8d
movzbl 0x2(%rdi),%r9d
movzbl 0x3(%rdi),%r10d
movzbl 0x4(%rdi),%r11d
movzbl 0x5(%rdi),%r15d
movzbl 0x6(%rdi),%r12d
movzbl 0x7(%rdi),%ebx
sub    $0x8,%rsp
lea    0xe81(%rip),%rdx
mov    %rax,%rdi
mov    $0x1c,%esi
push   %rbx
push   %r12
push   %r15
push   %r11
push   %r10
call   1030 <snprintf@plt>
add    $0x30,%rsp
mov    0x2f11(%rip),%ecx
lea    (%rcx,%rcx,8),%rax
lea    (%rax,%rax,2),%rax
add    %rcx,%rax
add    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@format_eui64.buf = internal global [4 x [28 x i8]] zeroinitializer
@format_eui64.i = internal global i32 0
@.str = [40 x i8] c"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\00"
define i8* @format_eui64(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @format_eui64.i
%4 = add nsw i32 %3, 1
%5 = srem i32 %4, 4
store i32 %5, i32* @format_eui64.i
%6 = load i32, i32* @format_eui64.i
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [4 x [28 x i8]], [4 x [28 x i8]]* @format_eui64.buf, i64 0, i64 %7
%9 = getelementptr inbounds [28 x i8], [28 x i8]* %8, i64 0, i64 0
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %14
%16 = load i8*, i8** %2
%17 = getelementptr inbounds i8, i8* %16, i64 2
%18 = load i8, i8* %17
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i64 3
%21 = load i8, i8* %20
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i64 4
%24 = load i8, i8* %23
%25 = load i8*, i8** %2
%26 = getelementptr inbounds i8, i8* %25, i64 5
%27 = load i8, i8* %26
%28 = load i8*, i8** %2
%29 = getelementptr inbounds i8, i8* %28, i64 6
%30 = load i8, i8* %29
%31 = load i8*, i8** %2
%32 = getelementptr inbounds i8, i8* %31, i64 7
%33 = load i8, i8* %32
%34 = call i32 @snprintf(i8* %9, i32 28, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i8 zeroext %12, i8 zeroext %15, i8 zeroext %18, i8 zeroext %21, i8 zeroext %24, i8 zeroext %27, i8 zeroext %30, i8 zeroext %33)
%35 = load i32, i32* @format_eui64.i
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [4 x [28 x i8]], [4 x [28 x i8]]* @format_eui64.buf, i64 0, i64 %36
%38 = getelementptr inbounds [28 x i8], [28 x i8]* %37, i64 0, i64 0
ret i8* %38
}

LLVM IR (-O2):
@format_eui64.buf = internal global [4 x [28 x i8]] zeroinitializer
@format_eui64.i = internal unnamed_addr global i32 0
@.str = [40 x i8] c"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\00"
define i8* @format_eui64(i8* nocapture %0) {
%2 = load i32, i32* @format_eui64.i
%3 = add nsw i32 %2, 1
%4 = srem i32 %3, 4
store i32 %4, i32* @format_eui64.i
%5 = zext i32 %4 to i64
%6 = getelementptr inbounds [4 x [28 x i8]], [4 x [28 x i8]]* @format_eui64.buf, i64 0, i64 %5, i64 0
%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 = getelementptr inbounds i8, i8* %0, i64 6
%19 = load i8, i8* %18
%20 = getelementptr inbounds i8, i8* %0, i64 7
%21 = load i8, i8* %20
%22 = tail call i32 @snprintf(i8* %6, i32 28, i8* getelementptr inbounds ([40 x i8], [40 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, i8 zeroext %19, i8 zeroext %21)
%23 = load i32, i32* @format_eui64.i
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds [4 x [28 x i8]], [4 x [28 x i8]]* @format_eui64.buf, i64 0, i64 %24, i64 0
ret i8* %25
}