; LLVM IR from lzyrapx/Competitive-Programming :: 51Nod/1264（计算几何）（线段相交）.ll (Z13dot_online_in5point4line)

; 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.line = type { %struct.point, %struct.point }
%struct.point = type { double, double }

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z13dot_online_in5point4line(double %0, double %1, ptr noundef byval(%struct.line) align 8 %2) #0 {
  %4 = alloca %struct.point, align 8
  %5 = alloca %struct.point, align 8
  %6 = alloca %struct.point, align 8
  %7 = alloca %struct.point, align 8
  %8 = alloca %struct.point, align 8
  %9 = alloca %struct.point, align 8
  %10 = alloca %struct.point, align 8
  %11 = alloca %struct.point, align 8
  %12 = alloca %struct.point, align 8
  %13 = alloca %struct.point, align 8
  %14 = getelementptr inbounds { double, double }, ptr %4, i32 0, i32 0
  store double %0, ptr %14, align 8
  %15 = getelementptr inbounds { double, double }, ptr %4, i32 0, i32 1
  store double %1, ptr %15, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 %4, i64 16, i1 false), !tbaa.struct !5
  %16 = getelementptr inbounds %struct.line, ptr %2, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %16, i64 16, i1 false), !tbaa.struct !5
  %17 = getelementptr inbounds %struct.line, ptr %2, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %17, i64 16, i1 false), !tbaa.struct !5
  %18 = getelementptr inbounds { double, double }, ptr %5, i32 0, i32 0
  %19 = load double, ptr %18, align 8
  %20 = getelementptr inbounds { double, double }, ptr %5, i32 0, i32 1
  %21 = load double, ptr %20, align 8
  %22 = getelementptr inbounds { double, double }, ptr %6, i32 0, i32 0
  %23 = load double, ptr %22, align 8
  %24 = getelementptr inbounds { double, double }, ptr %6, i32 0, i32 1
  %25 = load double, ptr %24, align 8
  %26 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 0
  %27 = load double, ptr %26, align 8
  %28 = getelementptr inbounds { double, double }, ptr %7, i32 0, i32 1
  %29 = load double, ptr %28, align 8
  %30 = call noundef double @_Z5xmult5pointS_S_(double %19, double %21, double %23, double %25, double %27, double %29)
  %31 = fcmp ogt double %30, 0.000000e+00
  br i1 %31, label %32, label %48

32:                                               ; preds = %3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %4, i64 16, i1 false), !tbaa.struct !5
  %33 = getelementptr inbounds %struct.line, ptr %2, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %33, i64 16, i1 false), !tbaa.struct !5
  %34 = getelementptr inbounds %struct.line, ptr %2, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %34, i64 16, i1 false), !tbaa.struct !5
  %35 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 0
  %36 = load double, ptr %35, align 8
  %37 = getelementptr inbounds { double, double }, ptr %8, i32 0, i32 1
  %38 = load double, ptr %37, align 8
  %39 = getelementptr inbounds { double, double }, ptr %9, i32 0, i32 0
  %40 = load double, ptr %39, align 8
  %41 = getelementptr inbounds { double, double }, ptr %9, i32 0, i32 1
  %42 = load double, ptr %41, align 8
  %43 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 0
  %44 = load double, ptr %43, align 8
  %45 = getelementptr inbounds { double, double }, ptr %10, i32 0, i32 1
  %46 = load double, ptr %45, align 8
  %47 = call noundef double @_Z5xmult5pointS_S_(double %36, double %38, double %40, double %42, double %44, double %46)
  br label %65

48:                                               ; preds = %3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %4, i64 16, i1 false), !tbaa.struct !5
  %49 = getelementptr inbounds %struct.line, ptr %2, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %49, i64 16, i1 false), !tbaa.struct !5
  %50 = getelementptr inbounds %struct.line, ptr %2, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %50, i64 16, i1 false), !tbaa.struct !5
  %51 = getelementptr inbounds { double, double }, ptr %11, i32 0, i32 0
  %52 = load double, ptr %51, align 8
  %53 = getelementptr inbounds { double, double }, ptr %11, i32 0, i32 1
  %54 = load double, ptr %53, align 8
  %55 = getelementptr inbounds { double, double }, ptr %12, i32 0, i32 0
  %56 = load double, ptr %55, align 8
  %57 = getelementptr inbounds { double, double }, ptr %12, i32 0, i32 1
  %58 = load double, ptr %57, align 8
  %59 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 0
  %60 = load double, ptr %59, align 8
  %61 = getelementptr inbounds { double, double }, ptr %13, i32 0, i32 1
  %62 = load double, ptr %61, align 8
  %63 = call noundef double @_Z5xmult5pointS_S_(double %52, double %54, double %56, double %58, double %60, double %62)
  %64 = fneg double %63
  br label %65

65:                                               ; preds = %48, %32
  %66 = phi double [ %47, %32 ], [ %64, %48 ]
  %67 = fcmp olt double %66, 1.000000e-08
  br i1 %67, label %68, label %98

68:                                               ; preds = %65
  %69 = getelementptr inbounds %struct.line, ptr %2, i32 0, i32 0
  %70 = getelementptr inbounds %struct.point, ptr %69, i32 0, i32 0
  %71 = load double, ptr %70, align 8, !tbaa !10
  %72 = getelementptr inbounds %struct.point, ptr %4, i32 0, i32 0
  %73 = load double, ptr %72, align 8, !tbaa !13
  %74 = fsub double %71, %73
  %75 = getelementptr inbounds %struct.line, ptr %2, i32 0, i32 1
  %76 = getelementptr inbounds %struct.point, ptr %75, i32 0, i32 0
  %77 = load double, ptr %76, align 8, !tbaa !14
  %78 = getelementptr inbounds %struct.point, ptr %4, i32 0, i32 0
  %79 = load double, ptr %78, align 8, !tbaa !13
  %80 = fsub double %77, %79
  %81 = fmul double %74, %80
  %82 = fcmp olt double %81, 1.000000e-08
  br i1 %82, label %83, label %98

83:                                               ; preds = %68
  %84 = getelementptr inbounds %struct.line, ptr %2, i32 0, i32 0
  %85 = getelementptr inbounds %struct.point, ptr %84, i32 0, i32 1
  %86 = load double, ptr %85, align 8, !tbaa !15
  %87 = getelementptr inbounds %struct.point, ptr %4, i32 0, i32 1
  %88 = load double, ptr %87, align 8, !tbaa !16
  %89 = fsub double %86, %88
  %90 = getelementptr inbounds %struct.line, ptr %2, i32 0, i32 1
  %91 = getelementptr inbounds %struct.point, ptr %90, i32 0, i32 1
  %92 = load double, ptr %91, align 8, !tbaa !17
  %93 = getelementptr inbounds %struct.point, ptr %4, i32 0, i32 1
  %94 = load double, ptr %93, align 8, !tbaa !16
  %95 = fsub double %92, %94
  %96 = fmul double %89, %95
  %97 = fcmp olt double %96, 1.000000e-08
  br label %98

98:                                               ; preds = %83, %68, %65
  %99 = phi i1 [ false, %68 ], [ false, %65 ], [ %97, %83 ]
  %100 = zext i1 %99 to i32
  ret i32 %100
}

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 nounwind willreturn memory(argmem: readwrite) }

!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 = !{i64 0, i64 8, !6, i64 8, i64 8, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !7, i64 0}
!11 = !{!"_ZTS4line", !12, i64 0, !12, i64 16}
!12 = !{!"_ZTS5point", !7, i64 0, !7, i64 8}
!13 = !{!12, !7, i64 0}
!14 = !{!11, !7, i64 16}
!15 = !{!11, !7, i64 8}
!16 = !{!12, !7, i64 8}
!17 = !{!11, !7, i64 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"

%struct.line = type { %struct.point, %struct.point }
%struct.point = type { double, double }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_Z5xmult5pointS_S_(double, double, double, double, double, double) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef range(i32 0, 2) i32 @_Z13dot_online_in5point4line(double %0, double %1, ptr nocapture noundef readonly byval(%struct.line) align 8 %2) local_unnamed_addr #0 {
  %.sroa.013.0.copyload = load double, ptr %2, align 8, !tbaa !5
  %.sroa.214.0..sroa_idx = getelementptr inbounds i8, ptr %2, i64 8
  %.sroa.214.0.copyload = load double, ptr %.sroa.214.0..sroa_idx, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %2, i64 16
  %.sroa.011.0.copyload = load double, ptr %4, align 8, !tbaa !5
  %.sroa.212.0..sroa_idx = getelementptr inbounds i8, ptr %2, i64 24
  %.sroa.212.0.copyload = load double, ptr %.sroa.212.0..sroa_idx, align 8, !tbaa !5
  %5 = tail call noundef double @_Z5xmult5pointS_S_(double %0, double %1, double %.sroa.013.0.copyload, double %.sroa.214.0.copyload, double %.sroa.011.0.copyload, double %.sroa.212.0.copyload)
  %6 = fcmp ogt double %5, 0.000000e+00
  %7 = tail call noundef double @_Z5xmult5pointS_S_(double %0, double %1, double %.sroa.013.0.copyload, double %.sroa.214.0.copyload, double %.sroa.011.0.copyload, double %.sroa.212.0.copyload)
  %8 = fneg double %7
  %9 = select i1 %6, double %7, double %8
  %10 = fcmp olt double %9, 1.000000e-08
  br i1 %10, label %11, label %22

11:                                               ; preds = %3
  %12 = fsub double %.sroa.013.0.copyload, %0
  %13 = fsub double %.sroa.011.0.copyload, %0
  %14 = fmul double %12, %13
  %15 = fcmp olt double %14, 1.000000e-08
  br i1 %15, label %16, label %22

16:                                               ; preds = %11
  %17 = fsub double %.sroa.214.0.copyload, %1
  %18 = fsub double %.sroa.212.0.copyload, %1
  %19 = fmul double %17, %18
  %20 = fcmp olt double %19, 1.000000e-08
  %21 = zext i1 %20 to i32
  br label %22

22:                                               ; preds = %16, %11, %3
  %23 = phi i32 [ 0, %11 ], [ 0, %3 ], [ %21, %16 ]
  ret i32 %23
}

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

!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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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