// File: /workspace/github_c_makefile_star2_O1/0xADE1A1DE[P]MeasureSuite/lib/src/evaluator.c
// Function: run_measurement
int run_measurement(struct measuresuite *ms) {

  // init result indicator
  size_t check_result = 0;
  if (init_cycle_results(ms)) {
    return 1;
  };

  // START MEASUREMENT
  uint64_t start_time = current_timestamp();

  DEBUG("Evaluating %lu batches\n", ms->num_batches);
  for (size_t batch_i = 0; batch_i < ms->num_batches; batch_i++) {

    if (randomize(ms) != 0 || shuffle_permutations(ms) != 0) {
      return 1;
    }

    DEBUG("Evaluating %lu functions\n", ms->num_functions);
    // for as many functions as we need to measure
    for (size_t func_i = 0; func_i < ms->num_functions; func_i++) {

      // get the function to measure
      size_t function_index = ms->permutation[func_i];
      struct function_tuple *fct = &ms->functions[function_index];

      // measure
      DEBUG("Run batch %lu for function %lu\n", batch_i, function_index);
      run_batch(ms, fct, &fct->cycle_results[batch_i]);
    }

    if (ms->enable_check) {

      for (size_t func_i = 1; func_i < ms->num_functions; func_i++) {

        // get the tuple and the previous
        struct function_tuple *fct = &ms->functions[func_i];
        struct function_tuple *prev = &ms->functions[func_i - 1];

        // check
        DEBUG("Checking correctness for function %lu and previous\n", func_i);
        if (check(ms->arg_width * ms->num_arg_out, fct->arithmetic_results,
                  prev->arithmetic_results)) {
          check_result = func_i;
          break;
        };
      }
    }
  }

  unsigned long elapsed_in_sec = current_timestamp() - start_time;

  if (generate_json(ms, elapsed_in_sec, check_result)) {
    return 1;
  }

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r15
callq 0x31fa
movl $0x1, %ecx
testl %eax, %eax
jne 0x38b9
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x32e4
movq %rax, 0x28(%rsp)
cmpq $0x0, 0x28(%r15)
je 0x3891
xorl %ebx, %ebx
movq $0x0, 0x18(%rsp)
movq %r15, 0x30(%rsp)
movq %r15, %rdi
callq 0x2cb5
testl %eax, %eax
jne 0x38b4
movq %r15, %rdi
callq 0x4c9c
testl %eax, %eax
jne 0x38b4
movq %rbx, 0x10(%rsp)
cmpq $0x0, 0x80(%r15)
je 0x381d
xorl %r12d, %r12d
movq 0x60(%r15), %rax
movq (%rax,%r12,8), %rcx
movq 0x70(%r15), %rax
leaq (%rcx,%rcx,4), %rcx
movq 0x18(%rax,%rcx,8), %r13
movq (%r15), %rsi
movq 0x10(%r15), %r11
movq 0x48(%r15), %rdx
leaq (%rsi,%rsi), %r9
leaq (%rsi,%rsi,2), %r10
decq %r11
cmpq $0x3, %r11
movq %r12, 0x40(%rsp)
movq %r13, 0x50(%rsp)
ja 0x372b
leaq (%rdx,%rsi,8), %rdi
movq %rsi, %r8
shlq $0x4, %r8
addq %rdx, %r8
leaq (%rdx,%r10,8), %rbp
leaq 0x27be(%rip), %r14      # 0x5e68
movslq (%r14,%r11,4), %r11
addq %r14, %r11
jmpq *%r11
shlq $0x5, %rsi
addq %rdx, %rsi
movq %rdx, %r9
movq %rdi, %r10
movq %r8, %r11
movq %rsi, 0x8(%rsp)
jmp 0x375e
leaq (,%r9,8), %r10
addq %r13, %r10
leaq (%r13,%rsi,8), %r9
movq %rdx, %r11
movq %rdi, %rbp
movq %r8, 0x8(%rsp)
jmp 0x375e
leaq (,%r10,8), %r11
addq %r13, %r11
leaq (%r13,%r9,8), %r10
leaq (,%rsi,8), %r9
addq %r13, %r9
movq %rdx, %rbp
movq %rdi, 0x8(%rsp)
jmp 0x375e
movq %rbp, 0x8(%rsp)
leaq (,%rsi,8), %r9
addq %r13, %r9
movq %rdx, %r10
movq %rdi, %r11
movq %r8, %rbp
jmp 0x375e
leaq (,%rsi,4), %rdi
leaq (,%rdi,8), %rbp
addq %r13, %rbp
leaq (%r13,%r10,8), %r11
leaq (,%r9,8), %r10
addq %r13, %r10
leaq (,%rsi,8), %r9
addq %r13, %r9
movq %rdx, 0x8(%rsp)
leaq (%rax,%rcx,8), %rdx
movq 0x8(%rdx), %rdx
testq %rdx, %rdx
je 0x38ca
movq %r11, %r14
movq %r10, %rbx
movq %r9, %r13
movq %rdx, %r12
movq 0x20(%rax,%rcx,8), %rax
movq %rax, 0x38(%rsp)
movq %r15, %rdi
movq 0x30(%r15), %r15
movq $0x0, 0x20(%rsp)
leaq 0x20(%rsp), %rsi
callq 0x3537
testq %r15, %r15
movq 0x8(%rsp), %r9
je 0x37e8
movq %r13, %rdx
movq %rbx, %r13
movq %r14, %rcx
movq %rbp, %r8
movq %r12, %rbx
movq %r14, 0x48(%rsp)
movq 0x50(%rsp), %rdi
movq %rdx, %r14
movq %rdx, %rsi
movq %r13, %rdx
movq %r8, %r12
movq %r9, %rbp
xorl %eax, %eax
callq *%rbx
movq %r12, %r8
movq %rbp, %r9
movq 0x48(%rsp), %rcx
movq %r14, %rdx
decq %r15
jne 0x37bd
movq 0x20(%rsp), %rsi
movq 0x30(%rsp), %r15
movq %r15, %rdi
callq 0x3574
movq 0x18(%rsp), %rcx
movq 0x38(%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
movq 0x40(%rsp), %r12
incq %r12
cmpq 0x80(%r15), %r12
jb 0x3652
testb $0x1, 0x68(%r15)
je 0x3875
cmpq $0x2, 0x80(%r15)
jb 0x3875
movl $0x1, %ebx
movl $0x40, %r14d
movq 0x10(%r15), %rdi
movq 0x70(%r15), %rax
imulq (%r15), %rdi
movq -0x28(%rax,%r14), %rdx
movq (%rax,%r14), %rsi
callq 0x3d20
testl %eax, %eax
movq 0x10(%rsp), %rax
cmovneq %rbx, %rax
movq %rax, 0x10(%rsp)
jne 0x3875
incq %rbx
addq $0x28, %r14
cmpq 0x80(%r15), %rbx
jb 0x3839
movq 0x18(%rsp), %rcx
incq %rcx
movq %rcx, 0x18(%rsp)
cmpq 0x28(%r15), %rcx
movq 0x10(%rsp), %rbx
jb 0x361c
xorl %eax, %eax
callq 0x32e4
subq 0x28(%rsp), %rax
movq %r15, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x4964
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
jmp 0x38b9
movl $0x1, %ecx
movl %ecx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x25a7(%rip), %rdi      # 0x5e78
leaq 0x25ad(%rip), %rsi      # 0x5e85
leaq 0x25b6(%rip), %rcx      # 0x5e95
movl $0x52, %edx
callq 0x2120
nopl (%rax)