#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int hw_address(char *, unsigned char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  if (argc < 2) {
    printf("%s [ifname]\n", argv[0]);
    return 0;
  }
  unsigned char address[6];
  if (hw_address(argv[1], address) == -1) {
    perror(argv[0]);
    exit(EXIT_FAILURE);
  }
  printf("%02x:%02x:%02x:%02x:%02x:%02x\n", (address[0]), (address[1]),
         (address[2]), (address[3]), (address[4]), (address[5]));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1181 <main+0x41>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e7 <main+0xa7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x16(%rbp),%rsi
call   1030 <hw_address@plt>
cmp    $0xffffffff,%eax
jne    11b5 <main+0x75>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <perror@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
movzbl -0x16(%rbp),%esi
movzbl -0x15(%rbp),%edx
movzbl -0x14(%rbp),%ecx
movzbl -0x13(%rbp),%r8d
movzbl -0x12(%rbp),%r9d
movzbl -0x11(%rbp),%eax
lea    0xe37(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1160 <main+0x20>
mov    (%rbx),%rsi
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11a4 <main+0x64>
mov    0x8(%rbx),%rdi
lea    0xa(%rsp),%rsi
call   1030 <hw_address@plt>
cmp    $0xffffffff,%eax
je     11ac <main+0x6c>
movzbl 0xa(%rsp),%esi
movzbl 0xb(%rsp),%edx
movzbl 0xc(%rsp),%ecx
movzbl 0xd(%rsp),%r8d
movzbl 0xe(%rsp),%r9d
movzbl 0xf(%rsp),%eax
mov    %eax,(%rsp)
lea    0xe70(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    (%rbx),%rdi
call   1050 <perror@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"%s [ifname]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [31 x i8] c"%02x:%02x:%02x:%02x:%02x:%02x\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [6 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %12)
store i32 0, i32* %3
br label %48
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%19 = call i32 @hw_address(i8* %17, i8* %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %28
21: ; preds = %14
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 @perror(i8* %24)
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %14
%29 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%30 = load i8, i8* %29
%31 = zext i8 %30 to i32
%32 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 1
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 2
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 3
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 4
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 5
%45 = load i8, i8* %44
%46 = zext i8 %45 to i32
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 %34, i32 %37, i32 %40, i32 %43, i32 %46)
store i32 0, i32* %3
br label %48
48: ; preds = %28, %9
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [13 x i8] c"%s [ifname]\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [31 x i8] c"%02x:%02x:%02x:%02x:%02x:%02x\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [6 x i8]
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %38
8: ; preds = %2
%9 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @hw_address(i8* %11, i8* %9)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %19
14: ; preds = %8
%15 = load i8*, i8** %1
%16 = call i32 @perror(i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %8
%20 = load i8, i8* %9
%21 = zext i8 %20 to i32
%22 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 1
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 2
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 3
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 4
%32 = load i8, i8* %31
%33 = zext i8 %32 to i32
%34 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 5
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %21, i32 %24, i32 %27, i32 %30, i32 %33, i32 %36)
br label %38
38: ; preds = %19, %5
ret i32 0
}