// File: /workspace/github_c_makefile_star2_O2/lb3361[P]dosfs/dosfs.c
// Function: rattrib
FRESULT rattrib(char *path, char *pattern, BYTE aset, BYTE aclr, int dflag, int sflag, int *pnf)
{
  DIR dir;
  FILINFO info;
  FRESULT res;
  while (path[0] == '/')
    path++;
  res = f_findfirst(&dir, &info, path, pattern);
  if (res != FR_OK && res != FR_NO_FILE)
    return res;
  while (res == FR_OK && info.fname[0])
    {
      if (dflag == 1 || !(info.fattrib & AM_DIR)) {
        *pnf += 1;
        if (aset == 0 && aclr == 0)
          {
            printf("%c%c%c%c %s%s/%s\n",
                   (info.fattrib & AM_ARC) ? 'A' : ' ',
                   (info.fattrib & AM_RDO) ? 'R' : ' ',
                   (info.fattrib & AM_SYS) ? 'S' : ' ',
                   (info.fattrib & AM_HID) ? 'H' : ' ',
                   path[0] ? "/" : "", path, info.fname );
          }
        else
          {
            char *fn = strconcat(path, "/", info.fname, 0);
            res = f_chmod(fn, aset, aset | aclr);
            if (res != FR_OK)
              fprintf(stderr, "dosfs: error while processing %s\n", fn);
            free(fn);
            if (res != FR_OK)
              return res;
          }
      }
      res = f_findnext(&dir, &info);
    }
  if (res != FR_OK)
    return res;
  if (sflag)
    {
      res = f_findfirst(&dir, &info, path, "*");
      if (res != FR_OK && res != FR_NO_FILE)
        return res;
      while (res == FR_OK && info.fname[0])
        {
          if (info.fattrib & AM_DIR) {
            char *fn = strconcat(path, "/", info.fname, 0);
            res = rattrib(fn, pattern, aset, aclr, dflag, sflag, pnf);
            free(fn);
            if (res != FR_OK)
              return res;
          }
          res = f_findnext(&dir, &info);
        }
      if (res != FR_OK)
          return res;
    }
  return FR_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movl %r9d, %r14d
movl %r8d, %ebp
movl %ecx, 0x14(%rsp)
movl %edx, %r12d
movq %rsi, %r13
movq %rdi, %r15
decq %r15
cmpb $0x2f, 0x1(%r15)
leaq 0x1(%r15), %r15
je 0x3c6b
leaq 0x148(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movq %r15, %rdx
movq %r13, %rcx
callq 0x75e1
movl %eax, %ebx
testl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
jne 0x3e8e
movq %r13, 0x20(%rsp)
movl %r14d, 0x10(%rsp)
movl 0x14(%rsp), %eax
movl %eax, %ecx
orb %r12b, %cl
movzbl %r12b, %eax
movl %eax, 0x18(%rsp)
movb %cl, 0xc(%rsp)
movzbl %cl, %eax
movl %eax, 0x1c(%rsp)
leaq 0x148(%rsp), %r12
leaq 0x28(%rsp), %r14
testl %ebx, %ebx
jne 0x3dbc
cmpb $0x0, 0x42(%rsp)
je 0x3dbc
cmpl $0x1, %ebp
je 0x3cf1
testb $0x10, 0x34(%rsp)
jne 0x3daa
movq 0x1e0(%rsp), %rax
incl (%rax)
cmpb $0x0, 0xc(%rsp)
je 0x3d51
movl %ebp, %r13d
movq %r14, %rbp
movq %r12, %r14
movq %r15, %rdi
leaq 0x778b(%rip), %rsi      # 0xb4a0
leaq 0x42(%rsp), %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x29f0
movq %rax, %r12
movq %rax, %rdi
movl 0x18(%rsp), %esi
movl 0x1c(%rsp), %edx
callq 0x806e
testl %eax, %eax
jne 0x3ea2
movq %r12, %rdi
callq 0x2030
movq %r14, %r12
movq %rbp, %r14
movl %r13d, %ebp
jmp 0x3daa
movzbl 0x34(%rsp), %eax
testb $0x20, %al
pushq $0x41
popq %rsi
pushq $0x20
popq %rdi
cmovel %edi, %esi
testb $0x1, %al
pushq $0x52
popq %rdx
cmovel %edi, %edx
testb $0x4, %al
pushq $0x53
popq %rcx
cmovel %edi, %ecx
testb $0x2, %al
pushq $0x48
popq %r8
cmovel %edi, %r8d
cmpb $0x0, (%r15)
leaq 0x771a(%rip), %r9       # 0xb4a0
leaq 0x7712(%rip), %rax      # 0xb49f
cmoveq %rax, %r9
leaq 0x81c3(%rip), %rdi      # 0xbf5b
xorl %eax, %eax
leaq 0x42(%rsp), %r10
pushq %r10
pushq %r15
callq 0x20e0
popq %rcx
popq %rdx
movq %r12, %rdi
movq %r14, %rsi
callq 0x7470
movl %eax, %ebx
jmp 0x3cce
testl %ebx, %ebx
jne 0x3e8e
cmpl $0x0, 0x10(%rsp)
je 0x3e8c
leaq 0x76cc(%rip), %rcx      # 0xb4a2
leaq 0x148(%rsp), %rdi
leaq 0x28(%rsp), %rsi
movq %r15, %rdx
callq 0x75e1
movl %eax, %ebx
testl $0xfffffffb, %eax       # imm = 0xFFFFFFFB
jne 0x3e8e
leaq 0x148(%rsp), %r14
leaq 0x28(%rsp), %r13
movzbl 0x14(%rsp), %eax
movl %eax, 0xc(%rsp)
testl %ebx, %ebx
jne 0x3e88
cmpb $0x0, 0x42(%rsp)
je 0x3e88
testb $0x10, 0x34(%rsp)
je 0x3e79
movq %r15, %rdi
leaq 0x7676(%rip), %rsi      # 0xb4a0
leaq 0x42(%rsp), %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x29f0
movq %r14, %r12
movq %rax, %r14
subq $0x8, %rsp
movq %rax, %rdi
movq 0x28(%rsp), %rsi
movl 0x20(%rsp), %edx
movl 0x14(%rsp), %ecx
movl %ebp, %r8d
movl 0x18(%rsp), %r9d
pushq 0x1e8(%rsp)
callq 0x3c44
popq %rcx
popq %rdx
movl %eax, %ebx
movq %r14, %rdi
movq %r12, %r14
callq 0x2030
testl %ebx, %ebx
jne 0x3e8e
movq %r14, %rdi
movq %r13, %rsi
callq 0x7470
movl %eax, %ebx
jmp 0x3e0e
testl %ebx, %ebx
jne 0x3e8e
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %ebx
movq 0xd14d(%rip), %rax      # 0x10ff8
movq (%rax), %rdi
leaq 0x7bde(%rip), %rsi      # 0xba93
movq %r12, %rdx
xorl %eax, %eax
callq 0x2180
movq %r12, %rdi
callq 0x2030
jmp 0x3e8e