#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 feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ getentry(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
scalar_t__ strstr(char *, char *);
void fill_var(int debug, char buffer[512], FILE *fact, FILE *commonfact) {
  int i, n, count;
  char tmpbuffer[512];
  char allfacts[200];
  char factname[200];
  char factvalue[200];
  int counter;
  for (i = 0; i <= 512; i++)
    tmpbuffer[i] = 0;
  for (i = 0, n = 0; i <= strlen(buffer); i++, n++) {
    if (buffer[i] != '<') {
      tmpbuffer[n] = buffer[i];
      continue;
    }
    if (buffer[++i] != '%') {
      tmpbuffer[n++] = '<';
      tmpbuffer[n] = buffer[i];
      continue;
    }
    if (buffer[++i] != '$') {
      tmpbuffer[n++] = '<';
      tmpbuffer[n++] = '%';
      tmpbuffer[n] = buffer[i];
      continue;
    }
    if (debug == 0)
      printf("found fact ... looking for factname\n");
    for (counter = 0; buffer[++i] != '%'; counter++) {
      factname[counter] = buffer[i];
    }
    factname[counter] = '\0';
    if (debug == 0) {
      printf("found factname: %s\n", factname);
      printf("looking for factvalue\n");
    }
    factname[counter++] = '=';
    factname[counter] = '\0';
    rewind(commonfact);
    do {
      fgets(allfacts, 200, commonfact);
      if (strstr(allfacts, factname) != 0)
        getentry(allfacts, factvalue);
    } while (feof(commonfact) != 1);
    rewind(fact);
    do {
      fgets(allfacts, 200, fact);
      if (strstr(allfacts, factname) != 0) {
        getentry(allfacts, factvalue);
      }
    } while (feof(fact) != 1);
    if (debug == 0) {
      printf("found factvalue: %s\n", factvalue);
      printf("adding fact to buffer\n");
    }
    strcat(tmpbuffer, factvalue);
    if (debug == 0)
      printf("current buffer: %s\n", tmpbuffer);
    n = strlen(tmpbuffer) - 1;
    i++;
  }
  strcpy(buffer, tmpbuffer);
}


x86 assembly (clang, -O0):
<fill_var>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4b0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x200,-0x24(%rbp)
jg     11d8 <fill_var+0x48>
movslq -0x24(%rbp),%rax
movb   $0x0,-0x230(%rbp,%rax,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b1 <fill_var+0x21>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x4a8(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x4a8(%rbp),%eax
cmp    %ecx,%eax
jg     1514 <fill_var+0x384>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3c,%eax
je     1238 <fill_var+0xa8>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x28(%rbp),%rax
mov    %cl,-0x230(%rbp,%rax,1)
jmp    14fd <fill_var+0x36d>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x24(%rbp)
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x25,%eax
je     1285 <fill_var+0xf5>
mov    -0x28(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x28(%rbp)
cltq
movb   $0x3c,-0x230(%rbp,%rax,1)
3c
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x28(%rbp),%rax
mov    %cl,-0x230(%rbp,%rax,1)
jmp    14fd <fill_var+0x36d>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x24(%rbp)
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x24,%eax
je     12e7 <fill_var+0x157>
mov    -0x28(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x28(%rbp)
cltq
movb   $0x3c,-0x230(%rbp,%rax,1)
3c
mov    -0x28(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x28(%rbp)
cltq
movb   $0x25,-0x230(%rbp,%rax,1)
25
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x28(%rbp),%rax
mov    %cl,-0x230(%rbp,%rax,1)
jmp    14fd <fill_var+0x36d>
cmpl   $0x0,-0x4(%rbp)
jne    12ff <fill_var+0x16f>
lea    0xd08(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4a4(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x24(%rbp)
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x25,%eax
je     1353 <fill_var+0x1c3>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x4a4(%rbp),%rax
mov    %cl,-0x3d0(%rbp,%rax,1)
mov    -0x4a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4a4(%rbp)
jmp    1309 <fill_var+0x179>
movslq -0x4a4(%rbp),%rax
movb   $0x0,-0x3d0(%rbp,%rax,1)
cmpl   $0x0,-0x4(%rbp)
jne    138f <fill_var+0x1ff>
lea    -0x3d0(%rbp),%rsi
lea    0xcab(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xcb1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4a4(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x4a4(%rbp)
cltq
movb   $0x3d,-0x3d0(%rbp,%rax,1)
3d
movslq -0x4a4(%rbp),%rax
movb   $0x0,-0x3d0(%rbp,%rax,1)
mov    -0x20(%rbp),%rdi
call   1060 <rewind@plt>
lea    -0x300(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0xc8,%esi
call   1070 <fgets@plt>
lea    -0x300(%rbp),%rdi
lea    -0x3d0(%rbp),%rsi
call   10b0 <strstr@plt>
cmp    $0x0,%rax
je     1407 <fill_var+0x277>
lea    -0x300(%rbp),%rdi
lea    -0x4a0(%rbp),%rsi
call   1090 <getentry@plt>
jmp    140c <fill_var+0x27c>
mov    -0x20(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x1,%eax
jne    13c2 <fill_var+0x232>
mov    -0x18(%rbp),%rdi
call   1060 <rewind@plt>
lea    -0x300(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0xc8,%esi
call   1070 <fgets@plt>
lea    -0x300(%rbp),%rdi
lea    -0x3d0(%rbp),%rsi
call   10b0 <strstr@plt>
cmp    $0x0,%rax
je     146c <fill_var+0x2dc>
lea    -0x300(%rbp),%rdi
lea    -0x4a0(%rbp),%rsi
call   1090 <getentry@plt>
jmp    1471 <fill_var+0x2e1>
mov    -0x18(%rbp),%rdi
call   1080 <feof@plt>
cmp    $0x1,%eax
jne    1427 <fill_var+0x297>
cmpl   $0x0,-0x4(%rbp)
jne    14b0 <fill_var+0x320>
lea    -0x4a0(%rbp),%rsi
lea    0xbb5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xbbc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x230(%rbp),%rdi
lea    -0x4a0(%rbp),%rsi
call   10a0 <strcat@plt>
cmpl   $0x0,-0x4(%rbp)
jne    14e2 <fill_var+0x352>
lea    -0x230(%rbp),%rsi
lea    0xba1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x230(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11e6 <fill_var+0x56>
mov    -0x10(%rbp),%rdi
lea    -0x230(%rbp),%rsi
call   1030 <strcpy@plt>
add    $0x4b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fill_var>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x498,%rsp
mov    %rcx,0x28(%rsp)
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %edi,0xc(%rsp)
lea    0x30(%rsp),%rdi
mov    $0x201,%edx
xor    %esi,%esi
call   1080 <memset@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
test   %eax,%eax
js     145c <fill_var+0x2ac>
lea    0x1(%rdi),%rax
mov    %rax,0x20(%rsp)
lea    0x3d0(%rsp),%r13
xor    %r12d,%r12d
xor    %ebp,%ebp
mov    %rdi,0x10(%rsp)
jmp    124a <fill_var+0x9a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movslq %ebp,%rcx
mov    %al,0x30(%rsp,%rcx,1)
lea    0x1(%r12),%ebx
add    $0x1,%ebp
mov    0x10(%rsp),%rdi
call   1050 <strlen@plt>
mov    0x10(%rsp),%rdi
cmp    %eax,%r12d
mov    %ebx,%r12d
jge    145c <fill_var+0x2ac>
movslq %r12d,%r14
mov    (%rdi,%r14,1),%al
cmp    $0x3c,%al
jne    1220 <fill_var+0x70>
mov    0x1(%rdi,%r14,1),%al
cmp    $0x25,%al
jne    1370 <fill_var+0x1c0>
lea    0x2(%r14),%rcx
mov    0x2(%rdi,%r14,1),%al
cmp    $0x24,%al
jne    138c <fill_var+0x1dc>
mov    %rcx,0x18(%rsp)
cmpl   $0x0,0xc(%rsp)
mov    0x28(%rsp),%rbx
jne    1295 <fill_var+0xe5>
lea    0xdde(%rip),%rdi
call   1040 <puts@plt>
mov    0x10(%rsp),%rdi
mov    0x3(%rdi,%r14,1),%cl
xor    %eax,%eax
cmp    $0x25,%cl
je     12d1 <fill_var+0x121>
add    $0x3,%r14
add    0x20(%rsp),%r14
xor    %eax,%eax
nopl   0x0(%rax)
mov    %cl,0x230(%rsp,%rax,1)
movzbl (%r14,%rax,1),%ecx
add    $0x1,%rax
cmp    $0x25,%cl
jne    12b0 <fill_var+0x100>
lea    (%r12,%rax,1),%ecx
add    $0x2,%ecx
mov    %rcx,0x18(%rsp)
mov    %eax,%r14d
movb   $0x0,0x230(%rsp,%r14,1)
cmpl   $0x0,0xc(%rsp)
lea    0x230(%rsp),%rbp
jne    1309 <fill_var+0x159>
lea    0xd0d(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd4f(%rip),%rdi
call   1040 <puts@plt>
movw   $0x3d,(%r14,%rbp,1)
mov    %rbx,%rdi
call   1070 <rewind@plt>
lea    0x300(%rsp),%r14
jmp    133d <fill_var+0x18d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   10a0 <feof@plt>
cmp    $0x1,%eax
je     13a6 <fill_var+0x1f6>
mov    %r13,%rdi
mov    $0xc8,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   10d0 <strstr@plt>
test   %rax,%rax
je     1330 <fill_var+0x180>
mov    %r13,%rdi
mov    %r14,%rsi
call   10b0 <getentry@plt>
jmp    1330 <fill_var+0x180>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14
movslq %ebp,%rcx
lea    0x1(%rcx),%rbp
movb   $0x3c,0x30(%rsp,%rcx,1)
mov    %al,0x31(%rsp,%rcx,1)
mov    %r14d,%r12d
jmp    1227 <fill_var+0x77>
movslq %ebp,%rbp
movw   $0x253c,0x30(%rsp,%rbp,1)
mov    %al,0x32(%rsp,%rbp,1)
add    $0x2,%rbp
mov    %ecx,%r12d
jmp    1227 <fill_var+0x77>
mov    %r15,%rdi
call   1070 <rewind@plt>
jmp    13bd <fill_var+0x20d>
mov    %r15,%rdi
call   10a0 <feof@plt>
cmp    $0x1,%eax
je     13ea <fill_var+0x23a>
mov    %r13,%rdi
mov    $0xc8,%esi
mov    %r15,%rdx
call   1090 <fgets@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   10d0 <strstr@plt>
test   %rax,%rax
je     13b0 <fill_var+0x200>
mov    %r13,%rdi
mov    %r14,%rsi
call   10b0 <getentry@plt>
jmp    13b0 <fill_var+0x200>
cmpl   $0x0,0xc(%rsp)
je     1403 <fill_var+0x253>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   10c0 <strcat@plt>
jmp    1441 <fill_var+0x291>
lea    0xc0a(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xc22(%rip),%rdi
call   1040 <puts@plt>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   10c0 <strcat@plt>
lea    0xbf2(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
add    $0xffffffff,%ebp
mov    0x18(%rsp),%r12
add    $0x2,%r12d
jmp    1227 <fill_var+0x77>
lea    0x30(%rsp),%rsi
call   1030 <strcpy@plt>
add    $0x498,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"found fact ... looking for factname\0A\00"
@.str.1 = [20 x i8] c"found factname: %s\0A\00"
@.str.2 = [23 x i8] c"looking for factvalue\0A\00"
@.str.3 = [21 x i8] c"found factvalue: %s\0A\00"
@.str.4 = [23 x i8] c"adding fact to buffer\0A\00"
@.str.5 = [20 x i8] c"current buffer: %s\0A\00"
define void @fill_var(i32 %0, i8* %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [512 x i8]
%13 = alloca [200 x i8]
%14 = alloca [200 x i8]
%15 = alloca [200 x i8]
%16 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
store i32 0, i32* %9
br label %17
17: ; preds = %24, %4
%18 = load i32, i32* %9
%19 = icmp sle i32 %18, 512
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = load i32, i32* %9
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 %22
store i8 0, i8* %23
br label %24
24: ; preds = %20
%25 = load i32, i32* %9
%26 = add nsw i32 %25, 1
store i32 %26, i32* %9
br label %17
27: ; preds = %17
store i32 0, i32* %9
store i32 0, i32* %10
br label %28
28: ; preds = %204, %27
%29 = load i32, i32* %9
%30 = load i8*, i8** %6
%31 = call i32 @strlen(i8* %30)
%32 = icmp sle i32 %29, %31
br i1 %32, label %33, label %209
33: ; preds = %28
%34 = load i8*, i8** %6
%35 = load i32, i32* %9
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 60
br i1 %40, label %41, label %50
41: ; preds = %33
%42 = load i8*, i8** %6
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
%46 = load i8, i8* %45
%47 = load i32, i32* %10
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 %48
store i8 %46, i8* %49
br label %204
50: ; preds = %33
%51 = load i8*, i8** %6
%52 = load i32, i32* %9
%53 = add nsw i32 %52, 1
store i32 %53, i32* %9
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %51, i64 %54
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp ne i32 %57, 37
br i1 %58, label %59, label %72
59: ; preds = %50
%60 = load i32, i32* %10
%61 = add nsw i32 %60, 1
store i32 %61, i32* %10
%62 = sext i32 %60 to i64
%63 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 %62
store i8 60, i8* %63
%64 = load i8*, i8** %6
%65 = load i32, i32* %9
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %64, i64 %66
%68 = load i8, i8* %67
%69 = load i32, i32* %10
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 %70
store i8 %68, i8* %71
br label %204
72: ; preds = %50
%73 = load i8*, i8** %6
%74 = load i32, i32* %9
%75 = add nsw i32 %74, 1
store i32 %75, i32* %9
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %73, i64 %76
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = icmp ne i32 %79, 36
br i1 %80, label %81, label %98
81: ; preds = %72
%82 = load i32, i32* %10
%83 = add nsw i32 %82, 1
store i32 %83, i32* %10
%84 = sext i32 %82 to i64
%85 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 %84
store i8 60, i8* %85
%86 = load i32, i32* %10
%87 = add nsw i32 %86, 1
store i32 %87, i32* %10
%88 = sext i32 %86 to i64
%89 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 %88
store i8 37, i8* %89
%90 = load i8*, i8** %6
%91 = load i32, i32* %9
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8, i8* %90, i64 %92
%94 = load i8, i8* %93
%95 = load i32, i32* %10
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 %96
store i8 %94, i8* %97
br label %204
98: ; preds = %72
%99 = load i32, i32* %5
%100 = icmp eq i32 %99, 0
br i1 %100, label %101, label %103
101: ; preds = %98
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %103
103: ; preds = %101, %98
store i32 0, i32* %16
br label %104
104: ; preds = %122, %103
%105 = load i8*, i8** %6
%106 = load i32, i32* %9
%107 = add nsw i32 %106, 1
store i32 %107, i32* %9
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds i8, i8* %105, i64 %108
%110 = load i8, i8* %109
%111 = sext i8 %110 to i32
%112 = icmp ne i32 %111, 37
br i1 %112, label %113, label %125
113: ; preds = %104
%114 = load i8*, i8** %6
%115 = load i32, i32* %9
%116 = sext i32 %115 to i64
%117 = getelementptr inbounds i8, i8* %114, i64 %116
%118 = load i8, i8* %117
%119 = load i32, i32* %16
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds [200 x i8], [200 x i8]* %14, i64 0, i64 %120
store i8 %118, i8* %121
br label %122
122: ; preds = %113
%123 = load i32, i32* %16
%124 = add nsw i32 %123, 1
store i32 %124, i32* %16
br label %104
125: ; preds = %104
%126 = load i32, i32* %16
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds [200 x i8], [200 x i8]* %14, i64 0, i64 %127
store i8 0, i8* %128
%129 = load i32, i32* %5
%130 = icmp eq i32 %129, 0
br i1 %130, label %131, label %135
131: ; preds = %125
%132 = getelementptr inbounds [200 x i8], [200 x i8]* %14, i64 0, i64 0
%133 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %132)
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
br label %135
135: ; preds = %131, %125
%136 = load i32, i32* %16
%137 = add nsw i32 %136, 1
store i32 %137, i32* %16
%138 = sext i32 %136 to i64
%139 = getelementptr inbounds [200 x i8], [200 x i8]* %14, i64 0, i64 %138
store i8 61, i8* %139
%140 = load i32, i32* %16
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds [200 x i8], [200 x i8]* %14, i64 0, i64 %141
store i8 0, i8* %142
%143 = load i32*, i32** %8
%144 = call i32 @rewind(i32* %143)
br label %145
145: ; preds = %158, %135
%146 = getelementptr inbounds [200 x i8], [200 x i8]* %13, i64 0, i64 0
%147 = load i32*, i32** %8
%148 = call i32 @fgets(i8* %146, i32 200, i32* %147)
%149 = getelementptr inbounds [200 x i8], [200 x i8]* %13, i64 0, i64 0
%150 = getelementptr inbounds [200 x i8], [200 x i8]* %14, i64 0, i64 0
%151 = call i64 @strstr(i8* %149, i8* %150)
%152 = icmp ne i64 %151, 0
br i1 %152, label %153, label %157
153: ; preds = %145
%154 = getelementptr inbounds [200 x i8], [200 x i8]* %13, i64 0, i64 0
%155 = getelementptr inbounds [200 x i8], [200 x i8]* %15, i64 0, i64 0
%156 = call i32 @getentry(i8* %154, i8* %155)
br label %157
157: ; preds = %153, %145
br label %158
158: ; preds = %157
%159 = load i32*, i32** %8
%160 = call i32 @feof(i32* %159)
%161 = icmp ne i32 %160, 1
br i1 %161, label %145, label %162
162: ; preds = %158
%163 = load i32*, i32** %7
%164 = call i32 @rewind(i32* %163)
br label %165
165: ; preds = %178, %162
%166 = getelementptr inbounds [200 x i8], [200 x i8]* %13, i64 0, i64 0
%167 = load i32*, i32** %7
%168 = call i32 @fgets(i8* %166, i32 200, i32* %167)
%169 = getelementptr inbounds [200 x i8], [200 x i8]* %13, i64 0, i64 0
%170 = getelementptr inbounds [200 x i8], [200 x i8]* %14, i64 0, i64 0
%171 = call i64 @strstr(i8* %169, i8* %170)
%172 = icmp ne i64 %171, 0
br i1 %172, label %173, label %177
173: ; preds = %165
%174 = getelementptr inbounds [200 x i8], [200 x i8]* %13, i64 0, i64 0
%175 = getelementptr inbounds [200 x i8], [200 x i8]* %15, i64 0, i64 0
%176 = call i32 @getentry(i8* %174, i8* %175)
br label %177
177: ; preds = %173, %165
br label %178
178: ; preds = %177
%179 = load i32*, i32** %7
%180 = call i32 @feof(i32* %179)
%181 = icmp ne i32 %180, 1
br i1 %181, label %165, label %182
182: ; preds = %178
%183 = load i32, i32* %5
%184 = icmp eq i32 %183, 0
br i1 %184, label %185, label %189
185: ; preds = %182
%186 = getelementptr inbounds [200 x i8], [200 x i8]* %15, i64 0, i64 0
%187 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %186)
%188 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %189
189: ; preds = %185, %182
%190 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%191 = getelementptr inbounds [200 x i8], [200 x i8]* %15, i64 0, i64 0
%192 = call i32 @strcat(i8* %190, i8* %191)
%193 = load i32, i32* %5
%194 = icmp eq i32 %193, 0
br i1 %194, label %195, label %198
195: ; preds = %189
%196 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%197 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %196)
br label %198
198: ; preds = %195, %189
%199 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%200 = call i32 @strlen(i8* %199)
%201 = sub nsw i32 %200, 1
store i32 %201, i32* %10
%202 = load i32, i32* %9
%203 = add nsw i32 %202, 1
store i32 %203, i32* %9
br label %204
204: ; preds = %198, %81, %59, %41
%205 = load i32, i32* %9
%206 = add nsw i32 %205, 1
store i32 %206, i32* %9
%207 = load i32, i32* %10
%208 = add nsw i32 %207, 1
store i32 %208, i32* %10
br label %28
209: ; preds = %28
%210 = load i8*, i8** %6
%211 = getelementptr inbounds [512 x i8], [512 x i8]* %12, i64 0, i64 0
%212 = call i32 @strcpy(i8* %210, i8* %211)
ret void
}

LLVM IR (-O2):
@.str.1 = [20 x i8] c"found factname: %s\0A\00"
@.str.3 = [21 x i8] c"found factvalue: %s\0A\00"
@.str.5 = [20 x i8] c"current buffer: %s\0A\00"
@str = [22 x i8] c"adding fact to buffer\00"
@str.6 = [22 x i8] c"looking for factvalue\00"
@str.7 = [36 x i8] c"found fact ... looking for factname\00"
define void @fill_var(i32 %0, i8* %1, i32* nocapture %2, i32* nocapture %3) {
%5 = alloca [512 x i8]
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%7 = alloca [200 x i8]
%8 = alloca [200 x i8]
%9 = alloca [200 x i8]
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%12 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%13 = getelementptr inbounds [200 x i8], [200 x i8]* %9, i64 0, i64 0
%14 = call i32 @strlen(i8* %1)
%15 = icmp slt i32 %14, 0
br i1 %15, label %129, label %16
16: ; preds = %4
%17 = icmp eq i32 %0, 0
br label %18
18: ; preds = %16, %122
%19 = phi i32 [ 0, %16 ], [ %125, %122 ]
%20 = phi i32 [ 0, %16 ], [ %126, %122 ]
%21 = sext i32 %19 to i64
%22 = getelementptr inbounds i8, i8* %1, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 60
br i1 %24, label %28, label %25
25: ; preds = %18
%26 = sext i32 %20 to i64
%27 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 %26
store i8 %23, i8* %27
br label %122
28: ; preds = %18
%29 = add nsw i32 %19, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %1, i64 %30
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 37
br i1 %33, label %40, label %34
34: ; preds = %28
%35 = add nsw i32 %20, 1
%36 = sext i32 %20 to i64
%37 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 %36
store i8 60, i8* %37
%38 = sext i32 %35 to i64
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 %38
store i8 %32, i8* %39
br label %122
40: ; preds = %28
%41 = add nsw i32 %19, 2
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %1, i64 %42
%44 = load i8, i8* %43
%45 = icmp eq i8 %44, 36
br i1 %45, label %55, label %46
46: ; preds = %40
%47 = add nsw i32 %20, 1
%48 = sext i32 %20 to i64
%49 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 %48
store i8 60, i8* %49
%50 = add nsw i32 %20, 2
%51 = sext i32 %47 to i64
%52 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 %51
store i8 37, i8* %52
%53 = sext i32 %50 to i64
%54 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 %53
store i8 %44, i8* %54
br label %122
55: ; preds = %40
br i1 %17, label %56, label %58
56: ; preds = %55
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.7, i64 0, i64 0))
br label %58
58: ; preds = %56, %55
%59 = add nsw i32 %19, 3
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %1, i64 %60
%62 = load i8, i8* %61
%63 = icmp eq i8 %62, 37
br i1 %63, label %77, label %64
64: ; preds = %58, %64
%65 = phi i64 [ %69, %64 ], [ 0, %58 ]
%66 = phi i64 [ %70, %64 ], [ %60, %58 ]
%67 = phi i8 [ %72, %64 ], [ %62, %58 ]
%68 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 %65
store i8 %67, i8* %68
%69 = add nuw i64 %65, 1
%70 = add i64 %66, 1
%71 = getelementptr inbounds i8, i8* %1, i64 %70
%72 = load i8, i8* %71
%73 = icmp eq i8 %72, 37
br i1 %73, label %74, label %64
74: ; preds = %64
%75 = trunc i64 %69 to i32
%76 = trunc i64 %66 to i32
br label %77
77: ; preds = %74, %58
%78 = phi i32 [ %41, %58 ], [ %76, %74 ]
%79 = phi i32 [ 0, %58 ], [ %75, %74 ]
%80 = zext i32 %79 to i64
%81 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 %80
store i8 0, i8* %81
br i1 %17, label %82, label %85
82: ; preds = %77
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%84 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.6, i64 0, i64 0))
br label %85
85: ; preds = %82, %77
%86 = add nuw nsw i32 %79, 1
store i8 61, i8* %81
%87 = zext i32 %86 to i64
%88 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 %87
store i8 0, i8* %88
%89 = call i32 @rewind(i32* %3)
br label %90
90: ; preds = %96, %85
%91 = call i32 @fgets(i8* %11, i32 200, i32* %3)
%92 = call i64 @strstr(i8* %11, i8* %12)
%93 = icmp eq i64 %92, 0
br i1 %93, label %96, label %94
94: ; preds = %90
%95 = call i32 @getentry(i8* %11, i8* %13)
br label %96
96: ; preds = %90, %94
%97 = call i32 @feof(i32* %3)
%98 = icmp eq i32 %97, 1
br i1 %98, label %99, label %90
99: ; preds = %96
%100 = call i32 @rewind(i32* %2)
br label %101
101: ; preds = %107, %99
%102 = call i32 @fgets(i8* %11, i32 200, i32* %2)
%103 = call i64 @strstr(i8* %11, i8* %12)
%104 = icmp eq i64 %103, 0
br i1 %104, label %107, label %105
105: ; preds = %101
%106 = call i32 @getentry(i8* %11, i8* %13)
br label %107
107: ; preds = %101, %105
%108 = call i32 @feof(i32* %2)
%109 = icmp eq i32 %108, 1
br i1 %109, label %110, label %101
110: ; preds = %107
br i1 %17, label %113, label %111
111: ; preds = %110
%112 = call i32 @strcat(i8* %10, i8* %13)
br label %118
113: ; preds = %110
%114 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%115 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%116 = call i32 @strcat(i8* %10, i8* %13)
%117 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i8* %10)
br label %118
118: ; preds = %111, %113
%119 = call i32 @strlen(i8* %10)
%120 = add nsw i32 %119, -1
%121 = add nsw i32 %78, 2
br label %122
122: ; preds = %118, %46, %34, %25
%123 = phi i32 [ %20, %25 ], [ %35, %34 ], [ %50, %46 ], [ %120, %118 ]
%124 = phi i32 [ %19, %25 ], [ %29, %34 ], [ %41, %46 ], [ %121, %118 ]
%125 = add nsw i32 %124, 1
%126 = add nsw i32 %123, 1
%127 = call i32 @strlen(i8* %1)
%128 = icmp slt i32 %124, %127
br i1 %128, label %18, label %129
129: ; preds = %122, %4
%130 = call i32 @strcpy(i8* %1, i8* %10)
ret void
}