#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 */
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct stat {
  int /*<<< orphan*/ st_mode;
};
struct dirent {
  char *d_name;
  scalar_t__ d_type;
};
typedef int /*<<< orphan*/ msg;
typedef int /*<<< orphan*/ int64_t;
struct TYPE_5__ {
  int gl_pathc;
  char **gl_pathv;
};
typedef TYPE_1__ glob_t;
typedef int /*<<< orphan*/ gl;
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
scalar_t__ DT_DIR;
scalar_t__ DT_REG;
scalar_t__ S_ISDIR(int /*<<< orphan*/);
scalar_t__ S_ISREG(int /*<<< orphan*/);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char *fgets(char *, size_t, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
scalar_t__ glob(char const *, int /*<<< orphan*/, int /*<<< orphan*/ *,
                TYPE_1__ *);
int /*<<< orphan*/ globfree(TYPE_1__ *);
scalar_t__ is_glob(char const *);
char *malloc(int);
int /*<<< orphan*/ memset(TYPE_1__ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ *opendir(char const *);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ send_preview_data(int /*<<< orphan*/, char const *, size_t,
                                     char *);
int /*<<< orphan*/ send_preview_error(int /*<<< orphan*/, char const *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char const *, ...);
int stat(char const *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strcmp(char *, char *);
char *strerror(int /*<<< orphan*/);
size_t strlen(char *);
void handle_load_preview_request(const char *path, int64_t preview_id) {
  struct stat st;
  fprintf(stderr, "info: load preview request -- %lld\n", preview_id);
  if (is_glob(path)) {
    glob_t gl;
    memset(&gl, 0, sizeof(gl));
    if (glob(path, 0, NULL, &gl) != 0) {
      char msg[1024];
      snprintf(msg, sizeof(msg), "error: cannot glob %s -- %s", path,
               strerror(errno));
      send_preview_error(preview_id, path, msg);
    } else {
      char *bits = malloc(1024 * 1024);
      int lpc, line_count = 10;
      bits[0] = '\0';
      for (lpc = 0; line_count > 0 && lpc < gl.gl_pathc; lpc++, line_count--) {
        strcat(bits, gl.gl_pathv[lpc]);
        strcat(bits, "\n");
      }
      if (lpc < gl.gl_pathc) {
        strcat(bits, " ... and more! ...\n");
      }
      send_preview_data(preview_id, path, strlen(bits), bits);
      globfree(&gl);
      free(bits);
    }
  } else if (stat(path, &st) == -1) {
    char msg[1024];
    snprintf(msg, sizeof(msg), "error: cannot open %s -- %s", path,
             strerror(errno));
    send_preview_error(preview_id, path, msg);
  } else if (S_ISREG(st.st_mode)) {
    size_t capacity = 1024 * 1024;
    char *bits = malloc(capacity);
    FILE *file;
    if ((file = fopen(path, "r")) == NULL) {
      char msg[1024];
      snprintf(msg, sizeof(msg), "error: cannot open %s -- %s", path,
               strerror(errno));
      send_preview_error(preview_id, path, msg);
    } else {
      int line_count = 10;
      size_t offset = 0;
      char *line;
      while (line_count && (capacity - offset) > 1024 &&
             (line = fgets(&bits[offset], capacity - offset, file)) != NULL) {
        offset += strlen(line);
        line_count -= 1;
      }
      fclose(file);
      send_preview_data(preview_id, path, offset, bits);
    }
    free(bits);
  } else if (S_ISDIR(st.st_mode)) {
    DIR *dir = opendir(path);
    if (dir == NULL) {
      char msg[1024];
      snprintf(msg, sizeof(msg), "error: unable to open directory -- %s", path);
      send_preview_error(preview_id, path, msg);
    } else {
      char *bits = malloc(1024 * 1024);
      struct dirent *entry;
      int line_count = 10;
      bits[0] = '\0';
      while ((entry = readdir(dir)) != NULL) {
        if (strcmp(entry->d_name, ".") == 0 ||
            strcmp(entry->d_name, "..") == 0) {
          continue;
        }
        if (entry->d_type != DT_REG && entry->d_type != DT_DIR) {
          continue;
        }
        if (line_count == 1) {
          strcat(bits, " ... and more! ...\n");
          break;
        }
        strcat(bits, entry->d_name);
        strcat(bits, "\n");
        line_count -= 1;
      }
      closedir(dir);
      send_preview_data(preview_id, path, strlen(bits), bits);
      free(bits);
    }
  } else {
    char msg[1024];
    snprintf(msg, sizeof(msg), "error: path is not a file or directory -- %s",
             path);
    send_preview_error(preview_id, path, msg);
  }
}


x86 assembly (clang, -O0):
<handle_load_preview_request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x14f0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    0x2d4f(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xd6b(%rip),%rsi
call   10f0 <fprintf@plt>
mov    -0x8(%rbp),%rdi
call   1180 <is_glob@plt>
cmp    $0x0,%rax
je     146f <handle_load_preview_request+0x1ff>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   10a0 <memset@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
xor    %eax,%eax
mov    %eax,%edx
lea    -0x20(%rbp),%rcx
call   1170 <glob@plt>
cmp    $0x0,%rax
je     133d <handle_load_preview_request+0xcd>
lea    -0x420(%rbp),%rax
mov    %rax,-0x14a0(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x1498(%rbp)
mov    0x2cce(%rip),%rax
mov    (%rax),%edi
call   1190 <strerror@plt>
mov    -0x14a0(%rbp),%rdi
mov    -0x1498(%rbp),%rcx
mov    %rax,%r8
mov    $0x400,%esi
lea    0xd06(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
lea    -0x420(%rbp),%rdx
call   10e0 <send_preview_error@plt>
jmp    146a <handle_load_preview_request+0x1fa>
mov    $0x100000,%edi
call   1130 <malloc@plt>
mov    %rax,-0x428(%rbp)
movl   $0xa,-0x430(%rbp)
mov    -0x428(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x42c(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x430(%rbp)
mov    %al,-0x14a1(%rbp)
jle    1393 <handle_load_preview_request+0x123>
mov    -0x42c(%rbp),%eax
cmp    -0x20(%rbp),%eax
setl   %al
mov    %al,-0x14a1(%rbp)
mov    -0x14a1(%rbp),%al
test   $0x1,%al
jne    13a6 <handle_load_preview_request+0x136>
jmp    13f7 <handle_load_preview_request+0x187>
mov    -0x428(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq -0x42c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   1160 <strcat@plt>
mov    -0x428(%rbp),%rdi
lea    0xc83(%rip),%rsi
call   1160 <strcat@plt>
mov    -0x42c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x42c(%rbp)
mov    -0x430(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x430(%rbp)
jmp    136c <handle_load_preview_request+0xfc>
mov    -0x42c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1419 <handle_load_preview_request+0x1a9>
mov    -0x428(%rbp),%rdi
lea    0xc2c(%rip),%rsi
call   1160 <strcat@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14b4(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x14b0(%rbp)
mov    -0x428(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x14b4(%rbp),%edi
mov    -0x14b0(%rbp),%rsi
mov    %rax,%rdx
mov    -0x428(%rbp),%rcx
call   1140 <send_preview_data@plt>
lea    -0x20(%rbp),%rdi
call   1030 <globfree@plt>
mov    -0x428(%rbp),%rdi
call   1040 <free@plt>
jmp    18c2 <handle_load_preview_request+0x652>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1100 <stat@plt>
cmp    $0xffffffff,%eax
jne    14e8 <handle_load_preview_request+0x278>
lea    -0x830(%rbp),%rax
mov    %rax,-0x14c8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x14c0(%rbp)
mov    0x2b23(%rip),%rax
mov    (%rax),%edi
call   1190 <strerror@plt>
mov    -0x14c8(%rbp),%rdi
mov    -0x14c0(%rbp),%rcx
mov    %rax,%r8
mov    $0x400,%esi
lea    0xb8b(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
lea    -0x830(%rbp),%rdx
call   10e0 <send_preview_error@plt>
jmp    18bd <handle_load_preview_request+0x64d>
mov    -0x10(%rbp),%edi
call   1110 <S_ISREG@plt>
cmp    $0x0,%rax
je     169f <handle_load_preview_request+0x42f>
movq   $0x100000,-0x838(%rbp)
mov    -0x838(%rbp),%rax
mov    %eax,%edi
call   1130 <malloc@plt>
mov    %rax,-0x840(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xb4b(%rip),%rsi
call   1150 <fopen@plt>
mov    %rax,-0x848(%rbp)
cmp    $0x0,%rax
jne    159e <handle_load_preview_request+0x32e>
lea    -0xc50(%rbp),%rax
mov    %rax,-0x14d8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x14d0(%rbp)
mov    0x2a6d(%rip),%rax
mov    (%rax),%edi
call   1190 <strerror@plt>
mov    -0x14d8(%rbp),%rdi
mov    -0x14d0(%rbp),%rcx
mov    %rax,%r8
mov    $0x400,%esi
lea    0xad5(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
lea    -0xc50(%rbp),%rdx
call   10e0 <send_preview_error@plt>
jmp    168e <handle_load_preview_request+0x41e>
movl   $0xa,-0xc54(%rbp)
movq   $0x0,-0xc60(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0xc54(%rbp)
mov    %al,-0x14d9(%rbp)
je     1627 <handle_load_preview_request+0x3b7>
mov    -0x838(%rbp),%rcx
sub    -0xc60(%rbp),%rcx
xor    %eax,%eax
cmp    $0x400,%rcx
mov    %al,-0x14d9(%rbp)
jbe    1627 <handle_load_preview_request+0x3b7>
mov    -0x840(%rbp),%rdi
add    -0xc60(%rbp),%rdi
mov    -0x838(%rbp),%rsi
sub    -0xc60(%rbp),%rsi
mov    -0x848(%rbp),%rdx
call   10c0 <fgets@plt>
mov    %rax,-0xc68(%rbp)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x14d9(%rbp)
mov    -0x14d9(%rbp),%al
test   $0x1,%al
jne    163a <handle_load_preview_request+0x3ca>
jmp    1668 <handle_load_preview_request+0x3f8>
mov    -0xc68(%rbp),%rdi
call   1070 <strlen@plt>
add    -0xc60(%rbp),%rax
mov    %rax,-0xc60(%rbp)
mov    -0xc54(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xc54(%rbp)
jmp    15b3 <handle_load_preview_request+0x343>
mov    -0x848(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    -0xc60(%rbp),%rdx
mov    -0x840(%rbp),%rcx
call   1140 <send_preview_data@plt>
mov    -0x840(%rbp),%rdi
call   1040 <free@plt>
jmp    18b8 <handle_load_preview_request+0x648>
mov    -0x10(%rbp),%edi
call   1080 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1882 <handle_load_preview_request+0x612>
mov    -0x8(%rbp),%rdi
call   1060 <opendir@plt>
mov    %rax,-0xc70(%rbp)
cmpq   $0x0,-0xc70(%rbp)
jne    1705 <handle_load_preview_request+0x495>
lea    -0x1070(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x400,%esi
lea    0x98c(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
lea    -0x1070(%rbp),%rdx
call   10e0 <send_preview_error@plt>
jmp    187d <handle_load_preview_request+0x60d>
mov    $0x100000,%edi
call   1130 <malloc@plt>
mov    %rax,-0x1078(%rbp)
movl   $0xa,-0x1084(%rbp)
mov    -0x1078(%rbp),%rax
movb   $0x0,(%rax)
mov    -0xc70(%rbp),%rdi
call   1120 <readdir@plt>
mov    %rax,-0x1080(%rbp)
cmp    $0x0,%rax
je     1829 <handle_load_preview_request+0x5b9>
mov    -0x1080(%rbp),%rax
mov    (%rax),%rdi
lea    0x941(%rip),%rsi
call   10d0 <strcmp@plt>
cmp    $0x0,%rax
je     1787 <handle_load_preview_request+0x517>
mov    -0x1080(%rbp),%rax
mov    (%rax),%rdi
lea    0x920(%rip),%rsi
call   10d0 <strcmp@plt>
cmp    $0x0,%rax
jne    178c <handle_load_preview_request+0x51c>
jmp    172a <handle_load_preview_request+0x4ba>
mov    -0x1080(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2842(%rip),%rcx
cmp    (%rcx),%rax
je     17c7 <handle_load_preview_request+0x557>
mov    -0x1080(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2817(%rip),%rcx
cmp    (%rcx),%rax
je     17c7 <handle_load_preview_request+0x557>
jmp    172a <handle_load_preview_request+0x4ba>
cmpl   $0x1,-0x1084(%rbp)
jne    17ec <handle_load_preview_request+0x57c>
mov    -0x1078(%rbp),%rdi
lea    0x85e(%rip),%rsi
call   1160 <strcat@plt>
jmp    1829 <handle_load_preview_request+0x5b9>
mov    -0x1078(%rbp),%rdi
mov    -0x1080(%rbp),%rax
mov    (%rax),%rsi
call   1160 <strcat@plt>
mov    -0x1078(%rbp),%rdi
lea    0x842(%rip),%rsi
call   1160 <strcat@plt>
mov    -0x1084(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1084(%rbp)
jmp    172a <handle_load_preview_request+0x4ba>
mov    -0xc70(%rbp),%rdi
call   10b0 <closedir@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14ec(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x14e8(%rbp)
mov    -0x1078(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x14ec(%rbp),%edi
mov    -0x14e8(%rbp),%rsi
mov    %rax,%rdx
mov    -0x1078(%rbp),%rcx
call   1140 <send_preview_data@plt>
mov    -0x1078(%rbp),%rdi
call   1040 <free@plt>
jmp    18b3 <handle_load_preview_request+0x643>
lea    -0x1490(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x400,%esi
lea    0x802(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
lea    -0x1490(%rbp),%rdx
call   10e0 <send_preview_error@plt>
jmp    18b8 <handle_load_preview_request+0x648>
jmp    18bd <handle_load_preview_request+0x64d>
jmp    18c2 <handle_load_preview_request+0x652>
add    $0x14f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_load_preview_request>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %esi,%r13d
mov    %rdi,%r12
mov    0x2d4a(%rip),%rax
mov    (%rax),%edi
lea    0xd69(%rip),%rsi
mov    %r13d,%edx
call   10f0 <fprintf@plt>
mov    %r12,%rdi
call   1180 <is_glob@plt>
test   %rax,%rax
je     12f2 <handle_load_preview_request+0x82>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   10a0 <memset@plt>
mov    %r12,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    %rbx,%rcx
call   1170 <glob@plt>
test   %rax,%rax
je     154f <handle_load_preview_request+0x2df>
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
call   1190 <strerror@plt>
lea    0xd37(%rip),%rdx
jmp    160a <handle_load_preview_request+0x39a>
lea    0x10(%rsp),%rsi
mov    %r12,%rdi
call   1100 <stat@plt>
cmp    $0xffffffff,%eax
je     15f5 <handle_load_preview_request+0x385>
mov    0x10(%rsp),%ebx
mov    %ebx,%edi
call   1110 <S_ISREG@plt>
test   %rax,%rax
je     1637 <handle_load_preview_request+0x3c7>
mov    $0x100000,%edi
call   1130 <malloc@plt>
mov    %rax,%r14
lea    0xd40(%rip),%rsi
mov    %r12,%rdi
call   1150 <fopen@plt>
test   %rax,%rax
je     169c <handle_load_preview_request+0x42c>
mov    %rax,%r15
mov    $0x100000,%ebp
mov    $0x100000,%esi
mov    %r14,%rdi
mov    %rax,%rdx
call   10c0 <fgets@plt>
test   %rax,%rax
je     16db <handle_load_preview_request+0x46b>
mov    %rax,%rdi
call   1070 <strlen@plt>
mov    %rax,%rbx
sub    %rax,%rbp
cmp    $0x401,%rbp
jb     16dd <handle_load_preview_request+0x46d>
lea    (%r14,%rbx,1),%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
call   10c0 <fgets@plt>
test   %rax,%rax
je     16dd <handle_load_preview_request+0x46d>
mov    %rax,%rdi
call   1070 <strlen@plt>
add    %rax,%rbx
mov    $0x100000,%esi
sub    %rbx,%rsi
cmp    $0x401,%rsi
jb     16dd <handle_load_preview_request+0x46d>
lea    (%r14,%rbx,1),%rdi
mov    %r15,%rdx
call   10c0 <fgets@plt>
test   %rax,%rax
je     16dd <handle_load_preview_request+0x46d>
mov    %rax,%rdi
call   1070 <strlen@plt>
add    %rax,%rbx
mov    $0x100000,%esi
sub    %rbx,%rsi
cmp    $0x401,%rsi
jb     16dd <handle_load_preview_request+0x46d>
lea    (%r14,%rbx,1),%rdi
mov    %r15,%rdx
call   10c0 <fgets@plt>
test   %rax,%rax
je     16dd <handle_load_preview_request+0x46d>
mov    %rax,%rdi
call   1070 <strlen@plt>
add    %rax,%rbx
mov    $0x100000,%esi
sub    %rbx,%rsi
cmp    $0x401,%rsi
jb     16dd <handle_load_preview_request+0x46d>
lea    (%r14,%rbx,1),%rdi
mov    %r15,%rdx
call   10c0 <fgets@plt>
test   %rax,%rax
je     16dd <handle_load_preview_request+0x46d>
mov    %rax,%rdi
call   1070 <strlen@plt>
add    %rax,%rbx
mov    $0x100000,%esi
sub    %rbx,%rsi
cmp    $0x401,%rsi
jb     16dd <handle_load_preview_request+0x46d>
lea    (%r14,%rbx,1),%rdi
mov    %r15,%rdx
call   10c0 <fgets@plt>
test   %rax,%rax
je     16dd <handle_load_preview_request+0x46d>
mov    %rax,%rdi
call   1070 <strlen@plt>
add    %rax,%rbx
mov    $0x100000,%esi
sub    %rbx,%rsi
cmp    $0x401,%rsi
jb     16dd <handle_load_preview_request+0x46d>
lea    (%r14,%rbx,1),%rdi
mov    %r15,%rdx
call   10c0 <fgets@plt>
test   %rax,%rax
je     16dd <handle_load_preview_request+0x46d>
mov    %rax,%rdi
call   1070 <strlen@plt>
add    %rax,%rbx
mov    $0x100000,%esi
sub    %rbx,%rsi
cmp    $0x401,%rsi
jb     16dd <handle_load_preview_request+0x46d>
lea    (%r14,%rbx,1),%rdi
mov    %r15,%rdx
call   10c0 <fgets@plt>
test   %rax,%rax
je     16dd <handle_load_preview_request+0x46d>
mov    %rax,%rdi
call   1070 <strlen@plt>
add    %rax,%rbx
mov    $0x100000,%esi
sub    %rbx,%rsi
cmp    $0x401,%rsi
jb     16dd <handle_load_preview_request+0x46d>
lea    (%r14,%rbx,1),%rdi
mov    %r15,%rdx
call   10c0 <fgets@plt>
test   %rax,%rax
je     16dd <handle_load_preview_request+0x46d>
mov    %rax,%rdi
call   1070 <strlen@plt>
add    %rax,%rbx
mov    $0x100000,%esi
sub    %rbx,%rsi
cmp    $0x401,%rsi
jb     16dd <handle_load_preview_request+0x46d>
mov    %r14,%rdi
add    %rbx,%rdi
mov    %r15,%rdx
call   10c0 <fgets@plt>
test   %rax,%rax
je     16dd <handle_load_preview_request+0x46d>
mov    %rax,%rdi
call   1070 <strlen@plt>
add    %rax,%rbx
jmp    16dd <handle_load_preview_request+0x46d>
mov    $0x100000,%edi
call   1130 <malloc@plt>
mov    %rax,%r15
movb   $0x0,(%rax)
cmpl   $0x0,0x10(%rsp)
jle    15ca <handle_load_preview_request+0x35a>
mov    $0xa,%ebx
mov    $0x1,%ecx
lea    0xadb(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %rcx,%rbp
mov    0x18(%rsp),%rax
mov    -0x8(%rax,%rcx,8),%rsi
mov    %r15,%rdi
call   1160 <strcat@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1160 <strcat@plt>
movslq 0x10(%rsp),%rax
cmp    $0x2,%ebx
jb     15b6 <handle_load_preview_request+0x346>
add    $0xffffffff,%ebx
lea    0x1(%rbp),%rcx
cmp    %rax,%rbp
jl     1580 <handle_load_preview_request+0x310>
cmp    %rax,%rbp
jge    15ca <handle_load_preview_request+0x35a>
lea    0xa7e(%rip),%rsi
mov    %r15,%rdi
call   1160 <strcat@plt>
mov    %r15,%rdi
call   1070 <strlen@plt>
mov    %r13d,%edi
mov    %r12,%rsi
mov    %rax,%rdx
mov    %r15,%rcx
call   1140 <send_preview_data@plt>
lea    0x10(%rsp),%rdi
call   1030 <globfree@plt>
mov    %r15,%rdi
jmp    16f9 <handle_load_preview_request+0x489>
mov    0x29cc(%rip),%rax
mov    (%rax),%edi
call   1190 <strerror@plt>
lea    0xa4a(%rip),%rdx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r12,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %r13d,%edi
mov    %r12,%rsi
mov    %rbx,%rdx
call   10e0 <send_preview_error@plt>
jmp    16fe <handle_load_preview_request+0x48e>
mov    %ebx,%edi
call   1080 <S_ISDIR@plt>
test   %rax,%rax
je     1710 <handle_load_preview_request+0x4a0>
mov    %r12,%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     1719 <handle_load_preview_request+0x4a9>
mov    %rax,%rbp
mov    $0x100000,%edi
call   1130 <malloc@plt>
mov    %rax,0x8(%rsp)
movb   $0x0,(%rax)
mov    %rbp,%rdi
call   1120 <readdir@plt>
test   %rax,%rax
je     17e6 <handle_load_preview_request+0x576>
mov    %rax,%r14
movl   $0xa,0x4(%rsp)
lea    0xa09(%rip),%r15
lea    0xa01(%rip),%rbx
jmp    1790 <handle_load_preview_request+0x520>
mov    0x2925(%rip),%rax
mov    (%rax),%edi
call   1190 <strerror@plt>
lea    0x9a3(%rip),%rdx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r12,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %r13d,%edi
mov    %r12,%rsi
mov    %rbx,%rdx
call   10e0 <send_preview_error@plt>
jmp    16f6 <handle_load_preview_request+0x486>
xor    %ebx,%ebx
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    %r13d,%edi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1140 <send_preview_data@plt>
mov    %r14,%rdi
call   1040 <free@plt>
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x984(%rip),%rdx
jmp    1720 <handle_load_preview_request+0x4b0>
lea    0x952(%rip),%rdx
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r12,%rcx
xor    %eax,%eax
call   1090 <snprintf@plt>
jmp    1624 <handle_load_preview_request+0x3b4>
mov    0x4(%rsp),%eax
cmp    $0x1,%eax
je     17d5 <handle_load_preview_request+0x565>
mov    (%r14),%rsi
mov    0x8(%rsp),%rdi
mov    %eax,%r14d
call   1160 <strcat@plt>
mov    0x8(%rsp),%rdi
lea    0x8ed(%rip),%rsi
call   1160 <strcat@plt>
add    $0xffffffff,%r14d
mov    %r14d,0x4(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
call   1120 <readdir@plt>
mov    %rax,%r14
test   %rax,%rax
je     17e6 <handle_load_preview_request+0x576>
mov    (%r14),%rdi
mov    %r15,%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     1780 <handle_load_preview_request+0x510>
mov    (%r14),%rdi
mov    %rbx,%rsi
call   10d0 <strcmp@plt>
test   %rax,%rax
je     1780 <handle_load_preview_request+0x510>
mov    0x8(%r14),%rax
mov    0x2825(%rip),%rcx
cmp    (%rcx),%rax
je     173c <handle_load_preview_request+0x4cc>
mov    0x2805(%rip),%rcx
cmp    (%rcx),%rax
jne    1780 <handle_load_preview_request+0x510>
jmp    173c <handle_load_preview_request+0x4cc>
lea    0x864(%rip),%rsi
mov    0x8(%rsp),%rdi
call   1160 <strcat@plt>
mov    %rbp,%rdi
call   10b0 <closedir@plt>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %r13d,%edi
mov    %r12,%rsi
mov    %rax,%rdx
mov    %rbx,%rcx
call   1140 <send_preview_data@plt>
mov    %rbx,%rdi
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <free@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
%struct.TYPE_5__ = type { i32, i8** }
%struct.dirent = type { i8*, i64 }
@stderr = global i32 0
@.str = [36 x i8] c"info: load preview request -- %lld\0A\00"
@.str.1 = [28 x i8] c"error: cannot glob %s -- %s\00"
@errno = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [20 x i8] c" ... and more! ...\0A\00"
@.str.4 = [28 x i8] c"error: cannot open %s -- %s\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [38 x i8] c"error: unable to open directory -- %s\00"
@.str.7 = [2 x i8] c".\00"
@.str.8 = [3 x i8] c"..\00"
@DT_REG = global i64 0
@DT_DIR = global i64 0
@.str.9 = [45 x i8] c"error: path is not a file or directory -- %s\00"
define void @handle_load_preview_request(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.stat
%6 = alloca %struct.TYPE_5__
%7 = alloca [1024 x i8]
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca [1024 x i8]
%12 = alloca i64
%13 = alloca i8*
%14 = alloca i32*
%15 = alloca [1024 x i8]
%16 = alloca i32
%17 = alloca i64
%18 = alloca i8*
%19 = alloca i32*
%20 = alloca [1024 x i8]
%21 = alloca i8*
%22 = alloca %struct.dirent*
%23 = alloca i32
%24 = alloca [1024 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%25 = load i32, i32* @stderr
%26 = load i32, i32* %4
%27 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = load i8*, i8** %3
%29 = call i64 @is_glob(i8* %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %95
31: ; preds = %2
%32 = call i32 @memset(%struct.TYPE_5__* %6, i32 0, i32 16)
%33 = load i8*, i8** %3
%34 = call i64 @glob(i8* %33, i32 0, i32* null, %struct.TYPE_5__* %6)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %46
36: ; preds = %31
%37 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%38 = load i8*, i8** %3
%39 = load i32, i32* @errno
%40 = call i8* @strerror(i32 %39)
%41 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %37, i32 1024, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %38, i8* %40)
%42 = load i32, i32* %4
%43 = load i8*, i8** %3
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%45 = call i32 @send_preview_error(i32 %42, i8* %43, i8* %44)
br label %94
46: ; preds = %31
%47 = call i8* @malloc(i32 1048576)
store i8* %47, i8** %8
store i32 10, i32* %10
%48 = load i8*, i8** %8
%49 = getelementptr inbounds i8, i8* %48, i64 0
store i8 0, i8* %49
store i32 0, i32* %9
br label %50
50: ; preds = %71, %46
%51 = load i32, i32* %10
%52 = icmp sgt i32 %51, 0
br i1 %52, label %53, label %58
53: ; preds = %50
%54 = load i32, i32* %9
%55 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 0
%56 = load i32, i32* %55
%57 = icmp slt i32 %54, %56
br label %58
58: ; preds = %53, %50
%59 = phi i1 [ false, %50 ], [ %57, %53 ]
br i1 %59, label %60, label %76
60: ; preds = %58
%61 = load i8*, i8** %8
%62 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 1
%63 = load i8**, i8*** %62
%64 = load i32, i32* %9
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8*, i8** %63, i64 %65
%67 = load i8*, i8** %66
%68 = call i32 @strcat(i8* %61, i8* %67)
%69 = load i8*, i8** %8
%70 = call i32 @strcat(i8* %69, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %71
71: ; preds = %60
%72 = load i32, i32* %9
%73 = add nsw i32 %72, 1
store i32 %73, i32* %9
%74 = load i32, i32* %10
%75 = add nsw i32 %74, -1
store i32 %75, i32* %10
br label %50
76: ; preds = %58
%77 = load i32, i32* %9
%78 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i32 0, i32 0
%79 = load i32, i32* %78
%80 = icmp slt i32 %77, %79
br i1 %80, label %81, label %84
81: ; preds = %76
%82 = load i8*, i8** %8
%83 = call i32 @strcat(i8* %82, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %84
84: ; preds = %81, %76
%85 = load i32, i32* %4
%86 = load i8*, i8** %3
%87 = load i8*, i8** %8
%88 = call i64 @strlen(i8* %87)
%89 = load i8*, i8** %8
%90 = call i32 @send_preview_data(i32 %85, i8* %86, i64 %88, i8* %89)
%91 = call i32 @globfree(%struct.TYPE_5__* %6)
%92 = load i8*, i8** %8
%93 = call i32 @free(i8* %92)
br label %94
94: ; preds = %84, %36
br label %261
95: ; preds = %2
%96 = load i8*, i8** %3
%97 = call i32 @stat(i8* %96, %struct.stat* %5)
%98 = icmp eq i32 %97, -1
br i1 %98, label %99, label %109
99: ; preds = %95
%100 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%101 = load i8*, i8** %3
%102 = load i32, i32* @errno
%103 = call i8* @strerror(i32 %102)
%104 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %100, i32 1024, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %101, i8* %103)
%105 = load i32, i32* %4
%106 = load i8*, i8** %3
%107 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 0, i64 0
%108 = call i32 @send_preview_error(i32 %105, i8* %106, i8* %107)
br label %260
109: ; preds = %95
%110 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%111 = load i32, i32* %110
%112 = call i64 @S_ISREG(i32 %111)
%113 = icmp ne i64 %112, 0
br i1 %113, label %114, label %170
114: ; preds = %109
store i64 1048576, i64* %12
%115 = load i64, i64* %12
%116 = trunc i64 %115 to i32
%117 = call i8* @malloc(i32 %116)
store i8* %117, i8** %13
%118 = load i8*, i8** %3
%119 = call i32* @fopen(i8* %118, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %119, i32** %14
%120 = icmp eq i32* %119, null
br i1 %120, label %121, label %131
121: ; preds = %114
%122 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%123 = load i8*, i8** %3
%124 = load i32, i32* @errno
%125 = call i8* @strerror(i32 %124)
%126 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %122, i32 1024, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %123, i8* %125)
%127 = load i32, i32* %4
%128 = load i8*, i8** %3
%129 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%130 = call i32 @send_preview_error(i32 %127, i8* %128, i8* %129)
br label %167
131: ; preds = %114
store i32 10, i32* %16
store i64 0, i64* %17
br label %132
132: ; preds = %152, %131
%133 = load i32, i32* %16
%134 = icmp ne i32 %133, 0
br i1 %134, label %135, label %150
135: ; preds = %132
%136 = load i64, i64* %12
%137 = load i64, i64* %17
%138 = sub i64 %136, %137
%139 = icmp ugt i64 %138, 1024
br i1 %139, label %140, label %150
140: ; preds = %135
%141 = load i8*, i8** %13
%142 = load i64, i64* %17
%143 = getelementptr inbounds i8, i8* %141, i64 %142
%144 = load i64, i64* %12
%145 = load i64, i64* %17
%146 = sub i64 %144, %145
%147 = load i32*, i32** %14
%148 = call i8* @fgets(i8* %143, i64 %146, i32* %147)
store i8* %148, i8** %18
%149 = icmp ne i8* %148, null
br label %150
150: ; preds = %140, %135, %132
%151 = phi i1 [ false, %135 ], [ false, %132 ], [ %149, %140 ]
br i1 %151, label %152, label %159
152: ; preds = %150
%153 = load i8*, i8** %18
%154 = call i64 @strlen(i8* %153)
%155 = load i64, i64* %17
%156 = add i64 %155, %154
store i64 %156, i64* %17
%157 = load i32, i32* %16
%158 = sub nsw i32 %157, 1
store i32 %158, i32* %16
br label %132
159: ; preds = %150
%160 = load i32*, i32** %14
%161 = call i32 @fclose(i32* %160)
%162 = load i32, i32* %4
%163 = load i8*, i8** %3
%164 = load i64, i64* %17
%165 = load i8*, i8** %13
%166 = call i32 @send_preview_data(i32 %162, i8* %163, i64 %164, i8* %165)
br label %167
167: ; preds = %159, %121
%168 = load i8*, i8** %13
%169 = call i32 @free(i8* %168)
br label %259
170: ; preds = %109
%171 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%172 = load i32, i32* %171
%173 = call i64 @S_ISDIR(i32 %172)
%174 = icmp ne i64 %173, 0
br i1 %174, label %175, label %250
175: ; preds = %170
%176 = load i8*, i8** %3
%177 = call i32* @opendir(i8* %176)
store i32* %177, i32** %19
%178 = load i32*, i32** %19
%179 = icmp eq i32* %178, null
br i1 %179, label %180, label %188
180: ; preds = %175
%181 = getelementptr inbounds [1024 x i8], [1024 x i8]* %20, i64 0, i64 0
%182 = load i8*, i8** %3
%183 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %181, i32 1024, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i8* %182)
%184 = load i32, i32* %4
%185 = load i8*, i8** %3
%186 = getelementptr inbounds [1024 x i8], [1024 x i8]* %20, i64 0, i64 0
%187 = call i32 @send_preview_error(i32 %184, i8* %185, i8* %186)
br label %249
188: ; preds = %175
%189 = call i8* @malloc(i32 1048576)
store i8* %189, i8** %21
store i32 10, i32* %23
%190 = load i8*, i8** %21
%191 = getelementptr inbounds i8, i8* %190, i64 0
store i8 0, i8* %191
br label %192
192: ; preds = %228, %221, %208, %188
%193 = load i32*, i32** %19
%194 = call %struct.dirent* @readdir(i32* %193)
store %struct.dirent* %194, %struct.dirent** %22
%195 = icmp ne %struct.dirent* %194, null
br i1 %195, label %196, label %238
196: ; preds = %192
%197 = load %struct.dirent*, %struct.dirent** %22
%198 = getelementptr inbounds %struct.dirent, %struct.dirent* %197, i32 0, i32 0
%199 = load i8*, i8** %198
%200 = call i64 @strcmp(i8* %199, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%201 = icmp eq i64 %200, 0
br i1 %201, label %208, label %202
202: ; preds = %196
%203 = load %struct.dirent*, %struct.dirent** %22
%204 = getelementptr inbounds %struct.dirent, %struct.dirent* %203, i32 0, i32 0
%205 = load i8*, i8** %204
%206 = call i64 @strcmp(i8* %205, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%207 = icmp eq i64 %206, 0
br i1 %207, label %208, label %209
208: ; preds = %202, %196
br label %192
209: ; preds = %202
%210 = load %struct.dirent*, %struct.dirent** %22
%211 = getelementptr inbounds %struct.dirent, %struct.dirent* %210, i32 0, i32 1
%212 = load i64, i64* %211
%213 = load i64, i64* @DT_REG
%214 = icmp ne i64 %212, %213
br i1 %214, label %215, label %222
215: ; preds = %209
%216 = load %struct.dirent*, %struct.dirent** %22
%217 = getelementptr inbounds %struct.dirent, %struct.dirent* %216, i32 0, i32 1
%218 = load i64, i64* %217
%219 = load i64, i64* @DT_DIR
%220 = icmp ne i64 %218, %219
br i1 %220, label %221, label %222
221: ; preds = %215
br label %192
222: ; preds = %215, %209
%223 = load i32, i32* %23
%224 = icmp eq i32 %223, 1
br i1 %224, label %225, label %228
225: ; preds = %222
%226 = load i8*, i8** %21
%227 = call i32 @strcat(i8* %226, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %238
228: ; preds = %222
%229 = load i8*, i8** %21
%230 = load %struct.dirent*, %struct.dirent** %22
%231 = getelementptr inbounds %struct.dirent, %struct.dirent* %230, i32 0, i32 0
%232 = load i8*, i8** %231
%233 = call i32 @strcat(i8* %229, i8* %232)
%234 = load i8*, i8** %21
%235 = call i32 @strcat(i8* %234, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%236 = load i32, i32* %23
%237 = sub nsw i32 %236, 1
store i32 %237, i32* %23
br label %192
238: ; preds = %225, %192
%239 = load i32*, i32** %19
%240 = call i32 @closedir(i32* %239)
%241 = load i32, i32* %4
%242 = load i8*, i8** %3
%243 = load i8*, i8** %21
%244 = call i64 @strlen(i8* %243)
%245 = load i8*, i8** %21
%246 = call i32 @send_preview_data(i32 %241, i8* %242, i64 %244, i8* %245)
%247 = load i8*, i8** %21
%248 = call i32 @free(i8* %247)
br label %249
249: ; preds = %238, %180
br label %258
250: ; preds = %170
%251 = getelementptr inbounds [1024 x i8], [1024 x i8]* %24, i64 0, i64 0
%252 = load i8*, i8** %3
%253 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %251, i32 1024, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i8* %252)
%254 = load i32, i32* %4
%255 = load i8*, i8** %3
%256 = getelementptr inbounds [1024 x i8], [1024 x i8]* %24, i64 0, i64 0
%257 = call i32 @send_preview_error(i32 %254, i8* %255, i8* %256)
br label %258
258: ; preds = %250, %249
br label %259
259: ; preds = %258, %167
br label %260
260: ; preds = %259, %99
br label %261
261: ; preds = %260, %94
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.TYPE_5__ = type { i32, i8** }
%struct.dirent = type { i8*, i64 }
@stderr = global i32 0
@.str = [36 x i8] c"info: load preview request -- %lld\0A\00"
@.str.1 = [28 x i8] c"error: cannot glob %s -- %s\00"
@errno = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [20 x i8] c" ... and more! ...\0A\00"
@.str.4 = [28 x i8] c"error: cannot open %s -- %s\00"
@.str.5 = [2 x i8] c"r\00"
@.str.6 = [38 x i8] c"error: unable to open directory -- %s\00"
@.str.7 = [2 x i8] c".\00"
@.str.8 = [3 x i8] c"..\00"
@DT_REG = global i64 0
@DT_DIR = global i64 0
@.str.9 = [45 x i8] c"error: path is not a file or directory -- %s\00"
define void @handle_load_preview_request(i8* %0, i32 %1) {
%3 = alloca %struct.stat
%4 = alloca %struct.TYPE_5__
%5 = alloca [1024 x i8]
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
%8 = alloca [1024 x i8]
%9 = alloca [1024 x i8]
%10 = bitcast %struct.stat* %3 to i8*
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %1)
%13 = tail call i64 @is_glob(i8* %0)
%14 = icmp eq i64 %13, 0
br i1 %14, label %57, label %15
15: ; preds = %2
%16 = bitcast %struct.TYPE_5__* %4 to i8*
%17 = call i32 @memset(%struct.TYPE_5__* %4, i32 0, i32 16)
%18 = call i64 @glob(i8* %0, i32 0, i32* null, %struct.TYPE_5__* %4)
%19 = icmp eq i64 %18, 0
br i1 %19, label %26, label %20
20: ; preds = %15
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%22 = load i32, i32* @errno
%23 = call i8* @strerror(i32 %22)
%24 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %21, i32 1024, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %23)
%25 = call i32 @send_preview_error(i32 %1, i8* %0, i8* %21)
br label %56
26: ; preds = %15
%27 = call dereferenceable_or_null(1048576) i8* @malloc(i32 1048576)
store i8 0, i8* %27
%28 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i64 0, i32 0
%29 = load i32, i32* %28
%30 = icmp sgt i32 %29, 0
br i1 %30, label %31, label %51
31: ; preds = %26
%32 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i64 0, i32 1
br label %33
33: ; preds = %31, %33
%34 = phi i64 [ 0, %31 ], [ %41, %33 ]
%35 = phi i32 [ 10, %31 ], [ %42, %33 ]
%36 = load i8**, i8*** %32
%37 = getelementptr inbounds i8*, i8** %36, i64 %34
%38 = load i8*, i8** %37
%39 = call i32 @strcat(i8* %27, i8* %38)
%40 = call i32 @strcat(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%41 = add nuw nsw i64 %34, 1
%42 = add nsw i32 %35, -1
%43 = icmp ugt i32 %35, 1
%44 = load i32, i32* %28
%45 = sext i32 %44 to i64
%46 = icmp slt i64 %41, %45
%47 = select i1 %43, i1 %46, i1 false
br i1 %47, label %33, label %48
48: ; preds = %33
br i1 %46, label %49, label %51
49: ; preds = %48
%50 = call i32 @strcat(i8* %27, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %51
51: ; preds = %26, %49, %48
%52 = call i64 @strlen(i8* %27)
%53 = call i32 @send_preview_data(i32 %1, i8* %0, i64 %52, i8* %27)
%54 = call i32 @globfree(%struct.TYPE_5__* %4)
%55 = call i32 @free(i8* %27)
br label %56
56: ; preds = %51, %20
br label %231
57: ; preds = %2
%58 = call i32 @stat(i8* %0, %struct.stat* %3)
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %66
60: ; preds = %57
%61 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%62 = load i32, i32* @errno
%63 = tail call i8* @strerror(i32 %62)
%64 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %61, i32 1024, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* %63)
%65 = call i32 @send_preview_error(i32 %1, i8* %0, i8* %61)
br label %231
66: ; preds = %57
%67 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%68 = load i32, i32* %67
%69 = tail call i64 @S_ISREG(i32 %68)
%70 = icmp eq i64 %69, 0
br i1 %70, label %173, label %71
71: ; preds = %66
%72 = tail call dereferenceable_or_null(1048576) i8* @malloc(i32 1048576)
%73 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%74 = icmp eq i32* %73, null
br i1 %74, label %75, label %81
75: ; preds = %71
%76 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%77 = load i32, i32* @errno
%78 = tail call i8* @strerror(i32 %77)
%79 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %76, i32 1024, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* %78)
%80 = call i32 @send_preview_error(i32 %1, i8* %0, i8* %76)
br label %171
81: ; preds = %71
%82 = tail call i8* @fgets(i8* %72, i64 1048576, i32* %73)
%83 = icmp eq i8* %82, null
br i1 %83, label %167, label %84
84: ; preds = %81
%85 = tail call i64 @strlen(i8* %82)
%86 = sub i64 1048576, %85
%87 = icmp ugt i64 %86, 1024
br i1 %87, label %88, label %167
88: ; preds = %84
%89 = getelementptr inbounds i8, i8* %72, i64 %85
%90 = tail call i8* @fgets(i8* %89, i64 %86, i32* %73)
%91 = icmp eq i8* %90, null
br i1 %91, label %167, label %92
92: ; preds = %88
%93 = tail call i64 @strlen(i8* %90)
%94 = add i64 %93, %85
%95 = sub i64 1048576, %94
%96 = icmp ugt i64 %95, 1024
br i1 %96, label %97, label %167
97: ; preds = %92
%98 = getelementptr inbounds i8, i8* %72, i64 %94
%99 = tail call i8* @fgets(i8* %98, i64 %95, i32* %73)
%100 = icmp eq i8* %99, null
br i1 %100, label %167, label %101
101: ; preds = %97
%102 = tail call i64 @strlen(i8* %99)
%103 = add i64 %102, %94
%104 = sub i64 1048576, %103
%105 = icmp ugt i64 %104, 1024
br i1 %105, label %106, label %167
106: ; preds = %101
%107 = getelementptr inbounds i8, i8* %72, i64 %103
%108 = tail call i8* @fgets(i8* %107, i64 %104, i32* %73)
%109 = icmp eq i8* %108, null
br i1 %109, label %167, label %110
110: ; preds = %106
%111 = tail call i64 @strlen(i8* %108)
%112 = add i64 %111, %103
%113 = sub i64 1048576, %112
%114 = icmp ugt i64 %113, 1024
br i1 %114, label %115, label %167
115: ; preds = %110
%116 = getelementptr inbounds i8, i8* %72, i64 %112
%117 = tail call i8* @fgets(i8* %116, i64 %113, i32* %73)
%118 = icmp eq i8* %117, null
br i1 %118, label %167, label %119
119: ; preds = %115
%120 = tail call i64 @strlen(i8* %117)
%121 = add i64 %120, %112
%122 = sub i64 1048576, %121
%123 = icmp ugt i64 %122, 1024
br i1 %123, label %124, label %167
124: ; preds = %119
%125 = getelementptr inbounds i8, i8* %72, i64 %121
%126 = tail call i8* @fgets(i8* %125, i64 %122, i32* %73)
%127 = icmp eq i8* %126, null
br i1 %127, label %167, label %128
128: ; preds = %124
%129 = tail call i64 @strlen(i8* %126)
%130 = add i64 %129, %121
%131 = sub i64 1048576, %130
%132 = icmp ugt i64 %131, 1024
br i1 %132, label %133, label %167
133: ; preds = %128
%134 = getelementptr inbounds i8, i8* %72, i64 %130
%135 = tail call i8* @fgets(i8* %134, i64 %131, i32* %73)
%136 = icmp eq i8* %135, null
br i1 %136, label %167, label %137
137: ; preds = %133
%138 = tail call i64 @strlen(i8* %135)
%139 = add i64 %138, %130
%140 = sub i64 1048576, %139
%141 = icmp ugt i64 %140, 1024
br i1 %141, label %142, label %167
142: ; preds = %137
%143 = getelementptr inbounds i8, i8* %72, i64 %139
%144 = tail call i8* @fgets(i8* %143, i64 %140, i32* %73)
%145 = icmp eq i8* %144, null
br i1 %145, label %167, label %146
146: ; preds = %142
%147 = tail call i64 @strlen(i8* %144)
%148 = add i64 %147, %139
%149 = sub i64 1048576, %148
%150 = icmp ugt i64 %149, 1024
br i1 %150, label %151, label %167
151: ; preds = %146
%152 = getelementptr inbounds i8, i8* %72, i64 %148
%153 = tail call i8* @fgets(i8* %152, i64 %149, i32* %73)
%154 = icmp eq i8* %153, null
br i1 %154, label %167, label %155
155: ; preds = %151
%156 = tail call i64 @strlen(i8* %153)
%157 = add i64 %156, %148
%158 = sub i64 1048576, %157
%159 = icmp ugt i64 %158, 1024
br i1 %159, label %160, label %167
160: ; preds = %155
%161 = getelementptr inbounds i8, i8* %72, i64 %157
%162 = tail call i8* @fgets(i8* %161, i64 %158, i32* %73)
%163 = icmp eq i8* %162, null
br i1 %163, label %167, label %164
164: ; preds = %160
%165 = tail call i64 @strlen(i8* %162)
%166 = add i64 %165, %157
br label %167
167: ; preds = %164, %160, %155, %151, %146, %142, %137, %133, %128, %124, %119, %115, %110, %106, %101, %97, %92, %88, %84, %81
%168 = phi i64 [ 0, %81 ], [ %85, %84 ], [ %85, %88 ], [ %94, %92 ], [ %94, %97 ], [ %103, %101 ], [ %103, %106 ], [ %112, %110 ], [ %112, %115 ], [ %121, %119 ], [ %121, %124 ], [ %130, %128 ], [ %130, %133 ], [ %139, %137 ], [ %139, %142 ], [ %148, %146 ], [ %148, %151 ], [ %157, %155 ], [ %157, %160 ], [ %166, %164 ]
%169 = tail call i32 @fclose(i32* %73)
%170 = tail call i32 @send_preview_data(i32 %1, i8* %0, i64 %168, i8* %72)
br label %171
171: ; preds = %167, %75
%172 = call i32 @free(i8* %72)
br label %231
173: ; preds = %66
%174 = tail call i64 @S_ISDIR(i32 %68)
%175 = icmp eq i64 %174, 0
br i1 %175, label %227, label %176
176: ; preds = %173
%177 = tail call i32* @opendir(i8* %0)
%178 = icmp eq i32* %177, null
br i1 %178, label %179, label %183
179: ; preds = %176
%180 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%181 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %180, i32 1024, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0), i8* %0)
%182 = call i32 @send_preview_error(i32 %1, i8* %0, i8* %180)
br label %231
183: ; preds = %176
%184 = tail call dereferenceable_or_null(1048576) i8* @malloc(i32 1048576)
store i8 0, i8* %184
%185 = tail call %struct.dirent* @readdir(i32* %177)
%186 = icmp eq %struct.dirent* %185, null
br i1 %186, label %222, label %187
187: ; preds = %183, %215
%188 = phi %struct.dirent* [ %220, %215 ], [ %185, %183 ]
%189 = phi i32 [ %219, %215 ], [ 10, %183 ]
br label %190
190: ; preds = %187, %200
%191 = phi %struct.dirent* [ %188, %187 ], [ %201, %200 ]
%192 = getelementptr inbounds %struct.dirent, %struct.dirent* %191, i64 0, i32 0
%193 = load i8*, i8** %192
%194 = tail call i64 @strcmp(i8* %193, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%195 = icmp eq i64 %194, 0
br i1 %195, label %200, label %196
196: ; preds = %190
%197 = load i8*, i8** %192
%198 = tail call i64 @strcmp(i8* %197, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%199 = icmp eq i64 %198, 0
br i1 %199, label %200, label %203
200: ; preds = %190, %196, %203
%201 = tail call %struct.dirent* @readdir(i32* %177)
%202 = icmp eq %struct.dirent* %201, null
br i1 %202, label %222, label %190
203: ; preds = %196
%204 = getelementptr inbounds %struct.dirent, %struct.dirent* %191, i64 0, i32 1
%205 = load i64, i64* %204
%206 = load i64, i64* @DT_REG
%207 = icmp eq i64 %205, %206
%208 = load i64, i64* @DT_DIR
%209 = icmp eq i64 %205, %208
%210 = select i1 %207, i1 true, i1 %209
br i1 %210, label %211, label %200
211: ; preds = %203
%212 = icmp eq i32 %189, 1
br i1 %212, label %213, label %215
213: ; preds = %211
%214 = tail call i32 @strcat(i8* %184, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
br label %222
215: ; preds = %211
%216 = load i8*, i8** %192
%217 = tail call i32 @strcat(i8* %184, i8* %216)
%218 = tail call i32 @strcat(i8* %184, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%219 = add nsw i32 %189, -1
%220 = tail call %struct.dirent* @readdir(i32* %177)
%221 = icmp eq %struct.dirent* %220, null
br i1 %221, label %222, label %187
222: ; preds = %215, %200, %183, %213
%223 = tail call i32 @closedir(i32* %177)
%224 = tail call i64 @strlen(i8* %184)
%225 = tail call i32 @send_preview_data(i32 %1, i8* %0, i64 %224, i8* %184)
%226 = tail call i32 @free(i8* %184)
br label %231
227: ; preds = %173
%228 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%229 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %228, i32 1024, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i8* %0)
%230 = call i32 @send_preview_error(i32 %1, i8* %0, i8* %228)
br label %231
231: ; preds = %179, %222, %60, %227, %171, %56
ret void
}