// File: /workspace/github_c_makefile_star2_O0/LPD-EPFL[P]mctop/src/helper.c
// Function: dvfs_scale_up
int
dvfs_scale_up(const size_t n_reps, const double ratio, double* dur)
{
  const double is_dvfs_ratio = 0.9;
  const uint max_tries = 16;
  uint tries = max_tries;

  clock_t s = clock();
  ticks times[2];
  times[0] = spin_time(n_reps);
  times[1] = spin_time(n_reps);
  ticks prev = times[1], last = prev;
  if (times[1] < (ratio * times[0]))
    {
      ticks cmp = prev;
      do
	{
	  cmp = prev;
	  last = spin_time(n_reps);
	  prev = last;
	}
      while (tries-- > 0 && last < (ratio * cmp));
    }
  clock_t e = clock();

  if (dur != NULL)
    {
      *dur = 1000.0 * (e - s) / (double) CLOCKS_PER_SEC;
    }
  return (last < (is_dvfs_ratio * times[0]));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movsd %xmm0, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movabsq $0x3feccccccccccccd, %rax # imm = 0x3FECCCCCCCCCCCCD
movq %rax, -0x20(%rbp)
movl $0x10, -0x24(%rbp)
movl $0x10, -0x28(%rbp)
callq 0x20a0
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x70f0
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
callq 0x70f0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
movaps 0x7e85(%rip), %xmm4     # 0xf050
movq -0x38(%rbp), %xmm1
punpckldq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
movapd 0x7e84(%rip), %xmm3     # 0xf060
subpd %xmm3, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movsd -0x10(%rbp), %xmm0
movq -0x40(%rbp), %xmm2
punpckldq %xmm4, %xmm2    # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
subpd %xmm3, %xmm2
movaps %xmm2, %xmm3
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x72af
movq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rdi
callq 0x70f0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
movl -0x28(%rbp), %ecx
movl %ecx, %eax
addl $-0x1, %eax
movl %eax, -0x28(%rbp)
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x61(%rbp)
jbe 0x72a2
movq -0x50(%rbp), %xmm1
movaps 0x7df4(%rip), %xmm4     # 0xf050
punpckldq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
movapd 0x7df8(%rip), %xmm3     # 0xf060
subpd %xmm3, %xmm1
movaps %xmm1, %xmm0
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm0, %xmm1
movsd -0x10(%rbp), %xmm0
movq -0x58(%rbp), %xmm2
punpckldq %xmm4, %xmm2    # xmm2 = xmm2[0],xmm4[0],xmm2[1],xmm4[1]
subpd %xmm3, %xmm2
movaps %xmm2, %xmm3
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm3, %xmm2
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
seta %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0x721e
jmp 0x72af
callq 0x20a0
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x72ec
movq -0x60(%rbp), %rax
subq -0x30(%rbp), %rax
cvtsi2sd %rax, %xmm1
movsd 0x975c(%rip), %xmm0     # 0x10a30
mulsd %xmm1, %xmm0
movsd 0x7d38(%rip), %xmm1     # 0xf018
divsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x50(%rbp), %xmm1
movaps 0x7d58(%rip), %xmm3     # 0xf050
punpckldq %xmm3, %xmm1    # xmm1 = xmm1[0],xmm3[0],xmm1[1],xmm3[1]
movapd 0x7d5c(%rip), %xmm0     # 0xf060
subpd %xmm0, %xmm1
movaps %xmm1, %xmm2
unpckhpd %xmm1, %xmm1            # xmm1 = xmm1[1,1]
addsd %xmm2, %xmm1
movq -0x40(%rbp), %xmm2
punpckldq %xmm3, %xmm2    # xmm2 = xmm2[0],xmm3[0],xmm2[1],xmm3[1]
subpd %xmm0, %xmm2
movaps %xmm2, %xmm0
unpckhpd %xmm2, %xmm2            # xmm2 = xmm2[1,1]
addsd %xmm0, %xmm2
movsd 0x7cf5(%rip), %xmm0     # 0xf028
mulsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
seta %al
andb $0x1, %al
movzbl %al, %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)