// File: 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
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x130(%rbp)
jmp 0x32c24
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x34930
movq -0x130(%rbp), %rdi
addq $0x98, %rdi
callq 0x34950
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x130(%rbp), %rdi
addq $0x98, %rdi
callq 0x349b0
movq %rax, -0x40(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x34980
testb $0x1, %al
jne 0x32c89
jmp 0x33058
leaq -0x30(%rbp), %rdi
callq 0x349e0
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x140(%rbp)
movq -0x48(%rbp), %rdi
callq 0xc460
movq -0x140(%rbp), %rsi
movq %rax, %rcx
leaq -0x68(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
callq 0xc6b0
movq -0x48(%rbp), %rsi
leaq -0x68(%rbp), %rdi
callq 0x34a00
movb %al, -0x131(%rbp)
leaq -0x68(%rbp), %rdi
callq 0xc3e0
movb -0x131(%rbp), %al
testb $0x1, %al
jne 0x32ce9
jmp 0x32cee
jmp 0x3304a
movq -0x10(%rbp), %rax
movq %rax, -0x148(%rbp)
movq -0x48(%rbp), %rdi
callq 0xc460
movq -0x148(%rbp), %rsi
movq %rax, %rdx
leaq -0x88(%rbp), %rdi
movq $-0x1, %rcx
callq 0xc6b0
leaq -0x88(%rbp), %rdi
callq 0xcb60
testb $0x1, %al
jne 0x32d7d
xorl %eax, %eax
movl %eax, %esi
leaq -0x88(%rbp), %rdi
callq 0xcd00
movq %rax, -0x150(%rbp)
jmp 0x32d48
movq -0x150(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
je 0x32d7d
movl $0x6, -0x98(%rbp)
jmp 0x3301e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x33039
leaq 0x735e9(%rip), %rsi     # 0xa636d
leaq -0x88(%rbp), %rdi
callq 0x331d0
movq %rax, -0x158(%rbp)
jmp 0x32d99
movq -0x158(%rbp), %rsi
leaq -0x88(%rbp), %rdi
callq 0xc070
jmp 0x32dae
leaq -0x30(%rbp), %rdi
callq 0x349e0
addq $0x20, %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rsi
leaq 0x7359d(%rip), %rdx     # 0xa636d
leaq -0xe0(%rbp), %rdi
callq 0x31740
jmp 0x32dde
leaq -0xc0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x34a30
jmp 0x32dfa
leaq -0xe0(%rbp), %rdi
callq 0xc3e0
leaq -0xc0(%rbp), %rdi
callq 0xc260
movq %rax, %rdi
xorl %eax, %eax
callq 0x22ef0
movq %rax, -0x160(%rbp)
jmp 0x32e25
movq -0x160(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x32ff8
leaq 0x76733(%rip), %rsi     # 0xa9575
leaq -0x120(%rbp), %rdi
leaq -0xc0(%rbp), %rdx
callq 0x25900
jmp 0x32e57
leaq 0x750ae(%rip), %rdx     # 0xa7f0c
leaq -0x100(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0x2eef0
jmp 0x32e73
movq -0x18(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0xc850
leaq -0x100(%rbp), %rdi
callq 0xc3e0
leaq -0x120(%rbp), %rdi
callq 0xc3e0
leaq 0xa1806(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x257e0
movq %rax, -0x168(%rbp)
jmp 0x32eb3
movq -0x168(%rbp), %rax
cmpq $0x0, %rax
je 0x32ff2
leaq 0xa17dd(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x25800
jmp 0x32ed5
leaq 0xa17cc(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x257e0
movq %rax, -0x170(%rbp)
jmp 0x32eed
movq -0x170(%rbp), %rdi
leaq 0x732b5(%rip), %rsi     # 0xa61b0
callq 0xc670
movq %rax, -0x178(%rbp)
jmp 0x32f09
movq -0x178(%rbp), %rdi
leaq 0x7397a(%rip), %rsi     # 0xa6891
callq 0xc670
movq %rax, -0x180(%rbp)
jmp 0x32f25
movq -0x180(%rbp), %rdi
leaq 0x735d6(%rip), %rsi     # 0xa6509
callq 0xc670
movq %rax, -0x188(%rbp)
jmp 0x32f41
movq -0x188(%rbp), %rdi
leaq 0x73953(%rip), %rsi     # 0xa68a2
callq 0xc670
movq %rax, -0x190(%rbp)
jmp 0x32f5d
movq -0x190(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xc5b0
movq %rax, -0x198(%rbp)
jmp 0x32f76
movq -0x198(%rbp), %rdi
movq 0xa103c(%rip), %rsi     # 0xd3fc0
callq 0xc6d0
jmp 0x32f8b
leaq 0xa1716(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x25820
jmp 0x32f9c
jmp 0x32ff2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0xe0(%rbp), %rdi
callq 0xc3e0
jmp 0x33039
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x33010
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x120(%rbp), %rdi
callq 0xc3e0
jmp 0x33010
jmp 0x32ff4
jmp 0x32ff6
jmp 0x32ff8
movl $0x4, -0x98(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0xc3e0
jmp 0x3301e
leaq -0xc0(%rbp), %rdi
callq 0xc3e0
jmp 0x33039
leaq -0x88(%rbp), %rdi
callq 0xc3e0
movl -0x98(%rbp), %eax
subl $0x4, %eax
je 0x33058
jmp 0x33037
jmp 0x3304a
leaq -0x88(%rbp), %rdi
callq 0xc3e0
jmp 0x331b7
leaq -0x30(%rbp), %rdi
callq 0x34a80
jmp 0x32c5c
movq -0x130(%rbp), %rdi
addq $0x98, %rdi
callq 0x349b0
movq %rax, -0x128(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x34ab0
testb $0x1, %al
jne 0x33088
jmp 0x33098
movq -0x18(%rbp), %rdi
leaq 0x7382c(%rip), %rsi     # 0xa68bf
callq 0xc920
cmpq $0x0, -0x28(%rbp)
jne 0x33146
jmp 0x330a5
leaq 0xa15fc(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x257e0
cmpq $0x0, %rax
je 0x33142
leaq 0xa15e3(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x25800
leaq 0xa15d4(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x257e0
movq %rax, %rdi
leaq 0x730ca(%rip), %rsi     # 0xa61b0
callq 0xc670
movq %rax, %rdi
leaq 0x7379c(%rip), %rsi     # 0xa6891
callq 0xc670
movq %rax, %rdi
leaq 0x73405(%rip), %rsi     # 0xa6509
callq 0xc670
movq %rax, %rdi
leaq 0x737c4(%rip), %rsi     # 0xa68d7
callq 0xc670
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0xc5b0
movq %rax, %rdi
movq 0xa0e92(%rip), %rsi     # 0xd3fc0
callq 0xc6d0
leaq 0xa156e(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x25820
jmp 0x33144
jmp 0x33183
movq -0x10(%rbp), %rdi
callq 0xc8f0
movl $0x40, %edi
callq 0xc690
movq -0x130(%rbp), %rsi
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x1a0(%rbp)
movq -0x28(%rbp), %rdx
callq 0x34ae0
jmp 0x33178
movq -0x1a0(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x33185
jmp 0x33187
movq -0x20(%rbp), %rax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq -0x1a0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
movl $0x40, %esi
callq 0xc6a0
movq -0x90(%rbp), %rdi
callq 0xcba0
nopw %cs:(%rax,%rax)