#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 ETHER_ADDR_LEN;
int /*<<< orphan*/ printf(char *, ...);
void print_macstr(unsigned char *mac) {
  int i;
  for (i = 0; i < ETHER_ADDR_LEN; i++) {
    printf("%02x", mac[i]);
    if (i != ETHER_ADDR_LEN - 1)
      printf(":");
  }
}


x86 assembly (clang, -O0):
<print_macstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2ec3(%rip),%rcx
cmp    (%rcx),%eax
jge    1187 <print_macstr+0x77>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
mov    0x2e97(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     1174 <print_macstr+0x64>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1179 <print_macstr+0x69>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <print_macstr+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_macstr>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x2ec1(%rip),%r15
cmpl   $0x0,(%r15)
jle    1184 <print_macstr+0x64>
mov    %rdi,%r12
lea    0xec1(%rip),%r14
xor    %ebx,%ebx
jmp    115b <print_macstr+0x3b>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cltq
cmp    %rax,%rbx
jge    1184 <print_macstr+0x64>
movzbl (%r12,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r15),%eax
lea    -0x1(%rax),%ecx
cmp    %rcx,%rbx
je     1150 <print_macstr+0x30>
mov    $0x3a,%edi
call   1030 <putchar@plt>
mov    (%r15),%eax
jmp    1150 <print_macstr+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@ETHER_ADDR_LEN = global i32 0
@.str = [5 x i8] c"%02x\00"
define void @print_macstr(i8* nocapture %0) {
%2 = load i32, i32* @ETHER_ADDR_LEN
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %22
4: ; preds = %1, %17
%5 = phi i64 [ %19, %17 ], [ 0, %1 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = zext i8 %7 to i32
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = load i32, i32* @ETHER_ADDR_LEN
%11 = add nsw i32 %10, -1
%12 = zext i32 %11 to i64
%13 = icmp eq i64 %5, %12
br i1 %13, label %17, label %14
14: ; preds = %4
%15 = tail call i32 @putchar(i32 58)
%16 = load i32, i32* @ETHER_ADDR_LEN
br label %17
17: ; preds = %4, %14
%18 = phi i32 [ %10, %4 ], [ %16, %14 ]
%19 = add nuw nsw i64 %5, 1
%20 = sext i32 %18 to i64
%21 = icmp slt i64 %19, %20
br i1 %21, label %4, label %22
22: ; preds = %17, %1
ret void
}