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

15:                                               ; preds = %26, %2
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %24

18:                                               ; preds = %15
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.MatrixElement, ptr %19, i32 0, i32 1
  %21 = load i32, ptr %20, align 8, !tbaa !16
  %22 = load i32, ptr %5, align 4, !tbaa !9
  %23 = icmp slt i32 %21, %22
  br label %24

24:                                               ; preds = %18, %15
  %25 = phi i1 [ false, %15 ], [ %23, %18 ]
  br i1 %25, label %26, label %30

26:                                               ; preds = %24
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.MatrixElement, ptr %27, i32 0, i32 4
  %29 = load ptr, ptr %28, align 8, !tbaa !17
  store ptr %29, ptr %6, align 8, !tbaa !5
  br label %15, !llvm.loop !18

30:                                               ; preds = %24
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %41

33:                                               ; preds = %30
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.MatrixElement, ptr %34, i32 0, i32 1
  %36 = load i32, ptr %35, align 8, !tbaa !16
  %37 = load i32, ptr %5, align 4, !tbaa !9
  %38 = icmp eq i32 %36, %37
  br i1 %38, label %39, label %41

39:                                               ; preds = %33
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %40, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %42

41:                                               ; preds = %33, %30
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %42

42:                                               ; preds = %41, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %43 = load ptr, ptr %3, align 8
  ret ptr %43
}

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


; 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(read, inaccessiblemem: none) uwtable
define dso_local ptr @spcFindDiag(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 88
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = sext i32 %1 to i64
  %6 = getelementptr inbounds ptr, ptr %4, i64 %5
  %.013 = load ptr, ptr %6, align 8, !tbaa !14
  %.not14 = icmp eq ptr %.013, null
  br i1 %.not14, label %.critedge11, label %.lr.ph

.lr.ph:                                           ; preds = %2, %10
  %.015 = phi ptr [ %.0, %10 ], [ %.013, %2 ]
  %7 = getelementptr inbounds i8, ptr %.015, i64 8
  %8 = load i32, ptr %7, align 8, !tbaa !15
  %9 = icmp slt i32 %8, %1
  br i1 %9, label %10, label %.critedge

10:                                               ; preds = %.lr.ph
  %11 = getelementptr inbounds i8, ptr %.015, i64 24
  %.0 = load ptr, ptr %11, align 8, !tbaa !14
  %.not = icmp eq ptr %.0, null
  br i1 %.not, label %.critedge11, label %.lr.ph, !llvm.loop !16

.critedge:                                        ; preds = %.lr.ph
  %12 = icmp eq i32 %8, %1
  br i1 %12, label %13, label %.critedge11

.critedge11:                                      ; preds = %10, %2, %.critedge
  br label %13

13:                                               ; preds = %.critedge, %.critedge11
  %.010 = phi ptr [ null, %.critedge11 ], [ %.015, %.critedge ]
  ret ptr %.010
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, 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" }

!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 88}
!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 = !{!11, !11, i64 0}
!15 = !{!13, !10, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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