; LLVM IR from MtSaka/library :: test/aoj/CGL/CGL_1_A.test.ll (ZN8geometry4areaERNS_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: mustprogress nounwind uwtable
declare dso_local noundef x86_fp80 @_ZN8geometry5crossENS_5pointES0_(ptr noundef byval(%"struct.geometry::point") align 16, ptr noundef byval(%"struct.geometry::point") align 16) #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: 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) #0 align 2

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

7:                                                ; preds = %29, %1
  %8 = load i32, ptr %4, align 4, !tbaa !11
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %"struct.geometry::polygon", ptr %9, i32 0, i32 0
  %11 = load i32, ptr %10, align 8, !tbaa !13
  %12 = icmp slt i32 %8, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %32

14:                                               ; preds = %7
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = load i32, ptr %4, align 4, !tbaa !11
  %17 = call noundef nonnull align 16 dereferenceable(32) ptr @_ZN8geometry7polygonixEi(ptr noundef nonnull align 8 dereferenceable(32) %15, i32 noundef %16)
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %5, ptr align 16 %17, i64 32, i1 false), !tbaa.struct !19
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = load i32, ptr %4, align 4, !tbaa !11
  %20 = add nsw i32 %19, 1
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.geometry::polygon", ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 8, !tbaa !13
  %24 = srem i32 %20, %23
  %25 = call noundef nonnull align 16 dereferenceable(32) ptr @_ZN8geometry7polygonixEi(ptr noundef nonnull align 8 dereferenceable(32) %18, i32 noundef %24)
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %6, ptr align 16 %25, i64 32, i1 false), !tbaa.struct !19
  %26 = call noundef x86_fp80 @_ZN8geometry5crossENS_5pointES0_(ptr noundef byval(%"struct.geometry::point") align 16 %5, ptr noundef byval(%"struct.geometry::point") align 16 %6)
  %27 = load x86_fp80, ptr %3, align 16, !tbaa !9
  %28 = fadd x86_fp80 %27, %26
  store x86_fp80 %28, ptr %3, align 16, !tbaa !9
  br label %29

29:                                               ; preds = %14
  %30 = load i32, ptr %4, align 4, !tbaa !11
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %4, align 4, !tbaa !11
  br label %7, !llvm.loop !20

32:                                               ; preds = %13
  %33 = load x86_fp80, ptr %3, align 16, !tbaa !9
  %34 = fdiv x86_fp80 %33, 0xK40008000000000000000
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #4
  ret x86_fp80 %34
}

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"long double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"_ZTSN8geometry7polygonE", !12, i64 0, !15, i64 8}
!15 = !{!"_ZTSSt6vectorIN8geometry5pointESaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIN8geometry5pointESaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN8geometry5pointESaIS1_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIN8geometry5pointESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{i64 0, i64 16, !9, i64 16, i64 16, !9}
!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 nounwind uwtable
declare dso_local noundef x86_fp80 @_ZN8geometry5crossENS_5pointES0_(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 #0 align 2

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

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %5 = fmul x86_fp80 %12, 0xK3FFE8000000000000000
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %1
  %.09.lcssa = phi x86_fp80 [ 0xK00000000000000000000, %1 ], [ %5, %._crit_edge.loopexit ]
  ret x86_fp80 %.09.lcssa

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.011 = phi i32 [ %7, %.lr.ph ], [ 0, %1 ]
  %.0910 = phi x86_fp80 [ %12, %.lr.ph ], [ 0xK00000000000000000000, %1 ]
  %6 = tail call noundef nonnull align 16 dereferenceable(32) ptr @_ZN8geometry7polygonixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %.011)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %2, ptr noundef nonnull align 16 dereferenceable(32) %6, i64 32, i1 false), !tbaa.struct !15
  %7 = add nuw nsw i32 %.011, 1
  %8 = load i32, ptr %0, align 8, !tbaa !5
  %9 = srem i32 %7, %8
  %10 = tail call noundef nonnull align 16 dereferenceable(32) ptr @_ZN8geometry7polygonixEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %9)
  %11 = tail call noundef x86_fp80 @_ZN8geometry5crossENS_5pointES0_(ptr noundef nonnull byval(%"struct.geometry::point") align 16 %2, ptr noundef nonnull byval(%"struct.geometry::point") align 16 %10)
  %12 = fadd x86_fp80 %.0910, %11
  %13 = load i32, ptr %0, align 8, !tbaa !5
  %14 = icmp slt i32 %7, %13
  br i1 %14, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !18
}

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }

!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,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass