#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*/ sprintf(char *, char *, ...);
char *print_mac(char *buff, unsigned char *mac, int len) {
  char *p = buff;
  int i;
  if (len == 0)
    sprintf(p, "<null>");
  else
    for (i = 0; i < len; i++)
      p += sprintf(p, "%.2x%s", mac[i], (i == len - 1) ? "" : ":");
  return buff;
}


x86 assembly (clang, -O0):
<print_mac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    114c <print_mac+0x3c>
mov    -0x20(%rbp),%rdi
lea    0xec0(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    11c0 <print_mac+0xb0>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11bb <print_mac+0xab>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
mov    -0x24(%rbp),%esi
mov    -0x14(%rbp),%r8d
sub    $0x1,%r8d
lea    0xe8d(%rip),%rcx
lea    0xe87(%rip),%rax
cmp    %r8d,%esi
cmove  %rax,%rcx
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1153 <print_mac+0x43>
jmp    11c0 <print_mac+0xb0>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_mac>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
mov    %rdi,(%rsp)
je     1177 <print_mac+0x67>
jle    1184 <print_mac+0x74>
mov    %rsi,%r12
lea    -0x1(%rdx),%r13d
mov    %edx,%ebp
lea    0xed2(%rip),%r15
xor    %r14d,%r14d
mov    (%rsp),%rbx
nopl   0x0(%rax)
movzbl (%r12,%r14,1),%edx
cmp    %r14,%r13
lea    0xebf(%rip),%rcx
lea    0xeb9(%rip),%rax
cmove  %rax,%rcx
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1030 <sprintf@plt>
cltq
add    %rax,%rbx
add    $0x1,%r14
cmp    %r14,%rbp
jne    1140 <print_mac+0x30>
jmp    1184 <print_mac+0x74>
movl   $0x3e6c6c,0x3(%rdi)
movl   $0x6c756e3c,(%rdi)
mov    (%rsp),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"<null>\00"
@.str.1 = [7 x i8] c"%.2x%s\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c":\00"
define i8* @print_mac(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = load i8*, i8** %4
store i8* %9, i8** %7
%10 = load i32, i32* %6
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load i8*, i8** %7
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %42
15: ; preds = %3
store i32 0, i32* %8
br label %16
16: ; preds = %38, %15
%17 = load i32, i32* %8
%18 = load i32, i32* %6
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %41
20: ; preds = %16
%21 = load i8*, i8** %7
%22 = load i8*, i8** %5
%23 = load i32, i32* %8
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = load i32, i32* %8
%29 = load i32, i32* %6
%30 = sub nsw i32 %29, 1
%31 = icmp eq i32 %28, %30
%32 = zext i1 %31 to i64
%33 = select i1 %31, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%34 = call i32 (i8*, i8*, ...) @sprintf(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %27, i8* %33)
%35 = load i8*, i8** %7
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds i8, i8* %35, i64 %36
store i8* %37, i8** %7
br label %38
38: ; preds = %20
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
br label %16
41: ; preds = %16
br label %42
42: ; preds = %41, %12
%43 = load i8*, i8** %4
ret i8* %43
}

LLVM IR (-O2):
@.str = [7 x i8] c"<null>\00"
@.str.1 = [7 x i8] c"%.2x%s\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [2 x i8] c":\00"
define i8* @print_mac(i8* returned writeonly %0, i8* nocapture %1, i32 %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %11, label %5
5: ; preds = %3
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %25
7: ; preds = %5
%8 = add nsw i32 %2, -1
%9 = zext i32 %8 to i64
%10 = zext i32 %2 to i64
br label %12
11: ; preds = %3
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(7) %0, i8* align 1 dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 7, i1 false)
br label %25
12: ; preds = %7, %12
%13 = phi i64 [ 0, %7 ], [ %23, %12 ]
%14 = phi i8* [ %0, %7 ], [ %22, %12 ]
%15 = getelementptr inbounds i8, i8* %1, i64 %13
%16 = load i8, i8* %15
%17 = zext i8 %16 to i32
%18 = icmp eq i64 %13, %9
%19 = select i1 %18, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
%20 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %14, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %17, i8* %19)
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %14, i64 %21
%23 = add nuw nsw i64 %13, 1
%24 = icmp eq i64 %23, %10
br i1 %24, label %25, label %12
25: ; preds = %12, %5, %11
ret i8* %0
}