#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);
int /*<<< orphan*/ printf(char *);
double stub1(double);
double stub2(double);
double stub3(double);
double rtsec(double (*func)(double), double x1, double x2, double xacc) {
  int j;
  double fl, f, dx, swap, xl, rts;
  fl = (*func)(x1);
  f = (*func)(x2);
  if (fabs(fl) < fabs(f)) {
    rts = x1;
    xl = x2;
    swap = fl;
    fl = f;
    f = swap;
  } else {
    xl = x1;
    rts = x2;
  }
  for (j = 0; j < 30; j++) {
    dx = (xl - rts) * f / (f - fl);
    xl = rts;
    fl = f;
    rts += dx;
    f = (*func)(rts);
    if (fabs(dx) < xacc || f == 0.0)
      return rts;
  }
  printf("\n\nError in function rtsec():");
  printf("\nToo many iterations!!!\n");
  exit(1);
}


x86 assembly (clang, -O0):
<rtsec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x10(%rbp),%xmm0
call   *%rax
movsd  %xmm0,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x18(%rbp),%xmm0
call   *%rax
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm1
movaps 0xe99(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
movaps 0xe89(%rip),%xmm2
pand   %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    11bc <rtsec+0x9c>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11d0 <rtsec+0xb0>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x1e,-0x24(%rbp)
jge    128b <rtsec+0x16b>
movsd  -0x50(%rbp),%xmm0
subsd  -0x58(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
subsd  -0x30(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x8(%rbp),%rax
movsd  -0x58(%rbp),%xmm0
call   *%rax
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm1
movaps 0xdbe(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
ja     126d <rtsec+0x14d>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1278 <rtsec+0x158>
jp     1278 <rtsec+0x158>
movsd  -0x58(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret
jmp    127d <rtsec+0x15d>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11d7 <rtsec+0xb7>
lea    0xd7e(%rip),%rdi
call   1030 <printf@plt>
lea    0xd8f(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<rtsec>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
movsd  %xmm2,0x38(%rsp)
movsd  %xmm1,0x8(%rsp)
mov    %rdi,%rbx
movsd  %xmm0,0x10(%rsp)
call   *%rdi
movaps %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   *%rbx
movapd 0x20(%rsp),%xmm3
movapd 0xe98(%rip),%xmm1
movapd %xmm3,%xmm2
andpd  %xmm1,%xmm2
andpd  %xmm0,%xmm1
ucomisd %xmm2,%xmm1
cmpltsd %xmm1,%xmm2
movapd %xmm2,%xmm1
andpd  %xmm3,%xmm1
andnpd %xmm0,%xmm2
orpd   %xmm1,%xmm2
ja     11a2 <rtsec+0x72>
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
mov    $0x1e,%ebp
jmp    11c0 <rtsec+0x90>
movapd %xmm0,%xmm3
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
mov    $0x1e,%ebp
nopw   0x0(%rax,%rax,1)
movapd %xmm1,%xmm4
movsd  %xmm0,0x40(%rsp)
subsd  %xmm0,%xmm4
mulsd  %xmm2,%xmm4
movapd %xmm2,0x20(%rsp)
movapd %xmm2,%xmm1
subsd  %xmm3,%xmm1
divsd  %xmm1,%xmm4
movapd %xmm4,0x10(%rsp)
addsd  %xmm4,%xmm0
movsd  %xmm0,0x8(%rsp)
call   *%rbx
movapd 0x10(%rsp),%xmm2
andpd  0xdfc(%rip),%xmm2
movsd  0x38(%rsp),%xmm1
ucomisd %xmm2,%xmm1
ja     1259 <rtsec+0x129>
ucomisd 0xdf8(%rip),%xmm0
jne    121c <rtsec+0xec>
jnp    1259 <rtsec+0x129>
movapd 0x20(%rsp),%xmm3
movapd %xmm0,%xmm2
add    $0xffffffff,%ebp
movsd  0x8(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
jne    11c0 <rtsec+0x90>
lea    0xdda(%rip),%rdi
call   1040 <printf@plt>
lea    0xdeb(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
movsd  0x8(%rsp),%xmm0
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"\0A\0AError in function rtsec():\00"
@.str.1 = [25 x i8] c"\0AToo many iterations!!!\0A\00"
define double @rtsec(double (double)* %0, double %1, double %2, double %3) {
%5 = alloca double (double)*
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
store double (double)* %0, double (double)** %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%16 = load double (double)*, double (double)** %5
%17 = load double, double* %6
%18 = call double %16(double %17)
store double %18, double* %10
%19 = load double (double)*, double (double)** %5
%20 = load double, double* %7
%21 = call double %19(double %20)
store double %21, double* %11
%22 = load double, double* %10
%23 = call double @llvm.fabs.f64(double %22)
%24 = load double, double* %11
%25 = call double @llvm.fabs.f64(double %24)
%26 = fcmp olt double %23, %25
br i1 %26, label %27, label %33
27: ; preds = %4
%28 = load double, double* %6
store double %28, double* %15
%29 = load double, double* %7
store double %29, double* %14
%30 = load double, double* %10
store double %30, double* %13
%31 = load double, double* %11
store double %31, double* %10
%32 = load double, double* %13
store double %32, double* %11
br label %36
33: ; preds = %4
%34 = load double, double* %6
store double %34, double* %14
%35 = load double, double* %7
store double %35, double* %15
br label %36
36: ; preds = %33, %27
store i32 0, i32* %9
br label %37
37: ; preds = %68, %36
%38 = load i32, i32* %9
%39 = icmp slt i32 %38, 30
br i1 %39, label %40, label %71
40: ; preds = %37
%41 = load double, double* %14
%42 = load double, double* %15
%43 = fsub double %41, %42
%44 = load double, double* %11
%45 = fmul double %43, %44
%46 = load double, double* %11
%47 = load double, double* %10
%48 = fsub double %46, %47
%49 = fdiv double %45, %48
store double %49, double* %12
%50 = load double, double* %15
store double %50, double* %14
%51 = load double, double* %11
store double %51, double* %10
%52 = load double, double* %12
%53 = load double, double* %15
%54 = fadd double %53, %52
store double %54, double* %15
%55 = load double (double)*, double (double)** %5
%56 = load double, double* %15
%57 = call double %55(double %56)
store double %57, double* %11
%58 = load double, double* %12
%59 = call double @llvm.fabs.f64(double %58)
%60 = load double, double* %8
%61 = fcmp olt double %59, %60
br i1 %61, label %65, label %62
62: ; preds = %40
%63 = load double, double* %11
%64 = fcmp oeq double %63, 0.000000e+00
br i1 %64, label %65, label %67
65: ; preds = %62, %40
%66 = load double, double* %15
ret double %66
67: ; preds = %62
br label %68
68: ; preds = %67
%69 = load i32, i32* %9
%70 = add nsw i32 %69, 1
store i32 %70, i32* %9
br label %37
71: ; preds = %37
%72 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%73 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%74 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@.str = [29 x i8] c"\0A\0AError in function rtsec():\00"
@str = [24 x i8] c"\0AToo many iterations!!!\00"
define double @rtsec(double (double)* nocapture %0, double %1, double %2, double %3) {
%5 = tail call double %0(double %1)
%6 = tail call double %0(double %2)
%7 = tail call double @llvm.fabs.f64(double %5)
%8 = tail call double @llvm.fabs.f64(double %6)
%9 = fcmp olt double %7, %8
%10 = select i1 %9, double %5, double %6
%11 = select i1 %9, double %6, double %5
%12 = select i1 %9, double %2, double %1
%13 = select i1 %9, double %1, double %2
br label %17
14: ; preds = %17
%15 = add nuw nsw i32 %20, 1
%16 = icmp eq i32 %15, 30
br i1 %16, label %34, label %17
17: ; preds = %4, %14
%18 = phi double [ %13, %4 ], [ %27, %14 ]
%19 = phi double [ %12, %4 ], [ %18, %14 ]
%20 = phi i32 [ 0, %4 ], [ %15, %14 ]
%21 = phi double [ %11, %4 ], [ %22, %14 ]
%22 = phi double [ %10, %4 ], [ %28, %14 ]
%23 = fsub double %19, %18
%24 = fmul double %22, %23
%25 = fsub double %22, %21
%26 = fdiv double %24, %25
%27 = fadd double %18, %26
%28 = tail call double %0(double %27)
%29 = tail call double @llvm.fabs.f64(double %26)
%30 = fcmp olt double %29, %3
%31 = fcmp oeq double %28, 0.000000e+00
%32 = select i1 %30, i1 true, i1 %31
br i1 %32, label %33, label %14
33: ; preds = %17
ret double %27
34: ; preds = %14
%35 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%37 = tail call i32 @exit(i32 1)
unreachable
}