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

/* Variables and functions */
int ETHER_ADDR_LEN;
int /*<<< orphan*/ printf(char const *, ...);
void show_address(const char *header, u_char *addr) {
  int i = ETHER_ADDR_LEN;
  printf(header);
  do {
    printf("%s%2.2X", (i == ETHER_ADDR_LEN) ? " " : ":", *addr++);
  } while (--i > 0);
  printf("\n");
}


x86 assembly (clang, -O0):
<show_address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ec9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%ecx
mov    0x2eaf(%rip),%rax
mov    (%rax),%edx
lea    0xec0(%rip),%rsi
lea    0xeb7(%rip),%rax
cmp    %edx,%ecx
cmove  %rax,%rsi
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x4,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%edx
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jg     1137 <show_address+0x27>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_address>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    0x2ebb(%rip),%r15
mov    (%r15),%r12d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec2(%rip),%r13
lea    0xebd(%rip),%rbp
lea    0xeac(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    (%r15),%r12d
mov    %rbp,%rsi
cmove  %r13,%rsi
mov    (%rbx),%edx
add    $0x4,%rbx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x1(%r12),%eax
cmp    $0x1,%r12d
mov    %eax,%r12d
jg     1160 <show_address+0x40>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@ETHER_ADDR_LEN = global i32 0
@.str = [8 x i8] c"%s%2.2X\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c":\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @show_address(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%6 = load i32, i32* @ETHER_ADDR_LEN
store i32 %6, i32* %5
%7 = load i8*, i8** %3
%8 = call i32 (i8*, ...) @printf(i8* %7)
br label %9
9: ; preds = %19, %2
%10 = load i32, i32* %5
%11 = load i32, i32* @ETHER_ADDR_LEN
%12 = icmp eq i32 %10, %11
%13 = zext i1 %12 to i64
%14 = select i1 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%15 = load i32*, i32** %4
%16 = getelementptr inbounds i32, i32* %15, i32 1
store i32* %16, i32** %4
%17 = load i32, i32* %15
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %14, i32 %17)
br label %19
19: ; preds = %9
%20 = load i32, i32* %5
%21 = add nsw i32 %20, -1
store i32 %21, i32* %5
%22 = icmp sgt i32 %21, 0
br i1 %22, label %9, label %23
23: ; preds = %19
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@ETHER_ADDR_LEN = global i32 0
@.str = [8 x i8] c"%s%2.2X\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [2 x i8] c":\00"
define void @show_address(i8* nocapture %0, i32* nocapture %1) {
%3 = load i32, i32* @ETHER_ADDR_LEN
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %0)
br label %5
5: ; preds = %5, %2
%6 = phi i32* [ %1, %2 ], [ %11, %5 ]
%7 = phi i32 [ %3, %2 ], [ %14, %5 ]
%8 = load i32, i32* @ETHER_ADDR_LEN
%9 = icmp eq i32 %7, %8
%10 = select i1 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%11 = getelementptr inbounds i32, i32* %6, i64 1
%12 = load i32, i32* %6
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %10, i32 %12)
%14 = add nsw i32 %7, -1
%15 = icmp sgt i32 %7, 1
br i1 %15, label %5, label %16
16: ; preds = %5
%17 = tail call i32 @putchar(i32 10)
ret void
}