#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 */
typedef struct TYPE_8__ TYPE_2__;
typedef struct TYPE_7__ TYPE_1__;

/* Type definitions */
struct TYPE_7__ {
  int rm_so;
  scalar_t__ rm_eo;
};
typedef TYPE_1__ regmatch_t;
struct TYPE_8__ {
  int re_nsub;
};
typedef TYPE_2__ regex_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ REG_EXTENDED;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, scalar_t__,
                           char const *);
int /*<<< orphan*/ fread(char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
char *malloc(int);
scalar_t__ regcomp(TYPE_2__ *, char *, int /*<<< orphan*/);
scalar_t__ regexec(TYPE_2__ *, char const *, int, TYPE_1__ *,
                   int /*<<< orphan*/);
int /*<<< orphan*/ regfree(TYPE_2__ *);
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ rename(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int parse_file(char *filename, char *out_file, char *pattern) {
  FILE *fp = fopen(filename, "rb");
  if (fp == NULL) {
    return 0;
  }
  fseek(fp, 0, SEEK_END);
  long len = ftell(fp);
  fseek(fp, 0, SEEK_SET);
  char *buffer = malloc((int)len + 1);
  fread(buffer, 1, len, fp);
  buffer[len] = '\0';
  fclose(fp);
  regex_t re;
  regmatch_t match[10];
  if (regcomp(&re, pattern, REG_EXTENDED) != 0) {
    return 0;
  }
  char *ext_temp = ".tmp";
  char *out_temp = malloc(strlen(out_file) + strlen(ext_temp) + 1);
  strcpy(out_temp, out_file);
  strcat(out_temp, ext_temp);
  FILE *out_file_tmp = fopen(out_temp, "wb");
  if (out_file_tmp == NULL) {
    return 0;
  }
  char *format[2] = {"\"%.*s\",", "\"%.*s\"\n"};
  int i = 0;
  int j = 0;
  const char *p = buffer;
  for (i = 0; (regexec(&re, p, re.re_nsub, match, 0) == 0); i++) {
    for (j = 1; j < re.re_nsub; j++) {
      if (match[j].rm_so == -1) {
        continue;
      }
      fprintf(out_file_tmp, format[(j == (re.re_nsub - 1))],
              match[j].rm_eo - match[j].rm_so, &p[match[j].rm_so]);
    }
    p += match[0].rm_eo;
  }
  fclose(out_file_tmp);
  free(buffer);
  regfree(&re);
  if (i > 1) {
    remove(out_file);
    rename(out_temp, out_file);
    return i;
  }
  remove(out_temp);
  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    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xdde(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1242 <parse_file+0x42>
movl   $0x0,-0x4(%rbp)
jmp    1543 <parse_file+0x343>
mov    -0x28(%rbp),%rdi
mov    0x2d93(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10f0 <fseek@plt>
mov    -0x28(%rbp),%rdi
call   10c0 <ftell@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x2d62(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10f0 <fseek@plt>
mov    -0x30(%rbp),%rax
mov    %eax,%edi
add    $0x1,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   1060 <fread@plt>
mov    -0x38(%rbp),%rax
mov    -0x30(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x20(%rbp),%rsi
mov    0x2d09(%rip),%rax
mov    (%rax),%edx
lea    -0x40(%rbp),%rdi
call   10a0 <regcomp@plt>
cmp    $0x0,%rax
je     12e0 <parse_file+0xe0>
movl   $0x0,-0x4(%rbp)
jmp    1543 <parse_file+0x343>
lea    0xd1c(%rip),%rax
mov    %rax,-0xe8(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <strlen@plt>
mov    %eax,-0x124(%rbp)
mov    -0xe8(%rbp),%rdi
call   1090 <strlen@plt>
mov    -0x124(%rbp),%edi
add    %eax,%edi
add    $0x1,%edi
call   10d0 <malloc@plt>
mov    %rax,-0xf0(%rbp)
mov    -0xf0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0xf0(%rbp),%rdi
mov    -0xe8(%rbp),%rsi
call   1120 <strcat@plt>
mov    -0xf0(%rbp),%rdi
lea    0xcb7(%rip),%rsi
call   1100 <fopen@plt>
mov    %rax,-0xf8(%rbp)
cmpq   $0x0,-0xf8(%rbp)
jne    1377 <parse_file+0x177>
movl   $0x0,-0x4(%rbp)
jmp    1543 <parse_file+0x343>
mov    0x2a72(%rip),%rax
mov    %rax,-0x110(%rbp)
mov    0x2a6c(%rip),%rax
mov    %rax,-0x108(%rbp)
movl   $0x0,-0x114(%rbp)
movl   $0x0,-0x118(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x120(%rbp)
movl   $0x0,-0x114(%rbp)
mov    -0x120(%rbp),%rsi
mov    -0x40(%rbp),%edx
lea    -0xe0(%rbp),%rcx
lea    -0x40(%rbp),%rdi
xor    %r8d,%r8d
call   10e0 <regexec@plt>
cmp    $0x0,%rax
jne    14de <parse_file+0x2de>
movl   $0x1,-0x118(%rbp)
mov    -0x118(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    14b5 <parse_file+0x2b5>
movslq -0x118(%rbp),%rcx
lea    -0xe0(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
cmpl   $0xffffffff,(%rax)
jne    141f <parse_file+0x21f>
jmp    14a1 <parse_file+0x2a1>
mov    -0xf8(%rbp),%rdi
mov    -0x118(%rbp),%eax
mov    -0x40(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
cltq
mov    -0x110(%rbp,%rax,8),%rsi
ff
movslq -0x118(%rbp),%rcx
lea    -0xe0(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%rdx
movslq -0x118(%rbp),%rcx
lea    -0xe0(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
movslq (%rax),%rax
sub    %rax,%rdx
mov    -0x120(%rbp),%rcx
movslq -0x118(%rbp),%r8
lea    -0xe0(%rbp),%rax
shl    $0x4,%r8
add    %r8,%rax
movslq (%rax),%rax
add    %rax,%rcx
call   10b0 <fprintf@plt>
mov    -0x118(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x118(%rbp)
jmp    13ed <parse_file+0x1ed>
mov    -0xd8(%rbp),%rax
add    -0x120(%rbp),%rax
mov    %rax,-0x120(%rbp)
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    13bc <parse_file+0x1bc>
mov    -0xf8(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
lea    -0x40(%rbp),%rdi
call   1080 <regfree@plt>
cmpl   $0x1,-0x114(%rbp)
jle    1530 <parse_file+0x330>
mov    -0x18(%rbp),%rdi
call   1040 <remove@plt>
mov    -0xf0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1110 <rename@plt>
mov    -0x114(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1543 <parse_file+0x343>
mov    -0xf0(%rbp),%rdi
call   1040 <remove@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
lea    0xde2(%rip),%rsi
call   1100 <fopen@plt>
test   %rax,%rax
je     1372 <parse_file+0x172>
mov    %rax,%rbx
mov    0x2db2(%rip),%rax
mov    (%rax),%edx
xor    %r13d,%r13d
mov    %rbx,%rdi
xor    %esi,%esi
call   10f0 <fseek@plt>
mov    %rbx,%rdi
call   10c0 <ftell@plt>
mov    %rax,%rbp
mov    0x2d81(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   10f0 <fseek@plt>
lea    0x1(%rbp),%edi
call   10d0 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    $0x1,%esi
mov    %rbp,%rdx
mov    %rbx,%rcx
call   1060 <fread@plt>
movb   $0x0,(%r12,%rbp,1)
mov    %rbx,%rdi
call   1070 <fclose@plt>
mov    0x2d3b(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    %r15,%rsi
call   10a0 <regcomp@plt>
test   %rax,%rax
jne    1375 <parse_file+0x175>
mov    %r14,%rdi
call   1090 <strlen@plt>
mov    %eax,%ebx
lea    0xd47(%rip),%rbp
mov    %rbp,%rdi
call   1090 <strlen@plt>
lea    (%rbx,%rax,1),%edi
add    $0x1,%edi
call   10d0 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <strcpy@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1120 <strcat@plt>
lea    0xd19(%rip),%rsi
mov    %rbx,0x10(%rsp)
mov    %rbx,%rdi
call   1100 <fopen@plt>
test   %rax,%rax
je     1375 <parse_file+0x175>
mov    %rax,%rbx
mov    %r14,0x18(%rsp)
mov    (%rsp),%edx
mov    %rsp,%rdi
lea    0x20(%rsp),%rcx
xor    %r13d,%r13d
mov    %r12,0x8(%rsp)
mov    %r12,%rsi
xor    %r8d,%r8d
call   10e0 <regexec@plt>
test   %rax,%rax
je     138a <parse_file+0x18a>
mov    %rbx,%rdi
call   1070 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %rsp,%rdi
call   1080 <regfree@plt>
cmp    $0x2,%r13d
jb     1368 <parse_file+0x168>
mov    0x18(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <remove@plt>
mov    0x10(%rsp),%rdi
mov    %rbx,%rsi
call   1110 <rename@plt>
jmp    1375 <parse_file+0x175>
mov    0x10(%rsp),%rdi
call   1040 <remove@plt>
xor    %r13d,%r13d
mov    %r13d,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r13d,%r13d
lea    0xc88(%rip),%rbp
mov    0x8(%rsp),%r12
jmp    13c5 <parse_file+0x1c5>
nopl   0x0(%rax,%rax,1)
add    0x28(%rsp),%r12
add    $0x1,%r13d
mov    %rsp,%rdi
mov    %r12,%rsi
lea    0x20(%rsp),%rcx
xor    %r8d,%r8d
call   10e0 <regexec@plt>
test   %rax,%rax
jne    132c <parse_file+0x12c>
mov    (%rsp),%edx
cmp    $0x2,%edx
jl     13a0 <parse_file+0x1a0>
mov    $0x1,%r15d
lea    0x38(%rsp),%r14
jmp    13f0 <parse_file+0x1f0>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r15
movslq %edx,%rax
add    $0x10,%r14
cmp    %rax,%r15
jge    13a0 <parse_file+0x1a0>
movslq -0x8(%r14),%rcx
cmp    $0xffffffffffffffff,%rcx
je     13e0 <parse_file+0x1e0>
add    $0xffffffff,%edx
xor    %eax,%eax
cmp    %rdx,%r15
sete   %al
movslq 0x0(%rbp,%rax,4),%rsi
add    %rbp,%rsi
mov    (%r14),%rdx
sub    %rcx,%rdx
add    %r12,%rcx
mov    %rbx,%rdi
call   10b0 <fprintf@plt>
mov    (%rsp),%edx
jmp    13e0 <parse_file+0x1e0>

LLVM IR (-O0):
%struct.TYPE_8__ = type { i32 }
%struct.TYPE_7__ = type { i32, i64 }
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@REG_EXTENDED = global i32 0
@.str.1 = [5 x i8] c".tmp\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [8 x i8] c"\22%.*s\22,\00"
@.str.4 = [8 x i8] c"\22%.*s\22\0A\00"
@__const.parse_file.format = [2 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0)]
define i32 @parse_file(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca %struct.TYPE_8__
%12 = alloca [10 x %struct.TYPE_7__]
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32*
%16 = alloca [2 x i8*]
%17 = alloca i32
%18 = alloca i32
%19 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%20 = load i8*, i8** %5
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %21, i32** %8
%22 = load i32*, i32** %8
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %25
24: ; preds = %3
store i32 0, i32* %4
br label %157
25: ; preds = %3
%26 = load i32*, i32** %8
%27 = load i32, i32* @SEEK_END
%28 = call i32 @fseek(i32* %26, i32 0, i32 %27)
%29 = load i32*, i32** %8
%30 = call i64 @ftell(i32* %29)
store i64 %30, i64* %9
%31 = load i32*, i32** %8
%32 = load i32, i32* @SEEK_SET
%33 = call i32 @fseek(i32* %31, i32 0, i32 %32)
%34 = load i64, i64* %9
%35 = trunc i64 %34 to i32
%36 = add nsw i32 %35, 1
%37 = call i8* @malloc(i32 %36)
store i8* %37, i8** %10
%38 = load i8*, i8** %10
%39 = load i64, i64* %9
%40 = load i32*, i32** %8
%41 = call i32 @fread(i8* %38, i32 1, i64 %39, i32* %40)
%42 = load i8*, i8** %10
%43 = load i64, i64* %9
%44 = getelementptr inbounds i8, i8* %42, i64 %43
store i8 0, i8* %44
%45 = load i32*, i32** %8
%46 = call i32 @fclose(i32* %45)
%47 = load i8*, i8** %7
%48 = load i32, i32* @REG_EXTENDED
%49 = call i64 @regcomp(%struct.TYPE_8__* %11, i8* %47, i32 %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %25
store i32 0, i32* %4
br label %157
52: ; preds = %25
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %13
%53 = load i8*, i8** %6
%54 = call i32 @strlen(i8* %53)
%55 = load i8*, i8** %13
%56 = call i32 @strlen(i8* %55)
%57 = add nsw i32 %54, %56
%58 = add nsw i32 %57, 1
%59 = call i8* @malloc(i32 %58)
store i8* %59, i8** %14
%60 = load i8*, i8** %14
%61 = load i8*, i8** %6
%62 = call i32 @strcpy(i8* %60, i8* %61)
%63 = load i8*, i8** %14
%64 = load i8*, i8** %13
%65 = call i32 @strcat(i8* %63, i8* %64)
%66 = load i8*, i8** %14
%67 = call i32* @fopen(i8* %66, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %67, i32** %15
%68 = load i32*, i32** %15
%69 = icmp eq i32* %68, null
br i1 %69, label %70, label %71
70: ; preds = %52
store i32 0, i32* %4
br label %157
71: ; preds = %52
%72 = bitcast [2 x i8*]* %16 to i8*
store i32 0, i32* %17
store i32 0, i32* %18
%73 = load i8*, i8** %10
store i8* %73, i8** %19
store i32 0, i32* %17
br label %74
74: ; preds = %136, %71
%75 = load i8*, i8** %19
%76 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %11, i32 0, i32 0
%77 = load i32, i32* %76
%78 = getelementptr inbounds [10 x %struct.TYPE_7__], [10 x %struct.TYPE_7__]* %12, i64 0, i64 0
%79 = call i64 @regexec(%struct.TYPE_8__* %11, i8* %75, i32 %77, %struct.TYPE_7__* %78, i32 0)
%80 = icmp eq i64 %79, 0
br i1 %80, label %81, label %139
81: ; preds = %74
store i32 1, i32* %18
br label %82
82: ; preds = %127, %81
%83 = load i32, i32* %18
%84 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %11, i32 0, i32 0
%85 = load i32, i32* %84
%86 = icmp slt i32 %83, %85
br i1 %86, label %87, label %130
87: ; preds = %82
%88 = load i32, i32* %18
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds [10 x %struct.TYPE_7__], [10 x %struct.TYPE_7__]* %12, i64 0, i64 %89
%91 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %90, i32 0, i32 0
%92 = load i32, i32* %91
%93 = icmp eq i32 %92, -1
br i1 %93, label %94, label %95
94: ; preds = %87
br label %127
95: ; preds = %87
%96 = load i32*, i32** %15
%97 = load i32, i32* %18
%98 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %11, i32 0, i32 0
%99 = load i32, i32* %98
%100 = sub nsw i32 %99, 1
%101 = icmp eq i32 %97, %100
%102 = zext i1 %101 to i32
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds [2 x i8*], [2 x i8*]* %16, i64 0, i64 %103
%105 = load i8*, i8** %104
%106 = load i32, i32* %18
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds [10 x %struct.TYPE_7__], [10 x %struct.TYPE_7__]* %12, i64 0, i64 %107
%109 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %108, i32 0, i32 1
%110 = load i64, i64* %109
%111 = load i32, i32* %18
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds [10 x %struct.TYPE_7__], [10 x %struct.TYPE_7__]* %12, i64 0, i64 %112
%114 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %113, i32 0, i32 0
%115 = load i32, i32* %114
%116 = sext i32 %115 to i64
%117 = sub nsw i64 %110, %116
%118 = load i8*, i8** %19
%119 = load i32, i32* %18
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds [10 x %struct.TYPE_7__], [10 x %struct.TYPE_7__]* %12, i64 0, i64 %120
%122 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %121, i32 0, i32 0
%123 = load i32, i32* %122
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds i8, i8* %118, i64 %124
%126 = call i32 @fprintf(i32* %96, i8* %105, i64 %117, i8* %125)
br label %127
127: ; preds = %95, %94
%128 = load i32, i32* %18
%129 = add nsw i32 %128, 1
store i32 %129, i32* %18
br label %82
130: ; preds = %82
%131 = getelementptr inbounds [10 x %struct.TYPE_7__], [10 x %struct.TYPE_7__]* %12, i64 0, i64 0
%132 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %131, i32 0, i32 1
%133 = load i64, i64* %132
%134 = load i8*, i8** %19
%135 = getelementptr inbounds i8, i8* %134, i64 %133
store i8* %135, i8** %19
br label %136
136: ; preds = %130
%137 = load i32, i32* %17
%138 = add nsw i32 %137, 1
store i32 %138, i32* %17
br label %74
139: ; preds = %74
%140 = load i32*, i32** %15
%141 = call i32 @fclose(i32* %140)
%142 = load i8*, i8** %10
%143 = call i32 @free(i8* %142)
%144 = call i32 @regfree(%struct.TYPE_8__* %11)
%145 = load i32, i32* %17
%146 = icmp sgt i32 %145, 1
br i1 %146, label %147, label %154
147: ; preds = %139
%148 = load i8*, i8** %6
%149 = call i32 @remove(i8* %148)
%150 = load i8*, i8** %14
%151 = load i8*, i8** %6
%152 = call i32 @rename(i8* %150, i8* %151)
%153 = load i32, i32* %17
store i32 %153, i32* %4
br label %157
154: ; preds = %139
%155 = load i8*, i8** %14
%156 = call i32 @remove(i8* %155)
store i32 0, i32* %4
br label %157
157: ; preds = %154, %147, %70, %51, %24
%158 = load i32, i32* %4
ret i32 %158
}

LLVM IR (-O2):
%struct.TYPE_8__ = type { i32 }
%struct.TYPE_7__ = type { i32, i64 }
@.str = [3 x i8] c"rb\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@REG_EXTENDED = global i32 0
@.str.1 = [5 x i8] c".tmp\00"
@.str.2 = [3 x i8] c"wb\00"
@.str.3 = [8 x i8] c"\22%.*s\22,\00"
@.str.4 = [8 x i8] c"\22%.*s\22\0A\00"
@reltable.parse_file = [2 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.3 to i64), i64 ptrtoint ([2 x i32]* @reltable.parse_file to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.4 to i64), i64 ptrtoint ([2 x i32]* @reltable.parse_file to i64)) to i32)]
define i32 @parse_file(i8* nocapture %0, i8* %1, i8* %2) {
%4 = alloca %struct.TYPE_8__
%5 = alloca [10 x %struct.TYPE_7__]
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %93, label %8
8: ; preds = %3
%9 = load i32, i32* @SEEK_END
%10 = tail call i32 @fseek(i32* %6, i32 0, i32 %9)
%11 = tail call i64 @ftell(i32* %6)
%12 = load i32, i32* @SEEK_SET
%13 = tail call i32 @fseek(i32* %6, i32 0, i32 %12)
%14 = trunc i64 %11 to i32
%15 = add nsw i32 %14, 1
%16 = tail call i8* @malloc(i32 %15)
%17 = tail call i32 @fread(i8* %16, i32 1, i64 %11, i32* %6)
%18 = getelementptr inbounds i8, i8* %16, i64 %11
store i8 0, i8* %18
%19 = tail call i32 @fclose(i32* %6)
%20 = bitcast %struct.TYPE_8__* %4 to i8*
%21 = bitcast [10 x %struct.TYPE_7__]* %5 to i8*
%22 = load i32, i32* @REG_EXTENDED
%23 = call i64 @regcomp(%struct.TYPE_8__* %4, i8* %2, i32 %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %91
25: ; preds = %8
%26 = call i32 @strlen(i8* %1)
%27 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%28 = add i32 %26, 1
%29 = add i32 %28, %27
%30 = call i8* @malloc(i32 %29)
%31 = call i32 @strcpy(i8* %30, i8* %1)
%32 = call i32 @strcat(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp eq i32* %33, null
br i1 %34, label %91, label %35
35: ; preds = %25
%36 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %4, i64 0, i32 0
%37 = getelementptr inbounds [10 x %struct.TYPE_7__], [10 x %struct.TYPE_7__]* %5, i64 0, i64 0
%38 = load i32, i32* %36
%39 = call i64 @regexec(%struct.TYPE_8__* %4, i8* %16, i32 %38, %struct.TYPE_7__* %37, i32 0)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %80
41: ; preds = %35
%42 = getelementptr inbounds [10 x %struct.TYPE_7__], [10 x %struct.TYPE_7__]* %5, i64 0, i64 0, i32 1
br label %43
43: ; preds = %41, %73
%44 = phi i8* [ %16, %41 ], [ %76, %73 ]
%45 = phi i32 [ 0, %41 ], [ %77, %73 ]
%46 = load i32, i32* %36
%47 = icmp sgt i32 %46, 1
br i1 %47, label %48, label %73
48: ; preds = %43, %68
%49 = phi i32 [ %69, %68 ], [ %46, %43 ]
%50 = phi i64 [ %70, %68 ], [ 1, %43 ]
%51 = getelementptr inbounds [10 x %struct.TYPE_7__], [10 x %struct.TYPE_7__]* %5, i64 0, i64 %50, i32 0
%52 = load i32, i32* %51
%53 = icmp eq i32 %52, -1
br i1 %53, label %68, label %54
54: ; preds = %48
%55 = add nsw i32 %49, -1
%56 = zext i32 %55 to i64
%57 = icmp eq i64 %50, %56
%58 = zext i1 %57 to i64
%59 = shl i64 %58, 2
%60 = call i8* @llvm.load.relative.i64(i8* bitcast ([2 x i32]* @reltable.parse_file to i8*), i64 %59)
%61 = getelementptr inbounds [10 x %struct.TYPE_7__], [10 x %struct.TYPE_7__]* %5, i64 0, i64 %50, i32 1
%62 = load i64, i64* %61
%63 = sext i32 %52 to i64
%64 = sub nsw i64 %62, %63
%65 = getelementptr inbounds i8, i8* %44, i64 %63
%66 = call i32 @fprintf(i32* %33, i8* %60, i64 %64, i8* %65)
%67 = load i32, i32* %36
br label %68
68: ; preds = %48, %54
%69 = phi i32 [ %49, %48 ], [ %67, %54 ]
%70 = add nuw nsw i64 %50, 1
%71 = sext i32 %69 to i64
%72 = icmp slt i64 %70, %71
br i1 %72, label %48, label %73
73: ; preds = %68, %43
%74 = phi i32 [ %46, %43 ], [ %69, %68 ]
%75 = load i64, i64* %42
%76 = getelementptr inbounds i8, i8* %44, i64 %75
%77 = add nuw nsw i32 %45, 1
%78 = call i64 @regexec(%struct.TYPE_8__* %4, i8* %76, i32 %74, %struct.TYPE_7__* %37, i32 0)
%79 = icmp eq i64 %78, 0
br i1 %79, label %43, label %80
80: ; preds = %73, %35
%81 = phi i32 [ 0, %35 ], [ %77, %73 ]
%82 = call i32 @fclose(i32* %33)
%83 = call i32 @free(i8* %16)
%84 = call i32 @regfree(%struct.TYPE_8__* %4)
%85 = icmp ugt i32 %81, 1
br i1 %85, label %86, label %89
86: ; preds = %80
%87 = call i32 @remove(i8* %1)
%88 = call i32 @rename(i8* %30, i8* %1)
br label %91
89: ; preds = %80
%90 = call i32 @remove(i8* %30)
br label %91
91: ; preds = %25, %89, %86, %8
%92 = phi i32 [ 0, %8 ], [ 0, %25 ], [ %81, %86 ], [ 0, %89 ]
br label %93
93: ; preds = %3, %91
%94 = phi i32 [ %92, %91 ], [ 0, %3 ]
ret i32 %94
}