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

; 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 @_ZNK3jet22TrianglePointGenerator12forEachPointERKNS_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 double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca %"class.jet::Vector", align 8
  %14 = alloca i8, align 1
  %15 = alloca i8, align 1
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca double, align 8
  %19 = 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
  %20 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %21 = load double, ptr %7, align 8, !tbaa !9
  %22 = fdiv double %21, 2.000000e+00
  store double %22, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %23 = load double, ptr %7, align 8, !tbaa !9
  %24 = call double @sqrt(double noundef 3.000000e+00) #5
  %25 = fmul double %23, %24
  %26 = fdiv double %25, 2.000000e+00
  store double %26, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = call noundef double @_ZNK3jet11BoundingBoxIdLm2EE5widthEv(ptr noundef nonnull align 8 dereferenceable(32) %27)
  store double %28, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = call noundef double @_ZNK3jet11BoundingBoxIdLm2EE6heightEv(ptr noundef nonnull align 8 dereferenceable(32) %29)
  store double %30, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #5
  call void @_ZN3jet6VectorIdLm2EEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %13)
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #5
  store i8 0, ptr %14, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #5
  store i8 0, ptr %15, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  store i32 0, ptr %16, align 4, !tbaa !13
  br label %31

31:                                               ; preds = %102, %4
  %32 = load i32, ptr %16, align 4, !tbaa !13
  %33 = sitofp i32 %32 to double
  %34 = load double, ptr %10, align 8, !tbaa !9
  %35 = fmul double %33, %34
  %36 = load double, ptr %12, align 8, !tbaa !9
  %37 = fcmp ole double %35, %36
  br i1 %37, label %38, label %42

38:                                               ; preds = %31
  %39 = load i8, ptr %15, align 1, !tbaa !11, !range !15, !noundef !16
  %40 = trunc i8 %39 to i1
  %41 = xor i1 %40, true
  br label %42

42:                                               ; preds = %38, %31
  %43 = phi i1 [ false, %31 ], [ %41, %38 ]
  br i1 %43, label %45, label %44

44:                                               ; preds = %42
  store i32 2, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  br label %105

45:                                               ; preds = %42
  %46 = load i32, ptr %16, align 4, !tbaa !13
  %47 = sitofp i32 %46 to double
  %48 = load double, ptr %10, align 8, !tbaa !9
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %"class.jet::BoundingBox", ptr %49, i32 0, i32 0
  %51 = getelementptr inbounds %"class.jet::Vector", ptr %50, i32 0, i32 1
  %52 = load double, ptr %51, align 8, !tbaa !17
  %53 = call double @llvm.fmuladd.f64(double %47, double %48, double %52)
  %54 = getelementptr inbounds %"class.jet::Vector", ptr %13, i32 0, i32 1
  store double %53, ptr %54, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %55 = load i8, ptr %14, align 1, !tbaa !11, !range !15, !noundef !16
  %56 = trunc i8 %55 to i1
  br i1 %56, label %57, label %59

57:                                               ; preds = %45
  %58 = load double, ptr %9, align 8, !tbaa !9
  br label %60

59:                                               ; preds = %45
  br label %60

60:                                               ; preds = %59, %57
  %61 = phi double [ %58, %57 ], [ 0.000000e+00, %59 ]
  store double %61, ptr %18, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  store i32 0, ptr %19, align 4, !tbaa !13
  br label %62

62:                                               ; preds = %93, %60
  %63 = load i32, ptr %19, align 4, !tbaa !13
  %64 = sitofp i32 %63 to double
  %65 = load double, ptr %7, align 8, !tbaa !9
  %66 = load double, ptr %18, align 8, !tbaa !9
  %67 = call double @llvm.fmuladd.f64(double %64, double %65, double %66)
  %68 = load double, ptr %11, align 8, !tbaa !9
  %69 = fcmp ole double %67, %68
  br i1 %69, label %70, label %74

70:                                               ; preds = %62
  %71 = load i8, ptr %15, align 1, !tbaa !11, !range !15, !noundef !16
  %72 = trunc i8 %71 to i1
  %73 = xor i1 %72, true
  br label %74

74:                                               ; preds = %70, %62
  %75 = phi i1 [ false, %62 ], [ %73, %70 ]
  br i1 %75, label %77, label %76

76:                                               ; preds = %74
  store i32 5, ptr %17, align 4
  br label %96

77:                                               ; preds = %74
  %78 = load i32, ptr %19, align 4, !tbaa !13
  %79 = sitofp i32 %78 to double
  %80 = load double, ptr %7, align 8, !tbaa !9
  %81 = load double, ptr %18, align 8, !tbaa !9
  %82 = call double @llvm.fmuladd.f64(double %79, double %80, double %81)
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds %"class.jet::BoundingBox", ptr %83, i32 0, i32 0
  %85 = getelementptr inbounds %"class.jet::Vector", ptr %84, i32 0, i32 0
  %86 = load double, ptr %85, align 8, !tbaa !21
  %87 = fadd double %82, %86
  %88 = getelementptr inbounds %"class.jet::Vector", ptr %13, i32 0, i32 0
  store double %87, ptr %88, align 8, !tbaa !22
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  %90 = call noundef zeroext i1 @_ZNKSt8functionIFbRKN3jet6VectorIdLm2EEEEEclES4_(ptr noundef nonnull align 8 dereferenceable(32) %89, ptr noundef nonnull align 8 dereferenceable(16) %13)
  br i1 %90, label %92, label %91

91:                                               ; preds = %77
  store i8 1, ptr %15, align 1, !tbaa !11
  store i32 5, ptr %17, align 4
  br label %96

92:                                               ; preds = %77
  br label %93

93:                                               ; preds = %92
  %94 = load i32, ptr %19, align 4, !tbaa !13
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %19, align 4, !tbaa !13
  br label %62, !llvm.loop !23

96:                                               ; preds = %91, %76
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  br label %97

97:                                               ; preds = %96
  %98 = load i8, ptr %14, align 1, !tbaa !11, !range !15, !noundef !16
  %99 = trunc i8 %98 to i1
  %100 = xor i1 %99, true
  %101 = zext i1 %100 to i8
  store i8 %101, ptr %14, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  br label %102

102:                                              ; preds = %97
  %103 = load i32, ptr %16, align 4, !tbaa !13
  %104 = add nsw i32 %103, 1
  store i32 %104, ptr %16, align 4, !tbaa !13
  br label %31, !llvm.loop !25

105:                                              ; preds = %44
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  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: nounwind
declare double @sqrt(double noundef) #2

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

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

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

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

; 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 = { nounwind "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, !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 @_ZNK3jet22TrianglePointGenerator12forEachPointERKNS_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
  %6 = fmul double %2, 5.000000e-01
  %7 = fmul double %2, 0x3FFBB67AE8584CAA
  %8 = fmul double %7, 5.000000e-01
  %9 = tail call noundef double @_ZNK3jet11BoundingBoxIdLm2EE5widthEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %10 = tail call noundef double @_ZNK3jet11BoundingBoxIdLm2EE6heightEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  call void @_ZN3jet6VectorIdLm2EEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5)
  %11 = fmul double %8, 0.000000e+00
  %12 = fcmp ugt double %11, %10
  br i1 %12, label %._crit_edge39, label %.lr.ph38

.lr.ph38:                                         ; preds = %4
  %13 = getelementptr inbounds i8, ptr %1, i64 8
  %14 = getelementptr inbounds i8, ptr %5, i64 8
  br label %15

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

15:                                               ; preds = %.lr.ph38, %._crit_edge
  %16 = phi double [ 0.000000e+00, %.lr.ph38 ], [ %32, %._crit_edge ]
  %.02735 = phi i32 [ 0, %.lr.ph38 ], [ %31, %._crit_edge ]
  %indvars40 = trunc i32 %.02735 to i1
  %17 = load double, ptr %13, align 8, !tbaa !5
  %18 = call double @llvm.fmuladd.f64(double %16, double %8, double %17)
  store double %18, ptr %14, align 8, !tbaa !11
  %19 = select i1 %indvars40, double %6, double 0.000000e+00
  %20 = call double @llvm.fmuladd.f64(double %2, double 0.000000e+00, double %19)
  %21 = fcmp ugt double %20, %9
  br i1 %21, label %._crit_edge, label %.lr.ph

22:                                               ; preds = %.lr.ph
  %23 = add nuw nsw i32 %.031, 1
  %24 = uitofp nneg i32 %23 to double
  %25 = call double @llvm.fmuladd.f64(double %24, double %2, double %19)
  %26 = fcmp ugt double %25, %9
  br i1 %26, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !12

.lr.ph:                                           ; preds = %15, %22
  %27 = phi double [ %25, %22 ], [ %20, %15 ]
  %.031 = phi i32 [ %23, %22 ], [ 0, %15 ]
  %28 = load double, ptr %1, align 8, !tbaa !14
  %29 = fadd double %27, %28
  store double %29, ptr %5, align 8, !tbaa !15
  %30 = call noundef zeroext i1 @_ZNKSt8functionIFbRKN3jet6VectorIdLm2EEEEEclES4_(ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef nonnull align 8 dereferenceable(16) %5)
  br i1 %30, label %22, label %._crit_edge.loopexit

._crit_edge.loopexit:                             ; preds = %.lr.ph, %22
  %.1.ph = xor i1 %30, true
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %15
  %.1 = phi i1 [ false, %15 ], [ %.1.ph, %._crit_edge.loopexit ]
  %31 = add nuw i32 %.02735, 1
  %32 = uitofp nneg i32 %31 to double
  %33 = fmul double %8, %32
  %34 = fcmp ugt double %33, %10
  %.not30 = or i1 %34, %.1
  br i1 %.not30, label %._crit_edge39, label %15, !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 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 nounwind uwtable
declare dso_local void @_ZN3jet6VectorIdLm2EEC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) 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,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass