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

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

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4swapI2PTENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS4_ESt18is_move_assignableIS4_EEE5valueEvE4typeERS4_SD_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK2PTmiERKS_(ptr dead_on_unwind noalias writable sret(%struct.PT) align 8, ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z20is_point_in_triangle2PTS_S_S_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #3 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %struct.PT, align 8
  %11 = alloca %struct.PT, align 8
  %12 = alloca i32, align 4
  %13 = alloca %struct.PT, align 8
  %14 = alloca %struct.PT, align 8
  %15 = alloca i32, align 4
  %16 = alloca %struct.PT, align 8
  %17 = alloca %struct.PT, align 8
  %18 = alloca i32, align 4
  %19 = alloca %struct.PT, align 8
  %20 = alloca %struct.PT, align 8
  %21 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @_ZNK2PTmiERKS_(ptr dead_on_unwind writable sret(%struct.PT) align 8 %10, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %0)
  call void @_ZNK2PTmiERKS_(ptr dead_on_unwind writable sret(%struct.PT) align 8 %11, ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(16) %0)
  %22 = call noundef double @_Z5cross2PTS_(ptr noundef %10, ptr noundef %11)
  %23 = call noundef i32 @_Z4signd(double noundef %22)
  %24 = icmp slt i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %4
  call void @_ZSt4swapI2PTENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS4_ESt18is_move_assignableIS4_EEE5valueEvE4typeERS4_SD_(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %2)
  br label %26

26:                                               ; preds = %25, %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  call void @_ZNK2PTmiERKS_(ptr dead_on_unwind writable sret(%struct.PT) align 8 %13, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %0)
  call void @_ZNK2PTmiERKS_(ptr dead_on_unwind writable sret(%struct.PT) align 8 %14, ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(16) %0)
  %27 = call noundef double @_Z5cross2PTS_(ptr noundef %13, ptr noundef %14)
  %28 = call noundef i32 @_Z4signd(double noundef %27)
  store i32 %28, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  call void @_ZNK2PTmiERKS_(ptr dead_on_unwind writable sret(%struct.PT) align 8 %16, ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(16) %1)
  call void @_ZNK2PTmiERKS_(ptr dead_on_unwind writable sret(%struct.PT) align 8 %17, ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(16) %1)
  %29 = call noundef double @_Z5cross2PTS_(ptr noundef %16, ptr noundef %17)
  %30 = call noundef i32 @_Z4signd(double noundef %29)
  store i32 %30, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  call void @_ZNK2PTmiERKS_(ptr dead_on_unwind writable sret(%struct.PT) align 8 %19, ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %2)
  call void @_ZNK2PTmiERKS_(ptr dead_on_unwind writable sret(%struct.PT) align 8 %20, ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(16) %2)
  %31 = call noundef double @_Z5cross2PTS_(ptr noundef %19, ptr noundef %20)
  %32 = call noundef i32 @_Z4signd(double noundef %31)
  store i32 %32, ptr %18, align 4, !tbaa !9
  %33 = load i32, ptr %12, align 4, !tbaa !9
  %34 = icmp slt i32 %33, 0
  br i1 %34, label %41, label %35

35:                                               ; preds = %26
  %36 = load i32, ptr %15, align 4, !tbaa !9
  %37 = icmp slt i32 %36, 0
  br i1 %37, label %41, label %38

38:                                               ; preds = %35
  %39 = load i32, ptr %18, align 4, !tbaa !9
  %40 = icmp slt i32 %39, 0
  br i1 %40, label %41, label %42

41:                                               ; preds = %38, %35, %26
  store i32 1, ptr %5, align 4
  store i32 1, ptr %21, align 4
  br label %51

42:                                               ; preds = %38
  %43 = load i32, ptr %12, align 4, !tbaa !9
  %44 = load i32, ptr %15, align 4, !tbaa !9
  %45 = add nsw i32 %43, %44
  %46 = load i32, ptr %18, align 4, !tbaa !9
  %47 = add nsw i32 %45, %46
  %48 = icmp ne i32 %47, 3
  br i1 %48, label %49, label %50

49:                                               ; preds = %42
  store i32 0, ptr %5, align 4
  store i32 1, ptr %21, align 4
  br label %51

50:                                               ; preds = %42
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %21, align 4
  br label %51

51:                                               ; preds = %50, %49, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  %52 = load i32, ptr %5, align 4
  ret i32 %52
}

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 = { 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 #3 = { 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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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 }

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4swapI2PTENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS4_ESt18is_move_assignableIS4_EEE5valueEvE4typeERS4_SD_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK2PTmiERKS_(ptr dead_on_unwind noalias writable sret(%struct.PT) align 8, ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 -1, 2) i32 @_Z20is_point_in_triangle2PTS_S_S_(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #2 {
  %5 = alloca %struct.PT, align 8
  %6 = alloca %struct.PT, align 8
  %7 = alloca %struct.PT, align 8
  %8 = alloca %struct.PT, align 8
  %9 = alloca %struct.PT, align 8
  %10 = alloca %struct.PT, align 8
  %11 = alloca %struct.PT, align 8
  %12 = alloca %struct.PT, align 8
  call void @_ZNK2PTmiERKS_(ptr dead_on_unwind nonnull writable sret(%struct.PT) align 8 %5, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %0)
  call void @_ZNK2PTmiERKS_(ptr dead_on_unwind nonnull writable sret(%struct.PT) align 8 %6, ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(16) %0)
  %13 = call noundef double @_Z5cross2PTS_(ptr noundef nonnull %5, ptr noundef nonnull %6)
  %14 = call noundef i32 @_Z4signd(double noundef %13)
  %15 = icmp slt i32 %14, 0
  br i1 %15, label %16, label %17

16:                                               ; preds = %4
  call void @_ZSt4swapI2PTENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS4_ESt18is_move_assignableIS4_EEE5valueEvE4typeERS4_SD_(ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %2)
  br label %17

17:                                               ; preds = %16, %4
  call void @_ZNK2PTmiERKS_(ptr dead_on_unwind nonnull writable sret(%struct.PT) align 8 %7, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %0)
  call void @_ZNK2PTmiERKS_(ptr dead_on_unwind nonnull writable sret(%struct.PT) align 8 %8, ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(16) %0)
  %18 = call noundef double @_Z5cross2PTS_(ptr noundef nonnull %7, ptr noundef nonnull %8)
  %19 = call noundef i32 @_Z4signd(double noundef %18)
  call void @_ZNK2PTmiERKS_(ptr dead_on_unwind nonnull writable sret(%struct.PT) align 8 %9, ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(16) %1)
  call void @_ZNK2PTmiERKS_(ptr dead_on_unwind nonnull writable sret(%struct.PT) align 8 %10, ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(16) %1)
  %20 = call noundef double @_Z5cross2PTS_(ptr noundef nonnull %9, ptr noundef nonnull %10)
  %21 = call noundef i32 @_Z4signd(double noundef %20)
  call void @_ZNK2PTmiERKS_(ptr dead_on_unwind nonnull writable sret(%struct.PT) align 8 %11, ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %2)
  call void @_ZNK2PTmiERKS_(ptr dead_on_unwind nonnull writable sret(%struct.PT) align 8 %12, ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(16) %2)
  %22 = call noundef double @_Z5cross2PTS_(ptr noundef nonnull %11, ptr noundef nonnull %12)
  %23 = call noundef i32 @_Z4signd(double noundef %22)
  %24 = or i32 %21, %19
  %25 = or i32 %24, %23
  %or.cond3.not = icmp sgt i32 %25, -1
  %26 = add nuw nsw i32 %21, %19
  %27 = add nuw nsw i32 %26, %23
  %.not = icmp eq i32 %27, 3
  %. = sext i1 %.not to i32
  %.0 = select i1 %or.cond3.not, i32 %., i32 1
  ret i32 %.0
}

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 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 = { 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: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass