#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 */
char *expand_string(char **, int *, char *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int strlen(char *);
int /*<<< orphan*/ strsep(char **, char *);
void append_file(char **dst, int *len, char *filename) {
  FILE *fd;
  char line[256], *p, *tail;
  fd = fopen(filename, "r");
  if (!fd) {
    perror(filename);
    return;
  }
  tail = expand_string(dst, len, *dst + strlen(*dst), 1);
  if (!tail)
    return;
  *tail++ = '(';
  while (fgets(line, sizeof(line), fd)) {
    p = line;
    strsep(&p, "#\n");
    p = line + strlen(line) - 1;
    while (p >= line && (*p == ' ' || *p == '\t' || *p == '\r'))
      *p-- = 0;
    if (p < line)
      continue;
    p = line;
    while (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n')
      ++p;
    if (*p == 0)
      continue;
    tail = expand_string(dst, len, tail, 2 * strlen(p) + 1);
    if (!tail)
      return;
    for (; *p; ++p) {
      if (*p == '.') {
        *tail++ = '\\';
        *tail++ = '.';
      } else if (*p == '?')
        *tail++ = '.';
      else
        *tail++ = *p;
    }
    *tail++ = '|';
    *tail = 0;
  }
  if (*(tail - 1) == '(')
    *--tail = 0;
  else if (*(tail - 1) == '|')
    *(tail - 1) = ')';
  fclose(fd);
}


x86 assembly (clang, -O0):
<append_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11b4 <append_file+0x44>
mov    -0x18(%rbp),%rdi
call   1090 <perror@plt>
jmp    15e8 <append_file+0x478>
mov    -0x8(%rbp),%rax
mov    %rax,-0x140(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x138(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x148(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
mov    -0x148(%rbp),%rdx
mov    -0x140(%rbp),%rdi
mov    -0x138(%rbp),%rsi
cltq
add    %rax,%rdx
mov    $0x1,%ecx
call   1050 <expand_string@plt>
mov    %rax,-0x130(%rbp)
cmpq   $0x0,-0x130(%rbp)
jne    1222 <append_file+0xb2>
jmp    15e8 <append_file+0x478>
mov    -0x130(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x130(%rbp)
movb   $0x28,(%rax)
lea    -0x120(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x100,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1589 <append_file+0x419>
lea    -0x120(%rbp),%rax
mov    %rax,-0x128(%rbp)
lea    -0x128(%rbp),%rdi
lea    0xd8d(%rip),%rsi
call   1070 <strsep@plt>
lea    -0x120(%rbp),%rax
mov    %rax,-0x150(%rbp)
lea    -0x120(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x150(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rcx
lea    -0x120(%rbp),%rdx
xor    %eax,%eax
cmp    %rdx,%rcx
mov    %al,-0x151(%rbp)
jb     1325 <append_file+0x1b5>
mov    -0x128(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x152(%rbp)
je     1319 <append_file+0x1a9>
mov    -0x128(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x152(%rbp)
je     1319 <append_file+0x1a9>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
sete   %al
mov    %al,-0x152(%rbp)
mov    -0x152(%rbp),%al
mov    %al,-0x151(%rbp)
mov    -0x151(%rbp),%al
test   $0x1,%al
jne    1338 <append_file+0x1c8>
jmp    1355 <append_file+0x1e5>
mov    -0x128(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x128(%rbp)
movb   $0x0,(%rax)
jmp    12ae <append_file+0x13e>
mov    -0x128(%rbp),%rax
lea    -0x120(%rbp),%rcx
cmp    %rcx,%rax
jae    1371 <append_file+0x201>
jmp    123a <append_file+0xca>
lea    -0x120(%rbp),%rax
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x153(%rbp)
je     13e6 <append_file+0x276>
mov    -0x128(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x9,%ecx
mov    %al,-0x153(%rbp)
je     13e6 <append_file+0x276>
mov    -0x128(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0xd,%ecx
mov    %al,-0x153(%rbp)
je     13e6 <append_file+0x276>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0x153(%rbp)
mov    -0x153(%rbp),%al
test   $0x1,%al
jne    13f9 <append_file+0x289>
jmp    1410 <append_file+0x2a0>
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
jmp    137f <append_file+0x20f>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1428 <append_file+0x2b8>
jmp    123a <append_file+0xca>
mov    -0x8(%rbp),%rax
mov    %rax,-0x170(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x168(%rbp)
mov    -0x130(%rbp),%rax
mov    %rax,-0x160(%rbp)
mov    -0x128(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x170(%rbp),%rdi
mov    -0x168(%rbp),%rsi
mov    -0x160(%rbp),%rdx
mov    %eax,%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
call   1050 <expand_string@plt>
mov    %rax,-0x130(%rbp)
cmpq   $0x0,-0x130(%rbp)
jne    1494 <append_file+0x324>
jmp    15e8 <append_file+0x478>
jmp    1499 <append_file+0x329>
mov    -0x128(%rbp),%rax
cmpb   $0x0,(%rax)
je     1562 <append_file+0x3f2>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    14f1 <append_file+0x381>
mov    -0x130(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x130(%rbp)
movb   $0x5c,(%rax)
mov    -0x130(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x130(%rbp)
movb   $0x2e,(%rax)
jmp    1546 <append_file+0x3d6>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3f,%eax
jne    1521 <append_file+0x3b1>
mov    -0x130(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x130(%rbp)
movb   $0x2e,(%rax)
jmp    1541 <append_file+0x3d1>
mov    -0x128(%rbp),%rax
mov    (%rax),%cl
mov    -0x130(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x130(%rbp)
mov    %cl,(%rax)
jmp    1546 <append_file+0x3d6>
jmp    154b <append_file+0x3db>
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
jmp    1499 <append_file+0x329>
mov    -0x130(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x130(%rbp)
movb   $0x7c,(%rax)
mov    -0x130(%rbp),%rax
movb   $0x0,(%rax)
jmp    123a <append_file+0xca>
mov    -0x130(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x28,%eax
jne    15bb <append_file+0x44b>
mov    -0x130(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x130(%rbp)
movb   $0x0,-0x1(%rax)
jmp    15df <append_file+0x46f>
mov    -0x130(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x7c,%eax
jne    15da <append_file+0x46a>
mov    -0x130(%rbp),%rax
movb   $0x29,-0x1(%rax)
jmp    15df <append_file+0x46f>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%rbp
lea    0xe6f(%rip),%rsi
mov    %rdx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     1379 <append_file+0x209>
mov    %rax,%r12
mov    0x0(%rbp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
movslq %eax,%rdx
add    %rbx,%rdx
mov    %rbp,0x10(%rsp)
mov    %rbp,%rdi
mov    %r14,0x18(%rsp)
mov    %r14,%rsi
mov    $0x1,%ecx
call   1050 <expand_string@plt>
test   %rax,%rax
je     1367 <append_file+0x1f7>
mov    %rax,%rbx
add    $0x1,%rbx
movb   $0x28,(%rax)
lea    0x20(%rsp),%r13
mov    %r13,%rdi
mov    $0x100,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     134b <append_file+0x1db>
lea    0x8(%rsp),%r14
movabs $0x100002600,%r15
movabs $0x100002200,%rbp
jmp    1249 <append_file+0xd9>
movw   $0x7c,(%rbx)
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r13,%rdi
mov    $0x100,%esi
mov    %r12,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     134b <append_file+0x1db>
mov    %r13,0x8(%rsp)
mov    %r14,%rdi
lea    0xdaa(%rip),%rsi
call   1070 <strsep@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
cltq
add    %rsp,%rax
add    $0x1f,%rax
mov    %rax,0x8(%rsp)
cmp    %r13,%rax
jb     1230 <append_file+0xc0>
nopl   0x0(%rax,%rax,1)
movzbl (%rax),%ecx
cmp    $0x20,%rcx
ja     12a7 <append_file+0x137>
bt     %rcx,%rbp
jae    12a7 <append_file+0x137>
lea    -0x1(%rax),%rcx
mov    %rcx,0x8(%rsp)
movb   $0x0,(%rax)
mov    0x8(%rsp),%rax
cmp    %r13,%rax
jae    1280 <append_file+0x110>
jmp    1230 <append_file+0xc0>
mov    %r13,%rdi
nopw   0x0(%rax,%rax,1)
movzbl (%rdi),%eax
cmp    $0x20,%rax
ja     12d4 <append_file+0x164>
bt     %rax,%r15
jae    12c5 <append_file+0x155>
add    $0x1,%rdi
jmp    12b0 <append_file+0x140>
test   %rax,%rax
jne    12d4 <append_file+0x164>
mov    %rdi,0x8(%rsp)
jmp    1230 <append_file+0xc0>
mov    %rdi,0x8(%rsp)
call   1040 <strlen@plt>
lea    (%rax,%rax,1),%ecx
add    $0x1,%ecx
mov    0x10(%rsp),%rdi
mov    0x18(%rsp),%rsi
mov    %rbx,%rdx
call   1050 <expand_string@plt>
test   %rax,%rax
je     1367 <append_file+0x1f7>
mov    %rax,%rbx
mov    0x8(%rsp),%rax
jmp    1325 <append_file+0x1b5>
cs nopw 0x0(%rax,%rax,1)
nop
movb   $0x2e,(%rbx)
add    $0x1,%rbx
mov    0x8(%rsp),%rax
add    $0x1,%rax
mov    %rax,0x8(%rsp)
movzbl (%rax),%eax
cmp    $0x2e,%al
je     1340 <append_file+0x1d0>
cmp    $0x3f,%al
je     1310 <append_file+0x1a0>
test   %al,%al
je     121d <append_file+0xad>
mov    %al,(%rbx)
jmp    1313 <append_file+0x1a3>
nopl   0x0(%rax)
movw   $0x2e5c,(%rbx)
add    $0x2,%rbx
jmp    1317 <append_file+0x1a7>
mov    -0x1(%rbx),%al
cmp    $0x28,%al
je     135a <append_file+0x1ea>
cmp    $0x7c,%al
jne    135f <append_file+0x1ef>
mov    $0x29,%al
jmp    135c <append_file+0x1ec>
xor    %eax,%eax
mov    %al,-0x1(%rbx)
mov    %r12,%rdi
call   1030 <fclose@plt>
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <perror@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"#\0A\00"
define void @append_file(i8** %0, i32* %1, i8* %2) {
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca [256 x i8]
%9 = alloca i8*
%10 = alloca i8*
store i8** %0, i8*** %4
store i32* %1, i32** %5
store i8* %2, i8** %6
%11 = load i8*, i8** %6
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %7
%13 = load i32*, i32** %7
%14 = icmp ne i32* %13, null
br i1 %14, label %18, label %15
15: ; preds = %3
%16 = load i8*, i8** %6
%17 = call i32 @perror(i8* %16)
br label %184
18: ; preds = %3
%19 = load i8**, i8*** %4
%20 = load i32*, i32** %5
%21 = load i8**, i8*** %4
%22 = load i8*, i8** %21
%23 = load i8**, i8*** %4
%24 = load i8*, i8** %23
%25 = call i32 @strlen(i8* %24)
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %22, i64 %26
%28 = call i8* @expand_string(i8** %19, i32* %20, i8* %27, i32 1)
store i8* %28, i8** %10
%29 = load i8*, i8** %10
%30 = icmp ne i8* %29, null
br i1 %30, label %32, label %31
31: ; preds = %18
br label %184
32: ; preds = %18
%33 = load i8*, i8** %10
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %10
store i8 40, i8* %33
br label %35
35: ; preds = %158, %112, %79, %32
%36 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%37 = load i32*, i32** %7
%38 = call i64 @fgets(i8* %36, i32 256, i32* %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %162
40: ; preds = %35
%41 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
store i8* %41, i8** %9
%42 = call i32 @strsep(i8** %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%45 = call i32 @strlen(i8* %44)
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %43, i64 %46
%48 = getelementptr inbounds i8, i8* %47, i64 -1
store i8* %48, i8** %9
br label %49
49: ; preds = %72, %40
%50 = load i8*, i8** %9
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%52 = icmp uge i8* %50, %51
br i1 %52, label %53, label %70
53: ; preds = %49
%54 = load i8*, i8** %9
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 32
br i1 %57, label %68, label %58
58: ; preds = %53
%59 = load i8*, i8** %9
%60 = load i8, i8* %59
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 9
br i1 %62, label %68, label %63
63: ; preds = %58
%64 = load i8*, i8** %9
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 13
br label %68
68: ; preds = %63, %58, %53
%69 = phi i1 [ true, %58 ], [ true, %53 ], [ %67, %63 ]
br label %70
70: ; preds = %68, %49
%71 = phi i1 [ false, %49 ], [ %69, %68 ]
br i1 %71, label %72, label %75
72: ; preds = %70
%73 = load i8*, i8** %9
%74 = getelementptr inbounds i8, i8* %73, i32 -1
store i8* %74, i8** %9
store i8 0, i8* %73
br label %49
75: ; preds = %70
%76 = load i8*, i8** %9
%77 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%78 = icmp ult i8* %76, %77
br i1 %78, label %79, label %80
79: ; preds = %75
br label %35
80: ; preds = %75
%81 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
store i8* %81, i8** %9
br label %82
82: ; preds = %104, %80
%83 = load i8*, i8** %9
%84 = load i8, i8* %83
%85 = sext i8 %84 to i32
%86 = icmp eq i32 %85, 32
br i1 %86, label %102, label %87
87: ; preds = %82
%88 = load i8*, i8** %9
%89 = load i8, i8* %88
%90 = sext i8 %89 to i32
%91 = icmp eq i32 %90, 9
br i1 %91, label %102, label %92
92: ; preds = %87
%93 = load i8*, i8** %9
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 13
br i1 %96, label %102, label %97
97: ; preds = %92
%98 = load i8*, i8** %9
%99 = load i8, i8* %98
%100 = sext i8 %99 to i32
%101 = icmp eq i32 %100, 10
br label %102
102: ; preds = %97, %92, %87, %82
%103 = phi i1 [ true, %92 ], [ true, %87 ], [ true, %82 ], [ %101, %97 ]
br i1 %103, label %104, label %107
104: ; preds = %102
%105 = load i8*, i8** %9
%106 = getelementptr inbounds i8, i8* %105, i32 1
store i8* %106, i8** %9
br label %82
107: ; preds = %102
%108 = load i8*, i8** %9
%109 = load i8, i8* %108
%110 = sext i8 %109 to i32
%111 = icmp eq i32 %110, 0
br i1 %111, label %112, label %113
112: ; preds = %107
br label %35
113: ; preds = %107
%114 = load i8**, i8*** %4
%115 = load i32*, i32** %5
%116 = load i8*, i8** %10
%117 = load i8*, i8** %9
%118 = call i32 @strlen(i8* %117)
%119 = mul nsw i32 2, %118
%120 = add nsw i32 %119, 1
%121 = call i8* @expand_string(i8** %114, i32* %115, i8* %116, i32 %120)
store i8* %121, i8** %10
%122 = load i8*, i8** %10
%123 = icmp ne i8* %122, null
br i1 %123, label %125, label %124
124: ; preds = %113
br label %184
125: ; preds = %113
br label %126
126: ; preds = %155, %125
%127 = load i8*, i8** %9
%128 = load i8, i8* %127
%129 = icmp ne i8 %128, 0
br i1 %129, label %130, label %158
130: ; preds = %126
%131 = load i8*, i8** %9
%132 = load i8, i8* %131
%133 = sext i8 %132 to i32
%134 = icmp eq i32 %133, 46
br i1 %134, label %135, label %140
135: ; preds = %130
%136 = load i8*, i8** %10
%137 = getelementptr inbounds i8, i8* %136, i32 1
store i8* %137, i8** %10
store i8 92, i8* %136
%138 = load i8*, i8** %10
%139 = getelementptr inbounds i8, i8* %138, i32 1
store i8* %139, i8** %10
store i8 46, i8* %138
br label %154
140: ; preds = %130
%141 = load i8*, i8** %9
%142 = load i8, i8* %141
%143 = sext i8 %142 to i32
%144 = icmp eq i32 %143, 63
br i1 %144, label %145, label %148
145: ; preds = %140
%146 = load i8*, i8** %10
%147 = getelementptr inbounds i8, i8* %146, i32 1
store i8* %147, i8** %10
store i8 46, i8* %146
br label %153
148: ; preds = %140
%149 = load i8*, i8** %9
%150 = load i8, i8* %149
%151 = load i8*, i8** %10
%152 = getelementptr inbounds i8, i8* %151, i32 1
store i8* %152, i8** %10
store i8 %150, i8* %151
br label %153
153: ; preds = %148, %145
br label %154
154: ; preds = %153, %135
br label %155
155: ; preds = %154
%156 = load i8*, i8** %9
%157 = getelementptr inbounds i8, i8* %156, i32 1
store i8* %157, i8** %9
br label %126
158: ; preds = %126
%159 = load i8*, i8** %10
%160 = getelementptr inbounds i8, i8* %159, i32 1
store i8* %160, i8** %10
store i8 124, i8* %159
%161 = load i8*, i8** %10
store i8 0, i8* %161
br label %35
162: ; preds = %35
%163 = load i8*, i8** %10
%164 = getelementptr inbounds i8, i8* %163, i64 -1
%165 = load i8, i8* %164
%166 = sext i8 %165 to i32
%167 = icmp eq i32 %166, 40
br i1 %167, label %168, label %171
168: ; preds = %162
%169 = load i8*, i8** %10
%170 = getelementptr inbounds i8, i8* %169, i32 -1
store i8* %170, i8** %10
store i8 0, i8* %170
br label %181
171: ; preds = %162
%172 = load i8*, i8** %10
%173 = getelementptr inbounds i8, i8* %172, i64 -1
%174 = load i8, i8* %173
%175 = sext i8 %174 to i32
%176 = icmp eq i32 %175, 124
br i1 %176, label %177, label %180
177: ; preds = %171
%178 = load i8*, i8** %10
%179 = getelementptr inbounds i8, i8* %178, i64 -1
store i8 41, i8* %179
br label %180
180: ; preds = %177, %171
br label %181
181: ; preds = %180, %168
%182 = load i32*, i32** %7
%183 = call i32 @fclose(i32* %182)
br label %184
184: ; preds = %181, %124, %31, %15
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"#\0A\00"
define void @append_file(i8** %0, i32* %1, i8* nocapture %2) {
%4 = alloca [256 x i8]
%5 = alloca i8*
%6 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%7 = bitcast i8** %5 to i8*
%8 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = tail call i32 @perror(i8* %2)
br label %84
12: ; preds = %3
%13 = load i8*, i8** %0
%14 = tail call i32 @strlen(i8* %13)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = tail call i8* @expand_string(i8** %0, i32* %1, i8* %16, i32 1)
%18 = icmp eq i8* %17, null
br i1 %18, label %84, label %19
19: ; preds = %12
%20 = getelementptr inbounds i8, i8* %17, i64 1
store i8 40, i8* %17
%21 = call i64 @fgets(i8* %6, i32 256, i32* %8)
%22 = icmp eq i64 %21, 0
br i1 %22, label %75, label %23
23: ; preds = %19, %71
%24 = phi i8* [ %72, %71 ], [ %20, %19 ]
br label %26
25: ; preds = %43
store i8* %44, i8** %5
br label %40
26: ; preds = %23, %40
store i8* %6, i8** %5
%27 = call i32 @strsep(i8** %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%28 = call i32 @strlen(i8* %6)
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 %29
%31 = getelementptr inbounds i8, i8* %30, i64 -1
store i8* %31, i8** %5
%32 = icmp ult i8* %31, %6
br i1 %32, label %40, label %33
33: ; preds = %26, %36
%34 = phi i8* [ %38, %36 ], [ %31, %26 ]
%35 = load i8, i8* %34
switch i8 %35, label %43 [
i8 32, label %36
i8 9, label %36
i8 13, label %36
]
36: ; preds = %33, %33, %33
%37 = getelementptr inbounds i8, i8* %34, i64 -1
store i8* %37, i8** %5
store i8 0, i8* %34
%38 = load i8*, i8** %5
%39 = icmp ult i8* %38, %6
br i1 %39, label %40, label %33
40: ; preds = %36, %26, %25
%41 = call i64 @fgets(i8* %6, i32 256, i32* %8)
%42 = icmp eq i64 %41, 0
br i1 %42, label %75, label %26
43: ; preds = %33, %46
%44 = phi i8* [ %47, %46 ], [ %6, %33 ]
%45 = load i8, i8* %44
switch i8 %45, label %48 [
i8 32, label %46
i8 9, label %46
i8 13, label %46
i8 10, label %46
i8 0, label %25
]
46: ; preds = %43, %43, %43, %43
%47 = getelementptr inbounds i8, i8* %44, i64 1
br label %43
48: ; preds = %43
store i8* %44, i8** %5
%49 = call i32 @strlen(i8* %44)
%50 = shl nsw i32 %49, 1
%51 = or i32 %50, 1
%52 = call i8* @expand_string(i8** %0, i32* %1, i8* %24, i32 %51)
%53 = icmp eq i8* %52, null
br i1 %53, label %84, label %54
54: ; preds = %48
%55 = load i8*, i8** %5
br label %56
56: ; preds = %54, %67
%57 = phi i8* [ %70, %67 ], [ %55, %54 ]
%58 = phi i8* [ %68, %67 ], [ %52, %54 ]
%59 = load i8, i8* %57
switch i8 %59, label %65 [
i8 0, label %71
i8 46, label %60
i8 63, label %63
]
60: ; preds = %56
%61 = getelementptr inbounds i8, i8* %58, i64 1
store i8 92, i8* %58
%62 = getelementptr inbounds i8, i8* %58, i64 2
store i8 46, i8* %61
br label %67
63: ; preds = %56
%64 = getelementptr inbounds i8, i8* %58, i64 1
store i8 46, i8* %58
br label %67
65: ; preds = %56
%66 = getelementptr inbounds i8, i8* %58, i64 1
store i8 %59, i8* %58
br label %67
67: ; preds = %60, %65, %63
%68 = phi i8* [ %62, %60 ], [ %64, %63 ], [ %66, %65 ]
%69 = load i8*, i8** %5
%70 = getelementptr inbounds i8, i8* %69, i64 1
store i8* %70, i8** %5
br label %56
71: ; preds = %56
%72 = getelementptr inbounds i8, i8* %58, i64 1
store i8 124, i8* %58
store i8 0, i8* %72
%73 = call i64 @fgets(i8* %6, i32 256, i32* %8)
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %23
75: ; preds = %71, %40, %19
%76 = phi i8* [ %20, %19 ], [ %24, %40 ], [ %72, %71 ]
%77 = getelementptr inbounds i8, i8* %76, i64 -1
%78 = load i8, i8* %77
switch i8 %78, label %82 [
i8 40, label %80
i8 124, label %79
]
79: ; preds = %75
br label %80
80: ; preds = %75, %79
%81 = phi i8 [ 41, %79 ], [ 0, %75 ]
store i8 %81, i8* %77
br label %82
82: ; preds = %80, %75
%83 = call i32 @fclose(i32* %8)
br label %84
84: ; preds = %48, %12, %82, %10
ret void
}