void actionPids(char *dir) {
  char **pids = (char **)malloc(sizeof(char *) * 32768);
  int pidsCount = 0;
  for (int i = 0; i < 32768; i++) {
    pids[i] = (char *)malloc(sizeof(char) * (5 + 1));
  }
  getPidFolders(dir, pids, &pidsCount);
  insertionSort(pids, pidsCount);
  for (int i = 0; i < pidsCount; i++) {
    printf("%s\n", pids[i]);
  }
  for (int i = 0; i < pidsCount; i++) {
    free(pids[i]);
  }
  free(pids);
}


x86 assembly (clang, -O0):
<actionPids>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x40000,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x8000,-0x18(%rbp)
jge    11ac <actionPids+0x5c>
mov    $0x6,%edi
call   1060 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1178 <actionPids+0x28>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   1040 <getPidFolders@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x0,%al
call   1070 <insertionSort@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1208 <actionPids+0xb8>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11d4 <actionPids+0x84>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    123a <actionPids+0xea>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    120f <actionPids+0xbf>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<actionPids>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
mov    $0x40000,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
movl   $0x0,0xc(%rsp)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x6,%edi
call   1060 <malloc@plt>
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    $0x8000,%rbx
jne    1180 <actionPids+0x30>
lea    0xc(%rsp),%rdx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <getPidFolders@plt>
mov    0xc(%rsp),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1070 <insertionSort@plt>
cmpl   $0x0,0xc(%rsp)
jle    1207 <actionPids+0xb7>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15,%rbx,8),%rdi
call   1050 <puts@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11d0 <actionPids+0x80>
test   %eax,%eax
jle    1207 <actionPids+0xb7>
xor    %ebx,%ebx
nopl   (%rax)
mov    (%r15,%rbx,8),%rdi
call   1030 <free@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     11f0 <actionPids+0xa0>
mov    %r15,%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
define void @actionPids(i8* %0) {
%2 = alloca i8*
%3 = alloca i8**
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
%8 = call i8* @malloc(i64 262144)
%9 = bitcast i8* %8 to i8**
store i8** %9, i8*** %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %10
10: ; preds = %19, %1
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 32768
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = call i8* @malloc(i64 6)
%15 = load i8**, i8*** %3
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
store i8* %14, i8** %18
br label %19
19: ; preds = %13
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
br label %10
22: ; preds = %10
%23 = load i8*, i8** %2
%24 = load i8**, i8*** %3
%25 = call i32 (i8*, i8**, i32*, ...) bitcast (i32 (...)* @getPidFolders to i32 (i8*, i8**, i32*, ...)*)(i8* %23, i8** %24, i32* %4)
%26 = load i8**, i8*** %3
%27 = load i32, i32* %4
%28 = call i32 (i8**, i32, ...) bitcast (i32 (...)* @insertionSort to i32 (i8**, i32, ...)*)(i8** %26, i32 %27)
store i32 0, i32* %6
br label %29
29: ; preds = %40, %22
%30 = load i32, i32* %6
%31 = load i32, i32* %4
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %43
33: ; preds = %29
%34 = load i8**, i8*** %3
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %34, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %38)
br label %40
40: ; preds = %33
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
br label %29
43: ; preds = %29
store i32 0, i32* %7
br label %44
44: ; preds = %54, %43
%45 = load i32, i32* %7
%46 = load i32, i32* %4
%47 = icmp slt i32 %45, %46
br i1 %47, label %48, label %57
48: ; preds = %44
%49 = load i8**, i8*** %3
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8*, i8** %49, i64 %51
%53 = load i8*, i8** %52
br label %54
54: ; preds = %48
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 1
store i32 %56, i32* %7
br label %44
57: ; preds = %44
%58 = load i8**, i8*** %3
%59 = bitcast i8** %58 to i8*
ret void
}

LLVM IR (-O2):
define void @actionPids(i8* %0) {
%2 = alloca i32
%3 = tail call dereferenceable_or_null(262144) i8* @malloc(i64 262144)
%4 = bitcast i8* %3 to i8**
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
br label %12
6: ; preds = %12
%7 = call i32 (i8*, i8**, i32*, ...) bitcast (i32 (...)* @getPidFolders to i32 (i8*, i8**, i32*, ...)*)(i8* %0, i8** %4, i32* %2)
%8 = load i32, i32* %2
%9 = call i32 (i8**, i32, ...) bitcast (i32 (...)* @insertionSort to i32 (i8**, i32, ...)*)(i8** %4, i32 %8)
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %20, label %29
12: ; preds = %1, %12
%13 = phi i64 [ 0, %1 ], [ %16, %12 ]
%14 = tail call dereferenceable_or_null(6) i8* @malloc(i64 6)
%15 = getelementptr inbounds i8*, i8** %4, i64 %13
store i8* %14, i8** %15
%16 = add nuw nsw i64 %13, 1
%17 = icmp eq i64 %16, 32768
br i1 %17, label %6, label %12
18: ; preds = %20
%19 = icmp sgt i32 %26, 0
br i1 %19, label %30, label %29
20: ; preds = %6, %20
%21 = phi i64 [ %25, %20 ], [ 0, %6 ]
%22 = getelementptr inbounds i8*, i8** %4, i64 %21
%23 = load i8*, i8** %22
%24 = call i32 @puts(i8* dereferenceable(1) %23)
%25 = add nuw nsw i64 %21, 1
%26 = load i32, i32* %2
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %20, label %18
29: ; preds = %30, %6, %18
ret void
30: ; preds = %18, %30
%31 = phi i64 [ %34, %30 ], [ 0, %18 ]
%32 = getelementptr inbounds i8*, i8** %4, i64 %31
%33 = load i8*, i8** %32
%34 = add nuw nsw i64 %31, 1
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = icmp slt i64 %34, %36
br i1 %37, label %30, label %29
}