; LLVM IR from stan-dev/math :: lib/sundials_6.1.1/src/cvodes (cvodes_ls)

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

@.str.40 = external hidden unnamed_addr constant [22 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

; 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 i32 @cvLs_AccessLMem(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @CVodeGetLinSolveStats(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8) #1 {
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  store ptr %0, ptr %11, align 8, !tbaa !5
  store ptr %1, ptr %12, align 8, !tbaa !5
  store ptr %2, ptr %13, align 8, !tbaa !5
  store ptr %3, ptr %14, align 8, !tbaa !5
  store ptr %4, ptr %15, align 8, !tbaa !5
  store ptr %5, ptr %16, align 8, !tbaa !5
  store ptr %6, ptr %17, align 8, !tbaa !5
  store ptr %7, ptr %18, align 8, !tbaa !5
  store ptr %8, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #2
  %24 = load ptr, ptr %11, align 8, !tbaa !5
  %25 = call i32 @cvLs_AccessLMem(ptr noundef %24, ptr noundef @.str.40, ptr noundef %20, ptr noundef %21)
  store i32 %25, ptr %22, align 4, !tbaa !9
  %26 = load i32, ptr %22, align 4, !tbaa !9
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %30

28:                                               ; preds = %9
  %29 = load i32, ptr %22, align 4, !tbaa !9
  store i32 %29, ptr %10, align 4
  store i32 1, ptr %23, align 4
  br label %63

30:                                               ; preds = %9
  %31 = load ptr, ptr %21, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.CVLsMemRec, ptr %31, i32 0, i32 17
  %33 = load i64, ptr %32, align 8, !tbaa !11
  %34 = load ptr, ptr %12, align 8, !tbaa !5
  store i64 %33, ptr %34, align 8, !tbaa !15
  %35 = load ptr, ptr %21, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.CVLsMemRec, ptr %35, i32 0, i32 18
  %37 = load i64, ptr %36, align 8, !tbaa !16
  %38 = load ptr, ptr %13, align 8, !tbaa !5
  store i64 %37, ptr %38, align 8, !tbaa !15
  %39 = load ptr, ptr %21, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.CVLsMemRec, ptr %39, i32 0, i32 21
  %41 = load i64, ptr %40, align 8, !tbaa !17
  %42 = load ptr, ptr %14, align 8, !tbaa !5
  store i64 %41, ptr %42, align 8, !tbaa !15
  %43 = load ptr, ptr %21, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.CVLsMemRec, ptr %43, i32 0, i32 23
  %45 = load i64, ptr %44, align 8, !tbaa !18
  %46 = load ptr, ptr %15, align 8, !tbaa !5
  store i64 %45, ptr %46, align 8, !tbaa !15
  %47 = load ptr, ptr %21, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.CVLsMemRec, ptr %47, i32 0, i32 20
  %49 = load i64, ptr %48, align 8, !tbaa !19
  %50 = load ptr, ptr %16, align 8, !tbaa !5
  store i64 %49, ptr %50, align 8, !tbaa !15
  %51 = load ptr, ptr %21, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.CVLsMemRec, ptr %51, i32 0, i32 22
  %53 = load i64, ptr %52, align 8, !tbaa !20
  %54 = load ptr, ptr %17, align 8, !tbaa !5
  store i64 %53, ptr %54, align 8, !tbaa !15
  %55 = load ptr, ptr %21, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.CVLsMemRec, ptr %55, i32 0, i32 24
  %57 = load i64, ptr %56, align 8, !tbaa !21
  %58 = load ptr, ptr %18, align 8, !tbaa !5
  store i64 %57, ptr %58, align 8, !tbaa !15
  %59 = load ptr, ptr %21, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.CVLsMemRec, ptr %59, i32 0, i32 25
  %61 = load i64, ptr %60, align 8, !tbaa !22
  %62 = load ptr, ptr %19, align 8, !tbaa !5
  store i64 %61, ptr %62, align 8, !tbaa !15
  store i32 0, ptr %10, align 4
  store i32 1, ptr %23, align 4
  br label %63

63:                                               ; preds = %30, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #2
  %64 = load i32, ptr %10, align 4
  ret i32 %64
}

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, !14, i64 120}
!12 = !{!"CVLsMemRec", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !13, i64 40, !13, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !14, i64 112, !14, i64 120, !14, i64 128, !14, i64 136, !14, i64 144, !14, i64 152, !14, i64 160, !14, i64 168, !14, i64 176, !14, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !10, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !10, i64 264, !6, i64 272, !6, i64 280, !10, i64 288}
!13 = !{!"double", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!14, !14, i64 0}
!16 = !{!12, !14, i64 128}
!17 = !{!12, !14, i64 152}
!18 = !{!12, !14, i64 168}
!19 = !{!12, !14, i64 144}
!20 = !{!12, !14, i64 160}
!21 = !{!12, !14, i64 176}
!22 = !{!12, !14, i64 184}


; 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.40 = external hidden unnamed_addr constant [22 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

; Function Attrs: mustprogress 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 i32 @cvLs_AccessLMem(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @CVodeGetLinSolveStats(ptr noundef %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef writeonly %5, ptr nocapture noundef writeonly %6, ptr nocapture noundef writeonly %7, ptr nocapture noundef writeonly %8) local_unnamed_addr #1 {
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #2
  %12 = call i32 @cvLs_AccessLMem(ptr noundef %0, ptr noundef nonnull @.str.40, ptr noundef nonnull %10, ptr noundef nonnull %11)
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %13, label %31

13:                                               ; preds = %9
  %14 = load ptr, ptr %11, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %14, i64 120
  %16 = load i64, ptr %15, align 8, !tbaa !9
  store i64 %16, ptr %1, align 8, !tbaa !14
  %17 = getelementptr inbounds i8, ptr %14, i64 128
  %18 = load i64, ptr %17, align 8, !tbaa !15
  store i64 %18, ptr %2, align 8, !tbaa !14
  %19 = getelementptr inbounds i8, ptr %14, i64 152
  %20 = load i64, ptr %19, align 8, !tbaa !16
  store i64 %20, ptr %3, align 8, !tbaa !14
  %21 = getelementptr inbounds i8, ptr %14, i64 168
  %22 = load i64, ptr %21, align 8, !tbaa !17
  store i64 %22, ptr %4, align 8, !tbaa !14
  %23 = getelementptr inbounds i8, ptr %14, i64 144
  %24 = load i64, ptr %23, align 8, !tbaa !18
  store i64 %24, ptr %5, align 8, !tbaa !14
  %25 = getelementptr inbounds i8, ptr %14, i64 160
  %26 = load i64, ptr %25, align 8, !tbaa !19
  store i64 %26, ptr %6, align 8, !tbaa !14
  %27 = getelementptr inbounds i8, ptr %14, i64 176
  %28 = load i64, ptr %27, align 8, !tbaa !20
  store i64 %28, ptr %7, align 8, !tbaa !14
  %29 = getelementptr inbounds i8, ptr %14, i64 184
  %30 = load i64, ptr %29, align 8, !tbaa !21
  store i64 %30, ptr %8, align 8, !tbaa !14
  br label %31

31:                                               ; preds = %9, %13
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #2
  ret i32 %12
}

attributes #0 = { mustprogress 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, !13, i64 120}
!10 = !{!"CVLsMemRec", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !12, i64 40, !12, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !13, i64 112, !13, i64 120, !13, i64 128, !13, i64 136, !13, i64 144, !13, i64 152, !13, i64 160, !13, i64 168, !13, i64 176, !13, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !11, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !11, i64 264, !6, i64 272, !6, i64 280, !11, i64 288}
!11 = !{!"int", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!10, !13, i64 128}
!16 = !{!10, !13, i64 152}
!17 = !{!10, !13, i64 168}
!18 = !{!10, !13, i64 144}
!19 = !{!10, !13, i64 160}
!20 = !{!10, !13, i64 176}
!21 = !{!10, !13, i64 184}


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