; LLVM IR from AdarshGaur/Competitive-Programming :: Algorithm Library/Strings/Hashing.ll (Z3prev)

; 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, i32 }

@pw = external dso_local global [100007 x %"struct.std::pair"], align 16
@ipw = external dso_local global [100007 x %"struct.std::pair"], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z6modpowiii(i32 noundef, i32 noundef, 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: mustprogress uwtable
define dso_local void @_Z3prev() #2 {
  %1 = alloca %"struct.std::pair", align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %"struct.std::pair", 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  store i32 1, ptr %3, align 4, !tbaa !5
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS3_S4_EEEbE4typeELb1EEEOS3_OS4_(ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %10 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) @pw, ptr noundef nonnull align 4 dereferenceable(8) %1) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 1, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 1, ptr %6, align 4, !tbaa !5
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS3_S4_EEEbE4typeELb1EEEOS3_OS4_(ptr noundef nonnull align 4 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %11 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) @ipw, ptr noundef nonnull align 4 dereferenceable(8) %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %12 = call noundef i32 @_Z6modpowiii(i32 noundef 137, i32 noundef 1000000005, i32 noundef 1000000007)
  store i32 %12, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %13 = call noundef i32 @_Z6modpowiii(i32 noundef 277, i32 noundef 987654317, i32 noundef 987654319)
  store i32 %13, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %83, %0
  %15 = load i32, ptr %9, align 4, !tbaa !5
  %16 = icmp slt i32 %15, 100007
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %86

18:                                               ; preds = %14
  %19 = load i32, ptr %9, align 4, !tbaa !5
  %20 = sub nsw i32 %19, 1
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [100007 x %"struct.std::pair"], ptr @pw, i64 0, i64 %21
  %23 = getelementptr inbounds %"struct.std::pair", ptr %22, i32 0, i32 0
  %24 = load i32, ptr %23, align 8, !tbaa !9
  %25 = sext i32 %24 to i64
  %26 = mul nsw i64 %25, 1
  %27 = mul nsw i64 %26, 137
  %28 = srem i64 %27, 1000000007
  %29 = trunc i64 %28 to i32
  %30 = load i32, ptr %9, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [100007 x %"struct.std::pair"], ptr @pw, i64 0, i64 %31
  %33 = getelementptr inbounds %"struct.std::pair", ptr %32, i32 0, i32 0
  store i32 %29, ptr %33, align 8, !tbaa !9
  %34 = load i32, ptr %9, align 4, !tbaa !5
  %35 = sub nsw i32 %34, 1
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [100007 x %"struct.std::pair"], ptr @pw, i64 0, i64 %36
  %38 = getelementptr inbounds %"struct.std::pair", ptr %37, i32 0, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !11
  %40 = sext i32 %39 to i64
  %41 = mul nsw i64 %40, 1
  %42 = mul nsw i64 %41, 277
  %43 = srem i64 %42, 987654319
  %44 = trunc i64 %43 to i32
  %45 = load i32, ptr %9, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [100007 x %"struct.std::pair"], ptr @pw, i64 0, i64 %46
  %48 = getelementptr inbounds %"struct.std::pair", ptr %47, i32 0, i32 1
  store i32 %44, ptr %48, align 4, !tbaa !11
  %49 = load i32, ptr %9, align 4, !tbaa !5
  %50 = sub nsw i32 %49, 1
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100007 x %"struct.std::pair"], ptr @ipw, i64 0, i64 %51
  %53 = getelementptr inbounds %"struct.std::pair", ptr %52, i32 0, i32 0
  %54 = load i32, ptr %53, align 8, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = mul nsw i64 %55, 1
  %57 = load i32, ptr %7, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = mul nsw i64 %56, %58
  %60 = srem i64 %59, 1000000007
  %61 = trunc i64 %60 to i32
  %62 = load i32, ptr %9, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [100007 x %"struct.std::pair"], ptr @ipw, i64 0, i64 %63
  %65 = getelementptr inbounds %"struct.std::pair", ptr %64, i32 0, i32 0
  store i32 %61, ptr %65, align 8, !tbaa !9
  %66 = load i32, ptr %9, align 4, !tbaa !5
  %67 = sub nsw i32 %66, 1
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [100007 x %"struct.std::pair"], ptr @ipw, i64 0, i64 %68
  %70 = getelementptr inbounds %"struct.std::pair", ptr %69, i32 0, i32 1
  %71 = load i32, ptr %70, align 4, !tbaa !11
  %72 = sext i32 %71 to i64
  %73 = mul nsw i64 %72, 1
  %74 = load i32, ptr %8, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = mul nsw i64 %73, %75
  %77 = srem i64 %76, 987654319
  %78 = trunc i64 %77 to i32
  %79 = load i32, ptr %9, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [100007 x %"struct.std::pair"], ptr @ipw, i64 0, i64 %80
  %82 = getelementptr inbounds %"struct.std::pair", ptr %81, i32 0, i32 1
  store i32 %78, ptr %82, align 4, !tbaa !11
  br label %83

83:                                               ; preds = %18
  %84 = load i32, ptr %9, align 4, !tbaa !5
  %85 = add nsw i32 %84, 1
  store i32 %85, ptr %9, align 4, !tbaa !5
  br label %14, !llvm.loop !12

86:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret void
}

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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !6, i64 0}
!10 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!11 = !{!10, !6, i64 4}
!12 = distinct !{!12, !13}
!13 = !{!"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.std::pair" = type { i32, i32 }

@pw = external dso_local global [100007 x %"struct.std::pair"], align 16
@ipw = external dso_local global [100007 x %"struct.std::pair"], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z6modpowiii(i32 noundef, i32 noundef, 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: mustprogress nounwind uwtable
define dso_local void @_Z3prev() local_unnamed_addr #0 {
  %1 = alloca %"struct.std::pair", align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %"struct.std::pair", align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #2
  store i32 1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #2
  store i32 1, ptr %3, align 4, !tbaa !5
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS3_S4_EEEbE4typeELb1EEEOS3_OS4_(ptr noundef nonnull align 4 dereferenceable(8) %1, ptr noundef nonnull align 4 dereferenceable(4) %2, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %7 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) @pw, ptr noundef nonnull align 4 dereferenceable(8) %1) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #2
  store i32 1, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #2
  store i32 1, ptr %6, align 4, !tbaa !5
  call void @_ZNSt4pairIiiEC2IiiTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS3_S4_EEEbE4typeELb1EEEOS3_OS4_(ptr noundef nonnull align 4 dereferenceable(8) %4, ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %8 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt4pairIiiEaSEOS0_(ptr noundef nonnull align 4 dereferenceable(8) @ipw, ptr noundef nonnull align 4 dereferenceable(8) %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #2
  %9 = call noundef i32 @_Z6modpowiii(i32 noundef 137, i32 noundef 1000000005, i32 noundef 1000000007)
  %10 = call noundef i32 @_Z6modpowiii(i32 noundef 277, i32 noundef 987654317, i32 noundef 987654319)
  %11 = sext i32 %9 to i64
  %12 = sext i32 %10 to i64
  %.pre = load i32, ptr @pw, align 16, !tbaa !9
  %.pre14 = load i32, ptr getelementptr inbounds (i8, ptr @pw, i64 4), align 4, !tbaa !11
  %.pre15 = load i32, ptr @ipw, align 16, !tbaa !9
  %.pre16 = load i32, ptr getelementptr inbounds (i8, ptr @ipw, i64 4), align 4, !tbaa !11
  br label %14

13:                                               ; preds = %14
  ret void

14:                                               ; preds = %0, %14
  %15 = phi i32 [ %.pre16, %0 ], [ %37, %14 ]
  %16 = phi i32 [ %.pre15, %0 ], [ %32, %14 ]
  %17 = phi i32 [ %.pre14, %0 ], [ %27, %14 ]
  %18 = phi i32 [ %.pre, %0 ], [ %22, %14 ]
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next, %14 ]
  %19 = sext i32 %18 to i64
  %20 = mul nsw i64 %19, 137
  %21 = srem i64 %20, 1000000007
  %22 = trunc nsw i64 %21 to i32
  %23 = getelementptr inbounds [100007 x %"struct.std::pair"], ptr @pw, i64 0, i64 %indvars.iv
  store i32 %22, ptr %23, align 8, !tbaa !9
  %24 = sext i32 %17 to i64
  %25 = mul nsw i64 %24, 277
  %26 = srem i64 %25, 987654319
  %27 = trunc nsw i64 %26 to i32
  %28 = getelementptr inbounds i8, ptr %23, i64 4
  store i32 %27, ptr %28, align 4, !tbaa !11
  %29 = sext i32 %16 to i64
  %30 = mul nsw i64 %29, %11
  %31 = srem i64 %30, 1000000007
  %32 = trunc nsw i64 %31 to i32
  %33 = getelementptr inbounds [100007 x %"struct.std::pair"], ptr @ipw, i64 0, i64 %indvars.iv
  store i32 %32, ptr %33, align 8, !tbaa !9
  %34 = sext i32 %15 to i64
  %35 = mul nsw i64 %34, %12
  %36 = srem i64 %35, 987654319
  %37 = trunc nsw i64 %36 to i32
  %38 = getelementptr inbounds i8, ptr %33, i64 4
  store i32 %37, ptr %38, align 4, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 100007
  br i1 %exitcond.not, label %13, label %14, !llvm.loop !12
}

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

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

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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, !6, i64 0}
!10 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!11 = !{!10, !6, i64 4}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass