#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 */
double _f(double);
double fabs(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ swapd(double *, double *);
double regula(double xs, double xe, double h, double eps, int iter) {
  int ic;
  double x0, x1, x2, y0, y1, y2;
  if (xs == xe || h <= 0. || eps <= 0. || iter < 1) {
    fprintf(stderr, "Error : Illegal parameter in regula()\n");
    return 0.;
  }
  if (xs > xe)
    swapd(&xs, &xe);
  x0 = xs;
  x1 = xe;
  y1 = _f(x1);
  do {
    y0 = _f(x0);
    if (y0 * y1 > 0.)
      x0 += h;
    else {
      for (ic = 0; ic < iter; ic++) {
        x2 = x0 - y0 * (x1 - x0) / (y1 - y0);
        y2 = _f(x2);
        if (y0 * y2 >= 0.) {
          x0 = x2;
          y0 = y2;
        } else {
          x1 = x2;
          y1 = y2;
        }
        if (fabs(y2) <= eps)
          return x2;
      }
      fprintf(stderr, "Error : No convergence in regula()\n");
      return x2;
    }
  } while (x0 <= xe);
  fprintf(stderr, "Error : No root in range(%e - %e) on regula()\n", xs, xe);
  return 0.;
}


x86 assembly (clang, -O0):
<regula>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
mov    %edi,-0x2c(%rbp)
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    116a <regula+0x3a>
jp     116a <regula+0x3a>
jmp    1190 <regula+0x60>
xorps  %xmm0,%xmm0
ucomisd -0x20(%rbp),%xmm0
jae    1190 <regula+0x60>
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jae    1190 <regula+0x60>
cmpl   $0x1,-0x2c(%rbp)
jge    11b4 <regula+0x84>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    136c <regula+0x23c>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11d1 <regula+0xa1>
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <swapd@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <_f@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1040 <_f@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x58(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    122e <regula+0xfe>
movsd  -0x20(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    132a <regula+0x1fa>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1304 <regula+0x1d4>
movsd  -0x38(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
subsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  -0x58(%rbp),%xmm2
subsd  -0x50(%rbp),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1040 <_f@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     12af <regula+0x17f>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    12c3 <regula+0x193>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x60(%rbp),%xmm1
movaps 0xd31(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     12f1 <regula+0x1c1>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    136c <regula+0x23c>
jmp    12f6 <regula+0x1c6>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1235 <regula+0x105>
mov    0x2cd5(%rip),%rax
mov    (%rax),%edi
lea    0xd23(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    136c <regula+0x23c>
jmp    132f <regula+0x1ff>
movsd  -0x38(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jae    11f4 <regula+0xc4>
mov    0x2c96(%rip),%rax
mov    (%rax),%edi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xcfe(%rip),%rsi
mov    $0x2,%al
call   1030 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<regula>:
push   %rbx
sub    $0x50,%rsp
movsd  %xmm3,0x28(%rsp)
movsd  %xmm2,(%rsp)
movsd  %xmm0,0x20(%rsp)
movsd  %xmm1,0x18(%rsp)
ucomisd %xmm1,%xmm0
jne    1158 <regula+0x28>
jnp    1231 <regula+0x101>
xorpd  %xmm2,%xmm2
ucomisd (%rsp),%xmm2
jae    1231 <regula+0x101>
ucomisd 0x28(%rsp),%xmm2
jae    1231 <regula+0x101>
mov    %edi,%ebx
test   %edi,%edi
jle    1231 <regula+0x101>
ucomisd %xmm1,%xmm0
jbe    119e <regula+0x6e>
lea    0x20(%rsp),%rdi
lea    0x18(%rsp),%rsi
call   1050 <swapd@plt>
movsd  0x20(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
movsd  %xmm0,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
call   1040 <_f@plt>
movsd  0x8(%rsp),%xmm2
movapd %xmm0,%xmm3
movapd %xmm0,0x30(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  %xmm2,0x8(%rsp)
movapd %xmm2,%xmm0
call   1040 <_f@plt>
movapd 0x30(%rsp),%xmm3
movapd %xmm0,%xmm5
movapd %xmm3,%xmm0
mulsd  %xmm5,%xmm0
ucomisd 0xe17(%rip),%xmm0
jbe    1251 <regula+0x121>
movsd  0x8(%rsp),%xmm2
addsd  (%rsp),%xmm2
movsd  0x18(%rsp),%xmm1
ucomisd %xmm2,%xmm1
jae    11d0 <regula+0xa0>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
movsd  0x20(%rsp),%xmm0
lea    0xe3b(%rip),%rsi
mov    $0x2,%al
call   1030 <fprintf@plt>
jmp    1248 <regula+0x118>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
lea    0xdd7(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
xorpd  %xmm0,%xmm0
jmp    134d <regula+0x21d>
movsd  0x8(%rsp),%xmm4
test   %ebx,%ebx
jle    132c <regula+0x1fc>
movsd  0x10(%rsp),%xmm1
jmp    1294 <regula+0x164>
nopw   0x0(%rax,%rax,1)
xorpd  %xmm3,%xmm3
cmpnlesd %xmm2,%xmm3
movapd %xmm3,%xmm2
andpd  %xmm0,%xmm2
andnpd 0x30(%rsp),%xmm3
orpd   %xmm2,%xmm3
add    $0xffffffff,%ebx
je     132c <regula+0x1fc>
movsd  %xmm5,0x48(%rsp)
movsd  %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
subsd  %xmm4,%xmm0
mulsd  %xmm5,%xmm0
movapd %xmm3,0x30(%rsp)
movapd %xmm3,%xmm1
subsd  %xmm5,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm4,0x8(%rsp)
subsd  %xmm0,%xmm4
movsd  %xmm4,(%rsp)
movapd %xmm4,%xmm0
call   1040 <_f@plt>
movapd %xmm0,%xmm1
andpd  0xd1e(%rip),%xmm1
movsd  0x28(%rsp),%xmm2
ucomisd %xmm1,%xmm2
jae    1348 <regula+0x218>
movapd %xmm0,%xmm2
movsd  0x48(%rsp),%xmm5
mulsd  %xmm5,%xmm2
ucomisd 0xd0c(%rip),%xmm2
movsd  (%rsp),%xmm6
movapd %xmm6,%xmm1
movsd  0x8(%rsp),%xmm4
jb     1270 <regula+0x140>
movapd %xmm0,%xmm5
movsd  0x10(%rsp),%xmm1
movapd %xmm6,%xmm4
jmp    1270 <regula+0x140>
movsd  %xmm6,(%rsp)
mov    0x2ca8(%rip),%rax
mov    (%rax),%edi
lea    0xcfe(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
movsd  (%rsp),%xmm0
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [39 x i8] c"Error : Illegal parameter in regula()\0A\00"
@.str.1 = [36 x i8] c"Error : No convergence in regula()\0A\00"
@.str.2 = [47 x i8] c"Error : No root in range(%e - %e) on regula()\0A\00"
define double @regula(double %0, double %1, double %2, double %3, i32 %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
store double %0, double* %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store i32 %4, i32* %11
%19 = load double, double* %7
%20 = load double, double* %8
%21 = fcmp oeq double %19, %20
br i1 %21, label %31, label %22
22: ; preds = %5
%23 = load double, double* %9
%24 = fcmp ole double %23, 0.000000e+00
br i1 %24, label %31, label %25
25: ; preds = %22
%26 = load double, double* %10
%27 = fcmp ole double %26, 0.000000e+00
br i1 %27, label %31, label %28
28: ; preds = %25
%29 = load i32, i32* %11
%30 = icmp slt i32 %29, 1
br i1 %30, label %31, label %34
31: ; preds = %28, %25, %22, %5
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %6
br label %110
34: ; preds = %28
%35 = load double, double* %7
%36 = load double, double* %8
%37 = fcmp ogt double %35, %36
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @swapd(double* %7, double* %8)
br label %40
40: ; preds = %38, %34
%41 = load double, double* %7
store double %41, double* %13
%42 = load double, double* %8
store double %42, double* %14
%43 = load double, double* %14
%44 = call double @_f(double %43)
store double %44, double* %17
br label %45
45: ; preds = %101, %40
%46 = load double, double* %13
%47 = call double @_f(double %46)
store double %47, double* %16
%48 = load double, double* %16
%49 = load double, double* %17
%50 = fmul double %48, %49
%51 = fcmp ogt double %50, 0.000000e+00
br i1 %51, label %52, label %56
52: ; preds = %45
%53 = load double, double* %9
%54 = load double, double* %13
%55 = fadd double %54, %53
store double %55, double* %13
br label %100
56: ; preds = %45
store i32 0, i32* %12
br label %57
57: ; preds = %93, %56
%58 = load i32, i32* %12
%59 = load i32, i32* %11
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %96
61: ; preds = %57
%62 = load double, double* %13
%63 = load double, double* %16
%64 = load double, double* %14
%65 = load double, double* %13
%66 = fsub double %64, %65
%67 = fmul double %63, %66
%68 = load double, double* %17
%69 = load double, double* %16
%70 = fsub double %68, %69
%71 = fdiv double %67, %70
%72 = fsub double %62, %71
store double %72, double* %15
%73 = load double, double* %15
%74 = call double @_f(double %73)
store double %74, double* %18
%75 = load double, double* %16
%76 = load double, double* %18
%77 = fmul double %75, %76
%78 = fcmp oge double %77, 0.000000e+00
br i1 %78, label %79, label %82
79: ; preds = %61
%80 = load double, double* %15
store double %80, double* %13
%81 = load double, double* %18
store double %81, double* %16
br label %85
82: ; preds = %61
%83 = load double, double* %15
store double %83, double* %14
%84 = load double, double* %18
store double %84, double* %17
br label %85
85: ; preds = %82, %79
%86 = load double, double* %18
%87 = call double @llvm.fabs.f64(double %86)
%88 = load double, double* %10
%89 = fcmp ole double %87, %88
br i1 %89, label %90, label %92
90: ; preds = %85
%91 = load double, double* %15
store double %91, double* %6
br label %110
92: ; preds = %85
br label %93
93: ; preds = %92
%94 = load i32, i32* %12
%95 = add nsw i32 %94, 1
store i32 %95, i32* %12
br label %57
96: ; preds = %57
%97 = load i32, i32* @stderr
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%99 = load double, double* %15
store double %99, double* %6
br label %110
100: ; preds = %52
br label %101
101: ; preds = %100
%102 = load double, double* %13
%103 = load double, double* %8
%104 = fcmp ole double %102, %103
br i1 %104, label %45, label %105
105: ; preds = %101
%106 = load i32, i32* @stderr
%107 = load double, double* %7
%108 = load double, double* %8
%109 = call i32 (i32, i8*, ...) @fprintf(i32 %106, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), double %107, double %108)
store double 0.000000e+00, double* %6
br label %110
110: ; preds = %105, %96, %90, %31
%111 = load double, double* %6
ret double %111
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [39 x i8] c"Error : Illegal parameter in regula()\0A\00"
@.str.1 = [36 x i8] c"Error : No convergence in regula()\0A\00"
@.str.2 = [47 x i8] c"Error : No root in range(%e - %e) on regula()\0A\00"
define double @regula(double %0, double %1, double %2, double %3, i32 %4) {
%6 = alloca double
%7 = alloca double
store double %0, double* %6
store double %1, double* %7
%8 = fcmp oeq double %0, %1
%9 = fcmp ole double %2, 0.000000e+00
%10 = or i1 %8, %9
%11 = fcmp ole double %3, 0.000000e+00
%12 = or i1 %10, %11
%13 = icmp slt i32 %4, 1
%14 = or i1 %12, %13
br i1 %14, label %15, label %18
15: ; preds = %5
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %70
18: ; preds = %5
%19 = fcmp ogt double %0, %1
br i1 %19, label %20, label %24
20: ; preds = %18
%21 = call i32 @swapd(double* %6, double* %7)
%22 = load double, double* %6
%23 = load double, double* %7
br label %24
24: ; preds = %20, %18
%25 = phi double [ %23, %20 ], [ %1, %18 ]
%26 = phi double [ %22, %20 ], [ %0, %18 ]
%27 = call double @_f(double %25)
br label %28
28: ; preds = %35, %24
%29 = phi double [ %26, %24 ], [ %36, %35 ]
%30 = call double @_f(double %29)
%31 = fmul double %27, %30
%32 = fcmp ogt double %31, 0.000000e+00
br i1 %32, label %35, label %33
33: ; preds = %28
%34 = icmp sgt i32 %4, 0
br i1 %34, label %39, label %62
35: ; preds = %28
%36 = fadd double %29, %2
%37 = load double, double* %7
%38 = fcmp ugt double %36, %37
br i1 %38, label %66, label %28
39: ; preds = %33, %55
%40 = phi double [ %56, %55 ], [ %27, %33 ]
%41 = phi double [ %57, %55 ], [ %30, %33 ]
%42 = phi double [ %58, %55 ], [ %25, %33 ]
%43 = phi double [ %59, %55 ], [ %29, %33 ]
%44 = phi i32 [ %60, %55 ], [ 0, %33 ]
%45 = fsub double %42, %43
%46 = fmul double %45, %41
%47 = fsub double %40, %41
%48 = fdiv double %46, %47
%49 = fsub double %43, %48
%50 = call double @_f(double %49)
%51 = fmul double %41, %50
%52 = fcmp ult double %51, 0.000000e+00
%53 = call double @llvm.fabs.f64(double %50)
%54 = fcmp ugt double %53, %3
br i1 %54, label %55, label %70
55: ; preds = %39
%56 = select i1 %52, double %50, double %40
%57 = select i1 %52, double %41, double %50
%58 = select i1 %52, double %49, double %42
%59 = select i1 %52, double %43, double %49
%60 = add nuw nsw i32 %44, 1
%61 = icmp eq i32 %60, %4
br i1 %61, label %62, label %39
62: ; preds = %55, %33
%63 = phi double [ undef, %33 ], [ %49, %55 ]
%64 = load i32, i32* @stderr
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
br label %70
66: ; preds = %35
%67 = load i32, i32* @stderr
%68 = load double, double* %6
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), double %68, double %37)
br label %70
70: ; preds = %39, %66, %62, %15
%71 = phi double [ 0.000000e+00, %15 ], [ 0.000000e+00, %66 ], [ %63, %62 ], [ %49, %39 ]
ret double %71
}