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

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

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #0

declare i64 @double_factorial(i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local double @normalize_contracted_gaussian_func(i64 noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #2 {
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca double, align 8
  %17 = alloca i64, align 8
  %18 = alloca i32, align 4
  %19 = alloca i64, align 8
  store i64 %0, ptr %8, align 8, !tbaa !5
  store i64 %1, ptr %9, align 8, !tbaa !5
  store i64 %2, ptr %10, align 8, !tbaa !5
  store i64 %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !9
  store ptr %5, ptr %13, align 8, !tbaa !9
  store ptr %6, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %20 = load i64, ptr %9, align 8, !tbaa !5
  %21 = load i64, ptr %10, align 8, !tbaa !5
  %22 = add i64 %20, %21
  %23 = load i64, ptr %11, align 8, !tbaa !5
  %24 = add i64 %22, %23
  store i64 %24, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  store double 0.000000e+00, ptr %16, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  store i64 0, ptr %17, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %76, %7
  %26 = load i64, ptr %17, align 8, !tbaa !5
  %27 = load i64, ptr %8, align 8, !tbaa !5
  %28 = icmp ult i64 %26, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  store i32 2, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  br label %79

30:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  store i64 0, ptr %19, align 8, !tbaa !5
  br label %31

31:                                               ; preds = %72, %30
  %32 = load i64, ptr %19, align 8, !tbaa !5
  %33 = load i64, ptr %8, align 8, !tbaa !5
  %34 = icmp ult i64 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  store i32 5, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  br label %75

36:                                               ; preds = %31
  %37 = load ptr, ptr %14, align 8, !tbaa !9
  %38 = load i64, ptr %17, align 8, !tbaa !5
  %39 = getelementptr inbounds double, ptr %37, i64 %38
  %40 = load double, ptr %39, align 8, !tbaa !11
  %41 = load ptr, ptr %14, align 8, !tbaa !9
  %42 = load i64, ptr %19, align 8, !tbaa !5
  %43 = getelementptr inbounds double, ptr %41, i64 %42
  %44 = load double, ptr %43, align 8, !tbaa !11
  %45 = fmul double %40, %44
  %46 = load ptr, ptr %13, align 8, !tbaa !9
  %47 = load i64, ptr %17, align 8, !tbaa !5
  %48 = getelementptr inbounds double, ptr %46, i64 %47
  %49 = load double, ptr %48, align 8, !tbaa !11
  %50 = fmul double %45, %49
  %51 = load ptr, ptr %13, align 8, !tbaa !9
  %52 = load i64, ptr %19, align 8, !tbaa !5
  %53 = getelementptr inbounds double, ptr %51, i64 %52
  %54 = load double, ptr %53, align 8, !tbaa !11
  %55 = fmul double %50, %54
  %56 = load ptr, ptr %12, align 8, !tbaa !9
  %57 = load i64, ptr %17, align 8, !tbaa !5
  %58 = getelementptr inbounds double, ptr %56, i64 %57
  %59 = load double, ptr %58, align 8, !tbaa !11
  %60 = load ptr, ptr %12, align 8, !tbaa !9
  %61 = load i64, ptr %19, align 8, !tbaa !5
  %62 = getelementptr inbounds double, ptr %60, i64 %61
  %63 = load double, ptr %62, align 8, !tbaa !11
  %64 = fadd double %59, %63
  %65 = load i64, ptr %15, align 8, !tbaa !5
  %66 = uitofp i64 %65 to double
  %67 = fadd double %66, 1.500000e+00
  %68 = call double @pow(double noundef %64, double noundef %67) #4
  %69 = fdiv double %55, %68
  %70 = load double, ptr %16, align 8, !tbaa !11
  %71 = fadd double %70, %69
  store double %71, ptr %16, align 8, !tbaa !11
  br label %72

72:                                               ; preds = %36
  %73 = load i64, ptr %19, align 8, !tbaa !5
  %74 = add i64 %73, 1
  store i64 %74, ptr %19, align 8, !tbaa !5
  br label %31, !llvm.loop !13

75:                                               ; preds = %35
  br label %76

76:                                               ; preds = %75
  %77 = load i64, ptr %17, align 8, !tbaa !5
  %78 = add i64 %77, 1
  store i64 %78, ptr %17, align 8, !tbaa !5
  br label %25, !llvm.loop !15

79:                                               ; preds = %29
  %80 = load double, ptr %16, align 8, !tbaa !11
  %81 = fmul double %80, 0x401645F7C63F2C6B
  %82 = load i64, ptr %9, align 8, !tbaa !5
  %83 = mul i64 2, %82
  %84 = sub i64 %83, 1
  %85 = call i64 @double_factorial(i64 noundef %84)
  %86 = sitofp i64 %85 to double
  %87 = fmul double %81, %86
  %88 = load i64, ptr %10, align 8, !tbaa !5
  %89 = mul i64 2, %88
  %90 = sub i64 %89, 1
  %91 = call i64 @double_factorial(i64 noundef %90)
  %92 = sitofp i64 %91 to double
  %93 = fmul double %87, %92
  %94 = load i64, ptr %11, align 8, !tbaa !5
  %95 = mul i64 2, %94
  %96 = sub i64 %95, 1
  %97 = call i64 @double_factorial(i64 noundef %96)
  %98 = sitofp i64 %97 to double
  %99 = fmul double %93, %98
  %100 = load i64, ptr %15, align 8, !tbaa !5
  %101 = uitofp i64 %100 to double
  %102 = call double @pow(double noundef 2.000000e+00, double noundef %101) #4
  %103 = fdiv double %99, %102
  %104 = call double @pow(double noundef %103, double noundef -5.000000e-01) #4
  store i32 1, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  ret double %104
}

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

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

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"long", !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, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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 nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #0

declare i64 @double_factorial(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local double @normalize_contracted_gaussian_func(i64 noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, ptr nocapture noundef readonly %4, ptr nocapture noundef readonly %5, ptr nocapture noundef readonly %6) local_unnamed_addr #2 {
  %8 = add i64 %2, %1
  %9 = add i64 %8, %3
  %.not = icmp eq i64 %0, 0
  %.pre = uitofp i64 %9 to double
  br i1 %.not, label %._crit_edge, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %7
  %10 = fadd double %.pre, 1.500000e+00
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %32
  %.02733 = phi i64 [ 0, %.preheader.lr.ph ], [ %33, %32 ]
  %.02832 = phi double [ 0.000000e+00, %.preheader.lr.ph ], [ %50, %32 ]
  %11 = getelementptr inbounds double, ptr %6, i64 %.02733
  %12 = getelementptr inbounds double, ptr %5, i64 %.02733
  %13 = getelementptr inbounds double, ptr %4, i64 %.02733
  br label %34

._crit_edge.loopexit:                             ; preds = %32
  %14 = fmul double %50, 0x401645F7C63F2C6B
  br label %._crit_edge

._crit_edge:                                      ; preds = %7, %._crit_edge.loopexit
  %.028.lcssa = phi double [ %14, %._crit_edge.loopexit ], [ 0.000000e+00, %7 ]
  %15 = shl i64 %1, 1
  %16 = add i64 %15, -1
  %17 = tail call i64 @double_factorial(i64 noundef %16) #3
  %18 = sitofp i64 %17 to double
  %19 = fmul double %.028.lcssa, %18
  %20 = shl i64 %2, 1
  %21 = add i64 %20, -1
  %22 = tail call i64 @double_factorial(i64 noundef %21) #3
  %23 = sitofp i64 %22 to double
  %24 = fmul double %19, %23
  %25 = shl i64 %3, 1
  %26 = add i64 %25, -1
  %27 = tail call i64 @double_factorial(i64 noundef %26) #3
  %28 = sitofp i64 %27 to double
  %29 = fmul double %24, %28
  %exp2 = tail call double @exp2(double %.pre) #3
  %30 = fdiv double %29, %exp2
  %31 = tail call double @pow(double noundef %30, double noundef -5.000000e-01) #3
  ret double %31

32:                                               ; preds = %34
  %33 = add nuw i64 %.02733, 1
  %exitcond34.not = icmp eq i64 %33, %0
  br i1 %exitcond34.not, label %._crit_edge.loopexit, label %.preheader, !llvm.loop !5

34:                                               ; preds = %.preheader, %34
  %.031 = phi i64 [ 0, %.preheader ], [ %51, %34 ]
  %.130 = phi double [ %.02832, %.preheader ], [ %50, %34 ]
  %35 = load double, ptr %11, align 8, !tbaa !7
  %36 = getelementptr inbounds double, ptr %6, i64 %.031
  %37 = load double, ptr %36, align 8, !tbaa !7
  %38 = fmul double %35, %37
  %39 = load double, ptr %12, align 8, !tbaa !7
  %40 = fmul double %38, %39
  %41 = getelementptr inbounds double, ptr %5, i64 %.031
  %42 = load double, ptr %41, align 8, !tbaa !7
  %43 = fmul double %40, %42
  %44 = load double, ptr %13, align 8, !tbaa !7
  %45 = getelementptr inbounds double, ptr %4, i64 %.031
  %46 = load double, ptr %45, align 8, !tbaa !7
  %47 = fadd double %44, %46
  %48 = tail call double @pow(double noundef %47, double noundef %10) #3
  %49 = fdiv double %43, %48
  %50 = fadd double %.130, %49
  %51 = add nuw i64 %.031, 1
  %exitcond.not = icmp eq i64 %51, %0
  br i1 %exitcond.not, label %32, label %34, !llvm.loop !11
}

declare double @exp2(double) local_unnamed_addr

attributes #0 = { 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 #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 }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = distinct !{!11, !6}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass