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

; 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::Size3" = type { i64, 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 @_ZNK3jet5ArrayIdLm3EE4sizeEv(ptr dead_on_unwind noalias writable sret(%"class.jet::Size3") align 8, ptr noundef nonnull align 8 dereferenceable(48)) #1 align 2

; 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) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN3jet8FdmBlas38lInfNormERKNS_5ArrayIdLm3EEE(ptr noundef nonnull align 8 dereferenceable(48) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.jet::Size3", align 8
  %4 = alloca double, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %3) #5
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  call void @_ZNK3jet5ArrayIdLm3EE4sizeEv(ptr dead_on_unwind writable sret(%"class.jet::Size3") align 8 %3, ptr noundef nonnull align 8 dereferenceable(48) %9)
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  store double 0.000000e+00, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store i64 0, ptr %5, align 8, !tbaa !11
  br label %10

10:                                               ; preds = %47, %1
  %11 = load i64, ptr %5, align 8, !tbaa !11
  %12 = getelementptr inbounds %"class.jet::Size3", ptr %3, i32 0, i32 2
  %13 = load i64, ptr %12, align 8, !tbaa !13
  %14 = icmp ult i64 %11, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %10
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %50

16:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store i64 0, ptr %7, align 8, !tbaa !11
  br label %17

17:                                               ; preds = %43, %16
  %18 = load i64, ptr %7, align 8, !tbaa !11
  %19 = getelementptr inbounds %"class.jet::Size3", ptr %3, i32 0, i32 1
  %20 = load i64, ptr %19, align 8, !tbaa !15
  %21 = icmp ult i64 %18, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %17
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %46

23:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 0, ptr %8, align 8, !tbaa !11
  br label %24

24:                                               ; preds = %39, %23
  %25 = load i64, ptr %8, align 8, !tbaa !11
  %26 = getelementptr inbounds %"class.jet::Size3", ptr %3, i32 0, i32 0
  %27 = load i64, ptr %26, align 8, !tbaa !16
  %28 = icmp ult i64 %25, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %24
  store i32 8, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %42

30:                                               ; preds = %24
  %31 = load double, ptr %4, align 8, !tbaa !9
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = load i64, ptr %8, align 8, !tbaa !11
  %34 = load i64, ptr %7, align 8, !tbaa !11
  %35 = load i64, ptr %5, align 8, !tbaa !11
  %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 !9
  %38 = call noundef double @_ZN3jet6absmaxIdEET_S1_S1_(double noundef %31, double noundef %37)
  store double %38, ptr %4, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %30
  %40 = load i64, ptr %8, align 8, !tbaa !11
  %41 = add i64 %40, 1
  store i64 %41, ptr %8, align 8, !tbaa !11
  br label %24, !llvm.loop !17

42:                                               ; preds = %29
  br label %43

43:                                               ; preds = %42
  %44 = load i64, ptr %7, align 8, !tbaa !11
  %45 = add i64 %44, 1
  store i64 %45, ptr %7, align 8, !tbaa !11
  br label %17, !llvm.loop !19

46:                                               ; preds = %22
  br label %47

47:                                               ; preds = %46
  %48 = load i64, ptr %5, align 8, !tbaa !11
  %49 = add i64 %48, 1
  store i64 %49, ptr %5, align 8, !tbaa !11
  br label %10, !llvm.loop !20

50:                                               ; preds = %15
  %51 = load double, ptr %4, align 8, !tbaa !9
  %52 = call double @llvm.fabs.f64(double %51)
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %3) #5
  ret double %52
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #4

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 = { 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, !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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 16}
!14 = !{!"_ZTSN3jet5Size3E", !12, i64 0, !12, i64 8, !12, i64 16}
!15 = !{!14, !12, i64 8}
!16 = !{!14, !12, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = distinct !{!20, !18}


; 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::Size3" = type { i64, 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 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 @_ZNK3jet5ArrayIdLm3EE4sizeEv(ptr dead_on_unwind noalias writable sret(%"class.jet::Size3") align 8, ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1 align 2

; 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 #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN3jet8FdmBlas38lInfNormERKNS_5ArrayIdLm3EEE(ptr noundef nonnull align 8 dereferenceable(48) %0) local_unnamed_addr #1 align 2 {
  %2 = alloca %"class.jet::Size3", align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #5
  call void @_ZNK3jet5ArrayIdLm3EE4sizeEv(ptr dead_on_unwind nonnull writable sret(%"class.jet::Size3") align 8 %2, ptr noundef nonnull align 8 dereferenceable(48) %0)
  %3 = getelementptr inbounds i8, ptr %2, i64 16
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %.not = icmp eq i64 %4, 0
  br i1 %.not, label %._crit_edge25, label %.preheader15.lr.ph

.preheader15.lr.ph:                               ; preds = %1
  %5 = getelementptr inbounds i8, ptr %2, i64 8
  %6 = load i64, ptr %5, align 8, !tbaa !10
  %.not28 = icmp eq i64 %6, 0
  br i1 %.not28, label %._crit_edge25, label %.preheader15

.preheader15:                                     ; preds = %.preheader15.lr.ph, %._crit_edge20
  %7 = phi i64 [ %14, %._crit_edge20 ], [ %4, %.preheader15.lr.ph ]
  %8 = phi i64 [ %15, %._crit_edge20 ], [ %6, %.preheader15.lr.ph ]
  %9 = phi i64 [ %16, %._crit_edge20 ], [ %6, %.preheader15.lr.ph ]
  %.01323 = phi i64 [ %17, %._crit_edge20 ], [ 0, %.preheader15.lr.ph ]
  %.01422 = phi double [ %.1.lcssa, %._crit_edge20 ], [ 0.000000e+00, %.preheader15.lr.ph ]
  %.not29 = icmp eq i64 %9, 0
  br i1 %.not29, label %._crit_edge20, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %.preheader15
  %10 = load i64, ptr %2, align 8, !tbaa !11
  %.not30 = icmp eq i64 %10, 0
  br i1 %.not30, label %._crit_edge20, label %.preheader

._crit_edge25:                                    ; preds = %._crit_edge20, %.preheader15.lr.ph, %1
  %.014.lcssa = phi double [ 0.000000e+00, %1 ], [ 0.000000e+00, %.preheader15.lr.ph ], [ %.1.lcssa, %._crit_edge20 ]
  %11 = call double @llvm.fabs.f64(double %.014.lcssa)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #5
  ret double %11

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %12 = phi i64 [ %19, %._crit_edge ], [ %8, %.preheader.lr.ph ]
  %13 = phi i64 [ %20, %._crit_edge ], [ 1, %.preheader.lr.ph ]
  %.01219 = phi i64 [ %21, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %.118 = phi double [ %.2.lcssa, %._crit_edge ], [ %.01422, %.preheader.lr.ph ]
  %.not31 = icmp eq i64 %13, 0
  br i1 %.not31, label %._crit_edge, label %.lr.ph

._crit_edge20.loopexit32:                         ; preds = %._crit_edge
  %.pre34 = load i64, ptr %3, align 8, !tbaa !5
  br label %._crit_edge20

._crit_edge20:                                    ; preds = %.preheader.lr.ph, %._crit_edge20.loopexit32, %.preheader15
  %14 = phi i64 [ %7, %.preheader15 ], [ %.pre34, %._crit_edge20.loopexit32 ], [ %7, %.preheader.lr.ph ]
  %15 = phi i64 [ %8, %.preheader15 ], [ %19, %._crit_edge20.loopexit32 ], [ %8, %.preheader.lr.ph ]
  %16 = phi i64 [ 0, %.preheader15 ], [ %19, %._crit_edge20.loopexit32 ], [ %9, %.preheader.lr.ph ]
  %.1.lcssa = phi double [ %.01422, %.preheader15 ], [ %.2.lcssa, %._crit_edge20.loopexit32 ], [ %.01422, %.preheader.lr.ph ]
  %17 = add nuw i64 %.01323, 1
  %18 = icmp ult i64 %17, %14
  br i1 %18, label %.preheader15, label %._crit_edge25, !llvm.loop !12

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

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %19 = phi i64 [ %12, %.preheader ], [ %.pre, %._crit_edge.loopexit ]
  %20 = phi i64 [ 0, %.preheader ], [ %27, %._crit_edge.loopexit ]
  %.2.lcssa = phi double [ %.118, %.preheader ], [ %25, %._crit_edge.loopexit ]
  %21 = add nuw i64 %.01219, 1
  %22 = icmp ult i64 %21, %19
  br i1 %22, label %.preheader, label %._crit_edge20.loopexit32, !llvm.loop !15

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.017 = phi i64 [ %26, %.lr.ph ], [ 0, %.preheader ]
  %.216 = phi double [ %25, %.lr.ph ], [ %.118, %.preheader ]
  %23 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNK3jet5ArrayIdLm3EEclEmmm(ptr noundef nonnull align 8 dereferenceable(48) %0, i64 noundef %.017, i64 noundef %.01219, i64 noundef %.01323)
  %24 = load double, ptr %23, align 8, !tbaa !16
  %25 = call noundef double @_ZN3jet6absmaxIdEET_S1_S1_(double noundef %.216, double noundef %24)
  %26 = add nuw i64 %.017, 1
  %27 = load i64, ptr %2, align 8, !tbaa !11
  %28 = icmp ult i64 %26, %27
  br i1 %28, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !18
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #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 = { 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 = { mustprogress 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 16}
!6 = !{!"_ZTSN3jet5Size3E", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 0}
!12 = distinct !{!12, !13, !14}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!"llvm.loop.unswitch.partial.disable"}
!15 = distinct !{!15, !13, !14}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !8, i64 0}
!18 = distinct !{!18, !13}


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