; LLVM IR from xirc/cp-algorithm :: atcoder/abc131/E/main.ll (Z5solveii)

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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::array<int, 2>, std::allocator<std::array<int, 2>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::array<int, 2>, std::allocator<std::array<int, 2>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::array<int, 2>, std::allocator<std::array<int, 2>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::array<int, 2>, std::allocator<std::array<int, 2>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::array" = type { [2 x i32] }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solveii(ptr dead_on_unwind noalias writable sret(%"class.std::vector") align 8 %0, i32 noundef %1, i32 noundef %2) #0 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i1, align 1
  %10 = alloca i32, align 4
  %11 = alloca %"struct.std::array", align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca %"struct.std::array", align 4
  store ptr %0, ptr %4, align 8
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = sub nsw i32 %17, 1
  %19 = load i32, ptr %5, align 4, !tbaa !5
  %20 = sub nsw i32 %19, 2
  %21 = mul nsw i32 %18, %20
  %22 = sdiv i32 %21, 2
  store i32 %22, ptr %7, align 4, !tbaa !5
  %23 = load i32, ptr %6, align 4, !tbaa !5
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = icmp sgt i32 %23, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %3
  call void @llvm.memset.p0.i64(ptr align 8 %0, i8 0, i64 24, i1 false)
  call void @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  store i32 1, ptr %8, align 4
  br label %89

27:                                               ; preds = %3
  store i1 false, ptr %9, align 1
  call void @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %38, %27
  %29 = load i32, ptr %10, align 4, !tbaa !5
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %45

33:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %34 = getelementptr inbounds %"struct.std::array", ptr %11, i32 0, i32 0
  store i32 0, ptr %34, align 4, !tbaa !5
  %35 = getelementptr inbounds i32, ptr %34, i64 1
  %36 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %36, ptr %35, align 4, !tbaa !5
  invoke void @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(8) %11)
          to label %37 unwind label %41

37:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %10, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %10, align 4, !tbaa !5
  br label %28, !llvm.loop !9

41:                                               ; preds = %33
  %42 = landingpad { ptr, i32 }
          cleanup
  %43 = extractvalue { ptr, i32 } %42, 0
  store ptr %43, ptr %12, align 8
  %44 = extractvalue { ptr, i32 } %42, 1
  store i32 %44, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %88

45:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 1, ptr %14, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %81, %45
  %47 = load i32, ptr %14, align 4, !tbaa !5
  %48 = load i32, ptr %5, align 4, !tbaa !5
  %49 = icmp slt i32 %47, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %46
  store i32 5, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %84

51:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %52 = load i32, ptr %14, align 4, !tbaa !5
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %15, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %72, %51
  %55 = load i32, ptr %15, align 4, !tbaa !5
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = icmp slt i32 %55, %56
  br i1 %57, label %59, label %58

58:                                               ; preds = %54
  store i32 8, ptr %8, align 4
  br label %79

59:                                               ; preds = %54
  %60 = load i32, ptr %6, align 4, !tbaa !5
  %61 = load i32, ptr %7, align 4, !tbaa !5
  %62 = icmp eq i32 %60, %61
  br i1 %62, label %63, label %64

63:                                               ; preds = %59
  store i32 8, ptr %8, align 4
  br label %79

64:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %65 = getelementptr inbounds %"struct.std::array", ptr %16, i32 0, i32 0
  %66 = load i32, ptr %14, align 4, !tbaa !5
  store i32 %66, ptr %65, align 4, !tbaa !5
  %67 = getelementptr inbounds i32, ptr %65, i64 1
  %68 = load i32, ptr %15, align 4, !tbaa !5
  store i32 %68, ptr %67, align 4, !tbaa !5
  invoke void @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(8) %16)
          to label %69 unwind label %75

69:                                               ; preds = %64
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  %70 = load i32, ptr %7, align 4, !tbaa !5
  %71 = add nsw i32 %70, -1
  store i32 %71, ptr %7, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %69
  %73 = load i32, ptr %15, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %15, align 4, !tbaa !5
  br label %54, !llvm.loop !11

75:                                               ; preds = %64
  %76 = landingpad { ptr, i32 }
          cleanup
  %77 = extractvalue { ptr, i32 } %76, 0
  store ptr %77, ptr %12, align 8
  %78 = extractvalue { ptr, i32 } %76, 1
  store i32 %78, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %88

79:                                               ; preds = %63, %58
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %80

80:                                               ; preds = %79
  br label %81

81:                                               ; preds = %80
  %82 = load i32, ptr %14, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %14, align 4, !tbaa !5
  br label %46, !llvm.loop !12

84:                                               ; preds = %50
  store i1 true, ptr %9, align 1
  store i32 1, ptr %8, align 4
  %85 = load i1, ptr %9, align 1
  br i1 %85, label %87, label %86

86:                                               ; preds = %84
  call void @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  br label %87

87:                                               ; preds = %86, %84
  br label %89

88:                                               ; preds = %75, %41
  call void @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %90

89:                                               ; preds = %87, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret void

90:                                               ; preds = %88
  %91 = load ptr, ptr %12, align 8
  %92 = load i32, ptr %13, align 4
  %93 = insertvalue { ptr, i32 } poison, ptr %91, 0
  %94 = insertvalue { ptr, i32 } %93, i32 %92, 1
  resume { ptr, i32 } %94
}

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(8)) #0 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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

%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::array<int, 2>, std::allocator<std::array<int, 2>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::array<int, 2>, std::allocator<std::array<int, 2>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::array<int, 2>, std::allocator<std::array<int, 2>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::array<int, 2>, std::allocator<std::array<int, 2>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::array" = type { [2 x i32] }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solveii(ptr dead_on_unwind noalias writable sret(%"class.std::vector") align 8 %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"struct.std::array", align 4
  %5 = alloca %"struct.std::array", align 4
  %6 = add nsw i32 %1, -1
  %7 = add nsw i32 %1, -2
  %8 = mul nsw i32 %6, %7
  %9 = sdiv i32 %8, 2
  %10 = icmp slt i32 %9, %2
  br i1 %10, label %11, label %12

11:                                               ; preds = %3
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %0, i8 0, i64 24, i1 false)
  tail call void @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  br label %.loopexit31

12:                                               ; preds = %3
  tail call void @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  %13 = icmp sgt i32 %1, 1
  br i1 %13, label %.lr.ph, label %.loopexit31

.lr.ph:                                           ; preds = %12
  %14 = getelementptr inbounds i8, ptr %4, i64 4
  br label %16

.preheader:                                       ; preds = %17
  br i1 %13, label %.lr.ph40, label %.loopexit31

.lr.ph40:                                         ; preds = %.preheader
  %15 = getelementptr inbounds i8, ptr %5, i64 4
  br label %21

16:                                               ; preds = %.lr.ph, %17
  %.02533 = phi i32 [ 1, %.lr.ph ], [ %18, %17 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  store i32 %.02533, ptr %14, align 4, !tbaa !5
  invoke void @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(8) %4)
          to label %17 unwind label %19

17:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  %18 = add nuw nsw i32 %.02533, 1
  %exitcond.not = icmp eq i32 %18, %1
  br i1 %exitcond.not, label %.preheader, label %16, !llvm.loop !9

19:                                               ; preds = %16
  %20 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  br label %32

.loopexit:                                        ; preds = %25, %21
  %.1.lcssa = phi i32 [ %.02638, %21 ], [ %26, %25 ]
  %exitcond41.not = icmp eq i32 %22, %1
  br i1 %exitcond41.not, label %.loopexit31, label %21, !llvm.loop !11

21:                                               ; preds = %.lr.ph40, %.loopexit
  %.02239 = phi i32 [ 1, %.lr.ph40 ], [ %22, %.loopexit ]
  %.02638 = phi i32 [ %9, %.lr.ph40 ], [ %.1.lcssa, %.loopexit ]
  %22 = add nuw nsw i32 %.02239, 1
  %23 = icmp sge i32 %22, %1
  %24 = icmp eq i32 %.02638, %2
  %or.cond34 = select i1 %23, i1 true, i1 %24
  br i1 %or.cond34, label %.loopexit, label %.lr.ph37

.lr.ph37:                                         ; preds = %21, %25
  %.036 = phi i32 [ %27, %25 ], [ %22, %21 ]
  %.135 = phi i32 [ %26, %25 ], [ %.02638, %21 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  store i32 %.02239, ptr %5, align 4, !tbaa !5
  store i32 %.036, ptr %15, align 4, !tbaa !5
  invoke void @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 4 dereferenceable(8) %5)
          to label %25 unwind label %30

25:                                               ; preds = %.lr.ph37
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  %26 = add nsw i32 %.135, -1
  %27 = add nuw nsw i32 %.036, 1
  %28 = icmp sge i32 %27, %1
  %29 = icmp eq i32 %26, %2
  %or.cond = select i1 %28, i1 true, i1 %29
  br i1 %or.cond, label %.loopexit, label %.lr.ph37, !llvm.loop !12

30:                                               ; preds = %.lr.ph37
  %31 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  br label %32

32:                                               ; preds = %30, %19
  %.pn = phi { ptr, i32 } [ %20, %19 ], [ %31, %30 ]
  call void @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  resume { ptr, i32 } %.pn

.loopexit31:                                      ; preds = %.loopexit, %12, %.preheader, %11
  ret void
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 2

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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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