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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int const);
void print_mac_address(const uint8_t *ptr, size_t len) {
  while (len > 1) {
    printf("%02X:", *ptr);
    ptr++;
    len--;
  }
  if (len == 1)
    printf("%02X\n", *ptr);
}


x86 assembly (clang, -O0):
<print_mac_address>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x1,-0x10(%rbp)
jbe    115a <print_mac_address+0x4a>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1120 <print_mac_address+0x10>
cmpq   $0x1,-0x10(%rbp)
jne    1177 <print_mac_address+0x67>
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
lea    0xe94(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_mac_address>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
cmp    $0x2,%rsi
jb     114b <print_mac_address+0x3b>
lea    0xed8(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    (%r14),%esi
mov    %r15,%rdi
call   1030 <printf@plt>
add    $0x4,%r14
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1130 <print_mac_address+0x20>
jmp    1151 <print_mac_address+0x41>
cmp    $0x1,%rbx
jne    1165 <print_mac_address+0x55>
mov    (%r14),%esi
lea    0xeab(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <printf@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

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

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