// File: /workspace/github_c_makefile_star2_O3/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 0x317e
movl $0x1, %ecx
testl %eax, %eax
jne 0x382f
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x3254
movq %rax, 0x30(%rsp)
cmpq $0x0, 0x28(%r15)
je 0x3807
xorl %ebx, %ebx
movq $0x0, 0x10(%rsp)
movq %r15, 0x20(%rsp)
movq %r15, %rdi
callq 0x2c55
testl %eax, %eax
jne 0x382a
movq %r15, %rdi
callq 0x4b70
testl %eax, %eax
jne 0x382a
cmpq $0x0, 0x80(%r15)
je 0x37f0
movq %rbx, 0x18(%rsp)
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 0x36ab
leaq (%rdx,%rsi,8), %rdi
movq %rsi, %r8
shlq $0x4, %r8
addq %rdx, %r8
leaq (%rdx,%r10,8), %r15
leaq 0x2836(%rip), %r14      # 0x5e60
movslq (%r14,%r11,4), %r11
addq %r14, %r11
jmpq *%r11
shlq $0x5, %rsi
addq %rdx, %rsi
movq %rdx, %r10
movq %rdi, %r9
movq %r8, %r11
movq %rsi, 0x8(%rsp)
jmp 0x36de
leaq (,%r9,8), %r9
addq %r13, %r9
leaq (%r13,%rsi,8), %r10
movq %rdx, %r11
movq %rdi, %r15
movq %r8, 0x8(%rsp)
jmp 0x36de
leaq (,%r10,8), %r11
addq %r13, %r11
leaq (%r13,%r9,8), %r9
leaq (,%rsi,8), %r10
addq %r13, %r10
movq %rdx, %r15
movq %rdi, 0x8(%rsp)
jmp 0x36de
movq %r15, 0x8(%rsp)
leaq (,%rsi,8), %r10
addq %r13, %r10
movq %rdx, %r9
movq %rdi, %r11
movq %r8, %r15
jmp 0x36de
leaq (,%rsi,4), %rdi
leaq (,%rdi,8), %r15
addq %r13, %r15
leaq (%r13,%r10,8), %r11
leaq (,%r9,8), %r9
addq %r13, %r9
leaq (,%rsi,8), %r10
addq %r13, %r10
movq %rdx, 0x8(%rsp)
leaq (%rax,%rcx,8), %rdx
movq 0x8(%rdx), %rdx
testq %rdx, %rdx
je 0x3840
movq %r11, %r12
movq %r10, %rbx
movq %r9, %r13
movq %rdx, %rbp
movq 0x20(%rax,%rcx,8), %rax
movq %rax, 0x38(%rsp)
movq 0x20(%rsp), %rdi
movq 0x30(%rdi), %r14
movq $0x0, 0x28(%rsp)
leaq 0x28(%rsp), %rsi
callq 0x34b7
testq %r14, %r14
movq 0x8(%rsp), %r9
je 0x3767
movq %r13, %rdx
movq %rbx, %r13
movq %r12, %rcx
movq %r15, %r8
movq %rbp, %rbx
movq %r12, 0x48(%rsp)
movq 0x50(%rsp), %rdi
movq %r13, %rsi
movq %rdx, %r12
movq %r8, %rbp
movq %r9, %r15
xorl %eax, %eax
callq *%rbx
movq %rbp, %r8
movq %r15, %r9
movq 0x48(%rsp), %rcx
movq %r12, %rdx
decq %r14
jne 0x373f
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %r15
movq %r15, %rdi
callq 0x34f4
movq 0x10(%rsp), %rcx
movq 0x38(%rsp), %rdx
movq %rax, (%rdx,%rcx,8)
movq 0x40(%rsp), %r12
incq %r12
movq 0x80(%r15), %rax
cmpq %rax, %r12
jb 0x35d2
cmpq $0x2, %rax
setb %al
testb $0x1, 0x68(%r15)
sete %cl
orb %al, %cl
jne 0x37eb
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 0x3d14
testl %eax, %eax
jne 0x37f0
incq %rbx
addq $0x28, %r14
cmpq 0x80(%r15), %rbx
jb 0x37bd
movq 0x18(%rsp), %rbx
movq 0x10(%rsp), %rcx
incq %rcx
movq %rcx, 0x10(%rsp)
cmpq 0x28(%r15), %rcx
jb 0x359c
xorl %eax, %eax
callq 0x3254
subq 0x30(%rsp), %rax
movq %r15, %rdi
movq %rax, %rsi
movq %rbx, %rdx
callq 0x48e4
xorl %ecx, %ecx
testl %eax, %eax
setne %cl
jmp 0x382f
movl $0x1, %ecx
movl %ecx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2629(%rip), %rdi      # 0x5e70
leaq 0x262f(%rip), %rsi      # 0x5e7d
leaq 0x2638(%rip), %rcx      # 0x5e8d
movl $0x52, %edx
callq 0x2120
nop