; 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.spTemplate = type { ptr, ptr, ptr, ptr }
%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
declare dso_local ptr @spGetElement(ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @spGetQuad(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr noundef %5) #1 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !9
  store i32 %3, ptr %11, align 4, !tbaa !9
  store i32 %4, ptr %12, align 4, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !5
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  %16 = load i32, ptr %9, align 4, !tbaa !9
  %17 = load i32, ptr %11, align 4, !tbaa !9
  %18 = call ptr @spGetElement(ptr noundef %15, i32 noundef %16, i32 noundef %17)
  %19 = load ptr, ptr %13, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.spTemplate, ptr %19, i32 0, i32 0
  store ptr %18, ptr %20, align 8, !tbaa !11
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = load i32, ptr %10, align 4, !tbaa !9
  %23 = load i32, ptr %12, align 4, !tbaa !9
  %24 = call ptr @spGetElement(ptr noundef %21, i32 noundef %22, i32 noundef %23)
  %25 = load ptr, ptr %13, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.spTemplate, ptr %25, i32 0, i32 1
  store ptr %24, ptr %26, align 8, !tbaa !13
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = load i32, ptr %10, align 4, !tbaa !9
  %29 = load i32, ptr %11, align 4, !tbaa !9
  %30 = call ptr @spGetElement(ptr noundef %27, i32 noundef %28, i32 noundef %29)
  %31 = load ptr, ptr %13, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.spTemplate, ptr %31, i32 0, i32 2
  store ptr %30, ptr %32, align 8, !tbaa !14
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = load i32, ptr %9, align 4, !tbaa !9
  %35 = load i32, ptr %12, align 4, !tbaa !9
  %36 = call ptr @spGetElement(ptr noundef %33, i32 noundef %34, i32 noundef %35)
  %37 = load ptr, ptr %13, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.spTemplate, ptr %37, i32 0, i32 3
  store ptr %36, ptr %38, align 8, !tbaa !15
  %39 = load ptr, ptr %13, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.spTemplate, ptr %39, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !11
  %42 = icmp eq ptr %41, null
  br i1 %42, label %58, label %43

43:                                               ; preds = %6
  %44 = load ptr, ptr %13, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.spTemplate, ptr %44, i32 0, i32 1
  %46 = load ptr, ptr %45, align 8, !tbaa !13
  %47 = icmp eq ptr %46, null
  br i1 %47, label %58, label %48

48:                                               ; preds = %43
  %49 = load ptr, ptr %13, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.spTemplate, ptr %49, i32 0, i32 2
  %51 = load ptr, ptr %50, align 8, !tbaa !14
  %52 = icmp eq ptr %51, null
  br i1 %52, label %58, label %53

53:                                               ; preds = %48
  %54 = load ptr, ptr %13, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.spTemplate, ptr %54, i32 0, i32 3
  %56 = load ptr, ptr %55, align 8, !tbaa !15
  %57 = icmp eq ptr %56, null
  br i1 %57, label %58, label %59

58:                                               ; preds = %53, %48, %43, %6
  store i32 5, ptr %7, align 4
  br label %80

59:                                               ; preds = %53
  %60 = load ptr, ptr %13, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.spTemplate, ptr %60, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8, !tbaa !11
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.MatrixFrame, ptr %63, i32 0, i32 40
  %65 = getelementptr inbounds %struct.MatrixElement, ptr %64, i32 0, i32 0
  %66 = icmp eq ptr %62, %65
  br i1 %66, label %67, label %79

67:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #2
  %68 = load ptr, ptr %13, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.spTemplate, ptr %68, i32 0, i32 0
  %70 = load ptr, ptr %69, align 8, !tbaa !11
  store ptr %70, ptr %14, align 8, !tbaa !5
  %71 = load ptr, ptr %13, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.spTemplate, ptr %71, i32 0, i32 1
  %73 = load ptr, ptr %72, align 8, !tbaa !13
  %74 = load ptr, ptr %13, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.spTemplate, ptr %74, i32 0, i32 0
  store ptr %73, ptr %75, align 8, !tbaa !11
  %76 = load ptr, ptr %14, align 8, !tbaa !5
  %77 = load ptr, ptr %13, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.spTemplate, ptr %77, i32 0, i32 1
  store ptr %76, ptr %78, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  br label %79

79:                                               ; preds = %67, %59
  store i32 0, ptr %7, align 4
  br label %80

80:                                               ; preds = %79, %58
  %81 = load i32, ptr %7, align 4
  ret i32 %81
}

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 0}
!12 = !{!"spTemplate", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!12, !6, i64 8}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !6, i64 24}


; 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: nounwind uwtable
declare dso_local ptr @spGetElement(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 6) i32 @spGetQuad(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, ptr nocapture noundef %5) local_unnamed_addr #0 {
  %7 = tail call ptr @spGetElement(ptr noundef %0, i32 noundef %1, i32 noundef %3)
  store ptr %7, ptr %5, align 8, !tbaa !5
  %8 = tail call ptr @spGetElement(ptr noundef %0, i32 noundef %2, i32 noundef %4)
  %9 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %8, ptr %9, align 8, !tbaa !10
  %10 = tail call ptr @spGetElement(ptr noundef %0, i32 noundef %2, i32 noundef %3)
  %11 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr %10, ptr %11, align 8, !tbaa !11
  %12 = tail call ptr @spGetElement(ptr noundef %0, i32 noundef %1, i32 noundef %4)
  %13 = getelementptr inbounds i8, ptr %5, i64 24
  store ptr %12, ptr %13, align 8, !tbaa !12
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = icmp eq ptr %14, null
  br i1 %15, label %27, label %16

16:                                               ; preds = %6
  %17 = load ptr, ptr %9, align 8, !tbaa !10
  %18 = icmp eq ptr %17, null
  br i1 %18, label %27, label %19

19:                                               ; preds = %16
  %20 = load ptr, ptr %11, align 8, !tbaa !11
  %21 = icmp eq ptr %20, null
  %22 = icmp eq ptr %12, null
  %or.cond = select i1 %21, i1 true, i1 %22
  br i1 %or.cond, label %27, label %23

23:                                               ; preds = %19
  %24 = getelementptr inbounds i8, ptr %0, i64 232
  %25 = icmp eq ptr %14, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  store ptr %17, ptr %5, align 8, !tbaa !5
  store ptr %14, ptr %9, align 8, !tbaa !10
  br label %27

27:                                               ; preds = %23, %26, %6, %16, %19
  %.0 = phi i32 [ 5, %19 ], [ 5, %16 ], [ 5, %6 ], [ 0, %26 ], [ 0, %23 ]
  ret i32 %.0
}

attributes #0 = { 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" }

!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 0}
!6 = !{!"spTemplate", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 16}
!12 = !{!6, !7, i64 24}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass