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

/* Variables and functions */
int /*<<< orphan*/ __rtinfo_internal_diep(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
unsigned int __rtinfo_internal_network_nbiface() {
  FILE *fp;
  char data[256];
  unsigned int nbiface = 0;
  if (!(fp = fopen("/proc/net/dev", "r")))
    __rtinfo_internal_diep("/proc/net/dev");
  while (fgets(data, sizeof(data), fp) != NULL) {
    if (!strncmp(data, "Inter-|", 7))
      continue;
    if (!strncmp(data, " face |", 7))
      continue;
    nbiface++;
  }
  fclose(fp);
  return nbiface;
}


x86 assembly (clang, -O0):
<__rtinfo_internal_network_nbiface>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x114(%rbp)
lea    0xe94(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    1192 <__rtinfo_internal_network_nbiface+0x42>
lea    0xe73(%rip),%rdi
call   1070 <__rtinfo_internal_diep@plt>
jmp    1197 <__rtinfo_internal_network_nbiface+0x47>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x100,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1216 <__rtinfo_internal_network_nbiface+0xc6>
lea    -0x110(%rbp),%rdi
lea    0xe4c(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11dc <__rtinfo_internal_network_nbiface+0x8c>
jmp    1197 <__rtinfo_internal_network_nbiface+0x47>
lea    -0x110(%rbp),%rdi
lea    0xe2e(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1202 <__rtinfo_internal_network_nbiface+0xb2>
jmp    1197 <__rtinfo_internal_network_nbiface+0x47>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1197 <__rtinfo_internal_network_nbiface+0x47>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x114(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__rtinfo_internal_network_nbiface>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
lea    0xe9a(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1186 <__rtinfo_internal_network_nbiface+0x36>
lea    0xe7f(%rip),%rdi
call   1070 <__rtinfo_internal_diep@plt>
xor    %r14d,%r14d
mov    %rsp,%rbp
lea    0xe7d(%rip),%r15
lea    0xe7e(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11e2 <__rtinfo_internal_network_nbiface+0x92>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11a0 <__rtinfo_internal_network_nbiface+0x50>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x1,%eax
sbb    $0xffffffff,%r14d
jmp    11a0 <__rtinfo_internal_network_nbiface+0x50>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    %r14d,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r12
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 = [8 x i8] c"Inter-|\00"
@.str.3 = [8 x i8] c" face |\00"
define i32 @__rtinfo_internal_network_nbiface() {
%1 = alloca i32*
%2 = alloca [256 x i8]
%3 = alloca i32
store i32 0, i32* %3
%4 = 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* %4, i32** %1
%5 = icmp ne i32* %4, null
br i1 %5, label %8, label %6
6: ; preds = %0
%7 = call i32 @__rtinfo_internal_diep(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %0
br label %9
9: ; preds = %24, %23, %18, %8
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%11 = load i32*, i32** %1
%12 = call i32* @fgets(i8* %10, i32 256, i32* %11)
%13 = icmp ne i32* %12, null
br i1 %13, label %14, label %27
14: ; preds = %9
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%16 = call i32 @strncmp(i8* %15, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%17 = icmp ne i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %14
br label %9
19: ; preds = %14
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%21 = call i32 @strncmp(i8* %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 7)
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %19
br label %9
24: ; preds = %19
%25 = load i32, i32* %3
%26 = add i32 %25, 1
store i32 %26, i32* %3
br label %9
27: ; preds = %9
%28 = load i32*, i32** %1
%29 = call i32 @fclose(i32* %28)
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@.str = [14 x i8] c"/proc/net/dev\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [8 x i8] c"Inter-|\00"
@.str.3 = [8 x i8] c" face |\00"
define i32 @__rtinfo_internal_network_nbiface() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 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 %5, label %7
5: ; preds = %0
%6 = tail call i32 @__rtinfo_internal_diep(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
br label %8
8: ; preds = %7, %16
%9 = phi i32 [ %20, %16 ], [ 0, %7 ]
br label %10
10: ; preds = %8, %13
%11 = call i32* @fgets(i8* %2, i32 256, i32* %3)
%12 = icmp eq i32* %11, null
br i1 %12, label %21, label %13
13: ; preds = %10
%14 = call i32 @strncmp(i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 7)
%15 = icmp eq i32 %14, 0
br i1 %15, label %10, label %16
16: ; preds = %13
%17 = call i32 @strncmp(i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 7)
%18 = icmp ne i32 %17, 0
%19 = zext i1 %18 to i32
%20 = add i32 %9, %19
br label %8
21: ; preds = %10
%22 = call i32 @fclose(i32* %3)
ret i32 %9
}