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

%struct.vec3d = type { double, double, double }
%struct.basis_func = type { i64, i64, i64, i64, ptr, ptr, ptr, double, double, double, double }

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #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.start.p0(i64 immarg, ptr nocapture) #2

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

; Function Attrs: nounwind uwtable
define dso_local double @basis_funcs_value(ptr noundef %0, ptr noundef %1) #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %struct.vec3d, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = 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 24, ptr %5) #5
  %12 = getelementptr inbounds %struct.vec3d, ptr %5, i32 0, i32 0
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.basis_func, ptr %13, i32 0, i32 8
  %15 = load double, ptr %14, align 8, !tbaa !9
  store double %15, ptr %12, align 8, !tbaa !13
  %16 = getelementptr inbounds %struct.vec3d, ptr %5, i32 0, i32 1
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.basis_func, ptr %17, i32 0, i32 9
  %19 = load double, ptr %18, align 8, !tbaa !15
  store double %19, ptr %16, align 8, !tbaa !16
  %20 = getelementptr inbounds %struct.vec3d, ptr %5, i32 0, i32 2
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.basis_func, ptr %21, i32 0, i32 10
  %23 = load double, ptr %22, align 8, !tbaa !17
  store double %23, ptr %20, align 8, !tbaa !18
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  call void @vec3d_subtract(ptr noundef %24, ptr noundef %5, ptr noundef %5)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %25 = call double @vec3d_norm_squared(ptr noundef %5)
  store double %25, ptr %6, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.vec3d, ptr %26, i32 0, i32 0
  %28 = load double, ptr %27, align 8, !tbaa !13
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.basis_func, ptr %29, i32 0, i32 8
  %31 = load double, ptr %30, align 8, !tbaa !9
  %32 = fsub double %28, %31
  %33 = fadd double %32, 1.000000e-100
  store double %33, ptr %7, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.vec3d, ptr %34, i32 0, i32 1
  %36 = load double, ptr %35, align 8, !tbaa !16
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.basis_func, ptr %37, i32 0, i32 9
  %39 = load double, ptr %38, align 8, !tbaa !15
  %40 = fsub double %36, %39
  %41 = fadd double %40, 1.000000e-100
  store double %41, ptr %8, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.vec3d, ptr %42, i32 0, i32 2
  %44 = load double, ptr %43, align 8, !tbaa !18
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.basis_func, ptr %45, i32 0, i32 10
  %47 = load double, ptr %46, align 8, !tbaa !17
  %48 = fsub double %44, %47
  %49 = fadd double %48, 1.000000e-100
  store double %49, ptr %9, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store double 0.000000e+00, ptr %10, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  store i64 0, ptr %11, align 8, !tbaa !20
  br label %50

50:                                               ; preds = %104, %2
  %51 = load i64, ptr %11, align 8, !tbaa !20
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.basis_func, ptr %52, i32 0, i32 3
  %54 = load i64, ptr %53, align 8, !tbaa !21
  %55 = icmp ult i64 %51, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %107

57:                                               ; preds = %50
  %58 = load ptr, ptr %3, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.basis_func, ptr %58, i32 0, i32 5
  %60 = load ptr, ptr %59, align 8, !tbaa !22
  %61 = load i64, ptr %11, align 8, !tbaa !20
  %62 = getelementptr inbounds double, ptr %60, i64 %61
  %63 = load double, 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 6
  %66 = load ptr, ptr %65, align 8, !tbaa !23
  %67 = load i64, ptr %11, align 8, !tbaa !20
  %68 = getelementptr inbounds double, ptr %66, i64 %67
  %69 = load double, ptr %68, align 8, !tbaa !19
  %70 = fmul double %63, %69
  %71 = load double, ptr %7, align 8, !tbaa !19
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.basis_func, ptr %72, i32 0, i32 0
  %74 = load i64, ptr %73, align 8, !tbaa !24
  %75 = uitofp i64 %74 to double
  %76 = call double @pow(double noundef %71, double noundef %75) #5
  %77 = fmul double %70, %76
  %78 = load double, ptr %8, align 8, !tbaa !19
  %79 = load ptr, ptr %3, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.basis_func, ptr %79, i32 0, i32 1
  %81 = load i64, ptr %80, align 8, !tbaa !25
  %82 = uitofp i64 %81 to double
  %83 = call double @pow(double noundef %78, double noundef %82) #5
  %84 = fmul double %77, %83
  %85 = load double, ptr %9, align 8, !tbaa !19
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.basis_func, ptr %86, i32 0, i32 2
  %88 = load i64, ptr %87, align 8, !tbaa !26
  %89 = uitofp i64 %88 to double
  %90 = call double @pow(double noundef %85, double noundef %89) #5
  %91 = fmul double %84, %90
  %92 = load ptr, ptr %3, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.basis_func, ptr %92, i32 0, i32 4
  %94 = load ptr, ptr %93, align 8, !tbaa !27
  %95 = load i64, ptr %11, align 8, !tbaa !20
  %96 = getelementptr inbounds double, ptr %94, i64 %95
  %97 = load double, ptr %96, align 8, !tbaa !19
  %98 = load double, ptr %6, align 8, !tbaa !19
  %99 = fmul double %97, %98
  %100 = fneg double %99
  %101 = call double @exp(double noundef %100) #5
  %102 = load double, ptr %10, align 8, !tbaa !19
  %103 = call double @llvm.fmuladd.f64(double %91, double %101, double %102)
  store double %103, ptr %10, align 8, !tbaa !19
  br label %104

104:                                              ; preds = %57
  %105 = load i64, ptr %11, align 8, !tbaa !20
  %106 = add i64 %105, 1
  store i64 %106, ptr %11, align 8, !tbaa !20
  br label %50, !llvm.loop !28

107:                                              ; preds = %56
  %108 = load double, ptr %10, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #5
  ret double %108
}

declare void @vec3d_subtract(ptr noundef, ptr noundef, ptr noundef) #4

declare double @vec3d_norm_squared(ptr noundef) #4

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

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "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 #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 64}
!10 = !{!"basis_func", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80}
!11 = !{!"long", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"vec3d", !12, i64 0, !12, i64 8, !12, i64 16}
!15 = !{!10, !12, i64 72}
!16 = !{!14, !12, i64 8}
!17 = !{!10, !12, i64 80}
!18 = !{!14, !12, i64 16}
!19 = !{!12, !12, i64 0}
!20 = !{!11, !11, i64 0}
!21 = !{!10, !11, i64 24}
!22 = !{!10, !6, i64 40}
!23 = !{!10, !6, i64 48}
!24 = !{!10, !11, i64 0}
!25 = !{!10, !11, i64 8}
!26 = !{!10, !11, i64 16}
!27 = !{!10, !6, i64 32}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}


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

%struct.vec3d = type { double, double, double }

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local double @basis_funcs_value(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = alloca %struct.vec3d, align 16
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #5
  %4 = getelementptr inbounds i8, ptr %0, i64 64
  %5 = getelementptr inbounds i8, ptr %0, i64 72
  %6 = load <2 x double>, ptr %4, align 8, !tbaa !5
  store <2 x double> %6, ptr %3, align 16, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %3, i64 16
  %8 = getelementptr inbounds i8, ptr %0, i64 80
  %9 = load double, ptr %8, align 8, !tbaa !9
  store double %9, ptr %7, align 16, !tbaa !13
  call void @vec3d_subtract(ptr noundef %1, ptr noundef nonnull %3, ptr noundef nonnull %3) #5
  %10 = call double @vec3d_norm_squared(ptr noundef nonnull %3) #5
  %11 = load double, ptr %1, align 8, !tbaa !15
  %12 = load double, ptr %4, align 8, !tbaa !16
  %13 = fsub double %11, %12
  %14 = fadd double %13, 1.000000e-100
  %15 = getelementptr inbounds i8, ptr %1, i64 8
  %16 = load double, ptr %15, align 8, !tbaa !17
  %17 = load double, ptr %5, align 8, !tbaa !18
  %18 = fsub double %16, %17
  %19 = fadd double %18, 1.000000e-100
  %20 = getelementptr inbounds i8, ptr %1, i64 16
  %21 = load double, ptr %20, align 8, !tbaa !13
  %22 = load double, ptr %8, align 8, !tbaa !9
  %23 = fsub double %21, %22
  %24 = fadd double %23, 1.000000e-100
  %25 = getelementptr inbounds i8, ptr %0, i64 24
  %26 = load i64, ptr %25, align 8, !tbaa !19
  %.not = icmp eq i64 %26, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %27 = getelementptr inbounds i8, ptr %0, i64 40
  %28 = getelementptr inbounds i8, ptr %0, i64 48
  %29 = getelementptr inbounds i8, ptr %0, i64 8
  %30 = getelementptr inbounds i8, ptr %0, i64 16
  %31 = getelementptr inbounds i8, ptr %0, i64 32
  br label %32

._crit_edge:                                      ; preds = %32, %2
  %.027.lcssa = phi double [ 0.000000e+00, %2 ], [ %58, %32 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #5
  ret double %.027.lcssa

32:                                               ; preds = %.lr.ph, %32
  %.029 = phi i64 [ 0, %.lr.ph ], [ %59, %32 ]
  %.02728 = phi double [ 0.000000e+00, %.lr.ph ], [ %58, %32 ]
  %33 = load ptr, ptr %27, align 8, !tbaa !20
  %34 = getelementptr inbounds double, ptr %33, i64 %.029
  %35 = load double, ptr %34, align 8, !tbaa !5
  %36 = load ptr, ptr %28, align 8, !tbaa !21
  %37 = getelementptr inbounds double, ptr %36, i64 %.029
  %38 = load double, ptr %37, align 8, !tbaa !5
  %39 = fmul double %35, %38
  %40 = load i64, ptr %0, align 8, !tbaa !22
  %41 = uitofp i64 %40 to double
  %42 = call double @pow(double noundef %14, double noundef %41) #5
  %43 = fmul double %39, %42
  %44 = load i64, ptr %29, align 8, !tbaa !23
  %45 = uitofp i64 %44 to double
  %46 = call double @pow(double noundef %19, double noundef %45) #5
  %47 = fmul double %43, %46
  %48 = load i64, ptr %30, align 8, !tbaa !24
  %49 = uitofp i64 %48 to double
  %50 = call double @pow(double noundef %24, double noundef %49) #5
  %51 = fmul double %47, %50
  %52 = load ptr, ptr %31, align 8, !tbaa !25
  %53 = getelementptr inbounds double, ptr %52, i64 %.029
  %54 = load double, ptr %53, align 8, !tbaa !5
  %55 = fneg double %54
  %56 = fmul double %10, %55
  %57 = call double @exp(double noundef %56) #5
  %58 = call double @llvm.fmuladd.f64(double %51, double %57, double %.02728)
  %59 = add nuw i64 %.029, 1
  %60 = load i64, ptr %25, align 8, !tbaa !19
  %61 = icmp ult i64 %59, %60
  br i1 %61, label %32, label %._crit_edge, !llvm.loop !26
}

declare void @vec3d_subtract(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare double @vec3d_norm_squared(ptr noundef) local_unnamed_addr #4

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

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "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 #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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 80}
!10 = !{!"basis_func", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !12, i64 40, !12, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80}
!11 = !{!"long", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !6, i64 16}
!14 = !{!"vec3d", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!14, !6, i64 0}
!16 = !{!10, !6, i64 64}
!17 = !{!14, !6, i64 8}
!18 = !{!10, !6, i64 72}
!19 = !{!10, !11, i64 24}
!20 = !{!10, !12, i64 40}
!21 = !{!10, !12, i64 48}
!22 = !{!10, !11, i64 0}
!23 = !{!10, !11, i64 8}
!24 = !{!10, !11, i64 16}
!25 = !{!10, !12, i64 32}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass