#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*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int sscanf(char *, char *, int *);
char *strchr(char *, char);
int /*<<< orphan*/ *strstr(char *, char *);
int Read_Neutrino_Cfg(char *entry) {
  FILE *nfh;
  char tstr[512], *cfptr = NULL;
  int rv = -1;
  if ((nfh = fopen("/var/tuxbox/config/neutrino.conf", "r")) != NULL) {
    tstr[0] = 0;
    while ((!feof(nfh)) && ((strstr(tstr, entry) == NULL) ||
                            ((cfptr = strchr(tstr, '=')) == NULL))) {
      fgets(tstr, 500, nfh);
    }
    if (!feof(nfh) && cfptr) {
      ++cfptr;
      if (sscanf(cfptr, "%d", &rv) != 1) {
        rv = -1;
      }
    }
    fclose(nfh);
  }
  return rv;
}


x86 assembly (clang, -O0):
<Read_Neutrino_Cfg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x218(%rbp)
movl   $0xffffffff,-0x21c(%rbp)
ff ff ff
lea    0xe65(%rip),%rdi
lea    0xe7f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     12c8 <Read_Neutrino_Cfg+0x158>
movb   $0x0,-0x210(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x21d(%rbp)
jne    122e <Read_Neutrino_Cfg+0xbe>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1090 <strstr@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x21e(%rbp)
je     1222 <Read_Neutrino_Cfg+0xb2>
lea    -0x210(%rbp),%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x218(%rbp)
cmp    $0x0,%rax
sete   %al
mov    %al,-0x21e(%rbp)
mov    -0x21e(%rbp),%al
mov    %al,-0x21d(%rbp)
mov    -0x21d(%rbp),%al
test   $0x1,%al
jne    1241 <Read_Neutrino_Cfg+0xd1>
jmp    125b <Read_Neutrino_Cfg+0xeb>
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1f4,%esi
call   1050 <fgets@plt>
jmp    11bc <Read_Neutrino_Cfg+0x4c>
mov    -0x10(%rbp),%rdi
call   1060 <feof@plt>
cmp    $0x0,%eax
jne    12bf <Read_Neutrino_Cfg+0x14f>
cmpq   $0x0,-0x218(%rbp)
je     12bf <Read_Neutrino_Cfg+0x14f>
mov    -0x218(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x218(%rbp)
mov    -0x218(%rbp),%rdi
lea    0xd88(%rip),%rsi
lea    -0x21c(%rbp),%rdx
call   1070 <sscanf@plt>
cmp    $0x1,%eax
je     12ba <Read_Neutrino_Cfg+0x14a>
movl   $0xffffffff,-0x21c(%rbp)
ff ff ff
jmp    12bf <Read_Neutrino_Cfg+0x14f>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x21c(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Read_Neutrino_Cfg>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rdi,%r14
movl   $0xffffffff,0xc(%rsp)
ff
lea    0xe70(%rip),%rdi
lea    0xe8a(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11fb <Read_Neutrino_Cfg+0x8b>
mov    %rax,%r12
movb   $0x0,0x10(%rsp)
mov    %rax,%rdi
call   1060 <feof@plt>
test   %eax,%eax
je     120f <Read_Neutrino_Cfg+0x9f>
xor    %ebx,%ebx
mov    %r12,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11ed <Read_Neutrino_Cfg+0x7d>
test   %rbx,%rbx
je     11ed <Read_Neutrino_Cfg+0x7d>
add    $0x1,%rbx
lea    0xe50(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1070 <sscanf@plt>
cmp    $0x1,%eax
je     11ed <Read_Neutrino_Cfg+0x7d>
movl   $0xffffffff,0xc(%rsp)
ff
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    0xc(%rsp),%eax
jmp    1200 <Read_Neutrino_Cfg+0x90>
mov    $0xffffffff,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0x10(%rsp),%r15
jmp    1240 <Read_Neutrino_Cfg+0xd0>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x1f4,%esi
mov    %r12,%rdx
call   1050 <fgets@plt>
mov    %r12,%rdi
call   1060 <feof@plt>
test   %eax,%eax
jne    11b5 <Read_Neutrino_Cfg+0x45>
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     1220 <Read_Neutrino_Cfg+0xb0>
mov    %r15,%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1220 <Read_Neutrino_Cfg+0xb0>
mov    %rax,%rbx
jmp    11b7 <Read_Neutrino_Cfg+0x47>

LLVM IR (-O0):
@.str = [33 x i8] c"/var/tuxbox/config/neutrino.conf\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @Read_Neutrino_Cfg(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [512 x i8]
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %2
store i8* null, i8** %5
store i32 -1, i32* %6
%7 = call i32* @fopen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %3
%8 = icmp ne i32* %7, null
br i1 %8, label %9, label %50
9: ; preds = %1
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
store i8 0, i8* %10
br label %11
11: ; preds = %28, %9
%12 = load i32*, i32** %3
%13 = call i32 @feof(i32* %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %26, label %15
15: ; preds = %11
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%17 = load i8*, i8** %2
%18 = call i32* @strstr(i8* %16, i8* %17)
%19 = icmp eq i32* %18, null
br i1 %19, label %24, label %20
20: ; preds = %15
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%22 = call i8* @strchr(i8* %21, i8 signext 61)
store i8* %22, i8** %5
%23 = icmp eq i8* %22, null
br label %24
24: ; preds = %20, %15
%25 = phi i1 [ true, %15 ], [ %23, %20 ]
br label %26
26: ; preds = %24, %11
%27 = phi i1 [ false, %11 ], [ %25, %24 ]
br i1 %27, label %28, label %32
28: ; preds = %26
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%30 = load i32*, i32** %3
%31 = call i32 @fgets(i8* %29, i32 500, i32* %30)
br label %11
32: ; preds = %26
%33 = load i32*, i32** %3
%34 = call i32 @feof(i32* %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %47, label %36
36: ; preds = %32
%37 = load i8*, i8** %5
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %47
39: ; preds = %36
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %5
%42 = load i8*, i8** %5
%43 = call i32 @sscanf(i8* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%44 = icmp ne i32 %43, 1
br i1 %44, label %45, label %46
45: ; preds = %39
store i32 -1, i32* %6
br label %46
46: ; preds = %45, %39
br label %47
47: ; preds = %46, %36, %32
%48 = load i32*, i32** %3
%49 = call i32 @fclose(i32* %48)
br label %50
50: ; preds = %47, %1
%51 = load i32, i32* %6
ret i32 %51
}

LLVM IR (-O2):
@.str = [33 x i8] c"/var/tuxbox/config/neutrino.conf\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @Read_Neutrino_Cfg(i8* nocapture %0) {
%2 = alloca [512 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%5 = bitcast i32* %3 to i8*
store i32 -1, i32* %3
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %35, label %8
8: ; preds = %1
store i8 0, i8* %4
%9 = call i32 @feof(i32* %6)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %8, %17
%12 = call i32* @strstr(i8* %4, i8* dereferenceable(1) %0)
%13 = icmp eq i32* %12, null
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = call i8* @strchr(i8* %4, i8 signext 61)
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %21
17: ; preds = %11, %14
%18 = call i32 @fgets(i8* %4, i32 500, i32* %6)
%19 = call i32 @feof(i32* %6)
%20 = icmp eq i32 %19, 0
br i1 %20, label %11, label %21
21: ; preds = %14, %17, %8
%22 = phi i8* [ null, %8 ], [ null, %17 ], [ %15, %14 ]
%23 = call i32 @feof(i32* %6)
%24 = icmp eq i32 %23, 0
%25 = icmp ne i8* %22, null
%26 = select i1 %24, i1 %25, i1 false
br i1 %26, label %27, label %32
27: ; preds = %21
%28 = getelementptr inbounds i8, i8* %22, i64 1
%29 = call i32 @sscanf(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%30 = icmp eq i32 %29, 1
br i1 %30, label %32, label %31
31: ; preds = %27
store i32 -1, i32* %3
br label %32
32: ; preds = %27, %31, %21
%33 = call i32 @fclose(i32* %6)
%34 = load i32, i32* %3
br label %35
35: ; preds = %32, %1
%36 = phi i32 [ %34, %32 ], [ -1, %1 ]
ret i32 %36
}