#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*/ bracket_minimum(int *, double *, double *, double *,
                                   double *, double *, double *,
                                   double (*)(double));
int /*<<< orphan*/ order_args(double *, double *, double *, double *, double *,
                              double *);
int /*<<< orphan*/ trap_minimum(double *, double *, double *, double *,
                                double *, double *, double, double (*)(double),
                                int);
void minimize_1d_raw(int *pcode, double *pf0, double *pf1, double *pf2,
                     double *px0, double *px1, double *px2, double f_goal,
                     double (*pfunction)(double x), int max_iterations) {
  double original_f1, original_x1;
  order_args(pf0, pf1, pf2, px0, px1, px2);
  original_f1 = *pf1;
  original_x1 = *px1;
  bracket_minimum(pcode, pf0, pf1, pf2, px0, px1, px2, pfunction);
  if (*pcode == 0)
    trap_minimum(pf0, pf1, pf2, px0, px1, px2, f_goal, pfunction,
                 max_iterations);
  else if (*pcode == -2) {
    if ((original_f1 == *pf0) && (original_f1 == *pf1) &&
        (original_f1 == *pf2)) {
      *px0 = *px1 = *px2 = original_x1;
      *pcode = 0;
    }
  }
}


x86 assembly (clang, -O0):
<minimize_1d_raw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x20(%rbp),%eax
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)
movsd  %xmm0,-0x38(%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
call   1040 <order_args@plt>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x30(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
mov    0x10(%rbp),%r10
mov    0x18(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <bracket_minimum@plt>
mov    -0x8(%rbp),%rax
cmpl   $0x0,(%rax)
jne    1208 <minimize_1d_raw+0xd8>
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  -0x38(%rbp),%xmm0
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%eax
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
call   1050 <trap_minimum@plt>
jmp    1291 <minimize_1d_raw+0x161>
mov    -0x8(%rbp),%rax
cmpl   $0xfffffffe,(%rax)
jne    128c <minimize_1d_raw+0x15c>
movsd  -0x40(%rbp),%xmm0
mov    -0x10(%rbp),%rax
ucomisd (%rax),%xmm0
jne    1287 <minimize_1d_raw+0x157>
jp     1287 <minimize_1d_raw+0x157>
movsd  -0x40(%rbp),%xmm0
mov    -0x18(%rbp),%rax
ucomisd (%rax),%xmm0
jne    1287 <minimize_1d_raw+0x157>
jp     1287 <minimize_1d_raw+0x157>
movsd  -0x40(%rbp),%xmm0
mov    -0x20(%rbp),%rax
ucomisd (%rax),%xmm0
jne    1287 <minimize_1d_raw+0x157>
jp     1287 <minimize_1d_raw+0x157>
movsd  -0x48(%rbp),%xmm0
mov    0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
jmp    128c <minimize_1d_raw+0x15c>
jmp    1291 <minimize_1d_raw+0x161>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<minimize_1d_raw>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movsd  %xmm0,0x20(%rsp)
mov    %r9,%rbx
mov    %r8,%r13
mov    %rcx,%r12
mov    %rdx,%rbp
mov    %rsi,%r15
mov    %rdi,%r14
mov    0x60(%rsp),%r9
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %r8,%rcx
mov    %rbx,%r8
call   1040 <order_args@plt>
movsd  0x0(%rbp),%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  (%rbx),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
mov    %r12,%rcx
mov    %r13,0x8(%rsp)
mov    %r13,%r8
mov    0x68(%rsp),%r13
mov    %rbx,%r9
push   %r13
push   0x68(%rsp)
call   1030 <bracket_minimum@plt>
add    $0x10,%rsp
mov    (%r14),%eax
cmp    $0xfffffffe,%eax
je     11e9 <minimize_1d_raw+0xb9>
test   %eax,%eax
jne    122e <minimize_1d_raw+0xfe>
mov    0x70(%rsp),%eax
mov    %r15,%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
mov    0x8(%rsp),%rcx
mov    %rbx,%r8
mov    0x60(%rsp),%r9
movsd  0x20(%rsp),%xmm0
push   %rax
push   %r13
call   1050 <trap_minimum@plt>
add    $0x38,%rsp
jmp    1232 <minimize_1d_raw+0x102>
movsd  0x10(%rsp),%xmm0
movsd  0x18(%rsp),%xmm1
ucomisd (%r15),%xmm1
jne    122e <minimize_1d_raw+0xfe>
jp     122e <minimize_1d_raw+0xfe>
ucomisd 0x0(%rbp),%xmm1
jne    122e <minimize_1d_raw+0xfe>
jp     122e <minimize_1d_raw+0xfe>
ucomisd (%r12),%xmm1
jne    122e <minimize_1d_raw+0xfe>
jp     122e <minimize_1d_raw+0xfe>
mov    0x60(%rsp),%rax
movsd  %xmm0,(%rax)
movsd  %xmm0,(%rbx)
mov    0x8(%rsp),%rax
movsd  %xmm0,(%rax)
movl   $0x0,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @minimize_1d_raw(i32* %0, double* %1, double* %2, double* %3, double* %4, double* %5, double* %6, double %7, double (double)* %8, i32 %9) {
%11 = alloca i32*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca double*
%17 = alloca double*
%18 = alloca double
%19 = alloca double (double)*
%20 = alloca i32
%21 = alloca double
%22 = alloca double
store i32* %0, i32** %11
store double* %1, double** %12
store double* %2, double** %13
store double* %3, double** %14
store double* %4, double** %15
store double* %5, double** %16
store double* %6, double** %17
store double %7, double* %18
store double (double)* %8, double (double)** %19
store i32 %9, i32* %20
%23 = load double*, double** %12
%24 = load double*, double** %13
%25 = load double*, double** %14
%26 = load double*, double** %15
%27 = load double*, double** %16
%28 = load double*, double** %17
%29 = call i32 @order_args(double* %23, double* %24, double* %25, double* %26, double* %27, double* %28)
%30 = load double*, double** %13
%31 = load double, double* %30
store double %31, double* %21
%32 = load double*, double** %16
%33 = load double, double* %32
store double %33, double* %22
%34 = load i32*, i32** %11
%35 = load double*, double** %12
%36 = load double*, double** %13
%37 = load double*, double** %14
%38 = load double*, double** %15
%39 = load double*, double** %16
%40 = load double*, double** %17
%41 = load double (double)*, double (double)** %19
%42 = call i32 @bracket_minimum(i32* %34, double* %35, double* %36, double* %37, double* %38, double* %39, double* %40, double (double)* %41)
%43 = load i32*, i32** %11
%44 = load i32, i32* %43
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %57
46: ; preds = %10
%47 = load double*, double** %12
%48 = load double*, double** %13
%49 = load double*, double** %14
%50 = load double*, double** %15
%51 = load double*, double** %16
%52 = load double*, double** %17
%53 = load double, double* %18
%54 = load double (double)*, double (double)** %19
%55 = load i32, i32* %20
%56 = call i32 @trap_minimum(double* %47, double* %48, double* %49, double* %50, double* %51, double* %52, double %53, double (double)* %54, i32 %55)
br label %84
57: ; preds = %10
%58 = load i32*, i32** %11
%59 = load i32, i32* %58
%60 = icmp eq i32 %59, -2
br i1 %60, label %61, label %83
61: ; preds = %57
%62 = load double, double* %21
%63 = load double*, double** %12
%64 = load double, double* %63
%65 = fcmp oeq double %62, %64
br i1 %65, label %66, label %82
66: ; preds = %61
%67 = load double, double* %21
%68 = load double*, double** %13
%69 = load double, double* %68
%70 = fcmp oeq double %67, %69
br i1 %70, label %71, label %82
71: ; preds = %66
%72 = load double, double* %21
%73 = load double*, double** %14
%74 = load double, double* %73
%75 = fcmp oeq double %72, %74
br i1 %75, label %76, label %82
76: ; preds = %71
%77 = load double, double* %22
%78 = load double*, double** %17
store double %77, double* %78
%79 = load double*, double** %16
store double %77, double* %79
%80 = load double*, double** %15
store double %77, double* %80
%81 = load i32*, i32** %11
store i32 0, i32* %81
br label %82
82: ; preds = %76, %71, %66, %61
br label %83
83: ; preds = %82, %57
br label %84
84: ; preds = %83, %46
ret void
}

LLVM IR (-O2):
define void @minimize_1d_raw(i32* %0, double* %1, double* %2, double* %3, double* %4, double* %5, double* %6, double %7, double (double)* %8, i32 %9) {
%11 = tail call i32 @order_args(double* %1, double* %2, double* %3, double* %4, double* %5, double* %6)
%12 = load double, double* %2
%13 = load double, double* %5
%14 = tail call i32 @bracket_minimum(i32* %0, double* %1, double* %2, double* %3, double* %4, double* %5, double* %6, double (double)* %8)
%15 = load i32, i32* %0
switch i32 %15, label %28 [
i32 0, label %16
i32 -2, label %18
]
16: ; preds = %10
%17 = tail call i32 @trap_minimum(double* %1, double* %2, double* %3, double* %4, double* %5, double* %6, double %7, double (double)* %8, i32 %9)
br label %28
18: ; preds = %10
%19 = load double, double* %1
%20 = fcmp oeq double %12, %19
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load double, double* %2
%23 = fcmp oeq double %12, %22
br i1 %23, label %24, label %28
24: ; preds = %21
%25 = load double, double* %3
%26 = fcmp oeq double %12, %25
br i1 %26, label %27, label %28
27: ; preds = %24
store double %13, double* %6
store double %13, double* %5
store double %13, double* %4
store i32 0, i32* %0
br label %28
28: ; preds = %10, %27, %24, %21, %18, %16
ret void
}