// File: 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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x6451e
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rsi
addq $0x18, %rsi
callq 0x2b080
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
leaq 0x43ac1(%rip), %rsi     # 0xa801a
callq 0x25b80
testb $0x1, %al
jne 0x64564
jmp 0x64571
leaq 0x42ac5(%rip), %rax     # 0xa7030
movq %rax, -0x58(%rbp)
jmp 0x6457e
leaq 0x42cc4(%rip), %rax     # 0xa723c
movq %rax, -0x58(%rbp)
jmp 0x6457e
movq -0x50(%rbp), %rdi
movq -0x58(%rbp), %rsi
movl $0x10, %edx
callq 0xc320
jmp 0x64592
movq -0x18(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x64691
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rcx
movl $0x1, %esi
callq 0xca10
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
leaq 0x43a4c(%rip), %rsi     # 0xa801a
callq 0x25b80
testb $0x1, %al
jne 0x645dc
jmp 0x6468c
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
leaq 0x43a28(%rip), %rsi     # 0xa8013
callq 0x25b80
testb $0x1, %al
jne 0x645f6
jmp 0x6463a
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x20(%rbp), %rax
jge 0x64638
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
movsbl (%rax,%rcx), %eax
movl $0x5f, %ecx
cltd
idivl %ecx
addl $0x20, %edx
movq -0x28(%rbp), %rax
movq -0x30(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x645fe
jmp 0x6468a
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
leaq 0x439bf(%rip), %rsi     # 0xa8008
callq 0x25b80
testb $0x1, %al
jne 0x64654
jmp 0x64688
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq -0x20(%rbp), %rax
jge 0x64686
movq -0x28(%rbp), %rax
movq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %edx
addl $0x30, %edx
movb %dl, (%rax,%rcx)
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x6465c
jmp 0x64688
jmp 0x6468a
jmp 0x6468c
jmp 0x647e1
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
leaq 0x43980(%rip), %rsi     # 0xa8020
callq 0x25b80
testb $0x1, %al
jne 0x646ae
jmp 0x64734
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
leaq 0x4394b(%rip), %rsi     # 0xa8008
callq 0x25b80
testb $0x1, %al
jne 0x646c8
jmp 0x646d9
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rdx
xorl %esi, %esi
callq 0xc350
jmp 0x6472f
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
leaq 0x4392b(%rip), %rsi     # 0xa8013
callq 0x25b80
testb $0x1, %al
jne 0x646f3
jmp 0x6472d
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
cmpq -0x20(%rbp), %rax
jge 0x6472b
callq 0xc300
andq $0xff, %rax
movb %al, %dl
movq -0x28(%rbp), %rax
movq -0x40(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x646fb
jmp 0x6472d
jmp 0x6472f
jmp 0x647df
movq -0x18(%rbp), %rdi
addq $0x8, %rdi
leaq 0x438d7(%rip), %rsi     # 0xa801a
callq 0x25b80
testb $0x1, %al
jne 0x64751
jmp 0x647dd
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
leaq 0x438a8(%rip), %rsi     # 0xa8008
callq 0x25b80
testb $0x1, %al
jne 0x6476b
jmp 0x6477f
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rdx
movl $0x30, %esi
callq 0xc350
jmp 0x647db
movq -0x18(%rbp), %rdi
addq $0x28, %rdi
leaq 0x43885(%rip), %rsi     # 0xa8013
callq 0x25b80
testb $0x1, %al
jne 0x64799
jmp 0x647d9
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x20(%rbp), %rax
jge 0x647d7
callq 0xc300
movl $0x5f, %ecx
cqto
idivq %rcx
addq $0x20, %rdx
movq -0x28(%rbp), %rax
movq -0x48(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x647a1
jmp 0x647d9
jmp 0x647db
jmp 0x647dd
jmp 0x647df
jmp 0x647e1
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x20(%rbp), %rdx
movq -0x18(%rbp), %rax
movq (%rax), %rcx
subq %rdx, %rcx
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
jg 0x6486f
jmp 0x6480a
jmp 0x6480c
movq -0x8(%rbp), %rax
movq $0x0, 0x38(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0x6483c
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0xc680
movq -0x18(%rbp), %rax
movq $0x0, 0x48(%rax)
movq -0x18(%rbp), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x6486d
movq -0x60(%rbp), %rdi
callq 0x64ea0
movq -0x60(%rbp), %rdi
movl $0x50, %esi
callq 0xc6a0
jmp 0x6486f
movl $0x1, %eax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)