; LLVM IR from cdalvaro/computational-physics :: computational-physics/main.ll (Z4pickiiiid)

; 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.cda::math::containers::Matrix" = type { i64, i64, i64, ptr, ptr }

@cI = external dso_local global %"class.cda::math::containers::Matrix", align 8

; 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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3cda4math10containers6MatrixIdED2Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #1 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3cda4math10containers6MatrixIdE4zeroERKmS5_(ptr dead_on_unwind noalias writable sret(%"class.cda::math::containers::Matrix") align 8, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4pickiiiid(ptr dead_on_unwind noalias writable sret(%"class.cda::math::containers::Matrix") align 8 %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, double noundef %5) #2 personality ptr @__gxx_personality_v0 {
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca double, align 8
  %13 = alloca i1, align 1
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca i64, align 8
  store ptr %0, ptr %7, align 8
  store i32 %1, ptr %8, align 4, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !5
  store double %5, ptr %12, align 8, !tbaa !9
  store i1 false, ptr %13, align 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %22 = call noundef i64 @_ZNK3cda4math10containers6MatrixIdE4rowsEv(ptr noundef nonnull align 8 dereferenceable(40) @cI)
  store i64 %22, ptr %14, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %23 = call noundef i64 @_ZNK3cda4math10containers6MatrixIdE7columnsEv(ptr noundef nonnull align 8 dereferenceable(40) @cI)
  store i64 %23, ptr %15, align 8, !tbaa !11
  call void @_ZN3cda4math10containers6MatrixIdE4zeroERKmS5_(ptr dead_on_unwind writable sret(%"class.cda::math::containers::Matrix") align 8 %0, ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull align 8 dereferenceable(8) %15)
  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.start.p0(i64 4, ptr %16) #3
  %24 = load i32, ptr %9, align 4, !tbaa !5
  %25 = load i32, ptr %11, align 4, !tbaa !5
  %26 = sub nsw i32 %24, %25
  store i32 %26, ptr %16, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %86, %6
  %28 = load i32, ptr %16, align 4, !tbaa !5
  %29 = load i32, ptr %9, align 4, !tbaa !5
  %30 = load i32, ptr %11, align 4, !tbaa !5
  %31 = add nsw i32 %29, %30
  %32 = icmp sle i32 %28, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %27
  store i32 2, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %89

34:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %35 = load i32, ptr %8, align 4, !tbaa !5
  %36 = load i32, ptr %10, align 4, !tbaa !5
  %37 = sub nsw i32 %35, %36
  store i32 %37, ptr %18, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %81, %34
  %39 = load i32, ptr %18, align 4, !tbaa !5
  %40 = load i32, ptr %8, align 4, !tbaa !5
  %41 = load i32, ptr %10, align 4, !tbaa !5
  %42 = add nsw i32 %40, %41
  %43 = icmp sle i32 %39, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %38
  store i32 5, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  br label %85

45:                                               ; preds = %38
  %46 = load i32, ptr %16, align 4, !tbaa !5
  %47 = icmp sge i32 %46, 0
  br i1 %47, label %48, label %80

48:                                               ; preds = %45
  %49 = load i32, ptr %16, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = invoke noundef i64 @_ZNK3cda4math10containers6MatrixIdE4rowsEv(ptr noundef nonnull align 8 dereferenceable(40) @cI)
          to label %52 unwind label %72

52:                                               ; preds = %48
  %53 = icmp ult i64 %50, %51
  br i1 %53, label %54, label %80

54:                                               ; preds = %52
  %55 = load i32, ptr %18, align 4, !tbaa !5
  %56 = icmp sge i32 %55, 0
  br i1 %56, label %57, label %80

57:                                               ; preds = %54
  %58 = load i32, ptr %18, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = invoke noundef i64 @_ZNK3cda4math10containers6MatrixIdE7columnsEv(ptr noundef nonnull align 8 dereferenceable(40) @cI)
          to label %61 unwind label %72

61:                                               ; preds = %57
  %62 = icmp ult i64 %59, %60
  br i1 %62, label %63, label %80

63:                                               ; preds = %61
  %64 = load double, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #3
  %65 = load i32, ptr %16, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  store i64 %66, ptr %21, align 8, !tbaa !11
  %67 = invoke noundef ptr @_ZN3cda4math10containers6MatrixIdEixERKm(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 8 dereferenceable(8) %21)
          to label %68 unwind label %76

68:                                               ; preds = %63
  %69 = load i32, ptr %18, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds double, ptr %67, i64 %70
  store double %64, ptr %71, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  br label %80

72:                                               ; preds = %57, %48
  %73 = landingpad { ptr, i32 }
          cleanup
  %74 = extractvalue { ptr, i32 } %73, 0
  store ptr %74, ptr %19, align 8
  %75 = extractvalue { ptr, i32 } %73, 1
  store i32 %75, ptr %20, align 4
  br label %84

76:                                               ; preds = %63
  %77 = landingpad { ptr, i32 }
          cleanup
  %78 = extractvalue { ptr, i32 } %77, 0
  store ptr %78, ptr %19, align 8
  %79 = extractvalue { ptr, i32 } %77, 1
  store i32 %79, ptr %20, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  br label %84

80:                                               ; preds = %68, %61, %54, %52, %45
  br label %81

81:                                               ; preds = %80
  %82 = load i32, ptr %18, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %18, align 4, !tbaa !5
  br label %38, !llvm.loop !13

84:                                               ; preds = %76, %72
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @_ZN3cda4math10containers6MatrixIdED2Ev(ptr noundef nonnull align 8 dereferenceable(40) %0) #3
  br label %93

85:                                               ; preds = %44
  br label %86

86:                                               ; preds = %85
  %87 = load i32, ptr %16, align 4, !tbaa !5
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %16, align 4, !tbaa !5
  br label %27, !llvm.loop !15

89:                                               ; preds = %33
  store i1 true, ptr %13, align 1
  store i32 1, ptr %17, align 4
  %90 = load i1, ptr %13, align 1
  br i1 %90, label %92, label %91

91:                                               ; preds = %89
  call void @_ZN3cda4math10containers6MatrixIdED2Ev(ptr noundef nonnull align 8 dereferenceable(40) %0) #3
  br label %92

92:                                               ; preds = %91, %89
  ret void

93:                                               ; preds = %84
  %94 = load ptr, ptr %19, align 8
  %95 = load i32, ptr %20, align 4
  %96 = insertvalue { ptr, i32 } poison, ptr %94, 0
  %97 = insertvalue { ptr, i32 } %96, i32 %95, 1
  resume { ptr, i32 } %97
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN3cda4math10containers6MatrixIdEixERKm(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK3cda4math10containers6MatrixIdE4rowsEv(ptr noundef nonnull align 8 dereferenceable(40)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK3cda4math10containers6MatrixIdE7columnsEv(ptr noundef nonnull align 8 dereferenceable(40)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !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.cda::math::containers::Matrix" = type { i64, i64, i64, ptr, ptr }

@cI = external dso_local global %"class.cda::math::containers::Matrix", align 8

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3cda4math10containers6MatrixIdE4zeroERKmS5_(ptr dead_on_unwind noalias writable sret(%"class.cda::math::containers::Matrix") align 8, ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4pickiiiid(ptr dead_on_unwind noalias writable sret(%"class.cda::math::containers::Matrix") align 8 %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, double noundef %5) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #3
  %10 = tail call noundef i64 @_ZNK3cda4math10containers6MatrixIdE4rowsEv(ptr noundef nonnull align 8 dereferenceable(40) @cI)
  store i64 %10, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #3
  %11 = tail call noundef i64 @_ZNK3cda4math10containers6MatrixIdE7columnsEv(ptr noundef nonnull align 8 dereferenceable(40) @cI)
  store i64 %11, ptr %8, align 8, !tbaa !5
  call void @_ZN3cda4math10containers6MatrixIdE4zeroERKmS5_(ptr dead_on_unwind writable sret(%"class.cda::math::containers::Matrix") align 8 %0, ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %8)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #3
  %12 = sub nsw i32 %2, %4
  %13 = add i32 %4, %2
  %.not26 = icmp sgt i32 %12, %13
  br i1 %.not26, label %._crit_edge30, label %.lr.ph29

.lr.ph29:                                         ; preds = %6
  %14 = sub nsw i32 %1, %3
  %15 = add i32 %3, %1
  %.not2324 = icmp sgt i32 %14, %15
  br i1 %.not2324, label %._crit_edge30, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph29, %._crit_edge
  %.02027 = phi i32 [ %30, %._crit_edge ], [ %12, %.lr.ph29 ]
  %16 = icmp sgt i32 %.02027, -1
  %17 = zext nneg i32 %.02027 to i64
  br i1 %16, label %.lr.ph.split.us, label %._crit_edge

.lr.ph.split.us:                                  ; preds = %.lr.ph, %28
  %.025.us = phi i32 [ %29, %28 ], [ %14, %.lr.ph ]
  %18 = call noundef i64 @_ZNK3cda4math10containers6MatrixIdE4rowsEv(ptr noundef nonnull align 8 dereferenceable(40) @cI)
  %19 = icmp ugt i64 %18, %17
  %20 = icmp sgt i32 %.025.us, -1
  %or.cond.us = and i1 %20, %19
  br i1 %or.cond.us, label %21, label %28

21:                                               ; preds = %.lr.ph.split.us
  %22 = zext nneg i32 %.025.us to i64
  %23 = call noundef i64 @_ZNK3cda4math10containers6MatrixIdE7columnsEv(ptr noundef nonnull align 8 dereferenceable(40) @cI)
  %24 = icmp ugt i64 %23, %22
  br i1 %24, label %25, label %28

25:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #3
  store i64 %17, ptr %9, align 8, !tbaa !5
  %26 = call noundef ptr @_ZN3cda4math10containers6MatrixIdEixERKm(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef nonnull align 8 dereferenceable(8) %9)
  %27 = getelementptr inbounds double, ptr %26, i64 %22
  store double %5, ptr %27, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #3
  br label %28

28:                                               ; preds = %25, %21, %.lr.ph.split.us
  %29 = add i32 %.025.us, 1
  %exitcond.not = icmp eq i32 %.025.us, %15
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !11

._crit_edge:                                      ; preds = %28, %.lr.ph
  %30 = add i32 %.02027, 1
  %exitcond33.not = icmp eq i32 %.02027, %13
  br i1 %exitcond33.not, label %._crit_edge30, label %.lr.ph, !llvm.loop !13

._crit_edge30:                                    ; preds = %._crit_edge, %.lr.ph29, %6
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN3cda4math10containers6MatrixIdEixERKm(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2 align 2

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

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

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass