; LLVM IR from ShahjalalShohag/code-library :: Geometry/Geometry 2D.ll (Z20ray_ray_intersection2PTS_S_S_)

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

%struct.PT = type { double, double }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z4signd(double noundef) #0

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z20ray_ray_intersection2PTS_S_S_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca i32, align 4
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %16 = getelementptr inbounds %struct.PT, ptr %2, i32 0, i32 0
  %17 = load double, ptr %16, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct.PT, ptr %0, i32 0, i32 0
  %19 = load double, ptr %18, align 8, !tbaa !9
  %20 = fsub double %17, %19
  store double %20, ptr %10, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %21 = getelementptr inbounds %struct.PT, ptr %2, i32 0, i32 1
  %22 = load double, ptr %21, align 8, !tbaa !13
  %23 = getelementptr inbounds %struct.PT, ptr %0, i32 0, i32 1
  %24 = load double, ptr %23, align 8, !tbaa !13
  %25 = fsub double %22, %24
  store double %25, ptr %11, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %26 = getelementptr inbounds %struct.PT, ptr %3, i32 0, i32 0
  %27 = load double, ptr %26, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.PT, ptr %1, i32 0, i32 1
  %29 = load double, ptr %28, align 8, !tbaa !13
  %30 = getelementptr inbounds %struct.PT, ptr %3, i32 0, i32 1
  %31 = load double, ptr %30, align 8, !tbaa !13
  %32 = getelementptr inbounds %struct.PT, ptr %1, i32 0, i32 0
  %33 = load double, ptr %32, align 8, !tbaa !9
  %34 = fmul double %31, %33
  %35 = fneg double %34
  %36 = call double @llvm.fmuladd.f64(double %27, double %29, double %35)
  store double %36, ptr %12, align 8, !tbaa !12
  %37 = load double, ptr %12, align 8, !tbaa !12
  %38 = call double @llvm.fabs.f64(double %37)
  %39 = fcmp olt double %38, 1.000000e-09
  br i1 %39, label %40, label %41

40:                                               ; preds = %4
  store i1 false, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %74

41:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %42 = load double, ptr %11, align 8, !tbaa !12
  %43 = getelementptr inbounds %struct.PT, ptr %3, i32 0, i32 0
  %44 = load double, ptr %43, align 8, !tbaa !9
  %45 = load double, ptr %10, align 8, !tbaa !12
  %46 = getelementptr inbounds %struct.PT, ptr %3, i32 0, i32 1
  %47 = load double, ptr %46, align 8, !tbaa !13
  %48 = fmul double %45, %47
  %49 = fneg double %48
  %50 = call double @llvm.fmuladd.f64(double %42, double %44, double %49)
  %51 = load double, ptr %12, align 8, !tbaa !12
  %52 = fdiv double %50, %51
  store double %52, ptr %14, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %53 = load double, ptr %11, align 8, !tbaa !12
  %54 = getelementptr inbounds %struct.PT, ptr %1, i32 0, i32 0
  %55 = load double, ptr %54, align 8, !tbaa !9
  %56 = load double, ptr %10, align 8, !tbaa !12
  %57 = getelementptr inbounds %struct.PT, ptr %1, i32 0, i32 1
  %58 = load double, ptr %57, align 8, !tbaa !13
  %59 = fmul double %56, %58
  %60 = fneg double %59
  %61 = call double @llvm.fmuladd.f64(double %53, double %55, double %60)
  %62 = load double, ptr %12, align 8, !tbaa !12
  %63 = fdiv double %61, %62
  store double %63, ptr %15, align 8, !tbaa !12
  %64 = load double, ptr %14, align 8, !tbaa !12
  %65 = call noundef i32 @_Z4signd(double noundef %64)
  %66 = icmp sge i32 %65, 0
  br i1 %66, label %67, label %72

67:                                               ; preds = %41
  %68 = load double, ptr %15, align 8, !tbaa !12
  %69 = call noundef i32 @_Z4signd(double noundef %68)
  %70 = icmp sge i32 %69, 0
  br i1 %70, label %71, label %72

71:                                               ; preds = %67
  store i1 true, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %73

72:                                               ; preds = %67, %41
  store i1 false, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %73

73:                                               ; preds = %72, %71
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  br label %74

74:                                               ; preds = %73, %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %75 = load i1, ptr %5, align 1
  ret i1 %75
}

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


; 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 i32 @_Z4signd(double noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z20ray_ray_intersection2PTS_S_S_(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3) local_unnamed_addr #0 {
  %5 = load double, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = load double, ptr %6, align 8, !tbaa !10
  %8 = getelementptr inbounds i8, ptr %3, i64 8
  %9 = load double, ptr %8, align 8, !tbaa !10
  %10 = load double, ptr %1, align 8, !tbaa !5
  %11 = fneg double %9
  %12 = fmul double %10, %11
  %13 = tail call double @llvm.fmuladd.f64(double %5, double %7, double %12)
  %14 = tail call double @llvm.fabs.f64(double %13)
  %15 = fcmp olt double %14, 1.000000e-09
  br i1 %15, label %38, label %16

16:                                               ; preds = %4
  %17 = getelementptr inbounds i8, ptr %2, i64 8
  %18 = load double, ptr %17, align 8, !tbaa !10
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  %20 = load double, ptr %19, align 8, !tbaa !10
  %21 = fsub double %18, %20
  %22 = load double, ptr %2, align 8, !tbaa !5
  %23 = load double, ptr %0, align 8, !tbaa !5
  %24 = fsub double %22, %23
  %25 = fneg double %24
  %26 = fmul double %9, %25
  %27 = tail call double @llvm.fmuladd.f64(double %21, double %5, double %26)
  %28 = fdiv double %27, %13
  %29 = tail call noundef i32 @_Z4signd(double noundef %28)
  %30 = icmp sgt i32 %29, -1
  br i1 %30, label %31, label %37

31:                                               ; preds = %16
  %32 = fmul double %7, %25
  %33 = tail call double @llvm.fmuladd.f64(double %21, double %10, double %32)
  %34 = fdiv double %33, %13
  %35 = tail call noundef i32 @_Z4signd(double noundef %34)
  %36 = icmp sgt i32 %35, -1
  br i1 %36, label %38, label %37

37:                                               ; preds = %31, %16
  br label %38

38:                                               ; preds = %37, %31, %4
  %.1 = phi i1 [ false, %4 ], [ false, %37 ], [ true, %31 ]
  ret i1 %.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 = { 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 0}
!6 = !{!"_ZTS2PT", !7, i64 0, !7, i64 8}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 8}


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