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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ parseRule(char *);
void parseRules(char *filename) {
  char buf[1024];
  FILE *fp = fopen(filename, "r");
  if (!fp)
    return;
  while (fgets(buf, sizeof(buf), fp)) {
    parseRule(buf);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<parseRules>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea6(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x418(%rbp)
cmpq   $0x0,-0x418(%rbp)
jne    1179 <parseRules+0x39>
jmp    11bd <parseRules+0x7d>
jmp    117e <parseRules+0x3e>
lea    -0x410(%rbp),%rdi
mov    -0x418(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     11b1 <parseRules+0x71>
lea    -0x410(%rbp),%rdi
call   1040 <parseRule@plt>
jmp    117e <parseRules+0x3e>
mov    -0x418(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseRules>:
push   %r14
push   %rbx
sub    $0x408,%rsp
lea    0xeaf(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     11a5 <parseRules+0x65>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     119d <parseRules+0x5d>
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <parseRule@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    1180 <parseRules+0x40>
mov    %r14,%rdi
call   1030 <fclose@plt>
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
define void @parseRules(i8* %0) {
%2 = alloca i8*
%3 = alloca [1024 x i8]
%4 = alloca i32*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %4
%7 = load i32*, i32** %4
%8 = icmp ne i32* %7, null
br i1 %8, label %10, label %9
9: ; preds = %1
br label %22
10: ; preds = %1
br label %11
11: ; preds = %16, %10
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%13 = load i32*, i32** %4
%14 = call i64 @fgets(i8* %12, i32 1024, i32* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%18 = call i32 @parseRule(i8* %17)
br label %11
19: ; preds = %11
%20 = load i32*, i32** %4
%21 = call i32 @fclose(i32* %20)
br label %22
22: ; preds = %19, %9
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
define void @parseRules(i8* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 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 %15, label %6
6: ; preds = %1
%7 = call i64 @fgets(i8* %3, i32 1024, i32* %4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %6, %9
%10 = call i32 @parseRule(i8* %3)
%11 = call i64 @fgets(i8* %3, i32 1024, i32* %4)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %9
13: ; preds = %9, %6
%14 = call i32 @fclose(i32* %4)
br label %15
15: ; preds = %1, %13
ret void
}