; LLVM IR from ShahjalalShohag/code-library :: Strings/String Hashing With Updates and Reverse.ll (Z4precv)

; 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::array" = type { [2 x i32] }

@_ZL3MOD = external hidden constant %"struct.std::array", align 4
@pw = external dso_local global [100009 x %"struct.std::array"], align 16
@ipw = external dso_local global [100009 x %"struct.std::array"], align 16
@_ZL1p = external hidden constant %"struct.std::array", align 4

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i64 @_ZmlSt5arrayIiLm2EES0_(i64, i64) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z4precv() #0 {
  %1 = alloca %"struct.std::array", align 4
  %2 = alloca i32, align 4
  %3 = alloca %"struct.std::array", align 4
  %4 = alloca %"struct.std::array", align 4
  %5 = alloca %"struct.std::array", align 4
  %6 = alloca %"struct.std::array", align 4
  %7 = alloca %"struct.std::array", align 4
  %8 = alloca i32, align 4
  %9 = alloca %"struct.std::array", align 4
  %10 = alloca %"struct.std::array", align 4
  %11 = alloca %"struct.std::array", align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #3
  %12 = getelementptr inbounds %"struct.std::array", ptr %1, i32 0, i32 0
  store i32 1, ptr %12, align 4, !tbaa !5
  %13 = getelementptr inbounds i32, ptr %12, i64 1
  store i32 1, ptr %13, align 4, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @pw, ptr align 4 %1, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.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
  br label %14

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

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

18:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = sub nsw i32 %19, 1
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [100009 x %"struct.std::array"], ptr @pw, i64 0, i64 %21
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 8 %22, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 @_ZL1p, i64 8, i1 false), !tbaa.struct !9
  %23 = getelementptr inbounds %"struct.std::array", ptr %4, i32 0, i32 0
  %24 = load i64, ptr %23, align 4
  %25 = getelementptr inbounds %"struct.std::array", ptr %5, i32 0, i32 0
  %26 = load i64, ptr %25, align 4
  %27 = call i64 @_ZmlSt5arrayIiLm2EES0_(i64 %24, i64 %26)
  %28 = getelementptr inbounds %"struct.std::array", ptr %3, i32 0, i32 0
  store i64 %27, ptr %28, align 4
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [100009 x %"struct.std::array"], ptr @pw, i64 0, i64 %30
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %31, ptr align 4 %3, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  br label %32

32:                                               ; preds = %18
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !11

35:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %36 = getelementptr inbounds %"struct.std::array", ptr %6, i32 0, i32 0
  store i32 1, ptr %36, align 4, !tbaa !5
  %37 = getelementptr inbounds i32, ptr %36, i64 1
  store i32 1, ptr %37, align 4, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @ipw, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %38 = getelementptr inbounds %"struct.std::array", ptr %7, i32 0, i32 0
  %39 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) @_ZL1p, i64 noundef 0) #3
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) @_ZL3MOD, i64 noundef 0) #3
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = sub nsw i32 %43, 2
  %45 = sext i32 %44 to i64
  %46 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) @_ZL3MOD, i64 noundef 0) #3
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = call noundef i32 @_Z5powerxxi(i64 noundef %41, i64 noundef %45, i32 noundef %47)
  store i32 %48, ptr %38, align 4, !tbaa !5
  %49 = getelementptr inbounds i32, ptr %38, i64 1
  %50 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) @_ZL1p, i64 noundef 1) #3
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) @_ZL3MOD, i64 noundef 1) #3
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = sub nsw i32 %54, 2
  %56 = sext i32 %55 to i64
  %57 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) @_ZL3MOD, i64 noundef 1) #3
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = call noundef i32 @_Z5powerxxi(i64 noundef %52, i64 noundef %56, i32 noundef %58)
  store i32 %59, ptr %49, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %78, %35
  %61 = load i32, ptr %8, align 4, !tbaa !5
  %62 = icmp slt i32 %61, 100009
  br i1 %62, label %64, label %63

63:                                               ; preds = %60
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %81

64:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %65 = load i32, ptr %8, align 4, !tbaa !5
  %66 = sub nsw i32 %65, 1
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [100009 x %"struct.std::array"], ptr @ipw, i64 0, i64 %67
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 8 %68, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %7, i64 8, i1 false), !tbaa.struct !9
  %69 = getelementptr inbounds %"struct.std::array", ptr %10, i32 0, i32 0
  %70 = load i64, ptr %69, align 4
  %71 = getelementptr inbounds %"struct.std::array", ptr %11, i32 0, i32 0
  %72 = load i64, ptr %71, align 4
  %73 = call i64 @_ZmlSt5arrayIiLm2EES0_(i64 %70, i64 %72)
  %74 = getelementptr inbounds %"struct.std::array", ptr %9, i32 0, i32 0
  store i64 %73, ptr %74, align 4
  %75 = load i32, ptr %8, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [100009 x %"struct.std::array"], ptr @ipw, i64 0, i64 %76
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %77, ptr align 4 %9, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %78

78:                                               ; preds = %64
  %79 = load i32, ptr %8, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %8, align 4, !tbaa !5
  br label %60, !llvm.loop !13

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

; 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) #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 = { nocallback nofree 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i64 0, i64 8, !10}
!10 = !{!7, !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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::array" = type { [2 x i32] }

@_ZL3MOD = external hidden constant %"struct.std::array", align 4
@pw = external dso_local local_unnamed_addr global [100009 x %"struct.std::array"], align 16
@ipw = external dso_local local_unnamed_addr global [100009 x %"struct.std::array"], align 16
@_ZL1p = external hidden constant %"struct.std::array", align 4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z5powerxxi(i64 noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i64 @_ZmlSt5arrayIiLm2EES0_(i64, i64) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z4precv() local_unnamed_addr #0 {
  store i32 1, ptr @pw, align 16
  store i32 1, ptr getelementptr inbounds (i8, ptr @pw, i64 4), align 4, !tbaa !5
  %.sroa.09.0.copyload = load i64, ptr @_ZL1p, align 4, !tbaa !5
  %.sroa.010.0.copyload.pre = load i64, ptr @pw, align 16, !tbaa !5
  br label %22

1:                                                ; preds = %22
  store i32 1, ptr @ipw, align 16
  store i32 1, ptr getelementptr inbounds (i8, ptr @ipw, i64 4), align 4, !tbaa !5
  %2 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) @_ZL1p, i64 noundef 0) #1
  %3 = load i32, ptr %2, align 4, !tbaa !8
  %4 = sext i32 %3 to i64
  %5 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) @_ZL3MOD, i64 noundef 0) #1
  %6 = load i32, ptr %5, align 4, !tbaa !8
  %7 = add nsw i32 %6, -2
  %8 = sext i32 %7 to i64
  %9 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) @_ZL3MOD, i64 noundef 0) #1
  %10 = load i32, ptr %9, align 4, !tbaa !8
  %11 = tail call noundef i32 @_Z5powerxxi(i64 noundef %4, i64 noundef %8, i32 noundef %10)
  %12 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) @_ZL1p, i64 noundef 1) #1
  %13 = load i32, ptr %12, align 4, !tbaa !8
  %14 = sext i32 %13 to i64
  %15 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) @_ZL3MOD, i64 noundef 1) #1
  %16 = load i32, ptr %15, align 4, !tbaa !8
  %17 = add nsw i32 %16, -2
  %18 = sext i32 %17 to i64
  %19 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt5arrayIiLm2EEixEm(ptr noundef nonnull align 4 dereferenceable(8) @_ZL3MOD, i64 noundef 1) #1
  %20 = load i32, ptr %19, align 4, !tbaa !8
  %21 = tail call noundef i32 @_Z5powerxxi(i64 noundef %14, i64 noundef %18, i32 noundef %20)
  %.sroa.4.0.insert.ext = zext i32 %21 to i64
  %.sroa.4.0.insert.shift = shl nuw i64 %.sroa.4.0.insert.ext, 32
  %.sroa.06.0.insert.ext = zext i32 %11 to i64
  %.sroa.06.0.insert.insert = or disjoint i64 %.sroa.4.0.insert.shift, %.sroa.06.0.insert.ext
  %.sroa.01.0.copyload.pre = load i64, ptr @ipw, align 16, !tbaa !5
  br label %26

22:                                               ; preds = %0, %22
  %.sroa.010.0.copyload = phi i64 [ %.sroa.010.0.copyload.pre, %0 ], [ %23, %22 ]
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next, %22 ]
  %23 = tail call i64 @_ZmlSt5arrayIiLm2EES0_(i64 %.sroa.010.0.copyload, i64 %.sroa.09.0.copyload)
  %24 = getelementptr inbounds [100009 x %"struct.std::array"], ptr @pw, i64 0, i64 %indvars.iv
  store i64 %23, ptr %24, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 100009
  br i1 %exitcond.not, label %1, label %22, !llvm.loop !10

25:                                               ; preds = %26
  ret void

26:                                               ; preds = %1, %26
  %.sroa.01.0.copyload = phi i64 [ %.sroa.01.0.copyload.pre, %1 ], [ %27, %26 ]
  %indvars.iv22 = phi i64 [ 1, %1 ], [ %indvars.iv.next23, %26 ]
  %27 = tail call i64 @_ZmlSt5arrayIiLm2EES0_(i64 %.sroa.01.0.copyload, i64 %.sroa.06.0.insert.insert)
  %28 = getelementptr inbounds [100009 x %"struct.std::array"], ptr @ipw, i64 0, i64 %indvars.iv22
  store i64 %27, ptr %28, align 8, !tbaa !5
  %indvars.iv.next23 = add nuw nsw i64 %indvars.iv22, 1
  %exitcond25.not = icmp eq i64 %indvars.iv.next23, 100009
  br i1 %exitcond25.not, label %25, label %26, !llvm.loop !12
}

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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


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