; LLVM IR from simbody/simbody :: SimTKmath/Integrators/src/CPodes/sundials/src/cpodes (cpodes)

; 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.CPodeMemRec = type { double, i32, ptr, ptr, ptr, i32, i32, i32, double, double, ptr, ptr, ptr, [13 x ptr], ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, double, double, double, double, double, double, double, double, [14 x double], [6 x double], [13 x double], [13 x double], double, double, double, double, double, double, double, i32, i32, i32, i32, i64, i64, i32, i32, ptr, ptr, ptr, ptr, double, ptr, ptr, ptr, i64, i64, double, i32, i32, i32, ptr, ptr, ptr, ptr, i32, i64, i64, i64, i64, i32, i32, ptr, ptr, i32, i32, double, double, ptr, [13 x ptr], ptr, ptr, ptr, ptr, double, i64, i64, i32, i32, i32, i64, i64, i32, i32, double, i32, i64, i32, i32, i32, i32, double, double, double, i64, i64, i64, i64, i64, i64, i32, double, double, double, i64, i64, i64, i64, i64, i64, ptr, ptr, ptr, ptr, ptr, i32, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i64, double, double, double, i32, double, i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, i32, [6 x [4 x double]], i32, i64, i32, ptr, i32, ptr, ptr, ptr, ptr, double, double, double, ptr, ptr, ptr, double, i32, i32, i64, double, double, i32, i32, ptr, ptr }

@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [54 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: nounwind uwtable
declare dso_local void @cpProcessError(ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ...) #1

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

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

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

14:                                               ; preds = %4
  call void (ptr, i32, ptr, ptr, ptr, ...) @cpProcessError(ptr noundef null, i32 noundef -21, ptr noundef @.str, ptr noundef @.str.27, ptr noundef @.str.8)
  store i32 -21, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %41

15:                                               ; preds = %4
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %16, ptr %10, align 8, !tbaa !5
  %17 = load ptr, ptr %10, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.CPodeMemRec, ptr %17, i32 0, i32 94
  %19 = load i32, ptr %18, align 8, !tbaa !9
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %23

21:                                               ; preds = %15
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  call void (ptr, i32, ptr, ptr, ptr, ...) @cpProcessError(ptr noundef %22, i32 noundef -30, ptr noundef @.str, ptr noundef @.str.27, ptr noundef @.str.28)
  store i32 -30, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %41

23:                                               ; preds = %15
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = load ptr, ptr %10, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.CPodeMemRec, ptr %25, i32 0, i32 84
  %27 = getelementptr inbounds [13 x ptr], ptr %26, i64 0, i64 0
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  call void @N_VScale(double noundef 1.000000e+00, ptr noundef %24, ptr noundef %28)
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.CPodeMemRec, ptr %30, i32 0, i32 77
  store ptr %29, ptr %31, align 8, !tbaa !14
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.CPodeMemRec, ptr %33, i32 0, i32 78
  store ptr %32, ptr %34, align 8, !tbaa !15
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.CPodeMemRec, ptr %35, i32 0, i32 95
  store i64 0, ptr %36, align 8, !tbaa !16
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.CPodeMemRec, ptr %37, i32 0, i32 96
  store i64 0, ptr %38, align 8, !tbaa !17
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.CPodeMemRec, ptr %39, i32 0, i32 76
  store i32 1, ptr %40, align 4, !tbaa !18
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %41

41:                                               ; preds = %23, %21, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %42 = load i32, ptr %5, align 4
  ret i32 %42
}

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 = { "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, !12, i64 1200}
!10 = !{!"CPodeMemRec", !11, i64 0, !12, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !12, i64 44, !12, i64 48, !11, i64 56, !11, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !7, i64 96, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !12, i64 248, !12, i64 252, !12, i64 256, !12, i64 260, !12, i64 264, !11, i64 272, !11, i64 280, !11, i64 288, !11, i64 296, !11, i64 304, !11, i64 312, !11, i64 320, !11, i64 328, !7, i64 336, !7, i64 448, !7, i64 496, !7, i64 600, !11, i64 704, !11, i64 712, !11, i64 720, !11, i64 728, !11, i64 736, !11, i64 744, !11, i64 752, !12, i64 760, !12, i64 764, !12, i64 768, !12, i64 772, !13, i64 776, !13, i64 784, !12, i64 792, !12, i64 796, !6, i64 800, !6, i64 808, !6, i64 816, !6, i64 824, !11, i64 832, !6, i64 840, !6, i64 848, !6, i64 856, !13, i64 864, !13, i64 872, !11, i64 880, !12, i64 888, !12, i64 892, !12, i64 896, !6, i64 904, !6, i64 912, !6, i64 920, !6, i64 928, !12, i64 936, !13, i64 944, !13, i64 952, !13, i64 960, !13, i64 968, !12, i64 976, !12, i64 980, !6, i64 984, !6, i64 992, !12, i64 1000, !12, i64 1004, !11, i64 1008, !11, i64 1016, !6, i64 1024, !7, i64 1032, !6, i64 1136, !6, i64 1144, !6, i64 1152, !6, i64 1160, !11, i64 1168, !13, i64 1176, !13, i64 1184, !12, i64 1192, !12, i64 1196, !12, i64 1200, !13, i64 1208, !13, i64 1216, !12, i64 1224, !12, i64 1228, !11, i64 1232, !12, i64 1240, !13, i64 1248, !12, i64 1256, !12, i64 1260, !12, i64 1264, !12, i64 1268, !11, i64 1272, !11, i64 1280, !11, i64 1288, !13, i64 1296, !13, i64 1304, !13, i64 1312, !13, i64 1320, !13, i64 1328, !13, i64 1336, !12, i64 1344, !11, i64 1352, !11, i64 1360, !11, i64 1368, !13, i64 1376, !13, i64 1384, !13, i64 1392, !13, i64 1400, !13, i64 1408, !13, i64 1416, !6, i64 1424, !6, i64 1432, !6, i64 1440, !6, i64 1448, !6, i64 1456, !12, i64 1464, !6, i64 1472, !6, i64 1480, !6, i64 1488, !6, i64 1496, !6, i64 1504, !6, i64 1512, !12, i64 1520, !12, i64 1524, !13, i64 1528, !11, i64 1536, !11, i64 1544, !11, i64 1552, !12, i64 1560, !11, i64 1568, !12, i64 1576, !12, i64 1580, !12, i64 1584, !12, i64 1588, !12, i64 1592, !12, i64 1596, !6, i64 1600, !6, i64 1608, !6, i64 1616, !12, i64 1624, !7, i64 1632, !12, i64 1824, !13, i64 1832, !12, i64 1840, !6, i64 1848, !12, i64 1856, !6, i64 1864, !6, i64 1872, !6, i64 1880, !6, i64 1888, !11, i64 1896, !11, i64 1904, !11, i64 1912, !6, i64 1920, !6, i64 1928, !6, i64 1936, !11, i64 1944, !12, i64 1952, !12, i64 1956, !13, i64 1960, !11, i64 1968, !11, i64 1976, !12, i64 1984, !12, i64 1988, !6, i64 1992, !6, i64 2000}
!11 = !{!"double", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!10, !6, i64 984}
!15 = !{!10, !6, i64 992}
!16 = !{!10, !13, i64 1208}
!17 = !{!10, !13, i64 1216}
!18 = !{!10, !12, i64 980}


; 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 [7 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [54 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @cpProcessError(ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -30, 1) i32 @CPodeQuadReInit(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = icmp eq ptr %0, null
  br i1 %5, label %6, label %7

6:                                                ; preds = %4
  tail call void (ptr, i32, ptr, ptr, ptr, ...) @cpProcessError(ptr noundef null, i32 noundef -21, ptr noundef nonnull @.str, ptr noundef nonnull @.str.27, ptr noundef nonnull @.str.8)
  br label %19

7:                                                ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 1200
  %9 = load i32, ptr %8, align 8, !tbaa !5
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %7
  tail call void (ptr, i32, ptr, ptr, ptr, ...) @cpProcessError(ptr noundef nonnull %0, i32 noundef -30, ptr noundef nonnull @.str, ptr noundef nonnull @.str.27, ptr noundef nonnull @.str.28)
  br label %19

12:                                               ; preds = %7
  %13 = getelementptr inbounds i8, ptr %0, i64 1032
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  tail call void @N_VScale(double noundef 1.000000e+00, ptr noundef %3, ptr noundef %14) #3
  %15 = getelementptr inbounds i8, ptr %0, i64 984
  store ptr %1, ptr %15, align 8, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %0, i64 992
  store ptr %2, ptr %16, align 8, !tbaa !15
  %17 = getelementptr inbounds i8, ptr %0, i64 1208
  %18 = getelementptr inbounds i8, ptr %0, i64 980
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %17, i8 0, i64 16, i1 false)
  store i32 1, ptr %18, align 4, !tbaa !16
  br label %19

19:                                               ; preds = %12, %11, %6
  %.0 = phi i32 [ -21, %6 ], [ -30, %11 ], [ 0, %12 ]
  ret i32 %.0
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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" }
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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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, !10, i64 1200}
!6 = !{!"CPodeMemRec", !7, i64 0, !10, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !7, i64 56, !7, i64 64, !11, i64 72, !11, i64 80, !11, i64 88, !8, i64 96, !11, i64 200, !11, i64 208, !11, i64 216, !11, i64 224, !11, i64 232, !11, i64 240, !10, i64 248, !10, i64 252, !10, i64 256, !10, i64 260, !10, i64 264, !7, i64 272, !7, i64 280, !7, i64 288, !7, i64 296, !7, i64 304, !7, i64 312, !7, i64 320, !7, i64 328, !8, i64 336, !8, i64 448, !8, i64 496, !8, i64 600, !7, i64 704, !7, i64 712, !7, i64 720, !7, i64 728, !7, i64 736, !7, i64 744, !7, i64 752, !10, i64 760, !10, i64 764, !10, i64 768, !10, i64 772, !12, i64 776, !12, i64 784, !10, i64 792, !10, i64 796, !11, i64 800, !11, i64 808, !11, i64 816, !11, i64 824, !7, i64 832, !11, i64 840, !11, i64 848, !11, i64 856, !12, i64 864, !12, i64 872, !7, i64 880, !10, i64 888, !10, i64 892, !10, i64 896, !11, i64 904, !11, i64 912, !11, i64 920, !11, i64 928, !10, i64 936, !12, i64 944, !12, i64 952, !12, i64 960, !12, i64 968, !10, i64 976, !10, i64 980, !11, i64 984, !11, i64 992, !10, i64 1000, !10, i64 1004, !7, i64 1008, !7, i64 1016, !11, i64 1024, !8, i64 1032, !11, i64 1136, !11, i64 1144, !11, i64 1152, !11, i64 1160, !7, i64 1168, !12, i64 1176, !12, i64 1184, !10, i64 1192, !10, i64 1196, !10, i64 1200, !12, i64 1208, !12, i64 1216, !10, i64 1224, !10, i64 1228, !7, i64 1232, !10, i64 1240, !12, i64 1248, !10, i64 1256, !10, i64 1260, !10, i64 1264, !10, i64 1268, !7, i64 1272, !7, i64 1280, !7, i64 1288, !12, i64 1296, !12, i64 1304, !12, i64 1312, !12, i64 1320, !12, i64 1328, !12, i64 1336, !10, i64 1344, !7, i64 1352, !7, i64 1360, !7, i64 1368, !12, i64 1376, !12, i64 1384, !12, i64 1392, !12, i64 1400, !12, i64 1408, !12, i64 1416, !11, i64 1424, !11, i64 1432, !11, i64 1440, !11, i64 1448, !11, i64 1456, !10, i64 1464, !11, i64 1472, !11, i64 1480, !11, i64 1488, !11, i64 1496, !11, i64 1504, !11, i64 1512, !10, i64 1520, !10, i64 1524, !12, i64 1528, !7, i64 1536, !7, i64 1544, !7, i64 1552, !10, i64 1560, !7, i64 1568, !10, i64 1576, !10, i64 1580, !10, i64 1584, !10, i64 1588, !10, i64 1592, !10, i64 1596, !11, i64 1600, !11, i64 1608, !11, i64 1616, !10, i64 1624, !8, i64 1632, !10, i64 1824, !12, i64 1832, !10, i64 1840, !11, i64 1848, !10, i64 1856, !11, i64 1864, !11, i64 1872, !11, i64 1880, !11, i64 1888, !7, i64 1896, !7, i64 1904, !7, i64 1912, !11, i64 1920, !11, i64 1928, !11, i64 1936, !7, i64 1944, !10, i64 1952, !10, i64 1956, !12, i64 1960, !7, i64 1968, !7, i64 1976, !10, i64 1984, !10, i64 1988, !11, i64 1992, !11, i64 2000}
!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 = !{!11, !11, i64 0}
!14 = !{!6, !11, i64 984}
!15 = !{!6, !11, i64 992}
!16 = !{!6, !10, i64 980}


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