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

/* Variables and functions */
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
char *dirname(char *);
int /*<<< orphan*/ execlp(char *, char *, char *, char *, char *, ...);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ realpath(char *, char *);
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ rmdir(char *);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *strtok(char *, char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("Usage: %s <filesdir>\n", argv[0]);
    exit(2);
  }
  setbuf(stdout, NULL);
  char real_d_files[256];
  realpath(argv[1], real_d_files);
  strcat(real_d_files, "/");
  char real_d_bin[256];
  realpath(argv[0], real_d_bin);
  strcat(real_d_bin, "/");
  char *base_d = dirname(real_d_bin);
  strcat(base_d, "/");
  char sw_path[256];
  strcpy(sw_path, base_d);
  strcat(sw_path, "sw");
  char csc_path[256];
  strcpy(csc_path, base_d);
  strcat(csc_path, "csc");
  char temp_d[256];
  strcpy(temp_d, base_d);
  strcat(temp_d, "temp/");
  char word_d[256];
  strcpy(word_d, real_d_files);
  strcat(word_d, "words.txt");
  printf("+-------------------------------\n");
  printf("|Words dired: %s\n", word_d);
  DIR *dp;
  struct dirent *ep;
  dp = opendir(real_d_files);
  if (dp != NULL) {
    while ((ep = readdir(dp)) != NULL) {
      if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0 ||
          strcmp(ep->d_name, "words.txt") == 0 ||
          strcmp(ep->d_name, "index.txt") == 0) {
        continue;
      }
      char temp[256];
      strcpy(temp, ep->d_name);
      char *pch;
      pch = strtok(temp, ".");
      char dired[256];
      strcpy(dired, real_d_files);
      strcat(dired, ep->d_name);
      printf("+-------------------------------\n");
      printf("|Dired: %s\n", dired);
      printf("+-------------------------------\n");
      printf("|");
      if (fork() == 0) {
        execlp(sw_path, "sw", dired, pch, word_d, base_d, NULL);
        fprintf(stderr, "**ERROR** sw not executed **ERROR**\n");
        exit(3);
      }
      wait(NULL);
    }
    printf("+-------------------------------\n");
    (void)closedir(dp);
  } else {
    fprintf(stderr, "Couldn't open the directory");
    exit(1);
  }
  if (fork() == 0) {
    execlp(csc_path, csc_path, real_d_files, temp_d, NULL);
    fprintf(stderr, "**ERROR** csc not executed **ERROR**\n");
    exit(3);
  }
  wait(NULL);
  dp = opendir(temp_d);
  if (dp != NULL) {
    while ((ep = readdir(dp)) != NULL) {
      char dired[256];
      strcpy(dired, temp_d);
      strcat(dired, ep->d_name);
      remove(dired);
    }
    (void)closedir(dp);
  } else {
    fprintf(stderr, "Couldn't open the directory");
    exit(1);
  }
  rmdir(temp_d);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x950,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1262 <main+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x2,%edi
call   1110 <exit@plt>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <setbuf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x110(%rbp),%rsi
call   10d0 <realpath@plt>
lea    -0x110(%rbp),%rdi
lea    0xd8b(%rip),%rsi
call   1100 <strcat@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    -0x210(%rbp),%rsi
call   10d0 <realpath@plt>
lea    -0x210(%rbp),%rdi
lea    0xd65(%rip),%rsi
call   1100 <strcat@plt>
lea    -0x210(%rbp),%rdi
call   1090 <dirname@plt>
mov    %rax,-0x218(%rbp)
mov    -0x218(%rbp),%rdi
lea    0xd3f(%rip),%rsi
call   1100 <strcat@plt>
lea    -0x320(%rbp),%rdi
mov    -0x218(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x320(%rbp),%rdi
lea    0xd0e(%rip),%rsi
call   1100 <strcat@plt>
lea    -0x420(%rbp),%rdi
mov    -0x218(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x420(%rbp),%rdi
lea    0xceb(%rip),%rsi
call   1100 <strcat@plt>
lea    -0x520(%rbp),%rdi
mov    -0x218(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x520(%rbp),%rdi
lea    0xcc9(%rip),%rsi
call   1100 <strcat@plt>
lea    -0x620(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x620(%rbp),%rdi
lea    0xca9(%rip),%rsi
call   1100 <strcat@plt>
lea    0xca7(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x620(%rbp),%rsi
lea    0xcb4(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x110(%rbp),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x628(%rbp)
cmpq   $0x0,-0x628(%rbp)
je     159a <main+0x37a>
jmp    13c8 <main+0x1a8>
mov    -0x628(%rbp),%rdi
call   10e0 <readdir@plt>
mov    %rax,-0x630(%rbp)
cmp    $0x0,%rax
je     157b <main+0x35b>
mov    -0x630(%rbp),%rax
mov    (%rax),%rdi
lea    0xc6c(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
je     1465 <main+0x245>
mov    -0x630(%rbp),%rax
mov    (%rax),%rdi
lea    0xc4b(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
je     1465 <main+0x245>
mov    -0x630(%rbp),%rax
mov    (%rax),%rdi
lea    0xbed(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
je     1465 <main+0x245>
mov    -0x630(%rbp),%rax
mov    (%rax),%rdi
lea    0xc0e(%rip),%rsi
call   10b0 <strcmp@plt>
cmp    $0x0,%rax
jne    146a <main+0x24a>
jmp    13c8 <main+0x1a8>
lea    -0x730(%rbp),%rdi
mov    -0x630(%rbp),%rax
mov    (%rax),%rsi
call   1040 <strcpy@plt>
lea    -0x730(%rbp),%rdi
lea    0xbd4(%rip),%rsi
call   10f0 <strtok@plt>
mov    %rax,-0x738(%rbp)
lea    -0x840(%rbp),%rdi
lea    -0x110(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x840(%rbp),%rdi
mov    -0x630(%rbp),%rax
mov    (%rax),%rsi
call   1100 <strcat@plt>
lea    0xb63(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x840(%rbp),%rsi
lea    0xb8f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xb40(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xb7f(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x0,%al
call   1140 <fork@plt>
cmp    $0x0,%rax
jne    156d <main+0x34d>
lea    -0x320(%rbp),%rdi
lea    -0x840(%rbp),%rdx
mov    -0x738(%rbp),%rcx
lea    -0x620(%rbp),%r8
mov    -0x218(%rbp),%r9
lea    0xad9(%rip),%rsi
xor    %eax,%eax
movq   $0x0,(%rsp)
mov    $0x0,%al
call   1120 <execlp@plt>
mov    0x2a8b(%rip),%rax
mov    (%rax),%edi
lea    0xb1e(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x3,%edi
call   1110 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1130 <wait@plt>
jmp    13c8 <main+0x1a8>
lea    0xaab(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x628(%rbp),%rdi
call   10a0 <closedir@plt>
jmp    15b9 <main+0x399>
mov    0x2a3f(%rip),%rax
mov    (%rax),%edi
lea    0xaf7(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    $0x0,%al
call   1140 <fork@plt>
cmp    $0x0,%rax
jne    1611 <main+0x3f1>
lea    -0x420(%rbp),%rdi
lea    -0x420(%rbp),%rsi
lea    -0x110(%rbp),%rdx
lea    -0x520(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
mov    $0x0,%al
call   1120 <execlp@plt>
mov    0x29e7(%rip),%rax
mov    (%rax),%edi
lea    0xabb(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x3,%edi
call   1110 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1130 <wait@plt>
lea    -0x520(%rbp),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x628(%rbp)
cmpq   $0x0,-0x628(%rbp)
je     16a8 <main+0x488>
jmp    1640 <main+0x420>
mov    -0x628(%rbp),%rdi
call   10e0 <readdir@plt>
mov    %rax,-0x630(%rbp)
cmp    $0x0,%rax
je     1697 <main+0x477>
lea    -0x940(%rbp),%rdi
lea    -0x520(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x940(%rbp),%rdi
mov    -0x630(%rbp),%rax
mov    (%rax),%rsi
call   1100 <strcat@plt>
lea    -0x940(%rbp),%rdi
call   1030 <remove@plt>
jmp    1640 <main+0x420>
mov    -0x628(%rbp),%rdi
call   10a0 <closedir@plt>
jmp    16c7 <main+0x4a7>
mov    0x2931(%rip),%rax
mov    (%rax),%edi
lea    0x9e9(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    -0x520(%rbp),%rdi
call   1060 <rmdir@plt>
xor    %edi,%edi
call   1110 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x828,%rsp
mov    %rsi,%rbp
cmp    $0x2,%edi
jne    1396 <main+0x156>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1090 <setbuf@plt>
mov    0x8(%rbp),%rdi
lea    0x120(%rsp),%r14
mov    %r14,%rsi
call   10f0 <realpath@plt>
lea    0xd99(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1120 <strcat@plt>
mov    0x0(%rbp),%rdi
lea    0x720(%rsp),%rbp
mov    %rbp,%rsi
call   10f0 <realpath@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1120 <strcat@plt>
mov    %rbp,%rdi
call   10b0 <dirname@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
call   1120 <strcat@plt>
lea    0x620(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <strcpy@plt>
lea    0xd34(%rip),%rsi
mov    %rbp,%rdi
call   1120 <strcat@plt>
lea    0x520(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <strcpy@plt>
lea    0xd15(%rip),%rsi
mov    %rbp,%rdi
call   1120 <strcat@plt>
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1050 <strcpy@plt>
lea    0xcfa(%rip),%rsi
mov    %rbp,%rdi
call   1120 <strcat@plt>
lea    0x420(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
call   1050 <strcpy@plt>
lea    0xcde(%rip),%rsi
mov    %rbp,%rdi
call   1120 <strcat@plt>
lea    0xd6b(%rip),%rdi
call   1060 <puts@plt>
lea    0xccd(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    %r14,%rdi
call   1070 <opendir@plt>
test   %rax,%rax
jne    13b2 <main+0x172>
mov    0x2c62(%rip),%rax
mov    (%rax),%edi
lea    0xcf6(%rip),%rsi
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    0x0(%rbp),%rsi
lea    0xc5f(%rip),%rdi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    $0x2,%edi
call   1130 <exit@plt>
mov    %rax,%rbp
mov    %rbx,0x10(%rsp)
mov    %rax,%rdi
call   1100 <readdir@plt>
test   %rax,%rax
jne    142c <main+0x1ec>
lea    0xcf1(%rip),%rdi
call   1060 <puts@plt>
mov    %rbp,%rdi
call   10c0 <closedir@plt>
xor    %eax,%eax
call   1160 <fork@plt>
test   %rax,%rax
jne    154c <main+0x30c>
lea    0x520(%rsp),%rdi
lea    0x120(%rsp),%rdx
lea    0x20(%rsp),%rcx
mov    %rdi,%rsi
xor    %r8d,%r8d
xor    %eax,%eax
call   1140 <execlp@plt>
mov    0x2bcc(%rip),%rax
mov    (%rax),%edi
lea    0xc7c(%rip),%rsi
call   10e0 <fprintf@plt>
mov    $0x3,%edi
call   1130 <exit@plt>
mov    %rax,%r14
lea    0xc0a(%rip),%r13
lea    0xc02(%rip),%rbx
lea    0xbdf(%rip),%r15
mov    %rbp,0x18(%rsp)
jmp    1464 <main+0x224>
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1100 <readdir@plt>
mov    %rax,%r14
test   %rax,%rax
je     13c7 <main+0x187>
mov    (%r14),%rdi
mov    %r13,%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     1450 <main+0x210>
mov    (%r14),%rdi
mov    %rbx,%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     1450 <main+0x210>
mov    (%r14),%rdi
mov    %r15,%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     1450 <main+0x210>
mov    (%r14),%rdi
lea    0xba4(%rip),%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     1450 <main+0x210>
mov    (%r14),%rsi
lea    0x320(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strcpy@plt>
mov    %rbx,%rdi
mov    %r13,%r12
mov    %r13,%rsi
call   1110 <strtok@plt>
mov    %rax,%r13
lea    0x220(%rsp),%rbx
mov    %rbx,%rdi
lea    0x120(%rsp),%rsi
call   1050 <strcpy@plt>
mov    (%r14),%rsi
mov    %rbx,%rdi
call   1120 <strcat@plt>
lea    0xbc9(%rip),%r14
mov    %r14,%rdi
call   1060 <puts@plt>
lea    0xb47(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    %r14,%rdi
call   1060 <puts@plt>
mov    $0x7c,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1160 <fork@plt>
test   %rax,%rax
je     15d7 <main+0x397>
xor    %edi,%edi
call   1150 <wait@plt>
lea    0xb00(%rip),%rbx
mov    %r12,%r13
mov    0x18(%rsp),%rbp
jmp    1450 <main+0x210>
xor    %edi,%edi
call   1150 <wait@plt>
lea    0x20(%rsp),%rdi
call   1070 <opendir@plt>
test   %rax,%rax
je     1377 <main+0x137>
mov    %rax,%r15
mov    %rax,%rdi
call   1100 <readdir@plt>
test   %rax,%rax
je     15be <main+0x37e>
mov    %rax,%rbx
lea    0x320(%rsp),%rbp
lea    0x20(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r14,%rsi
call   1050 <strcpy@plt>
mov    (%rbx),%rsi
mov    %rbp,%rdi
call   1120 <strcat@plt>
mov    %rbp,%rdi
call   1040 <remove@plt>
mov    %r15,%rdi
call   1100 <readdir@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1590 <main+0x350>
mov    %r15,%rdi
call   10c0 <closedir@plt>
lea    0x20(%rsp),%rdi
call   1080 <rmdir@plt>
xor    %edi,%edi
call   1130 <exit@plt>
movq   $0x0,(%rsp)
lea    0xa30(%rip),%rsi
lea    0x620(%rsp),%rdi
lea    0x220(%rsp),%rdx
lea    0x420(%rsp),%r8
mov    %r13,%rcx
mov    0x10(%rsp),%r9
xor    %eax,%eax
call   1140 <execlp@plt>
mov    0x29cc(%rip),%rax
mov    (%rax),%edi
lea    0xa3b(%rip),%rsi
jmp    141d <main+0x1dd>

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [22 x i8] c"Usage: %s <filesdir>\0A\00"
@stdout = global i32 0
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [3 x i8] c"sw\00"
@.str.3 = [4 x i8] c"csc\00"
@.str.4 = [6 x i8] c"temp/\00"
@.str.5 = [10 x i8] c"words.txt\00"
@.str.6 = [34 x i8] c"+-------------------------------\0A\00"
@.str.7 = [18 x i8] c"|Words dired: %s\0A\00"
@.str.8 = [2 x i8] c".\00"
@.str.9 = [3 x i8] c"..\00"
@.str.10 = [10 x i8] c"index.txt\00"
@.str.11 = [12 x i8] c"|Dired: %s\0A\00"
@.str.12 = [2 x i8] c"|\00"
@stderr = global i32 0
@.str.13 = [37 x i8] c"**ERROR** sw not executed **ERROR**\0A\00"
@.str.14 = [28 x i8] c"Couldn't open the directory\00"
@.str.15 = [38 x i8] c"**ERROR** csc not executed **ERROR**\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = alloca i8*
%9 = alloca [256 x i8]
%10 = alloca [256 x i8]
%11 = alloca [256 x i8]
%12 = alloca [256 x i8]
%13 = alloca i32*
%14 = alloca %struct.dirent*
%15 = alloca [256 x i8]
%16 = alloca i8*
%17 = alloca [256 x i8]
%18 = alloca [256 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 2
br i1 %20, label %21, label %27
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = call i32 @exit(i32 2)
unreachable
27: ; preds = %2
%28 = load i32, i32* @stdout
%29 = call i32 @setbuf(i32 %28, i32* null)
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%34 = call i32 @realpath(i8* %32, i8* %33)
%35 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%36 = call i32 @strcat(i8* %35, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 0
%39 = load i8*, i8** %38
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%41 = call i32 @realpath(i8* %39, i8* %40)
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%43 = call i32 @strcat(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%45 = call i8* @dirname(i8* %44)
store i8* %45, i8** %8
%46 = load i8*, i8** %8
%47 = call i32 @strcat(i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%48 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%49 = load i8*, i8** %8
%50 = call i32 @strcpy(i8* %48, i8* %49)
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%52 = call i32 @strcat(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%53 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%54 = load i8*, i8** %8
%55 = call i32 @strcpy(i8* %53, i8* %54)
%56 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%57 = call i32 @strcat(i8* %56, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%58 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%59 = load i8*, i8** %8
%60 = call i32 @strcpy(i8* %58, i8* %59)
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%62 = call i32 @strcat(i8* %61, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%63 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%64 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%65 = call i32 @strcpy(i8* %63, i8* %64)
%66 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%67 = call i32 @strcat(i8* %66, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%69 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %69)
%71 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%72 = call i32* @opendir(i8* %71)
store i32* %72, i32** %13
%73 = load i32*, i32** %13
%74 = icmp ne i32* %73, null
br i1 %74, label %75, label %144
75: ; preds = %27
br label %76
76: ; preds = %138, %104, %75
%77 = load i32*, i32** %13
%78 = call %struct.dirent* @readdir(i32* %77)
store %struct.dirent* %78, %struct.dirent** %14
%79 = icmp ne %struct.dirent* %78, null
br i1 %79, label %80, label %140
80: ; preds = %76
%81 = load %struct.dirent*, %struct.dirent** %14
%82 = getelementptr inbounds %struct.dirent, %struct.dirent* %81, i32 0, i32 0
%83 = load i8*, i8** %82
%84 = call i64 @strcmp(i8* %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%85 = icmp eq i64 %84, 0
br i1 %85, label %104, label %86
86: ; preds = %80
%87 = load %struct.dirent*, %struct.dirent** %14
%88 = getelementptr inbounds %struct.dirent, %struct.dirent* %87, i32 0, i32 0
%89 = load i8*, i8** %88
%90 = call i64 @strcmp(i8* %89, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%91 = icmp eq i64 %90, 0
br i1 %91, label %104, label %92
92: ; preds = %86
%93 = load %struct.dirent*, %struct.dirent** %14
%94 = getelementptr inbounds %struct.dirent, %struct.dirent* %93, i32 0, i32 0
%95 = load i8*, i8** %94
%96 = call i64 @strcmp(i8* %95, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%97 = icmp eq i64 %96, 0
br i1 %97, label %104, label %98
98: ; preds = %92
%99 = load %struct.dirent*, %struct.dirent** %14
%100 = getelementptr inbounds %struct.dirent, %struct.dirent* %99, i32 0, i32 0
%101 = load i8*, i8** %100
%102 = call i64 @strcmp(i8* %101, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%103 = icmp eq i64 %102, 0
br i1 %103, label %104, label %105
104: ; preds = %98, %92, %86, %80
br label %76
105: ; preds = %98
%106 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%107 = load %struct.dirent*, %struct.dirent** %14
%108 = getelementptr inbounds %struct.dirent, %struct.dirent* %107, i32 0, i32 0
%109 = load i8*, i8** %108
%110 = call i32 @strcpy(i8* %106, i8* %109)
%111 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%112 = call i8* @strtok(i8* %111, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i8* %112, i8** %16
%113 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%114 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%115 = call i32 @strcpy(i8* %113, i8* %114)
%116 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%117 = load %struct.dirent*, %struct.dirent** %14
%118 = getelementptr inbounds %struct.dirent, %struct.dirent* %117, i32 0, i32 0
%119 = load i8*, i8** %118
%120 = call i32 @strcat(i8* %116, i8* %119)
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%122 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i8* %122)
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%126 = call i64 (...) @fork()
%127 = icmp eq i64 %126, 0
br i1 %127, label %128, label %138
128: ; preds = %105
%129 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%130 = getelementptr inbounds [256 x i8], [256 x i8]* %17, i64 0, i64 0
%131 = load i8*, i8** %16
%132 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%133 = load i8*, i8** %8
%134 = call i32 (i8*, i8*, i8*, i8*, i8*, ...) @execlp(i8* %129, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %130, i8* %131, i8* %132, i8* %133, i8* null)
%135 = load i32, i32* @stderr
%136 = call i32 @fprintf(i32 %135, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.13, i64 0, i64 0))
%137 = call i32 @exit(i32 3)
unreachable
138: ; preds = %105
%139 = call i32 @wait(i32* null)
br label %76
140: ; preds = %76
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%142 = load i32*, i32** %13
%143 = call i32 @closedir(i32* %142)
br label %148
144: ; preds = %27
%145 = load i32, i32* @stderr
%146 = call i32 @fprintf(i32 %145, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0))
%147 = call i32 @exit(i32 1)
unreachable
148: ; preds = %140
%149 = call i64 (...) @fork()
%150 = icmp eq i64 %149, 0
br i1 %150, label %151, label %160
151: ; preds = %148
%152 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%153 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%154 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%155 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%156 = call i32 (i8*, i8*, i8*, i8*, i8*, ...) @execlp(i8* %152, i8* %153, i8* %154, i8* %155, i8* null)
%157 = load i32, i32* @stderr
%158 = call i32 @fprintf(i32 %157, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.15, i64 0, i64 0))
%159 = call i32 @exit(i32 3)
unreachable
160: ; preds = %148
%161 = call i32 @wait(i32* null)
%162 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%163 = call i32* @opendir(i8* %162)
store i32* %163, i32** %13
%164 = load i32*, i32** %13
%165 = icmp ne i32* %164, null
br i1 %165, label %166, label %185
166: ; preds = %160
br label %167
167: ; preds = %171, %166
%168 = load i32*, i32** %13
%169 = call %struct.dirent* @readdir(i32* %168)
store %struct.dirent* %169, %struct.dirent** %14
%170 = icmp ne %struct.dirent* %169, null
br i1 %170, label %171, label %182
171: ; preds = %167
%172 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%173 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%174 = call i32 @strcpy(i8* %172, i8* %173)
%175 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%176 = load %struct.dirent*, %struct.dirent** %14
%177 = getelementptr inbounds %struct.dirent, %struct.dirent* %176, i32 0, i32 0
%178 = load i8*, i8** %177
%179 = call i32 @strcat(i8* %175, i8* %178)
%180 = getelementptr inbounds [256 x i8], [256 x i8]* %18, i64 0, i64 0
%181 = call i32 @remove(i8* %180)
br label %167
182: ; preds = %167
%183 = load i32*, i32** %13
%184 = call i32 @closedir(i32* %183)
br label %189
185: ; preds = %160
%186 = load i32, i32* @stderr
%187 = call i32 @fprintf(i32 %186, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0))
%188 = call i32 @exit(i32 1)
unreachable
189: ; preds = %182
%190 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%191 = call i32 @rmdir(i8* %190)
%192 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [22 x i8] c"Usage: %s <filesdir>\0A\00"
@stdout = global i32 0
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [3 x i8] c"sw\00"
@.str.3 = [4 x i8] c"csc\00"
@.str.4 = [6 x i8] c"temp/\00"
@.str.5 = [10 x i8] c"words.txt\00"
@.str.7 = [18 x i8] c"|Words dired: %s\0A\00"
@.str.8 = [2 x i8] c".\00"
@.str.9 = [3 x i8] c"..\00"
@.str.10 = [10 x i8] c"index.txt\00"
@.str.11 = [12 x i8] c"|Dired: %s\0A\00"
@stderr = global i32 0
@.str.13 = [37 x i8] c"**ERROR** sw not executed **ERROR**\0A\00"
@.str.14 = [28 x i8] c"Couldn't open the directory\00"
@.str.15 = [38 x i8] c"**ERROR** csc not executed **ERROR**\0A\00"
@str.18 = [33 x i8] c"+-------------------------------\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = alloca [256 x i8]
%9 = alloca [256 x i8]
%10 = alloca [256 x i8]
%11 = alloca [256 x i8]
%12 = icmp eq i32 %0, 2
br i1 %12, label %17, label %13
13: ; preds = %2
%14 = load i8*, i8** %1
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = tail call i32 @exit(i32 2)
unreachable
17: ; preds = %2
%18 = load i32, i32* @stdout
%19 = tail call i32 @setbuf(i32 %18, i32* null)
%20 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @realpath(i8* %22, i8* %20)
%24 = call i32 @strcat(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%26 = load i8*, i8** %1
%27 = call i32 @realpath(i8* %26, i8* %25)
%28 = call i32 @strcat(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = call i8* @dirname(i8* %25)
%30 = call i32 @strcat(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%32 = call i32 @strcpy(i8* %31, i8* %29)
%33 = call i32 @strcat(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%34 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%35 = call i32 @strcpy(i8* %34, i8* %29)
%36 = call i32 @strcat(i8* %34, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%38 = call i32 @strcpy(i8* %37, i8* %29)
%39 = call i32 @strcat(i8* %37, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%41 = call i32 @strcpy(i8* %40, i8* %20)
%42 = call i32 @strcat(i8* %40, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.18, i64 0, i64 0))
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %40)
%45 = call i32* @opendir(i8* %20)
%46 = icmp eq i32* %45, null
br i1 %46, label %99, label %47
47: ; preds = %17
%48 = call %struct.dirent* @readdir(i32* %45)
%49 = icmp eq %struct.dirent* %48, null
br i1 %49, label %94, label %50
50: ; preds = %47
%51 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
br label %53
53: ; preds = %50, %71
%54 = phi %struct.dirent* [ %48, %50 ], [ %72, %71 ]
%55 = getelementptr inbounds %struct.dirent, %struct.dirent* %54, i64 0, i32 0
%56 = load i8*, i8** %55
%57 = call i64 @strcmp(i8* %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%58 = icmp eq i64 %57, 0
br i1 %58, label %71, label %59
59: ; preds = %53
%60 = load i8*, i8** %55
%61 = call i64 @strcmp(i8* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
%62 = icmp eq i64 %61, 0
br i1 %62, label %71, label %63
63: ; preds = %59
%64 = load i8*, i8** %55
%65 = call i64 @strcmp(i8* %64, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%66 = icmp eq i64 %65, 0
br i1 %66, label %71, label %67
67: ; preds = %63
%68 = load i8*, i8** %55
%69 = call i64 @strcmp(i8* %68, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %74
71: ; preds = %53, %59, %63, %67, %92
%72 = call %struct.dirent* @readdir(i32* %45)
%73 = icmp eq %struct.dirent* %72, null
br i1 %73, label %94, label %53
74: ; preds = %67
%75 = load i8*, i8** %55
%76 = call i32 @strcpy(i8* %51, i8* %75)
%77 = call i8* @strtok(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%78 = call i32 @strcpy(i8* %52, i8* %20)
%79 = load i8*, i8** %55
%80 = call i32 @strcat(i8* %52, i8* %79)
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.18, i64 0, i64 0))
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.11, i64 0, i64 0), i8* %52)
%83 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.18, i64 0, i64 0))
%84 = call i32 @putchar(i32 124)
%85 = call i64 (...) @fork()
%86 = icmp eq i64 %85, 0
br i1 %86, label %87, label %92
87: ; preds = %74
%88 = call i32 (i8*, i8*, i8*, i8*, i8*, ...) @execlp(i8* %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %52, i8* %77, i8* %40, i8* %29, i8* null)
%89 = load i32, i32* @stderr
%90 = call i32 @fprintf(i32 %89, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.13, i64 0, i64 0))
%91 = call i32 @exit(i32 3)
unreachable
92: ; preds = %74
%93 = call i32 @wait(i32* null)
br label %71
94: ; preds = %71, %47
%95 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.18, i64 0, i64 0))
%96 = call i32 @closedir(i32* %45)
%97 = call i64 (...) @fork()
%98 = icmp eq i64 %97, 0
br i1 %98, label %103, label %108
99: ; preds = %17
%100 = load i32, i32* @stderr
%101 = call i32 @fprintf(i32 %100, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0))
%102 = call i32 @exit(i32 1)
unreachable
103: ; preds = %94
%104 = call i32 (i8*, i8*, i8*, i8*, i8*, ...) @execlp(i8* %34, i8* %34, i8* %20, i8* %37, i8* null)
%105 = load i32, i32* @stderr
%106 = call i32 @fprintf(i32 %105, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.15, i64 0, i64 0))
%107 = call i32 @exit(i32 3)
unreachable
108: ; preds = %94
%109 = call i32 @wait(i32* null)
%110 = call i32* @opendir(i8* %37)
%111 = icmp eq i32* %110, null
br i1 %111, label %130, label %112
112: ; preds = %108
%113 = call %struct.dirent* @readdir(i32* %110)
%114 = icmp eq %struct.dirent* %113, null
br i1 %114, label %126, label %115
115: ; preds = %112
%116 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
br label %117
117: ; preds = %115, %117
%118 = phi %struct.dirent* [ %113, %115 ], [ %124, %117 ]
%119 = call i32 @strcpy(i8* %116, i8* %37)
%120 = getelementptr inbounds %struct.dirent, %struct.dirent* %118, i64 0, i32 0
%121 = load i8*, i8** %120
%122 = call i32 @strcat(i8* %116, i8* %121)
%123 = call i32 @remove(i8* %116)
%124 = call %struct.dirent* @readdir(i32* %110)
%125 = icmp eq %struct.dirent* %124, null
br i1 %125, label %126, label %117
126: ; preds = %117, %112
%127 = call i32 @closedir(i32* %110)
%128 = call i32 @rmdir(i8* %37)
%129 = call i32 @exit(i32 0)
unreachable
130: ; preds = %108
%131 = load i32, i32* @stderr
%132 = call i32 @fprintf(i32 %131, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0))
%133 = call i32 @exit(i32 1)
unreachable
}