; LLVM IR from Amoiensis/Optimization-Algorithm :: [LineSearchMethod]一维搜索法/[Golden Section Method]黄金分割法 (Golden_Section_Method)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca ptr, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  %17 = alloca double, align 8
  %18 = alloca double, align 8
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store double 4.000000e+00, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store double 6.000000e+00, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store double 1.000000e-03, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  store double 6.180000e-01, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  store ptr @Function, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %19 = load double, ptr %6, align 8, !tbaa !11
  store double %19, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %20 = load double, ptr %7, align 8, !tbaa !11
  store double %20, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %21 = load double, ptr %9, align 8, !tbaa !11
  %22 = load double, ptr %11, align 8, !tbaa !11
  %23 = load double, ptr %9, align 8, !tbaa !11
  %24 = fsub double 1.000000e+00, %23
  %25 = load double, ptr %12, align 8, !tbaa !11
  %26 = fmul double %24, %25
  %27 = call double @llvm.fmuladd.f64(double %21, double %22, double %26)
  store double %27, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %28 = load double, ptr %9, align 8, !tbaa !11
  %29 = fsub double 1.000000e+00, %28
  %30 = load double, ptr %11, align 8, !tbaa !11
  %31 = load double, ptr %9, align 8, !tbaa !11
  %32 = load double, ptr %12, align 8, !tbaa !11
  %33 = fmul double %31, %32
  %34 = call double @llvm.fmuladd.f64(double %29, double %30, double %33)
  store double %34, ptr %14, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %35 = load ptr, ptr %10, align 8, !tbaa !9
  %36 = load double, ptr %13, align 8, !tbaa !11
  %37 = call double %35(double noundef %36)
  store double %37, ptr %15, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %38 = load ptr, ptr %10, align 8, !tbaa !9
  %39 = load double, ptr %14, align 8, !tbaa !11
  %40 = call double %38(double noundef %39)
  store double %40, ptr %16, align 8, !tbaa !11
  br label %41

41:                                               ; preds = %107, %2
  %42 = load double, ptr %14, align 8, !tbaa !11
  %43 = load double, ptr %13, align 8, !tbaa !11
  %44 = fsub double %42, %43
  %45 = load double, ptr %8, align 8, !tbaa !11
  %46 = fcmp ogt double %44, %45
  br i1 %46, label %47, label %108

47:                                               ; preds = %41
  %48 = load double, ptr %15, align 8, !tbaa !11
  %49 = load double, ptr %16, align 8, !tbaa !11
  %50 = fcmp olt double %48, %49
  br i1 %50, label %51, label %65

51:                                               ; preds = %47
  %52 = load double, ptr %14, align 8, !tbaa !11
  store double %52, ptr %12, align 8, !tbaa !11
  %53 = load double, ptr %13, align 8, !tbaa !11
  store double %53, ptr %14, align 8, !tbaa !11
  %54 = load double, ptr %9, align 8, !tbaa !11
  %55 = load double, ptr %11, align 8, !tbaa !11
  %56 = load double, ptr %9, align 8, !tbaa !11
  %57 = fsub double 1.000000e+00, %56
  %58 = load double, ptr %12, align 8, !tbaa !11
  %59 = fmul double %57, %58
  %60 = call double @llvm.fmuladd.f64(double %54, double %55, double %59)
  store double %60, ptr %13, align 8, !tbaa !11
  %61 = load ptr, ptr %10, align 8, !tbaa !9
  %62 = load double, ptr %13, align 8, !tbaa !11
  %63 = call double %61(double noundef %62)
  store double %63, ptr %15, align 8, !tbaa !11
  %64 = load double, ptr %15, align 8, !tbaa !11
  store double %64, ptr %16, align 8, !tbaa !11
  br label %107

65:                                               ; preds = %47
  %66 = load double, ptr %15, align 8, !tbaa !11
  %67 = load double, ptr %16, align 8, !tbaa !11
  %68 = fcmp ogt double %66, %67
  br i1 %68, label %69, label %83

69:                                               ; preds = %65
  %70 = load double, ptr %13, align 8, !tbaa !11
  store double %70, ptr %11, align 8, !tbaa !11
  %71 = load double, ptr %14, align 8, !tbaa !11
  store double %71, ptr %13, align 8, !tbaa !11
  %72 = load double, ptr %9, align 8, !tbaa !11
  %73 = fsub double 1.000000e+00, %72
  %74 = load double, ptr %11, align 8, !tbaa !11
  %75 = load double, ptr %9, align 8, !tbaa !11
  %76 = load double, ptr %12, align 8, !tbaa !11
  %77 = fmul double %75, %76
  %78 = call double @llvm.fmuladd.f64(double %73, double %74, double %77)
  store double %78, ptr %14, align 8, !tbaa !11
  %79 = load double, ptr %16, align 8, !tbaa !11
  store double %79, ptr %15, align 8, !tbaa !11
  %80 = load ptr, ptr %10, align 8, !tbaa !9
  %81 = load double, ptr %14, align 8, !tbaa !11
  %82 = call double %80(double noundef %81)
  store double %82, ptr %16, align 8, !tbaa !11
  br label %106

83:                                               ; preds = %65
  %84 = load double, ptr %13, align 8, !tbaa !11
  store double %84, ptr %11, align 8, !tbaa !11
  %85 = load double, ptr %14, align 8, !tbaa !11
  store double %85, ptr %12, align 8, !tbaa !11
  %86 = load double, ptr %9, align 8, !tbaa !11
  %87 = load double, ptr %11, align 8, !tbaa !11
  %88 = load double, ptr %9, align 8, !tbaa !11
  %89 = fsub double 1.000000e+00, %88
  %90 = load double, ptr %12, align 8, !tbaa !11
  %91 = fmul double %89, %90
  %92 = call double @llvm.fmuladd.f64(double %86, double %87, double %91)
  store double %92, ptr %13, align 8, !tbaa !11
  %93 = load double, ptr %9, align 8, !tbaa !11
  %94 = fsub double 1.000000e+00, %93
  %95 = load double, ptr %11, align 8, !tbaa !11
  %96 = load double, ptr %9, align 8, !tbaa !11
  %97 = load double, ptr %12, align 8, !tbaa !11
  %98 = fmul double %96, %97
  %99 = call double @llvm.fmuladd.f64(double %94, double %95, double %98)
  store double %99, ptr %14, align 8, !tbaa !11
  %100 = load ptr, ptr %10, align 8, !tbaa !9
  %101 = load double, ptr %13, align 8, !tbaa !11
  %102 = call double %100(double noundef %101)
  store double %102, ptr %15, align 8, !tbaa !11
  %103 = load ptr, ptr %10, align 8, !tbaa !9
  %104 = load double, ptr %14, align 8, !tbaa !11
  %105 = call double %103(double noundef %104)
  store double %105, ptr %16, align 8, !tbaa !11
  br label %106

106:                                              ; preds = %83, %69
  br label %107

107:                                              ; preds = %106, %51
  br label %41, !llvm.loop !13

108:                                              ; preds = %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %109 = load double, ptr %14, align 8, !tbaa !11
  %110 = load double, ptr %13, align 8, !tbaa !11
  %111 = fadd double %109, %110
  %112 = fdiv double %111, 2.000000e+00
  store double %112, ptr %17, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %113 = load ptr, ptr %10, align 8, !tbaa !9
  %114 = load double, ptr %17, align 8, !tbaa !11
  %115 = call double %113(double noundef %114)
  store double %115, ptr %18, align 8, !tbaa !11
  %116 = load double, ptr %17, align 8, !tbaa !11
  %117 = load double, ptr %18, align 8, !tbaa !11
  %118 = call i32 (ptr, ...) @printf(ptr noundef @.str, double noundef %116, double noundef %117)
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  ret i32 0
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local double @Function(double noundef) #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

declare i32 @printf(ptr noundef, ...) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@.str = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = tail call double @Function(double noundef 0x40130E5604189374)
  %4 = tail call double @Function(double noundef 0x4014F1A9FBE76C8C)
  br label %5

5:                                                ; preds = %2, %24
  %.074 = phi double [ 4.000000e+00, %2 ], [ %.1, %24 ]
  %.05973 = phi double [ 6.000000e+00, %2 ], [ %.160, %24 ]
  %.06172 = phi double [ %4, %2 ], [ %.162, %24 ]
  %.06371 = phi double [ %3, %2 ], [ %.164, %24 ]
  %.06570 = phi double [ 0x4014F1A9FBE76C8C, %2 ], [ %.166, %24 ]
  %.06769 = phi double [ 0x40130E5604189374, %2 ], [ %.168, %24 ]
  %6 = fcmp olt double %.06371, %.06172
  br i1 %6, label %7, label %11

7:                                                ; preds = %5
  %8 = fmul double %.06570, 3.820000e-01
  %9 = tail call double @llvm.fmuladd.f64(double %.074, double 6.180000e-01, double %8)
  %10 = tail call double @Function(double noundef %9)
  br label %24

11:                                               ; preds = %5
  %12 = fcmp ogt double %.06371, %.06172
  br i1 %12, label %13, label %17

13:                                               ; preds = %11
  %14 = fmul double %.05973, 6.180000e-01
  %15 = tail call double @llvm.fmuladd.f64(double %.06769, double 3.820000e-01, double %14)
  %16 = tail call double @Function(double noundef %15)
  br label %24

17:                                               ; preds = %11
  %18 = fmul double %.06570, 3.820000e-01
  %19 = tail call double @llvm.fmuladd.f64(double %.06769, double 6.180000e-01, double %18)
  %20 = fmul double %.06570, 6.180000e-01
  %21 = tail call double @llvm.fmuladd.f64(double %.06769, double 3.820000e-01, double %20)
  %22 = tail call double @Function(double noundef %19)
  %23 = tail call double @Function(double noundef %21)
  br label %24

24:                                               ; preds = %13, %17, %7
  %.168 = phi double [ %9, %7 ], [ %.06570, %13 ], [ %19, %17 ]
  %.166 = phi double [ %.06769, %7 ], [ %15, %13 ], [ %21, %17 ]
  %.164 = phi double [ %10, %7 ], [ %.06172, %13 ], [ %22, %17 ]
  %.162 = phi double [ %10, %7 ], [ %16, %13 ], [ %23, %17 ]
  %.160 = phi double [ %.06570, %7 ], [ %.05973, %13 ], [ %.06570, %17 ]
  %.1 = phi double [ %.074, %7 ], [ %.06769, %13 ], [ %.06769, %17 ]
  %25 = fsub double %.166, %.168
  %26 = fcmp ogt double %25, 1.000000e-03
  br i1 %26, label %5, label %27, !llvm.loop !5

27:                                               ; preds = %24
  %28 = fadd double %.168, %.166
  %29 = fmul double %28, 5.000000e-01
  %30 = tail call double @Function(double noundef %29)
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %29, double noundef %30)
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare dso_local double @Function(double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass