#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*/ console_print_string(char const *);
int /*<<< orphan*/ console_put_hex8(char);
void print_mac(const char *str, char *mac) {
  console_print_string(str);
  for (int i = 0; i < 6; i++) {
    if (i)
      console_print_string(":");
    console_put_hex8(mac[i]);
  }
}


x86 assembly (clang, -O0):
<print_mac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <console_print_string@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x6,-0x14(%rbp)
jge    117f <print_mac+0x5f>
cmpl   $0x0,-0x14(%rbp)
je     1160 <print_mac+0x40>
lea    0xea5(%rip),%rdi
call   1030 <console_print_string@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <console_put_hex8@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1140 <print_mac+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_mac>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
call   1030 <console_print_string@plt>
movsbl (%rbx),%edi
call   1040 <console_put_hex8@plt>
lea    0xec5(%rip),%r14
mov    %r14,%rdi
call   1030 <console_print_string@plt>
movsbl 0x1(%rbx),%edi
call   1040 <console_put_hex8@plt>
mov    %r14,%rdi
call   1030 <console_print_string@plt>
movsbl 0x2(%rbx),%edi
call   1040 <console_put_hex8@plt>
mov    %r14,%rdi
call   1030 <console_print_string@plt>
movsbl 0x3(%rbx),%edi
call   1040 <console_put_hex8@plt>
mov    %r14,%rdi
call   1030 <console_print_string@plt>
movsbl 0x4(%rbx),%edi
call   1040 <console_put_hex8@plt>
mov    %r14,%rdi
call   1030 <console_print_string@plt>
movsbl 0x5(%rbx),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <console_put_hex8@plt>

LLVM IR (-O0):
@.str = [2 x i8] c":\00"
define void @print_mac(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %3
%7 = call i32 @console_print_string(i8* %6)
store i32 0, i32* %5
br label %8
8: ; preds = %23, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 6
br i1 %10, label %11, label %26
11: ; preds = %8
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @console_print_string(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
%17 = load i8*, i8** %4
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = call i32 @console_put_hex8(i8 signext %21)
br label %23
23: ; preds = %16
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 1
store i32 %25, i32* %5
br label %8
26: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c":\00"
define void @print_mac(i8* %0, i8* nocapture %1) {
%3 = tail call i32 @console_print_string(i8* %0)
%4 = load i8, i8* %1
%5 = tail call i32 @console_put_hex8(i8 signext %4)
%6 = tail call i32 @console_print_string(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds i8, i8* %1, i64 1
%8 = load i8, i8* %7
%9 = tail call i32 @console_put_hex8(i8 signext %8)
%10 = tail call i32 @console_print_string(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds i8, i8* %1, i64 2
%12 = load i8, i8* %11
%13 = tail call i32 @console_put_hex8(i8 signext %12)
%14 = tail call i32 @console_print_string(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = getelementptr inbounds i8, i8* %1, i64 3
%16 = load i8, i8* %15
%17 = tail call i32 @console_put_hex8(i8 signext %16)
%18 = tail call i32 @console_print_string(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%19 = getelementptr inbounds i8, i8* %1, i64 4
%20 = load i8, i8* %19
%21 = tail call i32 @console_put_hex8(i8 signext %20)
%22 = tail call i32 @console_print_string(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%23 = getelementptr inbounds i8, i8* %1, i64 5
%24 = load i8, i8* %23
%25 = tail call i32 @console_put_hex8(i8 signext %24)
ret void
}