; LLVM IR from ShahjalalShohag/code-library :: Number Theory/Number of Solutions to a Basic Linear Algebraic Equation.ll (Z2yoiiii)

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

@C = external dso_local global %struct.Combi, align 8

; Function Attrs: mustprogress uwtable
define dso_local i32 @_Z2yoiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca %struct.modint, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %struct.modint, align 4
  %12 = alloca %struct.modint, align 4
  %13 = alloca %struct.modint, align 4
  %14 = alloca %struct.modint, align 4
  %15 = alloca %struct.modint, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  %16 = load i32, ptr %7, align 4, !tbaa !5
  %17 = load i32, ptr %8, align 4, !tbaa !5
  %18 = load i32, ptr %6, align 4, !tbaa !5
  %19 = mul nsw i32 %17, %18
  %20 = icmp slt i32 %16, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %4
  call void @_ZN6modintILi1000000007EEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %5, i32 noundef 0)
  br label %77

22:                                               ; preds = %4
  %23 = load i32, ptr %8, align 4, !tbaa !5
  %24 = load i32, ptr %6, align 4, !tbaa !5
  %25 = mul nsw i32 %23, %24
  %26 = load i32, ptr %7, align 4, !tbaa !5
  %27 = sub nsw i32 %26, %25
  store i32 %27, ptr %7, align 4, !tbaa !5
  %28 = load i32, ptr %8, align 4, !tbaa !5
  %29 = load i32, ptr %9, align 4, !tbaa !5
  %30 = sub nsw i32 %29, %28
  store i32 %30, ptr %9, align 4, !tbaa !5
  call void @_ZN6modintILi1000000007EEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %5, i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %73, %22
  %32 = load i32, ptr %10, align 4, !tbaa !5
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = icmp sle i32 %32, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %76

36:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = load i32, ptr %10, align 4, !tbaa !5
  %39 = sub nsw i32 %37, %38
  %40 = load i32, ptr %10, align 4, !tbaa !5
  %41 = load i32, ptr %9, align 4, !tbaa !5
  %42 = mul nsw i32 %40, %41
  %43 = sub nsw i32 %39, %42
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = add nsw i32 %43, %44
  %46 = sub nsw i32 %45, 1
  %47 = add nsw i32 %46, 1
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = sub nsw i32 %48, 1
  %50 = add nsw i32 %49, 1
  %51 = call i32 @_ZN5Combi3ncrEii(ptr noundef nonnull align 8 dereferenceable(80) @C, i32 noundef %47, i32 noundef %50)
  %52 = getelementptr inbounds %struct.modint, ptr %12, i32 0, i32 0
  store i32 %51, ptr %52, align 4
  %53 = load i32, ptr %6, align 4, !tbaa !5
  %54 = load i32, ptr %10, align 4, !tbaa !5
  %55 = call i32 @_ZN5Combi3ncrEii(ptr noundef nonnull align 8 dereferenceable(80) @C, i32 noundef %53, i32 noundef %54)
  %56 = getelementptr inbounds %struct.modint, ptr %13, i32 0, i32 0
  store i32 %55, ptr %56, align 4
  %57 = getelementptr inbounds %struct.modint, ptr %13, i32 0, i32 0
  %58 = load i32, ptr %57, align 4
  %59 = call i32 @_ZNK6modintILi1000000007EEmlES0_(ptr noundef nonnull align 4 dereferenceable(4) %12, i32 %58)
  %60 = getelementptr inbounds %struct.modint, ptr %11, i32 0, i32 0
  store i32 %59, ptr %60, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  %61 = load i32, ptr %10, align 4, !tbaa !5
  %62 = and i32 %61, 1
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %68

64:                                               ; preds = %36
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 %11, i64 4, i1 false), !tbaa.struct !9
  %65 = getelementptr inbounds %struct.modint, ptr %14, i32 0, i32 0
  %66 = load i32, ptr %65, align 4
  %67 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6modintILi1000000007EEmIES0_(ptr noundef nonnull align 4 dereferenceable(4) %5, i32 %66)
  br label %72

68:                                               ; preds = %36
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %11, i64 4, i1 false), !tbaa.struct !9
  %69 = getelementptr inbounds %struct.modint, ptr %15, i32 0, i32 0
  %70 = load i32, ptr %69, align 4
  %71 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6modintILi1000000007EEpLES0_(ptr noundef nonnull align 4 dereferenceable(4) %5, i32 %70)
  br label %72

72:                                               ; preds = %68, %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %10, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %10, align 4, !tbaa !5
  br label %31, !llvm.loop !10

76:                                               ; preds = %35
  br label %77

77:                                               ; preds = %76, %21
  %78 = getelementptr inbounds %struct.modint, ptr %5, i32 0, i32 0
  %79 = load i32, ptr %78, align 4
  ret i32 %79
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i32 @_ZN5Combi3ncrEii(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, i32 noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i32 @_ZNK6modintILi1000000007EEmlES0_(ptr noundef nonnull align 4 dereferenceable(4), i32) #3 align 2

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN6modintILi1000000007EEmIES0_(ptr noundef nonnull align 4 dereferenceable(4), i32) #5 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN6modintILi1000000007EEpLES0_(ptr noundef nonnull align 4 dereferenceable(4), i32) #5 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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { inlinehint 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 #6 = { 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 = !{i64 0, i64 4, !5}
!10 = distinct !{!10, !11}
!11 = !{!"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.Combi = type { i32, %"class.std::vector", %"class.std::vector", %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<modint<1000000007>, std::allocator<modint<1000000007>>>::_Vector_impl" }
%"struct.std::_Vector_base<modint<1000000007>, std::allocator<modint<1000000007>>>::_Vector_impl" = type { %"struct.std::_Vector_base<modint<1000000007>, std::allocator<modint<1000000007>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<modint<1000000007>, std::allocator<modint<1000000007>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.modint = type { i32 }

@C = external dso_local global %struct.Combi, align 8

; Function Attrs: mustprogress uwtable
define dso_local i32 @_Z2yoiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = alloca %struct.modint, align 4
  %6 = alloca %struct.modint, align 4
  %7 = mul nsw i32 %2, %0
  %8 = icmp sgt i32 %7, %1
  br i1 %8, label %9, label %10

9:                                                ; preds = %4
  call void @_ZN6modintILi1000000007EEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %5, i32 noundef 0)
  br label %.loopexit

10:                                               ; preds = %4
  %.neg = sub i32 %2, %3
  call void @_ZN6modintILi1000000007EEC2Ei(ptr noundef nonnull align 4 dereferenceable(4) %5, i32 noundef 0)
  %.not31 = icmp slt i32 %0, 0
  br i1 %.not31, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %10
  %.neg30 = add i32 %1, %0
  br label %11

11:                                               ; preds = %.lr.ph, %23
  %.032 = phi i32 [ 0, %.lr.ph ], [ %24, %23 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  %.neg27 = mul i32 %.032, %.neg
  %12 = add i32 %7, %.032
  %13 = sub i32 %.neg30, %12
  %14 = add i32 %13, %.neg27
  %15 = call i32 @_ZN5Combi3ncrEii(ptr noundef nonnull align 8 dereferenceable(80) @C, i32 noundef %14, i32 noundef %0)
  store i32 %15, ptr %6, align 4
  %16 = call i32 @_ZN5Combi3ncrEii(ptr noundef nonnull align 8 dereferenceable(80) @C, i32 noundef %0, i32 noundef %.032)
  %17 = call i32 @_ZNK6modintILi1000000007EEmlES0_(ptr noundef nonnull align 4 dereferenceable(4) %6, i32 %16)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  %18 = and i32 %.032, 1
  %.not28 = icmp eq i32 %18, 0
  br i1 %.not28, label %21, label %19

19:                                               ; preds = %11
  %20 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6modintILi1000000007EEmIES0_(ptr noundef nonnull align 4 dereferenceable(4) %5, i32 %17)
  br label %23

21:                                               ; preds = %11
  %22 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6modintILi1000000007EEpLES0_(ptr noundef nonnull align 4 dereferenceable(4) %5, i32 %17)
  br label %23

23:                                               ; preds = %21, %19
  %24 = add nuw i32 %.032, 1
  %exitcond.not = icmp eq i32 %.032, %0
  br i1 %exitcond.not, label %.loopexit, label %11, !llvm.loop !5

.loopexit:                                        ; preds = %23, %10, %9
  %25 = load i32, ptr %5, align 4
  ret i32 %25
}

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i32 @_ZN5Combi3ncrEii(ptr noundef nonnull align 8 dereferenceable(80), i32 noundef, i32 noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i32 @_ZNK6modintILi1000000007EEmlES0_(ptr noundef nonnull align 4 dereferenceable(4), i32) local_unnamed_addr #3 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN6modintILi1000000007EEmIES0_(ptr noundef nonnull align 4 dereferenceable(4), i32) local_unnamed_addr #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN6modintILi1000000007EEpLES0_(ptr noundef nonnull align 4 dereferenceable(4), i32) local_unnamed_addr #4 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 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 = { inlinehint 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 #5 = { 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,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass