// File: /workspace/github_c_makefile_star2_O0/ugobas[P]tnm/optimization.c
// Function: Find_max_quad
float Find_max_quad(float x1, float x2, float x3,
		    float y1, float y2, float y3,
		    float MIN, float MAX)
{

 float yprime_2=((y1-y2)/(x1-x2));
  float yprime_3=((y1-y3)/(x1-x3));
  if(yprime_2 == yprime_3){
    // Singular data, return maximum value
    printf("WARNING in Find_max_quad, equal derivatives\n");
    float xmax=x2, ymax=y2;
    if(y1>ymax){ymax=y1; xmax=x1;}
    if(y3>ymax){xmax=x3;}
    return(xmax);
  }
  float a=(yprime_2-yprime_3)/(x2-x3);
  if(a>0){
    // Second derivative is positive, no maximum!
    //printf("WARNING, second derivative >0\n");
    printf("WARNING in Find_max_quad, second derivative %.2g >0\n", a);
    float xmax=x2, ymax=y2;
    if(y1>ymax){ymax=y1; xmax=x1;}
    if(y3>ymax){xmax=x3;}
    return(xmax);
  }
  float x0=0.5*(x1+x2)-yprime_2/(2*a);
  //printf("a= %.2f x0= %.2f\n", a, x0);
  if(x0<MIN){x0=(x1+MIN)/2;}
  //else if(x0>MAX){x0=(x3+MAX)/2;}
  return(x0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movss %xmm0, -0x8(%rbp)
movss %xmm1, -0xc(%rbp)
movss %xmm2, -0x10(%rbp)
movss %xmm3, -0x14(%rbp)
movss %xmm4, -0x18(%rbp)
movss %xmm5, -0x1c(%rbp)
movss %xmm6, -0x20(%rbp)
movss %xmm7, -0x24(%rbp)
movss -0x14(%rbp), %xmm0
subss -0x18(%rbp), %xmm0
movss -0x8(%rbp), %xmm1
subss -0xc(%rbp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x28(%rbp)
movss -0x14(%rbp), %xmm0
subss -0x1c(%rbp), %xmm0
movss -0x8(%rbp), %xmm1
subss -0x10(%rbp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x2c(%rbp)
movss -0x28(%rbp), %xmm0
ucomiss -0x2c(%rbp), %xmm0
jne 0x5cfdc
jp 0x5cfdc
leaq 0x250ca(%rip), %rdi     # 0x82048
movb $0x0, %al
callq 0x10d0
movss -0xc(%rbp), %xmm0
movss %xmm0, -0x30(%rbp)
movss -0x18(%rbp), %xmm0
movss %xmm0, -0x34(%rbp)
movss -0x14(%rbp), %xmm0
ucomiss -0x34(%rbp), %xmm0
jbe 0x5cfb8
movss -0x14(%rbp), %xmm0
movss %xmm0, -0x34(%rbp)
movss -0x8(%rbp), %xmm0
movss %xmm0, -0x30(%rbp)
movss -0x1c(%rbp), %xmm0
ucomiss -0x34(%rbp), %xmm0
jbe 0x5cfcd
movss -0x10(%rbp), %xmm0
movss %xmm0, -0x30(%rbp)
movss -0x30(%rbp), %xmm0
movss %xmm0, -0x4(%rbp)
jmp 0x5d100
movss -0x28(%rbp), %xmm0
subss -0x2c(%rbp), %xmm0
movss -0xc(%rbp), %xmm1
subss -0x10(%rbp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x38(%rbp)
movss -0x38(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jbe 0x5d074
movss -0x38(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x2505f(%rip), %rdi     # 0x82075
movb $0x1, %al
callq 0x10d0
movss -0xc(%rbp), %xmm0
movss %xmm0, -0x3c(%rbp)
movss -0x18(%rbp), %xmm0
movss %xmm0, -0x40(%rbp)
movss -0x14(%rbp), %xmm0
ucomiss -0x40(%rbp), %xmm0
jbe 0x5d050
movss -0x14(%rbp), %xmm0
movss %xmm0, -0x40(%rbp)
movss -0x8(%rbp), %xmm0
movss %xmm0, -0x3c(%rbp)
movss -0x1c(%rbp), %xmm0
ucomiss -0x40(%rbp), %xmm0
jbe 0x5d065
movss -0x10(%rbp), %xmm0
movss %xmm0, -0x3c(%rbp)
movss -0x3c(%rbp), %xmm0
movss %xmm0, -0x4(%rbp)
jmp 0x5d100
movss -0x8(%rbp), %xmm0
addss -0xc(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movss -0x28(%rbp), %xmm1
movss 0x19005(%rip), %xmm2    # 0x76094
mulss -0x38(%rbp), %xmm2
divss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movsd 0x18f4d(%rip), %xmm2    # 0x76008
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x44(%rbp)
movss -0x44(%rbp), %xmm1
movss -0x20(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x5d0f6
movss -0x8(%rbp), %xmm0
addss -0x20(%rbp), %xmm0
movss 0x18fa7(%rip), %xmm1    # 0x76094
divss %xmm1, %xmm0
movss %xmm0, -0x44(%rbp)
movss -0x44(%rbp), %xmm0
movss %xmm0, -0x4(%rbp)
movss -0x4(%rbp), %xmm0
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)