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

/* Variables and functions */
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
scalar_t__ strcmp(char *, char *);
int parse_file(const char *path_to_file, char *str) {
  FILE *fp = fopen(path_to_file, "r");
  char line[256];
  int i;
  if (fp != NULL) {
    while (fgets(line, sizeof(line), fp) != NULL) {
      i = 0;
      while (line[i] == ' ')
        i++;
      if (line[i] == '#')
        continue;
      if (strcmp(&line[i], str) == 0) {
        fclose(fp);
        return 1;
      }
    }
  } else {
    fclose(fp);
    error("ERROR opening file");
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<parse_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     123c <parse_file+0xec>
jmp    1187 <parse_file+0x37>
lea    -0x120(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x100,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     1237 <parse_file+0xe7>
movl   $0x0,-0x124(%rbp)
movslq -0x124(%rbp),%rax
movsbl -0x120(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    11dc <parse_file+0x8c>
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
jmp    11b0 <parse_file+0x60>
movslq -0x124(%rbp),%rax
movsbl -0x120(%rbp,%rax,1),%eax
ff
cmp    $0x23,%eax
jne    11f9 <parse_file+0xa9>
jmp    1187 <parse_file+0x37>
movslq -0x124(%rbp),%rax
lea    -0x120(%rbp),%rdi
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1232 <parse_file+0xe2>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    1261 <parse_file+0x111>
jmp    1187 <parse_file+0x37>
jmp    1251 <parse_file+0x101>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xdb6(%rip),%rdi
call   1060 <error@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_file>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %rsi,%r14
lea    0xe9a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11cf <parse_file+0x7f>
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11e2 <parse_file+0x92>
xor    %ecx,%ecx
mov    %rsp,%r15
jmp    11bd <parse_file+0x6d>
nop
mov    %ecx,%eax
lea    (%rsp,%rax,1),%rdi
mov    %r14,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11f9 <parse_file+0xa9>
mov    %r15,%rdi
mov    $0x100,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
mov    $0x0,%ecx
test   %rax,%rax
je     11e2 <parse_file+0x92>
movzbl (%rsp,%rcx,1),%eax
cmp    $0x23,%al
je     11a3 <parse_file+0x53>
cmp    $0x20,%al
jne    1190 <parse_file+0x40>
add    $0x1,%rcx
jmp    11bd <parse_file+0x6d>
xor    %edi,%edi
call   1030 <fclose@plt>
lea    0xe25(%rip),%rdi
call   1060 <error@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    $0x1,%eax
jmp    11ec <parse_file+0x9c>

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

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