// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
movq 0xb0(%rdi), %r12
movq %rdi, 0x20(%rsp)
leaq 0xa0(%rdi), %rax
movq %rax, 0x18(%rsp)
leaq 0x48(%rsp), %r13
leaq 0x88(%rsp), %r15
xorl %r14d, %r14d
movq %rsi, 0x10(%rsp)
cmpq 0x18(%rsp), %r12
je 0x1e0ba
leaq 0x20(%r12), %rbp
movq 0x28(%r12), %rcx
movq %r13, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0xb560
movq %r13, %rdi
movq %rbp, %rsi
callq 0x1eea8
movl %eax, %ebp
movq %r13, %rdi
callq 0xb230
testb %bpl, %bpl
jne 0x1e09e
movq 0x28(%r12), %rdx
movq %r13, %rdi
movq %rbx, %rsi
pushq $-0x1
popq %rcx
callq 0xb560
cmpq $0x0, 0x50(%rsp)
je 0x1df40
movq 0x48(%rsp), %rax
movb $0x1, %bpl
cmpb $0x2f, (%rax)
jne 0x1e091
movq %r13, %rdi
leaq 0x33403(%rip), %r14     # 0x5134d
movq %r14, %rsi
xorl %edx, %edx
callq 0xb300
movq %r13, %rdi
xorl %esi, %esi
movq %rax, %rdx
callq 0xb0e0
movq %r13, %rdi
movq %r13, %rsi
callq 0xb2e0
leaq 0x40(%r12), %rsi
leaq 0x68(%rsp), %rbp
movq %rbp, %rdi
movq %r14, %rdx
callq 0x1d867
leaq 0x28(%rsp), %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0x1eeb2
movq %rbp, %rdi
callq 0xb230
movq 0x28(%rsp), %rdi
xorl %eax, %eax
callq 0x187db
movq %rax, %r14
testq %rax, %rax
jne 0x1e085
movq %r15, %rbx
movq %r15, %rdi
leaq 0x3656b(%rip), %rsi     # 0x54529
leaq 0x28(%rsp), %rdx
callq 0x19ae2
leaq 0x68(%rsp), %rbp
movq %rbp, %rdi
movq %rbx, %rsi
leaq 0x34eb6(%rip), %rdx     # 0x52e90
callq 0x1cb18
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0xb690
movq %rbp, %rdi
callq 0xb230
movq %rbx, %rdi
callq 0xb230
leaq 0x5757d(%rip), %rax     # 0x75580
movq (%rax), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x1e085
addq $0x20, %rdi
callq 0xb800
leaq 0x57563(%rip), %rax     # 0x75580
movq (%rax), %rax
movq 0x8(%rax), %rdi
leaq 0x3315d(%rip), %rsi     # 0x51188
callq 0xb520
movq %rax, %rdi
leaq 0x33834(%rip), %rsi     # 0x5186e
callq 0xb520
movq %rax, %rdi
leaq 0x334a0(%rip), %rsi     # 0x514e9
callq 0xb520
movq %rax, %rdi
leaq 0x33827(%rip), %rsi     # 0x5187f
callq 0xb520
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0xb490
movq %rax, %rdi
callq 0xb270
leaq 0x57507(%rip), %rax     # 0x75580
movq (%rax), %rdi
addq $0x20, %rdi
callq 0xb3e0
leaq 0x28(%rsp), %rdi
callq 0xb230
xorl %ebp, %ebp
movq %r13, %rdi
callq 0xb230
testb %bpl, %bpl
je 0x1e0b3
movq %r12, %rdi
callq 0xb380
movq %rax, %r12
movq 0x10(%rsp), %rbx
jmp 0x1ded4
cmpq 0x18(%rsp), %r12
jne 0x1e0cb
leaq 0x337db(%rip), %rsi     # 0x5189c
movq 0x8(%rsp), %rdi
callq 0xba40
testq %r14, %r14
je 0x1e115
movq 0x10(%rsp), %rax
andq $0x0, 0x8(%rax)
movq (%rax), %rax
xorl %ebx, %ebx
movb %bl, (%rax)
pushq $0x40
popq %rdi
callq 0xb540
movq 0x20(%rsp), %rcx
movq %rcx, 0x8(%rax)
movb %bl, 0x10(%rax)
leaq 0x28(%rax), %rcx
movq %rcx, 0x18(%rax)
andq $0x0, 0x20(%rax)
movb %bl, 0x28(%rax)
leaq 0x5502c(%rip), %rcx     # 0x73138
movq %rcx, (%rax)
movq %r14, 0x38(%rax)
jmp 0x1e192
leaq 0x57464(%rip), %rbx     # 0x75580
movq (%rbx), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x1e190
addq $0x20, %rdi
callq 0xb800
movq (%rbx), %rax
movq 0x8(%rax), %rdi
leaq 0x3304b(%rip), %rsi     # 0x51188
callq 0xb520
leaq 0x33725(%rip), %rsi     # 0x5186e
movq %rax, %rdi
callq 0xb520
leaq 0x33391(%rip), %rsi     # 0x514e9
movq %rax, %rdi
callq 0xb520
leaq 0x3374d(%rip), %rsi     # 0x518b4
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0xb490
movq %rax, %rdi
callq 0xb270
movq (%rbx), %rdi
addq $0x20, %rdi
callq 0xb3e0
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0xb230
jmp 0x1e1cc
jmp 0x1e1c9
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
jmp 0x1e1d1
jmp 0x1e1c4
movq %rax, %rbx
jmp 0x1e1d6
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0xb230
leaq 0x48(%rsp), %rdi
callq 0xb230
movq %rbx, %rdi
callq 0xb9a0