#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 ETH_ALEN;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int const);
int /*<<< orphan*/ stdout;
void ethernet_print_mac(const uint8_t ether_dhost[ETH_ALEN]) {
  for (int i = 0; i < (ETH_ALEN - 1); i++) {
    fprintf(stdout, "%x:", ether_dhost[i]);
  }
  fprintf(stdout, "%x", ether_dhost[ETH_ALEN - 1]);
}


x86 assembly (clang, -O0):
<ethernet_print_mac>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2ebb(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1168 <ethernet_print_mac+0x58>
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xeab(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <ethernet_print_mac+0x13>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x2e6c(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe76(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ethernet_print_mac>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r12
mov    0x2ec5(%rip),%r15
movslq (%r15),%rax
cmp    $0x2,%rax
jl     1162 <ethernet_print_mac+0x52>
xor    %ebx,%ebx
mov    0x2ea3(%rip),%r13
lea    0xec4(%rip),%r14
nopl   0x0(%rax)
mov    0x0(%r13),%edi
mov    (%r12,%rbx,4),%edx
mov    %r14,%rsi
call   1030 <fprintf@plt>
add    $0x1,%rbx
movslq (%r15),%rax
add    $0xffffffffffffffff,%rax
cmp    %rax,%rbx
jl     1140 <ethernet_print_mac+0x30>
jmp    1166 <ethernet_print_mac+0x56>
add    $0xffffffffffffffff,%rax
mov    0x2e6b(%rip),%rcx
mov    (%rcx),%edi
mov    (%r12,%rax,4),%edx
lea    0xe8a(%rip),%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <fprintf@plt>

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

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