// File: mh0fm4[P]SCDC/test/demos/fstream/../../../src/lib/redirect/fstream/basic_file_scdc.h
// Function: scdc::__basic_file_scdc<char>::seekoff(long, std::_Ios_Seekdir)
streamoff
      seekoff(streamoff __off, ios_base::seekdir __way) throw ()
      {
        TRACE(__class__, __func__, "");

        streamoff ret = -1;

        if (__way == ios_base::end)
        {
          char buf[32];
          scdc_dataset_output_t output;

          scdc_dataset_output_unset(&output);
          SCDC_DATASET_INOUT_BUF_PTR(&output) = buf;
          SCDC_DATASET_INOUT_BUF_SIZE(&output) = sizeof(buf) - 1;

          if (scdc_dataset_cmd(_M_dataset, "ls", NULL, &output) != SCDC_SUCCESS) goto do_return;

          long long o;
          std::string s(static_cast<const char *>(SCDC_DATASET_INOUT_BUF_PTR(&output)), SCDC_DATASET_INOUT_BUF_CURRENT(&output));
          sscanf(s.c_str(), "f:%lld|", &o);
          offset = o;
          __way = ios_base::cur;

          while (output.next) output.next(&output, 0);
        }

        switch (__way)
        {
          case ios_base::beg:
            offset = std::max(static_cast<streamoff>(0), __off);
            ret = offset;
            break;
          case ios_base::cur:
            offset += __off;
            ret = offset;
            break;
          default:
            ret = -1;
            break;
        }

        if (ret >= 0) eof = false;

do_return:
        return ret;
      }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
jmp 0x114b3
jmp 0x114b5
movq $-0x1, -0x20(%rbp)
cmpl $0x2, -0x14(%rbp)
jne 0x115e4
leaq -0x98(%rbp), %rdi
callq 0x33f30
jmp 0x114d5
movq -0xd8(%rbp), %rax
leaq -0x40(%rbp), %rcx
movq %rcx, -0x88(%rbp)
movq $0x1f, -0x80(%rbp)
movq (%rax), %rdi
leaq 0x7d727(%rip), %rsi     # 0x8ec20
xorl %eax, %eax
movl %eax, %edx
leaq -0x98(%rbp), %rcx
callq 0x14970
movq %rax, -0xe0(%rbp)
jmp 0x11512
movq -0xe0(%rbp), %rax
cmpq $0x1, %rax
je 0x11524
jmp 0x1167c
movq -0x88(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0xf0(%rbp)
leaq -0xc1(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0xdd20
movq -0xf8(%rbp), %rsi
movq -0xf0(%rbp), %rdx
movq -0xe8(%rbp), %rcx
leaq -0xc0(%rbp), %rdi
callq 0xd840
jmp 0x11573
leaq -0xc1(%rbp), %rdi
callq 0xd7b0
leaq -0xc0(%rbp), %rdi
callq 0xd290
movq %rax, %rdi
leaq 0x7e05f(%rip), %rsi     # 0x8f5f4
leaq -0xa0(%rbp), %rdx
movb $0x0, %al
callq 0xd6b0
movq -0xd8(%rbp), %rax
movq -0xa0(%rbp), %rcx
movq %rcx, 0x10(%rax)
movl $0x1, -0x14(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x115d8
movq -0x60(%rbp), %rax
xorl %ecx, %ecx
movl %ecx, %esi
leaq -0x98(%rbp), %rdi
callq *%rax
jmp 0x115d6
jmp 0x115bc
leaq -0xc0(%rbp), %rdi
callq 0xd420
movl -0x14(%rbp), %eax
movl %eax, -0xfc(%rbp)
testl %eax, %eax
je 0x11600
jmp 0x115f3
movl -0xfc(%rbp), %eax
subl $0x1, %eax
je 0x11643
jmp 0x11660
movq $0x0, -0xd0(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x116c0
movq %rax, -0x108(%rbp)
jmp 0x11624
movq -0xd8(%rbp), %rax
movq -0x108(%rbp), %rcx
movq (%rcx), %rcx
movq %rcx, 0x10(%rax)
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x11668
movq -0xd8(%rbp), %rax
movq -0x10(%rbp), %rcx
addq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x11668
movq $-0x1, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jl 0x1167a
movq -0xd8(%rbp), %rax
movb $0x0, 0x18(%rax)
jmp 0x1167c
movq -0x20(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq %rax, %rdi
callq 0xeec0
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)