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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ isspace(char);
int /*<<< orphan*/ kattach_net_dhcp(char *);
char *strchr(char *, char);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
void kattach_net_dhcpscan(void) {
  char entry[512];
  char *delimit;
  char *devname;
  FILE *fp;
  if (!(fp = fopen("/proc/net/dev", "r")))
    return;
  while ((devname = fgets(entry, 512, fp))) {
    while (isspace(devname[0]))
      devname++;
    delimit = strchr(devname, ':');
    if (delimit) {
      *delimit = 0;
      if ((strncmp(devname, "bond", 4)) && (strncmp(devname, "eql", 3)) &&
          (strncmp(devname, "teql", 4)) && (strncmp(devname, "tunl", 4)) &&
          (strncmp(devname, "gre", 3)) && (strncmp(devname, "sit", 3))) {
        if (strncmp(devname, "lo", 2)) {
          kattach_net_dhcp(devname);
        } else if ((!strncmp(devname, "lo", 2)) && (strlen(devname) > 3)) {
          kattach_net_dhcp(devname);
        }
      }
    }
  }
  fclose(fp);
  return;
}


x86 assembly (clang, -O0):
<kattach_net_dhcpscan>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
lea    0xe6e(%rip),%rdi
lea    0xe75(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x218(%rbp)
cmp    $0x0,%rax
jne    11b4 <kattach_net_dhcpscan+0x34>
jmp    13a9 <kattach_net_dhcpscan+0x229>
jmp    11b9 <kattach_net_dhcpscan+0x39>
lea    -0x200(%rbp),%rdi
mov    -0x218(%rbp),%rdx
mov    $0x200,%esi
call   1090 <fgets@plt>
mov    %rax,-0x210(%rbp)
cmp    $0x0,%rax
je     139d <kattach_net_dhcpscan+0x21d>
jmp    11e7 <kattach_net_dhcpscan+0x67>
mov    -0x210(%rbp),%rax
movsbl (%rax),%edi
call   1080 <isspace@plt>
cmp    $0x0,%rax
je     1217 <kattach_net_dhcpscan+0x97>
mov    -0x210(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x210(%rbp)
jmp    11e7 <kattach_net_dhcpscan+0x67>
mov    -0x210(%rbp),%rdi
mov    $0x3a,%esi
call   1070 <strchr@plt>
mov    %rax,-0x208(%rbp)
cmpq   $0x0,-0x208(%rbp)
je     1398 <kattach_net_dhcpscan+0x218>
mov    -0x208(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x210(%rbp),%rdi
lea    0xdbb(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1393 <kattach_net_dhcpscan+0x213>
mov    -0x210(%rbp),%rdi
lea    0xd9f(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1393 <kattach_net_dhcpscan+0x213>
mov    -0x210(%rbp),%rdi
lea    0xd7c(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1393 <kattach_net_dhcpscan+0x213>
mov    -0x210(%rbp),%rdi
lea    0xd5f(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1393 <kattach_net_dhcpscan+0x213>
mov    -0x210(%rbp),%rdi
lea    0xd42(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1393 <kattach_net_dhcpscan+0x213>
mov    -0x210(%rbp),%rdi
lea    0xd24(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1393 <kattach_net_dhcpscan+0x213>
mov    -0x210(%rbp),%rdi
lea    0xd06(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1346 <kattach_net_dhcpscan+0x1c6>
mov    -0x210(%rbp),%rdi
call   1040 <kattach_net_dhcp@plt>
jmp    138e <kattach_net_dhcpscan+0x20e>
mov    -0x210(%rbp),%rdi
lea    0xcd3(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1389 <kattach_net_dhcpscan+0x209>
mov    -0x210(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x3,%eax
jle    1389 <kattach_net_dhcpscan+0x209>
mov    -0x210(%rbp),%rdi
call   1040 <kattach_net_dhcp@plt>
jmp    138e <kattach_net_dhcpscan+0x20e>
jmp    1393 <kattach_net_dhcpscan+0x213>
jmp    1398 <kattach_net_dhcpscan+0x218>
jmp    11b9 <kattach_net_dhcpscan+0x39>
mov    -0x218(%rbp),%rdi
call   1050 <fclose@plt>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kattach_net_dhcpscan>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
lea    0xe68(%rip),%rdi
lea    0xe6f(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1327 <kattach_net_dhcpscan+0x1a7>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x200,%esi
mov    %rax,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     131f <kattach_net_dhcpscan+0x19f>
mov    %rsp,%r14
lea    0xe3d(%rip),%r15
lea    0xe3c(%rip),%r12
lea    0xe34(%rip),%r13
jmp    1209 <kattach_net_dhcpscan+0x89>
mov    %rbp,%rdi
call   1040 <kattach_net_dhcp@plt>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     131f <kattach_net_dhcpscan+0x19f>
mov    %rax,%rbp
movsbl (%rax),%edi
call   1080 <isspace@plt>
mov    %rax,%rcx
lea    0x1(%rbp),%rax
test   %rcx,%rcx
jne    1209 <kattach_net_dhcpscan+0x89>
mov    %rbp,%rdi
mov    $0x3a,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     11f0 <kattach_net_dhcpscan+0x70>
movb   $0x0,(%rax)
mov    %rbp,%rdi
mov    %r15,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11f0 <kattach_net_dhcpscan+0x70>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11f0 <kattach_net_dhcpscan+0x70>
mov    %rbp,%rdi
mov    %r13,%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11f0 <kattach_net_dhcpscan+0x70>
mov    %rbp,%rdi
lea    0xd98(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11f0 <kattach_net_dhcpscan+0x70>
mov    %rbp,%rdi
lea    0xd80(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11f0 <kattach_net_dhcpscan+0x70>
mov    %rbp,%rdi
lea    0xd67(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11f0 <kattach_net_dhcpscan+0x70>
mov    %rbp,%rdi
lea    0xd4e(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11e3 <kattach_net_dhcpscan+0x63>
mov    %rbp,%rdi
lea    0xd31(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11f0 <kattach_net_dhcpscan+0x70>
mov    %rbp,%rdi
call   1060 <strlen@plt>
cmp    $0x4,%eax
jge    11e3 <kattach_net_dhcpscan+0x63>
jmp    11f0 <kattach_net_dhcpscan+0x70>
mov    %rbx,%rdi
call   1050 <fclose@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"/proc/net/dev\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"bond\00"
@.str.3 = [4 x i8] c"eql\00"
@.str.4 = [5 x i8] c"teql\00"
@.str.5 = [5 x i8] c"tunl\00"
@.str.6 = [4 x i8] c"gre\00"
@.str.7 = [4 x i8] c"sit\00"
@.str.8 = [3 x i8] c"lo\00"
define void @kattach_net_dhcpscan() {
%1 = alloca [512 x i8]
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32*
%5 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %4
%6 = icmp ne i32* %5, null
br i1 %6, label %8, label %7
7: ; preds = %0
br label %79
8: ; preds = %0
br label %9
9: ; preds = %75, %8
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%11 = load i32*, i32** %4
%12 = call i8* @fgets(i8* %10, i32 512, i32* %11)
store i8* %12, i8** %3
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %76
14: ; preds = %9
br label %15
15: ; preds = %21, %14
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = call i64 @isspace(i8 signext %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %3
br label %15
24: ; preds = %15
%25 = load i8*, i8** %3
%26 = call i8* @strchr(i8* %25, i8 signext 58)
store i8* %26, i8** %2
%27 = load i8*, i8** %2
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %75
29: ; preds = %24
%30 = load i8*, i8** %2
store i8 0, i8* %30
%31 = load i8*, i8** %3
%32 = call i64 @strncmp(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %74
34: ; preds = %29
%35 = load i8*, i8** %3
%36 = call i64 @strncmp(i8* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %74
38: ; preds = %34
%39 = load i8*, i8** %3
%40 = call i64 @strncmp(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %74
42: ; preds = %38
%43 = load i8*, i8** %3
%44 = call i64 @strncmp(i8* %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %74
46: ; preds = %42
%47 = load i8*, i8** %3
%48 = call i64 @strncmp(i8* %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 3)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %74
50: ; preds = %46
%51 = load i8*, i8** %3
%52 = call i64 @strncmp(i8* %51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 3)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %74
54: ; preds = %50
%55 = load i8*, i8** %3
%56 = call i64 @strncmp(i8* %55, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 2)
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %54
%59 = load i8*, i8** %3
%60 = call i32 @kattach_net_dhcp(i8* %59)
br label %73
61: ; preds = %54
%62 = load i8*, i8** %3
%63 = call i64 @strncmp(i8* %62, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 2)
%64 = icmp ne i64 %63, 0
br i1 %64, label %72, label %65
65: ; preds = %61
%66 = load i8*, i8** %3
%67 = call i32 @strlen(i8* %66)
%68 = icmp sgt i32 %67, 3
br i1 %68, label %69, label %72
69: ; preds = %65
%70 = load i8*, i8** %3
%71 = call i32 @kattach_net_dhcp(i8* %70)
br label %72
72: ; preds = %69, %65, %61
br label %73
73: ; preds = %72, %58
br label %74
74: ; preds = %73, %50, %46, %42, %38, %34, %29
br label %75
75: ; preds = %74, %24
br label %9
76: ; preds = %9
%77 = load i32*, i32** %4
%78 = call i32 @fclose(i32* %77)
br label %79
79: ; preds = %76, %7
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"/proc/net/dev\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"bond\00"
@.str.3 = [4 x i8] c"eql\00"
@.str.4 = [5 x i8] c"teql\00"
@.str.5 = [5 x i8] c"tunl\00"
@.str.6 = [4 x i8] c"gre\00"
@.str.7 = [4 x i8] c"sit\00"
@.str.8 = [3 x i8] c"lo\00"
define void @kattach_net_dhcpscan() {
%1 = alloca [512 x i8]
%2 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %53, label %5
5: ; preds = %0
%6 = call i8* @fgets(i8* %2, i32 512, i32* %3)
%7 = icmp eq i8* %6, null
br i1 %7, label %51, label %8
8: ; preds = %5, %14
%9 = phi i8* [ %15, %14 ], [ %6, %5 ]
%10 = load i8, i8* %9
%11 = call i64 @isspace(i8 signext %10)
%12 = icmp eq i64 %11, 0
%13 = getelementptr inbounds i8, i8* %9, i64 1
br i1 %12, label %16, label %14
14: ; preds = %8, %48
%15 = phi i8* [ %13, %8 ], [ %49, %48 ]
br label %8
16: ; preds = %8
%17 = call i8* @strchr(i8* %9, i8 signext 58)
%18 = icmp eq i8* %17, null
br i1 %18, label %48, label %19
19: ; preds = %16
store i8 0, i8* %17
%20 = call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%21 = icmp eq i64 %20, 0
br i1 %21, label %48, label %22
22: ; preds = %19
%23 = call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%24 = icmp eq i64 %23, 0
br i1 %24, label %48, label %25
25: ; preds = %22
%26 = call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%27 = icmp eq i64 %26, 0
br i1 %27, label %48, label %28
28: ; preds = %25
%29 = call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%30 = icmp eq i64 %29, 0
br i1 %30, label %48, label %31
31: ; preds = %28
%32 = call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 3)
%33 = icmp eq i64 %32, 0
br i1 %33, label %48, label %34
34: ; preds = %31
%35 = call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 3)
%36 = icmp eq i64 %35, 0
br i1 %36, label %48, label %37
37: ; preds = %34
%38 = call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 2)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %37
%41 = call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32 2)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %48
43: ; preds = %40
%44 = call i32 @strlen(i8* %9)
%45 = icmp sgt i32 %44, 3
br i1 %45, label %46, label %48
46: ; preds = %43, %37
%47 = call i32 @kattach_net_dhcp(i8* %9)
br label %48
48: ; preds = %46, %19, %22, %25, %28, %31, %34, %40, %43, %16
%49 = call i8* @fgets(i8* %2, i32 512, i32* %3)
%50 = icmp eq i8* %49, null
br i1 %50, label %51, label %14
51: ; preds = %48, %5
%52 = call i32 @fclose(i32* %3)
br label %53
53: ; preds = %0, %51
ret void
}