#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*/ line;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
scalar_t__ is_empty(char *);
int /*<<< orphan*/ is_hex(char *);
scalar_t__ isspace(char);
int /*<<< orphan*/ manufs_add(unsigned int, char *, char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
unsigned int parse_oui2(char *, unsigned int *);
int /*<<< orphan*/ perror(char const *);
int strlen(char *);
void manufs_load_from_oui_file(const char *filename) {
  char line[256];
  FILE *fp;
  fp = fopen(filename, "rt");
  if (fp == NULL) {
    perror(filename);
    return;
  }
  while (fgets(line, sizeof(line), fp)) {
    unsigned oui;
    unsigned offset = 0;
    if (is_empty(line))
      continue;
    if (!is_hex(line)) {
      while (fgets(line, sizeof(line), fp) && !is_empty(line))
        ;
      continue;
    }
    while (*line && isspace(line[strlen(line) - 1] & 0xFF))
      line[strlen(line) - 1] = '\0';
    oui = parse_oui2(line, &offset);
    {
      char shortname[12];
      memcpy(shortname, line + offset, 12);
      shortname[11] = '\0';
      manufs_add(oui, shortname, line + offset);
    }
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<manufs_load_from_oui_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x118(%rbp)
cmpq   $0x0,-0x118(%rbp)
jne    11f2 <manufs_load_from_oui_file+0x42>
mov    -0x8(%rbp),%rdi
call   10c0 <perror@plt>
jmp    13b2 <manufs_load_from_oui_file+0x202>
jmp    11f7 <manufs_load_from_oui_file+0x47>
lea    -0x110(%rbp),%rdi
mov    -0x118(%rbp),%rdx
mov    $0x100,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     13a6 <manufs_load_from_oui_file+0x1f6>
movl   $0x0,-0x120(%rbp)
lea    -0x110(%rbp),%rdi
call   1060 <is_empty@plt>
cmp    $0x0,%rax
je     123e <manufs_load_from_oui_file+0x8e>
jmp    11f7 <manufs_load_from_oui_file+0x47>
lea    -0x110(%rbp),%rdi
call   1050 <is_hex@plt>
cmp    $0x0,%eax
jne    12bd <manufs_load_from_oui_file+0x10d>
jmp    1258 <manufs_load_from_oui_file+0xa8>
lea    -0x110(%rbp),%rdi
mov    -0x118(%rbp),%rdx
mov    $0x100,%esi
call   1080 <fgets@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x12d(%rbp)
je     12a0 <manufs_load_from_oui_file+0xf0>
lea    -0x110(%rbp),%rdi
call   1060 <is_empty@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0x12d(%rbp)
mov    -0x12d(%rbp),%al
test   $0x1,%al
jne    12b3 <manufs_load_from_oui_file+0x103>
jmp    12b8 <manufs_load_from_oui_file+0x108>
jmp    1258 <manufs_load_from_oui_file+0xa8>
jmp    11f7 <manufs_load_from_oui_file+0x47>
jmp    12c2 <manufs_load_from_oui_file+0x112>
movsbl -0x110(%rbp),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x12e(%rbp)
je     130d <manufs_load_from_oui_file+0x15d>
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x110(%rbp,%rax,1),%eax
ff
and    $0xff,%eax
movsbl %al,%edi
call   1070 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x12e(%rbp)
mov    -0x12e(%rbp),%al
test   $0x1,%al
jne    1320 <manufs_load_from_oui_file+0x170>
jmp    133e <manufs_load_from_oui_file+0x18e>
lea    -0x110(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x110(%rbp,%rax,1)
jmp    12c2 <manufs_load_from_oui_file+0x112>
lea    -0x110(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   10a0 <parse_oui2@plt>
mov    %eax,-0x11c(%rbp)
lea    -0x12c(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    -0x120(%rbp),%eax
add    %rax,%rsi
mov    $0xc,%edx
call   1090 <memcpy@plt>
movb   $0x0,-0x121(%rbp)
mov    -0x11c(%rbp),%edi
lea    -0x12c(%rbp),%rsi
lea    -0x110(%rbp),%rdx
mov    -0x120(%rbp),%eax
add    %rax,%rdx
call   10d0 <manufs_add@plt>
jmp    11f7 <manufs_load_from_oui_file+0x47>
mov    -0x118(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<manufs_load_from_oui_file>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x110,%rsp
mov    %rdi,%rbx
lea    0xe37(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1323 <manufs_load_from_oui_file+0x173>
mov    %rax,%r14
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     130b <manufs_load_from_oui_file+0x15b>
mov    %rsp,%r15
lea    0x4(%rsp),%r12
jmp    1268 <manufs_load_from_oui_file+0xb8>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <parse_oui2@plt>
mov    %eax,%ebp
mov    (%rsp),%eax
lea    (%rsp,%rax,1),%rsi
add    $0x10,%rsi
mov    %r12,%rdi
mov    $0xc,%edx
call   1090 <memcpy@plt>
movb   $0x0,0xf(%rsp)
mov    (%rsp),%eax
lea    (%rsp,%rax,1),%rdx
add    $0x10,%rdx
mov    %ebp,%edi
mov    %r12,%rsi
call   10d0 <manufs_add@plt>
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     130b <manufs_load_from_oui_file+0x15b>
movl   $0x0,(%rsp)
mov    %rbx,%rdi
call   1060 <is_empty@plt>
test   %rax,%rax
jne    124f <manufs_load_from_oui_file+0x9f>
mov    %rbx,%rdi
call   1050 <is_hex@plt>
test   %eax,%eax
je     12e0 <manufs_load_from_oui_file+0x130>
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,0x10(%rsp)
je     1210 <manufs_load_from_oui_file+0x60>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movsbl -0x1(%rax,%rbx,1),%edi
call   1070 <isspace@plt>
test   %rax,%rax
je     1210 <manufs_load_from_oui_file+0x60>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
cmpb   $0x0,0x10(%rsp)
jne    129b <manufs_load_from_oui_file+0xeb>
jmp    1210 <manufs_load_from_oui_file+0x60>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r14,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     124f <manufs_load_from_oui_file+0x9f>
mov    %rbx,%rdi
call   1060 <is_empty@plt>
test   %rax,%rax
je     12e0 <manufs_load_from_oui_file+0x130>
jmp    124f <manufs_load_from_oui_file+0x9f>
mov    %r14,%rdi
call   1030 <fclose@plt>
add    $0x110,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
add    $0x110,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10c0 <perror@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"rt\00"
define void @manufs_load_from_oui_file(i8* %0) {
%2 = alloca i8*
%3 = alloca [256 x i8]
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [12 x i8]
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %4
%10 = load i32*, i32** %4
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = call i32 @perror(i8* %13)
br label %91
15: ; preds = %1
br label %16
16: ; preds = %71, %44, %25, %15
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%18 = load i32*, i32** %4
%19 = call i64 @fgets(i8* %17, i32 256, i32* %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %88
21: ; preds = %16
store i32 0, i32* %6
%22 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%23 = call i64 @is_empty(i8* %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %21
br label %16
26: ; preds = %21
%27 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%28 = call i32 @is_hex(i8* %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %45, label %30
30: ; preds = %26
br label %31
31: ; preds = %43, %30
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%33 = load i32*, i32** %4
%34 = call i64 @fgets(i8* %32, i32 256, i32* %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %31
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%38 = call i64 @is_empty(i8* %37)
%39 = icmp ne i64 %38, 0
%40 = xor i1 %39, true
br label %41
41: ; preds = %36, %31
%42 = phi i1 [ false, %31 ], [ %40, %36 ]
br i1 %42, label %43, label %44
43: ; preds = %41
br label %31
44: ; preds = %41
br label %16
45: ; preds = %26
br label %46
46: ; preds = %65, %45
%47 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %63
51: ; preds = %46
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%53 = call i32 @strlen(i8* %52)
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %55
%57 = load i8, i8* %56
%58 = sext i8 %57 to i32
%59 = and i32 %58, 255
%60 = trunc i32 %59 to i8
%61 = call i64 @isspace(i8 signext %60)
%62 = icmp ne i64 %61, 0
br label %63
63: ; preds = %51, %46
%64 = phi i1 [ false, %46 ], [ %62, %51 ]
br i1 %64, label %65, label %71
65: ; preds = %63
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%67 = call i32 @strlen(i8* %66)
%68 = sub nsw i32 %67, 1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 %69
store i8 0, i8* %70
br label %46
71: ; preds = %63
%72 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%73 = call i32 @parse_oui2(i8* %72, i32* %6)
store i32 %73, i32* %5
%74 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%75 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%76 = load i32, i32* %6
%77 = zext i32 %76 to i64
%78 = getelementptr inbounds i8, i8* %75, i64 %77
%79 = call i32 @memcpy(i8* %74, i8* %78, i32 12)
%80 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 11
store i8 0, i8* %80
%81 = load i32, i32* %5
%82 = getelementptr inbounds [12 x i8], [12 x i8]* %7, i64 0, i64 0
%83 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%84 = load i32, i32* %6
%85 = zext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %83, i64 %85
%87 = call i32 @manufs_add(i32 %81, i8* %82, i8* %86)
br label %16
88: ; preds = %16
%89 = load i32*, i32** %4
%90 = call i32 @fclose(i32* %89)
br label %91
91: ; preds = %88, %12
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"rt\00"
define void @manufs_load_from_oui_file(i8* nocapture %0) {
%2 = alloca [256 x i8]
%3 = alloca i32
%4 = alloca [12 x i8]
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %15, label %8
8: ; preds = %1
%9 = call i64 @fgets(i8* %5, i32 256, i32* %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %60, label %11
11: ; preds = %8
%12 = bitcast i32* %3 to i8*
%13 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 0
%14 = getelementptr inbounds [12 x i8], [12 x i8]* %4, i64 0, i64 11
br label %17
15: ; preds = %1
%16 = tail call i32 @perror(i8* %0)
br label %62
17: ; preds = %11, %57
store i32 0, i32* %3
%18 = call i64 @is_empty(i8* %5)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %57
20: ; preds = %17
%21 = call i32 @is_hex(i8* %5)
%22 = icmp eq i32 %21, 0
br i1 %22, label %26, label %23
23: ; preds = %20
%24 = load i8, i8* %5
%25 = icmp eq i8 %24, 0
br i1 %25, label %47, label %32
26: ; preds = %20, %29
%27 = call i64 @fgets(i8* %5, i32 256, i32* %6)
%28 = icmp eq i64 %27, 0
br i1 %28, label %57, label %29
29: ; preds = %26
%30 = call i64 @is_empty(i8* %5)
%31 = icmp eq i64 %30, 0
br i1 %31, label %26, label %57
32: ; preds = %23, %40
%33 = call i32 @strlen(i8* %5)
%34 = add nsw i32 %33, -1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = call i64 @isspace(i8 signext %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %47, label %40
40: ; preds = %32
%41 = call i32 @strlen(i8* %5)
%42 = add nsw i32 %41, -1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %43
store i8 0, i8* %44
%45 = load i8, i8* %5
%46 = icmp eq i8 %45, 0
br i1 %46, label %47, label %32
47: ; preds = %32, %40, %23
%48 = call i32 @parse_oui2(i8* %5, i32* %3)
%49 = load i32, i32* %3
%50 = zext i32 %49 to i64
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %50
%52 = call i32 @memcpy(i8* %13, i8* %51, i32 12)
store i8 0, i8* %14
%53 = load i32, i32* %3
%54 = zext i32 %53 to i64
%55 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 %54
%56 = call i32 @manufs_add(i32 %48, i8* %13, i8* %55)
br label %57
57: ; preds = %29, %26, %17, %47
%58 = call i64 @fgets(i8* %5, i32 256, i32* %6)
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %17
60: ; preds = %57, %8
%61 = call i32 @fclose(i32* %6)
br label %62
62: ; preds = %60, %15
ret void
}