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

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

@.str.5 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__._Z22circle_circle_relation2PTdS_d = external hidden unnamed_addr constant [51 x i8], align 1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2PTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_Z4dist2PTS_(ptr noundef, ptr noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z22circle_circle_relation2PTdS_d(ptr noundef %0, double noundef %1, ptr noundef %2, double noundef %3) #5 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca ptr, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca %struct.PT, align 8
  %12 = alloca %struct.PT, align 8
  %13 = alloca i32, align 4
  %14 = alloca double, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store double %1, ptr %7, align 8, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store double %3, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @_ZN2PTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef nonnull align 8 dereferenceable(16) %0)
  call void @_ZN2PTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %12, ptr noundef nonnull align 8 dereferenceable(16) %2)
  %15 = call noundef double @_Z4dist2PTS_(ptr noundef %11, ptr noundef %12)
  store double %15, ptr %10, align 8, !tbaa !9
  %16 = load double, ptr %10, align 8, !tbaa !9
  %17 = load double, ptr %7, align 8, !tbaa !9
  %18 = fsub double %16, %17
  %19 = load double, ptr %9, align 8, !tbaa !9
  %20 = fsub double %18, %19
  %21 = call noundef i32 @_Z4signd(double noundef %20)
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %23, label %24

23:                                               ; preds = %4
  store i32 5, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %68

24:                                               ; preds = %4
  %25 = load double, ptr %10, align 8, !tbaa !9
  %26 = load double, ptr %7, align 8, !tbaa !9
  %27 = fsub double %25, %26
  %28 = load double, ptr %9, align 8, !tbaa !9
  %29 = fsub double %27, %28
  %30 = call noundef i32 @_Z4signd(double noundef %29)
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %24
  store i32 4, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %68

33:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %34 = load double, ptr %7, align 8, !tbaa !9
  %35 = load double, ptr %9, align 8, !tbaa !9
  %36 = fsub double %34, %35
  %37 = call double @llvm.fabs.f64(double %36)
  store double %37, ptr %14, align 8, !tbaa !9
  %38 = load double, ptr %10, align 8, !tbaa !9
  %39 = load double, ptr %7, align 8, !tbaa !9
  %40 = fsub double %38, %39
  %41 = load double, ptr %9, align 8, !tbaa !9
  %42 = fsub double %40, %41
  %43 = call noundef i32 @_Z4signd(double noundef %42)
  %44 = icmp slt i32 %43, 0
  br i1 %44, label %45, label %52

45:                                               ; preds = %33
  %46 = load double, ptr %10, align 8, !tbaa !9
  %47 = load double, ptr %14, align 8, !tbaa !9
  %48 = fsub double %46, %47
  %49 = call noundef i32 @_Z4signd(double noundef %48)
  %50 = icmp sgt i32 %49, 0
  br i1 %50, label %51, label %52

51:                                               ; preds = %45
  store i32 3, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %67

52:                                               ; preds = %45, %33
  %53 = load double, ptr %10, align 8, !tbaa !9
  %54 = load double, ptr %14, align 8, !tbaa !9
  %55 = fsub double %53, %54
  %56 = call noundef i32 @_Z4signd(double noundef %55)
  %57 = icmp eq i32 %56, 0
  br i1 %57, label %58, label %59

58:                                               ; preds = %52
  store i32 2, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %67

59:                                               ; preds = %52
  %60 = load double, ptr %10, align 8, !tbaa !9
  %61 = load double, ptr %14, align 8, !tbaa !9
  %62 = fsub double %60, %61
  %63 = call noundef i32 @_Z4signd(double noundef %62)
  %64 = icmp slt i32 %63, 0
  br i1 %64, label %65, label %66

65:                                               ; preds = %59
  store i32 1, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %67

66:                                               ; preds = %59
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.5, i32 noundef 340, ptr noundef @__PRETTY_FUNCTION__._Z22circle_circle_relation2PTdS_d) #7
  unreachable

67:                                               ; preds = %65, %58, %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %68

68:                                               ; preds = %67, %32, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  %69 = load i32, ptr %5, align 4
  ret i32 %69
}

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 willreturn memory(argmem: readwrite) }
attributes #2 = { noreturn 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { inlinehint 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { noreturn 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, !10, i64 0}
!10 = !{!"double", !7, 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.PT = type { double, double }

@.str.5 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@__PRETTY_FUNCTION__._Z22circle_circle_relation2PTdS_d = external hidden unnamed_addr constant [51 x i8], align 1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2PTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef double @_Z4dist2PTS_(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 1, 6) i32 @_Z22circle_circle_relation2PTdS_d(ptr noundef nonnull %0, double noundef %1, ptr noundef %2, double noundef %3) local_unnamed_addr #4 {
  %5 = alloca %struct.PT, align 8
  %6 = alloca %struct.PT, align 8
  call void @_ZN2PTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 8 dereferenceable(16) %0)
  call void @_ZN2PTC2ERKS_(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull align 8 dereferenceable(16) %2)
  %7 = call noundef double @_Z4dist2PTS_(ptr noundef nonnull %5, ptr noundef nonnull %6)
  %8 = fsub double %7, %1
  %9 = fsub double %8, %3
  %10 = call noundef i32 @_Z4signd(double noundef %9)
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %30, label %12

12:                                               ; preds = %4
  %13 = call noundef i32 @_Z4signd(double noundef %9)
  %14 = icmp eq i32 %13, 0
  br i1 %14, label %30, label %15

15:                                               ; preds = %12
  %16 = fsub double %1, %3
  %17 = call double @llvm.fabs.f64(double %16)
  %18 = call noundef i32 @_Z4signd(double noundef %9)
  %19 = icmp slt i32 %18, 0
  %20 = fsub double %7, %17
  br i1 %19, label %21, label %._crit_edge

21:                                               ; preds = %15
  %22 = call noundef i32 @_Z4signd(double noundef %20)
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %30, label %._crit_edge

._crit_edge:                                      ; preds = %15, %21
  %24 = call noundef i32 @_Z4signd(double noundef %20)
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %30, label %26

26:                                               ; preds = %._crit_edge
  %27 = call noundef i32 @_Z4signd(double noundef %20)
  %28 = icmp slt i32 %27, 0
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.5, i32 noundef 340, ptr noundef nonnull @__PRETTY_FUNCTION__._Z22circle_circle_relation2PTdS_d) #5
  unreachable

30:                                               ; preds = %21, %._crit_edge, %26, %12, %4
  %.1 = phi i32 [ 5, %4 ], [ 4, %12 ], [ 3, %21 ], [ 2, %._crit_edge ], [ 1, %26 ]
  ret i32 %.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 = { noreturn 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 #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { inlinehint 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 #4 = { 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 #5 = { noreturn 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)"}


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