; LLVM IR from doyubkim/fluid-engine-dev :: src/jet/face_centered_grid3.ll (ZNK3jet17FaceCenteredGrid322divergenceAtCellCenterEmmm)

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

%"class.jet::FaceCenteredGrid3" = type { %"class.jet::VectorGrid3", %"class.jet::Array", %"class.jet::Array", %"class.jet::Array", %"class.jet::Vector", %"class.jet::Vector", %"class.jet::Vector", %"class.jet::LinearArraySampler", %"class.jet::LinearArraySampler", %"class.jet::LinearArraySampler", %"class.std::function" }
%"class.jet::VectorGrid3" = type { %"class.jet::VectorField3", %"class.jet::Grid3" }
%"class.jet::VectorField3" = type { %"class.jet::Field3" }
%"class.jet::Field3" = type { ptr }
%"class.jet::Grid3" = type { %"class.jet::Serializable", %"class.jet::Size3", %"class.jet::Vector", %"class.jet::Vector", %"class.jet::BoundingBox" }
%"class.jet::Serializable" = type { ptr }
%"class.jet::Size3" = type { i64, i64, i64 }
%"class.jet::BoundingBox" = type { %"class.jet::Vector", %"class.jet::Vector" }
%"class.jet::Array" = type { %"class.jet::Size3", %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.jet::Vector" = type { double, double, double }
%"class.jet::LinearArraySampler" = type { %"class.jet::Vector", %"class.jet::Vector", %"class.jet::Vector", %"class.jet::ConstArrayAccessor" }
%"class.jet::ConstArrayAccessor" = type { %"class.jet::Size3", ptr }
%"class.std::function" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }

; 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: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet5ArrayIdLm3EEclEmmm(ptr noundef nonnull align 8 dereferenceable(48), i64 noundef, i64 noundef, i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK3jet17FaceCenteredGrid322divergenceAtCellCenterEmmm(ptr noundef nonnull align 8 dereferenceable(696) %0, i64 noundef %1, i64 noundef %2, i64 noundef %3) #2 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  store ptr %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
  %16 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %17 = getelementptr inbounds i8, ptr %16, i64 8
  %18 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK3jet5Grid311gridSpacingEv(ptr noundef nonnull align 8 dereferenceable(128) %17)
  store ptr %18, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %19 = getelementptr inbounds %"class.jet::FaceCenteredGrid3", ptr %16, i32 0, i32 1
  %20 = load i64, ptr %6, align 8, !tbaa !9
  %21 = load i64, ptr %7, align 8, !tbaa !9
  %22 = load i64, ptr %8, align 8, !tbaa !9
  %23 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet5ArrayIdLm3EEclEmmm(ptr noundef nonnull align 8 dereferenceable(48) %19, i64 noundef %20, i64 noundef %21, i64 noundef %22)
  %24 = load double, ptr %23, align 8, !tbaa !11
  store double %24, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %25 = getelementptr inbounds %"class.jet::FaceCenteredGrid3", ptr %16, i32 0, i32 1
  %26 = load i64, ptr %6, align 8, !tbaa !9
  %27 = add i64 %26, 1
  %28 = load i64, ptr %7, align 8, !tbaa !9
  %29 = load i64, ptr %8, align 8, !tbaa !9
  %30 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet5ArrayIdLm3EEclEmmm(ptr noundef nonnull align 8 dereferenceable(48) %25, i64 noundef %27, i64 noundef %28, i64 noundef %29)
  %31 = load double, ptr %30, align 8, !tbaa !11
  store double %31, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %32 = getelementptr inbounds %"class.jet::FaceCenteredGrid3", ptr %16, i32 0, i32 2
  %33 = load i64, ptr %6, align 8, !tbaa !9
  %34 = load i64, ptr %7, align 8, !tbaa !9
  %35 = load i64, ptr %8, align 8, !tbaa !9
  %36 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet5ArrayIdLm3EEclEmmm(ptr noundef nonnull align 8 dereferenceable(48) %32, i64 noundef %33, i64 noundef %34, i64 noundef %35)
  %37 = load double, ptr %36, align 8, !tbaa !11
  store double %37, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %38 = getelementptr inbounds %"class.jet::FaceCenteredGrid3", ptr %16, i32 0, i32 2
  %39 = load i64, ptr %6, align 8, !tbaa !9
  %40 = load i64, ptr %7, align 8, !tbaa !9
  %41 = add i64 %40, 1
  %42 = load i64, ptr %8, align 8, !tbaa !9
  %43 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet5ArrayIdLm3EEclEmmm(ptr noundef nonnull align 8 dereferenceable(48) %38, i64 noundef %39, i64 noundef %41, i64 noundef %42)
  %44 = load double, ptr %43, align 8, !tbaa !11
  store double %44, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %45 = getelementptr inbounds %"class.jet::FaceCenteredGrid3", ptr %16, i32 0, i32 3
  %46 = load i64, ptr %6, align 8, !tbaa !9
  %47 = load i64, ptr %7, align 8, !tbaa !9
  %48 = load i64, ptr %8, align 8, !tbaa !9
  %49 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet5ArrayIdLm3EEclEmmm(ptr noundef nonnull align 8 dereferenceable(48) %45, i64 noundef %46, i64 noundef %47, i64 noundef %48)
  %50 = load double, ptr %49, align 8, !tbaa !11
  store double %50, ptr %14, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %51 = getelementptr inbounds %"class.jet::FaceCenteredGrid3", ptr %16, i32 0, i32 3
  %52 = load i64, ptr %6, align 8, !tbaa !9
  %53 = load i64, ptr %7, align 8, !tbaa !9
  %54 = load i64, ptr %8, align 8, !tbaa !9
  %55 = add i64 %54, 1
  %56 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet5ArrayIdLm3EEclEmmm(ptr noundef nonnull align 8 dereferenceable(48) %51, i64 noundef %52, i64 noundef %53, i64 noundef %55)
  %57 = load double, ptr %56, align 8, !tbaa !11
  store double %57, ptr %15, align 8, !tbaa !11
  %58 = load double, ptr %11, align 8, !tbaa !11
  %59 = load double, ptr %10, align 8, !tbaa !11
  %60 = fsub double %58, %59
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = getelementptr inbounds %"class.jet::Vector", ptr %61, i32 0, i32 0
  %63 = load double, ptr %62, align 8, !tbaa !13
  %64 = fdiv double %60, %63
  %65 = load double, ptr %13, align 8, !tbaa !11
  %66 = load double, ptr %12, align 8, !tbaa !11
  %67 = fsub double %65, %66
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = getelementptr inbounds %"class.jet::Vector", ptr %68, i32 0, i32 1
  %70 = load double, ptr %69, align 8, !tbaa !15
  %71 = fdiv double %67, %70
  %72 = fadd double %64, %71
  %73 = load double, ptr %15, align 8, !tbaa !11
  %74 = load double, ptr %14, align 8, !tbaa !11
  %75 = fsub double %73, %74
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = getelementptr inbounds %"class.jet::Vector", ptr %76, i32 0, i32 2
  %78 = load double, ptr %77, align 8, !tbaa !16
  %79 = fdiv double %75, %78
  %80 = fadd double %72, %79
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret double %80
}

declare noundef nonnull align 8 dereferenceable(24) ptr @_ZNK3jet5Grid311gridSpacingEv(ptr noundef nonnull align 8 dereferenceable(128)) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #2 = { mustprogress 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 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"_ZTSN3jet6VectorIdLm3EEE", !12, i64 0, !12, i64 8, !12, i64 16}
!15 = !{!14, !12, i64 8}
!16 = !{!14, !12, i64 16}


; 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 nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet5ArrayIdLm3EEclEmmm(ptr noundef nonnull align 8 dereferenceable(48), i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK3jet17FaceCenteredGrid322divergenceAtCellCenterEmmm(ptr noundef nonnull align 8 dereferenceable(696) %0, i64 noundef %1, i64 noundef %2, i64 noundef %3) local_unnamed_addr #1 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK3jet5Grid311gridSpacingEv(ptr noundef nonnull align 8 dereferenceable(128) %5)
  %7 = getelementptr inbounds i8, ptr %0, i64 136
  %8 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet5ArrayIdLm3EEclEmmm(ptr noundef nonnull align 8 dereferenceable(48) %7, i64 noundef %1, i64 noundef %2, i64 noundef %3)
  %9 = load double, ptr %8, align 8, !tbaa !5
  %10 = add i64 %1, 1
  %11 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet5ArrayIdLm3EEclEmmm(ptr noundef nonnull align 8 dereferenceable(48) %7, i64 noundef %10, i64 noundef %2, i64 noundef %3)
  %12 = load double, ptr %11, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 184
  %14 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet5ArrayIdLm3EEclEmmm(ptr noundef nonnull align 8 dereferenceable(48) %13, i64 noundef %1, i64 noundef %2, i64 noundef %3)
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = add i64 %2, 1
  %17 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet5ArrayIdLm3EEclEmmm(ptr noundef nonnull align 8 dereferenceable(48) %13, i64 noundef %1, i64 noundef %16, i64 noundef %3)
  %18 = load double, ptr %17, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %0, i64 232
  %20 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet5ArrayIdLm3EEclEmmm(ptr noundef nonnull align 8 dereferenceable(48) %19, i64 noundef %1, i64 noundef %2, i64 noundef %3)
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = add i64 %3, 1
  %23 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet5ArrayIdLm3EEclEmmm(ptr noundef nonnull align 8 dereferenceable(48) %19, i64 noundef %1, i64 noundef %2, i64 noundef %22)
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = fsub double %12, %9
  %26 = load double, ptr %6, align 8, !tbaa !9
  %27 = fdiv double %25, %26
  %28 = getelementptr inbounds i8, ptr %6, i64 8
  %29 = insertelement <2 x double> poison, double %18, i64 0
  %30 = insertelement <2 x double> %29, double %24, i64 1
  %31 = insertelement <2 x double> poison, double %15, i64 0
  %32 = insertelement <2 x double> %31, double %21, i64 1
  %33 = fsub <2 x double> %30, %32
  %34 = load <2 x double>, ptr %28, align 8, !tbaa !5
  %35 = fdiv <2 x double> %33, %34
  %36 = extractelement <2 x double> %35, i64 0
  %37 = fadd double %27, %36
  %38 = extractelement <2 x double> %35, i64 1
  %39 = fadd double %37, %38
  ret double %39
}

declare noundef nonnull align 8 dereferenceable(24) ptr @_ZNK3jet5Grid311gridSpacingEv(ptr noundef nonnull align 8 dereferenceable(128)) local_unnamed_addr #2

attributes #0 = { mustprogress 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 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 = { "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, !6, i64 0}
!6 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSN3jet6VectorIdLm3EEE", !6, i64 0, !6, i64 8, !6, i64 16}


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