#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 */
struct dirent {
  scalar_t__ d_type;
  char *d_name;
};
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
scalar_t__ DT_REG;
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ load_from_files(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
char *malloc(int);
int /*<<< orphan*/ *opendir(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
int snprintf(char *, int, char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  DIR *dir;
  struct dirent *ent;
  char *file_name;
  char *file_ext;
  char sys_command[1024];
  char o65_name[1024];
  char o65_file[1024];
  char *file_list[100];
  int file_list_index = 0;
  if ((dir = opendir("./test")) != NULL) {
    while ((ent = readdir(dir)) != NULL) {
      if (ent->d_type == DT_REG) {
        file_ext = strstr(ent->d_name, ".s");
        if (file_ext != NULL && strlen(file_ext) == 2 &&
            strlen(ent->d_name) < 1024) {
          file_list[file_list_index] = malloc(strlen(ent->d_name));
          strcpy(file_list[file_list_index], ent->d_name);
          file_list_index++;
        }
      }
    }
    closedir(dir);
  }
  int i = 0;
  int valid;
  FILE *fp_x6502;
  FILE *fp_out = fopen("./test/results.txt", "w");
  while (i < file_list_index) {
    file_name = file_list[i++];
    strncpy(o65_name, file_name, strlen(file_name) - 2);
    valid = snprintf(sys_command, 1024, "xa ./test/%s -o ./test/%s.o65",
                     file_name, o65_name);
    if (valid == 1024 || valid < 0) {
      return 1;
    }
    system(sys_command);
    snprintf(o65_file, 1024, "./test/%s.o65", o65_name);
    fp_x6502 = fopen(o65_file, "r");
    fprintf(fp_out, "%s\n", file_name);
    load_from_files(fp_x6502, fp_out);
    fprintf(fp_out, "\n");
    fclose(fp_x6502);
  }
  fclose(fp_out);
  system("rm ./test/*.o65");
  system("cmp --silent ./test/results.txt ./test/expected.txt || echo "
         "\"Warning! Unexpected test output\"");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0xf54(%rbp)
lea    0xdf6(%rip),%rdi
call   1060 <opendir@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1301 <main+0x121>
jmp    1222 <main+0x42>
mov    -0x18(%rbp),%rdi
call   10c0 <readdir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     12f8 <main+0x118>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    0x2d99(%rip),%rcx
cmp    (%rcx),%rax
jne    12f3 <main+0x113>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xda8(%rip),%rsi
call   1100 <strstr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     12ee <main+0x10e>
mov    -0x30(%rbp),%rdi
call   1070 <strlen@plt>
cmp    $0x2,%eax
jne    12ee <main+0x10e>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <strlen@plt>
cmp    $0x400,%eax
jge    12ee <main+0x10e>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <strlen@plt>
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,%rcx
movslq -0xf54(%rbp),%rax
mov    %rcx,-0xf50(%rbp,%rax,8)
ff
movslq -0xf54(%rbp),%rax
mov    -0xf50(%rbp,%rax,8),%rdi
ff
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rsi
call   1040 <strcpy@plt>
mov    -0xf54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf54(%rbp)
jmp    12f3 <main+0x113>
jmp    1222 <main+0x42>
mov    -0x18(%rbp),%rdi
call   10a0 <closedir@plt>
movl   $0x0,-0xf58(%rbp)
lea    0xcf8(%rip),%rdi
lea    0xd04(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0xf70(%rbp)
mov    -0xf58(%rbp),%eax
cmp    -0xf54(%rbp),%eax
jge    147d <main+0x29d>
mov    -0xf58(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xf58(%rbp)
cltq
mov    -0xf50(%rbp,%rax,8),%rax
ff
mov    %rax,-0x28(%rbp)
lea    -0x830(%rbp),%rax
mov    %rax,-0xf80(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xf78(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0xf80(%rbp),%rdi
mov    -0xf78(%rbp),%rsi
mov    %eax,%edx
sub    $0x2,%edx
call   1030 <strncpy@plt>
lea    -0x430(%rbp),%rdi
mov    -0x28(%rbp),%rcx
lea    -0x830(%rbp),%r8
mov    $0x400,%esi
lea    0xc71(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    %eax,-0xf5c(%rbp)
cmpl   $0x400,-0xf5c(%rbp)
je     13d8 <main+0x1f8>
cmpl   $0x0,-0xf5c(%rbp)
jge    13e4 <main+0x204>
movl   $0x1,-0x4(%rbp)
jmp    14a8 <main+0x2c8>
lea    -0x430(%rbp),%rdi
call   1080 <system@plt>
lea    -0xc30(%rbp),%rdi
lea    -0x830(%rbp),%rcx
mov    $0x400,%esi
lea    0xc25(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
lea    -0xc30(%rbp),%rdi
lea    0xc1e(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0xf68(%rbp)
mov    -0xf70(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xc02(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0xf68(%rbp),%rdi
mov    -0xf70(%rbp),%rsi
call   10f0 <load_from_files@plt>
mov    -0xf70(%rbp),%rdi
lea    0xbdc(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    -0xf68(%rbp),%rdi
call   1050 <fclose@plt>
jmp    1325 <main+0x145>
mov    -0xf70(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xbb3(%rip),%rdi
call   1080 <system@plt>
lea    0xbb7(%rip),%rdi
call   1080 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xf38,%rsp
lea    0xdf8(%rip),%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     12b6 <main+0xc6>
mov    %rax,%rbx
mov    %rax,%rdi
call   10d0 <readdir@plt>
test   %rax,%rax
je     12d1 <main+0xe1>
mov    %rax,%rbp
xor    %r15d,%r15d
mov    0x2da9(%rip),%r12
lea    0xdc9(%rip),%r14
jmp    1254 <main+0x64>
mov    %rbx,%rdi
call   10d0 <readdir@plt>
mov    %rax,%rbp
test   %rax,%rax
je     12d4 <main+0xe4>
mov    0x0(%rbp),%rax
cmp    (%r12),%rax
jne    1240 <main+0x50>
mov    0x8(%rbp),%rdi
mov    %r14,%rsi
call   1110 <strstr@plt>
test   %rax,%rax
je     1240 <main+0x50>
mov    %rax,%rdi
call   1070 <strlen@plt>
cmp    $0x2,%eax
jne    1240 <main+0x50>
mov    0x8(%rbp),%rdi
call   1070 <strlen@plt>
cmp    $0x3ff,%eax
jg     1240 <main+0x50>
mov    0x8(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,%edi
call   10e0 <malloc@plt>
movslq %r15d,%r15
mov    %rax,0x10(%rsp,%r15,8)
mov    0x8(%rbp),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
add    $0x1,%r15d
jmp    1240 <main+0x50>
lea    0xd4d(%rip),%rdi
lea    0xd59(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,%r14
jmp    13f6 <main+0x206>
xor    %r15d,%r15d
mov    %rbx,%rdi
call   10a0 <closedir@plt>
lea    0xd27(%rip),%rdi
lea    0xd33(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,%r14
test   %r15d,%r15d
jle    13f6 <main+0x206>
mov    %r15d,%eax
mov    %rax,0x8(%rsp)
lea    0x730(%rsp),%r15
lea    0xb30(%rsp),%rbp
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
mov    0x10(%rsp,%r12,8),%r13
mov    %r13,%rdi
call   1070 <strlen@plt>
lea    -0x2(%rax),%edx
mov    %r15,%rdi
mov    %r13,%rsi
call   1030 <strncpy@plt>
mov    %rbp,%rdi
mov    $0x400,%esi
lea    0xcd5(%rip),%rdx
mov    %r13,%rcx
mov    %r15,%r8
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x400,%ecx
je     1418 <main+0x228>
test   %ecx,%ecx
js     1418 <main+0x228>
add    $0x1,%r12
mov    %rbp,%rdi
call   1080 <system@plt>
lea    0x330(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
lea    0xc9a(%rip),%rdx
mov    %r15,%rcx
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %rbx,%rdi
lea    0xc94(%rip),%rsi
call   10f0 <fopen@plt>
mov    %r15,%rbx
mov    %rax,%r15
mov    %r14,%rdi
lea    0xc81(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   10c0 <fprintf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1100 <load_from_files@plt>
mov    $0xa,%edi
mov    %r14,%rsi
call   10b0 <fputc@plt>
mov    %r15,%rdi
mov    %rbx,%r15
call   1050 <fclose@plt>
cmp    %r12,0x8(%rsp)
jne    1320 <main+0x130>
mov    %r14,%rdi
call   1050 <fclose@plt>
lea    0xc3e(%rip),%rdi
call   1080 <system@plt>
lea    0xc42(%rip),%rdi
call   1080 <system@plt>
xor    %eax,%eax
add    $0xf38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i64, i8* }
@.str = [7 x i8] c"./test\00"
@DT_REG = global i64 0
@.str.1 = [3 x i8] c".s\00"
@.str.2 = [19 x i8] c"./test/results.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [30 x i8] c"xa ./test/%s -o ./test/%s.o65\00"
@.str.5 = [14 x i8] c"./test/%s.o65\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [4 x i8] c"%s\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [16 x i8] c"rm ./test/*.o65\00"
@.str.10 = [94 x i8] c"cmp --silent ./test/results.txt ./test/expected.txt || echo \22Warning! Unexpected test output\22\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.dirent*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [1024 x i8]
%11 = alloca [1024 x i8]
%12 = alloca [1024 x i8]
%13 = alloca [100 x i8*]
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32*
%18 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %14
%19 = call i32* @opendir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32* %19, i32** %6
%20 = icmp ne i32* %19, null
br i1 %20, label %21, label %73
21: ; preds = %2
br label %22
22: ; preds = %69, %21
%23 = load i32*, i32** %6
%24 = call %struct.dirent* @readdir(i32* %23)
store %struct.dirent* %24, %struct.dirent** %7
%25 = icmp ne %struct.dirent* %24, null
br i1 %25, label %26, label %70
26: ; preds = %22
%27 = load %struct.dirent*, %struct.dirent** %7
%28 = getelementptr inbounds %struct.dirent, %struct.dirent* %27, i32 0, i32 0
%29 = load i64, i64* %28
%30 = load i64, i64* @DT_REG
%31 = icmp eq i64 %29, %30
br i1 %31, label %32, label %69
32: ; preds = %26
%33 = load %struct.dirent*, %struct.dirent** %7
%34 = getelementptr inbounds %struct.dirent, %struct.dirent* %33, i32 0, i32 1
%35 = load i8*, i8** %34
%36 = call i8* @strstr(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %36, i8** %9
%37 = load i8*, i8** %9
%38 = icmp ne i8* %37, null
br i1 %38, label %39, label %68
39: ; preds = %32
%40 = load i8*, i8** %9
%41 = call i32 @strlen(i8* %40)
%42 = icmp eq i32 %41, 2
br i1 %42, label %43, label %68
43: ; preds = %39
%44 = load %struct.dirent*, %struct.dirent** %7
%45 = getelementptr inbounds %struct.dirent, %struct.dirent* %44, i32 0, i32 1
%46 = load i8*, i8** %45
%47 = call i32 @strlen(i8* %46)
%48 = icmp slt i32 %47, 1024
br i1 %48, label %49, label %68
49: ; preds = %43
%50 = load %struct.dirent*, %struct.dirent** %7
%51 = getelementptr inbounds %struct.dirent, %struct.dirent* %50, i32 0, i32 1
%52 = load i8*, i8** %51
%53 = call i32 @strlen(i8* %52)
%54 = call i8* @malloc(i32 %53)
%55 = load i32, i32* %14
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [100 x i8*], [100 x i8*]* %13, i64 0, i64 %56
store i8* %54, i8** %57
%58 = load i32, i32* %14
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [100 x i8*], [100 x i8*]* %13, i64 0, i64 %59
%61 = load i8*, i8** %60
%62 = load %struct.dirent*, %struct.dirent** %7
%63 = getelementptr inbounds %struct.dirent, %struct.dirent* %62, i32 0, i32 1
%64 = load i8*, i8** %63
%65 = call i32 @strcpy(i8* %61, i8* %64)
%66 = load i32, i32* %14
%67 = add nsw i32 %66, 1
store i32 %67, i32* %14
br label %68
68: ; preds = %49, %43, %39, %32
br label %69
69: ; preds = %68, %26
br label %22
70: ; preds = %22
%71 = load i32*, i32** %6
%72 = call i32 @closedir(i32* %71)
br label %73
73: ; preds = %70, %2
store i32 0, i32* %15
%74 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %74, i32** %18
br label %75
75: ; preds = %101, %73
%76 = load i32, i32* %15
%77 = load i32, i32* %14
%78 = icmp slt i32 %76, %77
br i1 %78, label %79, label %119
79: ; preds = %75
%80 = load i32, i32* %15
%81 = add nsw i32 %80, 1
store i32 %81, i32* %15
%82 = sext i32 %80 to i64
%83 = getelementptr inbounds [100 x i8*], [100 x i8*]* %13, i64 0, i64 %82
%84 = load i8*, i8** %83
store i8* %84, i8** %8
%85 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%86 = load i8*, i8** %8
%87 = load i8*, i8** %8
%88 = call i32 @strlen(i8* %87)
%89 = sub nsw i32 %88, 2
%90 = call i32 @strncpy(i8* %85, i8* %86, i32 %89)
%91 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%92 = load i8*, i8** %8
%93 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%94 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %91, i32 1024, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %92, i8* %93)
store i32 %94, i32* %16
%95 = load i32, i32* %16
%96 = icmp eq i32 %95, 1024
br i1 %96, label %100, label %97
97: ; preds = %79
%98 = load i32, i32* %16
%99 = icmp slt i32 %98, 0
br i1 %99, label %100, label %101
100: ; preds = %97, %79
store i32 1, i32* %3
br label %124
101: ; preds = %97
%102 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%103 = call i32 @system(i8* %102)
%104 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%105 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%106 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %104, i32 1024, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %105)
%107 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%108 = call i32* @fopen(i8* %107, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32* %108, i32** %17
%109 = load i32*, i32** %18
%110 = load i8*, i8** %8
%111 = call i32 (i32*, i8*, ...) @fprintf(i32* %109, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %110)
%112 = load i32*, i32** %17
%113 = load i32*, i32** %18
%114 = call i32 @load_from_files(i32* %112, i32* %113)
%115 = load i32*, i32** %18
%116 = call i32 (i32*, i8*, ...) @fprintf(i32* %115, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%117 = load i32*, i32** %17
%118 = call i32 @fclose(i32* %117)
br label %75
119: ; preds = %75
%120 = load i32*, i32** %18
%121 = call i32 @fclose(i32* %120)
%122 = call i32 @system(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%123 = call i32 @system(i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %3
br label %124
124: ; preds = %119, %100
%125 = load i32, i32* %3
ret i32 %125
}

LLVM IR (-O2):
%struct.dirent = type { i64, i8* }
@.str = [7 x i8] c"./test\00"
@DT_REG = global i64 0
@.str.1 = [3 x i8] c".s\00"
@.str.2 = [19 x i8] c"./test/results.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [30 x i8] c"xa ./test/%s -o ./test/%s.o65\00"
@.str.5 = [14 x i8] c"./test/%s.o65\00"
@.str.6 = [2 x i8] c"r\00"
@.str.7 = [4 x i8] c"%s\0A\00"
@.str.9 = [16 x i8] c"rm ./test/*.o65\00"
@.str.10 = [94 x i8] c"cmp --silent ./test/results.txt ./test/expected.txt || echo \22Warning! Unexpected test output\22\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = alloca [1024 x i8]
%6 = alloca [100 x i8*]
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%10 = bitcast [100 x i8*]* %6 to i8*
%11 = tail call i32* @opendir(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %78
15: ; preds = %2
%16 = tail call %struct.dirent* @readdir(i32* %11)
%17 = icmp eq %struct.dirent* %16, null
br i1 %17, label %50, label %18
18: ; preds = %15, %46
%19 = phi %struct.dirent* [ %48, %46 ], [ %16, %15 ]
%20 = phi i32 [ %47, %46 ], [ 0, %15 ]
%21 = getelementptr inbounds %struct.dirent, %struct.dirent* %19, i64 0, i32 0
%22 = load i64, i64* %21
%23 = load i64, i64* @DT_REG
%24 = icmp eq i64 %22, %23
br i1 %24, label %25, label %46
25: ; preds = %18
%26 = getelementptr inbounds %struct.dirent, %struct.dirent* %19, i64 0, i32 1
%27 = load i8*, i8** %26
%28 = tail call i8* @strstr(i8* dereferenceable(1) %27, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i8* %28, null
br i1 %29, label %46, label %30
30: ; preds = %25
%31 = tail call i32 @strlen(i8* %28)
%32 = icmp eq i32 %31, 2
br i1 %32, label %33, label %46
33: ; preds = %30
%34 = load i8*, i8** %26
%35 = tail call i32 @strlen(i8* %34)
%36 = icmp slt i32 %35, 1024
br i1 %36, label %37, label %46
37: ; preds = %33
%38 = load i8*, i8** %26
%39 = tail call i32 @strlen(i8* %38)
%40 = tail call i8* @malloc(i32 %39)
%41 = sext i32 %20 to i64
%42 = getelementptr inbounds [100 x i8*], [100 x i8*]* %6, i64 0, i64 %41
store i8* %40, i8** %42
%43 = load i8*, i8** %26
%44 = tail call i32 @strcpy(i8* %40, i8* %43)
%45 = add nsw i32 %20, 1
br label %46
46: ; preds = %25, %30, %33, %37, %18
%47 = phi i32 [ %45, %37 ], [ %20, %33 ], [ %20, %30 ], [ %20, %25 ], [ %20, %18 ]
%48 = tail call %struct.dirent* @readdir(i32* %11)
%49 = icmp eq %struct.dirent* %48, null
br i1 %49, label %50, label %18
50: ; preds = %46, %15
%51 = phi i32 [ 0, %15 ], [ %47, %46 ]
%52 = tail call i32 @closedir(i32* %11)
%53 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%54 = icmp sgt i32 %51, 0
br i1 %54, label %55, label %78
55: ; preds = %50
%56 = zext i32 %51 to i64
br label %57
57: ; preds = %55, %68
%58 = phi i64 [ 0, %55 ], [ %69, %68 ]
%59 = getelementptr inbounds [100 x i8*], [100 x i8*]* %6, i64 0, i64 %58
%60 = load i8*, i8** %59
%61 = call i32 @strlen(i8* %60)
%62 = add nsw i32 %61, -2
%63 = call i32 @strncpy(i8* %8, i8* %60, i32 %62)
%64 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %7, i32 1024, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i8* %60, i8* %8)
%65 = icmp eq i32 %64, 1024
%66 = icmp slt i32 %64, 0
%67 = or i1 %65, %66
br i1 %67, label %83, label %68
68: ; preds = %57
%69 = add nuw nsw i64 %58, 1
%70 = call i32 @system(i8* %7)
%71 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %9, i32 1024, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %8)
%72 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%73 = call i32 (i32*, i8*, ...) @fprintf(i32* %53, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %60)
%74 = call i32 @load_from_files(i32* %72, i32* %53)
%75 = call i32 @fputc(i32 10, i32* %53)
%76 = call i32 @fclose(i32* %72)
%77 = icmp eq i64 %69, %56
br i1 %77, label %78, label %57
78: ; preds = %68, %13, %50
%79 = phi i32* [ %14, %13 ], [ %53, %50 ], [ %53, %68 ]
%80 = call i32 @fclose(i32* %79)
%81 = call i32 @system(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0))
%82 = call i32 @system(i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.10, i64 0, i64 0))
br label %83
83: ; preds = %57, %78
%84 = phi i32 [ 0, %78 ], [ 1, %57 ]
ret i32 %84
}