#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 */
char *PSTR(char *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char, unsigned char,
                           unsigned char, unsigned char, unsigned char,
                           unsigned char);
char *eth2ascii(unsigned char *eth) {
  static char buf[18];
  sprintf(buf, PSTR("%02x:%02x:%02x:%02x:%02x:%02x"), (unsigned char)eth[0],
          (unsigned char)eth[1], (unsigned char)eth[2], (unsigned char)eth[3],
          (unsigned char)eth[4], (unsigned char)eth[5]);
  return buf;
}


x86 assembly (clang, -O0):
<eth2ascii>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rdi
call   1030 <PSTR@plt>
mov    %rax,%rsi
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    0x2ed5(%rip),%rdi
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    0x2eab(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eth2ascii>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xed2(%rip),%rdi
call   1030 <PSTR@plt>
movzbl (%rbx),%edx
movzbl 0x1(%rbx),%ecx
movzbl 0x2(%rbx),%r8d
movzbl 0x3(%rbx),%r9d
movzbl 0x4(%rbx),%r10d
movzbl 0x5(%rbx),%ebx
lea    0x2eec(%rip),%r14
mov    %r14,%rdi
mov    %rax,%rsi
push   %rbx
push   %r10
call   1040 <sprintf@plt>
add    $0x10,%rsp
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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