// File: mh0fm4[P]SCDC/src/components/dataset/dataset_inout.cc
// Function: input_fslist_dir_next(_scdc_dataset_inout_t*, _scdc_result_t*)
static scdcint_t input_fslist_dir_next(scdc_dataset_input_t *input, scdc_result_t *result)
{
  input_fslist_dir_data_t *data = static_cast<input_fslist_dir_data_t *>(input->data);

  bool first = true;

  char *buf = static_cast<char *>(SCDC_DATASET_INOUT_BUF_PTR(input));
  scdcint_t buf_size = SCDC_DATASET_INOUT_BUF_SIZE(input);

  SCDC_DATASET_INOUT_BUF_CURRENT(input) = 0;

  do {

    if (data->result && strcmp(data->result->d_name, ".") != 0 && strcmp(data->result->d_name, "..") != 0)
    {
      if (static_cast<scdcint_t>(strlen(data->result->d_name) + 16) < buf_size || first)
      {
        string pathname = string(data->pathname) + data->result->d_name;

        scdcint_t n;

        if (!data->follow_links && z_fs_is_link(pathname.c_str()))
          n = snprintf(buf, buf_size, "%s:l|", data->result->d_name);
        else if (z_fs_is_directory(pathname.c_str()))
          n = snprintf(buf, buf_size, "%s:d|", data->result->d_name);
        else if (z_fs_is_file(pathname.c_str()))
          n = snprintf(buf, buf_size, "%s:f:%" scdcint_fmt "|", data->result->d_name, z_fs_get_file_size(pathname.c_str()));
        else
          n = snprintf(buf, buf_size, "%s:?" scdcint_fmt "|", data->result->d_name);

        n = min(n, buf_size);

        buf += n;
        buf_size -= n;

        SCDC_DATASET_INOUT_BUF_CURRENT(input) += n;
        input->total_size += n;

        first = false;

      } else break;
    }

    data->result = readdir(data->dir);

  } while (data->result);

  if (!data->result) input->next = 0;

  return SCDC_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x18(%rbp)
movb $0x1, -0x19(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq $0x0, 0x20(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x110(%rax)
je 0x4a1f2
movq -0x18(%rbp), %rax
movq 0x110(%rax), %rdi
addq $0x13, %rdi
leaq 0x5c4a1(%rip), %rsi     # 0xa6370
callq 0xc970
cmpl $0x0, %eax
je 0x4a1f2
movq -0x18(%rbp), %rax
movq 0x110(%rax), %rdi
addq $0x13, %rdi
leaq 0x5c47c(%rip), %rsi     # 0xa636f
callq 0xc970
cmpl $0x0, %eax
je 0x4a1f2
movq -0x18(%rbp), %rax
movq 0x110(%rax), %rdi
addq $0x13, %rdi
callq 0xc280
addq $0x10, %rax
cmpq -0x30(%rbp), %rax
jl 0x49f29
testb $0x1, -0x19(%rbp)
je 0x4a1ee
movq -0x18(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq -0x71(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0xcbc0
movq -0xa0(%rbp), %rsi
movq -0x98(%rbp), %rdx
leaq -0x70(%rbp), %rdi
callq 0x27820
jmp 0x49f5d
movq -0x18(%rbp), %rax
movq 0x110(%rax), %rdx
addq $0x13, %rdx
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x2eef0
jmp 0x49f7b
leaq -0x70(%rbp), %rdi
callq 0xc3e0
leaq -0x71(%rbp), %rdi
callq 0xc730
movq -0x18(%rbp), %rax
testb $0x1, 0x100(%rax)
jne 0x4a050
leaq -0x50(%rbp), %rdi
callq 0xc260
movq %rax, %rdi
callq 0x5d520
movq %rax, -0xa8(%rbp)
jmp 0x49fb8
movq -0xa8(%rbp), %rax
cmpq $0x0, %rax
je 0x4a050
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x18(%rbp), %rax
movq 0x110(%rax), %rcx
addq $0x13, %rcx
leaq 0x5d50e(%rip), %rdx     # 0xa74f5
movb $0x0, %al
callq 0xcaf0
cltq
movq %rax, -0x90(%rbp)
jmp 0x4a17e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x4a025
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x70(%rbp), %rdi
callq 0xc3e0
leaq -0x71(%rbp), %rdi
callq 0xc730
jmp 0x4a24a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xc3e0
jmp 0x4a24a
leaq -0x50(%rbp), %rdi
callq 0xc260
movq %rax, %rdi
callq 0x5d460
movq %rax, -0xb0(%rbp)
jmp 0x4a06a
movq -0xb0(%rbp), %rax
cmpq $0x0, %rax
je 0x4a0aa
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x18(%rbp), %rax
movq 0x110(%rax), %rcx
addq $0x13, %rcx
leaq 0x5d466(%rip), %rdx     # 0xa74fb
movb $0x0, %al
callq 0xcaf0
cltq
movq %rax, -0x90(%rbp)
jmp 0x4a17c
leaq -0x50(%rbp), %rdi
callq 0xc260
movq %rax, %rdi
callq 0x5d4c0
movq %rax, -0xb8(%rbp)
jmp 0x4a0c4
movq -0xb8(%rbp), %rax
cmpq $0x0, %rax
je 0x4a14c
movq -0x28(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x18(%rbp), %rax
movq 0x110(%rax), %rax
addq $0x13, %rax
movq %rax, -0xc8(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xc260
movq %rax, %rdi
callq 0x5d580
movq %rax, -0xc0(%rbp)
jmp 0x4a117
movq -0xc0(%rbp), %r8
movq -0xc8(%rbp), %rcx
movq -0xd0(%rbp), %rsi
movq -0xd8(%rbp), %rdi
leaq 0x5d3c7(%rip), %rdx     # 0xa7501
movb $0x0, %al
callq 0xcaf0
cltq
movq %rax, -0x90(%rbp)
jmp 0x4a17a
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x18(%rbp), %rax
movq 0x110(%rax), %rcx
addq $0x13, %rcx
leaq 0x5d3a2(%rip), %rdx     # 0xa750c
movb $0x0, %al
callq 0xcaf0
cltq
movq %rax, -0x90(%rbp)
jmp 0x4a17c
jmp 0x4a17e
leaq -0x90(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2b080
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
addq -0x28(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x90(%rbp), %rcx
movq -0x30(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x90(%rbp), %rcx
movq -0x8(%rbp), %rax
addq 0x20(%rax), %rcx
movq %rcx, 0x20(%rax)
movq -0x90(%rbp), %rcx
movq -0x8(%rbp), %rax
addq 0x28(%rax), %rcx
movq %rcx, 0x28(%rax)
movb $0x0, -0x19(%rbp)
leaq -0x50(%rbp), %rdi
callq 0xc3e0
jmp 0x4a1f0
jmp 0x4a222
jmp 0x4a1f2
movq -0x18(%rbp), %rax
movq 0x108(%rax), %rdi
callq 0xca60
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x110(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x110(%rax)
jne 0x49ea7
movq -0x18(%rbp), %rax
cmpq $0x0, 0x110(%rax)
jne 0x4a23c
movq -0x8(%rbp), %rax
movq $0x0, 0x38(%rax)
movl $0x1, %eax
addq $0xe0, %rsp
popq %rbp
retq
movq -0x80(%rbp), %rdi
callq 0xcba0
nopw %cs:(%rax,%rax)