; LLVM IR from ippeb/ACM-ICPC :: computational_geometry/line_line_intersection (line_line_intersection)

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z9parallelQ4lineS_(ptr noundef byval(%struct.line) align 8, ptr noundef byval(%struct.line) align 8) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3absd(double noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z10same_lineQ4lineS_(ptr noundef byval(%struct.line) align 8, ptr noundef byval(%struct.line) align 8) #1

; 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) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_Z18intersection_point4lineS_P5point(ptr noundef byval(%struct.line) align 8 %0, ptr noundef byval(%struct.line) align 8 %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca %struct.line, align 8
  %6 = alloca %struct.line, align 8
  %7 = alloca %struct.line, align 8
  %8 = alloca %struct.line, align 8
  store ptr %2, ptr %4, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 %0, i64 24, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %1, i64 24, i1 false), !tbaa.struct !9
  %9 = call noundef zeroext i1 @_Z10same_lineQ4lineS_(ptr noundef byval(%struct.line) align 8 %5, ptr noundef byval(%struct.line) align 8 %6)
  br i1 %9, label %10, label %15

10:                                               ; preds = %3
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.point, ptr %11, i32 0, i32 0
  store double 0.000000e+00, ptr %12, align 8, !tbaa !12
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.point, ptr %13, i32 0, i32 1
  store double 0.000000e+00, ptr %14, align 8, !tbaa !14
  br label %72

15:                                               ; preds = %3
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %0, i64 24, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %1, i64 24, i1 false), !tbaa.struct !9
  %16 = call noundef zeroext i1 @_Z9parallelQ4lineS_(ptr noundef byval(%struct.line) align 8 %7, ptr noundef byval(%struct.line) align 8 %8)
  br i1 %16, label %17, label %18

17:                                               ; preds = %15
  br label %72

18:                                               ; preds = %15
  %19 = getelementptr inbounds %struct.line, ptr %1, i32 0, i32 1
  %20 = load double, ptr %19, align 8, !tbaa !15
  %21 = getelementptr inbounds %struct.line, ptr %0, i32 0, i32 2
  %22 = load double, ptr %21, align 8, !tbaa !17
  %23 = getelementptr inbounds %struct.line, ptr %0, i32 0, i32 1
  %24 = load double, ptr %23, align 8, !tbaa !15
  %25 = getelementptr inbounds %struct.line, ptr %1, i32 0, i32 2
  %26 = load double, ptr %25, align 8, !tbaa !17
  %27 = fmul double %24, %26
  %28 = fneg double %27
  %29 = call double @llvm.fmuladd.f64(double %20, double %22, double %28)
  %30 = getelementptr inbounds %struct.line, ptr %0, i32 0, i32 1
  %31 = load double, ptr %30, align 8, !tbaa !15
  %32 = getelementptr inbounds %struct.line, ptr %1, i32 0, i32 0
  %33 = load double, ptr %32, align 8, !tbaa !18
  %34 = getelementptr inbounds %struct.line, ptr %1, i32 0, i32 1
  %35 = load double, ptr %34, align 8, !tbaa !15
  %36 = getelementptr inbounds %struct.line, ptr %0, i32 0, i32 0
  %37 = load double, ptr %36, align 8, !tbaa !18
  %38 = fmul double %35, %37
  %39 = fneg double %38
  %40 = call double @llvm.fmuladd.f64(double %31, double %33, double %39)
  %41 = fdiv double %29, %40
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.point, ptr %42, i32 0, i32 0
  store double %41, ptr %43, align 8, !tbaa !12
  %44 = getelementptr inbounds %struct.line, ptr %0, i32 0, i32 1
  %45 = load double, ptr %44, align 8, !tbaa !15
  %46 = call noundef double @_ZSt3absd(double noundef %45)
  %47 = fcmp ogt double %46, 0x3E7AD7F29ABCAF48
  br i1 %47, label %48, label %60

48:                                               ; preds = %18
  %49 = getelementptr inbounds %struct.line, ptr %0, i32 0, i32 0
  %50 = load double, ptr %49, align 8, !tbaa !18
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.point, ptr %51, i32 0, i32 0
  %53 = load double, ptr %52, align 8, !tbaa !12
  %54 = getelementptr inbounds %struct.line, ptr %0, i32 0, i32 2
  %55 = load double, ptr %54, align 8, !tbaa !17
  %56 = call double @llvm.fmuladd.f64(double %50, double %53, double %55)
  %57 = fneg double %56
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.point, ptr %58, i32 0, i32 1
  store double %57, ptr %59, align 8, !tbaa !14
  br label %72

60:                                               ; preds = %18
  %61 = getelementptr inbounds %struct.line, ptr %1, i32 0, i32 0
  %62 = load double, ptr %61, align 8, !tbaa !18
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.point, ptr %63, i32 0, i32 0
  %65 = load double, ptr %64, align 8, !tbaa !12
  %66 = getelementptr inbounds %struct.line, ptr %1, i32 0, i32 2
  %67 = load double, ptr %66, align 8, !tbaa !17
  %68 = call double @llvm.fmuladd.f64(double %62, double %65, double %67)
  %69 = fneg double %68
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.point, ptr %70, i32 0, i32 1
  store double %69, ptr %71, align 8, !tbaa !14
  br label %72

72:                                               ; preds = %60, %48, %17, %10
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 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 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i64 0, i64 8, !10, i64 8, i64 8, !10, i64 16, i64 8, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"double", !7, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"_ZTS5point", !11, i64 0, !11, i64 8}
!14 = !{!13, !11, i64 8}
!15 = !{!16, !11, i64 8}
!16 = !{!"_ZTS4line", !11, i64 0, !11, i64 8, !11, i64 16}
!17 = !{!16, !11, i64 16}
!18 = !{!16, !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"

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z9parallelQ4lineS_(ptr noundef byval(%struct.line) align 8, ptr noundef byval(%struct.line) align 8) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3absd(double noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z10same_lineQ4lineS_(ptr noundef byval(%struct.line) align 8, ptr noundef byval(%struct.line) align 8) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z18intersection_point4lineS_P5point(ptr nocapture noundef readonly byval(%struct.line) align 8 %0, ptr nocapture noundef readonly byval(%struct.line) align 8 %1, ptr nocapture noundef %2) local_unnamed_addr #1 {
  %4 = tail call noundef zeroext i1 @_Z10same_lineQ4lineS_(ptr noundef nonnull byval(%struct.line) align 8 %0, ptr noundef nonnull byval(%struct.line) align 8 %1)
  br i1 %4, label %5, label %6

5:                                                ; preds = %3
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %2, i8 0, i64 16, i1 false)
  br label %37

6:                                                ; preds = %3
  %7 = tail call noundef zeroext i1 @_Z9parallelQ4lineS_(ptr noundef nonnull byval(%struct.line) align 8 %0, ptr noundef nonnull byval(%struct.line) align 8 %1)
  br i1 %7, label %37, label %8

8:                                                ; preds = %6
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = getelementptr inbounds i8, ptr %1, i64 16
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = load double, ptr %0, align 8, !tbaa !10
  %13 = load <2 x double>, ptr %9, align 8, !tbaa !11
  %14 = load <2 x double>, ptr %1, align 8, !tbaa !11
  %15 = shufflevector <2 x double> %14, <2 x double> %13, <2 x i32> <i32 1, i32 2>
  %16 = fneg <2 x double> %15
  %17 = insertelement <2 x double> poison, double %12, i64 0
  %18 = insertelement <2 x double> %17, double %11, i64 1
  %19 = fmul <2 x double> %18, %16
  %20 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %13, <2 x double> %14, <2 x double> %19)
  %21 = extractelement <2 x double> %20, i64 0
  %22 = extractelement <2 x double> %20, i64 1
  %23 = fdiv double %22, %21
  store double %23, ptr %2, align 8, !tbaa !12
  %24 = extractelement <2 x double> %13, i64 0
  %25 = tail call noundef double @_ZSt3absd(double noundef %24)
  %26 = fcmp ogt double %25, 0x3E7AD7F29ABCAF48
  %27 = load double, ptr %2, align 8, !tbaa !12
  %28 = getelementptr inbounds i8, ptr %2, i64 8
  br i1 %26, label %29, label %33

29:                                               ; preds = %8
  %30 = extractelement <2 x double> %13, i64 1
  %31 = tail call double @llvm.fmuladd.f64(double %12, double %27, double %30)
  %32 = fneg double %31
  store double %32, ptr %28, align 8, !tbaa !14
  br label %37

33:                                               ; preds = %8
  %34 = extractelement <2 x double> %14, i64 0
  %35 = tail call double @llvm.fmuladd.f64(double %34, double %27, double %11)
  %36 = fneg double %35
  store double %36, ptr %28, align 8, !tbaa !14
  br label %37

37:                                               ; preds = %6, %33, %29, %5
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 16}
!6 = !{!"_ZTS4line", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"_ZTS5point", !7, i64 0, !7, i64 8}
!14 = !{!13, !7, i64 8}


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