// File: /workspace/github_cpp_makefile_star2_O2/mh0fm4[P]SCDC/src/components/dataprov/dataprov_bench.cc
// Function: dataset_output_next(_scdc_dataset_inout_t*, _scdc_result_t*)
static scdcint_t dataset_output_next(scdc_dataset_output_t *output, scdc_result_t *result)
{
  dataset_output_next_data_t *data = static_cast<dataset_output_next_data_t *>(output->data);

  SCDC_TRACE_DATASET_OUTPUT(output, "dataset_output_next: ");

  /* min of data left and buffer size */
  scdcint_t size = min(data->total_size_left, SCDC_DATASET_INOUT_BUF_SIZE(output));

  char *buf = static_cast<char *>(SCDC_DATASET_INOUT_BUF_PTR(output));

  strncpy(output->format, (data->format == "ascii")?"text":"data", SCDC_FORMAT_MAX_SIZE);

  SCDC_TRACE("dataset_output_next: get data of size = " << size);

  if (data->file)
  {
    size = fread(buf, 1, size, data->file);

    if (data->format == "ascii")
    {
      if (data->content == "random")
      {
        for (scdcint_t i = 0; i < size; ++i) buf[i] = 32 + buf[i] % (126 - 32 + 1);

      } else if (data->content == "zero")
      {
        for (scdcint_t i = 0; i < size; ++i) buf[i] += '0';
      }
    }

  } else
  {
    if (data->format == "binary")
    {
      if (data->content == "zero")
      {
        memset(buf, 0, size);

      } else if (data->content == "random")
      {
        for (scdcint_t i = 0; i < size; ++i) buf[i] = random() & 0xFF;
      }

    } else if (data->format == "ascii")
    {
      if (data->content == "zero")
      {
        memset(buf, '0', size);

      } else if (data->content == "random")
      {
        for (scdcint_t i = 0; i < size; ++i) buf[i] = 32 + random() % (126 - 32 + 1);
      }
    }
  }

  SCDC_DATASET_INOUT_BUF_CURRENT(output) = size;

  data->total_size_left -= size;

  if (data->total_size_left <= 0)
  {
    SCDC_TRACE("dataset_output_next: done");

    output->next = 0;
    output->data = 0;

    if (data->file) fclose(data->file);
    data->file = 0;

    delete data;
  }

  return SCDC_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x40(%rdi), %rbx
movq 0x10(%rdi), %r12
movq 0x18(%rdi), %rax
movq (%rbx), %r15
cmpq %r15, %rax
cmovlq %rax, %r15
leaq 0x8(%rbx), %r13
leaq 0x22027(%rip), %rsi     # 0x52fa2
movq %r13, %rdi
callq 0x19be0
leaq 0x2107f(%rip), %rcx     # 0x52009
leaq 0x21284(%rip), %rsi     # 0x52215
testb %al, %al
cmovneq %rcx, %rsi
pushq $0x10
popq %rdx
movq %r14, %rdi
callq 0xb2c0
movq 0x48(%rbx), %rcx
testq %rcx, %rcx
je 0x3101c
pushq $0x1
popq %rsi
movq %r12, %rdi
movq %r15, %rdx
callq 0xb820
movq %rax, %r15
leaq 0x21fdf(%rip), %rsi     # 0x52fa2
movq %r13, %rdi
callq 0x19be0
testb %al, %al
je 0x31135
leaq 0x28(%rbx), %r13
leaq 0x21fbd(%rip), %rsi     # 0x52f9b
movq %r13, %rdi
callq 0x19be0
testb %al, %al
je 0x3108e
xorl %ecx, %ecx
testq %r15, %r15
movq %r15, %rdx
cmovleq %rcx, %rdx
movb $0x5f, %sil
cmpq %rcx, %rdx
je 0x31135
movsbl (%r12,%rcx), %eax
idivb %sil
movsbl %ah, %eax
addb $0x20, %al
movb %al, (%r12,%rcx)
incq %rcx
jmp 0x30ffd
leaq 0x21f85(%rip), %rsi     # 0x52fa8
movq %r13, %rdi
callq 0x19be0
testb %al, %al
je 0x3104d
leaq 0x28(%rbx), %r13
leaq 0x21f56(%rip), %rsi     # 0x52f90
movq %r13, %rdi
callq 0x19be0
testb %al, %al
je 0x310c0
movq %r12, %rdi
xorl %esi, %esi
jmp 0x31081
leaq 0x21f4e(%rip), %rsi     # 0x52fa2
movq %r13, %rdi
callq 0x19be0
testb %al, %al
je 0x31135
leaq 0x28(%rbx), %r13
leaq 0x21f21(%rip), %rsi     # 0x52f90
movq %r13, %rdi
callq 0x19be0
testb %al, %al
je 0x310f5
pushq $0x30
popq %rsi
movq %r12, %rdi
movq %r15, %rdx
callq 0xb2f0
jmp 0x31135
leaq 0x21efb(%rip), %rsi     # 0x52f90
movq %r13, %rdi
callq 0x19be0
testb %al, %al
je 0x31135
xorl %eax, %eax
testq %r15, %r15
movq %r15, %rcx
cmovleq %rax, %rcx
cmpq %rax, %rcx
je 0x31135
addb $0x30, (%r12,%rax)
incq %rax
jmp 0x310b1
leaq 0x21ed4(%rip), %rsi     # 0x52f9b
movq %r13, %rdi
callq 0x19be0
testb %al, %al
je 0x31135
xorl %r13d, %r13d
testq %r15, %r15
movl $0x0, %ebp
cmovgq %r15, %rbp
cmpq %r13, %rbp
je 0x31135
callq 0xb2a0
movb %al, (%r12,%r13)
incq %r13
jmp 0x310e2
leaq 0x21e9f(%rip), %rsi     # 0x52f9b
movq %r13, %rdi
callq 0x19be0
testb %al, %al
je 0x31135
xorl %r13d, %r13d
testq %r15, %r15
movl $0x0, %ebp
cmovgq %r15, %rbp
cmpq %r13, %rbp
je 0x31135
callq 0xb2a0
cqto
pushq $0x5f
popq %rcx
idivq %rcx
addb $0x20, %dl
movb %dl, (%r12,%r13)
incq %r13
jmp 0x31117
movq %r15, 0x20(%r14)
subq %r15, (%rbx)
jg 0x3116c
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%r14)
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x31154
callq 0xb530
andq $0x0, 0x48(%rbx)
movq %rbx, %rdi
callq 0x314f0
pushq $0x50
popq %rsi
movq %rbx, %rdi
callq 0xb550
pushq $0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq