// File: /workspace/github_c_makefile_star2_O2/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 $0x48, %rsp
movq %rdi, %r15
callq 0x303e
pushq $0x1
popq %rcx
testl %eax, %eax
jne 0x35fb
xorl %eax, %eax
callq 0x30fc
movq %rax, 0x28(%rsp)
xorl %r12d, %r12d
movq $0x0, (%rsp)
movq %r15, 0x8(%rsp)
cmpq 0x28(%r15), %r12
jae 0x35d9
movq %r15, %rdi
callq 0x2b84
testl %eax, %eax
jne 0x35d4
movq %r15, %rdi
callq 0x4860
testl %eax, %eax
jne 0x35d4
xorl %r11d, %r11d
movq %r12, 0x30(%rsp)
movq 0x80(%r15), %rax
cmpq %rax, %r11
jae 0x3587
movq 0x60(%r15), %rax
imulq $0x28, (%rax,%r11,8), %rax
movq 0x70(%r15), %rcx
movq 0x18(%rcx,%rax), %r8
movq (%r15), %rsi
movq 0x10(%r15), %r9
movq 0x48(%r15), %rdx
leaq (%rsi,%rsi), %rdi
leaq (%rsi,%rsi,2), %r10
decq %r9
leaq (%r8,%r10,8), %rbp
leaq (%r8,%rdi,8), %r15
movq %r8, 0x18(%rsp)
leaq (%r8,%rsi,8), %rdi
movq %rdi, 0x10(%rsp)
cmpq $0x3, %r9
movq %r11, 0x40(%rsp)
ja 0x34f3
leaq (%rdx,%rsi,8), %rdi
movq %rsi, %r8
shlq $0x4, %r8
addq %rdx, %r8
leaq (%rdx,%r10,8), %rbx
leaq 0x29af(%rip), %r10      # 0x5e60
movslq (%r10,%r9,4), %r9
addq %r10, %r9
jmpq *%r9
shlq $0x5, %rsi
addq %rdx, %rsi
movq %rdx, 0x10(%rsp)
movq %rdi, %r15
movq %r8, %rbp
movq %rbx, %r12
movq %rsi, %rbx
jmp 0x3503
movq %rdx, %rbp
movq %rdi, %r12
movq %r8, %rbx
jmp 0x3503
movq %rdx, %r12
movq %rdi, %rbx
jmp 0x3503
movq %rdx, %r15
movq %rdi, %rbp
movq %r8, %r12
jmp 0x3503
shlq $0x2, %rsi
movq 0x18(%rsp), %rdi
leaq (%rdi,%rsi,8), %r12
movq %rdx, %rbx
leaq (%rcx,%rax), %rdx
movq 0x8(%rdx), %r13
testq %r13, %r13
je 0x360c
movq 0x20(%rcx,%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x8(%rsp), %rdi
movq 0x30(%rdi), %r14
andq $0x0, 0x20(%rsp)
leaq 0x20(%rsp), %rsi
callq 0x3338
subq $0x1, %r14
jb 0x355a
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %r15, %rdx
movq %rbp, %rcx
movq %r12, %r8
movq %rbx, %r9
xorl %eax, %eax
callq *%r13
jmp 0x3537
movq 0x20(%rsp), %rsi
movq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x3375
movq 0x30(%rsp), %r12
movq 0x38(%rsp), %rcx
movq %rax, (%rcx,%r12,8)
movq 0x40(%rsp), %r11
incq %r11
jmp 0x343f
testb $0x1, 0x68(%r15)
je 0x35cc
pushq $0x40
popq %rbx
pushq $0x1
popq %r14
cmpq %rax, %r14
jae 0x35cc
movq 0x10(%r15), %rdi
movq 0x70(%r15), %rax
imulq (%r15), %rdi
movq -0x28(%rax,%rbx), %rdx
movq (%rax,%rbx), %rsi
callq 0x3a2c
testl %eax, %eax
jne 0x35c8
incq %r14
movq 0x80(%r15), %rax
addq $0x28, %rbx
jmp 0x3595
movq %r14, (%rsp)
incq %r12
jmp 0x340d
pushq $0x1
popq %rcx
jmp 0x35fb
xorl %eax, %eax
callq 0x30fc
subq 0x28(%rsp), %rax
movq %r15, %rdi
movq %rax, %rsi
movq (%rsp), %rdx
callq 0x4610
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
movl %ecx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x285d(%rip), %rdi      # 0x5e70
leaq 0x2863(%rip), %rsi      # 0x5e7d
leaq 0x286c(%rip), %rcx      # 0x5e8d
pushq $0x52
popq %rdx
callq 0x2120
nopl (%rax)