; LLVM IR from FernandoFong/ComputationalGeometry :: ConvexHull/GiftWrapping/GiftWrapping.ll (Z5angleSt4pairIiiES0_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.std::pair" = type { i32, i32 }

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z10same_pointSt4pairIiiES0_(i64, i64) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_Z5angleSt4pairIiiES0_d(i64 %0, i64 %1, double noundef %2) #2 {
  %4 = alloca double, align 8
  %5 = alloca %"struct.std::pair", align 4
  %6 = alloca %"struct.std::pair", align 4
  %7 = alloca double, align 8
  %8 = alloca %"struct.std::pair", align 4
  %9 = alloca %"struct.std::pair", align 4
  %10 = alloca double, align 8
  %11 = alloca i32, align 4
  store i64 %0, ptr %5, align 4
  store i64 %1, ptr %6, align 4
  store double %2, ptr %7, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %5, i64 8, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 4 %6, i64 8, i1 false)
  %12 = load i64, ptr %8, align 4
  %13 = load i64, ptr %9, align 4
  %14 = call noundef zeroext i1 @_Z10same_pointSt4pairIiiES0_(i64 %12, i64 %13)
  br i1 %14, label %15, label %16

15:                                               ; preds = %3
  store double -1.000000e+00, ptr %4, align 8
  br label %41

16:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %17 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 1
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 1
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = sub nsw i32 %18, %20
  %22 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 0
  %23 = load i32, ptr %22, align 4, !tbaa !12
  %24 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 0
  %25 = load i32, ptr %24, align 4, !tbaa !12
  %26 = sub nsw i32 %23, %25
  %27 = call noundef double @_ZSt5atan2IiiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef %21, i32 noundef %26)
  %28 = fmul double %27, 1.800000e+02
  %29 = fdiv double %28, 0x400921FB53C8D4F1
  store double %29, ptr %10, align 8, !tbaa !5
  %30 = load double, ptr %7, align 8, !tbaa !5
  %31 = load double, ptr %10, align 8, !tbaa !5
  %32 = fsub double %31, %30
  store double %32, ptr %10, align 8, !tbaa !5
  %33 = load double, ptr %10, align 8, !tbaa !5
  %34 = fcmp olt double %33, 0.000000e+00
  br i1 %34, label %35, label %38

35:                                               ; preds = %16
  %36 = load double, ptr %10, align 8, !tbaa !5
  %37 = fadd double %36, 3.600000e+02
  store double %37, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %40

38:                                               ; preds = %16
  %39 = load double, ptr %10, align 8, !tbaa !5
  store double %39, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %40

40:                                               ; preds = %38, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %41

41:                                               ; preds = %40, %15
  %42 = load double, ptr %4, align 8
  ret double %42
}

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt5atan2IiiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef, i32 noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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"}
!9 = !{!10, !11, i64 4}
!10 = !{!"_ZTSSt4pairIiiE", !11, i64 0, !11, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !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"

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z10same_pointSt4pairIiiES0_(i64, i64) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_Z5angleSt4pairIiiES0_d(i64 %0, i64 %1, double noundef %2) local_unnamed_addr #0 {
  %4 = tail call noundef zeroext i1 @_Z10same_pointSt4pairIiiES0_(i64 %0, i64 %1)
  br i1 %4, label %14, label %5

5:                                                ; preds = %3
  %.sroa.06.0.extract.trunc = trunc i64 %1 to i32
  %.sroa.3.0.extract.shift = lshr i64 %1, 32
  %.sroa.3.0.extract.trunc = trunc nuw i64 %.sroa.3.0.extract.shift to i32
  %.sroa.07.0.extract.trunc = trunc i64 %0 to i32
  %.sroa.38.0.extract.shift = lshr i64 %0, 32
  %.sroa.38.0.extract.trunc = trunc nuw i64 %.sroa.38.0.extract.shift to i32
  %6 = sub nsw i32 %.sroa.38.0.extract.trunc, %.sroa.3.0.extract.trunc
  %7 = sub nsw i32 %.sroa.07.0.extract.trunc, %.sroa.06.0.extract.trunc
  %8 = tail call noundef double @_ZSt5atan2IiiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef %6, i32 noundef %7)
  %9 = fmul double %8, 1.800000e+02
  %10 = fdiv double %9, 0x400921FB53C8D4F1
  %11 = fsub double %10, %2
  %12 = fcmp olt double %11, 0.000000e+00
  %13 = fadd double %11, 3.600000e+02
  %.0 = select i1 %12, double %13, double %11
  br label %14

14:                                               ; preds = %3, %5
  %.1 = phi double [ %.0, %5 ], [ -1.000000e+00, %3 ]
  ret double %.1
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt5atan2IiiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef, i32 noundef) local_unnamed_addr #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 = { 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" }

!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,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass