; LLVM IR from stan-dev/math :: lib/sundials_6.1.1/src/sunlinsol/lapackband (sunlinsol_lapackband)

; 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._generic_SUNLinearSolver = type { ptr, ptr, ptr }
%struct._SUNLinearSolverContent_LapackBand = type { i64, ptr, i64 }

@.str = external hidden unnamed_addr constant [2 x i8], align 1

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

declare i64 @SUNBandMatrix_Rows(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @SUNLinSolSolve_LapackBand(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, double noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca double, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store double %4, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %31, label %22

22:                                               ; preds = %5
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = icmp eq ptr %23, null
  br i1 %24, label %31, label %25

25:                                               ; preds = %22
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = icmp eq ptr %26, null
  br i1 %27, label %31, label %28

28:                                               ; preds = %25
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  %30 = icmp eq ptr %29, null
  br i1 %30, label %31, label %32

31:                                               ; preds = %28, %25, %22, %5
  store i32 -801, ptr %6, align 4
  store i32 1, ptr %19, align 4
  br label %74

32:                                               ; preds = %28
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  call void @N_VScale(double noundef 1.000000e+00, ptr noundef %33, ptr noundef %34)
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = call ptr @N_VGetArrayPointer(ptr noundef %35)
  store ptr %36, ptr %18, align 8, !tbaa !5
  %37 = load ptr, ptr %18, align 8, !tbaa !5
  %38 = icmp eq ptr %37, null
  br i1 %38, label %39, label %44

39:                                               ; preds = %32
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._generic_SUNLinearSolver, ptr %40, i32 0, i32 0
  %42 = load ptr, ptr %41, align 8, !tbaa !11
  %43 = getelementptr inbounds %struct._SUNLinearSolverContent_LapackBand, ptr %42, i32 0, i32 2
  store i64 -803, ptr %43, align 8, !tbaa !13
  store i32 -803, ptr %6, align 4
  store i32 1, ptr %19, align 4
  br label %74

44:                                               ; preds = %32
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = call i64 @SUNBandMatrix_Rows(ptr noundef %45)
  store i64 %46, ptr %12, align 8, !tbaa !16
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = call i64 @SUNBandMatrix_LowerBandwidth(ptr noundef %47)
  store i64 %48, ptr %13, align 8, !tbaa !16
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = call i64 @SUNBandMatrix_UpperBandwidth(ptr noundef %49)
  store i64 %50, ptr %14, align 8, !tbaa !16
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = call i64 @SUNBandMatrix_LDim(ptr noundef %51)
  store i64 %52, ptr %15, align 8, !tbaa !16
  store i64 1, ptr %16, align 8, !tbaa !16
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = call ptr @SUNBandMatrix_Data(ptr noundef %53)
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._generic_SUNLinearSolver, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !11
  %58 = getelementptr inbounds %struct._SUNLinearSolverContent_LapackBand, ptr %57, i32 0, i32 1
  %59 = load ptr, ptr %58, align 8, !tbaa !17
  %60 = load ptr, ptr %18, align 8, !tbaa !5
  call void @dgbtrs_(ptr noundef @.str, ptr noundef %12, ptr noundef %13, ptr noundef %14, ptr noundef %16, ptr noundef %54, ptr noundef %15, ptr noundef %59, ptr noundef %60, ptr noundef %12, ptr noundef %17)
  %61 = load i64, ptr %17, align 8, !tbaa !16
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct._generic_SUNLinearSolver, ptr %62, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8, !tbaa !11
  %65 = getelementptr inbounds %struct._SUNLinearSolverContent_LapackBand, ptr %64, i32 0, i32 2
  store i64 %61, ptr %65, align 8, !tbaa !13
  %66 = load i64, ptr %17, align 8, !tbaa !16
  %67 = icmp slt i64 %66, 0
  br i1 %67, label %68, label %69

68:                                               ; preds = %44
  store i32 -809, ptr %6, align 4
  store i32 1, ptr %19, align 4
  br label %74

69:                                               ; preds = %44
  %70 = load ptr, ptr %7, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._generic_SUNLinearSolver, ptr %70, i32 0, i32 0
  %72 = load ptr, ptr %71, align 8, !tbaa !11
  %73 = getelementptr inbounds %struct._SUNLinearSolverContent_LapackBand, ptr %72, i32 0, i32 2
  store i64 0, ptr %73, align 8, !tbaa !13
  store i32 0, ptr %6, align 4
  store i32 1, ptr %19, align 4
  br label %74

74:                                               ; preds = %69, %68, %39, %31
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %75 = load i32, ptr %6, align 4
  ret i32 %75
}

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

declare i64 @SUNBandMatrix_LowerBandwidth(ptr noundef) #1

declare i64 @SUNBandMatrix_UpperBandwidth(ptr noundef) #1

declare i64 @SUNBandMatrix_LDim(ptr noundef) #1

declare ptr @SUNBandMatrix_Data(ptr noundef) #1

declare void @N_VScale(double noundef, ptr noundef, ptr noundef) #1

declare ptr @N_VGetArrayPointer(ptr noundef) #1

declare void @dgbtrs_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

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

!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 = !{!"double", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_generic_SUNLinearSolver", !6, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!14, !15, i64 16}
!14 = !{!"_SUNLinearSolverContent_LapackBand", !15, i64 0, !6, i64 8, !15, i64 16}
!15 = !{!"long", !7, i64 0}
!16 = !{!15, !15, i64 0}
!17 = !{!14, !6, i64 8}


; 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"

@.str = external hidden unnamed_addr constant [2 x i8], align 1

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

declare i64 @SUNBandMatrix_Rows(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -809, 1) i32 @SUNLinSolSolve_LapackBand(ptr noundef readonly %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, double noundef %4) local_unnamed_addr #2 {
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #4
  %12 = insertelement <4 x ptr> poison, ptr %0, i64 0
  %13 = insertelement <4 x ptr> %12, ptr %1, i64 1
  %14 = insertelement <4 x ptr> %13, ptr %2, i64 2
  %15 = insertelement <4 x ptr> %14, ptr %3, i64 3
  %16 = icmp eq <4 x ptr> %15, zeroinitializer
  %17 = bitcast <4 x i1> %16 to i4
  %.not = icmp eq i4 %17, 0
  br i1 %.not, label %18, label %37

18:                                               ; preds = %5
  tail call void @N_VScale(double noundef 1.000000e+00, ptr noundef nonnull %3, ptr noundef nonnull %2) #4
  %19 = tail call ptr @N_VGetArrayPointer(ptr noundef nonnull %2) #4
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %24

21:                                               ; preds = %18
  %22 = load ptr, ptr %0, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 16
  store i64 -803, ptr %23, align 8, !tbaa !10
  br label %37

24:                                               ; preds = %18
  %25 = tail call i64 @SUNBandMatrix_Rows(ptr noundef nonnull %1) #4
  store i64 %25, ptr %6, align 8, !tbaa !13
  %26 = tail call i64 @SUNBandMatrix_LowerBandwidth(ptr noundef nonnull %1) #4
  store i64 %26, ptr %7, align 8, !tbaa !13
  %27 = tail call i64 @SUNBandMatrix_UpperBandwidth(ptr noundef nonnull %1) #4
  store i64 %27, ptr %8, align 8, !tbaa !13
  %28 = tail call i64 @SUNBandMatrix_LDim(ptr noundef nonnull %1) #4
  store i64 %28, ptr %9, align 8, !tbaa !13
  store i64 1, ptr %10, align 8, !tbaa !13
  %29 = tail call ptr @SUNBandMatrix_Data(ptr noundef nonnull %1) #4
  %30 = load ptr, ptr %0, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %30, i64 8
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  call void @dgbtrs_(ptr noundef nonnull @.str, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef nonnull %10, ptr noundef %29, ptr noundef nonnull %9, ptr noundef %32, ptr noundef nonnull %19, ptr noundef nonnull %6, ptr noundef nonnull %11) #4
  %33 = load i64, ptr %11, align 8, !tbaa !13
  %34 = load ptr, ptr %0, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %34, i64 16
  %36 = icmp slt i64 %33, 0
  %spec.store.select = call i64 @llvm.smin.i64(i64 %33, i64 0)
  store i64 %spec.store.select, ptr %35, align 8
  %spec.select = select i1 %36, i32 -809, i32 0
  br label %37

37:                                               ; preds = %24, %5, %21
  %.0 = phi i32 [ -803, %21 ], [ -801, %5 ], [ %spec.select, %24 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  ret i32 %.0
}

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

declare i64 @SUNBandMatrix_LowerBandwidth(ptr noundef) local_unnamed_addr #1

declare i64 @SUNBandMatrix_UpperBandwidth(ptr noundef) local_unnamed_addr #1

declare i64 @SUNBandMatrix_LDim(ptr noundef) local_unnamed_addr #1

declare ptr @SUNBandMatrix_Data(ptr noundef) local_unnamed_addr #1

declare void @N_VScale(double noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @N_VGetArrayPointer(ptr noundef) local_unnamed_addr #1

declare void @dgbtrs_(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smin.i64(i64, i64) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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, !7, i64 0}
!6 = !{!"_generic_SUNLinearSolver", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !12, i64 16}
!11 = !{!"_SUNLinearSolverContent_LapackBand", !12, i64 0, !7, i64 8, !12, i64 16}
!12 = !{!"long", !8, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!11, !7, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass