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

; 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 }
%struct.FillinListNodeStruct = type { ptr, i32, ptr }

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

; Function Attrs: allocsize(0)
declare ptr @malloc(i64 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @RecordAllocation(ptr noundef, ptr noundef) #2

; 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 @spcGetFillin(ptr noundef %0) #2 {
  %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 %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.MatrixFrame, ptr %7, i32 0, i32 46
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %76

11:                                               ; preds = %1
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.MatrixFrame, ptr %12, i32 0, i32 48
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  store ptr %14, ptr %4, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.FillinListNodeStruct, ptr %15, i32 0, i32 2
  %17 = load ptr, ptr %16, align 8, !tbaa !16
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %35

19:                                               ; preds = %11
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.FillinListNodeStruct, ptr %20, i32 0, i32 2
  %22 = load ptr, ptr %21, align 8, !tbaa !16
  store ptr %22, ptr %4, align 8, !tbaa !5
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.MatrixFrame, ptr %23, i32 0, i32 48
  store ptr %22, ptr %24, align 8, !tbaa !15
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.FillinListNodeStruct, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 8, !tbaa !18
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.MatrixFrame, ptr %28, i32 0, i32 46
  store i32 %27, ptr %29, align 8, !tbaa !9
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.FillinListNodeStruct, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !19
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.MatrixFrame, ptr %33, i32 0, i32 45
  store ptr %32, ptr %34, align 8, !tbaa !20
  br label %75

35:                                               ; preds = %11
  %36 = call ptr @malloc(i64 noundef 1240) #4
  store ptr %36, ptr %5, align 8, !tbaa !5
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  call void @RecordAllocation(ptr noundef %37, ptr noundef %38)
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.MatrixFrame, ptr %39, i32 0, i32 9
  %41 = load i32, ptr %40, align 4, !tbaa !21
  %42 = icmp eq i32 %41, 5
  br i1 %42, label %43, label %44

43:                                               ; preds = %35
  store ptr null, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %85

44:                                               ; preds = %35
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.MatrixFrame, ptr %45, i32 0, i32 46
  store i32 31, ptr %46, align 8, !tbaa !9
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.MatrixFrame, ptr %48, i32 0, i32 45
  store ptr %47, ptr %49, align 8, !tbaa !20
  %50 = call ptr @malloc(i64 noundef 24) #4
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.FillinListNodeStruct, ptr %51, i32 0, i32 2
  store ptr %50, ptr %52, align 8, !tbaa !16
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.FillinListNodeStruct, ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !16
  call void @RecordAllocation(ptr noundef %53, ptr noundef %56)
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.MatrixFrame, ptr %57, i32 0, i32 9
  %59 = load i32, ptr %58, align 4, !tbaa !21
  %60 = icmp eq i32 %59, 5
  br i1 %60, label %61, label %62

61:                                               ; preds = %44
  store ptr null, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %85

62:                                               ; preds = %44
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.FillinListNodeStruct, ptr %63, i32 0, i32 2
  %65 = load ptr, ptr %64, align 8, !tbaa !16
  store ptr %65, ptr %4, align 8, !tbaa !5
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.MatrixFrame, ptr %66, i32 0, i32 48
  store ptr %65, ptr %67, align 8, !tbaa !15
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.FillinListNodeStruct, ptr %69, i32 0, i32 0
  store ptr %68, ptr %70, align 8, !tbaa !19
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.FillinListNodeStruct, ptr %71, i32 0, i32 1
  store i32 31, ptr %72, align 8, !tbaa !18
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.FillinListNodeStruct, ptr %73, i32 0, i32 2
  store ptr null, ptr %74, align 8, !tbaa !16
  br label %75

75:                                               ; preds = %62, %19
  br label %76

76:                                               ; preds = %75, %1
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.MatrixFrame, ptr %77, i32 0, i32 46
  %79 = load i32, ptr %78, align 8, !tbaa !9
  %80 = add nsw i32 %79, -1
  store i32 %80, ptr %78, align 8, !tbaa !9
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.MatrixFrame, ptr %81, i32 0, i32 45
  %83 = load ptr, ptr %82, align 8, !tbaa !20
  %84 = getelementptr inbounds %struct.MatrixElement, ptr %83, i32 1
  store ptr %84, ptr %82, align 8, !tbaa !20
  store ptr %83, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %85

85:                                               ; preds = %76, %61, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  %86 = load ptr, ptr %2, align 8
  ret ptr %86
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { allocsize(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 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 }
attributes #4 = { allocsize(0) }

!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, !12, i64 312}
!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, !6, i64 328}
!16 = !{!17, !6, i64 16}
!17 = !{!"FillinListNodeStruct", !6, i64 0, !12, i64 8, !6, i64 16}
!18 = !{!17, !12, i64 8}
!19 = !{!17, !6, i64 0}
!20 = !{!10, !6, i64 304}
!21 = !{!10, !12, i64 52}


; 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 nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @RecordAllocation(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @spcGetFillin(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 312
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = icmp eq i32 %3, 0
  br i1 %4, label %5, label %29

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 328
  %7 = load ptr, ptr %6, align 8, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %7, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !15
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %15, label %10

10:                                               ; preds = %5
  store ptr %9, ptr %6, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %9, i64 8
  %12 = load i32, ptr %11, align 8, !tbaa !17
  %13 = load ptr, ptr %9, align 8, !tbaa !18
  %14 = getelementptr inbounds i8, ptr %0, i64 304
  store ptr %13, ptr %14, align 8, !tbaa !19
  br label %29

15:                                               ; preds = %5
  %16 = tail call dereferenceable_or_null(1240) ptr @malloc(i64 noundef 1240) #2
  tail call void @RecordAllocation(ptr noundef nonnull %0, ptr noundef %16)
  %17 = getelementptr inbounds i8, ptr %0, i64 52
  %18 = load i32, ptr %17, align 4, !tbaa !20
  %19 = icmp eq i32 %18, 5
  br i1 %19, label %35, label %20

20:                                               ; preds = %15
  store i32 31, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %0, i64 304
  store ptr %16, ptr %21, align 8, !tbaa !19
  %22 = tail call dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #2
  store ptr %22, ptr %8, align 8, !tbaa !15
  tail call void @RecordAllocation(ptr noundef nonnull %0, ptr noundef %22)
  %23 = load i32, ptr %17, align 4, !tbaa !20
  %24 = icmp eq i32 %23, 5
  br i1 %24, label %35, label %25

25:                                               ; preds = %20
  %26 = load ptr, ptr %8, align 8, !tbaa !15
  store ptr %26, ptr %6, align 8, !tbaa !14
  store ptr %16, ptr %26, align 8, !tbaa !18
  %27 = getelementptr inbounds i8, ptr %26, i64 8
  store i32 31, ptr %27, align 8, !tbaa !17
  %28 = getelementptr inbounds i8, ptr %26, i64 16
  store ptr null, ptr %28, align 8, !tbaa !15
  %.pre = load i32, ptr %2, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %10, %25, %1
  %30 = phi i32 [ %12, %10 ], [ %.pre, %25 ], [ %3, %1 ]
  %31 = add nsw i32 %30, -1
  store i32 %31, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %0, i64 304
  %33 = load ptr, ptr %32, align 8, !tbaa !19
  %34 = getelementptr inbounds i8, ptr %33, i64 40
  store ptr %34, ptr %32, align 8, !tbaa !19
  br label %35

35:                                               ; preds = %20, %15, %29
  %.0 = phi ptr [ %33, %29 ], [ null, %15 ], [ null, %20 ]
  ret ptr %.0
}

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 = { allocsize(0) }

!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, !10, i64 312}
!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, !11, i64 328}
!15 = !{!16, !11, i64 16}
!16 = !{!"FillinListNodeStruct", !11, i64 0, !10, i64 8, !11, i64 16}
!17 = !{!16, !10, i64 8}
!18 = !{!16, !11, i64 0}
!19 = !{!6, !11, i64 304}
!20 = !{!6, !10, i64 52}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass