; LLVM IR from Amoiensis/Optimization-Algorithm :: [Direct_Method]直接法/[Univariate_Search_Method]坐标轮换法 (main)

; 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.29 = external hidden unnamed_addr constant [22 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local double @Bisection_Method(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca ptr, align 8
  %10 = alloca double, 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
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store double -2.000000e+01, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store double 2.000000e+01, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store double 1.000000e-01, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store double 1.000000e-01, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store ptr @Function_sub, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %16 = load double, ptr %5, align 8, !tbaa !9
  store double %16, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %17 = load double, ptr %6, align 8, !tbaa !9
  store double %17, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  br label %18

18:                                               ; preds = %51, %2
  %19 = load double, ptr %11, align 8, !tbaa !9
  %20 = load double, ptr %10, align 8, !tbaa !9
  %21 = fsub double %19, %20
  %22 = load double, ptr %7, align 8, !tbaa !9
  %23 = fcmp ogt double %21, %22
  br i1 %23, label %24, label %52

24:                                               ; preds = %18
  %25 = load double, ptr %11, align 8, !tbaa !9
  %26 = load double, ptr %10, align 8, !tbaa !9
  %27 = fadd double %25, %26
  %28 = fdiv double %27, 2.000000e+00
  store double %28, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %29 = load double, ptr %12, align 8, !tbaa !9
  %30 = load double, ptr %8, align 8, !tbaa !9
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = call double @Func_derivative_sub(double noundef %29, double noundef %30, ptr noundef %31, ptr noundef %32)
  store double %33, ptr %13, align 8, !tbaa !9
  %34 = load double, ptr %13, align 8, !tbaa !9
  %35 = fcmp ogt double %34, 0.000000e+00
  br i1 %35, label %36, label %38

36:                                               ; preds = %24
  %37 = load double, ptr %12, align 8, !tbaa !9
  store double %37, ptr %11, align 8, !tbaa !9
  br label %51

38:                                               ; preds = %24
  %39 = load double, ptr %13, align 8, !tbaa !9
  %40 = fcmp olt double %39, 0.000000e+00
  br i1 %40, label %41, label %43

41:                                               ; preds = %38
  %42 = load double, ptr %12, align 8, !tbaa !9
  store double %42, ptr %10, align 8, !tbaa !9
  br label %50

43:                                               ; preds = %38
  %44 = load double, ptr %12, align 8, !tbaa !9
  %45 = load double, ptr %8, align 8, !tbaa !9
  %46 = fsub double %44, %45
  store double %46, ptr %10, align 8, !tbaa !9
  %47 = load double, ptr %12, align 8, !tbaa !9
  %48 = load double, ptr %8, align 8, !tbaa !9
  %49 = fadd double %47, %48
  store double %49, ptr %11, align 8, !tbaa !9
  br label %50

50:                                               ; preds = %43, %41
  br label %51

51:                                               ; preds = %50, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %18, !llvm.loop !11

52:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %53 = load double, ptr %11, align 8, !tbaa !9
  %54 = load double, ptr %10, align 8, !tbaa !9
  %55 = fadd double %53, %54
  %56 = fdiv double %55, 2.000000e+00
  store double %56, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %57 = load ptr, ptr %9, align 8, !tbaa !5
  %58 = load double, ptr %14, align 8, !tbaa !9
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = call double %57(double noundef %58, ptr noundef %59, ptr noundef %60)
  store double %61, ptr %15, align 8, !tbaa !9
  %62 = load double, ptr %14, align 8, !tbaa !9
  %63 = load double, ptr %15, align 8, !tbaa !9
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str.29, double noundef %62, double noundef %63)
  %65 = load double, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret double %65
}

; Function Attrs: nounwind uwtable
declare dso_local double @Function_sub(double noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local double @Func_derivative_sub(double noundef, double noundef, ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 #2 = { 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 #3 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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.29 = external hidden unnamed_addr constant [22 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local noundef double @Bisection_Method(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  br label %3

3:                                                ; preds = %2, %13
  %.032 = phi double [ -2.000000e+01, %2 ], [ %.1, %13 ]
  %.02831 = phi double [ 2.000000e+01, %2 ], [ %.129, %13 ]
  %4 = fadd double %.02831, %.032
  %5 = fmul double %4, 5.000000e-01
  %6 = tail call double @Func_derivative_sub(double noundef %5, double noundef 1.000000e-01, ptr noundef %0, ptr noundef %1)
  %7 = fcmp ogt double %6, 0.000000e+00
  br i1 %7, label %13, label %8

8:                                                ; preds = %3
  %9 = fcmp olt double %6, 0.000000e+00
  br i1 %9, label %13, label %10

10:                                               ; preds = %8
  %11 = fadd double %5, -1.000000e-01
  %12 = fadd double %5, 1.000000e-01
  br label %13

13:                                               ; preds = %8, %3, %10
  %.129 = phi double [ %12, %10 ], [ %5, %3 ], [ %.02831, %8 ]
  %.1 = phi double [ %11, %10 ], [ %.032, %3 ], [ %5, %8 ]
  %14 = fsub double %.129, %.1
  %15 = fcmp ogt double %14, 1.000000e-01
  br i1 %15, label %3, label %16, !llvm.loop !5

16:                                               ; preds = %13
  %17 = fadd double %.129, %.1
  %18 = fmul double %17, 5.000000e-01
  %19 = tail call double @Function_sub(double noundef %18, ptr noundef %0, ptr noundef %1)
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.29, double noundef %18, double noundef %19)
  ret double %18
}

; Function Attrs: nounwind uwtable
declare dso_local double @Function_sub(double noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local double @Func_derivative_sub(double noundef, double noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { 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" }
attributes #1 = { 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" }

!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: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass