int G_LayoutList(const char *map, char *list, int len) {
  char fileList[(256 / 2) * 5] = {""};
  char layouts[256] = {""};
  int numFiles, i, fileLen = 0, listLen;
  int count = 0;
  char *filePtr;
  Q_strcat(layouts, sizeof(layouts), "*BUILTIN* ");
  numFiles = trap_FS_GetFileList(va("layouts/%s", map), ".dat", fileList,
                                 sizeof(fileList));
  filePtr = fileList;
  for (i = 0; i < numFiles; i++, filePtr += fileLen + 1) {
    fileLen = strlen(filePtr);
    listLen = strlen(layouts);
    if (fileLen < 5)
      continue;
    if ((listLen + fileLen) >= sizeof(layouts))
      break;
    Q_strcat(layouts, sizeof(layouts), filePtr);
    listLen = strlen(layouts);
    layouts[listLen - 4] = ' ';
    layouts[listLen - 3] = '\0';
    count++;
  }
  if (count != numFiles) {
    G_Printf("^3"
             "WARNING: layout list was truncated to %d "
             "layouts, but %d layout files exist in layouts/%s/.\n",
             count, numFiles, map);
  }
  Q_strncpyz(list, layouts, len);
  return count + 1;
}


x86 assembly (clang, -O0):
<G_LayoutList>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3c0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0x2a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x280,%edx
call   1050 <memset@plt>
lea    -0x3a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1050 <memset@plt>
movl   $0x0,-0x3ac(%rbp)
movl   $0x0,-0x3b4(%rbp)
lea    -0x3a0(%rbp),%rdi
mov    $0x100,%esi
lea    0xe2d(%rip),%rdx
mov    $0x0,%al
call   1080 <Q_strcat@plt>
mov    -0x8(%rbp),%rsi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1070 <va@plt>
mov    %eax,%edi
lea    -0x2a0(%rbp),%rdx
lea    0xe1a(%rip),%rsi
mov    $0x280,%ecx
mov    $0x0,%al
call   1030 <trap_FS_GetFileList@plt>
mov    %eax,-0x3a4(%rbp)
lea    -0x2a0(%rbp),%rax
mov    %rax,-0x3c0(%rbp)
movl   $0x0,-0x3a8(%rbp)
mov    -0x3a8(%rbp),%eax
cmp    -0x3a4(%rbp),%eax
jge    131f <G_LayoutList+0x1af>
mov    -0x3c0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x3ac(%rbp)
lea    -0x3a0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x3b0(%rbp)
cmpl   $0x5,-0x3ac(%rbp)
jge    126e <G_LayoutList+0xfe>
jmp    12ee <G_LayoutList+0x17e>
mov    -0x3b0(%rbp),%eax
add    -0x3ac(%rbp),%eax
cltq
cmp    $0x100,%rax
jb     128d <G_LayoutList+0x11d>
jmp    131f <G_LayoutList+0x1af>
lea    -0x3a0(%rbp),%rdi
mov    -0x3c0(%rbp),%rdx
mov    $0x100,%esi
mov    $0x0,%al
call   1080 <Q_strcat@plt>
lea    -0x3a0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x3b0(%rbp)
mov    -0x3b0(%rbp),%eax
sub    $0x4,%eax
cltq
movb   $0x20,-0x3a0(%rbp,%rax,1)
20
mov    -0x3b0(%rbp),%eax
sub    $0x3,%eax
cltq
movb   $0x0,-0x3a0(%rbp,%rax,1)
mov    -0x3b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3b4(%rbp)
mov    -0x3a8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3a8(%rbp)
mov    -0x3ac(%rbp),%ecx
add    $0x1,%ecx
mov    -0x3c0(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x3c0(%rbp)
jmp    1226 <G_LayoutList+0xb6>
mov    -0x3b4(%rbp),%eax
cmp    -0x3a4(%rbp),%eax
je     134f <G_LayoutList+0x1df>
mov    -0x3b4(%rbp),%esi
mov    -0x3a4(%rbp),%edx
mov    -0x8(%rbp),%rcx
lea    0xcd3(%rip),%rdi
mov    $0x0,%al
call   1060 <G_Printf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x3a0(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    $0x0,%al
call   1090 <Q_strncpyz@plt>
mov    -0x3b4(%rbp),%eax
add    $0x1,%eax
add    $0x3c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<G_LayoutList>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3a8,%rsp
mov    %edx,0xc(%rsp)
mov    %rsi,0x18(%rsp)
mov    %rdi,%r14
lea    0x120(%rsp),%rbx
xor    %ebp,%ebp
mov    $0x280,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
lea    0xde2(%rip),%rdx
lea    0x20(%rsp),%rdi
mov    $0x100,%esi
xor    %eax,%eax
call   1080 <Q_strcat@plt>
lea    0xdd5(%rip),%rdi
mov    %r14,0x10(%rsp)
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <va@plt>
lea    0xdca(%rip),%rsi
mov    $0x280,%ecx
mov    %eax,%edi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <trap_FS_GetFileList@plt>
mov    %eax,0x8(%rsp)
test   %eax,%eax
jle    1305 <G_LayoutList+0x195>
lea    0x20(%rsp),%r14
movabs $0xfffffffd00000000,%r13
ff ff ff
mov    0x8(%rsp),%r12d
xor    %ebp,%ebp
jmp    12e2 <G_LayoutList+0x172>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x100,%esi
mov    %r14,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1080 <Q_strcat@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
shl    $0x20,%rax
movabs $0xfffffffc00000000,%rcx
ff ff ff
add    %rax,%rcx
sar    $0x20,%rcx
movb   $0x20,0x20(%rsp,%rcx,1)
add    %r13,%rax
sar    $0x20,%rax
movb   $0x0,0x20(%rsp,%rax,1)
add    $0x1,%ebp
lea    0x1(%r15),%eax
cltq
add    %rax,%rbx
add    $0xffffffff,%r12d
je     1305 <G_LayoutList+0x195>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rax,%r15
cmp    $0x5,%r15d
jl     12d3 <G_LayoutList+0x163>
mov    %r14,%rdi
call   1040 <strlen@plt>
add    %r15d,%eax
test   $0xffffff00,%eax
je     1290 <G_LayoutList+0x120>
mov    0x8(%rsp),%edx
cmp    %edx,%ebp
je     1322 <G_LayoutList+0x1b2>
lea    0xd07(%rip),%rdi
mov    %ebp,%esi
mov    0x10(%rsp),%rcx
xor    %eax,%eax
call   1060 <G_Printf@plt>
lea    0x20(%rsp),%rsi
mov    0x18(%rsp),%rdi
mov    0xc(%rsp),%edx
xor    %eax,%eax
call   1090 <Q_strncpyz@plt>
add    $0x1,%ebp
mov    %ebp,%eax
add    $0x3a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"*BUILTIN* \00"
@.str.1 = [11 x i8] c"layouts/%s\00"
@.str.2 = [5 x i8] c".dat\00"
@.str.3 = [95 x i8] c"^3WARNING: layout list was truncated to %d layouts, but %d layout files exist in layouts/%s/.\0A\00"
define i32 @G_LayoutList(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [640 x i8]
%8 = alloca [256 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%15 = bitcast [640 x i8]* %7 to i8*
%16 = bitcast [256 x i8]* %8 to i8*
store i32 0, i32* %11
store i32 0, i32* %13
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%18 = call i32 (i8*, i64, i8*, ...) bitcast (i32 (...)* @Q_strcat to i32 (i8*, i64, i8*, ...)*)(i8* %17, i64 256, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%19 = load i8*, i8** %4
%20 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @va to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [640 x i8], [640 x i8]* %7, i64 0, i64 0
%22 = call i32 (i32, i8*, i8*, i64, ...) bitcast (i32 (...)* @trap_FS_GetFileList to i32 (i32, i8*, i8*, i64, ...)*)(i32 %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %21, i64 640)
store i32 %22, i32* %9
%23 = getelementptr inbounds [640 x i8], [640 x i8]* %7, i64 0, i64 0
store i8* %23, i8** %14
store i32 0, i32* %10
br label %24
24: ; preds = %62, %3
%25 = load i32, i32* %10
%26 = load i32, i32* %9
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %70
28: ; preds = %24
%29 = load i8*, i8** %14
%30 = call i64 @strlen(i8* %29)
%31 = trunc i64 %30 to i32
store i32 %31, i32* %11
%32 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%33 = call i64 @strlen(i8* %32)
%34 = trunc i64 %33 to i32
store i32 %34, i32* %12
%35 = load i32, i32* %11
%36 = icmp slt i32 %35, 5
br i1 %36, label %37, label %38
37: ; preds = %28
br label %62
38: ; preds = %28
%39 = load i32, i32* %12
%40 = load i32, i32* %11
%41 = add nsw i32 %39, %40
%42 = sext i32 %41 to i64
%43 = icmp uge i64 %42, 256
br i1 %43, label %44, label %45
44: ; preds = %38
br label %70
45: ; preds = %38
%46 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%47 = load i8*, i8** %14
%48 = call i32 (i8*, i64, i8*, ...) bitcast (i32 (...)* @Q_strcat to i32 (i8*, i64, i8*, ...)*)(i8* %46, i64 256, i8* %47)
%49 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%50 = call i64 @strlen(i8* %49)
%51 = trunc i64 %50 to i32
store i32 %51, i32* %12
%52 = load i32, i32* %12
%53 = sub nsw i32 %52, 4
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 %54
store i8 32, i8* %55
%56 = load i32, i32* %12
%57 = sub nsw i32 %56, 3
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 %58
store i8 0, i8* %59
%60 = load i32, i32* %13
%61 = add nsw i32 %60, 1
store i32 %61, i32* %13
br label %62
62: ; preds = %45, %37
%63 = load i32, i32* %10
%64 = add nsw i32 %63, 1
store i32 %64, i32* %10
%65 = load i32, i32* %11
%66 = add nsw i32 %65, 1
%67 = load i8*, i8** %14
%68 = sext i32 %66 to i64
%69 = getelementptr inbounds i8, i8* %67, i64 %68
store i8* %69, i8** %14
br label %24
70: ; preds = %44, %24
%71 = load i32, i32* %13
%72 = load i32, i32* %9
%73 = icmp ne i32 %71, %72
br i1 %73, label %74, label %79
74: ; preds = %70
%75 = load i32, i32* %13
%76 = load i32, i32* %9
%77 = load i8*, i8** %4
%78 = call i32 (i8*, i32, i32, i8*, ...) bitcast (i32 (...)* @G_Printf to i32 (i8*, i32, i32, i8*, ...)*)(i8* getelementptr inbounds ([95 x i8], [95 x i8]* @.str.3, i64 0, i64 0), i32 %75, i32 %76, i8* %77)
br label %79
79: ; preds = %74, %70
%80 = load i8*, i8** %5
%81 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%82 = load i32, i32* %6
%83 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @Q_strncpyz to i32 (i8*, i8*, i32, ...)*)(i8* %80, i8* %81, i32 %82)
%84 = load i32, i32* %13
%85 = add nsw i32 %84, 1
ret i32 %85
}

LLVM IR (-O2):
@.str = [11 x i8] c"*BUILTIN* \00"
@.str.1 = [11 x i8] c"layouts/%s\00"
@.str.2 = [5 x i8] c".dat\00"
@.str.3 = [95 x i8] c"^3WARNING: layout list was truncated to %d layouts, but %d layout files exist in layouts/%s/.\0A\00"
define i32 @G_LayoutList(i8* %0, i8* %1, i32 %2) {
%4 = alloca [640 x i8]
%5 = alloca [256 x i8]
%6 = getelementptr inbounds [640 x i8], [640 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%8 = call i32 (i8*, i64, i8*, ...) bitcast (i32 (...)* @Q_strcat to i32 (i8*, i64, i8*, ...)*)(i8* %7, i64 256, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @va to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%10 = call i32 (i32, i8*, i8*, i64, ...) bitcast (i32 (...)* @trap_FS_GetFileList to i32 (i32, i8*, i8*, i64, ...)*)(i32 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %6, i64 640)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %43
12: ; preds = %3, %35
%13 = phi i8* [ %41, %35 ], [ %6, %3 ]
%14 = phi i32 [ %36, %35 ], [ 0, %3 ]
%15 = phi i32 [ %37, %35 ], [ 0, %3 ]
%16 = call i64 @strlen(i8* dereferenceable(1) %13)
%17 = trunc i64 %16 to i32
%18 = icmp slt i32 %17, 5
br i1 %18, label %35, label %19
19: ; preds = %12
%20 = call i64 @strlen(i8* %7)
%21 = add i64 %20, %16
%22 = and i64 %21, 4294967040
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %43
24: ; preds = %19
%25 = call i32 (i8*, i64, i8*, ...) bitcast (i32 (...)* @Q_strcat to i32 (i8*, i64, i8*, ...)*)(i8* %7, i64 256, i8* %13)
%26 = call i64 @strlen(i8* %7)
%27 = shl i64 %26, 32
%28 = add i64 %27, -17179869184
%29 = ashr exact i64 %28, 32
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %29
store i8 32, i8* %30
%31 = add i64 %27, -12884901888
%32 = ashr exact i64 %31, 32
%33 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 %32
store i8 0, i8* %33
%34 = add nsw i32 %14, 1
br label %35
35: ; preds = %12, %24
%36 = phi i32 [ %14, %12 ], [ %34, %24 ]
%37 = add nuw nsw i32 %15, 1
%38 = shl i64 %16, 32
%39 = add i64 %38, 4294967296
%40 = ashr exact i64 %39, 32
%41 = getelementptr inbounds i8, i8* %13, i64 %40
%42 = icmp eq i32 %37, %10
br i1 %42, label %43, label %12
43: ; preds = %35, %19, %3
%44 = phi i32 [ 0, %3 ], [ %14, %19 ], [ %36, %35 ]
%45 = icmp eq i32 %44, %10
br i1 %45, label %48, label %46
46: ; preds = %43
%47 = call i32 (i8*, i32, i32, i8*, ...) bitcast (i32 (...)* @G_Printf to i32 (i8*, i32, i32, i8*, ...)*)(i8* getelementptr inbounds ([95 x i8], [95 x i8]* @.str.3, i64 0, i64 0), i32 %44, i32 %10, i8* %0)
br label %48
48: ; preds = %46, %43
%49 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @Q_strncpyz to i32 (i8*, i8*, i32, ...)*)(i8* %1, i8* %7, i32 %2)
%50 = add nsw i32 %44, 1
ret i32 %50
}