#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*/ printf(char *, ...);
char *strchr(char *, char);
int strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int main(void) {
  char entry[512];
  char *delimit;
  char *devname;
  FILE *fp;
  if (!(fp = fopen("/proc/net/dev", "r")))
    return 1;
  while ((devname = fgets(entry, 512, fp))) {
    while (isspace(devname[0]))
      devname++;
    delimit = strchr(devname, ':');
    if (delimit) {
      *delimit = 0;
      if (strlen(devname) > 3)
        printf("\n\nlong\n\n");
      if (!strncmp(devname, "lo", 2))
        printf("%s \n", devname);
    }
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe67(%rip),%rdi
lea    0xe6e(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x228(%rbp)
cmp    $0x0,%rax
jne    11c2 <main+0x42>
movl   $0x1,-0x4(%rbp)
jmp    12cb <main+0x14b>
jmp    11c7 <main+0x47>
lea    -0x210(%rbp),%rdi
mov    -0x228(%rbp),%rdx
mov    $0x200,%esi
call   1090 <fgets@plt>
mov    %rax,-0x220(%rbp)
cmp    $0x0,%rax
je     12b8 <main+0x138>
jmp    11f5 <main+0x75>
mov    -0x220(%rbp),%rax
movsbl (%rax),%edi
call   1080 <isspace@plt>
cmp    $0x0,%rax
je     1225 <main+0xa5>
mov    -0x220(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x220(%rbp)
jmp    11f5 <main+0x75>
mov    -0x220(%rbp),%rdi
mov    $0x3a,%esi
call   1060 <strchr@plt>
mov    %rax,-0x218(%rbp)
cmpq   $0x0,-0x218(%rbp)
je     12b3 <main+0x133>
mov    -0x218(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x220(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x3,%eax
jle    1278 <main+0xf8>
lea    0xd9f(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x220(%rbp),%rdi
lea    0xd93(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12ae <main+0x12e>
mov    -0x220(%rbp),%rsi
lea    0xd75(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    12b3 <main+0x133>
jmp    11c7 <main+0x47>
mov    -0x228(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
lea    0xe58(%rip),%rdi
lea    0xe5f(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1287 <main+0xf7>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x200,%esi
mov    %rax,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     127b <main+0xeb>
mov    %rsp,%r14
lea    0xe35(%rip),%r15
lea    0xe26(%rip),%r12
lea    0xe22(%rip),%r13
jmp    1229 <main+0x99>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
mov    %r12,%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     126c <main+0xdc>
mov    %r14,%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     127b <main+0xeb>
mov    %rax,%rbp
movsbl (%rax),%edi
call   1090 <isspace@plt>
mov    %rax,%rcx
lea    0x1(%rbp),%rax
test   %rcx,%rcx
jne    1229 <main+0x99>
mov    %rbp,%rdi
mov    $0x3a,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     1214 <main+0x84>
movb   $0x0,(%rax)
mov    %rbp,%rdi
call   1060 <strlen@plt>
cmp    $0x4,%eax
jl     1200 <main+0x70>
mov    %r15,%rdi
call   1040 <puts@plt>
jmp    1200 <main+0x70>
mov    %r13,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1214 <main+0x84>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    128c <main+0xfc>
mov    $0x1,%eax
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 = [9 x i8] c"\0A\0Along\0A\0A\00"
@.str.3 = [3 x i8] c"lo\00"
@.str.4 = [5 x i8] c"%s \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [512 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
store i32 0, i32* %1
%6 = 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* %6, i32** %5
%7 = icmp ne i32* %6, null
br i1 %7, label %9, label %8
8: ; preds = %0
store i32 1, i32* %1
br label %49
9: ; preds = %0
br label %10
10: ; preds = %45, %9
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%12 = load i32*, i32** %5
%13 = call i8* @fgets(i8* %11, i32 512, i32* %12)
store i8* %13, i8** %4
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %46
15: ; preds = %10
br label %16
16: ; preds = %22, %15
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 0
%19 = load i8, i8* %18
%20 = call i64 @isspace(i8 signext %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %4
br label %16
25: ; preds = %16
%26 = load i8*, i8** %4
%27 = call i8* @strchr(i8* %26, i8 signext 58)
store i8* %27, i8** %3
%28 = load i8*, i8** %3
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %45
30: ; preds = %25
%31 = load i8*, i8** %3
store i8 0, i8* %31
%32 = load i8*, i8** %4
%33 = call i32 @strlen(i8* %32)
%34 = icmp sgt i32 %33, 3
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %37
37: ; preds = %35, %30
%38 = load i8*, i8** %4
%39 = call i32 @strncmp(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
%40 = icmp ne i32 %39, 0
br i1 %40, label %44, label %41
41: ; preds = %37
%42 = load i8*, i8** %4
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %41, %37
br label %45
45: ; preds = %44, %25
br label %10
46: ; preds = %10
%47 = load i32*, i32** %5
%48 = call i32 @fclose(i32* %47)
store i32 0, i32* %1
br label %49
49: ; preds = %46, %8
%50 = load i32, i32* %1
ret i32 %50
}

LLVM IR (-O2):
@.str = [14 x i8] c"/proc/net/dev\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [3 x i8] c"lo\00"
@.str.4 = [5 x i8] c"%s \0A\00"
@str = [8 x i8] c"\0A\0Along\0A\00"
define i32 @main() {
%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 %34, 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 %32, 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, %29
%15 = phi i8* [ %13, %8 ], [ %30, %29 ]
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 %29, label %19
19: ; preds = %16
store i8 0, i8* %17
%20 = call i32 @strlen(i8* %9)
%21 = icmp sgt i32 %20, 3
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
%25 = call i32 @strncmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 2)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %9)
br label %29
29: ; preds = %24, %27, %16
%30 = call i8* @fgets(i8* %2, i32 512, i32* %3)
%31 = icmp eq i8* %30, null
br i1 %31, label %32, label %14
32: ; preds = %29, %5
%33 = call i32 @fclose(i32* %3)
br label %34
34: ; preds = %0, %32
%35 = phi i32 [ 0, %32 ], [ 1, %0 ]
ret i32 %35
}