#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ exit(int);
double fabs(double);
double log(double);
double pow(double, double);
int /*<<< orphan*/ print1(char *);
double sqrt(double);
double STS_FindRoot(double x0, double dtr, double dta) {
  double a, b, c;
  double Ns, Ns1;
  int n;
  n = 0;
  Ns = x0 + 1.0;
  Ns1 = x0;
  while (fabs(Ns - Ns1) >= 1.0e-5) {
    Ns = Ns1;
    a = (1.0 - sqrt(0.01)) / (1.0 + sqrt(0.01));
    b = pow(a, 2.0 * Ns);
    c = (1.0 - b) / (1.0 + b);
    Ns1 = Ns + (dta - dtr * Ns / (2.0 * sqrt(0.01)) * c) /
                   (dtr / (2.0 * sqrt(0.01)) *
                    (c - 2.0 * Ns * b * log(a) * (1.0 + c) / (1.0 + b)));
    n += 1;
    if (n == 128) {
      print1("! STS_FindRoot: max number of iterations exceeded");
      exit(1);
      ;
    }
  }
  return (Ns);
}


x86 assembly (clang, -O0):
<STS_FindRoot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movl   $0x0,-0x44(%rbp)
movsd  0xe87(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
movaps 0xe82(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xe5e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     13b1 <STS_FindRoot+0x261>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe52(%rip),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe2a(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  0xe2e(%rip),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm2
movsd  -0x90(%rbp),%xmm0
ff
movsd  0xdfe(%rip),%xmm1
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xdf4(%rip),%xmm1
mulsd  -0x38(%rbp),%xmm1
call   1050 <pow@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  0xdcd(%rip),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  0xdc0(%rip),%xmm1
addsd  -0x28(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xd9c(%rip),%xmm0
call   1060 <sqrt@plt>
movsd  -0x88(%rbp),%xmm1
ff
movaps %xmm0,%xmm3
movsd  -0x80(%rbp),%xmm0
movsd  0xd77(%rip),%xmm2
mulsd  %xmm3,%xmm2
divsd  %xmm2,%xmm0
movsd  -0x30(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xd3c(%rip),%xmm0
call   1060 <sqrt@plt>
movaps %xmm0,%xmm2
movsd  -0x78(%rbp),%xmm0
movsd  0xd1f(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  0xd00(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1040 <log@plt>
movsd  -0x70(%rbp),%xmm4
movsd  -0x68(%rbp),%xmm3
movsd  -0x60(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
movaps %xmm0,%xmm5
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm5,%xmm4
movsd  0xcaf(%rip),%xmm5
addsd  -0x30(%rbp),%xmm5
mulsd  %xmm5,%xmm4
movsd  0xc9e(%rip),%xmm5
addsd  -0x28(%rbp),%xmm5
divsd  %xmm5,%xmm4
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
cmpl   $0x80,-0x44(%rbp)
jne    13ac <STS_FindRoot+0x25c>
lea    0xc93(%rip),%rdi
call   1030 <print1@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    118d <STS_FindRoot+0x3d>
movsd  -0x38(%rbp),%xmm0
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<STS_FindRoot>:
push   %rbx
sub    $0x30,%rsp
movsd  %xmm2,0x18(%rsp)
movapd %xmm0,%xmm2
movsd  0xeb9(%rip),%xmm0
movsd  %xmm1,0x10(%rsp)
divsd  0xeb3(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
addsd  %xmm2,%xmm0
mov    $0x80,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movapd %xmm0,%xmm1
subsd  %xmm2,%xmm1
andpd  0xeb0(%rip),%xmm1
ucomisd 0xe88(%rip),%xmm1
jb     1244 <STS_FindRoot+0x114>
movapd %xmm2,%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,0x20(%rsp)
movsd  0xe74(%rip),%xmm0
movsd  %xmm2,0x28(%rsp)
call   1040 <pow@plt>
movsd  0xe49(%rip),%xmm4
movapd %xmm4,%xmm1
subsd  %xmm0,%xmm1
movsd  0x20(%rsp),%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm4,%xmm0
divsd  %xmm0,%xmm1
movsd  0x28(%rsp),%xmm5
movapd %xmm5,%xmm2
mulsd  0x10(%rsp),%xmm2
divsd  0xe37(%rip),%xmm2
mulsd  %xmm1,%xmm2
addsd  0x18(%rsp),%xmm2
mulsd  0xe2d(%rip),%xmm3
movapd %xmm3,%xmm6
movapd %xmm1,%xmm3
addsd  %xmm4,%xmm3
mulsd  %xmm6,%xmm3
divsd  %xmm0,%xmm3
addsd  %xmm1,%xmm3
mulsd  0x8(%rsp),%xmm3
divsd  %xmm3,%xmm2
movapd %xmm5,%xmm0
addsd  %xmm5,%xmm2
add    $0xffffffff,%ebx
jne    1170 <STS_FindRoot+0x40>
lea    0xe0b(%rip),%rdi
call   1030 <print1@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [50 x i8] c"! STS_FindRoot: max number of iterations exceeded\00"
define double @STS_FindRoot(double %0, double %1, double %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32
store double %0, double* %4
store double %1, double* %5
store double %2, double* %6
store i32 0, i32* %12
%13 = load double, double* %4
%14 = fadd double %13, 1.000000e+00
store double %14, double* %10
%15 = load double, double* %4
store double %15, double* %11
br label %16
16: ; preds = %78, %3
%17 = load double, double* %10
%18 = load double, double* %11
%19 = fsub double %17, %18
%20 = call double @llvm.fabs.f64(double %19)
%21 = fcmp oge double %20, 1.000000e-05
br i1 %21, label %22, label %79
22: ; preds = %16
%23 = load double, double* %11
store double %23, double* %10
%24 = call double @sqrt(double 1.000000e-02)
%25 = fsub double 1.000000e+00, %24
%26 = call double @sqrt(double 1.000000e-02)
%27 = fadd double 1.000000e+00, %26
%28 = fdiv double %25, %27
store double %28, double* %7
%29 = load double, double* %7
%30 = load double, double* %10
%31 = fmul double 2.000000e+00, %30
%32 = call double @pow(double %29, double %31)
store double %32, double* %8
%33 = load double, double* %8
%34 = fsub double 1.000000e+00, %33
%35 = load double, double* %8
%36 = fadd double 1.000000e+00, %35
%37 = fdiv double %34, %36
store double %37, double* %9
%38 = load double, double* %10
%39 = load double, double* %6
%40 = load double, double* %5
%41 = load double, double* %10
%42 = fmul double %40, %41
%43 = call double @sqrt(double 1.000000e-02)
%44 = fmul double 2.000000e+00, %43
%45 = fdiv double %42, %44
%46 = load double, double* %9
%47 = fneg double %45
%48 = call double @llvm.fmuladd.f64(double %47, double %46, double %39)
%49 = load double, double* %5
%50 = call double @sqrt(double 1.000000e-02)
%51 = fmul double 2.000000e+00, %50
%52 = fdiv double %49, %51
%53 = load double, double* %9
%54 = load double, double* %10
%55 = fmul double 2.000000e+00, %54
%56 = load double, double* %8
%57 = fmul double %55, %56
%58 = load double, double* %7
%59 = call double @log(double %58)
%60 = fmul double %57, %59
%61 = load double, double* %9
%62 = fadd double 1.000000e+00, %61
%63 = fmul double %60, %62
%64 = load double, double* %8
%65 = fadd double 1.000000e+00, %64
%66 = fdiv double %63, %65
%67 = fsub double %53, %66
%68 = fmul double %52, %67
%69 = fdiv double %48, %68
%70 = fadd double %38, %69
store double %70, double* %11
%71 = load i32, i32* %12
%72 = add nsw i32 %71, 1
store i32 %72, i32* %12
%73 = load i32, i32* %12
%74 = icmp eq i32 %73, 128
br i1 %74, label %75, label %78
75: ; preds = %22
%76 = call i32 @print1(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%77 = call i32 @exit(i32 1)
unreachable
78: ; preds = %22
br label %16
79: ; preds = %16
%80 = load double, double* %10
ret double %80
}

LLVM IR (-O2):
@.str = [50 x i8] c"! STS_FindRoot: max number of iterations exceeded\00"
define double @STS_FindRoot(double %0, double %1, double %2) {
%4 = fadd double %0, 1.000000e+00
%5 = fdiv double %1, 2.000000e-01
br label %6
6: ; preds = %13, %3
%7 = phi double [ %4, %3 ], [ %8, %13 ]
%8 = phi double [ %0, %3 ], [ %30, %13 ]
%9 = phi i32 [ 0, %3 ], [ %31, %13 ]
%10 = fsub double %7, %8
%11 = tail call double @llvm.fabs.f64(double %10)
%12 = fcmp ult double %11, 1.000000e-05
br i1 %12, label %36, label %13
13: ; preds = %6
%14 = fmul double %8, 2.000000e+00
%15 = tail call double @pow(double 0x3FEA2E8BA2E8BA2E, double %14)
%16 = fsub double 1.000000e+00, %15
%17 = fadd double %15, 1.000000e+00
%18 = fdiv double %16, %17
%19 = fmul double %8, %1
%20 = fdiv double %19, -2.000000e-01
%21 = tail call double @llvm.fmuladd.f64(double %20, double %18, double %2)
%22 = fmul double %14, %15
%23 = fmul double %22, 0x3FC9AF93CD234415
%24 = fadd double %18, 1.000000e+00
%25 = fmul double %23, %24
%26 = fdiv double %25, %17
%27 = fadd double %18, %26
%28 = fmul double %5, %27
%29 = fdiv double %21, %28
%30 = fadd double %8, %29
%31 = add nuw nsw i32 %9, 1
%32 = icmp eq i32 %31, 128
br i1 %32, label %33, label %6
33: ; preds = %13
%34 = tail call i32 @print1(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%35 = tail call i32 @exit(i32 1)
unreachable
36: ; preds = %6
ret double %7
}