; LLVM IR from introlab/odas :: src/utils (gaussian)

; 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.gaussian_3d_obj = type { float, float, float, float, float, float, float, float }

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind
declare float @expf(float noundef) #1

; Function Attrs: nounwind uwtable
define dso_local float @gaussian_3d_eval(ptr noundef %0, float noundef %1, float noundef %2, float noundef %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca float, align 4
  %19 = alloca float, align 4
  %20 = alloca float, align 4
  %21 = alloca float, align 4
  %22 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store float %2, ptr %7, align 4, !tbaa !9
  store float %3, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  %23 = load float, ptr %6, align 4, !tbaa !9
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.gaussian_3d_obj, ptr %24, i32 0, i32 1
  %26 = load float, ptr %25, align 4, !tbaa !11
  %27 = fsub float %23, %26
  store float %27, ptr %10, align 4, !tbaa !9
  %28 = load float, ptr %7, align 4, !tbaa !9
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.gaussian_3d_obj, ptr %29, i32 0, i32 2
  %31 = load float, ptr %30, align 4, !tbaa !13
  %32 = fsub float %28, %31
  store float %32, ptr %11, align 4, !tbaa !9
  %33 = load float, ptr %8, align 4, !tbaa !9
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.gaussian_3d_obj, ptr %34, i32 0, i32 3
  %36 = load float, ptr %35, align 4, !tbaa !14
  %37 = fsub float %33, %36
  store float %37, ptr %12, align 4, !tbaa !9
  %38 = load float, ptr %10, align 4, !tbaa !9
  %39 = load float, ptr %10, align 4, !tbaa !9
  %40 = fmul float %38, %39
  store float %40, ptr %13, align 4, !tbaa !9
  %41 = load float, ptr %11, align 4, !tbaa !9
  %42 = load float, ptr %11, align 4, !tbaa !9
  %43 = fmul float %41, %42
  store float %43, ptr %14, align 4, !tbaa !9
  %44 = load float, ptr %12, align 4, !tbaa !9
  %45 = load float, ptr %12, align 4, !tbaa !9
  %46 = fmul float %44, %45
  store float %46, ptr %15, align 4, !tbaa !9
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.gaussian_3d_obj, ptr %47, i32 0, i32 4
  %49 = load float, ptr %48, align 4, !tbaa !15
  store float %49, ptr %16, align 4, !tbaa !9
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.gaussian_3d_obj, ptr %50, i32 0, i32 5
  %52 = load float, ptr %51, align 4, !tbaa !16
  store float %52, ptr %17, align 4, !tbaa !9
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.gaussian_3d_obj, ptr %53, i32 0, i32 6
  %55 = load float, ptr %54, align 4, !tbaa !17
  store float %55, ptr %18, align 4, !tbaa !9
  %56 = load float, ptr %16, align 4, !tbaa !9
  %57 = load float, ptr %16, align 4, !tbaa !9
  %58 = fmul float %56, %57
  store float %58, ptr %19, align 4, !tbaa !9
  %59 = load float, ptr %17, align 4, !tbaa !9
  %60 = load float, ptr %17, align 4, !tbaa !9
  %61 = fmul float %59, %60
  store float %61, ptr %20, align 4, !tbaa !9
  %62 = load float, ptr %18, align 4, !tbaa !9
  %63 = load float, ptr %18, align 4, !tbaa !9
  %64 = fmul float %62, %63
  store float %64, ptr %21, align 4, !tbaa !9
  %65 = load float, ptr %13, align 4, !tbaa !9
  %66 = load float, ptr %19, align 4, !tbaa !9
  %67 = fdiv float %65, %66
  %68 = load float, ptr %14, align 4, !tbaa !9
  %69 = load float, ptr %20, align 4, !tbaa !9
  %70 = fdiv float %68, %69
  %71 = fadd float %67, %70
  %72 = load float, ptr %15, align 4, !tbaa !9
  %73 = load float, ptr %21, align 4, !tbaa !9
  %74 = fdiv float %72, %73
  %75 = fadd float %71, %74
  %76 = fmul float -5.000000e-01, %75
  store float %76, ptr %22, align 4, !tbaa !9
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.gaussian_3d_obj, ptr %77, i32 0, i32 7
  %79 = load float, ptr %78, align 4, !tbaa !18
  %80 = load float, ptr %22, align 4, !tbaa !9
  %81 = call float @expf(float noundef %80) #3, !tbaa !19
  %82 = fmul float %79, %81
  store float %82, ptr %9, align 4, !tbaa !9
  %83 = load float, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret float %83
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 4}
!12 = !{!"gaussian_3d_obj", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 12}
!15 = !{!12, !10, i64 16}
!16 = !{!12, !10, i64 20}
!17 = !{!12, !10, i64 24}
!18 = !{!12, !10, i64 28}
!19 = !{!20, !20, i64 0}
!20 = !{!"int", !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: mustprogress nofree nounwind willreturn memory(write)
declare float @expf(float noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local float @gaussian_3d_eval(ptr nocapture noundef readonly %0, float noundef %1, float noundef %2, float noundef %3) local_unnamed_addr #1 {
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load float, ptr %5, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load float, ptr %7, align 4, !tbaa !10
  %9 = fsub float %2, %8
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  %11 = load float, ptr %10, align 4, !tbaa !11
  %12 = fmul float %9, %9
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = load float, ptr %13, align 4, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %0, i64 20
  %16 = load float, ptr %15, align 4, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %0, i64 24
  %18 = load float, ptr %17, align 4, !tbaa !14
  %19 = fmul float %16, %16
  %20 = fdiv float %12, %19
  %21 = insertelement <2 x float> poison, float %1, i64 0
  %22 = insertelement <2 x float> %21, float %3, i64 1
  %23 = insertelement <2 x float> poison, float %6, i64 0
  %24 = insertelement <2 x float> %23, float %11, i64 1
  %25 = fsub <2 x float> %22, %24
  %26 = fmul <2 x float> %25, %25
  %27 = insertelement <2 x float> poison, float %14, i64 0
  %28 = insertelement <2 x float> %27, float %18, i64 1
  %29 = fmul <2 x float> %28, %28
  %30 = fdiv <2 x float> %26, %29
  %31 = extractelement <2 x float> %30, i64 0
  %32 = fadd float %31, %20
  %33 = extractelement <2 x float> %30, i64 1
  %34 = fadd float %32, %33
  %35 = fmul float %34, -5.000000e-01
  %36 = getelementptr inbounds i8, ptr %0, i64 28
  %37 = load float, ptr %36, align 4, !tbaa !15
  %38 = tail call float @expf(float noundef %35) #2, !tbaa !16
  %39 = fmul float %37, %38
  ret float %39
}

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 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 = { 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, !7, i64 4}
!6 = !{!"gaussian_3d_obj", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 12}
!12 = !{!6, !7, i64 16}
!13 = !{!6, !7, i64 20}
!14 = !{!6, !7, i64 24}
!15 = !{!6, !7, i64 28}
!16 = !{!17, !17, i64 0}
!17 = !{!"int", !8, i64 0}


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass