; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2020-21/Dec/Plat (space_matrix)

; 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.3" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::vector<mint<1000000007, 5>>, std::allocator<std::vector<mint<1000000007, 5>>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::vector<mint<1000000007, 5>>, std::allocator<std::vector<mint<1000000007, 5>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::vector<mint<1000000007, 5>>, std::allocator<std::vector<mint<1000000007, 5>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::vector<mint<1000000007, 5>>, std::allocator<std::vector<mint<1000000007, 5>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str.12 = external hidden unnamed_addr constant [111 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [24 x i8], align 1
@__PRETTY_FUNCTION__._Z3powSt6vectorIS_I4mintILi1000000007ELi5EESaIS1_EESaIS3_EEx = external hidden unnamed_addr constant [17 x i8], align 1

; 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

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6makeIdi(ptr dead_on_unwind noalias writable sret(%"class.std::vector.3") align 8, i32 noundef) #2

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3powSt6vectorIS_I4mintILi1000000007ELi5EESaIS1_EESaIS3_EEx(ptr dead_on_unwind noalias writable sret(%"class.std::vector.3") align 8 %0, ptr noundef %1, i64 noundef %2) #2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca i1, align 1
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i64 %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %11 = call noundef i64 @_ZNKSt6vectorIS_I4mintILi1000000007ELi5EESaIS1_EESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #4
  %12 = trunc i64 %11 to i32
  store i32 %12, ptr %7, align 4, !tbaa !11
  %13 = load i32, ptr %7, align 4, !tbaa !11
  %14 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_I4mintILi1000000007ELi5EESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef 0) #4
  %15 = call noundef i64 @_ZNKSt6vectorI4mintILi1000000007ELi5EESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %14) #4
  %16 = trunc i64 %15 to i32
  %17 = icmp eq i32 %13, %16
  br i1 %17, label %18, label %21

18:                                               ; preds = %3
  %19 = load i64, ptr %6, align 8, !tbaa !9
  %20 = icmp sge i64 %19, 0
  br label %21

21:                                               ; preds = %18, %3
  %22 = phi i1 [ false, %3 ], [ %20, %18 ]
  br i1 %22, label %23, label %24

23:                                               ; preds = %21
  br label %26

24:                                               ; preds = %21
  call void @__assert_fail(ptr noundef @.str.14, ptr noundef @.str.12, i32 noundef 308, ptr noundef @__PRETTY_FUNCTION__._Z3powSt6vectorIS_I4mintILi1000000007ELi5EESaIS1_EESaIS3_EEx) #5
  unreachable

25:                                               ; No predecessors!
  br label %26

26:                                               ; preds = %25, %23
  store i1 false, ptr %8, align 1
  %27 = load i32, ptr %7, align 4, !tbaa !11
  call void @_Z6makeIdi(ptr dead_on_unwind writable sret(%"class.std::vector.3") align 8 %0, i32 noundef %27)
  br label %28

28:                                               ; preds = %47, %26
  %29 = load i64, ptr %6, align 8, !tbaa !9
  %30 = icmp ne i64 %29, 0
  br i1 %30, label %31, label %48

31:                                               ; preds = %28
  %32 = load i64, ptr %6, align 8, !tbaa !9
  %33 = and i64 %32, 1
  %34 = icmp ne i64 %33, 0
  br i1 %34, label %35, label %42

35:                                               ; preds = %31
  %36 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZmLRSt6vectorIS_I4mintILi1000000007ELi5EESaIS1_EESaIS3_EERKS5_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1)
          to label %37 unwind label %38

37:                                               ; preds = %35
  br label %42

38:                                               ; preds = %43, %35
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %9, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %10, align 4
  call void @_ZNSt6vectorIS_I4mintILi1000000007ELi5EESaIS1_EESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %52

42:                                               ; preds = %37, %31
  br label %43

43:                                               ; preds = %42
  %44 = load i64, ptr %6, align 8, !tbaa !9
  %45 = sdiv i64 %44, 2
  store i64 %45, ptr %6, align 8, !tbaa !9
  %46 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZmLRSt6vectorIS_I4mintILi1000000007ELi5EESaIS1_EESaIS3_EERKS5_(ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %1)
          to label %47 unwind label %38

47:                                               ; preds = %43
  br label %28, !llvm.loop !13

48:                                               ; preds = %28
  store i1 true, ptr %8, align 1
  %49 = load i1, ptr %8, align 1
  br i1 %49, label %51, label %50

50:                                               ; preds = %48
  call void @_ZNSt6vectorIS_I4mintILi1000000007ELi5EESaIS1_EESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  br label %51

51:                                               ; preds = %50, %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret void

52:                                               ; preds = %38
  %53 = load ptr, ptr %9, align 8
  %54 = load i32, ptr %10, align 4
  %55 = insertvalue { ptr, i32 } poison, ptr %53, 0
  %56 = insertvalue { ptr, i32 } %55, i32 %54, 1
  resume { ptr, i32 } %56
}

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 = { 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 #3 = { noreturn nounwind "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 }
attributes #5 = { noreturn 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 long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

%"class.std::vector.3" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::vector<mint<1000000007, 5>>, std::allocator<std::vector<mint<1000000007, 5>>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::vector<mint<1000000007, 5>>, std::allocator<std::vector<mint<1000000007, 5>>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::vector<mint<1000000007, 5>>, std::allocator<std::vector<mint<1000000007, 5>>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::vector<mint<1000000007, 5>>, std::allocator<std::vector<mint<1000000007, 5>>>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str.12 = external hidden unnamed_addr constant [111 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [24 x i8], align 1
@__PRETTY_FUNCTION__._Z3powSt6vectorIS_I4mintILi1000000007ELi5EESaIS1_EESaIS3_EEx = external hidden unnamed_addr constant [17 x i8], align 1

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6makeIdi(ptr dead_on_unwind noalias writable sret(%"class.std::vector.3") align 8, i32 noundef) local_unnamed_addr #1

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZmLRSt6vectorIS_I4mintILi1000000007ELi5EESaIS1_EESaIS3_EERKS5_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3powSt6vectorIS_I4mintILi1000000007ELi5EESaIS1_EESaIS3_EEx(ptr dead_on_unwind noalias writable sret(%"class.std::vector.3") align 8 %0, ptr noundef nonnull %1, i64 noundef %2) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %4 = tail call noundef i64 @_ZNKSt6vectorIS_I4mintILi1000000007ELi5EESaIS1_EESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #3
  %5 = trunc i64 %4 to i32
  %6 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_I4mintILi1000000007ELi5EESaIS1_EESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef 0) #3
  %7 = tail call noundef i64 @_ZNKSt6vectorI4mintILi1000000007ELi5EESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %6) #3
  %8 = trunc i64 %7 to i32
  %9 = icmp eq i32 %5, %8
  %10 = icmp sgt i64 %2, -1
  %11 = and i1 %10, %9
  br i1 %11, label %13, label %12

12:                                               ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.12, i32 noundef 308, ptr noundef nonnull @__PRETTY_FUNCTION__._Z3powSt6vectorIS_I4mintILi1000000007ELi5EESaIS1_EESaIS3_EEx) #4
  unreachable

13:                                               ; preds = %3
  tail call void @_Z6makeIdi(ptr dead_on_unwind writable sret(%"class.std::vector.3") align 8 %0, i32 noundef %5)
  br label %14

14:                                               ; preds = %21, %13
  %.0 = phi i64 [ %2, %13 ], [ %22, %21 ]
  %.not = icmp eq i64 %.0, 0
  br i1 %.not, label %24, label %15

15:                                               ; preds = %14
  %16 = and i64 %.0, 1
  %.not10 = icmp eq i64 %16, 0
  br i1 %.not10, label %21, label %17

17:                                               ; preds = %15
  %18 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZmLRSt6vectorIS_I4mintILi1000000007ELi5EESaIS1_EESaIS3_EERKS5_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(24) %1)
          to label %21 unwind label %19

19:                                               ; preds = %21, %17
  %20 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZNSt6vectorIS_I4mintILi1000000007ELi5EESaIS1_EESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #3
  resume { ptr, i32 } %20

21:                                               ; preds = %15, %17
  %22 = lshr i64 %.0, 1
  %23 = invoke noundef nonnull align 8 dereferenceable(24) ptr @_ZmLRSt6vectorIS_I4mintILi1000000007ELi5EESaIS1_EESaIS3_EERKS5_(ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(24) %1)
          to label %14 unwind label %19, !llvm.loop !5

24:                                               ; preds = %14
  ret void
}

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 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 = { noreturn nounwind "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 = { nounwind }
attributes #4 = { noreturn 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass