; LLVM IR from sympiler/nasoq :: src/QP/osqp_utils.ll (ZN5nasoq26mat_inf_norm_cols_sym_triuEPKNS_12sympiler_CSCEPd)

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

%"struct.nasoq::sympiler_CSC" = type { i64, i64, i64, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32 }

; 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 uwtable
define dso_local void @_ZN5nasoq26mat_inf_norm_cols_sym_triuEPKNS_12sympiler_CSCEPd(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %21, %2
  %10 = load i32, ptr %6, align 4, !tbaa !9
  %11 = sext i32 %10 to i64
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %"struct.nasoq::sympiler_CSC", ptr %12, i32 0, i32 1
  %14 = load i64, ptr %13, align 8, !tbaa !11
  %15 = icmp ult i64 %11, %14
  br i1 %15, label %16, label %24

16:                                               ; preds = %9
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = load i32, ptr %6, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds double, ptr %17, i64 %19
  store double 0.000000e+00, ptr %20, align 8, !tbaa !14
  br label %21

21:                                               ; preds = %16
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %6, align 4, !tbaa !9
  br label %9, !llvm.loop !16

24:                                               ; preds = %9
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %96, %24
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.nasoq::sympiler_CSC", ptr %28, i32 0, i32 1
  %30 = load i64, ptr %29, align 8, !tbaa !11
  %31 = icmp ult i64 %27, %30
  br i1 %31, label %32, label %99

32:                                               ; preds = %25
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %"struct.nasoq::sympiler_CSC", ptr %33, i32 0, i32 3
  %35 = load ptr, ptr %34, align 8, !tbaa !18
  %36 = load i32, ptr %6, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds i32, ptr %35, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !9
  store i32 %39, ptr %7, align 4, !tbaa !9
  br label %40

40:                                               ; preds = %92, %32
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.nasoq::sympiler_CSC", ptr %42, i32 0, i32 3
  %44 = load ptr, ptr %43, align 8, !tbaa !18
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = add nsw i32 %45, 1
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds i32, ptr %44, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !9
  %50 = icmp slt i32 %41, %49
  br i1 %50, label %51, label %95

51:                                               ; preds = %40
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %"struct.nasoq::sympiler_CSC", ptr %52, i32 0, i32 4
  %54 = load ptr, ptr %53, align 8, !tbaa !19
  %55 = load i32, ptr %7, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i32, ptr %54, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !9
  store i32 %58, ptr %5, align 4, !tbaa !9
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.nasoq::sympiler_CSC", ptr %59, i32 0, i32 6
  %61 = load ptr, ptr %60, align 8, !tbaa !20
  %62 = load i32, ptr %7, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds double, ptr %61, i64 %63
  %65 = load double, ptr %64, align 8, !tbaa !14
  %66 = call noundef double @_ZSt3absd(double noundef %65)
  store double %66, ptr %8, align 8, !tbaa !14
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = load i32, ptr %6, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds double, ptr %67, i64 %69
  %71 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %70)
  %72 = load double, ptr %71, align 8, !tbaa !14
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = load i32, ptr %6, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds double, ptr %73, i64 %75
  store double %72, ptr %76, align 8, !tbaa !14
  %77 = load i32, ptr %5, align 4, !tbaa !9
  %78 = load i32, ptr %6, align 4, !tbaa !9
  %79 = icmp ne i32 %77, %78
  br i1 %79, label %80, label %91

80:                                               ; preds = %51
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = load i32, ptr %5, align 4, !tbaa !9
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds double, ptr %81, i64 %83
  %85 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %84)
  %86 = load double, ptr %85, align 8, !tbaa !14
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = load i32, ptr %5, align 4, !tbaa !9
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds double, ptr %87, i64 %89
  store double %86, ptr %90, align 8, !tbaa !14
  br label %91

91:                                               ; preds = %80, %51
  br label %92

92:                                               ; preds = %91
  %93 = load i32, ptr %7, align 4, !tbaa !9
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %7, align 4, !tbaa !9
  br label %40, !llvm.loop !21

95:                                               ; preds = %40
  br label %96

96:                                               ; preds = %95
  %97 = load i32, ptr %6, align 4, !tbaa !9
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %6, align 4, !tbaa !9
  br label %25, !llvm.loop !22

99:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3absd(double noundef) #2

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

attributes #0 = { 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 = { inlinehint 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 = !{!"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}
!11 = !{!12, !13, i64 8}
!12 = !{!"_ZTSN5nasoq12sympiler_CSCE", !13, i64 0, !13, i64 8, !13, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80, !10, i64 84}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!12, !6, i64 24}
!19 = !{!12, !6, i64 32}
!20 = !{!12, !6, i64 48}
!21 = distinct !{!21, !17}
!22 = distinct !{!22, !17}


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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5nasoq26mat_inf_norm_cols_sym_triuEPKNS_12sympiler_CSCEPd(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %.not37 = icmp eq i64 %5, 0
  br i1 %.not37, label %._crit_edge, label %.lr.ph36

.lr.ph36:                                         ; preds = %2
  %6 = shl nuw i64 %5, 3
  tail call void @llvm.memset.p0.i64(ptr align 8 %1, i8 0, i64 %6, i1 false), !tbaa !12
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  %9 = getelementptr inbounds i8, ptr %0, i64 48
  %.pre = load ptr, ptr %7, align 8, !tbaa !14
  br label %13

.loopexit.loopexit:                               ; preds = %39
  %.pre44 = load i64, ptr %4, align 8, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %13
  %10 = phi i64 [ %.pre44, %.loopexit.loopexit ], [ %14, %13 ]
  %11 = phi ptr [ %40, %.loopexit.loopexit ], [ %15, %13 ]
  %12 = icmp ugt i64 %10, %indvars.iv.next42
  br i1 %12, label %13, label %._crit_edge, !llvm.loop !15

13:                                               ; preds = %.lr.ph36, %.loopexit
  %14 = phi i64 [ %5, %.lr.ph36 ], [ %10, %.loopexit ]
  %15 = phi ptr [ %.pre, %.lr.ph36 ], [ %11, %.loopexit ]
  %indvars.iv41 = phi i64 [ 0, %.lr.ph36 ], [ %indvars.iv.next42, %.loopexit ]
  %16 = getelementptr inbounds i32, ptr %15, i64 %indvars.iv41
  %17 = load i32, ptr %16, align 4, !tbaa !17
  %indvars.iv.next42 = add nuw nsw i64 %indvars.iv41, 1
  %18 = getelementptr inbounds i32, ptr %15, i64 %indvars.iv.next42
  %19 = load i32, ptr %18, align 4, !tbaa !17
  %20 = icmp slt i32 %17, %19
  br i1 %20, label %.lr.ph34, label %.loopexit

.lr.ph34:                                         ; preds = %13
  %21 = getelementptr inbounds double, ptr %1, i64 %indvars.iv41
  %22 = sext i32 %17 to i64
  br label %23

23:                                               ; preds = %.lr.ph34, %39
  %indvars.iv = phi i64 [ %22, %.lr.ph34 ], [ %indvars.iv.next, %39 ]
  %24 = load ptr, ptr %8, align 8, !tbaa !18
  %25 = getelementptr inbounds i32, ptr %24, i64 %indvars.iv
  %26 = load i32, ptr %25, align 4, !tbaa !17
  %27 = load ptr, ptr %9, align 8, !tbaa !19
  %28 = getelementptr inbounds double, ptr %27, i64 %indvars.iv
  %29 = load double, ptr %28, align 8, !tbaa !12
  %30 = call noundef double @_ZSt3absd(double noundef %29)
  store double %30, ptr %3, align 8, !tbaa !12
  %31 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %21)
  %32 = load double, ptr %31, align 8, !tbaa !12
  store double %32, ptr %21, align 8, !tbaa !12
  %33 = zext i32 %26 to i64
  %.not = icmp eq i64 %indvars.iv41, %33
  br i1 %.not, label %39, label %34

34:                                               ; preds = %23
  %35 = sext i32 %26 to i64
  %36 = getelementptr inbounds double, ptr %1, i64 %35
  %37 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %36)
  %38 = load double, ptr %37, align 8, !tbaa !12
  store double %38, ptr %36, align 8, !tbaa !12
  br label %39

39:                                               ; preds = %23, %34
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %40 = load ptr, ptr %7, align 8, !tbaa !14
  %41 = getelementptr inbounds i32, ptr %40, i64 %indvars.iv.next42
  %42 = load i32, ptr %41, align 4, !tbaa !17
  %43 = sext i32 %42 to i64
  %44 = icmp slt i64 %indvars.iv.next, %43
  br i1 %44, label %23, label %.loopexit.loopexit, !llvm.loop !20

._crit_edge:                                      ; preds = %.loopexit, %2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3absd(double noundef) local_unnamed_addr #2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #0 = { mustprogress 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 = { inlinehint 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !7, i64 8}
!6 = !{!"_ZTSN5nasoq12sympiler_CSCE", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !11, i64 64, !11, i64 68, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"double", !8, i64 0}
!14 = !{!6, !10, i64 24}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!11, !11, i64 0}
!18 = !{!6, !10, i64 32}
!19 = !{!6, !10, i64 48}
!20 = distinct !{!20, !16}


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