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


x86 assembly (clang, -O0):
<format_32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2f5e(%rip),%eax
add    $0x1,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,0x2f4d(%rip)
movslq 0x2f46(%rip),%rax
lea    0x2eff(%rip),%rdi
shl    $0x4,%rax
add    %rax,%rdi
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    $0x10,%esi
lea    0xe92(%rip),%rdx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %r9b,%r9d
movzbl 0x3(%rax),%eax
mov    %eax,(%rsp)
call   1030 <snprintf@plt>
movslq 0x2ef4(%rip),%rcx
lea    0x2ead(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_32>:
push   %rbx
sub    $0x10,%rsp
mov    0x2f65(%rip),%eax
lea    0x1(%rax),%ecx
lea    0x4(%rax),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
and    $0xfffffffc,%edx
neg    %edx
add    %edx,%eax
add    $0x1,%eax
mov    %eax,0x2f4a(%rip)
shl    $0x4,%rax
lea    0x2eff(%rip),%rbx
add    %rbx,%rax
movzbl (%rdi),%ecx
movzbl 0x1(%rdi),%r8d
movzbl 0x2(%rdi),%r9d
movzbl 0x3(%rdi),%edx
mov    %edx,(%rsp)
lea    0xea1(%rip),%rdx
mov    %rax,%rdi
mov    $0x10,%esi
call   1030 <snprintf@plt>
mov    0x2f0e(%rip),%eax
shl    $0x4,%rax
add    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@format_32.buf = internal global [4 x [16 x i8]] zeroinitializer
@format_32.i = internal global i32 0
@.str = [20 x i8] c"%02x:%02x:%02x:%02x\00"
define i8* @format_32(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @format_32.i
%4 = add nsw i32 %3, 1
%5 = srem i32 %4, 4
store i32 %5, i32* @format_32.i
%6 = load i32, i32* @format_32.i
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [4 x [16 x i8]], [4 x [16 x i8]]* @format_32.buf, i64 0, i64 %7
%9 = getelementptr inbounds [16 x i8], [16 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 = call i32 @snprintf(i8* %9, i32 16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8 zeroext %12, i8 zeroext %15, i8 zeroext %18, i8 zeroext %21)
%23 = load i32, i32* @format_32.i
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [4 x [16 x i8]], [4 x [16 x i8]]* @format_32.buf, i64 0, i64 %24
%26 = getelementptr inbounds [16 x i8], [16 x i8]* %25, i64 0, i64 0
ret i8* %26
}

LLVM IR (-O2):
@format_32.buf = internal global [4 x [16 x i8]] zeroinitializer
@format_32.i = internal unnamed_addr global i32 0
@.str = [20 x i8] c"%02x:%02x:%02x:%02x\00"
define i8* @format_32(i8* nocapture %0) {
%2 = load i32, i32* @format_32.i
%3 = add nsw i32 %2, 1
%4 = srem i32 %3, 4
store i32 %4, i32* @format_32.i
%5 = zext i32 %4 to i64
%6 = getelementptr inbounds [4 x [16 x i8]], [4 x [16 x i8]]* @format_32.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 = tail call i32 @snprintf(i8* %6, i32 16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8 zeroext %7, i8 zeroext %9, i8 zeroext %11, i8 zeroext %13)
%15 = load i32, i32* @format_32.i
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds [4 x [16 x i8]], [4 x [16 x i8]]* @format_32.buf, i64 0, i64 %16, i64 0
ret i8* %17
}