// File: /workspace/github_c_makefile_star2_O0/bhk[P]tooltree/luau/xpfs.c
// Function: xpfs_chmod
static int xpfs_chmod(lua_State *L)
{
   const char *filename = luaL_checkstring(L, 1);
   const char *szmode = luaL_checkstring(L, 2);
   int n;

	struct stat info;

   /* we only want to change user bits here, so get the current state */
	n = stat(filename, &info);
   if (n == 0) {
      mode_t MMM = info.st_mode;
      char pm = szmode[0];
      if (pm == '+' || pm == '-') {
         ++szmode;
      } else {
         #ifdef _WIN32
            MMM &= ~( _S_IREAD | _S_IWRITE );
         #else
            MMM &= ~S_IRWXU;
         #endif
      }

      for (; *szmode; ++szmode) {
         int bit = 0;
         #ifdef _WIN32
            if (*szmode == 'r') { bit = _S_IREAD; }
            if (*szmode == 'w') { bit = _S_IWRITE; }
         #else
            if (*szmode == 'r') { bit = S_IRUSR; }
            if (*szmode == 'w') { bit = S_IWUSR; }
            if (*szmode == 'x') { bit = S_IXUSR; }
         #endif
         if (pm == '-') {
            MMM &= ~bit;
         } else {
            MMM |= bit;
         }
      }
      n = chmod(filename, MMM);
   }

   if (n==0) {
      lua_pushboolean(L, 1);
      return 1;
   } else {
      lua_pushnil(L);
      lua_pushstring(L, strerror(errno));
      return 2;
   }
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0xc8(%rsp)
movq 0xc8(%rsp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x1120
movq %rax, 0xc0(%rsp)
movq 0xc8(%rsp), %rdi
movl $0x2, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x1120
movq %rax, 0xb8(%rsp)
movq 0xc0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x1150
movl %eax, 0xb4(%rsp)
cmpl $0x0, 0xb4(%rsp)
jne 0x14ac
movl 0x38(%rsp), %eax
movl %eax, 0x1c(%rsp)
movq 0xb8(%rsp), %rax
movb (%rax), %al
movb %al, 0x1b(%rsp)
movsbl 0x1b(%rsp), %eax
cmpl $0x2b, %eax
je 0x13cc
movsbl 0x1b(%rsp), %eax
cmpl $0x2d, %eax
jne 0x13e2
movq 0xb8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb8(%rsp)
jmp 0x13ef
movl 0x1c(%rsp), %eax
andl $0xfffffe3f, %eax       # imm = 0xFFFFFE3F
movl %eax, 0x1c(%rsp)
jmp 0x13f1
movq 0xb8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x1494
movl $0x0, 0x14(%rsp)
movq 0xb8(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x72, %eax
jne 0x1422
movl $0x100, 0x14(%rsp)      # imm = 0x100
movq 0xb8(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x77, %eax
jne 0x143a
movl $0x80, 0x14(%rsp)
movq 0xb8(%rsp), %rax
movsbl (%rax), %eax
cmpl $0x78, %eax
jne 0x1452
movl $0x40, 0x14(%rsp)
movsbl 0x1b(%rsp), %eax
cmpl $0x2d, %eax
jne 0x146d
movl 0x14(%rsp), %eax
xorl $-0x1, %eax
andl 0x1c(%rsp), %eax
movl %eax, 0x1c(%rsp)
jmp 0x1479
movl 0x14(%rsp), %eax
orl 0x1c(%rsp), %eax
movl %eax, 0x1c(%rsp)
jmp 0x147b
movq 0xb8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xb8(%rsp)
jmp 0x13f1
movq 0xc0(%rsp), %rdi
movl 0x1c(%rsp), %esi
callq 0x1190
movl %eax, 0xb4(%rsp)
cmpl $0x0, 0xb4(%rsp)
jne 0x14d5
movq 0xc8(%rsp), %rdi
movl $0x1, %esi
callq 0x1180
movl $0x1, 0xd4(%rsp)
jmp 0x1513
movq 0xc8(%rsp), %rdi
callq 0x11a0
movq 0xc8(%rsp), %rax
movq %rax, 0x8(%rsp)
callq 0x1050
movl (%rax), %edi
callq 0x11d0
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x11c0
movl $0x2, 0xd4(%rsp)
movl 0xd4(%rsp), %eax
addq $0xd8, %rsp
retq
nopw %cs:(%rax,%rax)