; LLVM IR from bohanwang/libpgo :: src/core/solidDeformationModel (invariantBasedMaterialStVK)

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

%"class.pgo::SolidDeformationModel::InvariantBasedMaterialStVK" = type { %"class.pgo::SolidDeformationModel::InvariantBasedMaterial", double, double, double }
%"class.pgo::SolidDeformationModel::InvariantBasedMaterial" = type { 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 speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_ZNK3pgo21SolidDeformationModel26InvariantBasedMaterialStVK11compute_psiEPKd(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef %1) unnamed_addr #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %10 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds double, ptr %11, i64 0
  %13 = load double, ptr %12, align 8, !tbaa !9
  store double %13, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds double, ptr %14, i64 1
  %16 = load double, ptr %15, align 8, !tbaa !9
  store double %16, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %17 = getelementptr inbounds %"class.pgo::SolidDeformationModel::InvariantBasedMaterialStVK", ptr %10, i32 0, i32 2
  %18 = load double, ptr %17, align 8, !tbaa !11
  %19 = fmul double 1.250000e-01, %18
  %20 = load double, ptr %5, align 8, !tbaa !9
  %21 = fsub double %20, 3.000000e+00
  %22 = fmul double %19, %21
  %23 = load double, ptr %5, align 8, !tbaa !9
  %24 = fsub double %23, 3.000000e+00
  %25 = getelementptr inbounds %"class.pgo::SolidDeformationModel::InvariantBasedMaterialStVK", ptr %10, i32 0, i32 1
  %26 = load double, ptr %25, align 8, !tbaa !14
  %27 = fmul double 2.500000e-01, %26
  %28 = load double, ptr %6, align 8, !tbaa !9
  %29 = load double, ptr %5, align 8, !tbaa !9
  %30 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %29, double %28)
  %31 = fadd double %30, 3.000000e+00
  %32 = fmul double %27, %31
  %33 = call double @llvm.fmuladd.f64(double %22, double %24, double %32)
  store double %33, ptr %7, align 8, !tbaa !9
  %34 = getelementptr inbounds %"class.pgo::SolidDeformationModel::InvariantBasedMaterialStVK", ptr %10, i32 0, i32 3
  %35 = load double, ptr %34, align 8, !tbaa !15
  %36 = fcmp ogt double %35, 0.000000e+00
  br i1 %36, label %37, label %62

37:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds double, ptr %38, i64 2
  %40 = load double, ptr %39, align 8, !tbaa !9
  store double %40, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %41 = load double, ptr %8, align 8, !tbaa !9
  %42 = call double @sqrt(double noundef %41) #4
  store double %42, ptr %9, align 8, !tbaa !9
  %43 = load double, ptr %9, align 8, !tbaa !9
  %44 = fcmp olt double %43, 1.000000e+00
  br i1 %44, label %45, label %61

45:                                               ; preds = %37
  %46 = getelementptr inbounds %"class.pgo::SolidDeformationModel::InvariantBasedMaterialStVK", ptr %10, i32 0, i32 3
  %47 = load double, ptr %46, align 8, !tbaa !15
  %48 = fneg double %47
  %49 = load double, ptr %9, align 8, !tbaa !9
  %50 = fsub double %49, 1.000000e+00
  %51 = fmul double %48, %50
  %52 = load double, ptr %9, align 8, !tbaa !9
  %53 = fsub double %52, 1.000000e+00
  %54 = fmul double %51, %53
  %55 = load double, ptr %9, align 8, !tbaa !9
  %56 = fsub double %55, 1.000000e+00
  %57 = fmul double %54, %56
  %58 = fdiv double %57, 2.592000e+03
  %59 = load double, ptr %7, align 8, !tbaa !9
  %60 = fadd double %59, %58
  store double %60, ptr %7, align 8, !tbaa !9
  br label %61

61:                                               ; preds = %45, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %62

62:                                               ; preds = %61, %2
  %63 = load double, ptr %7, align 8, !tbaa !9
  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 double %63
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 16}
!12 = !{!"_ZTSN3pgo21SolidDeformationModel26InvariantBasedMaterialStVKE", !13, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!13 = !{!"_ZTSN3pgo21SolidDeformationModel22InvariantBasedMaterialE"}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !10, 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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local noundef double @_ZNK3pgo21SolidDeformationModel26InvariantBasedMaterialStVK11compute_psiEPKd(ptr nocapture noundef nonnull readonly align 8 dereferenceable(32) %0, ptr nocapture noundef readonly %1) unnamed_addr #1 align 2 {
  %3 = load double, ptr %1, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load double, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load double, ptr %6, align 8, !tbaa !9
  %8 = fmul double %7, 1.250000e-01
  %9 = fadd double %3, -3.000000e+00
  %10 = fmul double %9, %8
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load double, ptr %11, align 8, !tbaa !12
  %13 = fmul double %12, 2.500000e-01
  %14 = tail call double @llvm.fmuladd.f64(double %3, double -2.000000e+00, double %5)
  %15 = fadd double %14, 3.000000e+00
  %16 = fmul double %15, %13
  %17 = tail call double @llvm.fmuladd.f64(double %10, double %9, double %16)
  %18 = getelementptr inbounds i8, ptr %0, i64 24
  %19 = load double, ptr %18, align 8, !tbaa !13
  %20 = fcmp ogt double %19, 0.000000e+00
  br i1 %20, label %21, label %35

21:                                               ; preds = %2
  %22 = getelementptr inbounds i8, ptr %1, i64 16
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = tail call double @sqrt(double noundef %23) #3
  %25 = fcmp olt double %24, 1.000000e+00
  br i1 %25, label %26, label %35

26:                                               ; preds = %21
  %27 = load double, ptr %18, align 8, !tbaa !13
  %28 = fneg double %27
  %29 = fadd double %24, -1.000000e+00
  %30 = fmul double %29, %28
  %31 = fmul double %29, %30
  %32 = fmul double %29, %31
  %33 = fdiv double %32, 2.592000e+03
  %34 = fadd double %17, %33
  br label %35

35:                                               ; preds = %21, %26, %2
  %.1 = phi double [ %17, %2 ], [ %34, %26 ], [ %17, %21 ]
  ret double %.1
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) 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 = { 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 #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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 16}
!10 = !{!"_ZTSN3pgo21SolidDeformationModel26InvariantBasedMaterialStVKE", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"_ZTSN3pgo21SolidDeformationModel22InvariantBasedMaterialE"}
!12 = !{!10, !6, i64 8}
!13 = !{!10, !6, i64 24}


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