#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*/ CONFIG_parse_line(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int strlen(char *);
int CONFIG_read_file(const char *filename) {
  FILE *file;
  char line_buffer[250];
  if (!(file = fopen(filename, "r"))) {
    return 0;
  }
  while (fgets(line_buffer, 250, file)) {
    while (line_buffer[strlen(line_buffer) - 1] == 10 ||
           line_buffer[strlen(line_buffer) - 1] == 13) {
      line_buffer[strlen(line_buffer) - 1] = '\0';
    }
    CONFIG_parse_line(line_buffer);
  }
  fclose(file);
  return 1;
}


x86 assembly (clang, -O0):
<CONFIG_read_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe96(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1189 <CONFIG_read_file+0x39>
movl   $0x0,-0x4(%rbp)
jmp    1253 <CONFIG_read_file+0x103>
jmp    118e <CONFIG_read_file+0x3e>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xfa,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1243 <CONFIG_read_file+0xf3>
jmp    11b2 <CONFIG_read_file+0x62>
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x120(%rbp,%rax,1),%ecx
ff
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x121(%rbp)
je     1201 <CONFIG_read_file+0xb1>
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x120(%rbp,%rax,1),%eax
ff
cmp    $0xd,%eax
sete   %al
mov    %al,-0x121(%rbp)
mov    -0x121(%rbp),%al
test   $0x1,%al
jne    1214 <CONFIG_read_file+0xc4>
jmp    1232 <CONFIG_read_file+0xe2>
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x120(%rbp,%rax,1)
jmp    11b2 <CONFIG_read_file+0x62>
lea    -0x120(%rbp),%rdi
call   1060 <CONFIG_parse_line@plt>
jmp    118e <CONFIG_read_file+0x3e>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CONFIG_read_file>:
push   %r14
push   %rbx
sub    $0x108,%rsp
lea    0xe9f(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11ea <CONFIG_read_file+0x9a>
mov    %rax,%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0xfa,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    11af <CONFIG_read_file+0x5f>
jmp    11db <CONFIG_read_file+0x8b>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%rbx,1)
je     11a0 <CONFIG_read_file+0x50>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0xd,-0x1(%rax,%rbx,1)
je     11a0 <CONFIG_read_file+0x50>
mov    %rbx,%rdi
call   1060 <CONFIG_parse_line@plt>
jmp    1180 <CONFIG_read_file+0x30>
mov    %r14,%rdi
call   1030 <fclose@plt>
mov    $0x1,%eax
jmp    11ec <CONFIG_read_file+0x9c>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define i32 @CONFIG_read_file(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca [250 x i8]
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %4
%8 = icmp ne i32* %7, null
br i1 %8, label %10, label %9
9: ; preds = %1
store i32 0, i32* %2
br label %49
10: ; preds = %1
br label %11
11: ; preds = %43, %10
%12 = getelementptr inbounds [250 x i8], [250 x i8]* %5, i64 0, i64 0
%13 = load i32*, i32** %4
%14 = call i64 @fgets(i8* %12, i32 250, i32* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %46
16: ; preds = %11
br label %17
17: ; preds = %37, %16
%18 = getelementptr inbounds [250 x i8], [250 x i8]* %5, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [250 x i8], [250 x i8]* %5, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 10
br i1 %25, label %35, label %26
26: ; preds = %17
%27 = getelementptr inbounds [250 x i8], [250 x i8]* %5, i64 0, i64 0
%28 = call i32 @strlen(i8* %27)
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [250 x i8], [250 x i8]* %5, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 13
br label %35
35: ; preds = %26, %17
%36 = phi i1 [ true, %17 ], [ %34, %26 ]
br i1 %36, label %37, label %43
37: ; preds = %35
%38 = getelementptr inbounds [250 x i8], [250 x i8]* %5, i64 0, i64 0
%39 = call i32 @strlen(i8* %38)
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [250 x i8], [250 x i8]* %5, i64 0, i64 %41
store i8 0, i8* %42
br label %17
43: ; preds = %35
%44 = getelementptr inbounds [250 x i8], [250 x i8]* %5, i64 0, i64 0
%45 = call i32 @CONFIG_parse_line(i8* %44)
br label %11
46: ; preds = %11
%47 = load i32*, i32** %4
%48 = call i32 @fclose(i32* %47)
store i32 1, i32* %2
br label %49
49: ; preds = %46, %9
%50 = load i32, i32* %2
ret i32 %50
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define i32 @CONFIG_read_file(i8* nocapture %0) {
%2 = alloca [250 x i8]
%3 = getelementptr inbounds [250 x i8], [250 x i8]* %2, i64 0, i64 0
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %35, label %6
6: ; preds = %1
%7 = call i64 @fgets(i8* %3, i32 250, i32* %4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %33, label %9
9: ; preds = %6, %28
%10 = call i32 @strlen(i8* %3)
%11 = add nsw i32 %10, -1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [250 x i8], [250 x i8]* %2, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 10
br i1 %15, label %23, label %16
16: ; preds = %9
%17 = call i32 @strlen(i8* %3)
%18 = add nsw i32 %17, -1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [250 x i8], [250 x i8]* %2, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 13
br i1 %22, label %23, label %29
23: ; preds = %9, %16
%24 = call i32 @strlen(i8* %3)
%25 = add nsw i32 %24, -1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [250 x i8], [250 x i8]* %2, i64 0, i64 %26
store i8 0, i8* %27
br label %28
28: ; preds = %23, %29
br label %9
29: ; preds = %16
%30 = call i32 @CONFIG_parse_line(i8* %3)
%31 = call i64 @fgets(i8* %3, i32 250, i32* %4)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %28
33: ; preds = %29, %6
%34 = call i32 @fclose(i32* %4)
br label %35
35: ; preds = %1, %33
%36 = phi i32 [ 1, %33 ], [ 0, %1 ]
ret i32 %36
}