; LLVM IR from ImperialCollegeLondon/pnflow :: src/pnm/pnflow/ElementThroat.ll (ZNK6Throat14crossesPlaneAtEd)

; 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.Elem = type { %class.Apex, [5 x %class.SlvrElm], i8, i32, ptr, double, double, i32, %"class.std::vector", ptr, double, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, %"struct.std::pair", %"struct.std::pair", %"struct.std::pair", i32, i32, i32, i32, %class.var3 }
%class.Apex = type { ptr, i8, double, double, ptr, i32, double, double, double, double, i8, i8, i8, i8, %"struct.std::pair" }
%class.SlvrElm = type { i8, i8, i8, double, double }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Elem *, std::allocator<Elem *>>::_Vector_impl" }
%"struct.std::_Vector_base<Elem *, std::allocator<Elem *>>::_Vector_impl" = type { %"struct.std::_Vector_base<Elem *, std::allocator<Elem *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Elem *, std::allocator<Elem *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { i32, double }
%class.var3 = type { double, double, double }

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

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

; 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 noundef zeroext i1 @_ZNK6Throat14crossesPlaneAtEd(ptr noundef nonnull align 8 dereferenceable(456) %0, double noundef %1) unnamed_addr #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store double %1, ptr %4, align 8, !tbaa !9
  %8 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %9 = getelementptr inbounds %class.Elem, ptr %8, i32 0, i32 8
  %10 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIP4ElemSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef 0) #3
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN4Elem4nodeEv(ptr noundef nonnull align 8 dereferenceable(408) %11)
  %13 = getelementptr inbounds %class.var3, ptr %12, i32 0, i32 0
  %14 = load double, ptr %13, align 8, !tbaa !11
  store double %14, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %15 = getelementptr inbounds %class.Elem, ptr %8, i32 0, i32 8
  %16 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIP4ElemSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %15, i64 noundef 1) #3
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN4Elem4nodeEv(ptr noundef nonnull align 8 dereferenceable(408) %17)
  %19 = getelementptr inbounds %class.var3, ptr %18, i32 0, i32 0
  %20 = load double, ptr %19, align 8, !tbaa !11
  store double %20, ptr %6, align 8, !tbaa !9
  %21 = load double, ptr %6, align 8, !tbaa !9
  %22 = load double, ptr %5, align 8, !tbaa !9
  %23 = fcmp olt double %21, %22
  br i1 %23, label %24, label %28

24:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %25 = load double, ptr %6, align 8, !tbaa !9
  store double %25, ptr %7, align 8, !tbaa !9
  %26 = load double, ptr %5, align 8, !tbaa !9
  store double %26, ptr %6, align 8, !tbaa !9
  %27 = load double, ptr %7, align 8, !tbaa !9
  store double %27, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %28

28:                                               ; preds = %24, %2
  %29 = load double, ptr %5, align 8, !tbaa !9
  %30 = load double, ptr %4, align 8, !tbaa !9
  %31 = fcmp olt double %29, %30
  br i1 %31, label %32, label %36

32:                                               ; preds = %28
  %33 = load double, ptr %6, align 8, !tbaa !9
  %34 = load double, ptr %4, align 8, !tbaa !9
  %35 = fcmp oge double %33, %34
  br label %36

36:                                               ; preds = %32, %28
  %37 = phi i1 [ false, %28 ], [ %35, %32 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret i1 %37
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 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 = { 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 0}
!12 = !{!"_ZTS4var3IdE", !10, i64 0, !10, i64 8, !10, i64 16}


; 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
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIP4ElemSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK6Throat14crossesPlaneAtEd(ptr noundef nonnull align 8 dereferenceable(456) %0, double noundef %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 264
  %4 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIP4ElemSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef 0) #1
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN4Elem4nodeEv(ptr noundef nonnull align 8 dereferenceable(408) %5)
  %7 = load double, ptr %6, align 8, !tbaa !9
  %8 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIP4ElemSaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %3, i64 noundef 1) #1
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZN4Elem4nodeEv(ptr noundef nonnull align 8 dereferenceable(408) %9)
  %11 = load double, ptr %10, align 8, !tbaa !9
  %12 = fcmp olt double %11, %7
  %.010 = select i1 %12, double %7, double %11
  %.0 = select i1 %12, double %11, double %7
  %13 = fcmp olt double %.0, %1
  %14 = fcmp oge double %.010, %1
  %15 = select i1 %13, i1 %14, i1 false
  ret i1 %15
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN4Elem4nodeEv(ptr noundef nonnull align 8 dereferenceable(408)) local_unnamed_addr #0 align 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 = { 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, !11, i64 0}
!10 = !{!"_ZTS4var3IdE", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"double", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass