#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*/ FILE;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ execlp(char *, char *, char *, char *, char *, char *,
                          char *, char *, char *);
int /*<<< orphan*/ execv(char *, char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int *malloc(int);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
char *strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ waitpid(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc < 3) {
    perror("The number of args is wrong!\n");
    exit(0);
  }
  int pid = 0;
  int len = 0;
  char buf[10000] = {0};
  int max = atoi(argv[1]);
  int *maxptr = malloc(sizeof(int) * max);
  int i = 0;
  char *dirname = strcat(argv[2], "/");
  DIR *dir;
  FILE *fp;
  struct dirent *ptr;
  dir = opendir(argv[2]);
  fp = fopen("list.txt", "w+");
  while ((ptr = readdir(dir)) != NULL) {
    fprintf(fp, "%s\n", ptr->d_name);
  }
  closedir(dir);
  fclose(fp);
  fp = fopen("list.txt", "r");
  while (fgets(buf, 10000, fp) != NULL) {
    len = (int)strlen(buf) - 1;
    if ('\n' == buf[len]) {
      buf[len] = '\0';
    }
    if ((strcmp(buf, ".") != 0) && (strcmp(buf, "..") != 0)) {
      pid = fork();
      if (0 == pid) {
        char *ars[] = {"sort", "-n -k 1 -u -o", strcat(dirname, buf), dirname,
                       (char *)NULL};
        execv("sort", ars);
        printf("error2\n");
        return 1;
      } else {
        maxptr[i++] = pid;
      }
      if (i >= max) {
        for (int j = 0; j != max; ++j) {
          waitpid(maxptr[j], NULL, 0);
        }
      }
    }
  }
  fclose(fp);
  execlp("sort", "-n", "-k", "1", "-u", "-o", "list.txt", "list.txt",
         (char *)NULL);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x27b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1276 <main+0x36>
lea    0xd96(%rip),%rdi
call   1100 <perror@plt>
xor    %edi,%edi
call   1130 <exit@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    -0x2730(%rbp),%rdi
xor    %esi,%esi
mov    $0x2710,%edx
call   1070 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1110 <atoi@plt>
mov    %eax,-0x2734(%rbp)
movslq -0x2734(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x2740(%rbp)
movl   $0x0,-0x2744(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd42(%rip),%rsi
call   1120 <strcat@plt>
mov    %rax,-0x2750(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x2758(%rbp)
lea    0xd1d(%rip),%rdi
lea    0xd1f(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x2760(%rbp)
mov    -0x2758(%rbp),%rdi
call   10c0 <readdir@plt>
mov    %rax,-0x2768(%rbp)
cmp    $0x0,%rax
je     1355 <main+0x115>
mov    -0x2760(%rbp),%rdi
mov    -0x2768(%rbp),%rax
mov    (%rax),%rdx
lea    0xce1(%rip),%rsi
call   10b0 <fprintf@plt>
jmp    1316 <main+0xd6>
mov    -0x2758(%rbp),%rdi
call   1080 <closedir@plt>
mov    -0x2760(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xcac(%rip),%rdi
lea    0xcb5(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x2760(%rbp)
lea    -0x2730(%rbp),%rdi
mov    -0x2760(%rbp),%rdx
mov    $0x2710,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     1537 <main+0x2f7>
lea    -0x2730(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
movslq -0x18(%rbp),%rax
movsbl -0x2730(%rbp,%rax,1),%ecx
ff
mov    $0xa,%eax
cmp    %ecx,%eax
jne    13e0 <main+0x1a0>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x2730(%rbp,%rax,1)
lea    -0x2730(%rbp),%rdi
lea    0xc45(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     1532 <main+0x2f2>
lea    -0x2730(%rbp),%rdi
lea    0xc27(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     1532 <main+0x2f2>
mov    $0x0,%al
call   1160 <fork@plt>
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmp    -0x14(%rbp),%eax
jne    14a9 <main+0x269>
lea    0xbff(%rip),%rax
mov    %rax,-0x2790(%rbp)
lea    0xbf6(%rip),%rax
mov    %rax,-0x2788(%rbp)
mov    -0x2750(%rbp),%rdi
lea    -0x2730(%rbp),%rsi
call   1120 <strcat@plt>
mov    %rax,-0x2780(%rbp)
mov    -0x2750(%rbp),%rax
mov    %rax,-0x2778(%rbp)
movq   $0x0,-0x2770(%rbp)
lea    -0x2790(%rbp),%rsi
lea    0xba9(%rip),%rdi
call   1150 <execv@plt>
lea    0xbb0(%rip),%rdi
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1595 <main+0x355>
mov    -0x14(%rbp),%edx
mov    -0x2740(%rbp),%rax
mov    -0x2744(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x2744(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x2744(%rbp),%eax
cmp    -0x2734(%rbp),%eax
jl     152d <main+0x2ed>
movl   $0x0,-0x2794(%rbp)
mov    -0x2794(%rbp),%eax
cmp    -0x2734(%rbp),%eax
je     1528 <main+0x2e8>
mov    -0x2740(%rbp),%rax
movslq -0x2794(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10e0 <waitpid@plt>
mov    -0x2794(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2794(%rbp)
jmp    14e6 <main+0x2a6>
jmp    152d <main+0x2ed>
jmp    1532 <main+0x2f2>
jmp    1387 <main+0x147>
mov    -0x2760(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xaeb(%rip),%rdi
lea    0xaff(%rip),%rsi
lea    0xafb(%rip),%rdx
lea    0xaf7(%rip),%rcx
lea    0xaf2(%rip),%r8
lea    0xad8(%rip),%r9
lea    0xaac(%rip),%rax
xor    %r10d,%r10d
mov    %rax,(%rsp)
mov    %rax,0x8(%rsp)
movq   $0x0,0x10(%rsp)
call   1140 <execlp@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x27b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2758,%rsp
cmp    $0x2,%edi
jle    14aa <main+0x26a>
mov    %rsi,%r14
lea    0x40(%rsp),%rdi
mov    $0x2710,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    0x8(%r14),%rdi
call   1110 <atoi@plt>
mov    %rax,(%rsp)
lea    0x0(,%rax,4),%edi
call   10d0 <malloc@plt>
mov    %rax,%rbx
mov    0x10(%r14),%rbp
mov    %rbp,%rdi
call   1060 <strlen@plt>
mov    %rbp,0x8(%rsp)
movw   $0x2f,0x0(%rbp,%rax,1)
mov    0x10(%r14),%rdi
call   1050 <opendir@plt>
mov    %rax,%r14
lea    0xd69(%rip),%rdi
lea    0xd6b(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,%rbp
mov    %r14,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     12fb <main+0xbb>
lea    0xd52(%rip),%r12
nopl   0x0(%rax,%rax,1)
mov    (%rax),%rdx
mov    %rbp,%rdi
mov    %r12,%rsi
call   10b0 <fprintf@plt>
mov    %r14,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
jne    12e0 <main+0xa0>
mov    %r14,%rdi
call   1080 <closedir@plt>
mov    %rbp,%rdi
call   1040 <fclose@plt>
lea    0xd0c(%rip),%rdi
lea    0xd15(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,%r13
lea    0x40(%rsp),%rdi
mov    $0x2710,%esi
mov    %rax,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
mov    (%rsp),%r12
je     13ef <main+0x1af>
mov    %r12d,%r14d
lea    0x40(%rsp),%rbp
xor    %r15d,%r15d
jmp    1369 <main+0x129>
nopl   (%rax)
mov    %rbp,%rdi
mov    $0x2710,%esi
mov    %r13,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     13ef <main+0x1af>
mov    %rbp,%rdi
call   1060 <strlen@plt>
add    $0xffffffff,%eax
cltq
cmpb   $0xa,0x40(%rsp,%rax,1)
jne    1382 <main+0x142>
movb   $0x0,0x40(%rsp,%rax,1)
mov    %rbp,%rdi
lea    0xca5(%rip),%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1350 <main+0x110>
mov    %rbp,%rdi
lea    0xc90(%rip),%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1350 <main+0x110>
xor    %eax,%eax
call   1160 <fork@plt>
test   %eax,%eax
je     144d <main+0x20d>
movslq %r15d,%rcx
add    $0x1,%r15d
mov    %eax,(%rbx,%rcx,4)
cmp    %r12d,%r15d
jl     1350 <main+0x110>
test   %r12d,%r12d
je     1350 <main+0x110>
xor    %r12d,%r12d
mov    (%rbx,%r12,4),%edi
xor    %esi,%esi
xor    %edx,%edx
call   10e0 <waitpid@plt>
add    $0x1,%r12
cmp    %r12,%r14
jne    13d0 <main+0x190>
mov    (%rsp),%r12
jmp    1350 <main+0x110>
mov    %r13,%rdi
call   1040 <fclose@plt>
sub    $0x8,%rsp
lea    0xc31(%rip),%rdi
lea    0xc3d(%rip),%rsi
lea    0xc39(%rip),%rdx
lea    0xc35(%rip),%rcx
lea    0xc30(%rip),%r8
lea    0xc1e(%rip),%r9
push   $0x0
lea    0xbf0(%rip),%rax
push   %rax
push   %rax
call   1140 <execlp@plt>
add    $0x20,%rsp
xor    %eax,%eax
add    $0x2758,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbdf(%rip),%rbx
mov    %rbx,0x10(%rsp)
lea    0xbd8(%rip),%rax
mov    %rax,0x18(%rsp)
lea    0x40(%rsp),%rsi
mov    0x8(%rsp),%rbp
mov    %rbp,%rdi
call   1120 <strcat@plt>
mov    %rbp,0x20(%rsp)
mov    %rbp,0x28(%rsp)
movq   $0x0,0x30(%rsp)
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1150 <execv@plt>
lea    0xbb3(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    143b <main+0x1fb>
lea    0xb4f(%rip),%rdi
call   1100 <perror@plt>
xor    %edi,%edi
call   1130 <exit@plt>

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [30 x i8] c"The number of args is wrong!\0A\00"
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [9 x i8] c"list.txt\00"
@.str.3 = [3 x i8] c"w+\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [2 x i8] c".\00"
@.str.7 = [3 x i8] c"..\00"
@.str.8 = [5 x i8] c"sort\00"
@.str.9 = [14 x i8] c"-n -k 1 -u -o\00"
@.str.10 = [8 x i8] c"error2\0A\00"
@.str.11 = [3 x i8] c"-n\00"
@.str.12 = [3 x i8] c"-k\00"
@.str.13 = [2 x i8] c"1\00"
@.str.14 = [3 x i8] c"-u\00"
@.str.15 = [3 x i8] c"-o\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [10000 x i8]
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca %struct.dirent*
%16 = alloca [5 x i8*]
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %23
20: ; preds = %2
%21 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%22 = call i32 @exit(i32 0)
unreachable
23: ; preds = %2
store i32 0, i32* %6
store i32 0, i32* %7
%24 = bitcast [10000 x i8]* %8 to i8*
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %9
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = mul i64 4, %30
%32 = trunc i64 %31 to i32
%33 = call i32* @malloc(i32 %32)
store i32* %33, i32** %10
store i32 0, i32* %11
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 2
%36 = load i8*, i8** %35
%37 = call i8* @strcat(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %37, i8** %12
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32* @opendir(i8* %40)
store i32* %41, i32** %13
%42 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %42, i32** %14
br label %43
43: ; preds = %47, %23
%44 = load i32*, i32** %13
%45 = call %struct.dirent* @readdir(i32* %44)
store %struct.dirent* %45, %struct.dirent** %15
%46 = icmp ne %struct.dirent* %45, null
br i1 %46, label %47, label %53
47: ; preds = %43
%48 = load i32*, i32** %14
%49 = load %struct.dirent*, %struct.dirent** %15
%50 = getelementptr inbounds %struct.dirent, %struct.dirent* %49, i32 0, i32 0
%51 = load i8*, i8** %50
%52 = call i32 @fprintf(i32* %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %51)
br label %43
53: ; preds = %43
%54 = load i32*, i32** %13
%55 = call i32 @closedir(i32* %54)
%56 = load i32*, i32** %14
%57 = call i32 @fclose(i32* %56)
%58 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %58, i32** %14
br label %59
59: ; preds = %132, %53
%60 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%61 = load i32*, i32** %14
%62 = call i32* @fgets(i8* %60, i32 10000, i32* %61)
%63 = icmp ne i32* %62, null
br i1 %63, label %64, label %133
64: ; preds = %59
%65 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%66 = call i64 @strlen(i8* %65)
%67 = trunc i64 %66 to i32
%68 = sub nsw i32 %67, 1
store i32 %68, i32* %7
%69 = load i32, i32* %7
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 %70
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp eq i32 10, %73
br i1 %74, label %75, label %79
75: ; preds = %64
%76 = load i32, i32* %7
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 %77
store i8 0, i8* %78
br label %79
79: ; preds = %75, %64
%80 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%81 = call i64 @strcmp(i8* %80, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%82 = icmp ne i64 %81, 0
br i1 %82, label %83, label %132
83: ; preds = %79
%84 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%85 = call i64 @strcmp(i8* %84, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%86 = icmp ne i64 %85, 0
br i1 %86, label %87, label %132
87: ; preds = %83
%88 = call i32 (...) @fork()
store i32 %88, i32* %6
%89 = load i32, i32* %6
%90 = icmp eq i32 0, %89
br i1 %90, label %91, label %104
91: ; preds = %87
%92 = getelementptr inbounds [5 x i8*], [5 x i8*]* %16, i64 0, i64 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8** %92
%93 = getelementptr inbounds i8*, i8** %92, i64 1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8** %93
%94 = getelementptr inbounds i8*, i8** %93, i64 1
%95 = load i8*, i8** %12
%96 = getelementptr inbounds [10000 x i8], [10000 x i8]* %8, i64 0, i64 0
%97 = call i8* @strcat(i8* %95, i8* %96)
store i8* %97, i8** %94
%98 = getelementptr inbounds i8*, i8** %94, i64 1
%99 = load i8*, i8** %12
store i8* %99, i8** %98
%100 = getelementptr inbounds i8*, i8** %98, i64 1
store i8* null, i8** %100
%101 = getelementptr inbounds [5 x i8*], [5 x i8*]* %16, i64 0, i64 0
%102 = call i32 @execv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8** %101)
%103 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %3
br label %137
104: ; preds = %87
%105 = load i32, i32* %6
%106 = load i32*, i32** %10
%107 = load i32, i32* %11
%108 = add nsw i32 %107, 1
store i32 %108, i32* %11
%109 = sext i32 %107 to i64
%110 = getelementptr inbounds i32, i32* %106, i64 %109
store i32 %105, i32* %110
br label %111
111: ; preds = %104
%112 = load i32, i32* %11
%113 = load i32, i32* %9
%114 = icmp sge i32 %112, %113
br i1 %114, label %115, label %131
115: ; preds = %111
store i32 0, i32* %17
br label %116
116: ; preds = %127, %115
%117 = load i32, i32* %17
%118 = load i32, i32* %9
%119 = icmp ne i32 %117, %118
br i1 %119, label %120, label %130
120: ; preds = %116
%121 = load i32*, i32** %10
%122 = load i32, i32* %17
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i32, i32* %121, i64 %123
%125 = load i32, i32* %124
%126 = call i32 @waitpid(i32 %125, i32* null, i32 0)
br label %127
127: ; preds = %120
%128 = load i32, i32* %17
%129 = add nsw i32 %128, 1
store i32 %129, i32* %17
br label %116
130: ; preds = %116
br label %131
131: ; preds = %130, %111
br label %132
132: ; preds = %131, %83, %79
br label %59
133: ; preds = %59
%134 = load i32*, i32** %14
%135 = call i32 @fclose(i32* %134)
%136 = call i32 @execlp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* null)
store i32 0, i32* %3
br label %137
137: ; preds = %133, %91
%138 = load i32, i32* %3
ret i32 %138
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [30 x i8] c"The number of args is wrong!\0A\00"
@.str.2 = [9 x i8] c"list.txt\00"
@.str.3 = [3 x i8] c"w+\00"
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [2 x i8] c".\00"
@.str.7 = [3 x i8] c"..\00"
@.str.8 = [5 x i8] c"sort\00"
@.str.9 = [14 x i8] c"-n -k 1 -u -o\00"
@.str.11 = [3 x i8] c"-n\00"
@.str.12 = [3 x i8] c"-k\00"
@.str.13 = [2 x i8] c"1\00"
@.str.14 = [3 x i8] c"-u\00"
@.str.15 = [3 x i8] c"-o\00"
@str = [7 x i8] c"error2\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10000 x i8]
%4 = alloca [5 x i8*]
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = shl i32 %13, 2
%15 = tail call i32* @malloc(i32 %14)
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = tail call i64 @strlen(i8* dereferenceable(1) %17)
%19 = getelementptr i8, i8* %17, i64 %18
%20 = bitcast i8* %19 to i16*
store i16 47, i16* %20
%21 = load i8*, i8** %16
%22 = tail call i32* @opendir(i8* %21)
%23 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%24 = tail call %struct.dirent* @readdir(i32* %22)
%25 = icmp eq %struct.dirent* %24, null
br i1 %25, label %33, label %26
26: ; preds = %9, %26
%27 = phi %struct.dirent* [ %31, %26 ], [ %24, %9 ]
%28 = getelementptr inbounds %struct.dirent, %struct.dirent* %27, i64 0, i32 0
%29 = load i8*, i8** %28
%30 = tail call i32 @fprintf(i32* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %29)
%31 = tail call %struct.dirent* @readdir(i32* %22)
%32 = icmp eq %struct.dirent* %31, null
br i1 %32, label %33, label %26
33: ; preds = %26, %9
%34 = tail call i32 @closedir(i32* %22)
%35 = tail call i32 @fclose(i32* %23)
%36 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%37 = call i32* @fgets(i8* %10, i32 10000, i32* %36)
%38 = icmp eq i32* %37, null
br i1 %38, label %88, label %39
39: ; preds = %33
%40 = icmp eq i32 %13, 0
%41 = zext i32 %13 to i64
br label %42
42: ; preds = %39, %84
%43 = phi i32 [ 0, %39 ], [ %85, %84 ]
%44 = call i64 @strlen(i8* %10)
%45 = shl i64 %44, 32
%46 = add i64 %45, -4294967296
%47 = ashr exact i64 %46, 32
%48 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = icmp eq i8 %49, 10
br i1 %50, label %51, label %52
51: ; preds = %42
store i8 0, i8* %48
br label %52
52: ; preds = %51, %42
%53 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %84, label %55
55: ; preds = %52
%56 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %84, label %58
58: ; preds = %55
%59 = call i32 (...) @fork()
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %71
61: ; preds = %58
%62 = bitcast [5 x i8*]* %4 to i8*
%63 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8** %63
%64 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8** %64
%65 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 2
%66 = call i8* @strcat(i8* dereferenceable(1) %17, i8* %10)
store i8* %17, i8** %65
%67 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 3
store i8* %17, i8** %67
%68 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 4
store i8* null, i8** %68
%69 = call i32 @execv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8** %63)
%70 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %91
71: ; preds = %58
%72 = add nsw i32 %43, 1
%73 = sext i32 %43 to i64
%74 = getelementptr inbounds i32, i32* %15, i64 %73
store i32 %59, i32* %74
%75 = icmp slt i32 %72, %13
%76 = or i1 %75, %40
br i1 %76, label %84, label %77
77: ; preds = %71, %77
%78 = phi i64 [ %82, %77 ], [ 0, %71 ]
%79 = getelementptr inbounds i32, i32* %15, i64 %78
%80 = load i32, i32* %79
%81 = call i32 @waitpid(i32 %80, i32* null, i32 0)
%82 = add nuw nsw i64 %78, 1
%83 = icmp eq i64 %82, %41
br i1 %83, label %84, label %77
84: ; preds = %77, %71, %55, %52
%85 = phi i32 [ %72, %71 ], [ %43, %55 ], [ %43, %52 ], [ %72, %77 ]
%86 = call i32* @fgets(i8* %10, i32 10000, i32* %36)
%87 = icmp eq i32* %86, null
br i1 %87, label %88, label %42
88: ; preds = %84, %33
%89 = call i32 @fclose(i32* %36)
%90 = call i32 @execlp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.15, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* null)
br label %91
91: ; preds = %88, %61
%92 = phi i32 [ 1, %61 ], [ 0, %88 ]
ret i32 %92
}