// File: /workspace/github_c_makefile_star2_O0/bhk[P]tooltree/luau/xpfs.c
// Function: do_stat
static int do_stat(lua_State *L, const char *filename, const char *mask)
{
   const char *pch;
   int ch;
   int nerr;
   struct stat info;

   if (*mask == 'L') {
      nerr = lstat(filename, &info);
   } else {
      nerr = stat(filename, &info);
   }
   if (nerr != 0) {
      lua_pushnil(L);
      lua_pushstring(L, strerror(errno));
      return 2;
   }

   lua_createtable(L, 0, strlen(mask));

   for (pch = mask; (ch = *pch++) != '\0'; ) {

      if (ch == '*' || ch == 'p') {
         char perm[11];
         unsigned m = (unsigned) info.st_mode;
         int group;

         for (group = 2; group >= 0; --group, m >>=3) {
            perm[group*3 + 0] = ((m&4) ? 'r' : '-');
            perm[group*3 + 1] = ((m&2) ? 'w' : '-');
            perm[group*3 + 2] = ((m&1) ? 'x' : '-');
         }
         perm[9] = '\0';
         lua_pushstring(L, perm);
         lua_setfield(L, -2, "perm");
      }

      if (ch == '*' || ch == 'k') {
         const char *kind = (S_ISREG(info.st_mode) ? "f" :
                             S_ISDIR(info.st_mode) ? "d" :
                             S_ISLNK(info.st_mode) ? "l" :
                             S_ISBLK(info.st_mode) ? "b" :
                             S_ISCHR(info.st_mode) ? "c" :
                             S_ISSOCK(info.st_mode) ? "s" :
                             S_ISFIFO(info.st_mode) ? "p" :
                             "o");
         lua_pushstring(L, kind);
         lua_setfield(L, -2, "kind");
      }

      if (ch == '*' || ch == 's') {
         lua_pushnumber(L, (lua_Number) info.st_size);
         lua_setfield(L, -2, "size");
      }

      if (ch == '*' || ch == 't') {
         lua_pushnumber(L, MAX( DTIME(info, m), DTIME(info, c)) );
         lua_setfield(L, -2, "time");
      }

      if (ch == '*' || ch == 'm') {
         STORETIME(info, m, "mtime");
      }

      if (ch == '*' || ch == 'a') {
         STORETIME(info, a, "atime");
      }

      if (ch == '*' || ch == 'c') {
         STORETIME(info, c, "ctime");
      }

      if (ch == '*' || ch == 'i') {
         lua_pushnumber(L, (lua_Number) info.st_ino);
         lua_setfield(L, -2, "inode");
      }

      if (ch == '*' || ch == 'd') {
         lua_pushnumber(L, (lua_Number) info.st_dev);
         lua_setfield(L, -2, "dev");
      }

      if (ch == '*' || ch == 'u') {
         lua_pushnumber(L, (lua_Number) info.st_uid);
         lua_setfield(L, -2, "uid");
      }

      if (ch == '*' || ch == 'g') {
         lua_pushnumber(L, (lua_Number) info.st_gid);
         lua_setfield(L, -2, "gid");
      }
   }
   return 1;
}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x128(%rsp)
movq %rsi, 0x120(%rsp)
movq %rdx, 0x118(%rsp)
movq 0x118(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x4c, %eax
jne 0x1a6a
movq 0x120(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x1130
movl %eax, 0x108(%rsp)
jmp 0x1a83
movq 0x120(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x1150
movl %eax, 0x108(%rsp)
cmpl $0x0, 0x108(%rsp)
je 0x1ad0
movq 0x128(%rsp), %rdi
callq 0x11a0
movq 0x128(%rsp), %rax
movq %rax, 0x50(%rsp)
callq 0x1050
movl (%rax), %edi
callq 0x11d0
movq 0x50(%rsp), %rdi
movq %rax, %rsi
callq 0x11c0
movl $0x2, 0x134(%rsp)
jmp 0x209c
movq 0x128(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x118(%rsp), %rdi
callq 0x10c0
movq 0x48(%rsp), %rdi
movl %eax, %edx
xorl %esi, %esi
callq 0x10b0
movq 0x118(%rsp), %rax
movq %rax, 0x110(%rsp)
movq 0x110(%rsp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, 0x110(%rsp)
movsbl (%rax), %eax
movl %eax, 0x10c(%rsp)
cmpl $0x0, %eax
je 0x2091
cmpl $0x2a, 0x10c(%rsp)
je 0x1b4a
cmpl $0x70, 0x10c(%rsp)
jne 0x1c28
movl 0x90(%rsp), %eax
movl %eax, 0x68(%rsp)
movl $0x2, 0x64(%rsp)
cmpl $0x0, 0x64(%rsp)
jl 0x1bf8
movl 0x68(%rsp), %edx
andl $0x4, %edx
movl $0x2d, %eax
movl $0x72, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movb %al, %cl
imull $0x3, 0x64(%rsp), %eax
addl $0x0, %eax
cltq
movb %cl, 0x6d(%rsp,%rax)
movl 0x68(%rsp), %edx
andl $0x2, %edx
movl $0x2d, %eax
movl $0x77, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movb %al, %cl
imull $0x3, 0x64(%rsp), %eax
addl $0x1, %eax
cltq
movb %cl, 0x6d(%rsp,%rax)
movl 0x68(%rsp), %edx
andl $0x1, %edx
movl $0x2d, %eax
movl $0x78, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movb %al, %cl
imull $0x3, 0x64(%rsp), %eax
addl $0x2, %eax
cltq
movb %cl, 0x6d(%rsp,%rax)
movl 0x64(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x64(%rsp)
movl 0x68(%rsp), %eax
shrl $0x3, %eax
movl %eax, 0x68(%rsp)
jmp 0x1b5d
movb $0x0, 0x76(%rsp)
movq 0x128(%rsp), %rdi
leaq 0x6d(%rsp), %rsi
callq 0x11c0
movq 0x128(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x1431(%rip), %rdx      # 0x3054
callq 0x10f0
cmpl $0x2a, 0x10c(%rsp)
je 0x1c40
cmpl $0x6b, 0x10c(%rsp)
jne 0x1da3
movl 0x90(%rsp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x1c64
leaq 0x13ff(%rip), %rax      # 0x3059
movq %rax, 0x40(%rsp)
jmp 0x1d6e
movl 0x90(%rsp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x4000, %eax           # imm = 0x4000
jne 0x1c88
leaq 0x1415(%rip), %rax      # 0x3093
movq %rax, 0x38(%rsp)
jmp 0x1d64
movl 0x90(%rsp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0xa000, %eax           # imm = 0xA000
jne 0x1cac
leaq 0x13b9(%rip), %rax      # 0x305b
movq %rax, 0x30(%rsp)
jmp 0x1d5a
movl 0x90(%rsp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x6000, %eax           # imm = 0x6000
jne 0x1cd0
leaq 0x1397(%rip), %rax      # 0x305d
movq %rax, 0x28(%rsp)
jmp 0x1d50
movl 0x90(%rsp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x2000, %eax           # imm = 0x2000
jne 0x1cf1
leaq 0x1375(%rip), %rax      # 0x305f
movq %rax, 0x20(%rsp)
jmp 0x1d46
movl 0x90(%rsp), %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0xc000, %eax           # imm = 0xC000
jne 0x1d12
leaq 0x1356(%rip), %rax      # 0x3061
movq %rax, 0x18(%rsp)
jmp 0x1d3c
movl 0x90(%rsp), %edx
andl $0xf000, %edx           # imm = 0xF000
leaq 0x133f(%rip), %rax      # 0x3065
leaq 0x1336(%rip), %rcx      # 0x3063
cmpl $0x1000, %edx           # imm = 0x1000
cmoveq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x128(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x11c0
movq 0x128(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x12c9(%rip), %rdx      # 0x3067
callq 0x10f0
cmpl $0x2a, 0x10c(%rsp)
je 0x1db7
cmpl $0x73, 0x10c(%rsp)
jne 0x1de7
movq 0x128(%rsp), %rdi
cvtsi2sdq 0xa8(%rsp), %xmm0
callq 0x1160
movq 0x128(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x128a(%rip), %rdx      # 0x306c
callq 0x10f0
cmpl $0x2a, 0x10c(%rsp)
je 0x1dfb
cmpl $0x74, 0x10c(%rsp)
jne 0x1e6d
movq 0x128(%rsp), %rax
movq %rax, 0x10(%rsp)
cvtsi2sdq 0xd0(%rsp), %xmm0
cvtsi2sdq 0xe0(%rsp), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x1e34
cvtsi2sdq 0xd0(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
jmp 0x1e44
cvtsi2sdq 0xe0(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x10(%rsp), %rdi
movsd 0x8(%rsp), %xmm0
callq 0x1160
movq 0x128(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x1210(%rip), %rdx      # 0x3078
callq 0x10f0
cmpl $0x2a, 0x10c(%rsp)
je 0x1e81
cmpl $0x6d, 0x10c(%rsp)
jne 0x1eb1
movq 0x128(%rsp), %rdi
cvtsi2sdq 0xd0(%rsp), %xmm0
callq 0x1160
movq 0x128(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x11c5(%rip), %rdx      # 0x3071
callq 0x10f0
cmpl $0x2a, 0x10c(%rsp)
je 0x1ec5
cmpl $0x61, 0x10c(%rsp)
jne 0x1ef5
movq 0x128(%rsp), %rdi
cvtsi2sdq 0xc0(%rsp), %xmm0
callq 0x1160
movq 0x128(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x1187(%rip), %rdx      # 0x3077
callq 0x10f0
cmpl $0x2a, 0x10c(%rsp)
je 0x1f09
cmpl $0x63, 0x10c(%rsp)
jne 0x1f39
movq 0x128(%rsp), %rdi
cvtsi2sdq 0xe0(%rsp), %xmm0
callq 0x1160
movq 0x128(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x1149(%rip), %rdx      # 0x307d
callq 0x10f0
cmpl $0x2a, 0x10c(%rsp)
je 0x1f4d
cmpl $0x69, 0x10c(%rsp)
jne 0x1f9e
movq 0x128(%rsp), %rdi
movaps 0x10a4(%rip), %xmm1     # 0x3000
movq 0x80(%rsp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x109f(%rip), %xmm1     # 0x3010
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
callq 0x1160
movq 0x128(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x10ea(%rip), %rdx      # 0x3083
callq 0x10f0
cmpl $0x2a, 0x10c(%rsp)
je 0x1fb2
cmpl $0x64, 0x10c(%rsp)
jne 0x2000
movq 0x128(%rsp), %rdi
movaps 0x103f(%rip), %xmm1     # 0x3000
movq 0x78(%rsp), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x103d(%rip), %xmm1     # 0x3010
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
callq 0x1160
movq 0x128(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x108e(%rip), %rdx      # 0x3089
callq 0x10f0
cmpl $0x2a, 0x10c(%rsp)
je 0x2014
cmpl $0x75, 0x10c(%rsp)
jne 0x2046
movq 0x128(%rsp), %rdi
movl 0x94(%rsp), %eax
cvtsi2sd %rax, %xmm0
callq 0x1160
movq 0x128(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x104c(%rip), %rdx      # 0x308d
callq 0x10f0
cmpl $0x2a, 0x10c(%rsp)
je 0x205a
cmpl $0x67, 0x10c(%rsp)
jne 0x208c
movq 0x128(%rsp), %rdi
movl 0x98(%rsp), %eax
cvtsi2sd %rax, %xmm0
callq 0x1160
movq 0x128(%rsp), %rdi
movl $0xfffffffe, %esi       # imm = 0xFFFFFFFE
leaq 0x100a(%rip), %rdx      # 0x3091
callq 0x10f0
jmp 0x1b08
movl $0x1, 0x134(%rsp)
movl 0x134(%rsp), %eax
addq $0x138, %rsp            # imm = 0x138
retq