; LLVM IR from tangjz/acm-icpc :: lydsy/3738.ll (Z5solvev)

; 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.std::pair" = type { i32, i64 }
%"struct.std::pair.0" = type { i32, i32 }

@N = external dso_local global i64, align 8
@M = external dso_local global i64, align 8
@all = external dso_local global %"struct.std::pair", align 8
@now = external dso_local global %"struct.std::pair", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z7mod_invi(i32 noundef) #0

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7mod_mulii(i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local { i32, i64 } @_Z8mod_factx(i64 noundef) #0

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #0 {
  %1 = alloca %"struct.std::pair.0", align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %"struct.std::pair", align 8
  %5 = alloca %"struct.std::pair", align 8
  %6 = alloca %"struct.std::pair", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  %7 = call i64 @_ZSt9make_pairIiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS1_INS2_IT0_E4typeEE6__typeEEOS3_OS8_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  store i64 %7, ptr %1, align 4
  %8 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIixEaSIiiEENSt9enable_ifIXsr6__and_ISt13is_assignableIRiOT_ES3_IRxOT0_EEE5valueERS0_E4typeEOS_IS5_S9_E(ptr noundef nonnull align 8 dereferenceable(16) @all, ptr noundef nonnull align 4 dereferenceable(8) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %4) #4
  %9 = load i64, ptr @N, align 8, !tbaa !9
  %10 = load i64, ptr @M, align 8, !tbaa !9
  %11 = add nsw i64 %9, %10
  %12 = call { i32, i64 } @_Z8mod_factx(i64 noundef %11)
  %13 = getelementptr inbounds { i32, i64 }, ptr %4, i32 0, i32 0
  %14 = extractvalue { i32, i64 } %12, 0
  store i32 %14, ptr %13, align 8
  %15 = getelementptr inbounds { i32, i64 }, ptr %4, i32 0, i32 1
  %16 = extractvalue { i32, i64 } %12, 1
  store i64 %16, ptr %15, align 8
  %17 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIixEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16) @now, ptr noundef nonnull align 8 dereferenceable(16) %4) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %4) #4
  %18 = load i32, ptr @all, align 8, !tbaa !11
  %19 = load i32, ptr @now, align 8, !tbaa !11
  %20 = call noundef i32 @_Z7mod_mulii(i32 noundef %18, i32 noundef %19)
  store i32 %20, ptr @all, align 8, !tbaa !11
  %21 = load i64, ptr getelementptr inbounds (%"struct.std::pair", ptr @now, i32 0, i32 1), align 8, !tbaa !13
  %22 = load i64, ptr getelementptr inbounds (%"struct.std::pair", ptr @all, i32 0, i32 1), align 8, !tbaa !13
  %23 = add nsw i64 %22, %21
  store i64 %23, ptr getelementptr inbounds (%"struct.std::pair", ptr @all, i32 0, i32 1), align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #4
  %24 = load i64, ptr @N, align 8, !tbaa !9
  %25 = call { i32, i64 } @_Z8mod_factx(i64 noundef %24)
  %26 = getelementptr inbounds { i32, i64 }, ptr %5, i32 0, i32 0
  %27 = extractvalue { i32, i64 } %25, 0
  store i32 %27, ptr %26, align 8
  %28 = getelementptr inbounds { i32, i64 }, ptr %5, i32 0, i32 1
  %29 = extractvalue { i32, i64 } %25, 1
  store i64 %29, ptr %28, align 8
  %30 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIixEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16) @now, ptr noundef nonnull align 8 dereferenceable(16) %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #4
  %31 = load i32, ptr @all, align 8, !tbaa !11
  %32 = load i32, ptr @now, align 8, !tbaa !11
  %33 = call noundef i32 @_Z7mod_invi(i32 noundef %32)
  %34 = call noundef i32 @_Z7mod_mulii(i32 noundef %31, i32 noundef %33)
  store i32 %34, ptr @all, align 8, !tbaa !11
  %35 = load i64, ptr getelementptr inbounds (%"struct.std::pair", ptr @now, i32 0, i32 1), align 8, !tbaa !13
  %36 = load i64, ptr getelementptr inbounds (%"struct.std::pair", ptr @all, i32 0, i32 1), align 8, !tbaa !13
  %37 = sub nsw i64 %36, %35
  store i64 %37, ptr getelementptr inbounds (%"struct.std::pair", ptr @all, i32 0, i32 1), align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #4
  %38 = load i64, ptr @M, align 8, !tbaa !9
  %39 = call { i32, i64 } @_Z8mod_factx(i64 noundef %38)
  %40 = getelementptr inbounds { i32, i64 }, ptr %6, i32 0, i32 0
  %41 = extractvalue { i32, i64 } %39, 0
  store i32 %41, ptr %40, align 8
  %42 = getelementptr inbounds { i32, i64 }, ptr %6, i32 0, i32 1
  %43 = extractvalue { i32, i64 } %39, 1
  store i64 %43, ptr %42, align 8
  %44 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIixEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16) @now, ptr noundef nonnull align 8 dereferenceable(16) %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #4
  %45 = load i32, ptr @all, align 8, !tbaa !11
  %46 = load i32, ptr @now, align 8, !tbaa !11
  %47 = call noundef i32 @_Z7mod_invi(i32 noundef %46)
  %48 = call noundef i32 @_Z7mod_mulii(i32 noundef %45, i32 noundef %47)
  store i32 %48, ptr @all, align 8, !tbaa !11
  %49 = load i64, ptr getelementptr inbounds (%"struct.std::pair", ptr @now, i32 0, i32 1), align 8, !tbaa !13
  %50 = load i64, ptr getelementptr inbounds (%"struct.std::pair", ptr @all, i32 0, i32 1), align 8, !tbaa !13
  %51 = sub nsw i64 %50, %49
  store i64 %51, ptr getelementptr inbounds (%"struct.std::pair", ptr @all, i32 0, i32 1), align 8, !tbaa !13
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIixEaSIiiEENSt9enable_ifIXsr6__and_ISt13is_assignableIRiOT_ES3_IRxOT0_EEE5valueERS0_E4typeEOS_IS5_S9_E(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(8)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIixEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #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 = { 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 #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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSSt4pairIixE", !6, i64 0, !10, i64 8}
!13 = !{!12, !10, i64 8}


; 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.std::pair" = type { i32, i64 }
%"struct.std::pair.0" = type { i32, i32 }

@N = external dso_local local_unnamed_addr global i64, align 8
@M = external dso_local local_unnamed_addr global i64, align 8
@all = external dso_local global %"struct.std::pair", align 8
@now = external dso_local global %"struct.std::pair", align 8

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z7mod_invi(i32 noundef) local_unnamed_addr #0

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7mod_mulii(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local { i32, i64 } @_Z8mod_factx(i64 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 {
  %1 = alloca %"struct.std::pair.0", align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %"struct.std::pair", align 8
  %5 = alloca %"struct.std::pair", align 8
  %6 = alloca %"struct.std::pair", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  %7 = call i64 @_ZSt9make_pairIiiESt4pairINSt25__strip_reference_wrapperINSt5decayIT_E4typeEE6__typeENS1_INS2_IT0_E4typeEE6__typeEEOS3_OS8_(ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  store i64 %7, ptr %1, align 8
  %8 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIixEaSIiiEENSt9enable_ifIXsr6__and_ISt13is_assignableIRiOT_ES3_IRxOT0_EEE5valueERS0_E4typeEOS_IS5_S9_E(ptr noundef nonnull align 8 dereferenceable(16) @all, ptr noundef nonnull align 4 dereferenceable(8) %1)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  %9 = load i64, ptr @N, align 8, !tbaa !9
  %10 = load i64, ptr @M, align 8, !tbaa !9
  %11 = add nsw i64 %10, %9
  %12 = call { i32, i64 } @_Z8mod_factx(i64 noundef %11)
  %13 = extractvalue { i32, i64 } %12, 0
  store i32 %13, ptr %4, align 8
  %14 = getelementptr inbounds i8, ptr %4, i64 8
  %15 = extractvalue { i32, i64 } %12, 1
  store i64 %15, ptr %14, align 8
  %16 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIixEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16) @now, ptr noundef nonnull align 8 dereferenceable(16) %4) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  %17 = load i32, ptr @all, align 8, !tbaa !11
  %18 = load i32, ptr @now, align 8, !tbaa !11
  %19 = call noundef i32 @_Z7mod_mulii(i32 noundef %17, i32 noundef %18)
  store i32 %19, ptr @all, align 8, !tbaa !11
  %20 = load i64, ptr getelementptr inbounds (i8, ptr @now, i64 8), align 8, !tbaa !13
  %21 = load i64, ptr getelementptr inbounds (i8, ptr @all, i64 8), align 8, !tbaa !13
  %22 = add nsw i64 %21, %20
  store i64 %22, ptr getelementptr inbounds (i8, ptr @all, i64 8), align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  %23 = load i64, ptr @N, align 8, !tbaa !9
  %24 = call { i32, i64 } @_Z8mod_factx(i64 noundef %23)
  %25 = extractvalue { i32, i64 } %24, 0
  store i32 %25, ptr %5, align 8
  %26 = getelementptr inbounds i8, ptr %5, i64 8
  %27 = extractvalue { i32, i64 } %24, 1
  store i64 %27, ptr %26, align 8
  %28 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIixEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16) @now, ptr noundef nonnull align 8 dereferenceable(16) %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  %29 = load i32, ptr @all, align 8, !tbaa !11
  %30 = load i32, ptr @now, align 8, !tbaa !11
  %31 = call noundef i32 @_Z7mod_invi(i32 noundef %30)
  %32 = call noundef i32 @_Z7mod_mulii(i32 noundef %29, i32 noundef %31)
  store i32 %32, ptr @all, align 8, !tbaa !11
  %33 = load i64, ptr getelementptr inbounds (i8, ptr @now, i64 8), align 8, !tbaa !13
  %34 = load i64, ptr getelementptr inbounds (i8, ptr @all, i64 8), align 8, !tbaa !13
  %35 = sub nsw i64 %34, %33
  store i64 %35, ptr getelementptr inbounds (i8, ptr @all, i64 8), align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #4
  %36 = load i64, ptr @M, align 8, !tbaa !9
  %37 = call { i32, i64 } @_Z8mod_factx(i64 noundef %36)
  %38 = extractvalue { i32, i64 } %37, 0
  store i32 %38, ptr %6, align 8
  %39 = getelementptr inbounds i8, ptr %6, i64 8
  %40 = extractvalue { i32, i64 } %37, 1
  store i64 %40, ptr %39, align 8
  %41 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIixEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16) @now, ptr noundef nonnull align 8 dereferenceable(16) %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  %42 = load i32, ptr @all, align 8, !tbaa !11
  %43 = load i32, ptr @now, align 8, !tbaa !11
  %44 = call noundef i32 @_Z7mod_invi(i32 noundef %43)
  %45 = call noundef i32 @_Z7mod_mulii(i32 noundef %42, i32 noundef %44)
  store i32 %45, ptr @all, align 8, !tbaa !11
  %46 = load i64, ptr getelementptr inbounds (i8, ptr @now, i64 8), align 8, !tbaa !13
  %47 = load i64, ptr getelementptr inbounds (i8, ptr @all, i64 8), align 8, !tbaa !13
  %48 = sub nsw i64 %47, %46
  store i64 %48, ptr getelementptr inbounds (i8, ptr @all, i64 8), align 8, !tbaa !13
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIixEaSIiiEENSt9enable_ifIXsr6__and_ISt13is_assignableIRiOT_ES3_IRxOT0_EEE5valueERS0_E4typeEOS_IS5_S9_E(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt4pairIixEaSEOS0_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_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 = { 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 #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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSSt4pairIixE", !6, i64 0, !10, i64 8}
!13 = !{!12, !10, i64 8}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass