#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 abs(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
double function(double *, int, int, double);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ system(char *);
double dicotomic(double *param, int dimension, int functiontype,
                 double precision, double *error, long int *inter,
                 double extr_a, double extr_b) {
  double funz_extr_a;
  double funz_extr_b;
  double m;
  double funz_m;
  system("clear");
  fprintf(stdout, "[*] Calculating ...\n");
  funz_extr_a = function(param, dimension, functiontype, extr_a);
  funz_extr_b = function(param, dimension, functiontype, extr_b);
  do {
    inter++;
    m = (extr_a + extr_b) / 2;
    funz_m = function(param, dimension, functiontype, m);
    if (funz_m == 0.) {
      *error = 0.;
      break;
    }
    if (funz_extr_a * funz_m < 0.) {
      extr_b = m;
      funz_extr_b = funz_m;
    }
    if (funz_extr_b * funz_m < 0.) {
      extr_a = m;
      funz_extr_a = funz_m;
    }
    *error = abs((extr_b - extr_a) / 2);
  } while (*error > precision);
  return m;
}


x86 assembly (clang, -O0):
<dicotomic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movsd  %xmm1,-0x30(%rbp)
movsd  %xmm2,-0x38(%rbp)
lea    0xe98(%rip),%rdi
call   1040 <system@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
lea    0xe89(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
movsd  -0x30(%rbp),%xmm0
call   1060 <function@plt>
movsd  %xmm0,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
movsd  -0x38(%rbp),%xmm0
call   1060 <function@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  0xe26(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
movsd  -0x50(%rbp),%xmm0
call   1060 <function@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1224 <dicotomic+0xe4>
jp     1224 <dicotomic+0xe4>
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
jmp    12b0 <dicotomic+0x170>
movsd  -0x40(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    124f <dicotomic+0x10f>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm1
mulsd  -0x58(%rbp),%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    127a <dicotomic+0x13a>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
movsd  0xd74(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1030 <abs@plt>
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd -0x18(%rbp),%xmm0
ja     11bc <dicotomic+0x7c>
movsd  -0x50(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dicotomic>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
movaps %xmm2,0x10(%rsp)
movsd  %xmm1,(%rsp)
mov    %rcx,%r14
movsd  %xmm0,0x28(%rsp)
mov    %edx,%r15d
mov    %esi,%ebx
mov    %rdi,%rbp
lea    0xea4(%rip),%rdi
call   1040 <system@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
lea    0xe95(%rip),%rsi
call   1050 <fprintf@plt>
mov    %rbp,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
movsd  (%rsp),%xmm0
call   1060 <function@plt>
movaps %xmm0,0x30(%rsp)
mov    %rbp,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
movaps 0x10(%rsp),%xmm0
call   1060 <function@plt>
movsd  (%rsp),%xmm2
movapd 0x10(%rsp),%xmm3
movsd  0xe3e(%rip),%xmm1
jmp    125a <dicotomic+0x11a>
nopw   0x0(%rax,%rax,1)
movsd  %xmm7,(%rsp)
cmpltsd %xmm2,%xmm6
movapd %xmm6,%xmm1
andpd  %xmm4,%xmm1
andnpd 0x10(%rsp),%xmm6
orpd   %xmm1,%xmm6
movapd %xmm6,0x50(%rsp)
cmpltsd %xmm2,%xmm0
movapd %xmm0,%xmm1
andpd  %xmm5,%xmm1
andnpd %xmm3,%xmm0
orpd   %xmm1,%xmm0
movapd %xmm0,0x10(%rsp)
movapd %xmm6,%xmm0
subsd  %xmm7,%xmm0
movsd  0xde3(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <abs@plt>
movsd  0xdd2(%rip),%xmm1
movsd  %xmm0,(%r14)
ucomisd 0x28(%rsp),%xmm0
movapd 0x50(%rsp),%xmm3
movaps 0x10(%rsp),%xmm0
movaps %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm2
jbe    12ef <dicotomic+0x1af>
movsd  %xmm0,0x8(%rsp)
movapd %xmm3,0x10(%rsp)
movapd %xmm3,%xmm0
movsd  %xmm2,(%rsp)
addsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
mov    %rbp,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
movapd %xmm0,0x40(%rsp)
call   1060 <function@plt>
ucomisd 0xd76(%rip),%xmm0
xorpd  %xmm2,%xmm2
jne    129a <dicotomic+0x15a>
jnp    12e8 <dicotomic+0x1a8>
movapd %xmm0,%xmm5
movapd 0x30(%rsp),%xmm3
movapd %xmm3,%xmm6
mulsd  %xmm0,%xmm6
ucomisd %xmm6,%xmm2
movapd %xmm0,%xmm1
ja     12bc <dicotomic+0x17c>
movsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
mulsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
movapd 0x40(%rsp),%xmm4
movapd %xmm4,%xmm7
movsd  (%rsp),%xmm1
ja     11d0 <dicotomic+0x90>
movapd %xmm1,%xmm7
jmp    11d0 <dicotomic+0x90>
movq   $0x0,(%r14)
movaps 0x40(%rsp),%xmm0
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"clear\00"
@stdout = global i32 0
@.str.1 = [21 x i8] c"[*] Calculating ...\0A\00"
define double @dicotomic(double* %0, i32 %1, i32 %2, double %3, double* %4, i64* %5, double %6, double %7) {
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double*
%14 = alloca i64*
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
store double* %0, double** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store double %3, double* %12
store double* %4, double** %13
store i64* %5, i64** %14
store double %6, double* %15
store double %7, double* %16
%21 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%22 = load i32, i32* @stdout
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%24 = load double*, double** %9
%25 = load i32, i32* %10
%26 = load i32, i32* %11
%27 = load double, double* %15
%28 = call double @function(double* %24, i32 %25, i32 %26, double %27)
store double %28, double* %17
%29 = load double*, double** %9
%30 = load i32, i32* %10
%31 = load i32, i32* %11
%32 = load double, double* %16
%33 = call double @function(double* %29, i32 %30, i32 %31, double %32)
store double %33, double* %18
br label %34
34: ; preds = %73, %8
%35 = load i64*, i64** %14
%36 = getelementptr inbounds i64, i64* %35, i32 1
store i64* %36, i64** %14
%37 = load double, double* %15
%38 = load double, double* %16
%39 = fadd double %37, %38
%40 = fdiv double %39, 2.000000e+00
store double %40, double* %19
%41 = load double*, double** %9
%42 = load i32, i32* %10
%43 = load i32, i32* %11
%44 = load double, double* %19
%45 = call double @function(double* %41, i32 %42, i32 %43, double %44)
store double %45, double* %20
%46 = load double, double* %20
%47 = fcmp oeq double %46, 0.000000e+00
br i1 %47, label %48, label %50
48: ; preds = %34
%49 = load double*, double** %13
store double 0.000000e+00, double* %49
br label %78
50: ; preds = %34
%51 = load double, double* %17
%52 = load double, double* %20
%53 = fmul double %51, %52
%54 = fcmp olt double %53, 0.000000e+00
br i1 %54, label %55, label %58
55: ; preds = %50
%56 = load double, double* %19
store double %56, double* %16
%57 = load double, double* %20
store double %57, double* %18
br label %58
58: ; preds = %55, %50
%59 = load double, double* %18
%60 = load double, double* %20
%61 = fmul double %59, %60
%62 = fcmp olt double %61, 0.000000e+00
br i1 %62, label %63, label %66
63: ; preds = %58
%64 = load double, double* %19
store double %64, double* %15
%65 = load double, double* %20
store double %65, double* %17
br label %66
66: ; preds = %63, %58
%67 = load double, double* %16
%68 = load double, double* %15
%69 = fsub double %67, %68
%70 = fdiv double %69, 2.000000e+00
%71 = call double @abs(double %70)
%72 = load double*, double** %13
store double %71, double* %72
br label %73
73: ; preds = %66
%74 = load double*, double** %13
%75 = load double, double* %74
%76 = load double, double* %12
%77 = fcmp ogt double %75, %76
br i1 %77, label %34, label %78
78: ; preds = %73, %48
%79 = load double, double* %19
ret double %79
}

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
@stdout = global i32 0
@.str.1 = [21 x i8] c"[*] Calculating ...\0A\00"
define double @dicotomic(double* %0, i32 %1, i32 %2, double %3, double* nocapture writeonly %4, i64* nocapture readnone %5, double %6, double %7) {
%9 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @stdout
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call double @function(double* %0, i32 %1, i32 %2, double %6)
%13 = tail call double @function(double* %0, i32 %1, i32 %2, double %7)
br label %14
14: ; preds = %24, %8
%15 = phi double [ %7, %8 ], [ %27, %24 ]
%16 = phi double [ %12, %8 ], [ %31, %24 ]
%17 = phi double [ %13, %8 ], [ %28, %24 ]
%18 = phi double [ %6, %8 ], [ %32, %24 ]
%19 = fadd double %15, %18
%20 = fmul double %19, 5.000000e-01
%21 = tail call double @function(double* %0, i32 %1, i32 %2, double %20)
%22 = fcmp oeq double %21, 0.000000e+00
br i1 %22, label %23, label %24
23: ; preds = %14
store double 0.000000e+00, double* %4
br label %37
24: ; preds = %14
%25 = fmul double %16, %21
%26 = fcmp olt double %25, 0.000000e+00
%27 = select i1 %26, double %20, double %15
%28 = select i1 %26, double %21, double %17
%29 = fmul double %21, %28
%30 = fcmp olt double %29, 0.000000e+00
%31 = select i1 %30, double %21, double %16
%32 = select i1 %30, double %20, double %18
%33 = fsub double %27, %32
%34 = fmul double %33, 5.000000e-01
%35 = tail call double @abs(double %34)
store double %35, double* %4
%36 = fcmp ogt double %35, %3
br i1 %36, label %14, label %37
37: ; preds = %24, %23
ret double %20
}