; LLVM IR from Tiramisu-Compiler/tiramisu :: benchmarks/linear_algebra/cg (HPC_Sparse_Matrix)

; 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.HPC_Sparse_Matrix_STRUCT = type { ptr, i32, i32, i32, i64, i32, i32, i32, ptr, ptr, ptr, ptr, ptr, ptr }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z13destroyMatrixRP24HPC_Sparse_Matrix_STRUCT(ptr noundef nonnull align 8 dereferenceable(8) %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.HPC_Sparse_Matrix_STRUCT, ptr %4, i32 0, i32 0
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = icmp ne ptr %6, null
  br i1 %7, label %8, label %16

8:                                                ; preds = %1
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.HPC_Sparse_Matrix_STRUCT, ptr %10, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = icmp eq ptr %12, null
  br i1 %13, label %15, label %14

14:                                               ; preds = %8
  call void @_ZdaPv(ptr noundef %12) #2
  br label %15

15:                                               ; preds = %14, %8
  br label %16

16:                                               ; preds = %15, %1
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.HPC_Sparse_Matrix_STRUCT, ptr %18, i32 0, i32 8
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %30

22:                                               ; preds = %16
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.HPC_Sparse_Matrix_STRUCT, ptr %24, i32 0, i32 8
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = icmp eq ptr %26, null
  br i1 %27, label %29, label %28

28:                                               ; preds = %22
  call void @_ZdaPv(ptr noundef %26) #2
  br label %29

29:                                               ; preds = %28, %22
  br label %30

30:                                               ; preds = %29, %16
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.HPC_Sparse_Matrix_STRUCT, ptr %32, i32 0, i32 12
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %44

36:                                               ; preds = %30
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.HPC_Sparse_Matrix_STRUCT, ptr %38, i32 0, i32 12
  %40 = load ptr, ptr %39, align 8, !tbaa !14
  %41 = icmp eq ptr %40, null
  br i1 %41, label %43, label %42

42:                                               ; preds = %36
  call void @_ZdaPv(ptr noundef %40) #2
  br label %43

43:                                               ; preds = %42, %36
  br label %44

44:                                               ; preds = %43, %30
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = load ptr, ptr %45, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.HPC_Sparse_Matrix_STRUCT, ptr %46, i32 0, i32 9
  %48 = load ptr, ptr %47, align 8, !tbaa !15
  %49 = icmp ne ptr %48, null
  br i1 %49, label %50, label %58

50:                                               ; preds = %44
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = load ptr, ptr %51, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.HPC_Sparse_Matrix_STRUCT, ptr %52, i32 0, i32 9
  %54 = load ptr, ptr %53, align 8, !tbaa !15
  %55 = icmp eq ptr %54, null
  br i1 %55, label %57, label %56

56:                                               ; preds = %50
  call void @_ZdaPv(ptr noundef %54) #2
  br label %57

57:                                               ; preds = %56, %50
  br label %58

58:                                               ; preds = %57, %44
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = load ptr, ptr %59, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.HPC_Sparse_Matrix_STRUCT, ptr %60, i32 0, i32 13
  %62 = load ptr, ptr %61, align 8, !tbaa !16
  %63 = icmp ne ptr %62, null
  br i1 %63, label %64, label %72

64:                                               ; preds = %58
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = load ptr, ptr %65, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.HPC_Sparse_Matrix_STRUCT, ptr %66, i32 0, i32 13
  %68 = load ptr, ptr %67, align 8, !tbaa !16
  %69 = icmp eq ptr %68, null
  br i1 %69, label %71, label %70

70:                                               ; preds = %64
  call void @_ZdaPv(ptr noundef %68) #2
  br label %71

71:                                               ; preds = %70, %64
  br label %72

72:                                               ; preds = %71, %58
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = load ptr, ptr %73, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.HPC_Sparse_Matrix_STRUCT, ptr %74, i32 0, i32 10
  %76 = load ptr, ptr %75, align 8, !tbaa !17
  %77 = icmp ne ptr %76, null
  br i1 %77, label %78, label %86

78:                                               ; preds = %72
  %79 = load ptr, ptr %2, align 8, !tbaa !5
  %80 = load ptr, ptr %79, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.HPC_Sparse_Matrix_STRUCT, ptr %80, i32 0, i32 10
  %82 = load ptr, ptr %81, align 8, !tbaa !17
  %83 = icmp eq ptr %82, null
  br i1 %83, label %85, label %84

84:                                               ; preds = %78
  call void @_ZdaPv(ptr noundef %82) #2
  br label %85

85:                                               ; preds = %84, %78
  br label %86

86:                                               ; preds = %85, %72
  %87 = load ptr, ptr %2, align 8, !tbaa !5
  %88 = load ptr, ptr %87, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.HPC_Sparse_Matrix_STRUCT, ptr %88, i32 0, i32 11
  %90 = load ptr, ptr %89, align 8, !tbaa !18
  %91 = icmp ne ptr %90, null
  br i1 %91, label %92, label %100

92:                                               ; preds = %86
  %93 = load ptr, ptr %2, align 8, !tbaa !5
  %94 = load ptr, ptr %93, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.HPC_Sparse_Matrix_STRUCT, ptr %94, i32 0, i32 11
  %96 = load ptr, ptr %95, align 8, !tbaa !18
  %97 = icmp eq ptr %96, null
  br i1 %97, label %99, label %98

98:                                               ; preds = %92
  call void @_ZdaPv(ptr noundef %96) #2
  br label %99

99:                                               ; preds = %98, %92
  br label %100

100:                                              ; preds = %99, %86
  %101 = load ptr, ptr %2, align 8, !tbaa !5
  %102 = load ptr, ptr %101, align 8, !tbaa !5
  %103 = icmp eq ptr %102, null
  br i1 %103, label %105, label %104

104:                                              ; preds = %100
  call void @_ZdlPvm(ptr noundef %102, i64 noundef 96) #2
  br label %105

105:                                              ; preds = %104, %100
  %106 = load ptr, ptr %2, align 8, !tbaa !5
  store ptr null, ptr %106, align 8, !tbaa !5
  ret void
}

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) #1

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #1

attributes #0 = { 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 #1 = { nobuiltin nounwind "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 = { builtin 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, !6, i64 0}
!10 = !{!"_ZTS24HPC_Sparse_Matrix_STRUCT", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !12, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!10, !6, i64 48}
!14 = !{!10, !6, i64 80}
!15 = !{!10, !6, i64 56}
!16 = !{!10, !6, i64 88}
!17 = !{!10, !6, i64 64}
!18 = !{!10, !6, i64 72}


; 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 nounwind uwtable
define dso_local void @_Z13destroyMatrixRP24HPC_Sparse_Matrix_STRUCT(ptr nocapture noundef nonnull align 8 dereferenceable(8) %0) local_unnamed_addr #0 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !9
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %5, label %4

4:                                                ; preds = %1
  tail call void @_ZdaPv(ptr noundef nonnull %3) #2
  %.pre = load ptr, ptr %0, align 8, !tbaa !5
  br label %5

5:                                                ; preds = %4, %1
  %6 = phi ptr [ %.pre, %4 ], [ %2, %1 ]
  %7 = getelementptr inbounds i8, ptr %6, i64 48
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %.not23 = icmp eq ptr %8, null
  br i1 %.not23, label %10, label %9

9:                                                ; preds = %5
  tail call void @_ZdaPv(ptr noundef nonnull %8) #2
  %.pre29 = load ptr, ptr %0, align 8, !tbaa !5
  br label %10

10:                                               ; preds = %9, %5
  %11 = phi ptr [ %.pre29, %9 ], [ %6, %5 ]
  %12 = getelementptr inbounds i8, ptr %11, i64 80
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  %.not24 = icmp eq ptr %13, null
  br i1 %.not24, label %15, label %14

14:                                               ; preds = %10
  tail call void @_ZdaPv(ptr noundef nonnull %13) #2
  %.pre30 = load ptr, ptr %0, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %14, %10
  %16 = phi ptr [ %.pre30, %14 ], [ %11, %10 ]
  %17 = getelementptr inbounds i8, ptr %16, i64 56
  %18 = load ptr, ptr %17, align 8, !tbaa !15
  %.not25 = icmp eq ptr %18, null
  br i1 %.not25, label %20, label %19

19:                                               ; preds = %15
  tail call void @_ZdaPv(ptr noundef nonnull %18) #2
  %.pre31 = load ptr, ptr %0, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %19, %15
  %21 = phi ptr [ %.pre31, %19 ], [ %16, %15 ]
  %22 = getelementptr inbounds i8, ptr %21, i64 88
  %23 = load ptr, ptr %22, align 8, !tbaa !16
  %.not26 = icmp eq ptr %23, null
  br i1 %.not26, label %25, label %24

24:                                               ; preds = %20
  tail call void @_ZdaPv(ptr noundef nonnull %23) #2
  %.pre32 = load ptr, ptr %0, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %24, %20
  %26 = phi ptr [ %.pre32, %24 ], [ %21, %20 ]
  %27 = getelementptr inbounds i8, ptr %26, i64 64
  %28 = load ptr, ptr %27, align 8, !tbaa !17
  %.not27 = icmp eq ptr %28, null
  br i1 %.not27, label %30, label %29

29:                                               ; preds = %25
  tail call void @_ZdaPv(ptr noundef nonnull %28) #2
  %.pre33 = load ptr, ptr %0, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %29, %25
  %31 = phi ptr [ %.pre33, %29 ], [ %26, %25 ]
  %32 = getelementptr inbounds i8, ptr %31, i64 72
  %33 = load ptr, ptr %32, align 8, !tbaa !18
  %.not28 = icmp eq ptr %33, null
  br i1 %.not28, label %.thread, label %34

34:                                               ; preds = %30
  tail call void @_ZdaPv(ptr noundef nonnull %33) #2
  %.pr = load ptr, ptr %0, align 8, !tbaa !5
  %35 = icmp eq ptr %.pr, null
  br i1 %35, label %37, label %.thread

.thread:                                          ; preds = %30, %34
  %36 = phi ptr [ %.pr, %34 ], [ %31, %30 ]
  tail call void @_ZdlPvm(ptr noundef nonnull %36, i64 noundef 96) #2
  br label %37

37:                                               ; preds = %.thread, %34
  store ptr null, ptr %0, align 8, !tbaa !5
  ret void
}

; Function Attrs: nobuiltin nounwind
declare void @_ZdaPv(ptr noundef) local_unnamed_addr #1

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { nobuiltin nounwind "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 = { builtin 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, !6, i64 0}
!10 = !{!"_ZTS24HPC_Sparse_Matrix_STRUCT", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !12, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!10, !6, i64 48}
!14 = !{!10, !6, i64 80}
!15 = !{!10, !6, i64 56}
!16 = !{!10, !6, i64 88}
!17 = !{!10, !6, i64 64}
!18 = !{!10, !6, i64 72}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass