#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 /*<<< orphan*/ mac;

/* Variables and functions */
scalar_t__ getifmac(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  char *interface;
  char mac[24];
  if (argc != 2) {
    printf("Usage: %s <netcard interface>\n", argv[0]);
    printf("e.g. : %s eth0\n", argv[0]);
    return -1;
  }
  interface = argv[1];
  if (getifmac(interface, mac, sizeof(mac)) != 0) {
    printf("get MAC addreds failed\n");
    return -1;
  }
  printf("%s: [%s]\n", interface, mac);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1176 <main+0x56>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <main+0xb5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x18,%edx
call   1040 <getifmac@plt>
cmp    $0x0,%rax
je     11b8 <main+0x98>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d5 <main+0xb5>
mov    -0x18(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    0xe80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    116a <main+0x3a>
mov    0x8(%rbx),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x18,%edx
call   1050 <getifmac@plt>
test   %rax,%rax
je     1193 <main+0x63>
lea    0xedb(%rip),%rdi
call   1030 <puts@plt>
mov    $0xffffffff,%ebp
jmp    11a9 <main+0x79>
mov    (%rbx),%rsi
lea    0xe8c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%rsi
lea    0xe9a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%ebp
jmp    11a9 <main+0x79>
lea    0xe95(%rip),%rdi
xor    %ebp,%ebp
mov    %rsp,%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Usage: %s <netcard interface>\0A\00"
@.str.1 = [16 x i8] c"e.g. : %s eth0\0A\00"
@.str.2 = [24 x i8] c"get MAC addreds failed\0A\00"
@.str.3 = [10 x i8] c"%s: [%s]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [24 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %19
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %17)
store i32 -1, i32* %3
br label %33
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
store i8* %22, i8** %6
%23 = load i8*, i8** %6
%24 = getelementptr inbounds [24 x i8], [24 x i8]* %7, i64 0, i64 0
%25 = call i64 @getifmac(i8* %23, i8* %24, i32 24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %19
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %33
29: ; preds = %19
%30 = load i8*, i8** %6
%31 = getelementptr inbounds [24 x i8], [24 x i8]* %7, i64 0, i64 0
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %30, i8* %31)
store i32 0, i32* %3
br label %33
33: ; preds = %29, %27, %10
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [31 x i8] c"Usage: %s <netcard interface>\0A\00"
@.str.1 = [16 x i8] c"e.g. : %s eth0\0A\00"
@.str.3 = [10 x i8] c"%s: [%s]\0A\00"
@str = [23 x i8] c"get MAC addreds failed\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [24 x i8]
%4 = getelementptr inbounds [24 x i8], [24 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 2
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %20
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @getifmac(i8* %13, i8* %4, i32 24)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %11
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %20
18: ; preds = %11
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %13, i8* %4)
br label %20
20: ; preds = %18, %16, %6
%21 = phi i32 [ -1, %6 ], [ -1, %16 ], [ 0, %18 ]
ret i32 %21
}