; LLVM IR from Amoiensis/Optimization-Algorithm :: [LineSearchMethod]一维搜索法/[Bisection Method]二分法 (Bisection_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
  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) #3
  store double 0.000000e+00, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store double 6.000000e+00, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store double 1.000000e-03, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  store double 1.000000e-03, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store ptr @Function, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %16 = load double, ptr %6, align 8, !tbaa !11
  store double %16, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %17 = load double, ptr %7, align 8, !tbaa !11
  store double %17, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  br label %18

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

24:                                               ; preds = %18
  %25 = load double, ptr %12, align 8, !tbaa !11
  %26 = load double, ptr %11, align 8, !tbaa !11
  %27 = fadd double %25, %26
  %28 = fdiv double %27, 2.000000e+00
  store double %28, ptr %13, align 8, !tbaa !11
  %29 = load double, ptr %13, align 8, !tbaa !11
  %30 = load double, ptr %9, align 8, !tbaa !11
  %31 = call double @Func_derivative(double noundef %29, double noundef %30)
  %32 = fcmp ogt double %31, 0.000000e+00
  br i1 %32, label %33, label %35

33:                                               ; preds = %24
  %34 = load double, ptr %13, align 8, !tbaa !11
  store double %34, ptr %12, align 8, !tbaa !11
  br label %50

35:                                               ; preds = %24
  %36 = load double, ptr %13, align 8, !tbaa !11
  %37 = load double, ptr %9, align 8, !tbaa !11
  %38 = call double @Func_derivative(double noundef %36, double noundef %37)
  %39 = fcmp olt double %38, 0.000000e+00
  br i1 %39, label %40, label %42

40:                                               ; preds = %35
  %41 = load double, ptr %13, align 8, !tbaa !11
  store double %41, ptr %11, align 8, !tbaa !11
  br label %49

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

49:                                               ; preds = %42, %40
  br label %50

50:                                               ; preds = %49, %33
  br label %18, !llvm.loop !13

51:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %52 = load double, ptr %12, align 8, !tbaa !11
  %53 = load double, ptr %11, align 8, !tbaa !11
  %54 = fadd double %52, %53
  %55 = fdiv double %54, 2.000000e+00
  store double %55, ptr %14, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %56 = load ptr, ptr %10, align 8, !tbaa !9
  %57 = load double, ptr %14, align 8, !tbaa !11
  %58 = call double %56(double noundef %57)
  store double %58, ptr %15, align 8, !tbaa !11
  %59 = load double, ptr %14, align 8, !tbaa !11
  %60 = load double, ptr %15, align 8, !tbaa !11
  %61 = call i32 (ptr, ...) @printf(ptr noundef @.str, double noundef %59, double noundef %60)
  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 %13) #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
  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: nounwind uwtable
declare dso_local double @Func_derivative(double noundef, double noundef) #0

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

; 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 = { "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 = !{!"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 {
  br label %3

3:                                                ; preds = %2, %14
  %.026 = phi double [ 0.000000e+00, %2 ], [ %.1, %14 ]
  %.02325 = phi double [ 6.000000e+00, %2 ], [ %.124, %14 ]
  %4 = fadd double %.02325, %.026
  %5 = fmul double %4, 5.000000e-01
  %6 = tail call double @Func_derivative(double noundef %5, double noundef 1.000000e-03)
  %7 = fcmp ogt double %6, 0.000000e+00
  br i1 %7, label %14, label %8

8:                                                ; preds = %3
  %9 = tail call double @Func_derivative(double noundef %5, double noundef 1.000000e-03)
  %10 = fcmp olt double %9, 0.000000e+00
  br i1 %10, label %14, label %11

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

14:                                               ; preds = %8, %3, %11
  %.124 = phi double [ %13, %11 ], [ %5, %3 ], [ %.02325, %8 ]
  %.1 = phi double [ %12, %11 ], [ %.026, %3 ], [ %5, %8 ]
  %15 = fsub double %.124, %.1
  %16 = fcmp ogt double %15, 1.000000e-03
  br i1 %16, label %3, label %17, !llvm.loop !5

17:                                               ; preds = %14
  %18 = fadd double %.124, %.1
  %19 = fmul double %18, 5.000000e-01
  %20 = tail call double @Function(double noundef %19)
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %19, double noundef %20)
  ret i32 0
}

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { 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: GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass