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

; 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::Vector" = type { double, double }
%"class.jet::Size2" = 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 uwtable
declare dso_local void @_ZNK3jet17FaceCenteredGrid217valueAtCellCenterEmm(ptr dead_on_unwind noalias writable sret(%"class.jet::Vector") align 8, ptr noundef nonnull align 8 dereferenceable(384), i64 noundef, i64 noundef) #1 align 2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3jet5Grid211gridSpacingEv(ptr noundef nonnull align 8 dereferenceable(88)) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK3jet17FaceCenteredGrid216curlAtCellCenterEmm(ptr noundef nonnull align 8 dereferenceable(384) %0, i64 noundef %1, i64 noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %"class.jet::Vector", align 8
  %9 = alloca %"class.jet::Vector", align 8
  %10 = alloca %"class.jet::Vector", align 8
  %11 = alloca %"class.jet::Vector", align 8
  %12 = alloca %"class.jet::Vector", align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  %16 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store i64 %2, ptr %6, align 8, !tbaa !9
  %17 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  %19 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3jet5Grid210resolutionEv(ptr noundef nonnull align 8 dereferenceable(88) %18)
  store ptr %19, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #4
  %20 = getelementptr inbounds i8, ptr %17, i64 8
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3jet5Grid211gridSpacingEv(ptr noundef nonnull align 8 dereferenceable(88) %20)
  call void @_ZN3jet6VectorIdLm2EEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 8 dereferenceable(16) %21)
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #4
  %22 = load i64, ptr %5, align 8, !tbaa !9
  %23 = icmp ugt i64 %22, 0
  br i1 %23, label %24, label %27

24:                                               ; preds = %3
  %25 = load i64, ptr %5, align 8, !tbaa !9
  %26 = sub i64 %25, 1
  br label %29

27:                                               ; preds = %3
  %28 = load i64, ptr %5, align 8, !tbaa !9
  br label %29

29:                                               ; preds = %27, %24
  %30 = phi i64 [ %26, %24 ], [ %28, %27 ]
  %31 = load i64, ptr %6, align 8, !tbaa !9
  call void @_ZNK3jet17FaceCenteredGrid217valueAtCellCenterEmm(ptr dead_on_unwind writable sret(%"class.jet::Vector") align 8 %9, ptr noundef nonnull align 8 dereferenceable(384) %17, i64 noundef %30, i64 noundef %31)
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  %32 = load i64, ptr %5, align 8, !tbaa !9
  %33 = add i64 %32, 1
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %"class.jet::Size2", ptr %34, i32 0, i32 0
  %36 = load i64, ptr %35, align 8, !tbaa !11
  %37 = icmp ult i64 %33, %36
  br i1 %37, label %38, label %41

38:                                               ; preds = %29
  %39 = load i64, ptr %5, align 8, !tbaa !9
  %40 = add i64 %39, 1
  br label %43

41:                                               ; preds = %29
  %42 = load i64, ptr %5, align 8, !tbaa !9
  br label %43

43:                                               ; preds = %41, %38
  %44 = phi i64 [ %40, %38 ], [ %42, %41 ]
  %45 = load i64, ptr %6, align 8, !tbaa !9
  call void @_ZNK3jet17FaceCenteredGrid217valueAtCellCenterEmm(ptr dead_on_unwind writable sret(%"class.jet::Vector") align 8 %10, ptr noundef nonnull align 8 dereferenceable(384) %17, i64 noundef %44, i64 noundef %45)
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #4
  %46 = load i64, ptr %5, align 8, !tbaa !9
  %47 = load i64, ptr %6, align 8, !tbaa !9
  %48 = icmp ugt i64 %47, 0
  br i1 %48, label %49, label %52

49:                                               ; preds = %43
  %50 = load i64, ptr %6, align 8, !tbaa !9
  %51 = sub i64 %50, 1
  br label %54

52:                                               ; preds = %43
  %53 = load i64, ptr %6, align 8, !tbaa !9
  br label %54

54:                                               ; preds = %52, %49
  %55 = phi i64 [ %51, %49 ], [ %53, %52 ]
  call void @_ZNK3jet17FaceCenteredGrid217valueAtCellCenterEmm(ptr dead_on_unwind writable sret(%"class.jet::Vector") align 8 %11, ptr noundef nonnull align 8 dereferenceable(384) %17, i64 noundef %46, i64 noundef %55)
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #4
  %56 = load i64, ptr %5, align 8, !tbaa !9
  %57 = load i64, ptr %6, align 8, !tbaa !9
  %58 = add i64 %57, 1
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds %"class.jet::Size2", ptr %59, i32 0, i32 1
  %61 = load i64, ptr %60, align 8, !tbaa !13
  %62 = icmp ult i64 %58, %61
  br i1 %62, label %63, label %66

63:                                               ; preds = %54
  %64 = load i64, ptr %6, align 8, !tbaa !9
  %65 = add i64 %64, 1
  br label %68

66:                                               ; preds = %54
  %67 = load i64, ptr %6, align 8, !tbaa !9
  br label %68

68:                                               ; preds = %66, %63
  %69 = phi i64 [ %65, %63 ], [ %67, %66 ]
  call void @_ZNK3jet17FaceCenteredGrid217valueAtCellCenterEmm(ptr dead_on_unwind writable sret(%"class.jet::Vector") align 8 %12, ptr noundef nonnull align 8 dereferenceable(384) %17, i64 noundef %56, i64 noundef %69)
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %70 = getelementptr inbounds %"class.jet::Vector", ptr %11, i32 0, i32 0
  %71 = load double, ptr %70, align 8, !tbaa !14
  store double %71, ptr %13, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %72 = getelementptr inbounds %"class.jet::Vector", ptr %12, i32 0, i32 0
  %73 = load double, ptr %72, align 8, !tbaa !14
  store double %73, ptr %14, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %74 = getelementptr inbounds %"class.jet::Vector", ptr %9, i32 0, i32 1
  %75 = load double, ptr %74, align 8, !tbaa !18
  store double %75, ptr %15, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %76 = getelementptr inbounds %"class.jet::Vector", ptr %10, i32 0, i32 1
  %77 = load double, ptr %76, align 8, !tbaa !18
  store double %77, ptr %16, align 8, !tbaa !17
  %78 = load double, ptr %16, align 8, !tbaa !17
  %79 = load double, ptr %15, align 8, !tbaa !17
  %80 = fsub double %78, %79
  %81 = fmul double 5.000000e-01, %80
  %82 = getelementptr inbounds %"class.jet::Vector", ptr %8, i32 0, i32 0
  %83 = load double, ptr %82, align 8, !tbaa !14
  %84 = fdiv double %81, %83
  %85 = load double, ptr %14, align 8, !tbaa !17
  %86 = load double, ptr %13, align 8, !tbaa !17
  %87 = fsub double %85, %86
  %88 = fmul double 5.000000e-01, %87
  %89 = getelementptr inbounds %"class.jet::Vector", ptr %8, i32 0, i32 1
  %90 = load double, ptr %89, align 8, !tbaa !18
  %91 = fdiv double %88, %90
  %92 = fsub double %84, %91
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  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 16, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret double %92
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3jet5Grid210resolutionEv(ptr noundef nonnull align 8 dereferenceable(88)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3jet6VectorIdLm2EEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #3 = { 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 #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, !10, i64 0}
!12 = !{!"_ZTSN3jet5Size2E", !10, i64 0, !10, i64 8}
!13 = !{!12, !10, i64 8}
!14 = !{!15, !16, i64 0}
!15 = !{!"_ZTSN3jet6VectorIdLm2EEE", !16, i64 0, !16, i64 8}
!16 = !{!"double", !7, i64 0}
!17 = !{!16, !16, i64 0}
!18 = !{!15, !16, i64 8}


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

%"class.jet::Vector" = type { double, double }

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3jet17FaceCenteredGrid217valueAtCellCenterEmm(ptr dead_on_unwind noalias writable sret(%"class.jet::Vector") align 8, ptr noundef nonnull align 8 dereferenceable(384), i64 noundef, i64 noundef) local_unnamed_addr #1 align 2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3jet5Grid211gridSpacingEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZNK3jet17FaceCenteredGrid216curlAtCellCenterEmm(ptr noundef nonnull align 8 dereferenceable(384) %0, i64 noundef %1, i64 noundef %2) local_unnamed_addr #1 align 2 {
  %4 = alloca %"class.jet::Vector", align 16
  %5 = alloca %"class.jet::Vector", align 16
  %6 = alloca %"class.jet::Vector", align 16
  %7 = alloca %"class.jet::Vector", align 8
  %8 = alloca %"class.jet::Vector", align 8
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3jet5Grid210resolutionEv(ptr noundef nonnull align 8 dereferenceable(88) %9)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  %11 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3jet5Grid211gridSpacingEv(ptr noundef nonnull align 8 dereferenceable(88) %9)
  call void @_ZN3jet6VectorIdLm2EEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 8 dereferenceable(16) %11)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #5
  %12 = call i64 @llvm.usub.sat.i64(i64 %1, i64 1)
  call void @_ZNK3jet17FaceCenteredGrid217valueAtCellCenterEmm(ptr dead_on_unwind nonnull writable sret(%"class.jet::Vector") align 8 %5, ptr noundef nonnull align 8 dereferenceable(384) %0, i64 noundef %12, i64 noundef %2)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #5
  %13 = add i64 %1, 1
  %14 = load i64, ptr %10, align 8, !tbaa !5
  %15 = icmp ult i64 %13, %14
  %16 = select i1 %15, i64 %13, i64 %1
  call void @_ZNK3jet17FaceCenteredGrid217valueAtCellCenterEmm(ptr dead_on_unwind nonnull writable sret(%"class.jet::Vector") align 8 %6, ptr noundef nonnull align 8 dereferenceable(384) %0, i64 noundef %16, i64 noundef %2)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #5
  %17 = call i64 @llvm.usub.sat.i64(i64 %2, i64 1)
  call void @_ZNK3jet17FaceCenteredGrid217valueAtCellCenterEmm(ptr dead_on_unwind nonnull writable sret(%"class.jet::Vector") align 8 %7, ptr noundef nonnull align 8 dereferenceable(384) %0, i64 noundef %1, i64 noundef %17)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #5
  %18 = add i64 %2, 1
  %19 = getelementptr inbounds i8, ptr %10, i64 8
  %20 = load i64, ptr %19, align 8, !tbaa !10
  %21 = icmp ult i64 %18, %20
  %22 = select i1 %21, i64 %18, i64 %2
  call void @_ZNK3jet17FaceCenteredGrid217valueAtCellCenterEmm(ptr dead_on_unwind nonnull writable sret(%"class.jet::Vector") align 8 %8, ptr noundef nonnull align 8 dereferenceable(384) %0, i64 noundef %1, i64 noundef %22)
  %23 = load double, ptr %7, align 8, !tbaa !11
  %24 = load double, ptr %8, align 8, !tbaa !11
  %25 = load <2 x double>, ptr %5, align 16
  %26 = shufflevector <2 x double> %25, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %27 = load <2 x double>, ptr %6, align 16
  %28 = shufflevector <2 x double> %27, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %29 = insertelement <2 x double> %28, double %24, i64 1
  %30 = insertelement <2 x double> %26, double %23, i64 1
  %31 = fsub <2 x double> %29, %30
  %32 = fmul <2 x double> %31, <double 5.000000e-01, double 5.000000e-01>
  %33 = load <2 x double>, ptr %4, align 16, !tbaa !14
  %34 = fdiv <2 x double> %32, %33
  %shift = shufflevector <2 x double> %34, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %35 = fsub <2 x double> %34, %shift
  %36 = extractelement <2 x double> %35, i64 0
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #5
  ret double %36
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNK3jet5Grid210resolutionEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3jet6VectorIdLm2EEC2ERKS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.usub.sat.i64(i64, i64) #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #3 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 0}
!6 = !{!"_ZTSN3jet5Size2E", !7, i64 0, !7, i64 8}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTSN3jet6VectorIdLm2EEE", !13, i64 0, !13, i64 8}
!13 = !{!"double", !8, i64 0}
!14 = !{!13, !13, i64 0}


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