#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(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *macsearch(unsigned char *, int);
int parseMAC(char *, unsigned char *);
int /*<<< orphan*/ printf(char *, char *, char const *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc < 2) {
    fprintf(stderr, "wrong # args, try %s <mac-address> [<mac-address> ...]\n",
            argv[0]);
    exit(1);
  }
  for (int i = 1; i < argc; i++) {
    unsigned char buff[6] = {0};
    const int n = parseMAC(argv[i], buff);
    if (n < 0) {
      fprintf(stderr, "Cannot parse MAC '%s'\n", argv[i]);
      continue;
    }
    const char *manufacturer = macsearch(buff, 6);
    if (manufacturer == NULL) {
      fprintf(stderr, "Cannot resolve manufacturer from MAC '%s'\n", argv[i]);
      continue;
    }
    printf("%s => %s\n", argv[i], manufacturer);
  }
}


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)
jge    11a6 <main+0x46>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe69(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    127e <main+0x11e>
lea    -0x1a(%rbp),%rdi
xor    %esi,%esi
mov    $0x6,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x1a(%rbp),%rsi
call   1060 <parseMAC@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    1211 <main+0xb1>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe31(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1270 <main+0x110>
lea    -0x1a(%rbp),%rdi
mov    $0x6,%esi
call   1070 <macsearch@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1254 <main+0xf4>
mov    0x2dab(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe05(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1270 <main+0x110>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe0f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ad <main+0x4d>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jl     1211 <main+0xc1>
mov    %edi,%ebp
mov    $0x1,%r12d
mov    %rsp,%r14
mov    0x2e67(%rip),%r15
lea    0xefa(%rip),%r13
jmp    11ac <main+0x5c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r15),%edi
mov    (%rbx,%r12,8),%rdx
lea    0xe9a(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x1,%r12
cmp    %r12,%rbp
je     1200 <main+0xb0>
movw   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
mov    (%rbx,%r12,8),%rdi
mov    %r14,%rsi
call   1050 <parseMAC@plt>
test   %eax,%eax
js     1190 <main+0x40>
mov    %r14,%rdi
mov    $0x6,%esi
call   1060 <macsearch@plt>
test   %rax,%rax
je     11f0 <main+0xa0>
mov    (%rbx,%r12,8),%rsi
mov    %r13,%rdi
mov    %rax,%rdx
call   1030 <printf@plt>
jmp    11a3 <main+0x53>
nopl   (%rax)
mov    (%r15),%edi
mov    (%rbx,%r12,8),%rdx
lea    0xe51(%rip),%rsi
jmp    119e <main+0x4e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xddc(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [56 x i8] c"wrong # args, try %s <mac-address> [<mac-address> ...]\0A\00"
@.str.1 = [23 x i8] c"Cannot parse MAC '%s'\0A\00"
@.str.2 = [43 x i8] c"Cannot resolve manufacturer from MAC '%s'\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 i32
%7 = alloca [6 x i8]
%8 = alloca i32
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 2
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
store i32 1, i32* %6
br label %20
20: ; preds = %64, %19
%21 = load i32, i32* %6
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %67
24: ; preds = %20
%25 = bitcast [6 x i8]* %7 to i8*
%26 = load i8**, i8*** %5
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%32 = call i32 @parseMAC(i8* %30, i8* %31)
store i32 %32, i32* %8
%33 = load i32, i32* %8
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %43
35: ; preds = %24
%36 = load i32, i32* @stderr
%37 = load i8**, i8*** %5
%38 = load i32, i32* %6
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %37, i64 %39
%41 = load i8*, i8** %40
%42 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %41)
br label %64
43: ; preds = %24
%44 = getelementptr inbounds [6 x i8], [6 x i8]* %7, i64 0, i64 0
%45 = call i8* @macsearch(i8* %44, i32 6)
store i8* %45, i8** %9
%46 = load i8*, i8** %9
%47 = icmp eq i8* %46, null
br i1 %47, label %48, label %56
48: ; preds = %43
%49 = load i32, i32* @stderr
%50 = load i8**, i8*** %5
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = call i32 @fprintf(i32 %49, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %54)
br label %64
56: ; preds = %43
%57 = load i8**, i8*** %5
%58 = load i32, i32* %6
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8*, i8** %57, i64 %59
%61 = load i8*, i8** %60
%62 = load i8*, i8** %9
%63 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %61, i8* %62)
br label %64
64: ; preds = %56, %48, %35
%65 = load i32, i32* %6
%66 = add nsw i32 %65, 1
store i32 %66, i32* %6
br label %20
67: ; preds = %20
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [56 x i8] c"wrong # args, try %s <mac-address> [<mac-address> ...]\0A\00"
@.str.1 = [23 x i8] c"Cannot parse MAC '%s'\0A\00"
@.str.2 = [43 x i8] c"Cannot resolve manufacturer from MAC '%s'\0A\00"
@.str.3 = [10 x i8] c"%s => %s\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 %8, label %5
5: ; preds = %2
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%7 = zext i32 %0 to i64
br label %14
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %34
ret i32 0
14: ; preds = %5, %34
%15 = phi i64 [ 1, %5 ], [ %35, %34 ]
%16 = getelementptr inbounds i8*, i8** %1, i64 %15
%17 = load i8*, i8** %16
%18 = call i32 @parseMAC(i8* %17, i8* %6)
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %14
%21 = load i32, i32* @stderr
%22 = load i8*, i8** %16
%23 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %34
24: ; preds = %14
%25 = call i8* @macsearch(i8* %6, i32 6)
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = load i32, i32* @stderr
%29 = load i8*, i8** %16
%30 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i8* %29)
br label %34
31: ; preds = %24
%32 = load i8*, i8** %16
%33 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %32, i8* %25)
br label %34
34: ; preds = %27, %31, %20
%35 = add nuw nsw i64 %15, 1
%36 = icmp eq i64 %35, %7
br i1 %36, label %13, label %14
}