; LLVM IR from microsoft/LightAIMD :: src (molecular_integral)

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

; 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: nounwind uwtable
define dso_local double @cg_kinetic_integral(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca double, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store double 0.000000e+00, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !11
  br label %9

9:                                                ; preds = %107, %2
  %10 = load i64, ptr %6, align 8, !tbaa !11
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.basis_func, ptr %11, i32 0, i32 3
  %13 = load i64, ptr %12, align 8, !tbaa !13
  %14 = icmp ult i64 %10, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %9
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %110

16:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !11
  br label %17

17:                                               ; preds = %103, %16
  %18 = load i64, ptr %8, align 8, !tbaa !11
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.basis_func, ptr %19, i32 0, i32 3
  %21 = load i64, ptr %20, align 8, !tbaa !13
  %22 = icmp ult i64 %18, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %17
  store i32 5, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %106

24:                                               ; preds = %17
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.basis_func, ptr %25, i32 0, i32 6
  %27 = load ptr, ptr %26, align 8, !tbaa !15
  %28 = load i64, ptr %6, align 8, !tbaa !11
  %29 = getelementptr inbounds double, ptr %27, i64 %28
  %30 = load double, ptr %29, align 8, !tbaa !9
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.basis_func, ptr %31, i32 0, i32 6
  %33 = load ptr, ptr %32, align 8, !tbaa !15
  %34 = load i64, ptr %8, align 8, !tbaa !11
  %35 = getelementptr inbounds double, ptr %33, i64 %34
  %36 = load double, ptr %35, align 8, !tbaa !9
  %37 = fmul double %30, %36
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.basis_func, ptr %38, i32 0, i32 5
  %40 = load ptr, ptr %39, align 8, !tbaa !16
  %41 = load i64, ptr %6, align 8, !tbaa !11
  %42 = getelementptr inbounds double, ptr %40, i64 %41
  %43 = load double, ptr %42, align 8, !tbaa !9
  %44 = fmul double %37, %43
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.basis_func, ptr %45, i32 0, i32 5
  %47 = load ptr, ptr %46, align 8, !tbaa !16
  %48 = load i64, ptr %8, align 8, !tbaa !11
  %49 = getelementptr inbounds double, ptr %47, i64 %48
  %50 = load double, ptr %49, align 8, !tbaa !9
  %51 = fmul double %44, %50
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.basis_func, ptr %52, i32 0, i32 4
  %54 = load ptr, ptr %53, align 8, !tbaa !17
  %55 = load i64, ptr %6, align 8, !tbaa !11
  %56 = getelementptr inbounds double, ptr %54, i64 %55
  %57 = load double, ptr %56, align 8, !tbaa !9
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.basis_func, ptr %58, i32 0, i32 0
  %60 = load i64, ptr %59, align 8, !tbaa !18
  %61 = load ptr, ptr %3, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.basis_func, ptr %61, i32 0, i32 1
  %63 = load i64, ptr %62, align 8, !tbaa !19
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.basis_func, ptr %64, i32 0, i32 2
  %66 = load i64, ptr %65, align 8, !tbaa !20
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.basis_func, ptr %67, i32 0, i32 8
  %69 = load double, ptr %68, align 8, !tbaa !21
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.basis_func, ptr %70, i32 0, i32 9
  %72 = load double, ptr %71, align 8, !tbaa !22
  %73 = load ptr, ptr %3, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.basis_func, ptr %73, i32 0, i32 10
  %75 = load double, ptr %74, align 8, !tbaa !23
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.basis_func, ptr %76, i32 0, i32 4
  %78 = load ptr, ptr %77, align 8, !tbaa !17
  %79 = load i64, ptr %8, align 8, !tbaa !11
  %80 = getelementptr inbounds double, ptr %78, i64 %79
  %81 = load double, ptr %80, align 8, !tbaa !9
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.basis_func, ptr %82, i32 0, i32 0
  %84 = load i64, ptr %83, align 8, !tbaa !18
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.basis_func, ptr %85, i32 0, i32 1
  %87 = load i64, ptr %86, align 8, !tbaa !19
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.basis_func, ptr %88, i32 0, i32 2
  %90 = load i64, ptr %89, align 8, !tbaa !20
  %91 = load ptr, ptr %4, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.basis_func, ptr %91, i32 0, i32 8
  %93 = load double, ptr %92, align 8, !tbaa !21
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.basis_func, ptr %94, i32 0, i32 9
  %96 = load double, ptr %95, align 8, !tbaa !22
  %97 = load ptr, ptr %4, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.basis_func, ptr %97, i32 0, i32 10
  %99 = load double, ptr %98, align 8, !tbaa !23
  %100 = call double @pg_kinetic_integral(double noundef %57, i64 noundef %60, i64 noundef %63, i64 noundef %66, double noundef %69, double noundef %72, double noundef %75, double noundef %81, i64 noundef %84, i64 noundef %87, i64 noundef %90, double noundef %93, double noundef %96, double noundef %99)
  %101 = load double, ptr %5, align 8, !tbaa !9
  %102 = call double @llvm.fmuladd.f64(double %51, double %100, double %101)
  store double %102, ptr %5, align 8, !tbaa !9
  br label %103

103:                                              ; preds = %24
  %104 = load i64, ptr %8, align 8, !tbaa !11
  %105 = add i64 %104, 1
  store i64 %105, ptr %8, align 8, !tbaa !11
  br label %17, !llvm.loop !24

106:                                              ; preds = %23
  br label %107

107:                                              ; preds = %106
  %108 = load i64, ptr %6, align 8, !tbaa !11
  %109 = add i64 %108, 1
  store i64 %109, ptr %6, align 8, !tbaa !11
  br label %9, !llvm.loop !26

110:                                              ; preds = %15
  %111 = load double, ptr %5, align 8, !tbaa !9
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret double %111
}

; Function Attrs: nounwind uwtable
declare hidden double @pg_kinetic_integral(double noundef, i64 noundef, i64 noundef, i64 noundef, double noundef, double noundef, double noundef, double noundef, i64 noundef, i64 noundef, i64 noundef, double noundef, double noundef, double noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 24}
!14 = !{!"basis_func", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80}
!15 = !{!14, !6, i64 48}
!16 = !{!14, !6, i64 40}
!17 = !{!14, !6, i64 32}
!18 = !{!14, !12, i64 0}
!19 = !{!14, !12, i64 8}
!20 = !{!14, !12, i64 16}
!21 = !{!14, !10, i64 64}
!22 = !{!14, !10, i64 72}
!23 = !{!14, !10, i64 80}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = distinct !{!26, !25}


; 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: nounwind uwtable
define dso_local double @cg_kinetic_integral(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %.not = icmp eq i64 %4, 0
  br i1 %.not, label %._crit_edge37, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %2
  %5 = getelementptr inbounds i8, ptr %1, i64 24
  %6 = getelementptr inbounds i8, ptr %0, i64 48
  %7 = getelementptr inbounds i8, ptr %1, i64 48
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  %9 = getelementptr inbounds i8, ptr %1, i64 40
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = getelementptr inbounds i8, ptr %0, i64 64
  %14 = getelementptr inbounds i8, ptr %0, i64 72
  %15 = getelementptr inbounds i8, ptr %0, i64 80
  %16 = getelementptr inbounds i8, ptr %1, i64 32
  %17 = getelementptr inbounds i8, ptr %1, i64 8
  %18 = getelementptr inbounds i8, ptr %1, i64 16
  %19 = getelementptr inbounds i8, ptr %1, i64 64
  %20 = getelementptr inbounds i8, ptr %1, i64 72
  %21 = getelementptr inbounds i8, ptr %1, i64 80
  %22 = load i64, ptr %5, align 8, !tbaa !5
  %.not39 = icmp eq i64 %22, 0
  br i1 %.not39, label %._crit_edge37, label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %23 = phi i64 [ %25, %._crit_edge ], [ %4, %.preheader.lr.ph ]
  %24 = phi i64 [ %26, %._crit_edge ], [ 1, %.preheader.lr.ph ]
  %.03136 = phi i64 [ %27, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %.03235 = phi double [ %.1.lcssa, %._crit_edge ], [ 0.000000e+00, %.preheader.lr.ph ]
  %.not40 = icmp eq i64 %24, 0
  br i1 %.not40, label %._crit_edge, label %.lr.ph

._crit_edge37:                                    ; preds = %._crit_edge, %.preheader.lr.ph, %2
  %.032.lcssa = phi double [ 0.000000e+00, %2 ], [ 0.000000e+00, %.preheader.lr.ph ], [ %.1.lcssa, %._crit_edge ]
  ret double %.032.lcssa

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i64, ptr %3, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %25 = phi i64 [ %23, %.preheader ], [ %.pre, %._crit_edge.loopexit ]
  %26 = phi i64 [ 0, %.preheader ], [ %65, %._crit_edge.loopexit ]
  %.1.lcssa = phi double [ %.03235, %.preheader ], [ %63, %._crit_edge.loopexit ]
  %27 = add nuw i64 %.03136, 1
  %28 = icmp ult i64 %27, %25
  br i1 %28, label %.preheader, label %._crit_edge37, !llvm.loop !12

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.034 = phi i64 [ %64, %.lr.ph ], [ 0, %.preheader ]
  %.133 = phi double [ %63, %.lr.ph ], [ %.03235, %.preheader ]
  %29 = load ptr, ptr %6, align 8, !tbaa !15
  %30 = getelementptr inbounds double, ptr %29, i64 %.03136
  %31 = load double, ptr %30, align 8, !tbaa !16
  %32 = load ptr, ptr %7, align 8, !tbaa !15
  %33 = getelementptr inbounds double, ptr %32, i64 %.034
  %34 = load double, ptr %33, align 8, !tbaa !16
  %35 = fmul double %31, %34
  %36 = load ptr, ptr %8, align 8, !tbaa !17
  %37 = getelementptr inbounds double, ptr %36, i64 %.03136
  %38 = load double, ptr %37, align 8, !tbaa !16
  %39 = fmul double %35, %38
  %40 = load ptr, ptr %9, align 8, !tbaa !17
  %41 = getelementptr inbounds double, ptr %40, i64 %.034
  %42 = load double, ptr %41, align 8, !tbaa !16
  %43 = fmul double %39, %42
  %44 = load ptr, ptr %10, align 8, !tbaa !18
  %45 = getelementptr inbounds double, ptr %44, i64 %.03136
  %46 = load double, ptr %45, align 8, !tbaa !16
  %47 = load i64, ptr %0, align 8, !tbaa !19
  %48 = load i64, ptr %11, align 8, !tbaa !20
  %49 = load i64, ptr %12, align 8, !tbaa !21
  %50 = load double, ptr %13, align 8, !tbaa !22
  %51 = load double, ptr %14, align 8, !tbaa !23
  %52 = load double, ptr %15, align 8, !tbaa !24
  %53 = load ptr, ptr %16, align 8, !tbaa !18
  %54 = getelementptr inbounds double, ptr %53, i64 %.034
  %55 = load double, ptr %54, align 8, !tbaa !16
  %56 = load i64, ptr %1, align 8, !tbaa !19
  %57 = load i64, ptr %17, align 8, !tbaa !20
  %58 = load i64, ptr %18, align 8, !tbaa !21
  %59 = load double, ptr %19, align 8, !tbaa !22
  %60 = load double, ptr %20, align 8, !tbaa !23
  %61 = load double, ptr %21, align 8, !tbaa !24
  %62 = tail call double @pg_kinetic_integral(double noundef %46, i64 noundef %47, i64 noundef %48, i64 noundef %49, double noundef %50, double noundef %51, double noundef %52, double noundef %55, i64 noundef %56, i64 noundef %57, i64 noundef %58, double noundef %59, double noundef %60, double noundef %61)
  %63 = tail call double @llvm.fmuladd.f64(double %43, double %62, double %.133)
  %64 = add nuw i64 %.034, 1
  %65 = load i64, ptr %5, align 8, !tbaa !5
  %66 = icmp ult i64 %64, %65
  br i1 %66, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !25
}

; Function Attrs: nounwind uwtable
declare hidden double @pg_kinetic_integral(double noundef, i64 noundef, i64 noundef, i64 noundef, double noundef, double noundef, double noundef, double noundef, i64 noundef, i64 noundef, i64 noundef, double noundef, double noundef, double noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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" }

!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 24}
!6 = !{!"basis_func", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = distinct !{!12, !13, !14}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!"llvm.loop.unswitch.partial.disable"}
!15 = !{!6, !10, i64 48}
!16 = !{!11, !11, i64 0}
!17 = !{!6, !10, i64 40}
!18 = !{!6, !10, i64 32}
!19 = !{!6, !7, i64 0}
!20 = !{!6, !7, i64 8}
!21 = !{!6, !7, i64 16}
!22 = !{!6, !11, i64 64}
!23 = !{!6, !11, i64 72}
!24 = !{!6, !11, i64 80}
!25 = distinct !{!25, !13}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass