; LLVM IR from ayush-tulsyan/ACM-ICPC-Handbook :: code/Geometry.ll (Z14PointInPolygonRKSt6vectorI2PTSaIS0_EES0_)

; 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: 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
define dso_local noundef zeroext i1 @_Z14PointInPolygonRKSt6vectorI2PTSaIS0_EES0_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #2
  store i8 0, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %8

8:                                                ; preds = %116, %2
  %9 = load i32, ptr %6, align 4, !tbaa !11
  %10 = sext i32 %9 to i64
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = call noundef i64 @_ZNKSt6vectorI2PTSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %11) #2
  %13 = icmp ult i64 %10, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %119

15:                                               ; preds = %8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %16 = load i32, ptr %6, align 4, !tbaa !11
  %17 = add nsw i32 %16, 1
  %18 = sext i32 %17 to i64
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = call noundef i64 @_ZNKSt6vectorI2PTSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %19) #2
  %21 = urem i64 %18, %20
  %22 = trunc i64 %21 to i32
  store i32 %22, ptr %7, align 4, !tbaa !11
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = load i32, ptr %6, align 4, !tbaa !11
  %25 = sext i32 %24 to i64
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %23, i64 noundef %25) #2
  %27 = getelementptr inbounds %struct.PT, ptr %26, i32 0, i32 1
  %28 = load double, ptr %27, align 8, !tbaa !13
  %29 = getelementptr inbounds %struct.PT, ptr %1, i32 0, i32 1
  %30 = load double, ptr %29, align 8, !tbaa !13
  %31 = fcmp ole double %28, %30
  br i1 %31, label %32, label %42

32:                                               ; preds = %15
  %33 = getelementptr inbounds %struct.PT, ptr %1, i32 0, i32 1
  %34 = load double, ptr %33, align 8, !tbaa !13
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = load i32, ptr %7, align 4, !tbaa !11
  %37 = sext i32 %36 to i64
  %38 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %35, i64 noundef %37) #2
  %39 = getelementptr inbounds %struct.PT, ptr %38, i32 0, i32 1
  %40 = load double, ptr %39, align 8, !tbaa !13
  %41 = fcmp olt double %34, %40
  br i1 %41, label %62, label %42

42:                                               ; preds = %32, %15
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = load i32, ptr %7, align 4, !tbaa !11
  %45 = sext i32 %44 to i64
  %46 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %43, i64 noundef %45) #2
  %47 = getelementptr inbounds %struct.PT, ptr %46, i32 0, i32 1
  %48 = load double, ptr %47, align 8, !tbaa !13
  %49 = getelementptr inbounds %struct.PT, ptr %1, i32 0, i32 1
  %50 = load double, ptr %49, align 8, !tbaa !13
  %51 = fcmp ole double %48, %50
  br i1 %51, label %52, label %115

52:                                               ; preds = %42
  %53 = getelementptr inbounds %struct.PT, ptr %1, i32 0, i32 1
  %54 = load double, ptr %53, align 8, !tbaa !13
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = load i32, ptr %6, align 4, !tbaa !11
  %57 = sext i32 %56 to i64
  %58 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %55, i64 noundef %57) #2
  %59 = getelementptr inbounds %struct.PT, ptr %58, i32 0, i32 1
  %60 = load double, ptr %59, align 8, !tbaa !13
  %61 = fcmp olt double %54, %60
  br i1 %61, label %62, label %115

62:                                               ; preds = %52, %32
  %63 = getelementptr inbounds %struct.PT, ptr %1, i32 0, i32 0
  %64 = load double, ptr %63, align 8, !tbaa !16
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = load i32, ptr %6, align 4, !tbaa !11
  %67 = sext i32 %66 to i64
  %68 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %65, i64 noundef %67) #2
  %69 = getelementptr inbounds %struct.PT, ptr %68, i32 0, i32 0
  %70 = load double, ptr %69, align 8, !tbaa !16
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = load i32, ptr %7, align 4, !tbaa !11
  %73 = sext i32 %72 to i64
  %74 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %71, i64 noundef %73) #2
  %75 = getelementptr inbounds %struct.PT, ptr %74, i32 0, i32 0
  %76 = load double, ptr %75, align 8, !tbaa !16
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = load i32, ptr %6, align 4, !tbaa !11
  %79 = sext i32 %78 to i64
  %80 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %77, i64 noundef %79) #2
  %81 = getelementptr inbounds %struct.PT, ptr %80, i32 0, i32 0
  %82 = load double, ptr %81, align 8, !tbaa !16
  %83 = fsub double %76, %82
  %84 = getelementptr inbounds %struct.PT, ptr %1, i32 0, i32 1
  %85 = load double, ptr %84, align 8, !tbaa !13
  %86 = load ptr, ptr %3, align 8, !tbaa !5
  %87 = load i32, ptr %6, align 4, !tbaa !11
  %88 = sext i32 %87 to i64
  %89 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %86, i64 noundef %88) #2
  %90 = getelementptr inbounds %struct.PT, ptr %89, i32 0, i32 1
  %91 = load double, ptr %90, align 8, !tbaa !13
  %92 = fsub double %85, %91
  %93 = fmul double %83, %92
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = load i32, ptr %7, align 4, !tbaa !11
  %96 = sext i32 %95 to i64
  %97 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %94, i64 noundef %96) #2
  %98 = getelementptr inbounds %struct.PT, ptr %97, i32 0, i32 1
  %99 = load double, ptr %98, align 8, !tbaa !13
  %100 = load ptr, ptr %3, align 8, !tbaa !5
  %101 = load i32, ptr %6, align 4, !tbaa !11
  %102 = sext i32 %101 to i64
  %103 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %100, i64 noundef %102) #2
  %104 = getelementptr inbounds %struct.PT, ptr %103, i32 0, i32 1
  %105 = load double, ptr %104, align 8, !tbaa !13
  %106 = fsub double %99, %105
  %107 = fdiv double %93, %106
  %108 = fadd double %70, %107
  %109 = fcmp olt double %64, %108
  br i1 %109, label %110, label %115

110:                                              ; preds = %62
  %111 = load i8, ptr %5, align 1, !tbaa !9, !range !17, !noundef !18
  %112 = trunc i8 %111 to i1
  %113 = xor i1 %112, true
  %114 = zext i1 %113 to i8
  store i8 %114, ptr %5, align 1, !tbaa !9
  br label %115

115:                                              ; preds = %110, %62, %52, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %116

116:                                              ; preds = %115
  %117 = load i32, ptr %6, align 4, !tbaa !11
  %118 = add nsw i32 %117, 1
  store i32 %118, ptr %6, align 4, !tbaa !11
  br label %8, !llvm.loop !19

119:                                              ; preds = %14
  %120 = load i8, ptr %5, align 1, !tbaa !9, !range !17, !noundef !18
  %121 = trunc i8 %120 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #2
  ret i1 %121
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorI2PTSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

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 = { 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 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !15, i64 8}
!14 = !{!"_ZTS2PT", !15, i64 0, !15, i64 8}
!15 = !{!"double", !7, i64 0}
!16 = !{!14, !15, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


; 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
define dso_local noundef zeroext i1 @_Z14PointInPolygonRKSt6vectorI2PTSaIS0_EES0_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = tail call noundef i64 @_ZNKSt6vectorI2PTSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  br label %5

._crit_edge:                                      ; preds = %56, %2
  %.0.lcssa = phi i1 [ false, %2 ], [ %.1, %56 ]
  ret i1 %.0.lcssa

5:                                                ; preds = %.lr.ph, %56
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %56 ]
  %.031 = phi i1 [ false, %.lr.ph ], [ %.1, %56 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %6 = tail call noundef i64 @_ZNKSt6vectorI2PTSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1
  %7 = urem i64 %indvars.iv.next, %6
  %8 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv) #1
  %9 = getelementptr inbounds i8, ptr %8, i64 8
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = load double, ptr %4, align 8, !tbaa !5
  %12 = fcmp ugt double %10, %11
  br i1 %12, label %18, label %13

13:                                               ; preds = %5
  %14 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %7) #1
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = fcmp olt double %11, %16
  br i1 %17, label %29, label %18

18:                                               ; preds = %13, %5
  %19 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %7) #1
  %20 = getelementptr inbounds i8, ptr %19, i64 8
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = load double, ptr %4, align 8, !tbaa !5
  %23 = fcmp ugt double %21, %22
  br i1 %23, label %56, label %24

24:                                               ; preds = %18
  %25 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv) #1
  %26 = getelementptr inbounds i8, ptr %25, i64 8
  %27 = load double, ptr %26, align 8, !tbaa !5
  %28 = fcmp olt double %22, %27
  br i1 %28, label %29, label %56

29:                                               ; preds = %24, %13
  %30 = load double, ptr %1, align 8, !tbaa !10
  %31 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv) #1
  %32 = load double, ptr %31, align 8, !tbaa !10
  %33 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %7) #1
  %34 = load double, ptr %33, align 8, !tbaa !10
  %35 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv) #1
  %36 = load double, ptr %35, align 8, !tbaa !10
  %37 = fsub double %34, %36
  %38 = load double, ptr %4, align 8, !tbaa !5
  %39 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv) #1
  %40 = getelementptr inbounds i8, ptr %39, i64 8
  %41 = load double, ptr %40, align 8, !tbaa !5
  %42 = fsub double %38, %41
  %43 = fmul double %37, %42
  %44 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %7) #1
  %45 = getelementptr inbounds i8, ptr %44, i64 8
  %46 = load double, ptr %45, align 8, !tbaa !5
  %47 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %indvars.iv) #1
  %48 = getelementptr inbounds i8, ptr %47, i64 8
  %49 = load double, ptr %48, align 8, !tbaa !5
  %50 = fsub double %46, %49
  %51 = fdiv double %43, %50
  %52 = fadd double %32, %51
  %53 = fcmp olt double %30, %52
  br i1 %53, label %54, label %56

54:                                               ; preds = %29
  %55 = xor i1 %.031, true
  br label %56

56:                                               ; preds = %54, %29, %24, %18
  %.1 = phi i1 [ %55, %54 ], [ %.031, %29 ], [ %.031, %24 ], [ %.031, %18 ]
  %57 = tail call noundef i64 @_ZNKSt6vectorI2PTSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #1
  %58 = icmp ugt i64 %57, %indvars.iv.next
  br i1 %58, label %5, label %._crit_edge, !llvm.loop !11
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorI2PTSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNKSt6vectorI2PTSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

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 = { 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 8}
!6 = !{!"_ZTS2PT", !7, i64 0, !7, i64 8}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass