// File: /workspace/github_cpp_makefile_star2_O2/mh0fm4[P]SCDC/src/components/dataprov/dataprov_hook.cc
// Function: scdc_dataprov_hook::dataset_open_read_state(scdc_data*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
scdc_dataset *scdc_dataprov_hook::dataset_open_read_state(scdc_data *incoming, scdc_result &result)
{
  SCDC_TRACE("dataset_open_read_state:");

  if (!hook_arg.hook.dataset_open_read_state)
  {
    SCDC_TRACE("dataset_open_read_state: using fallback");
    return scdc_dataprov::dataset_open_read_state(incoming, result);
  }

  char *buf;
  scdcint_t buf_size;
  const char *end;

  while (1)
  {
    buf = incoming->get_read_pos_buf();
    buf_size = incoming->get_read_pos_buf_size();
    end = memchr(buf, '|', buf_size);

    if (end) break;

    incoming->do_next();
  }

  buf_size = end - buf;

  scdc_result_t res = SCDC_RESULT_INIT_EMPTY;
  void *dataset = hook_arg.hook.dataset_open_read_state(dataprov, buf, buf_size, &res);
  result = SCDC_RESULT_STR(&res);

  if (!dataset)
  {
    SCDC_FAIL(__func__ << ": opening dataset by reading state with hook failed: '" << result << "'");
    return 0;
  }

  incoming->inc_read_pos(end - buf + 1);

  scdc_dataset_hook *dataset_hook = new scdc_dataset_hook(this, dataset);

  SCDC_TRACE("dataset_open_read_state: dataset_hook: '" << dataset_hook << "'");

  return dataset_hook;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
cmpq $0x0, 0x98(%rdi)
je 0x3b4a2
pushq $0x7c
popq %rbp
movq 0x20(%r15), %rdx
movq 0x28(%r15), %rax
movq 0x8(%r15), %r13
addq %rax, %r13
subq %rax, %rdx
movq %r13, %rdi
movl %ebp, %esi
callq 0xb5f0
testq %rax, %rax
jne 0x3b414
movq 0x38(%r15), %rax
testq %rax, %rax
je 0x3b3e3
movq %r15, %rdi
callq *%rax
jmp 0x3b3e3
movq %rax, %r12
subq %r13, %r12
leaq 0x8(%rsp), %rbp
movl $0x200, %edx            # imm = 0x200
movq %rbp, %rdi
xorl %esi, %esi
callq 0xb2f0
movq $0x200, -0x8(%rbp)      # imm = 0x200
movq 0xb8(%r14), %rdi
movq %rsp, %rcx
movq %r13, %rsi
movq %r12, %rdx
callq *0x98(%r14)
movq %rax, %r13
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xba40
testq %r13, %r13
je 0x3b4c1
movq 0x28(%r15), %rax
addq %r12, %rax
incq %rax
movq %rax, 0x28(%r15)
pushq $0x40
popq %rdi
callq 0xb540
movq %r14, 0x8(%rax)
xorl %ecx, %ecx
movb %cl, 0x10(%rax)
leaq 0x28(%rax), %rdx
movq %rdx, 0x18(%rax)
andq $0x0, 0x20(%rax)
movb %cl, 0x28(%rax)
leaq 0x38a4a(%rip), %rcx     # 0x73ee0
movq %rcx, (%rax)
movq %r13, 0x38(%rax)
jmp 0x3b54b
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2e2fe
leaq 0x3a0b8(%rip), %r14     # 0x75580
movq (%r14), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x3b549
addq $0x20, %rdi
callq 0xb800
movq (%r14), %rax
movq 0x8(%rax), %rdi
leaq 0x15c9f(%rip), %rsi     # 0x51188
callq 0xb520
leaq 0x1832d(%rip), %rsi     # 0x53822
movq %rax, %rdi
callq 0xb520
leaq 0x16029(%rip), %rsi     # 0x5152d
movq %rax, %rdi
callq 0xb520
leaq 0x183dc(%rip), %rsi     # 0x538ef
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
movq %rbx, %rsi
callq 0xb490
leaq 0x17e36(%rip), %rsi     # 0x53363
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
callq 0xb270
movq (%r14), %rdi
addq $0x20, %rdi
callq 0xb3e0
xorl %eax, %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop