// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/image.c
// Function: set_limits_automatically
void set_limits_automatically(Limits* ax)
{
 /*!Last Changed 13.09.2006*/
 /*!Last Changed 25.01.2005*/
 double difference, power;
 int digits, firstdigit, seconddigit, digitsp, digitsm;
 if (ax->max < 0)
   return;
 if (ax->min < 0)
  {
   digitsm = (int) log10(-ax->min);
   digitsp = (int) log10(ax->max);
   if (digitsp >= digitsm)
     digits = digitsp;
   else
     digits = digitsm;
   power = fpow(10, digits);
   if (((int) (ax->max / power)) * power != ax->max)
     ax->max = ((int) (ax->max / power + 1)) * power;
   if (((int) (-ax->min / power)) * power != -ax->min)
     ax->min = -(((int) (-ax->min / power + 1)) * power);
   ax->division = (int) (ax->max / power) + (int) (-ax->min / power);
   if (digits >= 0)
     ax->precision = 0;
   else
     ax->precision = abs(digits);
   return;
  }
 difference = ax->max - ax->min;
 firstdigit = (int) log10(ax->min);
 seconddigit = (int) log10(ax->max);
 digits = (int) log10(difference);
 if (firstdigit == seconddigit)
  {
   power = fpow(10, firstdigit);
   ax->min = ((int) (ax->min / power)) * power;
   if (ax->max != (int) (ax->max))
     ax->max = ((int) (ax->max / power + 1)) * power;
   else
     ax->max = ((int) (ax->max / power)) * power;
   ax->division = (int) ((ax->max - ax->min) / power);
  }
 else
  {
   ax->min = 0;
   power = fpow(10, seconddigit);
   if (((int) (ax->max / power)) * power != ax->max)
     ax->max = ((int) (ax->max / power + 1)) * power;
   ax->division = (int) (ax->max / power);
  }
 if (digits >= 0)
   ax->precision = 0;
 else
   ax->precision = abs(digits);
}

// Assembly:
movsd 0x8(%rdi), %xmm2
xorpd %xmm1, %xmm1
ucomisd %xmm2, %xmm1
ja 0x2e341
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movsd (%rdi), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x2e21a
xorpd 0x78080(%rip), %xmm0    # 0xa61d0
callq 0x39bcc
cvttsd2si %xmm0, %ebp
movsd 0x8(%rbx), %xmm0
callq 0x39bcc
cvttsd2si %xmm0, %eax
cmpl %ebp, %eax
cmovgl %eax, %ebp
movsd 0x79c44(%rip), %xmm0    # 0xa7db8
movl %ebp, %edi
callq 0x39b12
movsd 0x8(%rbx), %xmm1
movapd %xmm1, %xmm2
divsd %xmm0, %xmm2
cvttpd2dq %xmm2, %xmm3
cvtdq2pd %xmm3, %xmm3
mulsd %xmm0, %xmm3
ucomisd %xmm1, %xmm3
jne 0x2e19c
jnp 0x2e1b5
addsd 0x7737c(%rip), %xmm2    # 0xa5520
cvttpd2dq %xmm2, %xmm1
cvtdq2pd %xmm1, %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rbx)
movsd (%rbx), %xmm3
xorpd 0x7800f(%rip), %xmm3    # 0xa61d0
movapd %xmm3, %xmm2
divsd %xmm0, %xmm2
cvttpd2dq %xmm2, %xmm4
cvtdq2pd %xmm4, %xmm4
mulsd %xmm0, %xmm4
ucomisd %xmm3, %xmm4
jne 0x2e1e1
jnp 0x2e31a
addsd 0x77337(%rip), %xmm2    # 0xa5520
cvttpd2dq %xmm2, %xmm2
cvtdq2pd %xmm2, %xmm2
movapd 0x77fd7(%rip), %xmm3    # 0xa61d0
movapd %xmm0, %xmm4
xorpd %xmm3, %xmm4
mulsd %xmm2, %xmm4
movsd %xmm4, (%rbx)
xorpd %xmm3, %xmm4
divsd %xmm0, %xmm4
cvttsd2si %xmm4, %ecx
jmp 0x2e31e
subsd %xmm0, %xmm2
movsd %xmm2, (%rsp)
callq 0x39bcc
cvttsd2si %xmm0, %r14d
movsd 0x8(%rbx), %xmm0
callq 0x39bcc
cvttsd2si %xmm0, %r15d
movsd (%rsp), %xmm0
callq 0x39bcc
cvttsd2si %xmm0, %ebp
cmpl %r15d, %r14d
jne 0x2e2bf
movsd 0x79b61(%rip), %xmm0    # 0xa7db8
movl %r14d, %edi
callq 0x39b12
movsd (%rbx), %xmm1
movsd 0x8(%rbx), %xmm2
cvttpd2dq %xmm2, %xmm3
cvtdq2pd %xmm3, %xmm3
divsd %xmm0, %xmm1
cmpneqsd %xmm2, %xmm3
divsd %xmm0, %xmm2
movsd 0x7729b(%rip), %xmm4    # 0xa5520
addsd %xmm2, %xmm4
andpd %xmm3, %xmm4
andnpd %xmm2, %xmm3
orpd %xmm4, %xmm3
unpcklpd %xmm3, %xmm1            # xmm1 = xmm1[0],xmm3[0]
cvttpd2dq %xmm1, %xmm1
cvtdq2pd %xmm1, %xmm1
movapd %xmm0, %xmm2
unpcklpd %xmm0, %xmm2            # xmm2 = xmm2[0],xmm0[0]
mulpd %xmm1, %xmm2
movupd %xmm2, (%rbx)
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
subsd %xmm2, %xmm1
jmp 0x2e310
movq $0x0, (%rbx)
movsd 0x79aea(%rip), %xmm0    # 0xa7db8
movl %r15d, %edi
callq 0x39b12
movsd 0x8(%rbx), %xmm2
movapd %xmm2, %xmm1
divsd %xmm0, %xmm1
cvttpd2dq %xmm1, %xmm3
cvtdq2pd %xmm3, %xmm3
mulsd %xmm0, %xmm3
ucomisd %xmm2, %xmm3
jne 0x2e2f7
jnp 0x2e314
addsd 0x77221(%rip), %xmm1    # 0xa5520
cvttpd2dq %xmm1, %xmm1
cvtdq2pd %xmm1, %xmm1
mulsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rbx)
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
jmp 0x2e328
cvttsd2si %xmm2, %ecx
divsd %xmm0, %xmm1
cvttsd2si %xmm1, %eax
addl %ecx, %eax
movl %eax, 0x10(%rbx)
movl %ebp, %eax
negl %eax
sarl $0x1f, %ebp
andl %eax, %ebp
movl %ebp, 0x14(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq