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

; 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_N_Vector = type { ptr, ptr }
%struct._N_VectorContent_Serial = type { i64, i32, ptr }

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

declare ptr @N_VNew_Serial(i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @RefSol(double noundef %0, ptr noundef %1) #2 {
  %3 = alloca double, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca i32, align 4
  store double %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %13 = call ptr @N_VNew_Serial(i64 noundef 2)
  store ptr %13, ptr %6, align 8, !tbaa !9
  %14 = call ptr @N_VNew_Serial(i64 noundef 2)
  store ptr %14, ptr %7, align 8, !tbaa !9
  %15 = load ptr, ptr %6, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct._generic_N_Vector, ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = getelementptr inbounds %struct._N_VectorContent_Serial, ptr %17, i32 0, i32 2
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  %20 = getelementptr inbounds double, ptr %19, i64 0
  store double 0.000000e+00, ptr %20, align 8, !tbaa !5
  %21 = load ptr, ptr %6, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct._generic_N_Vector, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = getelementptr inbounds %struct._N_VectorContent_Serial, ptr %23, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !13
  %26 = getelementptr inbounds double, ptr %25, i64 1
  store double 0.000000e+00, ptr %26, align 8, !tbaa !5
  store double 0x3D06849B86A12B9B, ptr %8, align 8, !tbaa !5
  %27 = call ptr @CPodeCreate(i32 noundef 1, i32 noundef 2, i32 noundef 2)
  store ptr %27, ptr %5, align 8, !tbaa !9
  %28 = load ptr, ptr %5, align 8, !tbaa !9
  %29 = call i32 @CPodeSetMaxNumSteps(ptr noundef %28, i64 noundef 100000)
  store i32 %29, ptr %12, align 4, !tbaa !17
  %30 = load ptr, ptr %5, align 8, !tbaa !9
  %31 = load ptr, ptr %6, align 8, !tbaa !9
  %32 = load ptr, ptr %7, align 8, !tbaa !9
  %33 = load double, ptr %8, align 8, !tbaa !5
  %34 = call i32 @CPodeInit(ptr noundef %30, ptr noundef @fref, ptr noundef null, double noundef 0.000000e+00, ptr noundef %31, ptr noundef %32, i32 noundef 1, double noundef %33, ptr noundef %8)
  store i32 %34, ptr %12, align 4, !tbaa !17
  %35 = load ptr, ptr %5, align 8, !tbaa !9
  %36 = call i32 @CPDense(ptr noundef %35, i32 noundef 2)
  store i32 %36, ptr %12, align 4, !tbaa !17
  %37 = load ptr, ptr %5, align 8, !tbaa !9
  %38 = load double, ptr %3, align 8, !tbaa !5
  %39 = call i32 @CPodeSetStopTime(ptr noundef %37, double noundef %38)
  store i32 %39, ptr %12, align 4, !tbaa !17
  %40 = load ptr, ptr %5, align 8, !tbaa !9
  %41 = load double, ptr %3, align 8, !tbaa !5
  %42 = load ptr, ptr %6, align 8, !tbaa !9
  %43 = load ptr, ptr %7, align 8, !tbaa !9
  %44 = call i32 @CPode(ptr noundef %40, double noundef %41, ptr noundef %9, ptr noundef %42, ptr noundef %43, i32 noundef 3)
  store i32 %44, ptr %12, align 4, !tbaa !17
  %45 = load ptr, ptr %6, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct._generic_N_Vector, ptr %45, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !11
  %48 = getelementptr inbounds %struct._N_VectorContent_Serial, ptr %47, i32 0, i32 2
  %49 = load ptr, ptr %48, align 8, !tbaa !13
  %50 = getelementptr inbounds double, ptr %49, i64 0
  %51 = load double, ptr %50, align 8, !tbaa !5
  store double %51, ptr %10, align 8, !tbaa !5
  %52 = load ptr, ptr %6, align 8, !tbaa !9
  %53 = getelementptr inbounds %struct._generic_N_Vector, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !11
  %55 = getelementptr inbounds %struct._N_VectorContent_Serial, ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !13
  %57 = getelementptr inbounds double, ptr %56, i64 1
  %58 = load double, ptr %57, align 8, !tbaa !5
  store double %58, ptr %11, align 8, !tbaa !5
  %59 = load double, ptr %10, align 8, !tbaa !5
  %60 = call double @cos(double noundef %59) #4
  %61 = load ptr, ptr %4, align 8, !tbaa !9
  %62 = getelementptr inbounds %struct._generic_N_Vector, ptr %61, i32 0, i32 0
  %63 = load ptr, ptr %62, align 8, !tbaa !11
  %64 = getelementptr inbounds %struct._N_VectorContent_Serial, ptr %63, i32 0, i32 2
  %65 = load ptr, ptr %64, align 8, !tbaa !13
  %66 = getelementptr inbounds double, ptr %65, i64 0
  store double %60, ptr %66, align 8, !tbaa !5
  %67 = load double, ptr %10, align 8, !tbaa !5
  %68 = call double @sin(double noundef %67) #4
  %69 = load ptr, ptr %4, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct._generic_N_Vector, ptr %69, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !11
  %72 = getelementptr inbounds %struct._N_VectorContent_Serial, ptr %71, i32 0, i32 2
  %73 = load ptr, ptr %72, align 8, !tbaa !13
  %74 = getelementptr inbounds double, ptr %73, i64 1
  store double %68, ptr %74, align 8, !tbaa !5
  %75 = load double, ptr %11, align 8, !tbaa !5
  %76 = fneg double %75
  %77 = load double, ptr %10, align 8, !tbaa !5
  %78 = call double @sin(double noundef %77) #4
  %79 = fmul double %76, %78
  %80 = load ptr, ptr %4, align 8, !tbaa !9
  %81 = getelementptr inbounds %struct._generic_N_Vector, ptr %80, i32 0, i32 0
  %82 = load ptr, ptr %81, align 8, !tbaa !11
  %83 = getelementptr inbounds %struct._N_VectorContent_Serial, ptr %82, i32 0, i32 2
  %84 = load ptr, ptr %83, align 8, !tbaa !13
  %85 = getelementptr inbounds double, ptr %84, i64 2
  store double %79, ptr %85, align 8, !tbaa !5
  %86 = load double, ptr %11, align 8, !tbaa !5
  %87 = load double, ptr %10, align 8, !tbaa !5
  %88 = call double @cos(double noundef %87) #4
  %89 = fmul double %86, %88
  %90 = load ptr, ptr %4, align 8, !tbaa !9
  %91 = getelementptr inbounds %struct._generic_N_Vector, ptr %90, i32 0, i32 0
  %92 = load ptr, ptr %91, align 8, !tbaa !11
  %93 = getelementptr inbounds %struct._N_VectorContent_Serial, ptr %92, i32 0, i32 2
  %94 = load ptr, ptr %93, align 8, !tbaa !13
  %95 = getelementptr inbounds double, ptr %94, i64 3
  store double %89, ptr %95, align 8, !tbaa !5
  %96 = load ptr, ptr %6, align 8, !tbaa !9
  call void @N_VDestroy_Serial(ptr noundef %96)
  %97 = load ptr, ptr %7, align 8, !tbaa !9
  call void @N_VDestroy_Serial(ptr noundef %97)
  call void @CPodeFree(ptr noundef %5)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

declare ptr @CPodeCreate(i32 noundef, i32 noundef, i32 noundef) #1

declare i32 @CPodeInit(ptr noundef, ptr noundef, ptr noundef, double noundef, ptr noundef, ptr noundef, i32 noundef, double noundef, ptr noundef) #1

declare i32 @CPodeSetMaxNumSteps(ptr noundef, i64 noundef) #1

declare i32 @CPodeSetStopTime(ptr noundef, double noundef) #1

declare i32 @CPDense(ptr noundef, i32 noundef) #1

declare void @N_VDestroy_Serial(ptr noundef) #1

declare void @CPodeFree(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 i32 @CPode(ptr noundef, double noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden i32 @fref(double noundef, ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind
declare double @cos(double noundef) #3

; Function Attrs: nounwind
declare double @sin(double noundef) #3

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 "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 #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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_generic_N_Vector", !10, i64 0, !10, i64 8}
!13 = !{!14, !10, i64 16}
!14 = !{!"_N_VectorContent_Serial", !15, i64 0, !16, i64 8, !10, i64 16}
!15 = !{!"long", !7, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!16, !16, i64 0}


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

declare ptr @N_VNew_Serial(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @RefSol(double noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %6 = tail call ptr @N_VNew_Serial(i64 noundef 2) #5
  %7 = tail call ptr @N_VNew_Serial(i64 noundef 2) #5
  %8 = load ptr, ptr %6, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !10
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %10, i8 0, i64 16, i1 false)
  store double 0x3D06849B86A12B9B, ptr %4, align 8, !tbaa !14
  %11 = tail call ptr @CPodeCreate(i32 noundef 1, i32 noundef 2, i32 noundef 2) #5
  store ptr %11, ptr %3, align 8, !tbaa !16
  %12 = tail call i32 @CPodeSetMaxNumSteps(ptr noundef %11, i64 noundef 100000) #5
  %13 = call i32 @CPodeInit(ptr noundef %11, ptr noundef nonnull @fref, ptr noundef null, double noundef 0.000000e+00, ptr noundef nonnull %6, ptr noundef %7, i32 noundef 1, double noundef 0x3D06849B86A12B9B, ptr noundef nonnull %4) #5
  %14 = call i32 @CPDense(ptr noundef %11, i32 noundef 2) #5
  %15 = call i32 @CPodeSetStopTime(ptr noundef %11, double noundef %0) #5
  %16 = call i32 @CPode(ptr noundef %11, double noundef %0, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef %7, i32 noundef 3) #5
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %17, i64 16
  %19 = load ptr, ptr %18, align 8, !tbaa !10
  %20 = load double, ptr %19, align 8, !tbaa !14
  %21 = getelementptr inbounds i8, ptr %19, i64 8
  %22 = load double, ptr %21, align 8, !tbaa !14
  %23 = call double @cos(double noundef %20) #5
  %24 = load ptr, ptr %1, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  %26 = load ptr, ptr %25, align 8, !tbaa !10
  store double %23, ptr %26, align 8, !tbaa !14
  %27 = call double @sin(double noundef %20) #5
  %28 = load ptr, ptr %1, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 16
  %30 = load ptr, ptr %29, align 8, !tbaa !10
  %31 = getelementptr inbounds i8, ptr %30, i64 8
  store double %27, ptr %31, align 8, !tbaa !14
  %32 = fneg double %22
  %33 = call double @sin(double noundef %20) #5
  %34 = fmul double %33, %32
  %35 = load ptr, ptr %1, align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %35, i64 16
  %37 = load ptr, ptr %36, align 8, !tbaa !10
  %38 = getelementptr inbounds i8, ptr %37, i64 16
  store double %34, ptr %38, align 8, !tbaa !14
  %39 = call double @cos(double noundef %20) #5
  %40 = fmul double %22, %39
  %41 = load ptr, ptr %1, align 8, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %41, i64 16
  %43 = load ptr, ptr %42, align 8, !tbaa !10
  %44 = getelementptr inbounds i8, ptr %43, i64 24
  store double %40, ptr %44, align 8, !tbaa !14
  call void @N_VDestroy_Serial(ptr noundef nonnull %6) #5
  call void @N_VDestroy_Serial(ptr noundef %7) #5
  call void @CPodeFree(ptr noundef nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  ret void
}

declare ptr @CPodeCreate(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

declare i32 @CPodeInit(ptr noundef, ptr noundef, ptr noundef, double noundef, ptr noundef, ptr noundef, i32 noundef, double noundef, ptr noundef) local_unnamed_addr #1

declare i32 @CPodeSetMaxNumSteps(ptr noundef, i64 noundef) local_unnamed_addr #1

declare i32 @CPodeSetStopTime(ptr noundef, double noundef) local_unnamed_addr #1

declare i32 @CPDense(ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @N_VDestroy_Serial(ptr noundef) local_unnamed_addr #1

declare void @CPodeFree(ptr noundef) local_unnamed_addr #1

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

declare i32 @CPode(ptr noundef, double noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @fref(double noundef, ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #3

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

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 = { mustprogress nofree nounwind willreturn memory(write) "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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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_N_Vector", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 16}
!11 = !{!"_N_VectorContent_Serial", !12, i64 0, !13, i64 8, !7, i64 16}
!12 = !{!"long", !8, i64 0}
!13 = !{!"int", !8, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !8, i64 0}
!16 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass