// File: /workspace/github_cpp_makefile_star2_O1/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 0x31243(%rip), %rsi     # 0x6bf9a
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
leaq 0x302f1(%rip), %rax     # 0x6b059
leaq 0x304f6(%rip), %rsi     # 0x6b265
cmoveq %rax, %rsi
movl $0x10, %edx
movq %r14, %rdi
callq 0xb2a0
movq 0x48(%rbx), %rcx
testq %rcx, %rcx
je 0x3ae02
movl $0x1, %esi
movq %r12, %rdi
movq %r15, %rdx
callq 0xb7f0
movq %rax, %r15
leaq 0x311f7(%rip), %rsi     # 0x6bf9a
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
jne 0x3af4e
leaq 0x28(%rbx), %r13
leaq 0x311d5(%rip), %rsi     # 0x6bf93
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
je 0x3aefe
leaq 0x311b3(%rip), %rsi     # 0x6bf88
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
jne 0x3af4e
testq %r15, %r15
jle 0x3af4e
xorl %eax, %eax
addb $0x30, (%r12,%rax)
incq %rax
cmpq %rax, %r15
jne 0x3adf0
jmp 0x3af4e
leaq 0x31197(%rip), %rsi     # 0x6bfa0
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
je 0x3aeb0
leaq 0x3117a(%rip), %rsi     # 0x6bf9a
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
jne 0x3af4e
leaq 0x28(%rbx), %r13
leaq 0x3114d(%rip), %rsi     # 0x6bf88
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
je 0x3af3e
leaq 0x31141(%rip), %rsi     # 0x6bf93
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
sete %al
testq %r15, %r15
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x3af4e
xorl %r13d, %r13d
movabsq $-0x53896e7bf53896e7, %rbp # imm = 0xAC7691840AC76919
callq 0xb280
movq %rax, %rcx
imulq %rbp
addq %rcx, %rdx
movq %rdx, %rax
shrq $0x3f, %rax
shrl $0x6, %edx
addl %eax, %edx
imull $0x5f, %edx, %eax
subl %eax, %ecx
addb $0x20, %cl
movb %cl, (%r12,%r13)
incq %r13
cmpq %r13, %r15
jne 0x3ae7d
jmp 0x3af4e
leaq 0x28(%rbx), %r13
leaq 0x310cd(%rip), %rsi     # 0x6bf88
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
je 0x3af37
leaq 0x310c5(%rip), %rsi     # 0x6bf93
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
sete %al
testq %r15, %r15
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x3af4e
xorl %r13d, %r13d
callq 0xb280
movb %al, (%r12,%r13)
incq %r13
cmpq %r13, %r15
jne 0x3aeeb
jmp 0x3af4e
testq %r15, %r15
jle 0x3af4e
xorl %eax, %eax
movsbq (%r12,%rax), %rcx
imulq $-0x53896e7b, %rcx, %rdx # imm = 0xAC769185
shrq $0x20, %rdx
addl %ecx, %edx
movl %edx, %esi
shrl $0x1f, %esi
shrl $0x6, %edx
addl %esi, %edx
imull $0x5f, %edx, %edx
subl %edx, %ecx
addb $0x20, %cl
movb %cl, (%r12,%rax)
incq %rax
cmpq %rax, %r15
jne 0x3af05
jmp 0x3af4e
movq %r12, %rdi
xorl %esi, %esi
jmp 0x3af46
movq %r12, %rdi
movl $0x30, %esi
movq %r15, %rdx
callq 0xb2d0
movq %r15, 0x20(%r14)
subq %r15, (%rbx)
jg 0x3afb2
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%r14)
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x3af6d
callq 0xb4f0
movq $0x0, 0x48(%rbx)
movq 0x28(%rbx), %rdi
leaq 0x38(%rbx), %rax
cmpq %rax, %rdi
je 0x3af8d
movq (%rax), %rsi
incq %rsi
callq 0xb510
movq 0x8(%rbx), %rdi
leaq 0x18(%rbx), %rax
cmpq %rax, %rdi
je 0x3afa5
movq (%rax), %rsi
incq %rsi
callq 0xb510
movl $0x50, %esi
movq %rbx, %rdi
callq 0xb510
movl $0x1, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq