; LLVM IR from tyoma/agge :: src/agge/dash.ll (ZN4agge4dash15seek_dash_startEv)

; 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.agge::dash" = type { %"class.agge::vertex_sequence", ptr, ptr, float, float, float, %"struct.agge::point", i32, %"class.agge::pod_vector.0" }
%"class.agge::vertex_sequence" = type { %"class.agge::pod_vector" }
%"class.agge::pod_vector" = type { ptr, ptr, ptr }
%"struct.agge::point" = type { float, float }
%"class.agge::pod_vector.0" = type { ptr, ptr, ptr }
%"struct.agge::dash::dash_gap" = type { float, float }

; 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
define dso_local void @_ZN4agge4dash15seek_dash_startEv(ptr noundef nonnull align 8 dereferenceable(88) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca float, align 4
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %9 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store float 0.000000e+00, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %10 = getelementptr inbounds %"class.agge::dash", ptr %9, i32 0, i32 8
  %11 = call noundef ptr @_ZN4agge10pod_vectorINS_4dash8dash_gapEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %10)
  store ptr %11, ptr %4, align 8, !tbaa !5
  br label %12

12:                                               ; preds = %28, %1
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %"class.agge::dash", ptr %9, i32 0, i32 8
  %15 = call noundef ptr @_ZN4agge10pod_vectorINS_4dash8dash_gapEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %14)
  %16 = icmp ne ptr %13, %15
  br i1 %16, label %18, label %17

17:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %31

18:                                               ; preds = %12
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %"struct.agge::dash::dash_gap", ptr %19, i32 0, i32 0
  %21 = load float, ptr %20, align 4, !tbaa !11
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.agge::dash::dash_gap", ptr %22, i32 0, i32 1
  %24 = load float, ptr %23, align 4, !tbaa !13
  %25 = fadd float %21, %24
  %26 = load float, ptr %3, align 4, !tbaa !9
  %27 = fadd float %26, %25
  store float %27, ptr %3, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %18
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.agge::dash::dash_gap", ptr %29, i32 1
  store ptr %30, ptr %4, align 8, !tbaa !5
  br label %12, !llvm.loop !14

31:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %32 = getelementptr inbounds %"class.agge::dash", ptr %9, i32 0, i32 5
  %33 = load float, ptr %32, align 8, !tbaa !16
  %34 = load float, ptr %3, align 4, !tbaa !9
  %35 = getelementptr inbounds %"class.agge::dash", ptr %9, i32 0, i32 5
  %36 = load float, ptr %35, align 8, !tbaa !16
  %37 = load float, ptr %3, align 4, !tbaa !9
  %38 = fdiv float %36, %37
  %39 = fptosi float %38 to i32
  %40 = sitofp i32 %39 to float
  %41 = fneg float %34
  %42 = call float @llvm.fmuladd.f32(float %41, float %40, float %33)
  store float %42, ptr %5, align 4, !tbaa !9
  %43 = getelementptr inbounds %"class.agge::dash", ptr %9, i32 0, i32 8
  %44 = call noundef ptr @_ZN4agge10pod_vectorINS_4dash8dash_gapEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %43)
  %45 = getelementptr inbounds %"class.agge::dash", ptr %9, i32 0, i32 2
  store ptr %44, ptr %45, align 8, !tbaa !23
  br label %46

46:                                               ; preds = %67, %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %47 = getelementptr inbounds %"class.agge::dash", ptr %9, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !23
  %49 = getelementptr inbounds %"struct.agge::dash::dash_gap", ptr %48, i32 0, i32 0
  %50 = load float, ptr %49, align 4, !tbaa !11
  %51 = getelementptr inbounds %"class.agge::dash", ptr %9, i32 0, i32 2
  %52 = load ptr, ptr %51, align 8, !tbaa !23
  %53 = getelementptr inbounds %"struct.agge::dash::dash_gap", ptr %52, i32 0, i32 1
  %54 = load float, ptr %53, align 4, !tbaa !13
  %55 = fadd float %50, %54
  store float %55, ptr %6, align 4, !tbaa !9
  %56 = load float, ptr %5, align 4, !tbaa !9
  %57 = load float, ptr %6, align 4, !tbaa !9
  %58 = fcmp olt float %56, %57
  br i1 %58, label %59, label %60

59:                                               ; preds = %46
  store i32 5, ptr %7, align 4
  br label %64

60:                                               ; preds = %46
  %61 = load float, ptr %6, align 4, !tbaa !9
  %62 = load float, ptr %5, align 4, !tbaa !9
  %63 = fsub float %62, %61
  store float %63, ptr %5, align 4, !tbaa !9
  store i32 0, ptr %7, align 4
  br label %64

64:                                               ; preds = %60, %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %65 = load i32, ptr %7, align 4
  switch i32 %65, label %98 [
    i32 0, label %66
    i32 5, label %71
  ]

66:                                               ; preds = %64
  br label %67

67:                                               ; preds = %66
  %68 = getelementptr inbounds %"class.agge::dash", ptr %9, i32 0, i32 2
  %69 = load ptr, ptr %68, align 8, !tbaa !23
  %70 = getelementptr inbounds %"struct.agge::dash::dash_gap", ptr %69, i32 1
  store ptr %70, ptr %68, align 8, !tbaa !23
  br label %46, !llvm.loop !24

71:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %72 = getelementptr inbounds %"class.agge::dash", ptr %9, i32 0, i32 2
  %73 = load ptr, ptr %72, align 8, !tbaa !23
  %74 = getelementptr inbounds %"struct.agge::dash::dash_gap", ptr %73, i32 0, i32 0
  %75 = load float, ptr %74, align 4, !tbaa !11
  %76 = load float, ptr %5, align 4, !tbaa !9
  %77 = fsub float %75, %76
  store float %77, ptr %8, align 4, !tbaa !9
  %78 = load float, ptr %8, align 4, !tbaa !9
  %79 = fcmp ogt float %78, 0.000000e+00
  br i1 %79, label %80, label %84

80:                                               ; preds = %71
  %81 = getelementptr inbounds %"class.agge::dash", ptr %9, i32 0, i32 3
  store float 0.000000e+00, ptr %81, align 8, !tbaa !25
  %82 = load float, ptr %8, align 4, !tbaa !9
  %83 = getelementptr inbounds %"class.agge::dash", ptr %9, i32 0, i32 4
  store float %82, ptr %83, align 4, !tbaa !26
  br label %97

84:                                               ; preds = %71
  %85 = getelementptr inbounds %"class.agge::dash", ptr %9, i32 0, i32 2
  %86 = load ptr, ptr %85, align 8, !tbaa !23
  %87 = getelementptr inbounds %"struct.agge::dash::dash_gap", ptr %86, i32 0, i32 1
  %88 = load float, ptr %87, align 4, !tbaa !13
  %89 = load float, ptr %8, align 4, !tbaa !9
  %90 = fadd float %88, %89
  %91 = getelementptr inbounds %"class.agge::dash", ptr %9, i32 0, i32 3
  store float %90, ptr %91, align 8, !tbaa !25
  %92 = getelementptr inbounds %"class.agge::dash", ptr %9, i32 0, i32 2
  %93 = load ptr, ptr %92, align 8, !tbaa !23
  %94 = getelementptr inbounds %"struct.agge::dash::dash_gap", ptr %93, i32 0, i32 0
  %95 = load float, ptr %94, align 4, !tbaa !11
  %96 = getelementptr inbounds %"class.agge::dash", ptr %9, i32 0, i32 4
  store float %95, ptr %96, align 4, !tbaa !26
  br label %97

97:                                               ; preds = %84, %80
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret void

98:                                               ; preds = %64
  unreachable
}

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #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 = { 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 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN4agge4dash8dash_gapE", !10, i64 0, !10, i64 4}
!13 = !{!12, !10, i64 4}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !10, i64 48}
!17 = !{!"_ZTSN4agge4dashE", !18, i64 0, !6, i64 24, !6, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !20, i64 52, !21, i64 60, !22, i64 64}
!18 = !{!"_ZTSN4agge15vertex_sequenceE", !19, i64 0}
!19 = !{!"_ZTSN4agge10pod_vectorINS_6vertexEEE", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{!"_ZTSN4agge5pointIfEE", !10, i64 0, !10, i64 4}
!21 = !{!"_ZTSN4agge4dash5stateE", !7, i64 0}
!22 = !{!"_ZTSN4agge10pod_vectorINS_4dash8dash_gapEEE", !6, i64 0, !6, i64 8, !6, i64 16}
!23 = !{!17, !6, i64 32}
!24 = distinct !{!24, !15}
!25 = !{!17, !10, i64 40}
!26 = !{!17, !10, i64 44}


; 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"

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4agge4dash15seek_dash_startEv(ptr noundef nonnull align 8 dereferenceable(88) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 64
  %3 = tail call noundef ptr @_ZN4agge10pod_vectorINS_4dash8dash_gapEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %2)
  %4 = tail call noundef ptr @_ZN4agge10pod_vectorINS_4dash8dash_gapEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %2)
  %.not23 = icmp eq ptr %3, %4
  br i1 %.not23, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %1
  %.0.lcssa = phi float [ 0.000000e+00, %1 ], [ %22, %.lr.ph ]
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  %6 = load float, ptr %5, align 8, !tbaa !5
  %7 = fdiv float %6, %.0.lcssa
  %8 = fptosi float %7 to i32
  %9 = sitofp i32 %8 to float
  %10 = fneg float %.0.lcssa
  %11 = tail call float @llvm.fmuladd.f32(float %10, float %9, float %6)
  %12 = tail call noundef ptr @_ZN4agge10pod_vectorINS_4dash8dash_gapEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %2)
  %13 = load float, ptr %12, align 4, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %12, i64 4
  %15 = load float, ptr %14, align 4, !tbaa !18
  %16 = fadd float %13, %15
  %17 = fcmp olt float %11, %16
  br i1 %17, label %._crit_edge30, label %.lr.ph29

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.025 = phi float [ %22, %.lr.ph ], [ 0.000000e+00, %1 ]
  %.01724 = phi ptr [ %23, %.lr.ph ], [ %3, %1 ]
  %18 = load float, ptr %.01724, align 4, !tbaa !16
  %19 = getelementptr inbounds i8, ptr %.01724, i64 4
  %20 = load float, ptr %19, align 4, !tbaa !18
  %21 = fadd float %18, %20
  %22 = fadd float %.025, %21
  %23 = getelementptr inbounds i8, ptr %.01724, i64 8
  %24 = tail call noundef ptr @_ZN4agge10pod_vectorINS_4dash8dash_gapEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %2)
  %.not = icmp eq ptr %23, %24
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !19

.lr.ph29:                                         ; preds = %._crit_edge, %.lr.ph29
  %25 = phi float [ %31, %.lr.ph29 ], [ %16, %._crit_edge ]
  %.01827 = phi float [ %26, %.lr.ph29 ], [ %11, %._crit_edge ]
  %storemerge26 = phi ptr [ %27, %.lr.ph29 ], [ %12, %._crit_edge ]
  %26 = fsub float %.01827, %25
  %27 = getelementptr inbounds i8, ptr %storemerge26, i64 8
  %28 = load float, ptr %27, align 4, !tbaa !16
  %29 = getelementptr inbounds i8, ptr %storemerge26, i64 12
  %30 = load float, ptr %29, align 4, !tbaa !18
  %31 = fadd float %28, %30
  %32 = fcmp olt float %26, %31
  br i1 %32, label %._crit_edge30, label %.lr.ph29, !llvm.loop !21

._crit_edge30:                                    ; preds = %.lr.ph29, %._crit_edge
  %storemerge.lcssa = phi ptr [ %12, %._crit_edge ], [ %27, %.lr.ph29 ]
  %.018.lcssa = phi float [ %11, %._crit_edge ], [ %26, %.lr.ph29 ]
  %.lcssa22 = phi float [ %13, %._crit_edge ], [ %28, %.lr.ph29 ]
  %.lcssa = phi float [ %15, %._crit_edge ], [ %30, %.lr.ph29 ]
  %33 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %storemerge.lcssa, ptr %33, align 8, !tbaa !22
  %34 = fsub float %.lcssa22, %.018.lcssa
  %35 = fcmp ogt float %34, 0.000000e+00
  %36 = fadd float %.lcssa, %34
  %.sink = select i1 %35, float 0.000000e+00, float %36
  %.lcssa22.sink = select i1 %35, float %34, float %.lcssa22
  %37 = getelementptr inbounds i8, ptr %0, i64 40
  store float %.sink, ptr %37, align 8
  %38 = getelementptr inbounds i8, ptr %0, i64 44
  store float %.lcssa22.sink, ptr %38, align 4
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4agge10pod_vectorINS_4dash8dash_gapEE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4agge10pod_vectorINS_4dash8dash_gapEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

attributes #0 = { 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 #1 = { 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !12, i64 48}
!6 = !{!"_ZTSN4agge4dashE", !7, i64 0, !9, i64 24, !9, i64 32, !12, i64 40, !12, i64 44, !12, i64 48, !13, i64 52, !14, i64 60, !15, i64 64}
!7 = !{!"_ZTSN4agge15vertex_sequenceE", !8, i64 0}
!8 = !{!"_ZTSN4agge10pod_vectorINS_6vertexEEE", !9, i64 0, !9, i64 8, !9, i64 16}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"float", !10, i64 0}
!13 = !{!"_ZTSN4agge5pointIfEE", !12, i64 0, !12, i64 4}
!14 = !{!"_ZTSN4agge4dash5stateE", !10, i64 0}
!15 = !{!"_ZTSN4agge10pod_vectorINS_4dash8dash_gapEEE", !9, i64 0, !9, i64 8, !9, i64 16}
!16 = !{!17, !12, i64 0}
!17 = !{!"_ZTSN4agge4dash8dash_gapE", !12, i64 0, !12, i64 4}
!18 = !{!17, !12, i64 4}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = !{!6, !9, i64 32}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass