; LLVM IR from doyubkim/fluid-engine-dev :: src/jet (fdm_utils)

; 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::Size2" = type { i64, i64 }
%"class.jet::Vector" = type { double, double }

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3jet18ConstArrayAccessorIdLm2EE4sizeEv(ptr dead_on_unwind noalias writable sret(%"class.jet::Size2") align 8, ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, i64 noundef) #2 align 2

; 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
define dso_local noundef double @_ZN3jet10laplacian2ERKNS_18ConstArrayAccessorIdLm2EEERKNS_6VectorIdLm2EEEmm(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, i64 noundef %2, i64 noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca double, align 8
  %10 = alloca %"class.jet::Size2", align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  %14 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  store i64 %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = load i64, ptr %7, align 8, !tbaa !9
  %17 = load i64, ptr %8, align 8, !tbaa !9
  %18 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %15, i64 noundef %16, i64 noundef %17)
  %19 = load double, ptr %18, align 8, !tbaa !11
  store double %19, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZNK3jet18ConstArrayAccessorIdLm2EE4sizeEv(ptr dead_on_unwind writable sret(%"class.jet::Size2") align 8 %10, ptr noundef nonnull align 8 dereferenceable(24) %20)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store double 0.000000e+00, ptr %11, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store double 0.000000e+00, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store double 0.000000e+00, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  store double 0.000000e+00, ptr %14, align 8, !tbaa !11
  %21 = load i64, ptr %7, align 8, !tbaa !9
  %22 = icmp ugt i64 %21, 0
  br i1 %22, label %23, label %32

23:                                               ; preds = %4
  %24 = load double, ptr %9, align 8, !tbaa !11
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = load i64, ptr %7, align 8, !tbaa !9
  %27 = sub i64 %26, 1
  %28 = load i64, ptr %8, align 8, !tbaa !9
  %29 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %25, i64 noundef %27, i64 noundef %28)
  %30 = load double, ptr %29, align 8, !tbaa !11
  %31 = fsub double %24, %30
  store double %31, ptr %11, align 8, !tbaa !11
  br label %32

32:                                               ; preds = %23, %4
  %33 = load i64, ptr %7, align 8, !tbaa !9
  %34 = add i64 %33, 1
  %35 = getelementptr inbounds %"class.jet::Size2", ptr %10, i32 0, i32 0
  %36 = load i64, ptr %35, align 8, !tbaa !13
  %37 = icmp ult i64 %34, %36
  br i1 %37, label %38, label %47

38:                                               ; preds = %32
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %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 @_ZNK3jet18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %39, i64 noundef %41, i64 noundef %42)
  %44 = load double, ptr %43, align 8, !tbaa !11
  %45 = load double, ptr %9, align 8, !tbaa !11
  %46 = fsub double %44, %45
  store double %46, ptr %12, align 8, !tbaa !11
  br label %47

47:                                               ; preds = %38, %32
  %48 = load i64, ptr %8, align 8, !tbaa !9
  %49 = icmp ugt i64 %48, 0
  br i1 %49, label %50, label %59

50:                                               ; preds = %47
  %51 = load double, ptr %9, align 8, !tbaa !11
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load i64, ptr %7, align 8, !tbaa !9
  %54 = load i64, ptr %8, align 8, !tbaa !9
  %55 = sub i64 %54, 1
  %56 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %52, i64 noundef %53, i64 noundef %55)
  %57 = load double, ptr %56, align 8, !tbaa !11
  %58 = fsub double %51, %57
  store double %58, ptr %13, align 8, !tbaa !11
  br label %59

59:                                               ; preds = %50, %47
  %60 = load i64, ptr %8, align 8, !tbaa !9
  %61 = add i64 %60, 1
  %62 = getelementptr inbounds %"class.jet::Size2", ptr %10, i32 0, i32 1
  %63 = load i64, ptr %62, align 8, !tbaa !15
  %64 = icmp ult i64 %61, %63
  br i1 %64, label %65, label %74

65:                                               ; preds = %59
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = load i64, ptr %7, align 8, !tbaa !9
  %68 = load i64, ptr %8, align 8, !tbaa !9
  %69 = add i64 %68, 1
  %70 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %66, i64 noundef %67, i64 noundef %69)
  %71 = load double, ptr %70, align 8, !tbaa !11
  %72 = load double, ptr %9, align 8, !tbaa !11
  %73 = fsub double %71, %72
  store double %73, ptr %14, align 8, !tbaa !11
  br label %74

74:                                               ; preds = %65, %59
  %75 = load double, ptr %12, align 8, !tbaa !11
  %76 = load double, ptr %11, align 8, !tbaa !11
  %77 = fsub double %75, %76
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = getelementptr inbounds %"class.jet::Vector", ptr %78, i32 0, i32 0
  %80 = load double, ptr %79, align 8, !tbaa !16
  %81 = call noundef double @_ZN3jet6squareIdEET_S1_(double noundef %80)
  %82 = fdiv double %77, %81
  %83 = load double, ptr %14, align 8, !tbaa !11
  %84 = load double, ptr %13, align 8, !tbaa !11
  %85 = fsub double %83, %84
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  %87 = getelementptr inbounds %"class.jet::Vector", ptr %86, i32 0, i32 1
  %88 = load double, ptr %87, align 8, !tbaa !18
  %89 = call noundef double @_ZN3jet6squareIdEET_S1_(double noundef %88)
  %90 = fdiv double %85, %89
  %91 = fadd double %82, %90
  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 16, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret double %91
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZN3jet6squareIdEET_S1_(double noundef) #3

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 = { 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 #3 = { inlinehint 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, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTSN3jet5Size2E", !10, i64 0, !10, i64 8}
!15 = !{!14, !10, i64 8}
!16 = !{!17, !12, i64 0}
!17 = !{!"_ZTSN3jet6VectorIdLm2EEE", !12, i64 0, !12, i64 8}
!18 = !{!17, !12, 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::Size2" = type { i64, i64 }

; 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 uwtable
declare dso_local void @_ZNK3jet18ConstArrayAccessorIdLm2EE4sizeEv(ptr dead_on_unwind noalias writable sret(%"class.jet::Size2") align 8, ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef, i64 noundef) local_unnamed_addr #2 align 2

; 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
define dso_local noundef double @_ZN3jet10laplacian2ERKNS_18ConstArrayAccessorIdLm2EEERKNS_6VectorIdLm2EEEmm(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %1, i64 noundef %2, i64 noundef %3) local_unnamed_addr #1 {
  %5 = alloca %"class.jet::Size2", align 8
  %6 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %2, i64 noundef %3)
  %7 = load double, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  call void @_ZNK3jet18ConstArrayAccessorIdLm2EE4sizeEv(ptr dead_on_unwind nonnull writable sret(%"class.jet::Size2") align 8 %5, ptr noundef nonnull align 8 dereferenceable(24) %0)
  %.not = icmp eq i64 %2, 0
  br i1 %.not, label %13, label %8

8:                                                ; preds = %4
  %9 = add i64 %2, -1
  %10 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %9, i64 noundef %3)
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = fsub double %7, %11
  br label %13

13:                                               ; preds = %8, %4
  %.031 = phi double [ %12, %8 ], [ 0.000000e+00, %4 ]
  %14 = add i64 %2, 1
  %15 = load i64, ptr %5, align 8, !tbaa !9
  %16 = icmp ult i64 %14, %15
  br i1 %16, label %17, label %21

17:                                               ; preds = %13
  %18 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %14, i64 noundef %3)
  %19 = load double, ptr %18, align 8, !tbaa !5
  %20 = fsub double %19, %7
  br label %21

21:                                               ; preds = %17, %13
  %.030 = phi double [ %20, %17 ], [ 0.000000e+00, %13 ]
  %.not36 = icmp eq i64 %3, 0
  br i1 %.not36, label %27, label %22

22:                                               ; preds = %21
  %23 = add i64 %3, -1
  %24 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %2, i64 noundef %23)
  %25 = load double, ptr %24, align 8, !tbaa !5
  %26 = fsub double %7, %25
  br label %27

27:                                               ; preds = %22, %21
  %.029 = phi double [ %26, %22 ], [ 0.000000e+00, %21 ]
  %28 = add i64 %3, 1
  %29 = getelementptr inbounds i8, ptr %5, i64 8
  %30 = load i64, ptr %29, align 8, !tbaa !12
  %31 = icmp ult i64 %28, %30
  br i1 %31, label %32, label %36

32:                                               ; preds = %27
  %33 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet18ConstArrayAccessorIdLm2EEclEmm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %2, i64 noundef %28)
  %34 = load double, ptr %33, align 8, !tbaa !5
  %35 = fsub double %34, %7
  br label %36

36:                                               ; preds = %32, %27
  %.0 = phi double [ %35, %32 ], [ 0.000000e+00, %27 ]
  %37 = insertelement <2 x double> poison, double %.030, i64 0
  %38 = insertelement <2 x double> %37, double %.0, i64 1
  %39 = insertelement <2 x double> poison, double %.031, i64 0
  %40 = insertelement <2 x double> %39, double %.029, i64 1
  %41 = fsub <2 x double> %38, %40
  %42 = load double, ptr %1, align 8, !tbaa !13
  %43 = call noundef double @_ZN3jet6squareIdEET_S1_(double noundef %42)
  %44 = getelementptr inbounds i8, ptr %1, i64 8
  %45 = load double, ptr %44, align 8, !tbaa !15
  %46 = call noundef double @_ZN3jet6squareIdEET_S1_(double noundef %45)
  %47 = insertelement <2 x double> poison, double %43, i64 0
  %48 = insertelement <2 x double> %47, double %46, i64 1
  %49 = fdiv <2 x double> %41, %48
  %shift = shufflevector <2 x double> %49, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %50 = fadd <2 x double> %49, %shift
  %51 = extractelement <2 x double> %50, i64 0
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  ret double %51
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZN3jet6squareIdEET_S1_(double noundef) local_unnamed_addr #3

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 = { 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 #3 = { inlinehint 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTSN3jet5Size2E", !11, i64 0, !11, i64 8}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTSN3jet6VectorIdLm2EEE", !6, i64 0, !6, i64 8}
!15 = !{!14, !6, i64 8}


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