; LLVM IR from TheAlgorithms/C-Plus-Plus :: strings (rabin_karp)

; 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"

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN13string_search14check_if_equalERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_iiii(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN13string_search10rabin_karpERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %11) #2
  %13 = trunc i64 %12 to i32
  %14 = call noundef i64 @_ZN13string_search11create_hashERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi(ptr noundef nonnull align 8 dereferenceable(32) %10, i32 noundef %13)
  store i64 %14, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %16) #2
  %18 = trunc i64 %17 to i32
  %19 = call noundef i64 @_ZN13string_search11create_hashERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi(ptr noundef nonnull align 8 dereferenceable(32) %15, i32 noundef %18)
  store i64 %19, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %20

20:                                               ; preds = %76, %2
  %21 = load i32, ptr %8, align 4, !tbaa !11
  %22 = sext i32 %21 to i64
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %23) #2
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %25) #2
  %27 = sub i64 %24, %26
  %28 = icmp ule i64 %22, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %20
  store i32 2, ptr %9, align 4
  br label %79

30:                                               ; preds = %20
  %31 = load i64, ptr %6, align 8, !tbaa !9
  %32 = load i64, ptr %7, align 8, !tbaa !9
  %33 = icmp eq i64 %31, %32
  br i1 %33, label %34, label %52

34:                                               ; preds = %30
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = load i32, ptr %8, align 4, !tbaa !11
  %38 = load i32, ptr %8, align 4, !tbaa !11
  %39 = sext i32 %38 to i64
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %40) #2
  %42 = add i64 %39, %41
  %43 = sub i64 %42, 1
  %44 = trunc i64 %43 to i32
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %45) #2
  %47 = sub i64 %46, 1
  %48 = trunc i64 %47 to i32
  %49 = call noundef zeroext i1 @_ZN13string_search14check_if_equalERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_iiii(ptr noundef nonnull align 8 dereferenceable(32) %35, ptr noundef nonnull align 8 dereferenceable(32) %36, i32 noundef %37, i32 noundef %44, i32 noundef 0, i32 noundef %48)
  br i1 %49, label %50, label %52

50:                                               ; preds = %34
  %51 = load i32, ptr %8, align 4, !tbaa !11
  store i32 %51, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %79

52:                                               ; preds = %34, %30
  %53 = load i32, ptr %8, align 4, !tbaa !11
  %54 = sext i32 %53 to i64
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %55) #2
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %57) #2
  %59 = sub i64 %56, %58
  %60 = icmp ult i64 %54, %59
  br i1 %60, label %61, label %75

61:                                               ; preds = %52
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = load i32, ptr %8, align 4, !tbaa !11
  %64 = load i32, ptr %8, align 4, !tbaa !11
  %65 = sext i32 %64 to i64
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %66) #2
  %68 = add i64 %65, %67
  %69 = trunc i64 %68 to i32
  %70 = load i64, ptr %7, align 8, !tbaa !9
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %71) #2
  %73 = trunc i64 %72 to i32
  %74 = call noundef i64 @_ZN13string_search16recalculate_hashERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiili(ptr noundef nonnull align 8 dereferenceable(32) %62, i32 noundef %63, i32 noundef %69, i64 noundef %70, i32 noundef %73)
  store i64 %74, ptr %7, align 8, !tbaa !9
  br label %75

75:                                               ; preds = %61, %52
  br label %76

76:                                               ; preds = %75
  %77 = load i32, ptr %8, align 4, !tbaa !11
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %8, align 4, !tbaa !11
  br label %20, !llvm.loop !13

79:                                               ; preds = %50, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  %80 = load i32, ptr %9, align 4
  switch i32 %80, label %82 [
    i32 2, label %81
  ]

81:                                               ; preds = %79
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %82

82:                                               ; preds = %81, %79
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %83 = load i32, ptr %3, align 4
  ret i32 %83
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) #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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN13string_search11create_hashERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN13string_search16recalculate_hashERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiili(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i32 noundef, i64 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN13string_search14check_if_equalERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_iiii(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN13string_search10rabin_karpERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) local_unnamed_addr #0 {
  %3 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #1
  %4 = trunc i64 %3 to i32
  %5 = tail call noundef i64 @_ZN13string_search11create_hashERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %4)
  %6 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #1
  %7 = trunc i64 %6 to i32
  %8 = tail call noundef i64 @_ZN13string_search11create_hashERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %7)
  %9 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #1
  %10 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #1
  br label %11

11:                                               ; preds = %2, %37
  %indvars.iv = phi i64 [ 0, %2 ], [ %indvars.iv.next, %37 ]
  %.02832 = phi i64 [ %8, %2 ], [ %.1, %37 ]
  %12 = icmp eq i64 %5, %.02832
  br i1 %12, label %13, label %24

13:                                               ; preds = %11
  %14 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #1
  %15 = trunc i64 %14 to i32
  %16 = trunc i64 %indvars.iv to i32
  %17 = add i32 %16, -1
  %18 = add i32 %17, %15
  %19 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #1
  %20 = trunc i64 %19 to i32
  %21 = add i32 %20, -1
  %22 = trunc nuw nsw i64 %indvars.iv to i32
  %23 = tail call noundef zeroext i1 @_ZN13string_search14check_if_equalERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES7_iiii(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %22, i32 noundef %18, i32 noundef 0, i32 noundef %21)
  br i1 %23, label %41, label %24

24:                                               ; preds = %13, %11
  %25 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #1
  %26 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #1
  %27 = sub i64 %25, %26
  %28 = icmp ugt i64 %27, %indvars.iv
  br i1 %28, label %29, label %37

29:                                               ; preds = %24
  %30 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #1
  %31 = trunc i64 %30 to i32
  %32 = trunc nuw nsw i64 %indvars.iv to i32
  %33 = add i32 %32, %31
  %34 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #1
  %35 = trunc i64 %34 to i32
  %36 = tail call noundef i64 @_ZN13string_search16recalculate_hashERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEiili(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %32, i32 noundef %33, i64 noundef %.02832, i32 noundef %35)
  br label %37

37:                                               ; preds = %24, %29
  %.1 = phi i64 [ %36, %29 ], [ %.02832, %24 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %38 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #1
  %39 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %1) #1
  %40 = sub i64 %38, %39
  %.not.not = icmp ugt i64 %40, %indvars.iv
  br i1 %.not.not, label %11, label %41, !llvm.loop !5

41:                                               ; preds = %13, %37
  %spec.select = phi i32 [ %22, %13 ], [ -1, %37 ]
  ret i32 %spec.select
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) 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 = { 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,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass