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

; 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 }
%"class.jet::IterativeLevelSetSolver2" = type { %"class.jet::LevelSetSolver2", double }
%"class.jet::LevelSetSolver2" = type { ptr }

; 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
define dso_local noundef double @_ZN3jet24IterativeLevelSetSolver214pseudoTimeStepENS_18ConstArrayAccessorIdLm2EEERKNS_6VectorIdLm2EEE(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %1, ptr noundef nonnull align 8 dereferenceable(16) %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"class.jet::Size2", align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  %14 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #4
  call void @_ZNK3jet18ConstArrayAccessorIdLm2EE4sizeEv(ptr dead_on_unwind writable sret(%"class.jet::Size2") align 8 %7, ptr noundef nonnull align 8 dereferenceable(24) %1)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = getelementptr inbounds %"class.jet::Vector", ptr %16, i32 0, i32 0
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = getelementptr inbounds %"class.jet::Vector", ptr %18, i32 0, i32 1
  %20 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %17, ptr noundef nonnull align 8 dereferenceable(8) %19)
  %21 = load double, ptr %20, align 8, !tbaa !9
  store double %21, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %22 = call noundef double @_ZNSt14numeric_limitsIdE3maxEv() #4
  %23 = fneg double %22
  store double %23, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %24 = getelementptr inbounds %"class.jet::IterativeLevelSetSolver2", ptr %15, i32 0, i32 1
  %25 = load double, ptr %24, align 8, !tbaa !11
  %26 = load double, ptr %8, align 8, !tbaa !9
  %27 = fmul double %25, %26
  store double %27, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store i64 0, ptr %11, align 8, !tbaa !14
  br label %28

28:                                               ; preds = %52, %3
  %29 = load i64, ptr %11, align 8, !tbaa !14
  %30 = getelementptr inbounds %"class.jet::Size2", ptr %7, i32 0, i32 1
  %31 = load i64, ptr %30, align 8, !tbaa !16
  %32 = icmp ult i64 %29, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %28
  store i32 2, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %55

34:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store i64 0, ptr %13, align 8, !tbaa !14
  br label %35

35:                                               ; preds = %48, %34
  %36 = load i64, ptr %13, align 8, !tbaa !14
  %37 = getelementptr inbounds %"class.jet::Size2", ptr %7, i32 0, i32 0
  %38 = load i64, ptr %37, align 8, !tbaa !18
  %39 = icmp ult i64 %36, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %35
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %51

41:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load i64, ptr %13, align 8, !tbaa !14
  %44 = load i64, ptr %11, align 8, !tbaa !14
  %45 = call noundef double @_ZN3jet24IterativeLevelSetSolver24signERKNS_18ConstArrayAccessorIdLm2EEERKNS_6VectorIdLm2EEEmm(ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(16) %42, i64 noundef %43, i64 noundef %44)
  store double %45, ptr %14, align 8, !tbaa !9
  %46 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull align 8 dereferenceable(8) %9)
  %47 = load double, ptr %46, align 8, !tbaa !9
  store double %47, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %48

48:                                               ; preds = %41
  %49 = load i64, ptr %13, align 8, !tbaa !14
  %50 = add i64 %49, 1
  store i64 %50, ptr %13, align 8, !tbaa !14
  br label %35, !llvm.loop !19

51:                                               ; preds = %40
  br label %52

52:                                               ; preds = %51
  %53 = load i64, ptr %11, align 8, !tbaa !14
  %54 = add i64 %53, 1
  store i64 %54, ptr %11, align 8, !tbaa !14
  br label %28, !llvm.loop !21

55:                                               ; preds = %33
  br label %56

56:                                               ; preds = %65, %55
  %57 = load double, ptr %10, align 8, !tbaa !9
  %58 = load double, ptr %9, align 8, !tbaa !9
  %59 = fmul double %57, %58
  %60 = load double, ptr %8, align 8, !tbaa !9
  %61 = fdiv double %59, %60
  %62 = getelementptr inbounds %"class.jet::IterativeLevelSetSolver2", ptr %15, i32 0, i32 1
  %63 = load double, ptr %62, align 8, !tbaa !11
  %64 = fcmp ogt double %61, %63
  br i1 %64, label %65, label %68

65:                                               ; preds = %56
  %66 = load double, ptr %10, align 8, !tbaa !9
  %67 = fmul double %66, 5.000000e-01
  store double %67, ptr %10, align 8, !tbaa !9
  br label %56, !llvm.loop !22

68:                                               ; preds = %56
  %69 = load double, ptr %10, align 8, !tbaa !9
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #4
  ret double %69
}

; 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 @_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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN3jet24IterativeLevelSetSolver24signERKNS_18ConstArrayAccessorIdLm2EEERKNS_6VectorIdLm2EEEmm(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(16), i64 noundef, i64 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNSt14numeric_limitsIdE3maxEv() #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 = { 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 #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 = !{!"double", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_ZTSN3jet24IterativeLevelSetSolver2E", !13, i64 0, !10, i64 8}
!13 = !{!"_ZTSN3jet15LevelSetSolver2E"}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!17, !15, i64 8}
!17 = !{!"_ZTSN3jet5Size2E", !15, i64 0, !15, i64 8}
!18 = !{!17, !15, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = distinct !{!22, !20}


; 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
define dso_local noundef double @_ZN3jet24IterativeLevelSetSolver214pseudoTimeStepENS_18ConstArrayAccessorIdLm2EEERKNS_6VectorIdLm2EEE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(16) %0, ptr noundef nonnull %1, ptr noundef nonnull align 8 dereferenceable(16) %2) local_unnamed_addr #1 align 2 {
  %4 = alloca %"class.jet::Size2", align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  call void @_ZNK3jet18ConstArrayAccessorIdLm2EE4sizeEv(ptr dead_on_unwind nonnull writable sret(%"class.jet::Size2") align 8 %4, ptr noundef nonnull align 8 dereferenceable(24) %1)
  %7 = getelementptr inbounds i8, ptr %2, i64 8
  %8 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %9 = load double, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %10 = call noundef double @_ZNSt14numeric_limitsIdE3maxEv() #4
  %11 = fneg double %10
  store double %11, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = load double, ptr %12, align 8, !tbaa !9
  %14 = fmul double %9, %13
  %15 = getelementptr inbounds i8, ptr %4, i64 8
  %16 = load i64, ptr %15, align 8, !tbaa !12
  %.not = icmp eq i64 %16, 0
  %17 = load i64, ptr %4, align 8
  %.not22 = icmp eq i64 %17, 0
  %or.cond = select i1 %.not, i1 true, i1 %.not22
  br i1 %or.cond, label %.preheader, label %.preheader16

.preheader16:                                     ; preds = %3, %._crit_edge
  %18 = phi double [ %26, %._crit_edge ], [ %11, %3 ]
  %19 = phi i64 [ %27, %._crit_edge ], [ %16, %3 ]
  %20 = phi i64 [ %28, %._crit_edge ], [ 1, %3 ]
  %.01418 = phi i64 [ %29, %._crit_edge ], [ 0, %3 ]
  %.not23 = icmp eq i64 %20, 0
  br i1 %.not23, label %._crit_edge, label %.lr.ph

.preheader.loopexit24:                            ; preds = %._crit_edge
  %.pre25 = load double, ptr %12, align 8, !tbaa !9
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit24, %3
  %21 = phi double [ %.pre25, %.preheader.loopexit24 ], [ %13, %3 ]
  %22 = phi double [ %26, %.preheader.loopexit24 ], [ %11, %3 ]
  %23 = fmul double %14, %22
  %24 = fdiv double %23, %9
  %25 = fcmp ogt double %24, %21
  br i1 %25, label %.lr.ph20, label %._crit_edge21

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = load i64, ptr %15, align 8, !tbaa !12
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader16
  %26 = phi double [ %33, %._crit_edge.loopexit ], [ %18, %.preheader16 ]
  %27 = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %19, %.preheader16 ]
  %28 = phi i64 [ %35, %._crit_edge.loopexit ], [ 0, %.preheader16 ]
  %29 = add nuw i64 %.01418, 1
  %30 = icmp ult i64 %29, %27
  br i1 %30, label %.preheader16, label %.preheader.loopexit24, !llvm.loop !15

.lr.ph:                                           ; preds = %.preheader16, %.lr.ph
  %.017 = phi i64 [ %34, %.lr.ph ], [ 0, %.preheader16 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  %31 = call noundef double @_ZN3jet24IterativeLevelSetSolver24signERKNS_18ConstArrayAccessorIdLm2EEERKNS_6VectorIdLm2EEEmm(ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(16) %2, i64 noundef %.017, i64 noundef %.01418)
  store double %31, ptr %6, align 8, !tbaa !5
  %32 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %33 = load double, ptr %32, align 8, !tbaa !5
  store double %33, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  %34 = add nuw i64 %.017, 1
  %35 = load i64, ptr %4, align 8, !tbaa !18
  %36 = icmp ult i64 %34, %35
  br i1 %36, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !19

.lr.ph20:                                         ; preds = %.preheader, %.lr.ph20
  %.01519 = phi double [ %37, %.lr.ph20 ], [ %14, %.preheader ]
  %37 = fmul double %.01519, 5.000000e-01
  %38 = fmul double %37, %22
  %39 = fdiv double %38, %9
  %40 = fcmp ogt double %39, %21
  br i1 %40, label %.lr.ph20, label %._crit_edge21, !llvm.loop !20

._crit_edge21:                                    ; preds = %.lr.ph20, %.preheader
  %.015.lcssa = phi double [ %14, %.preheader ], [ %37, %.lr.ph20 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  ret double %.015.lcssa
}

; 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 @_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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIdERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZN3jet24IterativeLevelSetSolver24signERKNS_18ConstArrayAccessorIdLm2EEERKNS_6VectorIdLm2EEEmm(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(16), i64 noundef, i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNSt14numeric_limitsIdE3maxEv() local_unnamed_addr #3 align 2

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 = { 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 #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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"_ZTSN3jet24IterativeLevelSetSolver2E", !11, i64 0, !6, i64 8}
!11 = !{!"_ZTSN3jet15LevelSetSolver2E"}
!12 = !{!13, !14, i64 8}
!13 = !{!"_ZTSN3jet5Size2E", !14, i64 0, !14, i64 8}
!14 = !{!"long", !7, i64 0}
!15 = distinct !{!15, !16, !17}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!"llvm.loop.unswitch.partial.disable"}
!18 = !{!13, !14, i64 0}
!19 = distinct !{!19, !16}
!20 = distinct !{!20, !16}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass