; LLVM IR from InsightSoftwareConsortium/ITK :: Modules/ThirdParty/VNL/src/vxl/v3p/netlib/sparse (spBuild)

; 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.MatrixFrame = type { double, i32, i32, i32, i32, ptr, ptr, ptr, i32, i32, i32, ptr, ptr, i32, i32, ptr, ptr, i64, ptr, i32, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, i32, i8, i32, double, i32, i32, i32, i32, i32, i32, %struct.MatrixElement, ptr, i32, ptr, i32, ptr, i32, ptr, ptr }
%struct.MatrixElement = type { double, i32, i32, ptr, ptr, ptr }

; 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: nounwind uwtable
define dso_local void @spcLinkRows(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.MatrixFrame, ptr %7, i32 0, i32 16
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %9, ptr %5, align 8, !tbaa !5
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.MatrixFrame, ptr %10, i32 0, i32 39
  %12 = load i32, ptr %11, align 4, !tbaa !15
  store i32 %12, ptr %6, align 4, !tbaa !16
  br label %13

13:                                               ; preds = %21, %1
  %14 = load i32, ptr %6, align 4, !tbaa !16
  %15 = icmp sge i32 %14, 1
  br i1 %15, label %16, label %24

16:                                               ; preds = %13
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = load i32, ptr %6, align 4, !tbaa !16
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds ptr, ptr %17, i64 %19
  store ptr null, ptr %20, align 8, !tbaa !5
  br label %21

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

24:                                               ; preds = %13
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.MatrixFrame, ptr %25, i32 0, i32 39
  %27 = load i32, ptr %26, align 4, !tbaa !15
  store i32 %27, ptr %6, align 4, !tbaa !16
  br label %28

28:                                               ; preds = %62, %24
  %29 = load i32, ptr %6, align 4, !tbaa !16
  %30 = icmp sge i32 %29, 1
  br i1 %30, label %31, label %65

31:                                               ; preds = %28
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.MatrixFrame, ptr %32, i32 0, i32 15
  %34 = load ptr, ptr %33, align 8, !tbaa !19
  %35 = load i32, ptr %6, align 4, !tbaa !16
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds ptr, ptr %34, i64 %36
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  store ptr %38, ptr %3, align 8, !tbaa !5
  br label %39

39:                                               ; preds = %42, %31
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = icmp ne ptr %40, null
  br i1 %41, label %42, label %61

42:                                               ; preds = %39
  %43 = load i32, ptr %6, align 4, !tbaa !16
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.MatrixElement, ptr %44, i32 0, i32 2
  store i32 %43, ptr %45, align 4, !tbaa !20
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.MatrixElement, ptr %47, i32 0, i32 1
  %49 = load i32, ptr %48, align 8, !tbaa !21
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds ptr, ptr %46, i64 %50
  store ptr %51, ptr %4, align 8, !tbaa !5
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.MatrixElement, ptr %54, i32 0, i32 3
  store ptr %53, ptr %55, align 8, !tbaa !22
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %56, ptr %57, align 8, !tbaa !5
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.MatrixElement, ptr %58, i32 0, i32 4
  %60 = load ptr, ptr %59, align 8, !tbaa !23
  store ptr %60, ptr %3, align 8, !tbaa !5
  br label %39, !llvm.loop !24

61:                                               ; preds = %39
  br label %62

62:                                               ; preds = %61
  %63 = load i32, ptr %6, align 4, !tbaa !16
  %64 = add nsw i32 %63, -1
  store i32 %64, ptr %6, align 4, !tbaa !16
  br label %28, !llvm.loop !25

65:                                               ; preds = %28
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.MatrixFrame, ptr %66, i32 0, i32 35
  store i32 1, ptr %67, align 4, !tbaa !26
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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/C++ TBAA"}
!9 = !{!10, !6, i64 96}
!10 = !{!"MatrixFrame", !11, i64 0, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !12, i64 48, !12, i64 52, !12, i64 56, !6, i64 64, !6, i64 72, !12, i64 80, !12, i64 84, !6, i64 88, !6, i64 96, !13, i64 104, !6, i64 112, !12, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !12, i64 168, !12, i64 172, !12, i64 176, !12, i64 180, !12, i64 184, !12, i64 188, !7, i64 192, !12, i64 196, !11, i64 200, !12, i64 208, !12, i64 212, !12, i64 216, !12, i64 220, !12, i64 224, !12, i64 228, !14, i64 232, !6, i64 272, !12, i64 280, !6, i64 288, !12, i64 296, !6, i64 304, !12, i64 312, !6, i64 320, !6, i64 328}
!11 = !{!"double", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!"MatrixElement", !11, i64 0, !12, i64 8, !12, i64 12, !6, i64 16, !6, i64 24, !6, i64 32}
!15 = !{!10, !12, i64 228}
!16 = !{!12, !12, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!10, !6, i64 88}
!20 = !{!14, !12, i64 12}
!21 = !{!14, !12, i64 8}
!22 = !{!14, !6, i64 16}
!23 = !{!14, !6, i64 24}
!24 = distinct !{!24, !18}
!25 = distinct !{!25, !18}
!26 = !{!10, !12, i64 212}


; 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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @spcLinkRows(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 96
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 228
  %5 = load i32, ptr %4, align 4, !tbaa !14
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph28, label %._crit_edge29

.lr.ph28:                                         ; preds = %1
  %7 = zext nneg i32 %5 to i64
  %8 = shl nuw nsw i64 %7, 3
  %9 = add nsw i32 %5, -1
  %10 = zext nneg i32 %9 to i64
  %11 = sub nsw i64 %7, %10
  %12 = shl nsw i64 %11, 3
  %scevgep = getelementptr i8, ptr %3, i64 %12
  tail call void @llvm.memset.p0.i64(ptr align 8 %scevgep, i8 0, i64 %8, i1 false), !tbaa !15
  %13 = getelementptr inbounds i8, ptr %0, i64 88
  %14 = zext nneg i32 %5 to i64
  br label %15

15:                                               ; preds = %.lr.ph28, %._crit_edge
  %indvars.iv = phi i64 [ %14, %.lr.ph28 ], [ %indvars.iv.next, %._crit_edge ]
  %16 = load ptr, ptr %13, align 8, !tbaa !16
  %17 = getelementptr inbounds ptr, ptr %16, i64 %indvars.iv
  %.02123 = load ptr, ptr %17, align 8, !tbaa !15
  %.not24 = icmp eq ptr %.02123, null
  br i1 %.not24, label %._crit_edge, label %.lr.ph26.preheader

.lr.ph26.preheader:                               ; preds = %15
  %18 = trunc nuw nsw i64 %indvars.iv to i32
  br label %.lr.ph26

.lr.ph26:                                         ; preds = %.lr.ph26.preheader, %.lr.ph26
  %.02125 = phi ptr [ %.021, %.lr.ph26 ], [ %.02123, %.lr.ph26.preheader ]
  %19 = getelementptr inbounds i8, ptr %.02125, i64 12
  store i32 %18, ptr %19, align 4, !tbaa !17
  %20 = getelementptr inbounds i8, ptr %.02125, i64 8
  %21 = load i32, ptr %20, align 8, !tbaa !18
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds ptr, ptr %3, i64 %22
  %24 = load ptr, ptr %23, align 8, !tbaa !15
  %25 = getelementptr inbounds i8, ptr %.02125, i64 16
  store ptr %24, ptr %25, align 8, !tbaa !19
  store ptr %.02125, ptr %23, align 8, !tbaa !15
  %26 = getelementptr inbounds i8, ptr %.02125, i64 24
  %.021 = load ptr, ptr %26, align 8, !tbaa !15
  %.not = icmp eq ptr %.021, null
  br i1 %.not, label %._crit_edge, label %.lr.ph26, !llvm.loop !20

._crit_edge:                                      ; preds = %.lr.ph26, %15
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %27 = icmp sgt i64 %indvars.iv, 1
  br i1 %27, label %15, label %._crit_edge29, !llvm.loop !22

._crit_edge29:                                    ; preds = %._crit_edge, %1
  %28 = getelementptr inbounds i8, ptr %0, i64 212
  store i32 1, ptr %28, align 4, !tbaa !23
  ret void
}

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

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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 nounwind willreturn memory(argmem: write) }

!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, !11, i64 96}
!6 = !{!"MatrixFrame", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !11, i64 24, !11, i64 32, !11, i64 40, !10, i64 48, !10, i64 52, !10, i64 56, !11, i64 64, !11, i64 72, !10, i64 80, !10, i64 84, !11, i64 88, !11, i64 96, !12, i64 104, !11, i64 112, !10, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !11, i64 152, !11, i64 160, !10, i64 168, !10, i64 172, !10, i64 176, !10, i64 180, !10, i64 184, !10, i64 188, !8, i64 192, !10, i64 196, !7, i64 200, !10, i64 208, !10, i64 212, !10, i64 216, !10, i64 220, !10, i64 224, !10, i64 228, !13, i64 232, !11, i64 272, !10, i64 280, !11, i64 288, !10, i64 296, !11, i64 304, !10, i64 312, !11, i64 320, !11, i64 328}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!"MatrixElement", !7, i64 0, !10, i64 8, !10, i64 12, !11, i64 16, !11, i64 24, !11, i64 32}
!14 = !{!6, !10, i64 228}
!15 = !{!11, !11, i64 0}
!16 = !{!6, !11, i64 88}
!17 = !{!13, !10, i64 12}
!18 = !{!13, !10, i64 8}
!19 = !{!13, !11, i64 16}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}
!23 = !{!6, !10, i64 212}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass