; LLVM IR from spirosmaggioros/AlgoPlus :: tests/algorithms/geometry/convex_hull.ll (ZN7helpers11orientationESt4pairIiiES1_S1_)

; 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: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN7helpers11orientationESt4pairIiiES1_S1_(i64 %0, i64 %1, i64 %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca %"struct.std::pair", align 4
  %6 = alloca %"struct.std::pair", align 4
  %7 = alloca %"struct.std::pair", align 4
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  store i64 %0, ptr %5, align 4
  store i64 %1, ptr %6, align 4
  store i64 %2, ptr %7, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %10 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 0
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 1
  %13 = load i32, ptr %12, align 4, !tbaa !10
  %14 = getelementptr inbounds %"struct.std::pair", ptr %7, i32 0, i32 1
  %15 = load i32, ptr %14, align 4, !tbaa !10
  %16 = sub nsw i32 %13, %15
  %17 = mul nsw i32 %11, %16
  %18 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 0
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = getelementptr inbounds %"struct.std::pair", ptr %7, i32 0, i32 1
  %21 = load i32, ptr %20, align 4, !tbaa !10
  %22 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 1
  %23 = load i32, ptr %22, align 4, !tbaa !10
  %24 = sub nsw i32 %21, %23
  %25 = mul nsw i32 %19, %24
  %26 = add nsw i32 %17, %25
  %27 = getelementptr inbounds %"struct.std::pair", ptr %7, i32 0, i32 0
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = getelementptr inbounds %"struct.std::pair", ptr %5, i32 0, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !10
  %31 = getelementptr inbounds %"struct.std::pair", ptr %6, i32 0, i32 1
  %32 = load i32, ptr %31, align 4, !tbaa !10
  %33 = sub nsw i32 %30, %32
  %34 = mul nsw i32 %28, %33
  %35 = add nsw i32 %26, %34
  %36 = sitofp i32 %35 to double
  store double %36, ptr %8, align 8, !tbaa !11
  %37 = load double, ptr %8, align 8, !tbaa !11
  %38 = fcmp olt double %37, 0.000000e+00
  br i1 %38, label %39, label %40

39:                                               ; preds = %3
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %45

40:                                               ; preds = %3
  %41 = load double, ptr %8, align 8, !tbaa !11
  %42 = fcmp ogt double %41, 0.000000e+00
  br i1 %42, label %43, label %44

43:                                               ; preds = %40
  store i32 1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %45

44:                                               ; preds = %40
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %45

45:                                               ; preds = %44, %43, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  %46 = load i32, ptr %4, align 4
  ret i32 %46
}

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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, !7, i64 0}
!6 = !{!"_ZTSSt4pairIiiE", !7, i64 0, !7, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 4}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !8, 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 nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef range(i32 -1, 2) i32 @_ZN7helpers11orientationESt4pairIiiES1_S1_(i64 %0, i64 %1, i64 %2) local_unnamed_addr #0 {
  %.sroa.06.0.extract.trunc = trunc i64 %0 to i32
  %.sroa.27.0.extract.shift = lshr i64 %0, 32
  %.sroa.27.0.extract.trunc = trunc nuw i64 %.sroa.27.0.extract.shift to i32
  %.sroa.03.0.extract.trunc = trunc i64 %1 to i32
  %.sroa.24.0.extract.shift = lshr i64 %1, 32
  %.sroa.24.0.extract.trunc = trunc nuw i64 %.sroa.24.0.extract.shift to i32
  %.sroa.0.0.extract.trunc = trunc i64 %2 to i32
  %.sroa.2.0.extract.shift = lshr i64 %2, 32
  %.sroa.2.0.extract.trunc = trunc nuw i64 %.sroa.2.0.extract.shift to i32
  %4 = sub nsw i32 %.sroa.24.0.extract.trunc, %.sroa.2.0.extract.trunc
  %5 = mul nsw i32 %4, %.sroa.06.0.extract.trunc
  %6 = sub nsw i32 %.sroa.2.0.extract.trunc, %.sroa.27.0.extract.trunc
  %7 = mul nsw i32 %6, %.sroa.03.0.extract.trunc
  %8 = sub nsw i32 %.sroa.27.0.extract.trunc, %.sroa.24.0.extract.trunc
  %9 = mul nsw i32 %8, %.sroa.0.0.extract.trunc
  %10 = add i32 %7, %9
  %11 = add i32 %10, %5
  %.not = icmp ne i32 %11, 0
  %. = zext i1 %.not to i32
  %.inv = icmp sgt i32 %11, -1
  %.0 = select i1 %.inv, i32 %., i32 -1
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass