; LLVM IR from openvinotoolkit/model_server :: src (stringutils)

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN4ovms11isValidUtf8ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(32) %0) #1 {
  %2 = alloca i1, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  store i64 0, ptr %4, align 8, !tbaa !9
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %8) #2
  %10 = icmp eq i64 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %1
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %80

12:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %13) #2
  store i64 %14, ptr %6, align 8, !tbaa !9
  br label %15

15:                                               ; preds = %76, %12
  %16 = load i64, ptr %6, align 8, !tbaa !9
  %17 = add i64 %16, -1
  store i64 %17, ptr %6, align 8, !tbaa !9
  %18 = icmp ugt i64 %16, 0
  br i1 %18, label %19, label %22

19:                                               ; preds = %15
  %20 = load i64, ptr %4, align 8, !tbaa !9
  %21 = icmp ule i64 %20, 3
  br label %22

22:                                               ; preds = %19, %15
  %23 = phi i1 [ false, %15 ], [ %21, %19 ]
  br i1 %23, label %25, label %24

24:                                               ; preds = %22
  store i32 2, ptr %5, align 4
  br label %77

25:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = load i64, ptr %6, align 8, !tbaa !9
  %28 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %26, i64 noundef %27) #2
  %29 = load i8, ptr %28, align 1, !tbaa !11
  %30 = zext i8 %29 to i32
  store i32 %30, ptr %7, align 4, !tbaa !12
  %31 = load i32, ptr %7, align 4, !tbaa !12
  %32 = ashr i32 %31, 7
  %33 = icmp eq i32 %32, 0
  br i1 %33, label %34, label %38

34:                                               ; preds = %25
  %35 = load i64, ptr %4, align 8, !tbaa !9
  %36 = icmp eq i64 %35, 0
  br i1 %36, label %37, label %38

37:                                               ; preds = %34
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %74

38:                                               ; preds = %34, %25
  %39 = load i32, ptr %7, align 4, !tbaa !12
  %40 = ashr i32 %39, 6
  %41 = icmp eq i32 %40, 2
  br i1 %41, label %42, label %45

42:                                               ; preds = %38
  %43 = load i64, ptr %4, align 8, !tbaa !9
  %44 = add i64 %43, 1
  store i64 %44, ptr %4, align 8, !tbaa !9
  br label %73

45:                                               ; preds = %38
  %46 = load i32, ptr %7, align 4, !tbaa !12
  %47 = ashr i32 %46, 5
  %48 = icmp eq i32 %47, 6
  br i1 %48, label %49, label %54

49:                                               ; preds = %45
  %50 = load i64, ptr %4, align 8, !tbaa !9
  %51 = add i64 %50, 1
  %52 = icmp eq i64 %51, 2
  br i1 %52, label %53, label %54

53:                                               ; preds = %49
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %74

54:                                               ; preds = %49, %45
  %55 = load i32, ptr %7, align 4, !tbaa !12
  %56 = ashr i32 %55, 4
  %57 = icmp eq i32 %56, 14
  br i1 %57, label %58, label %63

58:                                               ; preds = %54
  %59 = load i64, ptr %4, align 8, !tbaa !9
  %60 = add i64 %59, 1
  %61 = icmp eq i64 %60, 3
  br i1 %61, label %62, label %63

62:                                               ; preds = %58
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %74

63:                                               ; preds = %58, %54
  %64 = load i32, ptr %7, align 4, !tbaa !12
  %65 = ashr i32 %64, 3
  %66 = icmp eq i32 %65, 30
  br i1 %66, label %67, label %72

67:                                               ; preds = %63
  %68 = load i64, ptr %4, align 8, !tbaa !9
  %69 = add i64 %68, 1
  %70 = icmp eq i64 %69, 4
  br i1 %70, label %71, label %72

71:                                               ; preds = %67
  store i1 true, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %74

72:                                               ; preds = %67, %63
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %74

73:                                               ; preds = %42
  store i32 0, ptr %5, align 4
  br label %74

74:                                               ; preds = %73, %72, %71, %62, %53, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  %75 = load i32, ptr %5, align 4
  switch i32 %75, label %77 [
    i32 0, label %76
  ]

76:                                               ; preds = %74
  br label %15, !llvm.loop !14

77:                                               ; preds = %74, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  %78 = load i32, ptr %5, align 4
  switch i32 %78, label %80 [
    i32 2, label %79
  ]

79:                                               ; preds = %77
  store i1 false, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %80

80:                                               ; preds = %79, %77, %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  %81 = load i1, ptr %2, align 1
  ret i1 %81
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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 noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN4ovms11isValidUtf8ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE(ptr noundef nonnull align 8 dereferenceable(32) %0) local_unnamed_addr #0 {
  %2 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  %3 = icmp eq i64 %2, 0
  br i1 %3, label %.thread, label %4

4:                                                ; preds = %1
  %5 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #2
  %.not = icmp eq i64 %5, 0
  br i1 %.not, label %.thread, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %4
  %6 = add i64 %5, -1
  %umin = tail call i64 @llvm.umin.i64(i64 %6, i64 3)
  %7 = add i64 %5, -1
  %8 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %7) #2
  %9 = load i8, ptr %8, align 1, !tbaa !5
  %10 = icmp sgt i8 %9, -1
  br i1 %10, label %.thread, label %11

11:                                               ; preds = %.lr.ph.preheader
  %12 = zext i8 %9 to i32
  %.mask.peel = and i32 %12, 192
  %13 = icmp eq i32 %.mask.peel, 128
  br i1 %13, label %14, label %.loopexit

14:                                               ; preds = %11
  %exitcond.not.peel = icmp eq i64 %6, 0
  br i1 %exitcond.not.peel, label %.thread, label %.lr.ph

.lr.ph:                                           ; preds = %14, %28
  %.in = phi i64 [ %15, %28 ], [ %7, %14 ]
  %.02339 = phi i64 [ %29, %28 ], [ 1, %14 ]
  %15 = add i64 %.in, -1
  %16 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) %0, i64 noundef %15) #2
  %17 = load i8, ptr %16, align 1, !tbaa !5
  %18 = zext i8 %17 to i32
  %.mask = and i32 %18, 192
  %19 = icmp eq i32 %.mask, 128
  br i1 %19, label %28, label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %11
  %.02339.lcssa46 = phi i64 [ 0, %11 ], [ %.02339, %.lr.ph ]
  %.lcssa = phi i32 [ %12, %11 ], [ %18, %.lr.ph ]
  %.mask25 = and i32 %.lcssa, 224
  %20 = icmp eq i32 %.mask25, 192
  %21 = icmp eq i64 %.02339.lcssa46, 1
  %or.cond30 = and i1 %20, %21
  br i1 %or.cond30, label %.thread, label %22

22:                                               ; preds = %.loopexit
  %.mask26 = and i32 %.lcssa, 240
  %23 = icmp eq i32 %.mask26, 224
  %24 = icmp eq i64 %.02339.lcssa46, 2
  %or.cond31 = and i1 %23, %24
  br i1 %or.cond31, label %.thread, label %25

25:                                               ; preds = %22
  %.mask27 = and i32 %.lcssa, 248
  %26 = icmp eq i32 %.mask27, 240
  %27 = icmp eq i64 %.02339.lcssa46, 3
  %or.cond32 = and i1 %26, %27
  br label %.thread

28:                                               ; preds = %.lr.ph
  %29 = add nuw nsw i64 %.02339, 1
  %exitcond.not = icmp eq i64 %.02339, %umin
  br i1 %exitcond.not, label %.thread, label %.lr.ph, !llvm.loop !8

.thread:                                          ; preds = %.lr.ph.preheader, %14, %28, %4, %.loopexit, %22, %25, %1
  %.3 = phi i1 [ false, %1 ], [ %or.cond32, %25 ], [ true, %22 ], [ true, %.loopexit ], [ false, %4 ], [ %10, %.lr.ph.preheader ], [ %10, %14 ], [ false, %28 ]
  ret i1 %.3
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #1

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 speculatable willreturn memory(none) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9, !10}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass