; LLVM IR from kazunetakahashi/atcoder :: 2020/0222_ABC156/past/E.ll (Z5solvexx)

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

@C = external dso_local global %class.Combination, align 8

; Function Attrs: mustprogress uwtable
define dso_local i64 @_Z5solvexx(i64 noundef %0, i64 noundef %1) #0 {
  %3 = alloca %class.Mint, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca %class.Mint, align 8
  %8 = alloca %class.Mint, align 8
  %9 = alloca %class.Mint, align 8
  store i64 %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !5
  call void @_ZN4MintILx1000000007EEC2Ex(ptr noundef nonnull align 8 dereferenceable(8) %3, i64 noundef 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %42, %2
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = sext i32 %11 to i64
  %13 = load i64, ptr %5, align 8, !tbaa !5
  %14 = icmp sle i64 %12, %13
  br i1 %14, label %16, label %15

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

16:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %17 = load i64, ptr %4, align 8, !tbaa !5
  %18 = trunc i64 %17 to i32
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = call i64 @_ZN11CombinationILx1000000007ELx3000010EEclEii(ptr noundef nonnull align 8 dereferenceable(72) @C, i32 noundef %18, i32 noundef %19)
  %21 = getelementptr inbounds %class.Mint, ptr %8, i32 0, i32 0
  store i64 %20, ptr %21, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = load i64, ptr %4, align 8, !tbaa !5
  %25 = add nsw i64 %23, %24
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = sub nsw i64 %25, %27
  %29 = sub nsw i64 %28, 1
  %30 = trunc i64 %29 to i32
  %31 = load i64, ptr %4, align 8, !tbaa !5
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = sub nsw i64 %31, %33
  %35 = sub nsw i64 %34, 1
  %36 = trunc i64 %35 to i32
  %37 = call i64 @_ZN11CombinationILx1000000007ELx3000010EEclEii(ptr noundef nonnull align 8 dereferenceable(72) @C, i32 noundef %30, i32 noundef %36)
  %38 = getelementptr inbounds %class.Mint, ptr %9, i32 0, i32 0
  store i64 %37, ptr %38, align 8
  %39 = call i64 @_ZNK4MintILx1000000007EEmlERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %9)
  %40 = getelementptr inbounds %class.Mint, ptr %7, i32 0, i32 0
  store i64 %39, ptr %40, align 8
  %41 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4MintILx1000000007EEpLERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %7)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %42

42:                                               ; preds = %16
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %6, align 4, !tbaa !9
  br label %10, !llvm.loop !11

45:                                               ; preds = %15
  %46 = getelementptr inbounds %class.Mint, ptr %3, i32 0, i32 0
  %47 = load i64, ptr %46, align 8
  ret i64 %47
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4MintILx1000000007EEC2Ex(ptr noundef nonnull align 8 dereferenceable(8), i64 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: mustprogress uwtable
declare dso_local i64 @_ZN11CombinationILx1000000007ELx3000010EEclEii(ptr noundef nonnull align 8 dereferenceable(72), i32 noundef, i32 noundef) #0 align 2

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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.Combination = type { %"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<Mint<>, std::allocator<Mint<>>>::_Vector_impl" }
%"struct.std::_Vector_base<Mint<>, std::allocator<Mint<>>>::_Vector_impl" = type { %"struct.std::_Vector_base<Mint<>, std::allocator<Mint<>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Mint<>, std::allocator<Mint<>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.Mint = type { i64 }

@C = external dso_local global %class.Combination, align 8

; Function Attrs: mustprogress uwtable
define dso_local i64 @_Z5solvexx(i64 noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = alloca %class.Mint, align 8
  %4 = alloca %class.Mint, align 8
  %5 = alloca %class.Mint, align 8
  %6 = alloca %class.Mint, align 8
  call void @_ZN4MintILx1000000007EEC2Ex(ptr noundef nonnull align 8 dereferenceable(8) %3, i64 noundef 0)
  %.not11 = icmp slt i64 %1, 0
  br i1 %.not11, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %7 = trunc i64 %0 to i32
  %8 = add i32 %7, -1
  br label %10

._crit_edge:                                      ; preds = %10, %2
  %9 = load i64, ptr %3, align 8
  ret i64 %9

10:                                               ; preds = %.lr.ph, %10
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %10 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %11 = trunc nuw nsw i64 %indvars.iv to i32
  %12 = call i64 @_ZN11CombinationILx1000000007ELx3000010EEclEii(ptr noundef nonnull align 8 dereferenceable(72) @C, i32 noundef %7, i32 noundef %11)
  store i64 %12, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  %13 = xor i64 %indvars.iv, -1
  %14 = add i64 %13, %0
  %15 = trunc i64 %14 to i32
  %16 = call i64 @_ZN11CombinationILx1000000007ELx3000010EEclEii(ptr noundef nonnull align 8 dereferenceable(72) @C, i32 noundef %8, i32 noundef %15)
  store i64 %16, ptr %6, align 8
  %17 = call i64 @_ZNK4MintILx1000000007EEmlERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6)
  store i64 %17, ptr %4, align 8
  %18 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN4MintILx1000000007EEpLERKS0_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %.not.not = icmp slt i64 %indvars.iv, %1
  br i1 %.not.not, label %10, label %._crit_edge, !llvm.loop !5
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4MintILx1000000007EEC2Ex(ptr noundef nonnull align 8 dereferenceable(8), i64 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: mustprogress uwtable
declare dso_local i64 @_ZN11CombinationILx1000000007ELx3000010EEclEii(ptr noundef nonnull align 8 dereferenceable(72), i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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,SROAPass,SimplifyCFGPass