#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*/ printf(char *, ...);
void printMac(char *payload) {
  for (int i = 0 + 6; i < 6 + 6; i++) {
    if (i > 0 + 6)
      printf(":");
    printf("%X", (int)(*(unsigned char *)(&payload[i])));
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printMac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x6,-0xc(%rbp)
cmpl   $0xc,-0xc(%rbp)
jge    116d <printMac+0x5d>
cmpl   $0x6,-0xc(%rbp)
jle    1145 <printMac+0x35>
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <printMac+0x13>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printMac>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
movzbl 0x6(%rdi),%esi
lea    0xece(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x3a,%edi
call   1030 <putchar@plt>
movzbl 0x7(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x3a,%edi
call   1030 <putchar@plt>
movzbl 0x8(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x3a,%edi
call   1030 <putchar@plt>
movzbl 0x9(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x3a,%edi
call   1030 <putchar@plt>
movzbl 0xa(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x3a,%edi
call   1030 <putchar@plt>
movzbl 0xb(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%X\00"
define void @printMac(i8* nocapture %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 6
%3 = load i8, i8* %2
%4 = zext i8 %3 to i32
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %4)
%6 = tail call i32 @putchar(i32 58)
%7 = getelementptr inbounds i8, i8* %0, i64 7
%8 = load i8, i8* %7
%9 = zext i8 %8 to i32
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = tail call i32 @putchar(i32 58)
%12 = getelementptr inbounds i8, i8* %0, i64 8
%13 = load i8, i8* %12
%14 = zext i8 %13 to i32
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = tail call i32 @putchar(i32 58)
%17 = getelementptr inbounds i8, i8* %0, i64 9
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = tail call i32 @putchar(i32 58)
%22 = getelementptr inbounds i8, i8* %0, i64 10
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = tail call i32 @putchar(i32 58)
%27 = getelementptr inbounds i8, i8* %0, i64 11
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = tail call i32 @putchar(i32 10)
ret void
}