#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 EXIT_FAILURE;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int get_mac_address(unsigned char *, char *);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 2)
    return EXIT_FAILURE;
  char *interface = argv[1];
  unsigned char address[6];
  memset(address, 0, 6);
  unsigned char *pt = address;
  int i = 0;
  i = get_mac_address(address, interface);
  if (i != 0) {
    fprintf(stderr, "Could not retrieve the address\n");
    return EXIT_FAILURE;
  }
  printf("Printing mac address of interface %s\n", interface);
  printf("%.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", pt[0], pt[1], pt[2], pt[3], pt[4],
         pt[5]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1171 <main+0x31>
mov    0x2e71(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1237 <main+0xf7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
lea    -0x1e(%rbp),%rdi
xor    %esi,%esi
mov    $0x6,%edx
call   1050 <memset@plt>
lea    -0x1e(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    -0x1e(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <get_mac_address@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     11dc <main+0x9c>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
lea    0xe3a(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e06(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1237 <main+0xf7>
mov    -0x18(%rbp),%rsi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
movzbl (%rax),%esi
mov    -0x28(%rbp),%rax
movzbl 0x1(%rax),%edx
mov    -0x28(%rbp),%rax
movzbl 0x2(%rax),%ecx
mov    -0x28(%rbp),%rax
movzbl 0x3(%rax),%r8d
mov    -0x28(%rbp),%rax
movzbl 0x4(%rax),%r9d
mov    -0x28(%rbp),%rax
movzbl 0x5(%rax),%eax
lea    0xe20(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jne    118c <main+0x4c>
mov    0x8(%rsi),%r14
lea    0xa(%rsp),%r15
xor    %ebx,%ebx
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x6,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <get_mac_address@plt>
test   %eax,%eax
je     1197 <main+0x57>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
lea    0xe79(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%ebx
jmp    11d9 <main+0x99>
lea    0xe82(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
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    0xe74(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str = [32 x i8] c"Could not retrieve the address\0A\00"
@.str.1 = [38 x i8] c"Printing mac address of interface %s\0A\00"
@.str.2 = [31 x i8] c"%.2X:%.2X:%.2X:%.2X:%.2X:%.2X\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [6 x i8]
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = load i32, i32* @EXIT_FAILURE
store i32 %13, i32* %3
br label %58
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
store i8* %17, i8** %6
%18 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%19 = call i32 @memset(i8* %18, i32 0, i32 6)
%20 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
store i8* %20, i8** %8
store i32 0, i32* %9
%21 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%22 = load i8*, i8** %6
%23 = call i32 @get_mac_address(i8* %21, i8* %22)
store i32 %23, i32* %9
%24 = load i32, i32* %9
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %14
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%29 = load i32, i32* @EXIT_FAILURE
store i32 %29, i32* %3
br label %58
30: ; preds = %14
%31 = load i8*, i8** %6
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %31)
%33 = load i8*, i8** %8
%34 = getelementptr inbounds i8, i8* %33, i64 0
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = load i8*, i8** %8
%38 = getelementptr inbounds i8, i8* %37, i64 1
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = load i8*, i8** %8
%42 = getelementptr inbounds i8, i8* %41, i64 2
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = load i8*, i8** %8
%46 = getelementptr inbounds i8, i8* %45, i64 3
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = load i8*, i8** %8
%50 = getelementptr inbounds i8, i8* %49, i64 4
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = load i8*, i8** %8
%54 = getelementptr inbounds i8, i8* %53, i64 5
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %36, i32 %40, i32 %44, i32 %48, i32 %52, i32 %56)
store i32 0, i32* %3
br label %58
58: ; preds = %30, %26, %12
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
@EXIT_FAILURE = global i32 0
@stderr = global i32 0
@.str = [32 x i8] c"Could not retrieve the address\0A\00"
@.str.1 = [38 x i8] c"Printing mac address of interface %s\0A\00"
@.str.2 = [31 x i8] c"%.2X:%.2X:%.2X:%.2X:%.2X:%.2X\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [6 x i8]
%4 = icmp eq i32 %0, 2
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = load i32, i32* @EXIT_FAILURE
br label %40
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%11 = call i32 @memset(i8* %10, i32 0, i32 6)
%12 = call i32 @get_mac_address(i8* %10, i8* %9)
%13 = icmp eq i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %7
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
br label %38
18: ; preds = %7
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%20 = load i8, i8* %10
%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.2, i64 0, i64 0), i32 %21, i32 %24, i32 %27, i32 %30, i32 %33, i32 %36)
br label %38
38: ; preds = %18, %14
%39 = phi i32 [ %17, %14 ], [ 0, %18 ]
br label %40
40: ; preds = %38, %5
%41 = phi i32 [ %6, %5 ], [ %39, %38 ]
ret i32 %41
}