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

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

; 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: 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) #2

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

7:                                                ; preds = %2
  store double 0.000000e+00, ptr %3, align 8
  br label %32

8:                                                ; preds = %2
  %9 = getelementptr inbounds %struct.line, ptr %0, i32 0, i32 0
  %10 = load double, ptr %9, align 8, !tbaa !10
  %11 = getelementptr inbounds %struct.line, ptr %1, i32 0, i32 1
  %12 = load double, ptr %11, align 8, !tbaa !12
  %13 = getelementptr inbounds %struct.line, ptr %1, i32 0, i32 0
  %14 = load double, ptr %13, align 8, !tbaa !10
  %15 = getelementptr inbounds %struct.line, ptr %0, i32 0, i32 1
  %16 = load double, ptr %15, align 8, !tbaa !12
  %17 = fmul double %14, %16
  %18 = fneg double %17
  %19 = call double @llvm.fmuladd.f64(double %10, double %12, double %18)
  %20 = getelementptr inbounds %struct.line, ptr %0, i32 0, i32 0
  %21 = load double, ptr %20, align 8, !tbaa !10
  %22 = getelementptr inbounds %struct.line, ptr %1, i32 0, i32 0
  %23 = load double, ptr %22, align 8, !tbaa !10
  %24 = getelementptr inbounds %struct.line, ptr %0, i32 0, i32 1
  %25 = load double, ptr %24, align 8, !tbaa !12
  %26 = getelementptr inbounds %struct.line, ptr %1, i32 0, i32 1
  %27 = load double, ptr %26, align 8, !tbaa !12
  %28 = fmul double %25, %27
  %29 = call double @llvm.fmuladd.f64(double %21, double %23, double %28)
  %30 = fdiv double %19, %29
  %31 = call double @atan(double noundef %30) #4
  store double %31, ptr %3, align 8
  br label %32

32:                                               ; preds = %8, %7
  %33 = load double, ptr %3, align 8
  ret double %33
}

; Function Attrs: nounwind
declare double @atan(double noundef) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind "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 #4 = { 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 = !{i64 0, i64 8, !6, i64 8, i64 8, !6, i64 16, 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", !7, i64 0, !7, i64 8, !7, i64 16}
!12 = !{!11, !7, 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"

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

; 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 #0

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_Z5angle4lineS_(ptr nocapture noundef readonly byval(%struct.line) align 8 %0, ptr nocapture noundef readonly byval(%struct.line) align 8 %1) local_unnamed_addr #0 {
  %3 = 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 %3, label %21, label %4

4:                                                ; preds = %2
  %5 = load <2 x double>, ptr %0, align 8
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load <2 x double>, ptr %6, align 8
  %8 = load <2 x double>, ptr %1, align 8, !tbaa !5
  %9 = extractelement <2 x double> %8, i64 0
  %10 = fneg double %9
  %11 = shufflevector <2 x double> %7, <2 x double> poison, <2 x i32> zeroinitializer
  %12 = shufflevector <2 x double> %8, <2 x double> poison, <2 x i32> <i32 1, i32 poison>
  %13 = insertelement <2 x double> %12, double %10, i64 1
  %14 = fmul <2 x double> %11, %13
  %15 = shufflevector <2 x double> %5, <2 x double> poison, <2 x i32> zeroinitializer
  %16 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %15, <2 x double> %8, <2 x double> %14)
  %17 = extractelement <2 x double> %16, i64 0
  %18 = extractelement <2 x double> %16, i64 1
  %19 = fdiv double %18, %17
  %20 = tail call double @atan(double noundef %19) #3
  br label %21

21:                                               ; preds = %2, %4
  %.0 = phi double [ %20, %4 ], [ 0.000000e+00, %2 ]
  ret double %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @atan(double noundef) local_unnamed_addr #1

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

attributes #0 = { 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 #1 = { mustprogress nofree nounwind willreturn memory(write) "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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