; LLVM IR from gzc/CLRS :: C33-Computational-Geometry/exercise_code/colinear.ll (Z6myfuncRK5PointS1_)

; 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.Point = type { float, float }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z6myfuncRK5PointS1_(ptr noundef nonnull align 4 dereferenceable(8) %0, ptr noundef nonnull align 4 dereferenceable(8) %1) #0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %class.Point, ptr %6, i32 0, i32 1
  %8 = load float, ptr %7, align 4, !tbaa !9
  %9 = fcmp ogt float %8, 0.000000e+00
  br i1 %9, label %10, label %16

10:                                               ; preds = %2
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %class.Point, ptr %11, i32 0, i32 1
  %13 = load float, ptr %12, align 4, !tbaa !9
  %14 = fcmp olt float %13, 0.000000e+00
  br i1 %14, label %15, label %16

15:                                               ; preds = %10
  store i1 true, ptr %3, align 1
  br label %47

16:                                               ; preds = %10, %2
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %class.Point, ptr %17, i32 0, i32 1
  %19 = load float, ptr %18, align 4, !tbaa !9
  %20 = fcmp olt float %19, 0.000000e+00
  br i1 %20, label %21, label %27

21:                                               ; preds = %16
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %class.Point, ptr %22, i32 0, i32 1
  %24 = load float, ptr %23, align 4, !tbaa !9
  %25 = fcmp ogt float %24, 0.000000e+00
  br i1 %25, label %26, label %27

26:                                               ; preds = %21
  store i1 false, ptr %3, align 1
  br label %47

27:                                               ; preds = %21, %16
  br label %28

28:                                               ; preds = %27
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %class.Point, ptr %29, i32 0, i32 0
  %31 = load float, ptr %30, align 4, !tbaa !12
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %class.Point, ptr %32, i32 0, i32 1
  %34 = load float, ptr %33, align 4, !tbaa !9
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %class.Point, ptr %35, i32 0, i32 0
  %37 = load float, ptr %36, align 4, !tbaa !12
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %class.Point, ptr %38, i32 0, i32 1
  %40 = load float, ptr %39, align 4, !tbaa !9
  %41 = fmul float %37, %40
  %42 = fneg float %41
  %43 = call float @llvm.fmuladd.f32(float %31, float %34, float %42)
  %44 = fcmp olt float %43, 0.000000e+00
  br i1 %44, label %45, label %46

45:                                               ; preds = %28
  store i1 false, ptr %3, align 1
  br label %47

46:                                               ; preds = %28
  store i1 true, ptr %3, align 1
  br label %47

47:                                               ; preds = %46, %45, %26, %15
  %48 = load i1, ptr %3, align 1
  ret i1 %48
}

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

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 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 4}
!10 = !{!"_ZTS5Point", !11, i64 0, !11, i64 4}
!11 = !{!"float", !7, i64 0}
!12 = !{!10, !11, i64 0}


; 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 nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef zeroext i1 @_Z6myfuncRK5PointS1_(ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %0, ptr nocapture noundef nonnull readonly align 4 dereferenceable(8) %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 4
  %4 = load float, ptr %3, align 4, !tbaa !5
  %5 = fcmp ogt float %4, 0.000000e+00
  %6 = getelementptr inbounds i8, ptr %1, i64 4
  %7 = load float, ptr %6, align 4
  %8 = fcmp olt float %7, 0.000000e+00
  %or.cond = select i1 %5, i1 %8, i1 false
  br i1 %or.cond, label %19, label %9

9:                                                ; preds = %2
  %10 = fcmp olt float %4, 0.000000e+00
  %11 = fcmp ogt float %7, 0.000000e+00
  %or.cond13 = select i1 %10, i1 %11, i1 false
  br i1 %or.cond13, label %19, label %12

12:                                               ; preds = %9
  %13 = load float, ptr %0, align 4, !tbaa !10
  %14 = load float, ptr %1, align 4, !tbaa !10
  %15 = fneg float %14
  %16 = fmul float %4, %15
  %17 = tail call float @llvm.fmuladd.f32(float %13, float %7, float %16)
  %18 = fcmp uge float %17, 0.000000e+00
  br label %19

19:                                               ; preds = %12, %9, %2
  %.0 = phi i1 [ true, %2 ], [ false, %9 ], [ %18, %12 ]
  ret i1 %.0
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 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, !7, i64 4}
!6 = !{!"_ZTS5Point", !7, i64 0, !7, i64 4}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}


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