// File: /workspace/github_c_makefile_star2_O0/guszejnovdavid[P]MISFIT/FindParameter_Newton.c
// Function: FindMach(double)
double FindMach(double m)

{
    double Delta = 1E-6;       /* Tolerance  */
    double Epsilon = 1E-6;     /* Tolerance  */
    double Small = 1E-6;       /* Tolerance  */

    int Max = 99;  /* Maximum number of iterations  */
    int Cond = 0;  /* Condition fo loop termination */
    int K;         /* Counter for loop              */

    double P0=1.0;    /* INPUT : Must be close to the root */
    double P1;    /* New iterate    */
    double Y0;    /* Function value */
    double Y1;    /* Function value */
    double Df;    /* Derivative     */
    double Dp;
    double RelErr;


    Y0 = ffunction_Mach(P0,m);

    for ( K = 1; K <= Max ; K++) {

        if(Cond) break;

        Df = dffunction_Mach(P0);      /* Compute the derivative  */

         if( Df == 0) {       /* Check division by zero */
             Cond = 1;
             Dp   = 0;
         }

         else Dp = Y0/Df;

        P1 = P0 - Dp;       /* New iterate */
        Y1 = ffunction_Mach(P1,m);   /* New function value */

        RelErr = 2 * fabs(Dp) / ( fabs(P1) + Small );  /* Relative error */

        if( (RelErr < Delta)  && (fabs(Y1) < Epsilon) ) { /* Check for   */

            if( Cond != 1) Cond = 2;                      /* convergence */

        }

        P0 = P1;
        Y0 = Y1;
    }

if(Cond == 0) printf("The maximum number of iterations was exceeded !\n");

if(Cond == 1) printf("Division by zero was encountered !\n");

return P0;

//if(Cond == 2) printf("The root was found with the desired tolerance !\n");

}

// Assembly:
subq $0x68, %rsp
movsd %xmm0, 0x60(%rsp)
movsd 0x3f26(%rip), %xmm0     # 0x1c4e8
movsd %xmm0, 0x58(%rsp)
movsd 0x3f18(%rip), %xmm0     # 0x1c4e8
movsd %xmm0, 0x50(%rsp)
movsd 0x3f0a(%rip), %xmm0     # 0x1c4e8
movsd %xmm0, 0x48(%rsp)
movl $0x63, 0x44(%rsp)
movl $0x0, 0x40(%rsp)
movsd 0x3b5c(%rip), %xmm0     # 0x1c158
movsd %xmm0, 0x30(%rsp)
movsd 0x30(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
callq 0x184b0
movsd %xmm0, 0x20(%rsp)
movl $0x1, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
cmpl 0x44(%rsp), %eax
jg 0x1874f
cmpl $0x0, 0x40(%rsp)
je 0x1863b
jmp 0x1874f
movsd 0x30(%rsp), %xmm0
callq 0x18520
movsd %xmm0, 0x10(%rsp)
movsd 0x10(%rsp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x18670
jp 0x18670
movl $0x1, 0x40(%rsp)
xorps %xmm0, %xmm0
movsd %xmm0, 0x8(%rsp)
jmp 0x18682
movsd 0x20(%rsp), %xmm0
divsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd 0x30(%rsp), %xmm0
subsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x28(%rsp)
movsd 0x28(%rsp), %xmm0
movsd 0x60(%rsp), %xmm1
callq 0x184b0
movsd %xmm0, 0x18(%rsp)
movsd 0x8(%rsp), %xmm1
movaps 0x3ec8(%rip), %xmm0     # 0x1c580
pand %xmm0, %xmm1
movsd 0x3e14(%rip), %xmm0     # 0x1c4d8
mulsd %xmm1, %xmm0
movsd 0x28(%rsp), %xmm1
movaps 0x3eab(%rip), %xmm2     # 0x1c580
pand %xmm2, %xmm1
addsd 0x48(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
movsd (%rsp), %xmm1
movsd 0x58(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x18727
movsd 0x18(%rsp), %xmm1
movaps 0x3e7a(%rip), %xmm0     # 0x1c580
pand %xmm0, %xmm1
movsd 0x50(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x18727
cmpl $0x1, 0x40(%rsp)
je 0x18725
movl $0x2, 0x40(%rsp)
jmp 0x18727
movsd 0x28(%rsp), %xmm0
movsd %xmm0, 0x30(%rsp)
movsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x20(%rsp)
movl 0x3c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x3c(%rsp)
jmp 0x18621
cmpl $0x0, 0x40(%rsp)
jne 0x18764
leaq 0x4193(%rip), %rdi      # 0x1c8f0
movb $0x0, %al
callq 0x8050
cmpl $0x1, 0x40(%rsp)
jne 0x18779
leaq 0x41af(%rip), %rdi      # 0x1c921
movb $0x0, %al
callq 0x8050
movsd 0x30(%rsp), %xmm0
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)