// File: /workspace/github_cpp_makefile_star2_O3/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 0x316db(%rip), %rsi     # 0x6c012
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
leaq 0x30731(%rip), %rax     # 0x6b079
leaq 0x30936(%rip), %rsi     # 0x6b285
cmoveq %rax, %rsi
movl $0x10, %edx
movq %r14, %rdi
callq 0xb2a0
movq 0x48(%rbx), %rcx
testq %rcx, %rcx
je 0x3a9e2
movl $0x1, %esi
movq %r12, %rdi
movq %r15, %rdx
callq 0xb7f0
movq %rax, %r15
leaq 0x3168f(%rip), %rsi     # 0x6c012
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
jne 0x3ab2a
leaq 0x28(%rbx), %r13
leaq 0x3166d(%rip), %rsi     # 0x6c00b
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
je 0x3aade
leaq 0x3164b(%rip), %rsi     # 0x6c000
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
jne 0x3ab2a
testq %r15, %r15
jle 0x3ab2a
xorl %eax, %eax
addb $0x30, (%r12,%rax)
incq %rax
cmpq %rax, %r15
jne 0x3a9d0
jmp 0x3ab2a
leaq 0x3162f(%rip), %rsi     # 0x6c018
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
je 0x3aa90
leaq 0x31612(%rip), %rsi     # 0x6c012
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
jne 0x3ab2a
leaq 0x28(%rbx), %r13
leaq 0x315e5(%rip), %rsi     # 0x6c000
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
je 0x3ab1a
leaq 0x315d9(%rip), %rsi     # 0x6c00b
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
sete %al
testq %r15, %r15
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x3ab2a
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 0x3aa5d
jmp 0x3ab2a
leaq 0x28(%rbx), %r13
leaq 0x31565(%rip), %rsi     # 0x6c000
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
je 0x3ab13
leaq 0x3155d(%rip), %rsi     # 0x6c00b
movq %r13, %rdi
callq 0xb110
testl %eax, %eax
sete %al
testq %r15, %r15
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x3ab2a
xorl %r13d, %r13d
callq 0xb280
movb %al, (%r12,%r13)
incq %r13
cmpq %r13, %r15
jne 0x3aacb
jmp 0x3ab2a
testq %r15, %r15
jle 0x3ab2a
xorl %eax, %eax
movsbl (%r12,%rax), %ecx
imull $0x57, %ecx, %edx
movzwl %dx, %esi
shrl $0xd, %edx
shrl $0xf, %esi
addb %dl, %sil
movzbl %sil, %edx
imull $0x5f, %edx, %edx
subb %dl, %cl
addb $0x20, %cl
movb %cl, (%r12,%rax)
incq %rax
cmpq %rax, %r15
jne 0x3aae5
jmp 0x3ab2a
movq %r12, %rdi
xorl %esi, %esi
jmp 0x3ab22
movq %r12, %rdi
movl $0x30, %esi
movq %r15, %rdx
callq 0xb2d0
movq %r15, 0x20(%r14)
subq %r15, (%rbx)
jg 0x3ab8e
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%r14)
movq 0x48(%rbx), %rdi
testq %rdi, %rdi
je 0x3ab49
callq 0xb4f0
movq $0x0, 0x48(%rbx)
movq 0x28(%rbx), %rdi
leaq 0x38(%rbx), %rax
cmpq %rax, %rdi
je 0x3ab69
movq (%rax), %rsi
incq %rsi
callq 0xb510
movq 0x8(%rbx), %rdi
leaq 0x18(%rbx), %rax
cmpq %rax, %rdi
je 0x3ab81
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