#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 stat {
  int st_mode;
};
struct match {
  int dummy;
};
struct dirent {
  size_t d_reclen;
  char const *d_name;
  int d_type;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int EACCES;
int ENOTDIR;
int FNM_NOESCAPE;
int FNM_PERIOD;
int GLOB_ABORTED;
int GLOB_ERR;
int GLOB_MARK;
int GLOB_NOESCAPE;
int GLOB_NOSPACE;
int /*<<< orphan*/ NAME_MAX;
int S_ISDIR(int);
int /*<<< orphan*/ S_ISLNK(int);
scalar_t__ __glob_append(struct match **, char const *, size_t, int);
int __glob_is_literal(char const *, int);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int errno;
scalar_t__ fnmatch(char const *, char const *, int);
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
int /*<<< orphan*/ *opendir(char const *);
int readdir_r(int /*<<< orphan*/ *, void *, struct dirent **);
int /*<<< orphan*/ stat(char const *, struct stat *);
char *strchr(char const *, char);
scalar_t__ strcmp(char const *, char const *);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
int __glob_match_in_dir(const char *d, const char *p, int flags,
                        int (*errfunc)(const char *path, int err),
                        struct match **tail) {
  DIR *dir;
  long long de_buf[(sizeof(struct dirent) + NAME_MAX + sizeof(long long)) /
                   sizeof(long long)];
  struct dirent *de;
  char pat[strlen(p) + 1];
  char *p2;
  size_t l = strlen(d);
  int literal;
  int fnm_flags = ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0) | FNM_PERIOD;
  int error;
  if ((p2 = strchr(p, '/'))) {
    strcpy(pat, p);
    pat[p2 - p] = 0;
    for (; *p2 == '/'; p2++)
      ;
    p = pat;
  }
  literal = __glob_is_literal(p, !(flags & GLOB_NOESCAPE));
  if (*d == '/' && !*(d + 1))
    l = 0;
  dir = opendir(*d ? d : ".");
  error = errno;
  if (!dir) {
    if (error == ENOTDIR)
      return 0;
    if (error == EACCES && !*p) {
      struct stat st;
      if (!stat(d, &st) && S_ISDIR(st.st_mode)) {
        if (__glob_append(tail, d, l, l))
          return GLOB_NOSPACE;
        return 0;
      }
    }
    if (errfunc(d, error) || (flags & GLOB_ERR))
      return GLOB_ABORTED;
    return 0;
  }
  if (!*p) {
    error = __glob_append(tail, d, l, l) ? GLOB_NOSPACE : 0;
    closedir(dir);
    return error;
  }
  while (!(error = readdir_r(dir, (void *)de_buf, &de)) && de) {
    char namebuf[l + de->d_reclen + 2], *name = namebuf;
    if (!literal && fnmatch(p, de->d_name, fnm_flags))
      continue;
    if (literal && strcmp(p, de->d_name))
      continue;
    if (p2 && de->d_type && !S_ISDIR(de->d_type << 12) &&
        !S_ISLNK(de->d_type << 12))
      continue;
    if (*d) {
      memcpy(name, d, l);
      name[l] = '/';
      strcpy(name + l + 1, de->d_name);
    } else {
      name = de->d_name;
    }
    if (p2) {
      if ((error = __glob_match_in_dir(name, p2, flags, errfunc, tail))) {
        closedir(dir);
        return error;
      }
    } else {
      int mark = 0;
      if (flags & GLOB_MARK) {
        if (de->d_type)
          mark = S_ISDIR(de->d_type << 12);
        else {
          struct stat st;
          stat(name, &st);
          mark = S_ISDIR(st.st_mode);
        }
      }
      if (__glob_append(tail, name, l + de->d_reclen + 1, mark)) {
        closedir(dir);
        return GLOB_NOSPACE;
      }
    }
  }
  closedir(dir);
  if (error && (errfunc(d, error) || (flags & GLOB_ERR)))
    return GLOB_ABORTED;
  return 0;
}


x86 assembly (clang, -O0):
<__glob_match_in_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    0x2d73(%rip),%rax
movslq (%rax),%rax
add    $0x20,%rax
shr    $0x3,%rax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xb0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <strlen@plt>
add    $0x1,%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <strlen@plt>
cltq
mov    %rax,-0x68(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2d45(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12aa <__glob_match_in_dir+0xba>
mov    0x2d5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xb4(%rbp)
jmp    12b7 <__glob_match_in_dir+0xc7>
xor    %eax,%eax
mov    %eax,-0xb4(%rbp)
jmp    12b7 <__glob_match_in_dir+0xc7>
mov    -0xb4(%rbp),%eax
mov    0x2ce4(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x70(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2f,%esi
call   10a0 <strchr@plt>
mov    %rax,-0x60(%rbp)
cmp    $0x0,%rax
je     133c <__glob_match_in_dir+0x14c>
mov    -0xa8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0xa8(%rbp),%rax
mov    -0x60(%rbp),%rcx
mov    -0x18(%rbp),%rdx
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x60(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1331 <__glob_match_in_dir+0x141>
jmp    1320 <__glob_match_in_dir+0x130>
mov    -0x60(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x60(%rbp)
jmp    130b <__glob_match_in_dir+0x11b>
mov    -0xa8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%eax
mov    0x2c86(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%esi
call   1040 <__glob_is_literal@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1387 <__glob_match_in_dir+0x197>
mov    -0x10(%rbp),%rax
cmpb   $0x0,0x1(%rax)
jne    1387 <__glob_match_in_dir+0x197>
movq   $0x0,-0x68(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     13a7 <__glob_match_in_dir+0x1b7>
mov    -0x10(%rbp),%rax
mov    %rax,-0xc0(%rbp)
jmp    13ba <__glob_match_in_dir+0x1ca>
lea    0xc52(%rip),%rax
mov    %rax,-0xc0(%rbp)
jmp    13ba <__glob_match_in_dir+0x1ca>
mov    -0xc0(%rbp),%rdi
call   1070 <opendir@plt>
mov    %rax,-0x38(%rbp)
mov    0x2bcf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    14f3 <__glob_match_in_dir+0x303>
mov    -0x74(%rbp),%eax
mov    0x2c05(%rip),%rcx
cmp    (%rcx),%eax
jne    1406 <__glob_match_in_dir+0x216>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x78(%rbp)
jmp    18c5 <__glob_match_in_dir+0x6d5>
mov    -0x74(%rbp),%eax
mov    0x2ba8(%rip),%rcx
cmp    (%rcx),%eax
jne    149d <__glob_match_in_dir+0x2ad>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    149d <__glob_match_in_dir+0x2ad>
mov    -0x10(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   10f0 <stat@plt>
cmp    $0x0,%eax
jne    1498 <__glob_match_in_dir+0x2a8>
mov    -0x80(%rbp),%edi
call   10b0 <S_ISDIR@plt>
cmp    $0x0,%eax
je     1498 <__glob_match_in_dir+0x2a8>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    -0x68(%rbp),%rax
mov    %eax,%ecx
call   1090 <__glob_append@plt>
cmp    $0x0,%rax
je     1485 <__glob_match_in_dir+0x295>
mov    0x2b4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x78(%rbp)
jmp    18c5 <__glob_match_in_dir+0x6d5>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x78(%rbp)
jmp    18c5 <__glob_match_in_dir+0x6d5>
jmp    149d <__glob_match_in_dir+0x2ad>
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x74(%rbp),%esi
call   *%rax
cmp    $0x0,%eax
jne    14c8 <__glob_match_in_dir+0x2d8>
mov    -0x1c(%rbp),%eax
mov    0x2b23(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     14e0 <__glob_match_in_dir+0x2f0>
mov    0x2ac9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x78(%rbp)
jmp    18c5 <__glob_match_in_dir+0x6d5>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x78(%rbp)
jmp    18c5 <__glob_match_in_dir+0x6d5>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1566 <__glob_match_in_dir+0x376>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    -0x68(%rbp),%rax
mov    %eax,%ecx
call   1090 <__glob_append@plt>
cmp    $0x0,%rax
je     1535 <__glob_match_in_dir+0x345>
mov    0x2a98(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc4(%rbp)
jmp    1542 <__glob_match_in_dir+0x352>
xor    %eax,%eax
mov    %eax,-0xc4(%rbp)
jmp    1542 <__glob_match_in_dir+0x352>
mov    -0xc4(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x38(%rbp),%rdi
call   10d0 <closedir@plt>
mov    -0x74(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x78(%rbp)
jmp    18c5 <__glob_match_in_dir+0x6d5>
jmp    156b <__glob_match_in_dir+0x37b>
mov    -0xb0(%rbp),%rsi
mov    -0x38(%rbp),%rdi
lea    -0x50(%rbp),%rdx
call   1060 <readdir_r@plt>
mov    %eax,%ecx
mov    %ecx,-0x74(%rbp)
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xc5(%rbp)
jne    15a3 <__glob_match_in_dir+0x3b3>
cmpq   $0x0,-0x50(%rbp)
setne  %al
mov    %al,-0xc5(%rbp)
mov    -0xc5(%rbp),%al
test   $0x1,%al
jne    15b6 <__glob_match_in_dir+0x3c6>
jmp    1861 <__glob_match_in_dir+0x671>
mov    -0x68(%rbp),%rax
mov    -0x50(%rbp),%rcx
mov    (%rcx),%rdx
lea    0x2(%rax,%rdx,1),%rcx
mov    %rsp,%rsi
mov    %rsi,-0x88(%rbp)
lea    0x11(%rax,%rdx,1),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,%rsp
mov    %rcx,-0x90(%rbp)
mov    %rax,-0x98(%rbp)
cmpl   $0x0,-0x6c(%rbp)
jne    1624 <__glob_match_in_dir+0x434>
mov    -0x18(%rbp),%rdi
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x70(%rbp),%edx
call   10c0 <fnmatch@plt>
cmp    $0x0,%rax
je     1624 <__glob_match_in_dir+0x434>
movl   $0x5,-0x78(%rbp)
jmp    1828 <__glob_match_in_dir+0x638>
cmpl   $0x0,-0x6c(%rbp)
je     1655 <__glob_match_in_dir+0x465>
mov    -0x18(%rbp),%rdi
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%rsi
call   10e0 <strcmp@plt>
cmp    $0x0,%rax
je     1655 <__glob_match_in_dir+0x465>
movl   $0x5,-0x78(%rbp)
jmp    1828 <__glob_match_in_dir+0x638>
cmpq   $0x0,-0x60(%rbp)
je     16aa <__glob_match_in_dir+0x4ba>
mov    -0x50(%rbp),%rax
cmpl   $0x0,0x10(%rax)
je     16aa <__glob_match_in_dir+0x4ba>
mov    -0x50(%rbp),%rax
mov    0x10(%rax),%edi
shl    $0xc,%edi
call   10b0 <S_ISDIR@plt>
cmp    $0x0,%eax
jne    16aa <__glob_match_in_dir+0x4ba>
mov    -0x50(%rbp),%rax
mov    0x10(%rax),%edi
shl    $0xc,%edi
call   1050 <S_ISLNK@plt>
cmp    $0x0,%eax
jne    16aa <__glob_match_in_dir+0x4ba>
movl   $0x5,-0x78(%rbp)
jmp    1828 <__glob_match_in_dir+0x638>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     16fb <__glob_match_in_dir+0x50b>
mov    -0x98(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x68(%rbp),%rdx
call   1100 <memcpy@plt>
mov    -0x98(%rbp),%rax
mov    -0x68(%rbp),%rcx
movb   $0x2f,(%rax,%rcx,1)
mov    -0x98(%rbp),%rdi
add    -0x68(%rbp),%rdi
add    $0x1,%rdi
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
jmp    170a <__glob_match_in_dir+0x51a>
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     175c <__glob_match_in_dir+0x56c>
mov    -0x98(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
call   1110 <__glob_match_in_dir@plt>
mov    %eax,-0x74(%rbp)
cmp    $0x0,%eax
je     1757 <__glob_match_in_dir+0x567>
mov    -0x38(%rbp),%rdi
call   10d0 <closedir@plt>
mov    -0x74(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x78(%rbp)
jmp    1828 <__glob_match_in_dir+0x638>
jmp    1821 <__glob_match_in_dir+0x631>
movl   $0x0,-0x9c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2858(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     17cc <__glob_match_in_dir+0x5dc>
mov    -0x50(%rbp),%rax
cmpl   $0x0,0x10(%rax)
je     17a3 <__glob_match_in_dir+0x5b3>
mov    -0x50(%rbp),%rax
mov    0x10(%rax),%edi
shl    $0xc,%edi
call   10b0 <S_ISDIR@plt>
mov    %eax,-0x9c(%rbp)
jmp    17c7 <__glob_match_in_dir+0x5d7>
mov    -0x98(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   10f0 <stat@plt>
mov    -0xa0(%rbp),%edi
call   10b0 <S_ISDIR@plt>
mov    %eax,-0x9c(%rbp)
jmp    17cc <__glob_match_in_dir+0x5dc>
mov    -0x30(%rbp),%rdi
mov    -0x98(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    -0x50(%rbp),%rax
add    (%rax),%rdx
add    $0x1,%rdx
mov    -0x9c(%rbp),%ecx
call   1090 <__glob_append@plt>
cmp    $0x0,%rax
je     181c <__glob_match_in_dir+0x62c>
mov    -0x38(%rbp),%rdi
call   10d0 <closedir@plt>
mov    0x27b5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x78(%rbp)
jmp    1828 <__glob_match_in_dir+0x638>
jmp    1821 <__glob_match_in_dir+0x631>
movl   $0x0,-0x78(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,%rsp
mov    -0x78(%rbp),%eax
mov    %eax,-0xcc(%rbp)
test   %eax,%eax
je     185c <__glob_match_in_dir+0x66c>
jmp    1848 <__glob_match_in_dir+0x658>
mov    -0xcc(%rbp),%eax
sub    $0x5,%eax
je     156b <__glob_match_in_dir+0x37b>
jmp    18c5 <__glob_match_in_dir+0x6d5>
jmp    156b <__glob_match_in_dir+0x37b>
mov    -0x38(%rbp),%rdi
call   10d0 <closedir@plt>
cmpl   $0x0,-0x74(%rbp)
je     18b7 <__glob_match_in_dir+0x6c7>
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rdi
mov    -0x74(%rbp),%esi
call   *%rax
cmp    $0x0,%eax
jne    189f <__glob_match_in_dir+0x6af>
mov    -0x1c(%rbp),%eax
mov    0x274c(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     18b7 <__glob_match_in_dir+0x6c7>
mov    0x26f2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x78(%rbp)
jmp    18c5 <__glob_match_in_dir+0x6d5>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x78(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__glob_match_in_dir>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r8,-0x48(%rbp)
mov    %rcx,-0x50(%rbp)
mov    %edx,-0x2c(%rbp)
mov    %rsi,%r15
mov    %rdi,%rbx
mov    0x2d6f(%rip),%rax
movslq (%rax),%rax
add    $0x20,%rax
and    $0xfffffffffffffff8,%rax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x78(%rbp)
mov    %rcx,%rsp
mov    %rsi,%rdi
call   1080 <strlen@plt>
add    $0x1,%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    %rbx,-0x58(%rbp)
mov    %rbx,%rdi
call   1080 <strlen@plt>
mov    %eax,-0x40(%rbp)
mov    0x2d65(%rip),%rax
xor    %r12d,%r12d
mov    (%rax),%r14d
mov    $0x0,%ecx
and    -0x2c(%rbp),%r14d
je     1285 <__glob_match_in_dir+0x95>
mov    0x2d75(%rip),%rax
mov    (%rax),%ecx
mov    0x2d1c(%rip),%rax
or     (%rax),%ecx
mov    %ecx,-0x64(%rbp)
mov    %r15,%rdi
mov    $0x2f,%esi
call   10a0 <strchr@plt>
test   %rax,%rax
je     12ed <__glob_match_in_dir+0xfd>
mov    %rax,%rbx
mov    %r13,%rdi
mov    %r15,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rax
sub    %r15,%rax
movb   $0x0,0x0(%r13,%rax,1)
add    $0xffffffffffffffff,%rbx
mov    %rbx,%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpb   $0x2f,0x1(%r12)
lea    0x1(%r12),%r12
je     12d0 <__glob_match_in_dir+0xe0>
mov    0x2cec(%rip),%rax
mov    (%rax),%r14d
and    -0x2c(%rbp),%r14d
jmp    12f0 <__glob_match_in_dir+0x100>
mov    %r15,%r13
movslq -0x40(%rbp),%r15
xor    %esi,%esi
test   %r14d,%r14d
sete   %sil
mov    %r13,%rdi
call   1040 <__glob_is_literal@plt>
mov    %eax,-0x68(%rbp)
mov    -0x58(%rbp),%rbx
mov    (%rbx),%al
cmp    $0x2f,%al
jne    131c <__glob_match_in_dir+0x12c>
xor    %ecx,%ecx
cmpb   $0x0,0x1(%rbx)
cmove  %rcx,%r15
test   %al,%al
lea    0xcdb(%rip),%rdi
cmovne %rbx,%rdi
call   1070 <opendir@plt>
mov    %rax,-0x40(%rbp)
test   %rax,%rax
je     1538 <__glob_match_in_dir+0x348>
cmpb   $0x0,0x0(%r13)
je     159f <__glob_match_in_dir+0x3af>
mov    %r15,-0x70(%rbp)
mov    %r13,%r15
lea    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rdi
mov    -0x78(%rbp),%rsi
call   1060 <readdir_r@plt>
mov    %eax,%ebx
test   %eax,%eax
sete   %r13b
jne    151b <__glob_match_in_dir+0x32b>
mov    -0x38(%rbp),%rax
test   %rax,%rax
je     151b <__glob_match_in_dir+0x32b>
mov    -0x70(%rbp),%rcx
lea    0x2(%rcx),%rdx
mov    %rdx,-0x88(%rbp)
add    $0x1,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rsp,%r13
mov    (%rax),%rax
mov    -0x88(%rbp),%rcx
add    %rcx,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rsi
cmpl   $0x0,-0x68(%rbp)
je     13e0 <__glob_match_in_dir+0x1f0>
mov    %r15,%rdi
call   10e0 <strcmp@plt>
test   %rax,%rax
jne    14f0 <__glob_match_in_dir+0x300>
jmp    13f4 <__glob_match_in_dir+0x204>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    -0x64(%rbp),%edx
call   10c0 <fnmatch@plt>
test   %rax,%rax
jne    14f0 <__glob_match_in_dir+0x300>
test   %r12,%r12
je     1430 <__glob_match_in_dir+0x240>
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%edi
test   %edi,%edi
je     1430 <__glob_match_in_dir+0x240>
shl    $0xc,%edi
call   10b0 <S_ISDIR@plt>
test   %eax,%eax
jne    1430 <__glob_match_in_dir+0x240>
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%edi
shl    $0xc,%edi
call   1050 <S_ISLNK@plt>
test   %eax,%eax
je     14f0 <__glob_match_in_dir+0x300>
nopw   0x0(%rax,%rax,1)
mov    -0x58(%rbp),%rsi
cmpb   $0x0,(%rsi)
je     1486 <__glob_match_in_dir+0x296>
mov    %r14,%rdi
mov    -0x70(%rbp),%rbx
mov    %rbx,%rdx
call   1100 <memcpy@plt>
movb   $0x2f,(%r14,%rbx,1)
lea    (%r14,%rbx,1),%rdi
add    $0x1,%rdi
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
test   %r12,%r12
je     1493 <__glob_match_in_dir+0x2a3>
mov    %r14,%rdi
mov    %r12,%rsi
mov    -0x2c(%rbp),%edx
mov    -0x50(%rbp),%rcx
mov    -0x48(%rbp),%r8
call   1110 <__glob_match_in_dir@plt>
test   %eax,%eax
je     14f0 <__glob_match_in_dir+0x300>
jmp    15de <__glob_match_in_dir+0x3ee>
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%r14
test   %r12,%r12
jne    1467 <__glob_match_in_dir+0x277>
mov    -0x2c(%rbp),%eax
mov    0x2b2b(%rip),%rcx
test   %eax,(%rcx)
je     14b1 <__glob_match_in_dir+0x2c1>
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%edi
test   %edi,%edi
je     14b5 <__glob_match_in_dir+0x2c5>
shl    $0xc,%edi
jmp    14c4 <__glob_match_in_dir+0x2d4>
xor    %ecx,%ecx
jmp    14cb <__glob_match_in_dir+0x2db>
mov    %r14,%rdi
lea    -0x60(%rbp),%rsi
call   10f0 <stat@plt>
mov    -0x60(%rbp),%edi
call   10b0 <S_ISDIR@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
mov    (%rax),%rdx
add    -0x80(%rbp),%rdx
mov    -0x48(%rbp),%rdi
mov    %r14,%rsi
call   1090 <__glob_append@plt>
test   %rax,%rax
jne    15ef <__glob_match_in_dir+0x3ff>
nopl   0x0(%rax,%rax,1)
mov    %r13,%rsp
mov    -0x40(%rbp),%rdi
mov    -0x78(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1060 <readdir_r@plt>
mov    %eax,%ebx
test   %eax,%eax
sete   %r13b
jne    151b <__glob_match_in_dir+0x32b>
mov    -0x38(%rbp),%rax
test   %rax,%rax
jne    1390 <__glob_match_in_dir+0x1a0>
mov    -0x40(%rbp),%rdi
call   10d0 <closedir@plt>
xor    %r14d,%r14d
test   %r13b,%r13b
jne    15cc <__glob_match_in_dir+0x3dc>
mov    -0x58(%rbp),%rdi
mov    %ebx,%esi
jmp    157e <__glob_match_in_dir+0x38e>
mov    0x2a61(%rip),%rax
mov    (%rax),%r12d
mov    0x2aa7(%rip),%rax
xor    %r14d,%r14d
cmp    (%rax),%r12d
je     15cc <__glob_match_in_dir+0x3dc>
mov    0x2a60(%rip),%rax
cmp    (%rax),%r12d
jne    1578 <__glob_match_in_dir+0x388>
cmpb   $0x0,0x0(%r13)
jne    1578 <__glob_match_in_dir+0x388>
lea    -0x38(%rbp),%rsi
mov    %rbx,%rdi
call   10f0 <stat@plt>
test   %eax,%eax
je     1607 <__glob_match_in_dir+0x417>
mov    %rbx,%rdi
mov    %r12d,%esi
call   *-0x50(%rbp)
test   %eax,%eax
jne    1593 <__glob_match_in_dir+0x3a3>
mov    0x2a54(%rip),%rax
mov    -0x2c(%rbp),%ecx
test   %ecx,(%rax)
je     15cc <__glob_match_in_dir+0x3dc>
mov    0x29fe(%rip),%rax
mov    (%rax),%r14d
jmp    15cc <__glob_match_in_dir+0x3dc>
mov    -0x48(%rbp),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r15d,%ecx
call   1090 <__glob_append@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     15c3 <__glob_match_in_dir+0x3d3>
mov    0x2a00(%rip),%rax
mov    (%rax),%r14d
mov    -0x40(%rbp),%rdi
call   10d0 <closedir@plt>
mov    %r14d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%r14d
mov    -0x40(%rbp),%rdi
call   10d0 <closedir@plt>
mov    %r13,%rsp
jmp    15cc <__glob_match_in_dir+0x3dc>
mov    -0x40(%rbp),%rdi
call   10d0 <closedir@plt>
mov    0x29c1(%rip),%rax
mov    (%rax),%r14d
mov    %r13,%rsp
jmp    15cc <__glob_match_in_dir+0x3dc>
mov    -0x38(%rbp),%edi
call   10b0 <S_ISDIR@plt>
test   %eax,%eax
je     1578 <__glob_match_in_dir+0x388>
mov    -0x48(%rbp),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r15d,%ecx
call   1090 <__glob_append@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     15cc <__glob_match_in_dir+0x3dc>
mov    0x2988(%rip),%rax
jmp    159a <__glob_match_in_dir+0x3aa>

LLVM IR (-O0):
%struct.match = type { i32 }
%struct.dirent = type { i64, i8*, i32 }
%struct.stat = type { i32 }
@NAME_MAX = global i32 0
@GLOB_NOESCAPE = global i32 0
@FNM_NOESCAPE = global i32 0
@FNM_PERIOD = global i32 0
@.str = [2 x i8] c".\00"
@errno = global i32 0
@ENOTDIR = global i32 0
@EACCES = global i32 0
@GLOB_NOSPACE = global i32 0
@GLOB_ERR = global i32 0
@GLOB_ABORTED = global i32 0
@GLOB_MARK = global i32 0
define i32 @__glob_match_in_dir(i8* %0, i8* %1, i32 %2, i32 (i8*, i32)* %3, %struct.match** %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32 (i8*, i32)*
%11 = alloca %struct.match**
%12 = alloca i32*
%13 = alloca i8*
%14 = alloca i64
%15 = alloca %struct.dirent*
%16 = alloca i64
%17 = alloca i8*
%18 = alloca i64
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca %struct.stat
%24 = alloca i8*
%25 = alloca i64
%26 = alloca i8*
%27 = alloca i32
%28 = alloca %struct.stat
store i8* %0, i8** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i32 (i8*, i32)* %3, i32 (i8*, i32)** %10
store %struct.match** %4, %struct.match*** %11
%29 = load i32, i32* @NAME_MAX
%30 = sext i32 %29 to i64
%31 = add i64 24, %30
%32 = add i64 %31, 8
%33 = udiv i64 %32, 8
%34 = call i8* @llvm.stacksave()
store i8* %34, i8** %13
%35 = alloca i64, i64 %33
store i64 %33, i64* %14
%36 = load i8*, i8** %8
%37 = call i32 @strlen(i8* %36)
%38 = add nsw i32 %37, 1
%39 = zext i32 %38 to i64
%40 = alloca i8, i64 %39
store i64 %39, i64* %16
%41 = load i8*, i8** %7
%42 = call i32 @strlen(i8* %41)
%43 = sext i32 %42 to i64
store i64 %43, i64* %18
%44 = load i32, i32* %9
%45 = load i32, i32* @GLOB_NOESCAPE
%46 = and i32 %44, %45
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %5
%49 = load i32, i32* @FNM_NOESCAPE
br label %51
50: ; preds = %5
br label %51
51: ; preds = %50, %48
%52 = phi i32 [ %49, %48 ], [ 0, %50 ]
%53 = load i32, i32* @FNM_PERIOD
%54 = or i32 %52, %53
store i32 %54, i32* %20
%55 = load i8*, i8** %8
%56 = call i8* @strchr(i8* %55, i8 signext 47)
store i8* %56, i8** %17
%57 = icmp ne i8* %56, null
br i1 %57, label %58, label %77
58: ; preds = %51
%59 = load i8*, i8** %8
%60 = call i32 @strcpy(i8* %40, i8* %59)
%61 = load i8*, i8** %17
%62 = load i8*, i8** %8
%63 = ptrtoint i8* %61 to i64
%64 = ptrtoint i8* %62 to i64
%65 = sub i64 %63, %64
%66 = getelementptr inbounds i8, i8* %40, i64 %65
store i8 0, i8* %66
br label %67
67: ; preds = %73, %58
%68 = load i8*, i8** %17
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = icmp eq i32 %70, 47
br i1 %71, label %72, label %76
72: ; preds = %67
br label %73
73: ; preds = %72
%74 = load i8*, i8** %17
%75 = getelementptr inbounds i8, i8* %74, i32 1
store i8* %75, i8** %17
br label %67
76: ; preds = %67
store i8* %40, i8** %8
br label %77
77: ; preds = %76, %51
%78 = load i8*, i8** %8
%79 = load i32, i32* %9
%80 = load i32, i32* @GLOB_NOESCAPE
%81 = and i32 %79, %80
%82 = icmp ne i32 %81, 0
%83 = xor i1 %82, true
%84 = zext i1 %83 to i32
%85 = call i32 @__glob_is_literal(i8* %78, i32 %84)
store i32 %85, i32* %19
%86 = load i8*, i8** %7
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = icmp eq i32 %88, 47
br i1 %89, label %90, label %96
90: ; preds = %77
%91 = load i8*, i8** %7
%92 = getelementptr inbounds i8, i8* %91, i64 1
%93 = load i8, i8* %92
%94 = icmp ne i8 %93, 0
br i1 %94, label %96, label %95
95: ; preds = %90
store i64 0, i64* %18
br label %96
96: ; preds = %95, %90, %77
%97 = load i8*, i8** %7
%98 = load i8, i8* %97
%99 = sext i8 %98 to i32
%100 = icmp ne i32 %99, 0
br i1 %100, label %101, label %103
101: ; preds = %96
%102 = load i8*, i8** %7
br label %104
103: ; preds = %96
br label %104
104: ; preds = %103, %101
%105 = phi i8* [ %102, %101 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %103 ]
%106 = call i32* @opendir(i8* %105)
store i32* %106, i32** %12
%107 = load i32, i32* @errno
store i32 %107, i32* %21
%108 = load i32*, i32** %12
%109 = icmp ne i32* %108, null
br i1 %109, label %158, label %110
110: ; preds = %104
%111 = load i32, i32* %21
%112 = load i32, i32* @ENOTDIR
%113 = icmp eq i32 %111, %112
br i1 %113, label %114, label %115
114: ; preds = %110
store i32 0, i32* %6
store i32 1, i32* %22
br label %347
115: ; preds = %110
%116 = load i32, i32* %21
%117 = load i32, i32* @EACCES
%118 = icmp eq i32 %116, %117
br i1 %118, label %119, label %144
119: ; preds = %115
%120 = load i8*, i8** %8
%121 = load i8, i8* %120
%122 = icmp ne i8 %121, 0
br i1 %122, label %144, label %123
123: ; preds = %119
%124 = load i8*, i8** %7
%125 = call i32 @stat(i8* %124, %struct.stat* %23)
%126 = icmp ne i32 %125, 0
br i1 %126, label %143, label %127
127: ; preds = %123
%128 = getelementptr inbounds %struct.stat, %struct.stat* %23, i32 0, i32 0
%129 = load i32, i32* %128
%130 = call i32 @S_ISDIR(i32 %129)
%131 = icmp ne i32 %130, 0
br i1 %131, label %132, label %143
132: ; preds = %127
%133 = load %struct.match**, %struct.match*** %11
%134 = load i8*, i8** %7
%135 = load i64, i64* %18
%136 = load i64, i64* %18
%137 = trunc i64 %136 to i32
%138 = call i64 @__glob_append(%struct.match** %133, i8* %134, i64 %135, i32 %137)
%139 = icmp ne i64 %138, 0
br i1 %139, label %140, label %142
140: ; preds = %132
%141 = load i32, i32* @GLOB_NOSPACE
store i32 %141, i32* %6
store i32 1, i32* %22
br label %347
142: ; preds = %132
store i32 0, i32* %6
store i32 1, i32* %22
br label %347
143: ; preds = %127, %123
br label %144
144: ; preds = %143, %119, %115
%145 = load i32 (i8*, i32)*, i32 (i8*, i32)** %10
%146 = load i8*, i8** %7
%147 = load i32, i32* %21
%148 = call i32 %145(i8* %146, i32 %147)
%149 = icmp ne i32 %148, 0
br i1 %149, label %155, label %150
150: ; preds = %144
%151 = load i32, i32* %9
%152 = load i32, i32* @GLOB_ERR
%153 = and i32 %151, %152
%154 = icmp ne i32 %153, 0
br i1 %154, label %155, label %157
155: ; preds = %150, %144
%156 = load i32, i32* @GLOB_ABORTED
store i32 %156, i32* %6
store i32 1, i32* %22
br label %347
157: ; preds = %150
store i32 0, i32* %6
store i32 1, i32* %22
br label %347
158: ; preds = %104
%159 = load i8*, i8** %8
%160 = load i8, i8* %159
%161 = icmp ne i8 %160, 0
br i1 %161, label %178, label %162
162: ; preds = %158
%163 = load %struct.match**, %struct.match*** %11
%164 = load i8*, i8** %7
%165 = load i64, i64* %18
%166 = load i64, i64* %18
%167 = trunc i64 %166 to i32
%168 = call i64 @__glob_append(%struct.match** %163, i8* %164, i64 %165, i32 %167)
%169 = icmp ne i64 %168, 0
br i1 %169, label %170, label %172
170: ; preds = %162
%171 = load i32, i32* @GLOB_NOSPACE
br label %173
172: ; preds = %162
br label %173
173: ; preds = %172, %170
%174 = phi i32 [ %171, %170 ], [ 0, %172 ]
store i32 %174, i32* %21
%175 = load i32*, i32** %12
%176 = call i32 @closedir(i32* %175)
%177 = load i32, i32* %21
store i32 %177, i32* %6
store i32 1, i32* %22
br label %347
178: ; preds = %158
br label %179
179: ; preds = %327, %324, %178
%180 = load i32*, i32** %12
%181 = bitcast i64* %35 to i8*
%182 = call i32 @readdir_r(i32* %180, i8* %181, %struct.dirent** %15)
store i32 %182, i32* %21
%183 = icmp ne i32 %182, 0
br i1 %183, label %187, label %184
184: ; preds = %179
%185 = load %struct.dirent*, %struct.dirent** %15
%186 = icmp ne %struct.dirent* %185, null
br label %187
187: ; preds = %184, %179
%188 = phi i1 [ false, %179 ], [ %186, %184 ]
br i1 %188, label %189, label %328
189: ; preds = %187
%190 = load i64, i64* %18
%191 = load %struct.dirent*, %struct.dirent** %15
%192 = getelementptr inbounds %struct.dirent, %struct.dirent* %191, i32 0, i32 0
%193 = load i64, i64* %192
%194 = add i64 %190, %193
%195 = add i64 %194, 2
%196 = call i8* @llvm.stacksave()
store i8* %196, i8** %24
%197 = alloca i8, i64 %195
store i64 %195, i64* %25
store i8* %197, i8** %26
%198 = load i32, i32* %19
%199 = icmp ne i32 %198, 0
br i1 %199, label %209, label %200
200: ; preds = %189
%201 = load i8*, i8** %8
%202 = load %struct.dirent*, %struct.dirent** %15
%203 = getelementptr inbounds %struct.dirent, %struct.dirent* %202, i32 0, i32 1
%204 = load i8*, i8** %203
%205 = load i32, i32* %20
%206 = call i64 @fnmatch(i8* %201, i8* %204, i32 %205)
%207 = icmp ne i64 %206, 0
br i1 %207, label %208, label %209
208: ; preds = %200
store i32 5, i32* %22
br label %324
209: ; preds = %200, %189
%210 = load i32, i32* %19
%211 = icmp ne i32 %210, 0
br i1 %211, label %212, label %220
212: ; preds = %209
%213 = load i8*, i8** %8
%214 = load %struct.dirent*, %struct.dirent** %15
%215 = getelementptr inbounds %struct.dirent, %struct.dirent* %214, i32 0, i32 1
%216 = load i8*, i8** %215
%217 = call i64 @strcmp(i8* %213, i8* %216)
%218 = icmp ne i64 %217, 0
br i1 %218, label %219, label %220
219: ; preds = %212
store i32 5, i32* %22
br label %324
220: ; preds = %212, %209
%221 = load i8*, i8** %17
%222 = icmp ne i8* %221, null
br i1 %222, label %223, label %243
223: ; preds = %220
%224 = load %struct.dirent*, %struct.dirent** %15
%225 = getelementptr inbounds %struct.dirent, %struct.dirent* %224, i32 0, i32 2
%226 = load i32, i32* %225
%227 = icmp ne i32 %226, 0
br i1 %227, label %228, label %243
228: ; preds = %223
%229 = load %struct.dirent*, %struct.dirent** %15
%230 = getelementptr inbounds %struct.dirent, %struct.dirent* %229, i32 0, i32 2
%231 = load i32, i32* %230
%232 = shl i32 %231, 12
%233 = call i32 @S_ISDIR(i32 %232)
%234 = icmp ne i32 %233, 0
br i1 %234, label %243, label %235
235: ; preds = %228
%236 = load %struct.dirent*, %struct.dirent** %15
%237 = getelementptr inbounds %struct.dirent, %struct.dirent* %236, i32 0, i32 2
%238 = load i32, i32* %237
%239 = shl i32 %238, 12
%240 = call i32 @S_ISLNK(i32 %239)
%241 = icmp ne i32 %240, 0
br i1 %241, label %243, label %242
242: ; preds = %235
store i32 5, i32* %22
br label %324
243: ; preds = %235, %228, %223, %220
%244 = load i8*, i8** %7
%245 = load i8, i8* %244
%246 = icmp ne i8 %245, 0
br i1 %246, label %247, label %263
247: ; preds = %243
%248 = load i8*, i8** %26
%249 = load i8*, i8** %7
%250 = load i64, i64* %18
%251 = call i32 @memcpy(i8* %248, i8* %249, i64 %250)
%252 = load i8*, i8** %26
%253 = load i64, i64* %18
%254 = getelementptr inbounds i8, i8* %252, i64 %253
store i8 47, i8* %254
%255 = load i8*, i8** %26
%256 = load i64, i64* %18
%257 = getelementptr inbounds i8, i8* %255, i64 %256
%258 = getelementptr inbounds i8, i8* %257, i64 1
%259 = load %struct.dirent*, %struct.dirent** %15
%260 = getelementptr inbounds %struct.dirent, %struct.dirent* %259, i32 0, i32 1
%261 = load i8*, i8** %260
%262 = call i32 @strcpy(i8* %258, i8* %261)
br label %267
263: ; preds = %243
%264 = load %struct.dirent*, %struct.dirent** %15
%265 = getelementptr inbounds %struct.dirent, %struct.dirent* %264, i32 0, i32 1
%266 = load i8*, i8** %265
store i8* %266, i8** %26
br label %267
267: ; preds = %263, %247
%268 = load i8*, i8** %17
%269 = icmp ne i8* %268, null
br i1 %269, label %270, label %283
270: ; preds = %267
%271 = load i8*, i8** %26
%272 = load i8*, i8** %17
%273 = load i32, i32* %9
%274 = load i32 (i8*, i32)*, i32 (i8*, i32)** %10
%275 = load %struct.match**, %struct.match*** %11
%276 = call i32 @__glob_match_in_dir(i8* %271, i8* %272, i32 %273, i32 (i8*, i32)* %274, %struct.match** %275)
store i32 %276, i32* %21
%277 = icmp ne i32 %276, 0
br i1 %277, label %278, label %282
278: ; preds = %270
%279 = load i32*, i32** %12
%280 = call i32 @closedir(i32* %279)
%281 = load i32, i32* %21
store i32 %281, i32* %6
store i32 1, i32* %22
br label %324
282: ; preds = %270
br label %323
283: ; preds = %267
store i32 0, i32* %27
%284 = load i32, i32* %9
%285 = load i32, i32* @GLOB_MARK
%286 = and i32 %284, %285
%287 = icmp ne i32 %286, 0
br i1 %287, label %288, label %306
288: ; preds = %283
%289 = load %struct.dirent*, %struct.dirent** %15
%290 = getelementptr inbounds %struct.dirent, %struct.dirent* %289, i32 0, i32 2
%291 = load i32, i32* %290
%292 = icmp ne i32 %291, 0
br i1 %292, label %293, label %299
293: ; preds = %288
%294 = load %struct.dirent*, %struct.dirent** %15
%295 = getelementptr inbounds %struct.dirent, %struct.dirent* %294, i32 0, i32 2
%296 = load i32, i32* %295
%297 = shl i32 %296, 12
%298 = call i32 @S_ISDIR(i32 %297)
store i32 %298, i32* %27
br label %305
299: ; preds = %288
%300 = load i8*, i8** %26
%301 = call i32 @stat(i8* %300, %struct.stat* %28)
%302 = getelementptr inbounds %struct.stat, %struct.stat* %28, i32 0, i32 0
%303 = load i32, i32* %302
%304 = call i32 @S_ISDIR(i32 %303)
store i32 %304, i32* %27
br label %305
305: ; preds = %299, %293
br label %306
306: ; preds = %305, %283
%307 = load %struct.match**, %struct.match*** %11
%308 = load i8*, i8** %26
%309 = load i64, i64* %18
%310 = load %struct.dirent*, %struct.dirent** %15
%311 = getelementptr inbounds %struct.dirent, %struct.dirent* %310, i32 0, i32 0
%312 = load i64, i64* %311
%313 = add i64 %309, %312
%314 = add i64 %313, 1
%315 = load i32, i32* %27
%316 = call i64 @__glob_append(%struct.match** %307, i8* %308, i64 %314, i32 %315)
%317 = icmp ne i64 %316, 0
br i1 %317, label %318, label %322
318: ; preds = %306
%319 = load i32*, i32** %12
%320 = call i32 @closedir(i32* %319)
%321 = load i32, i32* @GLOB_NOSPACE
store i32 %321, i32* %6
store i32 1, i32* %22
br label %324
322: ; preds = %306
br label %323
323: ; preds = %322, %282
store i32 0, i32* %22
br label %324
324: ; preds = %323, %318, %278, %242, %219, %208
%325 = load i8*, i8** %24
%326 = load i32, i32* %22
switch i32 %326, label %347 [
i32 0, label %327
i32 5, label %179
]
327: ; preds = %324
br label %179
328: ; preds = %187
%329 = load i32*, i32** %12
%330 = call i32 @closedir(i32* %329)
%331 = load i32, i32* %21
%332 = icmp ne i32 %331, 0
br i1 %332, label %333, label %346
333: ; preds = %328
%334 = load i32 (i8*, i32)*, i32 (i8*, i32)** %10
%335 = load i8*, i8** %7
%336 = load i32, i32* %21
%337 = call i32 %334(i8* %335, i32 %336)
%338 = icmp ne i32 %337, 0
br i1 %338, label %344, label %339
339: ; preds = %333
%340 = load i32, i32* %9
%341 = load i32, i32* @GLOB_ERR
%342 = and i32 %340, %341
%343 = icmp ne i32 %342, 0
br i1 %343, label %344, label %346
344: ; preds = %339, %333
%345 = load i32, i32* @GLOB_ABORTED
store i32 %345, i32* %6
store i32 1, i32* %22
br label %347
346: ; preds = %339, %328
store i32 0, i32* %6
store i32 1, i32* %22
br label %347
347: ; preds = %346, %344, %324, %173, %157, %155, %142, %140, %114
%348 = load i8*, i8** %13
%349 = load i32, i32* %6
ret i32 %349
}

LLVM IR (-O2):
%struct.match = type { i32 }
%struct.dirent = type { i64, i8*, i32 }
%struct.stat = type { i32 }
@NAME_MAX = global i32 0
@GLOB_NOESCAPE = global i32 0
@FNM_NOESCAPE = global i32 0
@FNM_PERIOD = global i32 0
@.str = [2 x i8] c".\00"
@errno = global i32 0
@ENOTDIR = global i32 0
@EACCES = global i32 0
@GLOB_NOSPACE = global i32 0
@GLOB_ERR = global i32 0
@GLOB_ABORTED = global i32 0
@GLOB_MARK = global i32 0
define i32 @__glob_match_in_dir(i8* %0, i8* %1, i32 %2, i32 (i8*, i32)* nocapture %3, %struct.match** %4) {
%6 = alloca %struct.dirent*
%7 = alloca %struct.stat
%8 = alloca %struct.stat
%9 = load i32, i32* @NAME_MAX
%10 = sext i32 %9 to i64
%11 = add nsw i64 %10, 32
%12 = lshr i64 %11, 3
%13 = alloca i64, i64 %12
%14 = bitcast %struct.dirent** %6 to i8*
%15 = tail call i32 @strlen(i8* %1)
%16 = add nsw i32 %15, 1
%17 = zext i32 %16 to i64
%18 = alloca i8, i64 %17
%19 = tail call i32 @strlen(i8* %0)
%20 = sext i32 %19 to i64
%21 = load i32, i32* @GLOB_NOESCAPE
%22 = and i32 %21, %2
%23 = icmp eq i32 %22, 0
%24 = load i32, i32* @FNM_NOESCAPE
%25 = select i1 %23, i32 0, i32 %24
%26 = load i32, i32* @FNM_PERIOD
%27 = or i32 %25, %26
%28 = tail call i8* @strchr(i8* dereferenceable(1) %1, i8 signext 47)
%29 = icmp eq i8* %28, null
br i1 %29, label %44, label %30
30: ; preds = %5
%31 = call i32 @strcpy(i8* %18, i8* %1)
%32 = ptrtoint i8* %28 to i64
%33 = ptrtoint i8* %1 to i64
%34 = sub i64 %32, %33
%35 = getelementptr inbounds i8, i8* %18, i64 %34
store i8 0, i8* %35
br label %36
36: ; preds = %36, %30
%37 = phi i8* [ %28, %30 ], [ %40, %36 ]
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 47
%40 = getelementptr inbounds i8, i8* %37, i64 1
br i1 %39, label %36, label %41
41: ; preds = %36
%42 = load i32, i32* @GLOB_NOESCAPE
%43 = and i32 %42, %2
br label %44
44: ; preds = %41, %5
%45 = phi i32 [ %43, %41 ], [ %22, %5 ]
%46 = phi i8* [ %37, %41 ], [ null, %5 ]
%47 = phi i8* [ %18, %41 ], [ %1, %5 ]
%48 = icmp eq i32 %45, 0
%49 = zext i1 %48 to i32
%50 = call i32 @__glob_is_literal(i8* %47, i32 %49)
%51 = load i8, i8* %0
%52 = icmp eq i8 %51, 47
br i1 %52, label %53, label %58
53: ; preds = %44
%54 = getelementptr inbounds i8, i8* %0, i64 1
%55 = load i8, i8* %54
%56 = icmp eq i8 %55, 0
%57 = select i1 %56, i64 0, i64 %20
br label %58
58: ; preds = %53, %44
%59 = phi i64 [ %20, %44 ], [ %57, %53 ]
%60 = icmp eq i8 %51, 0
%61 = select i1 %60, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %0
%62 = call i32* @opendir(i8* %61)
%63 = load i32, i32* @errno
%64 = icmp eq i32* %62, null
br i1 %64, label %65, label %99
65: ; preds = %58
%66 = load i32, i32* @ENOTDIR
%67 = icmp eq i32 %63, %66
br i1 %67, label %226, label %68
68: ; preds = %65
%69 = load i32, i32* @EACCES
%70 = icmp eq i32 %63, %69
br i1 %70, label %71, label %90
71: ; preds = %68
%72 = load i8, i8* %47
%73 = icmp eq i8 %72, 0
br i1 %73, label %74, label %90
74: ; preds = %71
%75 = bitcast %struct.stat* %7 to i8*
%76 = call i32 @stat(i8* %0, %struct.stat* %7)
%77 = icmp eq i32 %76, 0
br i1 %77, label %78, label %83
78: ; preds = %74
%79 = getelementptr inbounds %struct.stat, %struct.stat* %7, i64 0, i32 0
%80 = load i32, i32* %79
%81 = call i32 @S_ISDIR(i32 %80)
%82 = icmp eq i32 %81, 0
br i1 %82, label %83, label %84
83: ; preds = %78, %74
br label %90
84: ; preds = %78
%85 = trunc i64 %59 to i32
%86 = call i64 @__glob_append(%struct.match** %4, i8* %0, i64 %59, i32 %85)
%87 = icmp eq i64 %86, 0
%88 = load i32, i32* @GLOB_NOSPACE
%89 = select i1 %87, i32 0, i32 %88
br label %226
90: ; preds = %83, %71, %68
%91 = call i32 %3(i8* %0, i32 %63)
%92 = icmp eq i32 %91, 0
br i1 %92, label %93, label %97
93: ; preds = %90
%94 = load i32, i32* @GLOB_ERR
%95 = and i32 %94, %2
%96 = icmp eq i32 %95, 0
br i1 %96, label %226, label %97
97: ; preds = %93, %90
%98 = load i32, i32* @GLOB_ABORTED
br label %226
99: ; preds = %58
%100 = load i8, i8* %47
%101 = icmp eq i8 %100, 0
br i1 %101, label %116, label %102
102: ; preds = %99
%103 = bitcast i64* %13 to i8*
%104 = call i32 @readdir_r(i32* %62, i8* %103, %struct.dirent** %6)
%105 = icmp eq i32 %104, 0
%106 = load %struct.dirent*, %struct.dirent** %6
%107 = icmp ne %struct.dirent* %106, null
%108 = select i1 %105, i1 %107, i1 false
br i1 %108, label %109, label %213
109: ; preds = %102
%110 = add nsw i64 %59, 2
%111 = icmp eq i32 %50, 0
%112 = icmp eq i8* %46, null
%113 = bitcast %struct.stat* %8 to i8*
%114 = getelementptr inbounds %struct.stat, %struct.stat* %8, i64 0, i32 0
%115 = add nsw i64 %59, 1
br label %123
116: ; preds = %99
%117 = trunc i64 %59 to i32
%118 = call i64 @__glob_append(%struct.match** %4, i8* %0, i64 %59, i32 %117)
%119 = icmp eq i64 %118, 0
%120 = load i32, i32* @GLOB_NOSPACE
%121 = select i1 %119, i32 0, i32 %120
%122 = call i32 @closedir(i32* %62)
br label %226
123: ; preds = %109, %207
%124 = phi %struct.dirent* [ %106, %109 ], [ %210, %207 ]
%125 = getelementptr inbounds %struct.dirent, %struct.dirent* %124, i64 0, i32 0
%126 = load i64, i64* %125
%127 = add i64 %110, %126
%128 = call i8* @llvm.stacksave()
%129 = alloca i8, i64 %127
%130 = load %struct.dirent*, %struct.dirent** %6
%131 = getelementptr inbounds %struct.dirent, %struct.dirent* %130, i64 0, i32 1
%132 = load i8*, i8** %131
br i1 %111, label %133, label %136
133: ; preds = %123
%134 = call i64 @fnmatch(i8* %47, i8* %132, i32 %27)
%135 = icmp eq i64 %134, 0
br i1 %135, label %139, label %207
136: ; preds = %123
%137 = call i64 @strcmp(i8* %47, i8* %132)
%138 = icmp eq i64 %137, 0
br i1 %138, label %139, label %207
139: ; preds = %133, %136
br i1 %112, label %156, label %140
140: ; preds = %139
%141 = load %struct.dirent*, %struct.dirent** %6
%142 = getelementptr inbounds %struct.dirent, %struct.dirent* %141, i64 0, i32 2
%143 = load i32, i32* %142
%144 = icmp eq i32 %143, 0
br i1 %144, label %156, label %145
145: ; preds = %140
%146 = shl i32 %143, 12
%147 = call i32 @S_ISDIR(i32 %146)
%148 = icmp eq i32 %147, 0
br i1 %148, label %149, label %156
149: ; preds = %145
%150 = load %struct.dirent*, %struct.dirent** %6
%151 = getelementptr inbounds %struct.dirent, %struct.dirent* %150, i64 0, i32 2
%152 = load i32, i32* %151
%153 = shl i32 %152, 12
%154 = call i32 @S_ISLNK(i32 %153)
%155 = icmp eq i32 %154, 0
br i1 %155, label %207, label %156
156: ; preds = %149, %145, %140, %139
%157 = load i8, i8* %0
%158 = icmp eq i8 %157, 0
br i1 %158, label %167, label %159
159: ; preds = %156
%160 = call i32 @memcpy(i8* %129, i8* %0, i64 %59)
%161 = getelementptr inbounds i8, i8* %129, i64 %59
store i8 47, i8* %161
%162 = getelementptr inbounds i8, i8* %161, i64 1
%163 = load %struct.dirent*, %struct.dirent** %6
%164 = getelementptr inbounds %struct.dirent, %struct.dirent* %163, i64 0, i32 1
%165 = load i8*, i8** %164
%166 = call i32 @strcpy(i8* %162, i8* %165)
br label %171
167: ; preds = %156
%168 = load %struct.dirent*, %struct.dirent** %6
%169 = getelementptr inbounds %struct.dirent, %struct.dirent* %168, i64 0, i32 1
%170 = load i8*, i8** %169
br label %171
171: ; preds = %167, %159
%172 = phi i8* [ %129, %159 ], [ %170, %167 ]
br i1 %112, label %178, label %173
173: ; preds = %171
%174 = call i32 @__glob_match_in_dir(i8* %172, i8* %46, i32 %2, i32 (i8*, i32)* %3, %struct.match** %4)
%175 = icmp eq i32 %174, 0
br i1 %175, label %207, label %176
176: ; preds = %173
%177 = call i32 @closedir(i32* %62)
br label %205
178: ; preds = %171
%179 = load i32, i32* @GLOB_MARK
%180 = and i32 %179, %2
%181 = icmp eq i32 %180, 0
br i1 %181, label %194, label %182
182: ; preds = %178
%183 = load %struct.dirent*, %struct.dirent** %6
%184 = getelementptr inbounds %struct.dirent, %struct.dirent* %183, i64 0, i32 2
%185 = load i32, i32* %184
%186 = icmp eq i32 %185, 0
br i1 %186, label %190, label %187
187: ; preds = %182
%188 = shl i32 %185, 12
%189 = call i32 @S_ISDIR(i32 %188)
br label %194
190: ; preds = %182
%191 = call i32 @stat(i8* %172, %struct.stat* %8)
%192 = load i32, i32* %114
%193 = call i32 @S_ISDIR(i32 %192)
br label %194
194: ; preds = %187, %190, %178
%195 = phi i32 [ %189, %187 ], [ %193, %190 ], [ 0, %178 ]
%196 = load %struct.dirent*, %struct.dirent** %6
%197 = getelementptr inbounds %struct.dirent, %struct.dirent* %196, i64 0, i32 0
%198 = load i64, i64* %197
%199 = add i64 %115, %198
%200 = call i64 @__glob_append(%struct.match** %4, i8* %172, i64 %199, i32 %195)
%201 = icmp eq i64 %200, 0
br i1 %201, label %207, label %202
202: ; preds = %194
%203 = call i32 @closedir(i32* %62)
%204 = load i32, i32* @GLOB_NOSPACE
br label %205
205: ; preds = %176, %202
%206 = phi i32 [ %204, %202 ], [ %174, %176 ]
br label %226
207: ; preds = %194, %173, %149, %136, %133
%208 = call i32 @readdir_r(i32* %62, i8* %103, %struct.dirent** %6)
%209 = icmp eq i32 %208, 0
%210 = load %struct.dirent*, %struct.dirent** %6
%211 = icmp ne %struct.dirent* %210, null
%212 = select i1 %209, i1 %211, i1 false
br i1 %212, label %123, label %213
213: ; preds = %207, %102
%214 = phi i32 [ %104, %102 ], [ %208, %207 ]
%215 = phi i1 [ %105, %102 ], [ %209, %207 ]
%216 = call i32 @closedir(i32* %62)
br i1 %215, label %226, label %217
217: ; preds = %213
%218 = call i32 %3(i8* %0, i32 %214)
%219 = icmp eq i32 %218, 0
br i1 %219, label %220, label %224
220: ; preds = %217
%221 = load i32, i32* @GLOB_ERR
%222 = and i32 %221, %2
%223 = icmp eq i32 %222, 0
br i1 %223, label %226, label %224
224: ; preds = %220, %217
%225 = load i32, i32* @GLOB_ABORTED
br label %226
226: ; preds = %205, %84, %213, %220, %93, %65, %224, %116, %97
%227 = phi i32 [ %225, %224 ], [ %121, %116 ], [ %98, %97 ], [ %89, %84 ], [ 0, %65 ], [ 0, %93 ], [ 0, %220 ], [ 0, %213 ], [ %206, %205 ]
ret i32 %227
}