; LLVM IR from ByungKwanLee/Adavanced-ECMS :: advanced_ecms/src/interp_tool.ll (ZN11interp_Tool14interpolate_1dERSt6vectorIfSaIfEES3_fb)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef float @_ZN11interp_Tool14interpolate_1dERSt6vectorIfSaIfEES3_fb(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, float noundef %2, i1 noundef zeroext %3) #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store float %2, ptr %7, align 4, !tbaa !9
  %16 = zext i1 %3 to i8
  store i8 %16, ptr %8, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = call noundef i64 @_ZNKSt6vectorIfSaIfEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %17) #3
  %19 = trunc i64 %18 to i32
  store i32 %19, ptr %9, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !13
  %20 = load float, ptr %7, align 4, !tbaa !9
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = load i32, ptr %9, align 4, !tbaa !13
  %23 = sub nsw i32 %22, 2
  %24 = sext i32 %23 to i64
  %25 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef %24) #3
  %26 = load float, ptr %25, align 4, !tbaa !9
  %27 = fcmp oge float %20, %26
  br i1 %27, label %28, label %31

28:                                               ; preds = %4
  %29 = load i32, ptr %9, align 4, !tbaa !13
  %30 = sub nsw i32 %29, 2
  store i32 %30, ptr %10, align 4, !tbaa !13
  br label %45

31:                                               ; preds = %4
  br label %32

32:                                               ; preds = %41, %31
  %33 = load float, ptr %7, align 4, !tbaa !9
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load i32, ptr %10, align 4, !tbaa !13
  %36 = add nsw i32 %35, 1
  %37 = sext i32 %36 to i64
  %38 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %34, i64 noundef %37) #3
  %39 = load float, ptr %38, align 4, !tbaa !9
  %40 = fcmp ogt float %33, %39
  br i1 %40, label %41, label %44

41:                                               ; preds = %32
  %42 = load i32, ptr %10, align 4, !tbaa !13
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %10, align 4, !tbaa !13
  br label %32, !llvm.loop !15

44:                                               ; preds = %32
  br label %45

45:                                               ; preds = %44, %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = load i32, ptr %10, align 4, !tbaa !13
  %48 = sext i32 %47 to i64
  %49 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %46, i64 noundef %48) #3
  %50 = load float, ptr %49, align 4, !tbaa !9
  store float %50, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = load i32, ptr %10, align 4, !tbaa !13
  %53 = sext i32 %52 to i64
  %54 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %51, i64 noundef %53) #3
  %55 = load float, ptr %54, align 4, !tbaa !9
  store float %55, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = load i32, ptr %10, align 4, !tbaa !13
  %58 = add nsw i32 %57, 1
  %59 = sext i32 %58 to i64
  %60 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %56, i64 noundef %59) #3
  %61 = load float, ptr %60, align 4, !tbaa !9
  store float %61, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = load i32, ptr %10, align 4, !tbaa !13
  %64 = add nsw i32 %63, 1
  %65 = sext i32 %64 to i64
  %66 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %62, i64 noundef %65) #3
  %67 = load float, ptr %66, align 4, !tbaa !9
  store float %67, ptr %14, align 4, !tbaa !9
  %68 = load i8, ptr %8, align 1, !tbaa !11, !range !17, !noundef !18
  %69 = trunc i8 %68 to i1
  br i1 %69, label %83, label %70

70:                                               ; preds = %45
  %71 = load float, ptr %7, align 4, !tbaa !9
  %72 = load float, ptr %11, align 4, !tbaa !9
  %73 = fcmp olt float %71, %72
  br i1 %73, label %74, label %76

74:                                               ; preds = %70
  %75 = load float, ptr %12, align 4, !tbaa !9
  store float %75, ptr %14, align 4, !tbaa !9
  br label %76

76:                                               ; preds = %74, %70
  %77 = load float, ptr %7, align 4, !tbaa !9
  %78 = load float, ptr %13, align 4, !tbaa !9
  %79 = fcmp ogt float %77, %78
  br i1 %79, label %80, label %82

80:                                               ; preds = %76
  %81 = load float, ptr %14, align 4, !tbaa !9
  store float %81, ptr %12, align 4, !tbaa !9
  br label %82

82:                                               ; preds = %80, %76
  br label %83

83:                                               ; preds = %82, %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %84 = load float, ptr %14, align 4, !tbaa !9
  %85 = load float, ptr %12, align 4, !tbaa !9
  %86 = fsub float %84, %85
  %87 = load float, ptr %13, align 4, !tbaa !9
  %88 = load float, ptr %11, align 4, !tbaa !9
  %89 = fsub float %87, %88
  %90 = fdiv float %86, %89
  store float %90, ptr %15, align 4, !tbaa !9
  %91 = load float, ptr %12, align 4, !tbaa !9
  %92 = load float, ptr %15, align 4, !tbaa !9
  %93 = load float, ptr %7, align 4, !tbaa !9
  %94 = load float, ptr %11, align 4, !tbaa !9
  %95 = fsub float %93, %94
  %96 = call float @llvm.fmuladd.f32(float %92, float %95, float %91)
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret float %96
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIfSaIfEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

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

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

attributes #0 = { mustprogress 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 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{i8 0, i8 2}
!18 = !{}


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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef float @_ZN11interp_Tool14interpolate_1dERSt6vectorIfSaIfEES3_fb(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1, float noundef %2, i1 noundef zeroext %3) local_unnamed_addr #0 align 2 {
  %5 = tail call noundef i64 @_ZNKSt6vectorIfSaIfEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %6 = trunc i64 %5 to i32
  %7 = add nsw i32 %6, -2
  %8 = sext i32 %7 to i64
  %9 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %8) #2
  %10 = load float, ptr %9, align 4, !tbaa !5
  %11 = fcmp ugt float %10, %2
  br i1 %11, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %4, %.preheader
  %indvars.iv = phi i64 [ %indvars.iv.next, %.preheader ], [ 0, %4 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %12 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv.next) #2
  %13 = load float, ptr %12, align 4, !tbaa !5
  %14 = fcmp olt float %13, %2
  br i1 %14, label %.preheader, label %.loopexit.loopexit, !llvm.loop !9

.loopexit.loopexit:                               ; preds = %.preheader
  %15 = trunc nuw nsw i64 %indvars.iv to i32
  %sext = shl i64 %indvars.iv, 32
  %.pre = ashr exact i64 %sext, 32
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %4
  %.pre-phi = phi i64 [ %.pre, %.loopexit.loopexit ], [ %8, %4 ]
  %.1 = phi i32 [ %15, %.loopexit.loopexit ], [ %7, %4 ]
  %16 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.pre-phi) #2
  %17 = load float, ptr %16, align 4, !tbaa !5
  %18 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %.pre-phi) #2
  %19 = load float, ptr %18, align 4, !tbaa !5
  %20 = add nsw i32 %.1, 1
  %21 = sext i32 %20 to i64
  %22 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %21) #2
  %23 = load float, ptr %22, align 4, !tbaa !5
  %24 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %21) #2
  %25 = load float, ptr %24, align 4, !tbaa !5
  br i1 %3, label %30, label %26

26:                                               ; preds = %.loopexit
  %27 = fcmp ogt float %17, %2
  %.031 = select i1 %27, float %19, float %25
  %28 = fcmp olt float %23, %2
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  br label %30

30:                                               ; preds = %26, %29, %.loopexit
  %.033 = phi float [ %19, %.loopexit ], [ %.031, %29 ], [ %19, %26 ]
  %.132 = phi float [ %25, %.loopexit ], [ %.031, %29 ], [ %.031, %26 ]
  %31 = fsub float %.132, %.033
  %32 = fsub float %23, %17
  %33 = fdiv float %31, %32
  %34 = fsub float %2, %17
  %35 = tail call float @llvm.fmuladd.f32(float %33, float %34, float %.033)
  ret float %35
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIfSaIfEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIfSaIfEEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

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

attributes #0 = { mustprogress 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 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass