; 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 uwtable
define dso_local double @normalize_gaussian_primitive(double noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3) #0 {
  %5 = alloca double, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store double %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store i64 %2, ptr %7, align 8, !tbaa !9
  store i64 %3, ptr %8, align 8, !tbaa !9
  %9 = load i64, ptr %6, align 8, !tbaa !9
  %10 = load i64, ptr %7, align 8, !tbaa !9
  %11 = add i64 %9, %10
  %12 = load i64, ptr %8, align 8, !tbaa !9
  %13 = add i64 %11, %12
  %14 = uitofp i64 %13 to double
  %15 = fadd double %14, 7.500000e-01
  %16 = call double @pow(double noundef 2.000000e+00, double noundef %15) #4
  %17 = load double, ptr %5, align 8, !tbaa !5
  %18 = load i64, ptr %6, align 8, !tbaa !9
  %19 = load i64, ptr %7, align 8, !tbaa !9
  %20 = add i64 %18, %19
  %21 = load i64, ptr %8, align 8, !tbaa !9
  %22 = add i64 %20, %21
  %23 = uitofp i64 %22 to double
  %24 = call double @llvm.fmuladd.f64(double 5.000000e-01, double %23, double 7.500000e-01)
  %25 = call double @pow(double noundef %17, double noundef %24) #4
  %26 = fmul double %16, %25
  %27 = load i64, ptr %6, align 8, !tbaa !9
  %28 = mul i64 2, %27
  %29 = sub i64 %28, 1
  %30 = call i64 @double_factorial(i64 noundef %29)
  %31 = load i64, ptr %7, align 8, !tbaa !9
  %32 = mul i64 2, %31
  %33 = sub i64 %32, 1
  %34 = call i64 @double_factorial(i64 noundef %33)
  %35 = mul nsw i64 %30, %34
  %36 = load i64, ptr %8, align 8, !tbaa !9
  %37 = mul i64 2, %36
  %38 = sub i64 %37, 1
  %39 = call i64 @double_factorial(i64 noundef %38)
  %40 = mul nsw i64 %35, %39
  %41 = sitofp i64 %40 to double
  %42 = fmul double %41, 0x401645F7C63F2C6B
  %43 = call double @sqrt(double noundef %42) #4
  %44 = fdiv double %26, %43
  ret double %44
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

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

declare i64 @double_factorial(i64 noundef) #3

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 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { "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 = !{!"long", !7, 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: nounwind uwtable
define dso_local double @normalize_gaussian_primitive(double noundef %0, i64 noundef %1, i64 noundef %2, i64 noundef %3) local_unnamed_addr #0 {
  %5 = add i64 %2, %1
  %6 = add i64 %5, %3
  %7 = uitofp i64 %6 to double
  %8 = fadd double %7, 7.500000e-01
  %exp2 = tail call double @exp2(double %8) #4
  %9 = tail call double @llvm.fmuladd.f64(double %7, double 5.000000e-01, double 7.500000e-01)
  %10 = tail call double @pow(double noundef %0, double noundef %9) #4
  %11 = fmul double %exp2, %10
  %12 = shl i64 %1, 1
  %13 = add i64 %12, -1
  %14 = tail call i64 @double_factorial(i64 noundef %13) #4
  %15 = shl i64 %2, 1
  %16 = add i64 %15, -1
  %17 = tail call i64 @double_factorial(i64 noundef %16) #4
  %18 = mul nsw i64 %17, %14
  %19 = shl i64 %3, 1
  %20 = add i64 %19, -1
  %21 = tail call i64 @double_factorial(i64 noundef %20) #4
  %22 = mul nsw i64 %18, %21
  %23 = sitofp i64 %22 to double
  %24 = fmul double %23, 0x401645F7C63F2C6B
  %25 = tail call double @sqrt(double noundef %24) #4
  %26 = fdiv double %11, %25
  ret double %26
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

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

declare i64 @double_factorial(i64 noundef) local_unnamed_addr #3

declare double @exp2(double) local_unnamed_addr

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


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