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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK3jet19GridPointGenerator212forEachPointERKNS_11BoundingBoxIdLm2EEEdRKSt8functionIFbRKNS_6VectorIdLm2EEEEE(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, double noundef %2, ptr noundef nonnull align 8 dereferenceable(32) %3) unnamed_addr #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %"class.jet::Vector", align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca i8, align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store double %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #4
  call void @_ZN3jet6VectorIdLm2EEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %9)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = call noundef double @_ZNK3jet11BoundingBoxIdLm2EE5widthEv(ptr noundef nonnull align 8 dereferenceable(32) %17)
  store double %18, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = call noundef double @_ZNK3jet11BoundingBoxIdLm2EE6heightEv(ptr noundef nonnull align 8 dereferenceable(32) %19)
  store double %20, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #4
  store i8 0, ptr %12, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !13
  br label %21

21:                                               ; preds = %78, %4
  %22 = load i32, ptr %13, align 4, !tbaa !13
  %23 = sitofp i32 %22 to double
  %24 = load double, ptr %7, align 8, !tbaa !9
  %25 = fmul double %23, %24
  %26 = load double, ptr %11, align 8, !tbaa !9
  %27 = fcmp ole double %25, %26
  br i1 %27, label %28, label %32

28:                                               ; preds = %21
  %29 = load i8, ptr %12, align 1, !tbaa !11, !range !15, !noundef !16
  %30 = trunc i8 %29 to i1
  %31 = xor i1 %30, true
  br label %32

32:                                               ; preds = %28, %21
  %33 = phi i1 [ false, %21 ], [ %31, %28 ]
  br i1 %33, label %35, label %34

34:                                               ; preds = %32
  store i32 2, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %81

35:                                               ; preds = %32
  %36 = load i32, ptr %13, align 4, !tbaa !13
  %37 = sitofp i32 %36 to double
  %38 = load double, ptr %7, align 8, !tbaa !9
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %"class.jet::BoundingBox", ptr %39, i32 0, i32 0
  %41 = getelementptr inbounds %"class.jet::Vector", ptr %40, i32 0, i32 1
  %42 = load double, ptr %41, align 8, !tbaa !17
  %43 = call double @llvm.fmuladd.f64(double %37, double %38, double %42)
  %44 = getelementptr inbounds %"class.jet::Vector", ptr %9, i32 0, i32 1
  store double %43, ptr %44, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !13
  br label %45

45:                                               ; preds = %73, %35
  %46 = load i32, ptr %15, align 4, !tbaa !13
  %47 = sitofp i32 %46 to double
  %48 = load double, ptr %7, align 8, !tbaa !9
  %49 = fmul double %47, %48
  %50 = load double, ptr %10, align 8, !tbaa !9
  %51 = fcmp ole double %49, %50
  br i1 %51, label %52, label %56

52:                                               ; preds = %45
  %53 = load i8, ptr %12, align 1, !tbaa !11, !range !15, !noundef !16
  %54 = trunc i8 %53 to i1
  %55 = xor i1 %54, true
  br label %56

56:                                               ; preds = %52, %45
  %57 = phi i1 [ false, %45 ], [ %55, %52 ]
  br i1 %57, label %59, label %58

58:                                               ; preds = %56
  store i32 5, ptr %14, align 4
  br label %76

59:                                               ; preds = %56
  %60 = load i32, ptr %15, align 4, !tbaa !13
  %61 = sitofp i32 %60 to double
  %62 = load double, ptr %7, align 8, !tbaa !9
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %"class.jet::BoundingBox", ptr %63, i32 0, i32 0
  %65 = getelementptr inbounds %"class.jet::Vector", ptr %64, i32 0, i32 0
  %66 = load double, ptr %65, align 8, !tbaa !21
  %67 = call double @llvm.fmuladd.f64(double %61, double %62, double %66)
  %68 = getelementptr inbounds %"class.jet::Vector", ptr %9, i32 0, i32 0
  store double %67, ptr %68, align 8, !tbaa !22
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = call noundef zeroext i1 @_ZNKSt8functionIFbRKN3jet6VectorIdLm2EEEEEclES4_(ptr noundef nonnull align 8 dereferenceable(32) %69, ptr noundef nonnull align 8 dereferenceable(16) %9)
  br i1 %70, label %72, label %71

71:                                               ; preds = %59
  store i8 1, ptr %12, align 1, !tbaa !11
  store i32 5, ptr %14, align 4
  br label %76

72:                                               ; preds = %59
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %15, align 4, !tbaa !13
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %15, align 4, !tbaa !13
  br label %45, !llvm.loop !23

76:                                               ; preds = %71, %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %77

77:                                               ; preds = %76
  br label %78

78:                                               ; preds = %77
  %79 = load i32, ptr %13, align 4, !tbaa !13
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %13, align 4, !tbaa !13
  br label %21, !llvm.loop !25

81:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 1, 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 16, ptr %9) #4
  ret void
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK3jet11BoundingBoxIdLm2EE5widthEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK3jet11BoundingBoxIdLm2EE6heightEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNKSt8functionIFbRKN3jet6VectorIdLm2EEEEEclES4_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(16)) #0 align 2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!18, !10, i64 8}
!18 = !{!"_ZTSN3jet11BoundingBoxIdLm2EEE", !19, i64 0, !19, i64 16}
!19 = !{!"_ZTSN3jet6VectorIdLm2EEE", !10, i64 0, !10, i64 8}
!20 = !{!19, !10, i64 8}
!21 = !{!18, !10, i64 0}
!22 = !{!19, !10, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = distinct !{!25, !24}


; 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 uwtable
define dso_local void @_ZNK3jet19GridPointGenerator212forEachPointERKNS_11BoundingBoxIdLm2EEEdRKSt8functionIFbRKNS_6VectorIdLm2EEEEE(ptr nocapture noundef nonnull readnone align 8 dereferenceable(8) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, double noundef %2, ptr noundef nonnull align 8 dereferenceable(32) %3) unnamed_addr #0 align 2 {
  %5 = alloca %"class.jet::Vector", align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  call void @_ZN3jet6VectorIdLm2EEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5)
  %6 = call noundef double @_ZNK3jet11BoundingBoxIdLm2EE5widthEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %7 = call noundef double @_ZNK3jet11BoundingBoxIdLm2EE6heightEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %8 = fmul double %2, 0.000000e+00
  %9 = fcmp ugt double %8, %7
  br i1 %9, label %._crit_edge29, label %.lr.ph28

.lr.ph28:                                         ; preds = %4
  %10 = getelementptr inbounds i8, ptr %1, i64 8
  %11 = getelementptr inbounds i8, ptr %5, i64 8
  %12 = fcmp ugt double %8, %6
  br i1 %12, label %._crit_edge29, label %.lr.ph

._crit_edge29:                                    ; preds = %._crit_edge, %21, %.lr.ph28, %4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  ret void

.lr.ph:                                           ; preds = %.lr.ph28, %._crit_edge
  %13 = phi double [ %27, %._crit_edge ], [ 0.000000e+00, %.lr.ph28 ]
  %.01926 = phi i32 [ %26, %._crit_edge ], [ 0, %.lr.ph28 ]
  %14 = load double, ptr %10, align 8, !tbaa !5
  %15 = call double @llvm.fmuladd.f64(double %13, double %2, double %14)
  store double %15, ptr %11, align 8, !tbaa !11
  br label %21

16:                                               ; preds = %21
  %17 = add nuw nsw i32 %.022, 1
  %18 = uitofp nneg i32 %17 to double
  %19 = fmul double %18, %2
  %20 = fcmp ugt double %19, %6
  br i1 %20, label %._crit_edge, label %21, !llvm.loop !12

21:                                               ; preds = %.lr.ph, %16
  %22 = phi double [ 0.000000e+00, %.lr.ph ], [ %18, %16 ]
  %.022 = phi i32 [ 0, %.lr.ph ], [ %17, %16 ]
  %23 = load double, ptr %1, align 8, !tbaa !14
  %24 = call double @llvm.fmuladd.f64(double %22, double %2, double %23)
  store double %24, ptr %5, align 8, !tbaa !15
  %25 = call noundef zeroext i1 @_ZNKSt8functionIFbRKN3jet6VectorIdLm2EEEEEclES4_(ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef nonnull align 8 dereferenceable(16) %5)
  br i1 %25, label %16, label %._crit_edge29

._crit_edge:                                      ; preds = %16
  %26 = add nuw nsw i32 %.01926, 1
  %27 = uitofp nneg i32 %26 to double
  %28 = fmul double %27, %2
  %29 = fcmp ole double %28, %7
  %.not21.not = and i1 %29, %25
  br i1 %.not21.not, label %.lr.ph, label %._crit_edge29, !llvm.loop !16
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK3jet11BoundingBoxIdLm2EE5widthEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK3jet11BoundingBoxIdLm2EE6heightEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNKSt8functionIFbRKN3jet6VectorIdLm2EEEEEclES4_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

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

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


; Effective O3 passes: AggressiveInstCombinePass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass