; LLVM IR from LiJiangnanBit/path_optimizer :: src/tools/spline.ll (ZN18PathOptimizationNS2tk11band_matrixclEii)

; 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.PathOptimizationNS::tk::band_matrix" = type { %"class.std::vector", %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::vector<double>, std::allocator<std::vector<double>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::vector<double>, std::allocator<std::vector<double>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::vector<double>, std::allocator<std::vector<double>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::vector<double>, std::allocator<std::vector<double>>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str.1 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [51 x i8], align 1
@__PRETTY_FUNCTION__._ZN18PathOptimizationNS2tk11band_matrixclEii = external hidden unnamed_addr constant [66 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; 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 nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IdSaIdEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK18PathOptimizationNS2tk11band_matrix3dimEv(ptr noundef nonnull align 8 dereferenceable(48)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN18PathOptimizationNS2tk11band_matrixclEii(ptr noundef nonnull align 8 dereferenceable(48) %0, i32 noundef %1, i32 noundef %2) #3 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  %10 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %11 = load i32, ptr %7, align 4, !tbaa !9
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = sub nsw i32 %11, %12
  store i32 %13, ptr %8, align 4, !tbaa !9
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = icmp sge i32 %14, 0
  br i1 %15, label %16, label %27

16:                                               ; preds = %3
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = call noundef i32 @_ZNK18PathOptimizationNS2tk11band_matrix3dimEv(ptr noundef nonnull align 8 dereferenceable(48) %10)
  %19 = icmp slt i32 %17, %18
  br i1 %19, label %20, label %27

20:                                               ; preds = %16
  %21 = load i32, ptr %7, align 4, !tbaa !9
  %22 = icmp sge i32 %21, 0
  br i1 %22, label %23, label %27

23:                                               ; preds = %20
  %24 = load i32, ptr %7, align 4, !tbaa !9
  %25 = call noundef i32 @_ZNK18PathOptimizationNS2tk11band_matrix3dimEv(ptr noundef nonnull align 8 dereferenceable(48) %10)
  %26 = icmp slt i32 %24, %25
  br label %27

27:                                               ; preds = %23, %20, %16, %3
  %28 = phi i1 [ false, %20 ], [ false, %16 ], [ false, %3 ], [ %26, %23 ]
  br i1 %28, label %29, label %30

29:                                               ; preds = %27
  br label %32

30:                                               ; preds = %27
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 45, ptr noundef @__PRETTY_FUNCTION__._ZN18PathOptimizationNS2tk11band_matrixclEii) #5
  unreachable

31:                                               ; No predecessors!
  br label %32

32:                                               ; preds = %31, %29
  %33 = call noundef i32 @_ZNK18PathOptimizationNS2tk11band_matrix9num_lowerEv(ptr noundef nonnull align 8 dereferenceable(48) %10)
  %34 = sub nsw i32 0, %33
  %35 = load i32, ptr %8, align 4, !tbaa !9
  %36 = icmp sle i32 %34, %35
  br i1 %36, label %37, label %41

37:                                               ; preds = %32
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = call noundef i32 @_ZNK18PathOptimizationNS2tk11band_matrix9num_upperEv(ptr noundef nonnull align 8 dereferenceable(48) %10)
  %40 = icmp sle i32 %38, %39
  br label %41

41:                                               ; preds = %37, %32
  %42 = phi i1 [ false, %32 ], [ %40, %37 ]
  br i1 %42, label %43, label %44

43:                                               ; preds = %41
  br label %46

44:                                               ; preds = %41
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 46, ptr noundef @__PRETTY_FUNCTION__._ZN18PathOptimizationNS2tk11band_matrixclEii) #5
  unreachable

45:                                               ; No predecessors!
  br label %46

46:                                               ; preds = %45, %43
  %47 = load i32, ptr %8, align 4, !tbaa !9
  %48 = icmp sge i32 %47, 0
  br i1 %48, label %49, label %57

49:                                               ; preds = %46
  %50 = getelementptr inbounds %"class.PathOptimizationNS::tk::band_matrix", ptr %10, i32 0, i32 0
  %51 = load i32, ptr %8, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IdSaIdEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %50, i64 noundef %52) #4
  %54 = load i32, ptr %6, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %53, i64 noundef %55) #4
  store ptr %56, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %66

57:                                               ; preds = %46
  %58 = getelementptr inbounds %"class.PathOptimizationNS::tk::band_matrix", ptr %10, i32 0, i32 1
  %59 = load i32, ptr %8, align 4, !tbaa !9
  %60 = sub nsw i32 0, %59
  %61 = sext i32 %60 to i64
  %62 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IdSaIdEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %58, i64 noundef %61) #4
  %63 = load i32, ptr %6, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %62, i64 noundef %64) #4
  store ptr %65, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %66

66:                                               ; preds = %57, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %67 = load ptr, ptr %4, align 8
  ret ptr %67
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK18PathOptimizationNS2tk11band_matrix9num_lowerEv(ptr noundef nonnull align 8 dereferenceable(48)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK18PathOptimizationNS2tk11band_matrix9num_upperEv(ptr noundef nonnull align 8 dereferenceable(48)) #2 align 2

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

attributes #0 = { noreturn 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { nounwind }
attributes #5 = { noreturn 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 = !{!"int", !7, i64 0}


; 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.1 = external hidden unnamed_addr constant [83 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [51 x i8], align 1
@__PRETTY_FUNCTION__._ZN18PathOptimizationNS2tk11band_matrixclEii = external hidden unnamed_addr constant [66 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK18PathOptimizationNS2tk11band_matrix3dimEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN18PathOptimizationNS2tk11band_matrixclEii(ptr noundef nonnull align 8 dereferenceable(48) %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 align 2 {
  %4 = sub nsw i32 %2, %1
  %5 = icmp sgt i32 %1, -1
  br i1 %5, label %6, label %.critedge

6:                                                ; preds = %3
  %7 = tail call noundef i32 @_ZNK18PathOptimizationNS2tk11band_matrix3dimEv(ptr noundef nonnull align 8 dereferenceable(48) %0)
  %8 = icmp sgt i32 %7, %1
  %9 = icmp sgt i32 %2, -1
  %or.cond = and i1 %9, %8
  br i1 %or.cond, label %10, label %.critedge

10:                                               ; preds = %6
  %11 = tail call noundef i32 @_ZNK18PathOptimizationNS2tk11band_matrix3dimEv(ptr noundef nonnull align 8 dereferenceable(48) %0)
  %12 = icmp sgt i32 %11, %2
  br i1 %12, label %13, label %.critedge

.critedge:                                        ; preds = %6, %3, %10
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 45, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN18PathOptimizationNS2tk11band_matrixclEii) #3
  unreachable

13:                                               ; preds = %10
  %14 = tail call noundef i32 @_ZNK18PathOptimizationNS2tk11band_matrix9num_lowerEv(ptr noundef nonnull align 8 dereferenceable(48) %0)
  %15 = sub nsw i32 0, %14
  %.not = icmp slt i32 %4, %15
  br i1 %.not, label %.critedge3, label %16

16:                                               ; preds = %13
  %17 = tail call noundef i32 @_ZNK18PathOptimizationNS2tk11band_matrix9num_upperEv(ptr noundef nonnull align 8 dereferenceable(48) %0)
  %.not20 = icmp sgt i32 %4, %17
  br i1 %.not20, label %.critedge3, label %18

.critedge3:                                       ; preds = %13, %16
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 46, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN18PathOptimizationNS2tk11band_matrixclEii) #3
  unreachable

18:                                               ; preds = %16
  %.sink = tail call i32 @llvm.abs.i32(i32 %4, i1 true)
  %19 = icmp slt i32 %4, 0
  %.sink22.idx = select i1 %19, i64 24, i64 0
  %.sink22 = getelementptr inbounds i8, ptr %0, i64 %.sink22.idx
  %20 = zext nneg i32 %.sink to i64
  %21 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IdSaIdEESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %.sink22, i64 noundef %20) #4
  %22 = zext nneg i32 %1 to i64
  %23 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %21, i64 noundef %22) #4
  ret ptr %23
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK18PathOptimizationNS2tk11band_matrix9num_lowerEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK18PathOptimizationNS2tk11band_matrix9num_upperEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1 align 2

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #2

attributes #0 = { noreturn 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 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { noreturn nounwind }
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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass