; LLVM IR from MtSaka/library :: test/aoj/CGL/CGL_1_A.test.ll (ZN8geometry9is_convexERNS_7polygonE)

; 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.geometry::point" = type { x86_fp80, x86_fp80 }
%"struct.geometry::polygon" = type { i32, %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<geometry::point, std::allocator<geometry::point>>::_Vector_impl" }
%"struct.std::_Vector_base<geometry::point, std::allocator<geometry::point>>::_Vector_impl" = type { %"struct.std::_Vector_base<geometry::point, std::allocator<geometry::point>>::_Vector_impl_data" }
%"struct.std::_Vector_base<geometry::point, std::allocator<geometry::point>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; 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 uwtable
declare dso_local noundef i32 @_ZN8geometry3ccwENS_5pointES0_S0_(ptr noundef byval(%"struct.geometry::point") align 16, ptr noundef byval(%"struct.geometry::point") align 16, ptr noundef byval(%"struct.geometry::point") align 16) #1

; 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) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 16 dereferenceable(32) ptr @_ZN8geometry7polygonixEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN8geometry9is_convexERNS_7polygonE(ptr noundef nonnull align 8 dereferenceable(32) %0) #1 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %"struct.geometry::point", align 16
  %9 = alloca %"struct.geometry::point", align 16
  %10 = alloca %"struct.geometry::point", align 16
  %11 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %53, %1
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %"struct.geometry::polygon", ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !11
  %17 = icmp slt i32 %13, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %56

19:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = call noundef nonnull align 16 dereferenceable(32) ptr @_ZN8geometry7polygonixEi(ptr noundef nonnull align 8 dereferenceable(32) %20, i32 noundef %21)
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %8, ptr align 16 %22, i64 32, i1 false), !tbaa.struct !17
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = add nsw i32 %24, 1
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.geometry::polygon", ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !11
  %29 = srem i32 %25, %28
  %30 = call noundef nonnull align 16 dereferenceable(32) ptr @_ZN8geometry7polygonixEi(ptr noundef nonnull align 8 dereferenceable(32) %23, i32 noundef %29)
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %9, ptr align 16 %30, i64 32, i1 false), !tbaa.struct !17
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = add nsw i32 %32, 2
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %"struct.geometry::polygon", ptr %34, i32 0, i32 0
  %36 = load i32, ptr %35, align 8, !tbaa !11
  %37 = srem i32 %33, %36
  %38 = call noundef nonnull align 16 dereferenceable(32) ptr @_ZN8geometry7polygonixEi(ptr noundef nonnull align 8 dereferenceable(32) %31, i32 noundef %37)
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %10, ptr align 16 %38, i64 32, i1 false), !tbaa.struct !17
  %39 = call noundef i32 @_ZN8geometry3ccwENS_5pointES0_S0_(ptr noundef byval(%"struct.geometry::point") align 16 %8, ptr noundef byval(%"struct.geometry::point") align 16 %9, ptr noundef byval(%"struct.geometry::point") align 16 %10)
  store i32 %39, ptr %7, align 4, !tbaa !9
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = icmp eq i32 %40, 1
  br i1 %41, label %42, label %45

42:                                               ; preds = %19
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %5, align 4, !tbaa !9
  br label %52

45:                                               ; preds = %19
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = icmp eq i32 %46, -1
  br i1 %47, label %48, label %51

48:                                               ; preds = %45
  %49 = load i32, ptr %4, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %4, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %48, %45
  br label %52

52:                                               ; preds = %51, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %53

53:                                               ; preds = %52
  %54 = load i32, ptr %6, align 4, !tbaa !9
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %6, align 4, !tbaa !9
  br label %12, !llvm.loop !20

56:                                               ; preds = %18
  %57 = load i32, ptr %5, align 4, !tbaa !9
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %63

59:                                               ; preds = %56
  %60 = load i32, ptr %4, align 4, !tbaa !9
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %63

62:                                               ; preds = %59
  store i1 false, ptr %2, align 1
  store i32 1, ptr %11, align 4
  br label %64

63:                                               ; preds = %59, %56
  store i1 true, ptr %2, align 1
  store i32 1, ptr %11, align 4
  br label %64

64:                                               ; preds = %63, %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %65 = load i1, ptr %2, align 1
  ret i1 %65
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN8geometry7polygonE", !10, i64 0, !13, i64 8}
!13 = !{!"_ZTSSt6vectorIN8geometry5pointESaIS1_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIN8geometry5pointESaIS1_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIN8geometry5pointESaIS1_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIN8geometry5pointESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{i64 0, i64 16, !18, i64 16, i64 16, !18}
!18 = !{!19, !19, i64 0}
!19 = !{!"long double", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"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"

%"struct.geometry::point" = type { x86_fp80, x86_fp80 }

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN8geometry3ccwENS_5pointES0_S0_(ptr noundef byval(%"struct.geometry::point") align 16, ptr noundef byval(%"struct.geometry::point") align 16, ptr noundef byval(%"struct.geometry::point") align 16) local_unnamed_addr #0

; Function Attrs: mustprogress 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) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 16 dereferenceable(32) ptr @_ZN8geometry7polygonixEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN8geometry9is_convexERNS_7polygonE(ptr noundef nonnull align 8 dereferenceable(32) %0) local_unnamed_addr #0 {
  %2 = alloca %"struct.geometry::point", align 16
  %3 = alloca %"struct.geometry::point", align 16
  %4 = load i32, ptr %0, align 8, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %._crit_edge

._crit_edge.loopexit:                             ; preds = %23
  %6 = icmp eq i32 %.1, 0
  %7 = icmp eq i32 %.121, 0
  %8 = select i1 %6, i1 true, i1 %7
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %1
  %.019.lcssa = phi i1 [ true, %1 ], [ %8, %._crit_edge.loopexit ]
  ret i1 %.019.lcssa

.lr.ph:                                           ; preds = %1, %23
  %.01826 = phi i32 [ %10, %23 ], [ 0, %1 ]
  %.01925 = phi i32 [ %.1, %23 ], [ 0, %1 ]
  %.02024 = phi i32 [ %.121, %23 ], [ 0, %1 ]
  %9 = tail call noundef nonnull align 16 dereferenceable(32) ptr @_ZN8geometry7polygonixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %.01826)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %2, ptr noundef nonnull align 16 dereferenceable(32) %9, i64 32, i1 false), !tbaa.struct !15
  %10 = add nuw nsw i32 %.01826, 1
  %11 = load i32, ptr %0, align 8, !tbaa !5
  %12 = srem i32 %10, %11
  %13 = tail call noundef nonnull align 16 dereferenceable(32) ptr @_ZN8geometry7polygonixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %12)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %3, ptr noundef nonnull align 16 dereferenceable(32) %13, i64 32, i1 false), !tbaa.struct !15
  %14 = add nuw nsw i32 %.01826, 2
  %15 = load i32, ptr %0, align 8, !tbaa !5
  %16 = srem i32 %14, %15
  %17 = tail call noundef nonnull align 16 dereferenceable(32) ptr @_ZN8geometry7polygonixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %16)
  %18 = tail call noundef i32 @_ZN8geometry3ccwENS_5pointES0_S0_(ptr noundef nonnull byval(%"struct.geometry::point") align 16 %2, ptr noundef nonnull byval(%"struct.geometry::point") align 16 %3, ptr noundef nonnull byval(%"struct.geometry::point") align 16 %17)
  switch i32 %18, label %23 [
    i32 1, label %19
    i32 -1, label %21
  ]

19:                                               ; preds = %.lr.ph
  %20 = add nsw i32 %.01925, 1
  br label %23

21:                                               ; preds = %.lr.ph
  %22 = add nsw i32 %.02024, 1
  br label %23

23:                                               ; preds = %.lr.ph, %21, %19
  %.121 = phi i32 [ %.02024, %19 ], [ %22, %21 ], [ %.02024, %.lr.ph ]
  %.1 = phi i32 [ %20, %19 ], [ %.01925, %21 ], [ %.01925, %.lr.ph ]
  %24 = load i32, ptr %0, align 8, !tbaa !5
  %25 = icmp slt i32 %10, %24
  br i1 %25, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !18
}

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"_ZTSN8geometry7polygonE", !7, i64 0, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIN8geometry5pointESaIS1_EE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIN8geometry5pointESaIS1_EE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIN8geometry5pointESaIS1_EE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIN8geometry5pointESaIS1_EE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{i64 0, i64 16, !16, i64 16, i64 16, !16}
!16 = !{!17, !17, i64 0}
!17 = !{!"long double", !8, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass