; LLVM IR from xirc/cp-algorithm :: codeforces/1430/1430A/main.ll (Z5solvei)

; 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<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::initializer_list" = type { ptr, i64 }
%"class.std::allocator" = type { i8 }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvei(ptr dead_on_unwind noalias writable sret(%"class.std::vector") align 8 %0, i32 noundef %1) #0 personality ptr @__gxx_personality_v0 {
  %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 i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %"class.std::initializer_list", align 8
  %11 = alloca [3 x i32], align 4
  %12 = alloca %"class.std::allocator", align 1
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %3, align 8
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %78, %2
  %16 = load i32, ptr %5, align 4, !tbaa !5
  %17 = icmp slt i32 %16, 150
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  store i32 2, ptr %6, align 4
  br label %81

19:                                               ; preds = %15
  %20 = load i32, ptr %5, align 4, !tbaa !5
  %21 = mul nsw i32 %20, 7
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = icmp sgt i32 %21, %22
  br i1 %23, label %24, label %25

24:                                               ; preds = %19
  store i32 2, ptr %6, align 4
  br label %81

25:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %72, %25
  %27 = load i32, ptr %7, align 4, !tbaa !5
  %28 = icmp slt i32 %27, 250
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  store i32 5, ptr %6, align 4
  br label %75

30:                                               ; preds = %26
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = mul nsw i32 %31, 7
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = mul nsw i32 %33, 5
  %35 = add nsw i32 %32, %34
  %36 = load i32, ptr %4, align 4, !tbaa !5
  %37 = icmp sgt i32 %35, %36
  br i1 %37, label %38, label %39

38:                                               ; preds = %30
  store i32 5, ptr %6, align 4
  br label %75

39:                                               ; preds = %30
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = load i32, ptr %5, align 4, !tbaa !5
  %42 = mul nsw i32 %41, 7
  %43 = sub nsw i32 %40, %42
  %44 = load i32, ptr %7, align 4, !tbaa !5
  %45 = mul nsw i32 %44, 5
  %46 = sub nsw i32 %43, %45
  store i32 %46, ptr %8, align 4, !tbaa !5
  %47 = load i32, ptr %8, align 4, !tbaa !5
  %48 = srem i32 %47, 3
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %50, label %51

50:                                               ; preds = %39
  store i32 7, ptr %6, align 4
  br label %70

51:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %52 = load i32, ptr %8, align 4, !tbaa !5
  %53 = sdiv i32 %52, 3
  store i32 %53, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %11) #4
  %54 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %54, ptr %11, align 4, !tbaa !5
  %55 = getelementptr inbounds i32, ptr %11, i64 1
  %56 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %56, ptr %55, align 4, !tbaa !5
  %57 = getelementptr inbounds i32, ptr %11, i64 2
  %58 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %58, ptr %57, align 4, !tbaa !5
  %59 = getelementptr inbounds %"class.std::initializer_list", ptr %10, i32 0, i32 0
  store ptr %11, ptr %59, align 8, !tbaa !9
  %60 = getelementptr inbounds %"class.std::initializer_list", ptr %10, i32 0, i32 1
  store i64 3, ptr %60, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #4
  call void @_ZNSaIiEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %12) #4
  %61 = getelementptr inbounds { ptr, i64 }, ptr %10, i32 0, i32 0
  %62 = load ptr, ptr %61, align 8
  %63 = getelementptr inbounds { ptr, i64 }, ptr %10, i32 0, i32 1
  %64 = load i64, ptr %63, align 8
  invoke void @_ZNSt6vectorIiSaIiEEC2ESt16initializer_listIiERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr %62, i64 %64, ptr noundef nonnull align 1 dereferenceable(1) %12)
          to label %65 unwind label %66

65:                                               ; preds = %51
  call void @_ZNSt15__new_allocatorIiED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %12) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %11) #4
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %70

66:                                               ; preds = %51
  %67 = landingpad { ptr, i32 }
          cleanup
  %68 = extractvalue { ptr, i32 } %67, 0
  store ptr %68, ptr %13, align 8
  %69 = extractvalue { ptr, i32 } %67, 1
  store i32 %69, ptr %14, align 4
  call void @_ZNSt15__new_allocatorIiED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %12) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %85

70:                                               ; preds = %65, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %71 = load i32, ptr %6, align 4
  switch i32 %71, label %75 [
    i32 7, label %72
  ]

72:                                               ; preds = %70
  %73 = load i32, ptr %7, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %7, align 4, !tbaa !5
  br label %26, !llvm.loop !14

75:                                               ; preds = %70, %38, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  %76 = load i32, ptr %6, align 4
  switch i32 %76, label %81 [
    i32 5, label %77
  ]

77:                                               ; preds = %75
  br label %78

78:                                               ; preds = %77
  %79 = load i32, ptr %5, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %5, align 4, !tbaa !5
  br label %15, !llvm.loop !16

81:                                               ; preds = %75, %24, %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  %82 = load i32, ptr %6, align 4
  switch i32 %82, label %90 [
    i32 2, label %83
    i32 1, label %84
  ]

83:                                               ; preds = %81
  call void @llvm.memset.p0.i64(ptr align 8 %0, i8 0, i64 24, i1 false)
  call void @_ZNSt6vectorIiSaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  br label %84

84:                                               ; preds = %83, %81
  ret void

85:                                               ; preds = %66
  %86 = load ptr, ptr %13, align 8
  %87 = load i32, ptr %14, align 4
  %88 = insertvalue { ptr, i32 } poison, ptr %86, 0
  %89 = insertvalue { ptr, i32 } %88, i32 %87, 1
  resume { ptr, i32 } %89

90:                                               ; preds = %81
  unreachable
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSaIiEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEEC2ESt16initializer_listIiERKS0_(ptr noundef nonnull align 8 dereferenceable(24), ptr, i64, ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIiED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 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 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!10, !11, i64 0}
!10 = !{!"_ZTSSt16initializer_listIiE", !11, i64 0, !12, i64 8}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !12, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


; 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<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::allocator" = type { i8 }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvei(ptr dead_on_unwind noalias writable sret(%"class.std::vector") align 8 %0, i32 noundef %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca [3 x i32], align 4
  %4 = alloca %"class.std::allocator", align 1
  br label %5

5:                                                ; preds = %2, %29
  %.038 = phi i32 [ 0, %2 ], [ %30, %29 ]
  %6 = mul nuw nsw i32 %.038, 7
  %7 = icmp sgt i32 %6, %1
  br i1 %7, label %32, label %.preheader

.preheader:                                       ; preds = %5, %27
  %.02337 = phi i32 [ %28, %27 ], [ 0, %5 ]
  %8 = mul nuw nsw i32 %.02337, 5
  %9 = add nuw nsw i32 %8, %6
  %10 = icmp sgt i32 %9, %1
  br i1 %10, label %29, label %11

11:                                               ; preds = %.preheader
  %12 = sub i32 %1, %9
  %13 = srem i32 %12, 3
  %.not.not = icmp eq i32 %13, 0
  br i1 %.not.not, label %14, label %.preheader.1

14:                                               ; preds = %24, %11
  %.02337.lcssa46 = phi i32 [ %.02337, %11 ], [ %20, %24 ]
  %.lcssa = phi i32 [ %12, %11 ], [ %25, %24 ]
  %15 = sdiv i32 %.lcssa, 3
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %3) #4
  store i32 %15, ptr %3, align 4, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %3, i64 4
  store i32 %.02337.lcssa46, ptr %16, align 4, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %3, i64 8
  store i32 %.038, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #4
  call void @_ZNSaIiEC2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #4
  invoke void @_ZNSt6vectorIiSaIiEEC2ESt16initializer_listIiERKS0_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr nonnull %3, i64 3, ptr noundef nonnull align 1 dereferenceable(1) %4)
          to label %31 unwind label %18

18:                                               ; preds = %14
  %19 = landingpad { ptr, i32 }
          cleanup
  call void @_ZNSt15__new_allocatorIiED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #4
  resume { ptr, i32 } %19

.preheader.1:                                     ; preds = %11
  %20 = or disjoint i32 %.02337, 1
  %21 = mul nuw nsw i32 %20, 5
  %22 = add nuw nsw i32 %21, %6
  %23 = icmp sgt i32 %22, %1
  br i1 %23, label %29, label %24

24:                                               ; preds = %.preheader.1
  %25 = sub i32 %1, %22
  %26 = srem i32 %25, 3
  %.not.not.1 = icmp eq i32 %26, 0
  br i1 %.not.not.1, label %14, label %27

27:                                               ; preds = %24
  %28 = add nuw nsw i32 %.02337, 2
  %exitcond.not.1 = icmp eq i32 %28, 250
  br i1 %exitcond.not.1, label %29, label %.preheader, !llvm.loop !9

29:                                               ; preds = %27, %.preheader.1, %.preheader
  %30 = add nuw nsw i32 %.038, 1
  %exitcond41.not = icmp eq i32 %30, 150
  br i1 %exitcond41.not, label %32, label %5, !llvm.loop !11

31:                                               ; preds = %14
  call void @_ZNSt15__new_allocatorIiED2Ev(ptr noundef nonnull align 1 dereferenceable(1) %4) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %3) #4
  br label %33

32:                                               ; preds = %29, %5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %0, i8 0, i64 24, i1 false)
  tail call void @_ZNSt6vectorIiSaIiEEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  br label %33

33:                                               ; preds = %31, %32
  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 nounwind uwtable
declare dso_local void @_ZNSaIiEC2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIiSaIiEEC2ESt16initializer_listIiERKS0_(ptr noundef nonnull align 8 dereferenceable(24), ptr, i64, ptr noundef nonnull align 1 dereferenceable(1)) 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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt15__new_allocatorIiED2Ev(ptr noundef nonnull align 1 dereferenceable(1)) unnamed_addr #2 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 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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}


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