; LLVM IR from rgolubtsov/nonlinear-optimization-algorithms-multilang :: nlp-unconstrained-cli/hooke-jeeves/cc/src (hooke)

; 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"

%"class.NLPUCCLIHooke::Rosenbrock" = type { i8 }

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN13NLPUCCLIHooke5Hooke10bestNearbyEPdS1_djPKv(ptr noundef nonnull align 1 dereferenceable(1) %0, ptr noundef %1, ptr noundef %2, double noundef %3, i32 noundef %4, ptr noundef %5) #0 align 2 personality ptr @__gxx_personality_v0 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca double, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca double, align 8
  %14 = alloca [250 x double], align 16
  %15 = alloca double, align 8
  %16 = alloca i32, align 4
  %17 = alloca %"class.NLPUCCLIHooke::Rosenbrock", align 1
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store double %3, ptr %10, align 8, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !11
  store ptr %5, ptr %12, align 8, !tbaa !5
  %20 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 2000, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %21 = load double, ptr %10, align 8, !tbaa !9
  store double %21, ptr %13, align 8, !tbaa !9
  store i32 0, ptr %16, align 4, !tbaa !11
  br label %22

22:                                               ; preds = %35, %6
  %23 = load i32, ptr %16, align 4, !tbaa !11
  %24 = load i32, ptr %11, align 4, !tbaa !11
  %25 = icmp ult i32 %23, %24
  br i1 %25, label %26, label %38

26:                                               ; preds = %22
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = load i32, ptr %16, align 4, !tbaa !11
  %29 = zext i32 %28 to i64
  %30 = getelementptr inbounds double, ptr %27, i64 %29
  %31 = load double, ptr %30, align 8, !tbaa !9
  %32 = load i32, ptr %16, align 4, !tbaa !11
  %33 = zext i32 %32 to i64
  %34 = getelementptr inbounds [250 x double], ptr %14, i64 0, i64 %33
  store double %31, ptr %34, align 8, !tbaa !9
  br label %35

35:                                               ; preds = %26
  %36 = load i32, ptr %16, align 4, !tbaa !11
  %37 = add i32 %36, 1
  store i32 %37, ptr %16, align 4, !tbaa !11
  br label %22, !llvm.loop !13

38:                                               ; preds = %22
  store i32 0, ptr %16, align 4, !tbaa !11
  br label %39

39:                                               ; preds = %118, %38
  %40 = load i32, ptr %16, align 4, !tbaa !11
  %41 = load i32, ptr %11, align 4, !tbaa !11
  %42 = icmp ult i32 %40, %41
  br i1 %42, label %43, label %121

43:                                               ; preds = %39
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = load i32, ptr %16, align 4, !tbaa !11
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds double, ptr %44, i64 %46
  %48 = load double, ptr %47, align 8, !tbaa !9
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = load i32, ptr %16, align 4, !tbaa !11
  %51 = zext i32 %50 to i64
  %52 = getelementptr inbounds double, ptr %49, i64 %51
  %53 = load double, ptr %52, align 8, !tbaa !9
  %54 = fadd double %48, %53
  %55 = load i32, ptr %16, align 4, !tbaa !11
  %56 = zext i32 %55 to i64
  %57 = getelementptr inbounds [250 x double], ptr %14, i64 0, i64 %56
  store double %54, ptr %57, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %17) #4
  call void @_ZN13NLPUCCLIHooke10RosenbrockC1Ev(ptr noundef nonnull align 1 dereferenceable(1) %17)
  %58 = getelementptr inbounds [250 x double], ptr %14, i64 0, i64 0
  %59 = load i32, ptr %11, align 4, !tbaa !11
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  %61 = invoke noundef double @_ZN13NLPUCCLIHooke10Rosenbrock1fEPKdjPKv(ptr noundef %58, i32 noundef %59, ptr noundef %60)
          to label %62 unwind label %68

62:                                               ; preds = %43
  store double %61, ptr %15, align 8, !tbaa !9
  %63 = load double, ptr %15, align 8, !tbaa !9
  %64 = load double, ptr %13, align 8, !tbaa !9
  %65 = fcmp olt double %63, %64
  br i1 %65, label %66, label %72

66:                                               ; preds = %62
  %67 = load double, ptr %15, align 8, !tbaa !9
  store double %67, ptr %13, align 8, !tbaa !9
  br label %117

68:                                               ; preds = %72, %43
  %69 = landingpad { ptr, i32 }
          cleanup
  %70 = extractvalue { ptr, i32 } %69, 0
  store ptr %70, ptr %18, align 8
  %71 = extractvalue { ptr, i32 } %69, 1
  store i32 %71, ptr %19, align 4
  call void @_ZN13NLPUCCLIHooke10RosenbrockD1Ev(ptr noundef nonnull align 1 dereferenceable(1) %17) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 2000, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %140

72:                                               ; preds = %62
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = load i32, ptr %16, align 4, !tbaa !11
  %75 = zext i32 %74 to i64
  %76 = getelementptr inbounds double, ptr %73, i64 %75
  %77 = load double, ptr %76, align 8, !tbaa !9
  %78 = fsub double 0.000000e+00, %77
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  %80 = load i32, ptr %16, align 4, !tbaa !11
  %81 = zext i32 %80 to i64
  %82 = getelementptr inbounds double, ptr %79, i64 %81
  store double %78, ptr %82, align 8, !tbaa !9
  %83 = load ptr, ptr %9, align 8, !tbaa !5
  %84 = load i32, ptr %16, align 4, !tbaa !11
  %85 = zext i32 %84 to i64
  %86 = getelementptr inbounds double, ptr %83, i64 %85
  %87 = load double, ptr %86, align 8, !tbaa !9
  %88 = load ptr, ptr %8, align 8, !tbaa !5
  %89 = load i32, ptr %16, align 4, !tbaa !11
  %90 = zext i32 %89 to i64
  %91 = getelementptr inbounds double, ptr %88, i64 %90
  %92 = load double, ptr %91, align 8, !tbaa !9
  %93 = fadd double %87, %92
  %94 = load i32, ptr %16, align 4, !tbaa !11
  %95 = zext i32 %94 to i64
  %96 = getelementptr inbounds [250 x double], ptr %14, i64 0, i64 %95
  store double %93, ptr %96, align 8, !tbaa !9
  %97 = getelementptr inbounds [250 x double], ptr %14, i64 0, i64 0
  %98 = load i32, ptr %11, align 4, !tbaa !11
  %99 = load ptr, ptr %12, align 8, !tbaa !5
  %100 = invoke noundef double @_ZN13NLPUCCLIHooke10Rosenbrock1fEPKdjPKv(ptr noundef %97, i32 noundef %98, ptr noundef %99)
          to label %101 unwind label %68

101:                                              ; preds = %72
  store double %100, ptr %15, align 8, !tbaa !9
  %102 = load double, ptr %15, align 8, !tbaa !9
  %103 = load double, ptr %13, align 8, !tbaa !9
  %104 = fcmp olt double %102, %103
  br i1 %104, label %105, label %107

105:                                              ; preds = %101
  %106 = load double, ptr %15, align 8, !tbaa !9
  store double %106, ptr %13, align 8, !tbaa !9
  br label %116

107:                                              ; preds = %101
  %108 = load ptr, ptr %9, align 8, !tbaa !5
  %109 = load i32, ptr %16, align 4, !tbaa !11
  %110 = zext i32 %109 to i64
  %111 = getelementptr inbounds double, ptr %108, i64 %110
  %112 = load double, ptr %111, align 8, !tbaa !9
  %113 = load i32, ptr %16, align 4, !tbaa !11
  %114 = zext i32 %113 to i64
  %115 = getelementptr inbounds [250 x double], ptr %14, i64 0, i64 %114
  store double %112, ptr %115, align 8, !tbaa !9
  br label %116

116:                                              ; preds = %107, %105
  br label %117

117:                                              ; preds = %116, %66
  call void @_ZN13NLPUCCLIHooke10RosenbrockD1Ev(ptr noundef nonnull align 1 dereferenceable(1) %17) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %17) #4
  br label %118

118:                                              ; preds = %117
  %119 = load i32, ptr %16, align 4, !tbaa !11
  %120 = add i32 %119, 1
  store i32 %120, ptr %16, align 4, !tbaa !11
  br label %39, !llvm.loop !15

121:                                              ; preds = %39
  store i32 0, ptr %16, align 4, !tbaa !11
  br label %122

122:                                              ; preds = %135, %121
  %123 = load i32, ptr %16, align 4, !tbaa !11
  %124 = load i32, ptr %11, align 4, !tbaa !11
  %125 = icmp ult i32 %123, %124
  br i1 %125, label %126, label %138

126:                                              ; preds = %122
  %127 = load i32, ptr %16, align 4, !tbaa !11
  %128 = zext i32 %127 to i64
  %129 = getelementptr inbounds [250 x double], ptr %14, i64 0, i64 %128
  %130 = load double, ptr %129, align 8, !tbaa !9
  %131 = load ptr, ptr %9, align 8, !tbaa !5
  %132 = load i32, ptr %16, align 4, !tbaa !11
  %133 = zext i32 %132 to i64
  %134 = getelementptr inbounds double, ptr %131, i64 %133
  store double %130, ptr %134, align 8, !tbaa !9
  br label %135

135:                                              ; preds = %126
  %136 = load i32, ptr %16, align 4, !tbaa !11
  %137 = add i32 %136, 1
  store i32 %137, ptr %16, align 4, !tbaa !11
  br label %122, !llvm.loop !16

138:                                              ; preds = %122
  %139 = load double, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 2000, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  ret double %139

140:                                              ; preds = %68
  %141 = load ptr, ptr %18, align 8
  %142 = load i32, ptr %19, align 4
  %143 = insertvalue { ptr, i32 } poison, ptr %141, 0
  %144 = insertvalue { ptr, i32 } %143, i32 %142, 1
  resume { ptr, i32 } %144
}

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

declare void @_ZN13NLPUCCLIHooke10RosenbrockC1Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2

declare noundef double @_ZN13NLPUCCLIHooke10Rosenbrock1fEPKdjPKv(ptr noundef, i32 noundef, ptr noundef) #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN13NLPUCCLIHooke10RosenbrockD1Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #3

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

attributes #0 = { mustprogress 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 "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; 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"

%"class.NLPUCCLIHooke::Rosenbrock" = type { i8 }

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN13NLPUCCLIHooke5Hooke10bestNearbyEPdS1_djPKv(ptr nocapture noundef nonnull readnone align 1 dereferenceable(1) %0, ptr nocapture noundef %1, ptr nocapture noundef %2, double noundef %3, i32 noundef %4, ptr noundef %5) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %7 = alloca [250 x double], align 16
  %8 = alloca %"class.NLPUCCLIHooke::Rosenbrock", align 1
  call void @llvm.lifetime.start.p0(i64 2000, ptr nonnull %7) #5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph56.preheader

.lr.ph56.preheader:                               ; preds = %6
  %9 = zext i32 %4 to i64
  %10 = shl nuw nsw i64 %9, 3
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %7, ptr align 8 %2, i64 %10, i1 false), !tbaa !5
  %wide.trip.count = zext i32 %4 to i64
  br label %.lr.ph56

.preheader:                                       ; preds = %34
  br i1 %.not, label %._crit_edge, label %.lr.ph58.preheader

.lr.ph58.preheader:                               ; preds = %.preheader
  %11 = zext i32 %4 to i64
  %12 = shl nuw nsw i64 %11, 3
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %2, ptr nonnull align 16 %7, i64 %12, i1 false), !tbaa !5
  br label %._crit_edge

.lr.ph56:                                         ; preds = %.lr.ph56.preheader, %34
  %indvars.iv = phi i64 [ 0, %.lr.ph56.preheader ], [ %indvars.iv.next, %34 ]
  %.055 = phi double [ %3, %.lr.ph56.preheader ], [ %.1, %34 ]
  %13 = getelementptr inbounds double, ptr %2, i64 %indvars.iv
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds double, ptr %1, i64 %indvars.iv
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = fadd double %14, %16
  %18 = getelementptr inbounds [250 x double], ptr %7, i64 0, i64 %indvars.iv
  store double %17, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %8) #5
  call void @_ZN13NLPUCCLIHooke10RosenbrockC1Ev(ptr noundef nonnull align 1 dereferenceable(1) %8)
  %19 = invoke noundef double @_ZN13NLPUCCLIHooke10Rosenbrock1fEPKdjPKv(ptr noundef nonnull %7, i32 noundef %4, ptr noundef %5)
          to label %20 unwind label %22

20:                                               ; preds = %.lr.ph56
  %21 = fcmp olt double %19, %.055
  br i1 %21, label %34, label %24

22:                                               ; preds = %24, %.lr.ph56
  %23 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN13NLPUCCLIHooke10RosenbrockD1Ev(ptr noundef nonnull align 1 dereferenceable(1) %8) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 2000, ptr nonnull %7) #5
  resume { ptr, i32 } %23

24:                                               ; preds = %20
  %25 = load double, ptr %15, align 8, !tbaa !5
  %26 = fsub double 0.000000e+00, %25
  store double %26, ptr %15, align 8, !tbaa !5
  %27 = load double, ptr %13, align 8, !tbaa !5
  %28 = fadd double %26, %27
  store double %28, ptr %18, align 8, !tbaa !5
  %29 = invoke noundef double @_ZN13NLPUCCLIHooke10Rosenbrock1fEPKdjPKv(ptr noundef nonnull %7, i32 noundef %4, ptr noundef %5)
          to label %30 unwind label %22

30:                                               ; preds = %24
  %31 = fcmp olt double %29, %.055
  br i1 %31, label %34, label %32

32:                                               ; preds = %30
  %33 = load double, ptr %13, align 8, !tbaa !5
  store double %33, ptr %18, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %30, %20, %32
  %.1 = phi double [ %.055, %32 ], [ %19, %20 ], [ %29, %30 ]
  call void @_ZN13NLPUCCLIHooke10RosenbrockD1Ev(ptr noundef nonnull align 1 dereferenceable(1) %8) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %8) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader, label %.lr.ph56, !llvm.loop !9

._crit_edge:                                      ; preds = %6, %.lr.ph58.preheader, %.preheader
  %.0.lcssa67 = phi double [ %.1, %.lr.ph58.preheader ], [ %.1, %.preheader ], [ %3, %6 ]
  call void @llvm.lifetime.end.p0(i64 2000, ptr nonnull %7) #5
  ret double %.0.lcssa67
}

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

declare void @_ZN13NLPUCCLIHooke10RosenbrockC1Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2

declare noundef double @_ZN13NLPUCCLIHooke10Rosenbrock1fEPKdjPKv(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN13NLPUCCLIHooke10RosenbrockD1Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #3

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

attributes #0 = { mustprogress 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 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 "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass