#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*/ expand_width(double *, double, double, double, double,
                                double, double);
int /*<<< orphan*/ insert_new_bracket_point(double *, double *, double *,
                                            double *, double *, double *,
                                            double, double);
int numcmp(double, double);
scalar_t__ random_bit();
double stub1(double);
void bracket_minimum(int *pcode, double *pf0, double *pf1, double *pf2,
                     double *px0, double *px1, double *px2,
                     double (*pfunction)(double x)) {
  int iteration_count, cmp;
  double xnew, fnew, widthg;
  widthg = *px2 - *px0;
  iteration_count = 0;
  for (;;) {
    if ((numcmp(*pf1, *pf0) < 0) && (numcmp(*pf1, *pf2) < 0)) {
      *pcode = 0;
      return;
    }
    ++iteration_count;
    if (iteration_count > 100) {
      *pcode = -2;
      return;
    }
    expand_width(&widthg, *pf0, *pf1, *pf2, *px0, *px1, *px2);
    cmp = numcmp(*pf0, *pf2);
    if (cmp < 0)
      xnew = *px0 - widthg;
    else if (cmp > 0)
      xnew = *px2 + widthg;
    else if (random_bit())
      xnew = *px0 - widthg;
    else
      xnew = *px2 + widthg;
    fnew = (*pfunction)(xnew);
    insert_new_bracket_point(pf0, pf1, pf2, px0, px1, px2, xnew, fnew);
  }
}


x86 assembly (clang, -O0):
<bracket_minimum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x28(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm1
call   1050 <numcmp@plt>
cmp    $0x0,%eax
jge    11cf <bracket_minimum+0x8f>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm1
call   1050 <numcmp@plt>
cmp    $0x0,%eax
jge    11cf <bracket_minimum+0x8f>
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
jmp    1304 <bracket_minimum+0x1c4>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x64,-0x34(%rbp)
jle    11f1 <bracket_minimum+0xb1>
mov    -0x8(%rbp),%rax
movl   $0xfffffffe,(%rax)
jmp    1304 <bracket_minimum+0x1c4>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm3
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm4
mov    0x10(%rbp),%rax
movsd  (%rax),%xmm5
lea    -0x50(%rbp),%rdi
call   1060 <expand_width@plt>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm1
call   1050 <numcmp@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    1263 <bracket_minimum+0x123>
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    12c8 <bracket_minimum+0x188>
cmpl   $0x0,-0x38(%rbp)
jle    1284 <bracket_minimum+0x144>
mov    0x10(%rbp),%rax
movsd  (%rax),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    12c3 <bracket_minimum+0x183>
mov    $0x0,%al
call   1040 <random_bit@plt>
cmp    $0x0,%rax
je     12ac <bracket_minimum+0x16c>
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
subsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    12be <bracket_minimum+0x17e>
mov    0x10(%rbp),%rax
movsd  (%rax),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    12c3 <bracket_minimum+0x183>
jmp    12c8 <bracket_minimum+0x188>
mov    0x18(%rbp),%rax
movsd  -0x40(%rbp),%xmm0
call   *%rax
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    0x10(%rbp),%r9
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
call   1030 <insert_new_bracket_point@plt>
jmp    1184 <bracket_minimum+0x44>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bracket_minimum>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,%r12
mov    %rcx,%r13
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %rdi,0x18(%rsp)
mov    0x60(%rsp),%rax
movsd  (%rax),%xmm0
subsd  (%r8),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x64,%r14d
jmp    11ce <bracket_minimum+0x8e>
xor    %eax,%eax
call   1040 <random_bit@plt>
test   %rax,%rax
je     1248 <bracket_minimum+0x108>
movsd  (%r12),%xmm0
subsd  0x8(%rsp),%xmm0
mov    0x60(%rsp),%r15
movsd  %xmm0,0x20(%rsp)
call   *0x68(%rsp)
movapd %xmm0,%xmm1
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %r12,%rcx
mov    0x10(%rsp),%r8
mov    %r15,%r9
movsd  0x20(%rsp),%xmm0
call   1030 <insert_new_bracket_point@plt>
movsd  (%rbx),%xmm0
movsd  0x0(%rbp),%xmm1
call   1050 <numcmp@plt>
test   %eax,%eax
jns    11f3 <bracket_minimum+0xb3>
movsd  (%rbx),%xmm0
movsd  0x0(%r13),%xmm1
call   1050 <numcmp@plt>
test   %eax,%eax
js     1264 <bracket_minimum+0x124>
sub    $0x1,%r14d
jb     125d <bracket_minimum+0x11d>
movsd  0x0(%rbp),%xmm0
movsd  (%rbx),%xmm1
movsd  0x0(%r13),%xmm2
movsd  (%r12),%xmm3
mov    0x10(%rsp),%rax
movsd  (%rax),%xmm4
mov    0x60(%rsp),%rax
movsd  (%rax),%xmm5
lea    0x8(%rsp),%rdi
call   1060 <expand_width@plt>
movsd  0x0(%rbp),%xmm0
movsd  0x0(%r13),%xmm1
call   1050 <numcmp@plt>
test   %eax,%eax
js     1190 <bracket_minimum+0x50>
je     1180 <bracket_minimum+0x40>
mov    0x60(%rsp),%r15
movsd  (%r15),%xmm0
addsd  0x8(%rsp),%xmm0
jmp    11a1 <bracket_minimum+0x61>
mov    $0xfffffffe,%eax
jmp    1266 <bracket_minimum+0x126>
xor    %eax,%eax
mov    0x18(%rsp),%rcx
mov    %eax,(%rcx)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @bracket_minimum(i32* %0, double* %1, double* %2, double* %3, double* %4, double* %5, double* %6, double (double)* %7) {
%9 = alloca i32*
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca double (double)*
%17 = alloca i32
%18 = alloca i32
%19 = alloca double
%20 = alloca double
%21 = alloca double
store i32* %0, i32** %9
store double* %1, double** %10
store double* %2, double** %11
store double* %3, double** %12
store double* %4, double** %13
store double* %5, double** %14
store double* %6, double** %15
store double (double)* %7, double (double)** %16
%22 = load double*, double** %15
%23 = load double, double* %22
%24 = load double*, double** %13
%25 = load double, double* %24
%26 = fsub double %23, %25
store double %26, double* %21
store i32 0, i32* %17
br label %27
27: ; preds = %99, %8
%28 = load double*, double** %11
%29 = load double, double* %28
%30 = load double*, double** %10
%31 = load double, double* %30
%32 = call i32 @numcmp(double %29, double %31)
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %43
34: ; preds = %27
%35 = load double*, double** %11
%36 = load double, double* %35
%37 = load double*, double** %12
%38 = load double, double* %37
%39 = call i32 @numcmp(double %36, double %38)
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %34
%42 = load i32*, i32** %9
store i32 0, i32* %42
br label %112
43: ; preds = %34, %27
%44 = load i32, i32* %17
%45 = add nsw i32 %44, 1
store i32 %45, i32* %17
%46 = load i32, i32* %17
%47 = icmp sgt i32 %46, 100
br i1 %47, label %48, label %50
48: ; preds = %43
%49 = load i32*, i32** %9
store i32 -2, i32* %49
br label %112
50: ; preds = %43
%51 = load double*, double** %10
%52 = load double, double* %51
%53 = load double*, double** %11
%54 = load double, double* %53
%55 = load double*, double** %12
%56 = load double, double* %55
%57 = load double*, double** %13
%58 = load double, double* %57
%59 = load double*, double** %14
%60 = load double, double* %59
%61 = load double*, double** %15
%62 = load double, double* %61
%63 = call i32 @expand_width(double* %21, double %52, double %54, double %56, double %58, double %60, double %62)
%64 = load double*, double** %10
%65 = load double, double* %64
%66 = load double*, double** %12
%67 = load double, double* %66
%68 = call i32 @numcmp(double %65, double %67)
store i32 %68, i32* %18
%69 = load i32, i32* %18
%70 = icmp slt i32 %69, 0
br i1 %70, label %71, label %76
71: ; preds = %50
%72 = load double*, double** %13
%73 = load double, double* %72
%74 = load double, double* %21
%75 = fsub double %73, %74
store double %75, double* %19
br label %99
76: ; preds = %50
%77 = load i32, i32* %18
%78 = icmp sgt i32 %77, 0
br i1 %78, label %79, label %84
79: ; preds = %76
%80 = load double*, double** %15
%81 = load double, double* %80
%82 = load double, double* %21
%83 = fadd double %81, %82
store double %83, double* %19
br label %98
84: ; preds = %76
%85 = call i64 (...) @random_bit()
%86 = icmp ne i64 %85, 0
br i1 %86, label %87, label %92
87: ; preds = %84
%88 = load double*, double** %13
%89 = load double, double* %88
%90 = load double, double* %21
%91 = fsub double %89, %90
store double %91, double* %19
br label %97
92: ; preds = %84
%93 = load double*, double** %15
%94 = load double, double* %93
%95 = load double, double* %21
%96 = fadd double %94, %95
store double %96, double* %19
br label %97
97: ; preds = %92, %87
br label %98
98: ; preds = %97, %79
br label %99
99: ; preds = %98, %71
%100 = load double (double)*, double (double)** %16
%101 = load double, double* %19
%102 = call double %100(double %101)
store double %102, double* %20
%103 = load double*, double** %10
%104 = load double*, double** %11
%105 = load double*, double** %12
%106 = load double*, double** %13
%107 = load double*, double** %14
%108 = load double*, double** %15
%109 = load double, double* %19
%110 = load double, double* %20
%111 = call i32 @insert_new_bracket_point(double* %103, double* %104, double* %105, double* %106, double* %107, double* %108, double %109, double %110)
br label %27
112: ; preds = %48, %41
ret void
}

LLVM IR (-O2):
define void @bracket_minimum(i32* nocapture writeonly %0, double* %1, double* %2, double* %3, double* %4, double* %5, double* %6, double (double)* nocapture %7) {
%9 = alloca double
%10 = bitcast double* %9 to i8*
%11 = load double, double* %6
%12 = load double, double* %4
%13 = fsub double %11, %12
store double %13, double* %9
br label %14
14: ; preds = %61, %8
%15 = phi i32 [ 0, %8 ], [ %26, %61 ]
%16 = load double, double* %2
%17 = load double, double* %1
%18 = call i32 @numcmp(double %16, double %17)
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %14
%21 = load double, double* %2
%22 = load double, double* %3
%23 = call i32 @numcmp(double %21, double %22)
%24 = icmp slt i32 %23, 0
br i1 %24, label %65, label %25
25: ; preds = %20, %14
%26 = add nuw nsw i32 %15, 1
%27 = icmp eq i32 %15, 100
br i1 %27, label %65, label %28
28: ; preds = %25
%29 = load double, double* %1
%30 = load double, double* %2
%31 = load double, double* %3
%32 = load double, double* %4
%33 = load double, double* %5
%34 = load double, double* %6
%35 = call i32 @expand_width(double* %9, double %29, double %30, double %31, double %32, double %33, double %34)
%36 = load double, double* %1
%37 = load double, double* %3
%38 = call i32 @numcmp(double %36, double %37)
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %28
%41 = load double, double* %4
%42 = load double, double* %9
%43 = fsub double %41, %42
br label %61
44: ; preds = %28
%45 = icmp eq i32 %38, 0
br i1 %45, label %50, label %46
46: ; preds = %44
%47 = load double, double* %6
%48 = load double, double* %9
%49 = fadd double %47, %48
br label %61
50: ; preds = %44
%51 = call i64 (...) @random_bit()
%52 = icmp eq i64 %51, 0
br i1 %52, label %57, label %53
53: ; preds = %50
%54 = load double, double* %4
%55 = load double, double* %9
%56 = fsub double %54, %55
br label %61
57: ; preds = %50
%58 = load double, double* %6
%59 = load double, double* %9
%60 = fadd double %58, %59
br label %61
61: ; preds = %46, %57, %53, %40
%62 = phi double [ %43, %40 ], [ %49, %46 ], [ %56, %53 ], [ %60, %57 ]
%63 = call double %7(double %62)
%64 = call i32 @insert_new_bracket_point(double* %1, double* %2, double* %3, double* %4, double* %5, double* %6, double %62, double %63)
br label %14
65: ; preds = %25, %20
%66 = phi i32 [ 0, %20 ], [ -2, %25 ]
store i32 %66, i32* %0
ret void
}