void FS_Dir_f(void) {
  char *path = ((void *)0);
  char findname[1024];
  char wildcard[1024] = "*.*";
  char **dirnames;
  int ndirs;
  if (Cmd_Argc() != 1) {
    com_strlcpy(wildcard, Cmd_Argv(1), sizeof(wildcard));
  }
  while ((path = FS_NextPath(path)) != ((void *)0)) {
    char *tmp = findname;
    com_snprintf(findname, sizeof(findname), "%s%c%s", path, '/', wildcard);
    while (*tmp != 0) {
      if (*tmp == '\\')
        *tmp = '/';
      tmp++;
    }
    Com_Printf("Directory of %s\n", findname);
    Com_Printf("----\n");
    if ((dirnames = FS_ListFiles(findname, &ndirs, 0, 0)) != 0) {
      int i;
      for (i = 0; i < ndirs - 1; i++) {
        if (strrchr(dirnames[i], '/'))
          Com_Printf("%s\n", strrchr(dirnames[i], '/') + 1);
        else
          Com_Printf("%s\n", dirnames[i]);
        {
          Memory_free((dirnames[i]));
          ((dirnames[i])) = ((void *)0);
        };
      }
      {
        Memory_free((dirnames));
        ((dirnames)) = ((void *)0);
      };
    }
    Com_Printf("\n");
  };
}


x86 assembly (clang, -O0):
<FS_Dir_f>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
movq   $0x0,-0x8(%rbp)
lea    -0x810(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
movb   $0x2a,-0x810(%rbp)
movb   $0x2e,-0x80f(%rbp)
movb   $0x2a,-0x80e(%rbp)
mov    $0x0,%al
call   1030 <Cmd_Argc@plt>
cmp    $0x1,%eax
je     121a <FS_Dir_f+0x7a>
lea    -0x810(%rbp),%rax
mov    %rax,-0x838(%rbp)
mov    $0x1,%edi
mov    $0x0,%al
call   10c0 <Cmd_Argv@plt>
mov    -0x838(%rbp),%rdi
mov    %eax,%esi
mov    $0x400,%edx
mov    $0x0,%al
call   10b0 <com_strlcpy@plt>
jmp    121f <FS_Dir_f+0x7f>
mov    -0x8(%rbp),%rdi
mov    $0x0,%al
call   1080 <FS_NextPath@plt>
cltq
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
je     1415 <FS_Dir_f+0x275>
lea    -0x410(%rbp),%rax
mov    %rax,-0x828(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x8(%rbp),%rcx
lea    -0x810(%rbp),%r9
mov    $0x400,%esi
lea    0xd9a(%rip),%rdx
mov    $0x2f,%r8d
mov    $0x0,%al
call   1070 <com_snprintf@plt>
mov    -0x828(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12ba <FS_Dir_f+0x11a>
mov    -0x828(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    12a3 <FS_Dir_f+0x103>
mov    -0x828(%rbp),%rax
movb   $0x2f,(%rax)
mov    -0x828(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x828(%rbp)
jmp    1273 <FS_Dir_f+0xd3>
lea    -0x410(%rbp),%rsi
lea    0xd3f(%rip),%rdi
mov    $0x0,%al
call   10a0 <Com_Printf@plt>
lea    0xd42(%rip),%rdi
mov    $0x0,%al
call   10a0 <Com_Printf@plt>
lea    -0x410(%rbp),%rdi
lea    -0x81c(%rbp),%rsi
xor    %ecx,%ecx
mov    %ecx,%edx
mov    $0x0,%al
call   1040 <FS_ListFiles@plt>
cltq
mov    %rax,-0x818(%rbp)
cmp    $0x0,%rax
je     1402 <FS_Dir_f+0x262>
movl   $0x0,-0x82c(%rbp)
mov    -0x82c(%rbp),%eax
mov    -0x81c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    13e9 <FS_Dir_f+0x249>
mov    -0x818(%rbp),%rax
movslq -0x82c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
cmp    $0x0,%rax
je     1386 <FS_Dir_f+0x1e6>
mov    -0x818(%rbp),%rax
movslq -0x82c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
mov    %rax,%rsi
add    $0x1,%rsi
lea    0xc9a(%rip),%rdi
mov    $0x0,%al
call   10a0 <Com_Printf@plt>
jmp    13a6 <FS_Dir_f+0x206>
mov    -0x818(%rbp),%rax
movslq -0x82c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xc75(%rip),%rdi
mov    $0x0,%al
call   10a0 <Com_Printf@plt>
mov    -0x818(%rbp),%rax
movslq -0x82c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x0,%al
call   1090 <Memory_free@plt>
mov    -0x818(%rbp),%rax
movslq -0x82c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x82c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x82c(%rbp)
jmp    1313 <FS_Dir_f+0x173>
mov    -0x818(%rbp),%rdi
mov    $0x0,%al
call   1090 <Memory_free@plt>
movq   $0x0,-0x818(%rbp)
lea    0xc13(%rip),%rdi
mov    $0x0,%al
call   10a0 <Com_Printf@plt>
jmp    121f <FS_Dir_f+0x7f>
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FS_Dir_f>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x818,%rsp
lea    0x10(%rsp),%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1060 <memset@plt>
movw   $0x2e2a,0x10(%rsp)
movb   $0x2a,0x12(%rsp)
xor    %eax,%eax
call   1030 <Cmd_Argc@plt>
cmp    $0x1,%eax
je     11f9 <FS_Dir_f+0x59>
mov    $0x1,%edi
xor    %eax,%eax
call   10c0 <Cmd_Argv@plt>
lea    0x10(%rsp),%rdi
mov    $0x400,%edx
mov    %eax,%esi
xor    %eax,%eax
call   10b0 <com_strlcpy@plt>
xor    %edi,%edi
xor    %eax,%eax
call   1080 <FS_NextPath@plt>
test   %eax,%eax
je     133b <FS_Dir_f+0x19b>
lea    0x410(%rsp),%rbx
lea    0xdfb(%rip),%r15
jmp    124a <FS_Dir_f+0xaa>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rdi
xor    %eax,%eax
call   1090 <Memory_free@plt>
lea    0xdeb(%rip),%rdi
xor    %eax,%eax
call   10a0 <Com_Printf@plt>
mov    %r12,%rdi
xor    %eax,%eax
call   1080 <FS_NextPath@plt>
test   %eax,%eax
je     133b <FS_Dir_f+0x19b>
movslq %eax,%r12
mov    $0x400,%esi
mov    %rbx,%rdi
lea    0xda4(%rip),%rdx
mov    %r12,%rcx
mov    $0x2f,%r8d
lea    0x10(%rsp),%r9
xor    %eax,%eax
call   1070 <com_snprintf@plt>
mov    %rbx,%rax
jmp    1287 <FS_Dir_f+0xe7>
cs nopw 0x0(%rax,%rax,1)
movb   $0x2f,(%rax)
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0x5c,%cl
je     1280 <FS_Dir_f+0xe0>
test   %cl,%cl
jne    1283 <FS_Dir_f+0xe3>
lea    0xd6d(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10a0 <Com_Printf@plt>
lea    0xd6d(%rip),%rdi
xor    %eax,%eax
call   10a0 <Com_Printf@plt>
mov    %rbx,%rdi
lea    0xc(%rsp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <FS_ListFiles@plt>
test   %eax,%eax
je     122a <FS_Dir_f+0x8a>
movslq %eax,%r13
cmpl   $0x2,0xc(%rsp)
jl     1220 <FS_Dir_f+0x80>
xor    %r14d,%r14d
jmp    1318 <FS_Dir_f+0x178>
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   10a0 <Com_Printf@plt>
mov    0x0(%r13,%r14,8),%rdi
xor    %eax,%eax
call   1090 <Memory_free@plt>
movq   $0x0,0x0(%r13,%r14,8)
add    $0x1,%r14
movslq 0xc(%rsp),%rax
add    $0xffffffffffffffff,%rax
cmp    %rax,%r14
jge    1220 <FS_Dir_f+0x80>
mov    0x0(%r13,%r14,8),%rbp
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     12e0 <FS_Dir_f+0x140>
add    $0x1,%rax
mov    %r15,%rdi
mov    %rax,%rsi
jmp    12e6 <FS_Dir_f+0x146>
add    $0x818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s%c%s\00"
@.str.1 = [17 x i8] c"Directory of %s\0A\00"
@.str.2 = [6 x i8] c"----\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @FS_Dir_f() {
%1 = alloca i8*
%2 = alloca [1024 x i8]
%3 = alloca [1024 x i8]
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i8* null, i8** %1
%8 = bitcast [1024 x i8]* %3 to i8*
%9 = bitcast i8* %8 to [1024 x i8]*
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i32 0, i32 0
store i8 42, i8* %10
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i32 0, i32 1
store i8 46, i8* %11
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i32 0, i32 2
store i8 42, i8* %12
%13 = call i32 (...) @Cmd_Argc()
%14 = icmp ne i32 %13, 1
br i1 %14, label %15, label %19
15: ; preds = %0
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%17 = call i32 (i32, ...) bitcast (i32 (...)* @Cmd_Argv to i32 (i32, ...)*)(i32 1)
%18 = call i32 (i8*, i32, i64, ...) bitcast (i32 (...)* @com_strlcpy to i32 (i8*, i32, i64, ...)*)(i8* %16, i32 %17, i64 1024)
br label %19
19: ; preds = %15, %0
br label %20
20: ; preds = %103, %19
%21 = load i8*, i8** %1
%22 = call i32 (i8*, ...) bitcast (i32 (...)* @FS_NextPath to i32 (i8*, ...)*)(i8* %21)
%23 = sext i32 %22 to i64
%24 = inttoptr i64 %23 to i8*
store i8* %24, i8** %1
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %105
26: ; preds = %20
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
store i8* %27, i8** %6
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%29 = load i8*, i8** %1
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%31 = call i32 (i8*, i64, i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @com_snprintf to i32 (i8*, i64, i8*, i8*, i32, i8*, ...)*)(i8* %28, i64 1024, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %29, i32 47, i8* %30)
br label %32
32: ; preds = %44, %26
%33 = load i8*, i8** %6
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %47
37: ; preds = %32
%38 = load i8*, i8** %6
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 92
br i1 %41, label %42, label %44
42: ; preds = %37
%43 = load i8*, i8** %6
store i8 47, i8* %43
br label %44
44: ; preds = %42, %37
%45 = load i8*, i8** %6
%46 = getelementptr inbounds i8, i8* %45, i32 1
store i8* %46, i8** %6
br label %32
47: ; preds = %32
%48 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%49 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @Com_Printf to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %48)
%50 = call i32 (i8*, ...) bitcast (i32 (...)* @Com_Printf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%52 = call i32 (i8*, i32*, i32, i32, ...) bitcast (i32 (...)* @FS_ListFiles to i32 (i8*, i32*, i32, i32, ...)*)(i8* %51, i32* %5, i32 0, i32 0)
%53 = sext i32 %52 to i64
%54 = inttoptr i64 %53 to i8**
store i8** %54, i8*** %4
%55 = icmp ne i8** %54, null
br i1 %55, label %56, label %103
56: ; preds = %47
store i32 0, i32* %7
br label %57
57: ; preds = %97, %56
%58 = load i32, i32* %7
%59 = load i32, i32* %5
%60 = sub nsw i32 %59, 1
%61 = icmp slt i32 %58, %60
br i1 %61, label %62, label %100
62: ; preds = %57
%63 = load i8**, i8*** %4
%64 = load i32, i32* %7
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %63, i64 %65
%67 = load i8*, i8** %66
%68 = call i8* @strrchr(i8* %67, i32 47)
%69 = icmp ne i8* %68, null
br i1 %69, label %70, label %79
70: ; preds = %62
%71 = load i8**, i8*** %4
%72 = load i32, i32* %7
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8*, i8** %71, i64 %73
%75 = load i8*, i8** %74
%76 = call i8* @strrchr(i8* %75, i32 47)
%77 = getelementptr inbounds i8, i8* %76, i64 1
%78 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @Com_Printf to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %77)
br label %86
79: ; preds = %62
%80 = load i8**, i8*** %4
%81 = load i32, i32* %7
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds i8*, i8** %80, i64 %82
%84 = load i8*, i8** %83
%85 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @Com_Printf to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %84)
br label %86
86: ; preds = %79, %70
%87 = load i8**, i8*** %4
%88 = load i32, i32* %7
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8*, i8** %87, i64 %89
%91 = load i8*, i8** %90
%92 = call i32 (i8*, ...) bitcast (i32 (...)* @Memory_free to i32 (i8*, ...)*)(i8* %91)
%93 = load i8**, i8*** %4
%94 = load i32, i32* %7
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i8*, i8** %93, i64 %95
store i8* null, i8** %96
br label %97
97: ; preds = %86
%98 = load i32, i32* %7
%99 = add nsw i32 %98, 1
store i32 %99, i32* %7
br label %57
100: ; preds = %57
%101 = load i8**, i8*** %4
%102 = call i32 (i8**, ...) bitcast (i32 (...)* @Memory_free to i32 (i8**, ...)*)(i8** %101)
store i8** null, i8*** %4
br label %103
103: ; preds = %100, %47
%104 = call i32 (i8*, ...) bitcast (i32 (...)* @Com_Printf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %20
105: ; preds = %20
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s%c%s\00"
@.str.1 = [17 x i8] c"Directory of %s\0A\00"
@.str.2 = [6 x i8] c"----\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
define void @FS_Dir_f() {
%1 = alloca [1024 x i8]
%2 = alloca [1024 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
store i8 42, i8* %5
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 1
store i8 46, i8* %6
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 2
store i8 42, i8* %7
%8 = bitcast i32* %3 to i8*
%9 = tail call i32 (...) @Cmd_Argc()
%10 = icmp eq i32 %9, 1
br i1 %10, label %14, label %11
11: ; preds = %0
%12 = tail call i32 (i32, ...) bitcast (i32 (...)* @Cmd_Argv to i32 (i32, ...)*)(i32 1)
%13 = call i32 (i8*, i32, i64, ...) bitcast (i32 (...)* @com_strlcpy to i32 (i8*, i32, i64, ...)*)(i8* %5, i32 %12, i64 1024)
br label %14
14: ; preds = %11, %0
%15 = call i32 (i8*, ...) bitcast (i32 (...)* @FS_NextPath to i32 (i8*, ...)*)(i8* null)
%16 = icmp eq i32 %15, 0
br i1 %16, label %63, label %17
17: ; preds = %14, %59
%18 = phi i32 [ %61, %59 ], [ %15, %14 ]
%19 = sext i32 %18 to i64
%20 = inttoptr i64 %19 to i8*
%21 = call i32 (i8*, i64, i8*, i8*, i32, i8*, ...) bitcast (i32 (...)* @com_snprintf to i32 (i8*, i64, i8*, i8*, i32, i8*, ...)*)(i8* %4, i64 1024, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %20, i32 47, i8* %5)
br label %22
22: ; preds = %26, %17
%23 = phi i8* [ %4, %17 ], [ %27, %26 ]
%24 = load i8, i8* %23
switch i8 %24, label %26 [
i8 0, label %28
i8 92, label %25
]
25: ; preds = %22
store i8 47, i8* %23
br label %26
26: ; preds = %22, %25
%27 = getelementptr inbounds i8, i8* %23, i64 1
br label %22
28: ; preds = %22
%29 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @Com_Printf to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%30 = call i32 (i8*, ...) bitcast (i32 (...)* @Com_Printf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%31 = call i32 (i8*, i32*, i32, i32, ...) bitcast (i32 (...)* @FS_ListFiles to i32 (i8*, i32*, i32, i32, ...)*)(i8* %4, i32* %3, i32 0, i32 0)
%32 = sext i32 %31 to i64
%33 = inttoptr i64 %32 to i8**
%34 = icmp eq i32 %31, 0
br i1 %34, label %59, label %35
35: ; preds = %28
%36 = load i32, i32* %3
%37 = icmp sgt i32 %36, 1
br i1 %37, label %38, label %57
38: ; preds = %35, %49
%39 = phi i64 [ %52, %49 ], [ 0, %35 ]
%40 = getelementptr inbounds i8*, i8** %33, i64 %39
%41 = load i8*, i8** %40
%42 = call i8* @strrchr(i8* dereferenceable(1) %41, i32 47)
%43 = icmp eq i8* %42, null
br i1 %43, label %47, label %44
44: ; preds = %38
%45 = getelementptr inbounds i8, i8* %42, i64 1
%46 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @Com_Printf to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %45)
br label %49
47: ; preds = %38
%48 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @Com_Printf to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %41)
br label %49
49: ; preds = %47, %44
%50 = load i8*, i8** %40
%51 = call i32 (i8*, ...) bitcast (i32 (...)* @Memory_free to i32 (i8*, ...)*)(i8* %50)
store i8* null, i8** %40
%52 = add nuw nsw i64 %39, 1
%53 = load i32, i32* %3
%54 = add nsw i32 %53, -1
%55 = sext i32 %54 to i64
%56 = icmp slt i64 %52, %55
br i1 %56, label %38, label %57
57: ; preds = %49, %35
%58 = call i32 (i8**, ...) bitcast (i32 (...)* @Memory_free to i32 (i8**, ...)*)(i8** %33)
br label %59
59: ; preds = %57, %28
%60 = call i32 (i8*, ...) bitcast (i32 (...)* @Com_Printf to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%61 = call i32 (i8*, ...) bitcast (i32 (...)* @FS_NextPath to i32 (i8*, ...)*)(i8* %20)
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %17
63: ; preds = %59, %14
ret void
}