// File: /workspace/github_cpp_makefile_star2_O1/mh0fm4[P]SCDC/src/components/dataprov/dataprov_relay.cc
// Function: scdc_dataprov_relay::dataset_open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
scdc_dataset *scdc_dataprov_relay::dataset_open(std::string &path, scdc_result &result)
{
  SCDC_TRACE("dataset_open: path: '" << path << "'");

  scdc_dataset_relay *dataset_relay = 0;
  scdc_dataset_t ds = SCDC_DATASET_NULL;

  relay_t::iterator r;
  for (r = relay.begin(); r != relay.end(); ++r)
  {
    const string &relay_path = r->first;

    /* if the given path does not contain the relay_path as a prefix, then skip */
    if (path.substr(0, relay_path.size()) != relay_path) continue;

    /* remove the relay_path prefix from the full path */
    string p = path.substr(relay_path.size());

    /* if the full path without the relay_path prefix does not continue with a slash, then skip */
    if (!p.empty() && p[0] != '/') continue;

    /* remove leading slashs */
    p = ltrim(p, "/");

    const string &dst_path = r->second;

    string uri = dst_path + "/" + p;

    ds = scdc_dataset_open(uri.c_str());

    if (ds == SCDC_DATASET_NULL)
    {
      result = "opening remote dataset '" + uri + "' failed";
      SCDC_FAIL(__func__ << ": scdc_dataset_open failed: " << result);
    }

    break;
  }

  if (r == relay.end()) result = "no matching relay found";

  if (ds == SCDC_DATASET_NULL)
  {
    SCDC_FAIL(__func__ << ": failed: " << result);
    goto do_return;
  }

  /* unset path to prevent a further cd command */
  path.clear();

  dataset_relay = new scdc_dataset_relay(this, ds);

do_return:
  SCDC_TRACE("dataset_open: return: " << dataset_relay);

  return dataset_relay;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rdx, 0x8(%rsp)
movq %rsi, 0x30(%rsp)
movq 0xb0(%rdi), %r12
movq %rdi, 0x80(%rsp)
leaq 0xa0(%rdi), %rax
movq %rax, 0x78(%rsp)
cmpq %rax, %r12
je 0x20ed2
leaq 0x38(%rsp), %r14
leaq 0x88(%rsp), %r13
xorl %ebp, %ebp
movq 0x28(%r12), %rcx
movq %r14, %r15
movq %r14, %rdi
movq 0x30(%rsp), %rsi
xorl %edx, %edx
callq 0xb530
movq 0x40(%rsp), %rdx
movb $0x1, %r14b
cmpq 0x28(%r12), %rdx
jne 0x20baf
testq %rdx, %rdx
je 0x20bac
movq 0x20(%r12), %rsi
movq 0x38(%rsp), %rdi
callq 0xb520
testl %eax, %eax
setne %r14b
jmp 0x20baf
xorl %r14d, %r14d
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x20bcb
movq 0x48(%rsp), %rsi
incq %rsi
callq 0xb510
movb $0x1, %bl
testb %r14b, %r14b
je 0x20bda
movq %r15, %r14
jmp 0x20eb6
movq 0x28(%r12), %rdx
movq %r15, %r14
movq %r15, %rdi
movq 0x30(%rsp), %rsi
movq $-0x1, %rcx
callq 0xb530
cmpq $0x0, 0x40(%rsp)
je 0x20c0e
movq 0x38(%rsp), %rax
movb $0x1, %bl
cmpb $0x2f, (%rax)
jne 0x20e9a
movl $0x1, %ecx
movq %r14, %rdi
leaq 0x49730(%rip), %rbx     # 0x6a34d
movq %rbx, %rsi
xorl %edx, %edx
callq 0xb980
movq %r14, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0xb0e0
movq %r14, %rdi
movq %r14, %rsi
callq 0xb2c0
leaq 0x20(%rsp), %r14
movq %r14, 0x10(%rsp)
movq 0x40(%r12), %rsi
movq 0x48(%r12), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rbp
movq %rbp, %rdi
callq 0x1d19a
movq %rbp, %rdi
movq %rbx, %rsi
callq 0xba60
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq %rbp, %rdi
callq 0xb150
leaq 0x68(%rsp), %rsi
movq %rsi, 0x58(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x20ca8
movq %rdx, 0x58(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x68(%rsp)
jmp 0x20cae
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, 0x60(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x20cdd
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x58(%rsp), %rdi
xorl %eax, %eax
callq 0x19faa
movq %rax, %rbp
movq %r15, %r14
testq %rax, %rax
jne 0x20e7c
movq %r13, %rbx
movq %r13, %rdi
leaq 0x4c824(%rip), %rsi     # 0x6d529
leaq 0x58(%rsp), %rdx
callq 0x1b85e
movq %rbx, %rdi
leaq 0x4b16f(%rip), %rsi     # 0x6be88
callq 0xba60
leaq 0x20(%rsp), %rbx
movq %rbx, 0x10(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x20d46
movq %rdx, 0x10(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x20(%rsp)
jmp 0x20d4c
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
movq %rdx, 0x18(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x8(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xb670
movq 0x10(%rsp), %rdi
cmpq %rbx, %rdi
je 0x20d8a
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x20daf
movq 0x98(%rsp), %rsi
incq %rsi
callq 0xb510
leaq 0x6b7ba(%rip), %rax     # 0x8c570
movq (%rax), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x20e7c
addq $0x20, %rdi
callq 0xb7d0
leaq 0x6b79c(%rip), %rax     # 0x8c570
movq (%rax), %rax
movq 0x8(%rax), %rbx
movl $0xb, %edx
movq %rbx, %rdi
leaq 0x4939e(%rip), %rsi     # 0x6a188
callq 0xb5f0
movl $0x10, %edx
movq %rbx, %rdi
leaq 0x49abb(%rip), %rsi     # 0x6a8b9
callq 0xb5f0
movl $0xc, %edx
movq %rbx, %rdi
leaq 0x496d7(%rip), %rsi     # 0x6a4e9
callq 0xb5f0
movl $0x1c, %edx
movq %rbx, %rdi
leaq 0x49aa4(%rip), %rsi     # 0x6a8ca
callq 0xb5f0
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %rbx, %rdi
callq 0xb5f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0xb4d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0xb050
movq %rax, %rdi
callq 0xb340
leaq 0x6b700(%rip), %rax     # 0x8c570
movq (%rax), %rdi
addq $0x20, %rdi
callq 0xb3b0
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x20e98
movq 0x68(%rsp), %rsi
incq %rsi
callq 0xb510
xorl %ebx, %ebx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x20eb6
movq 0x48(%rsp), %rsi
incq %rsi
callq 0xb510
testb %bl, %bl
je 0x20ed4
movq %r12, %rdi
callq 0xb350
movq %rax, %r12
cmpq 0x78(%rsp), %rax
jne 0x20b6a
jmp 0x20ed4
xorl %ebp, %ebp
cmpq 0x78(%rsp), %r12
jne 0x20ef8
movq 0x8(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x499fc(%rip), %rcx     # 0x6a8e7
movl $0x17, %r8d
xorl %esi, %esi
callq 0xb870
testq %rbp, %rbp
je 0x20f48
xorl %ebx, %ebx
movq 0x30(%rsp), %rax
movq %rbx, 0x8(%rax)
movq (%rax), %rax
movb %bl, (%rax)
movl $0x40, %edi
callq 0xb500
movq 0x80(%rsp), %rcx
movq %rcx, 0x8(%rax)
movb %bl, 0x10(%rax)
leaq 0x28(%rax), %rcx
movq %rcx, 0x18(%rax)
movq %rbx, 0x20(%rax)
movb %bl, 0x28(%rax)
leaq 0x69234(%rip), %rcx     # 0x8a170
movq %rcx, (%rax)
movq %rbp, 0x38(%rax)
jmp 0x21009
leaq 0x6b621(%rip), %r14     # 0x8c570
movq (%r14), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x21007
addq $0x20, %rdi
callq 0xb7d0
movq (%r14), %rax
movq 0x8(%rax), %rbx
leaq 0x49214(%rip), %rsi     # 0x6a188
movl $0xb, %edx
movq %rbx, %rdi
callq 0xb5f0
leaq 0x49931(%rip), %rsi     # 0x6a8b9
movl $0x10, %edx
movq %rbx, %rdi
callq 0xb5f0
leaq 0x4954d(%rip), %rsi     # 0x6a4e9
movl $0xc, %edx
movq %rbx, %rdi
callq 0xb5f0
leaq 0x4994f(%rip), %rsi     # 0x6a8ff
movl $0xa, %edx
movq %rbx, %rdi
callq 0xb5f0
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %rbx, %rdi
callq 0xb5f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0xb4d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0xb050
movq %rax, %rdi
callq 0xb340
movq (%r14), %rdi
addq $0x20, %rdi
callq 0xb3b0
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x21067
movq 0x98(%rsp), %rsi
incq %rsi
callq 0xb510
jmp 0x21067
jmp 0x21064
jmp 0x2104b
jmp 0x2105f
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x21083
movq 0x20(%rsp), %rsi
jmp 0x2107b
movq %rax, %rbx
jmp 0x21083
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x21083
movq 0x68(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x2109f
movq 0x48(%rsp), %rsi
incq %rsi
callq 0xb510
movq %rbx, %rdi
callq 0xb9c0
nop