; LLVM IR from kala13x/libxutils :: src/data (str)

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

@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1

; 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: nounwind uwtable
declare dso_local zeroext i8 @xstrncmp(ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @xstrcmp(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @xstrused(ptr noundef) #1

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

declare i64 @XArray_Used(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @xstrregex(ptr noundef %0, i64 noundef %1, ptr noundef %2) #1 {
  %4 = alloca i8, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %21

18:                                               ; preds = %3
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %22, label %21

21:                                               ; preds = %18, %3
  store i8 0, ptr %4, align 1
  br label %115

22:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = call ptr @xstrsplitd(ptr noundef %23, ptr noundef @.str.3)
  store ptr %24, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = call i64 @XArray_Used(ptr noundef %25)
  store i64 %26, ptr %9, align 8, !tbaa !9
  %27 = load i64, ptr %9, align 8, !tbaa !9
  %28 = icmp ne i64 %27, 0
  br i1 %28, label %33, label %29

29:                                               ; preds = %22
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = call zeroext i8 @xstrcmp(ptr noundef %30, ptr noundef %31)
  store i8 %32, ptr %4, align 1
  store i32 1, ptr %10, align 4
  br label %114

33:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store i64 0, ptr %12, align 8, !tbaa !9
  store i64 0, ptr %11, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %109, %33
  %35 = load i64, ptr %11, align 8, !tbaa !9
  %36 = load i64, ptr %9, align 8, !tbaa !9
  %37 = icmp ult i64 %35, %36
  br i1 %37, label %38, label %112

38:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = load i64, ptr %11, align 8, !tbaa !9
  %41 = call ptr @XArray_GetData(ptr noundef %39, i64 noundef %40)
  store ptr %41, ptr %13, align 8, !tbaa !5
  %42 = load ptr, ptr %13, align 8, !tbaa !5
  %43 = call zeroext i8 @xstrused(ptr noundef %42)
  %44 = zext i8 %43 to i32
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %105

46:                                               ; preds = %38
  %47 = load ptr, ptr %13, align 8, !tbaa !5
  %48 = call zeroext i8 @xstrcmp(ptr noundef %47, ptr noundef @.str.3)
  %49 = icmp ne i8 %48, 0
  br i1 %49, label %105, label %50

50:                                               ; preds = %46
  %51 = load i64, ptr %11, align 8, !tbaa !9
  %52 = icmp ne i64 %51, 0
  br i1 %52, label %61, label %53

53:                                               ; preds = %50
  %54 = load ptr, ptr %13, align 8, !tbaa !5
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = load ptr, ptr %13, align 8, !tbaa !5
  %57 = call i64 @strlen(ptr noundef %56) #5
  %58 = call zeroext i8 @xstrncmp(ptr noundef %54, ptr noundef %55, i64 noundef %57)
  %59 = icmp ne i8 %58, 0
  br i1 %59, label %61, label %60

60:                                               ; preds = %53
  store i8 0, ptr %4, align 1
  store i32 1, ptr %10, align 4
  br label %106

61:                                               ; preds = %53, %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = load i64, ptr %6, align 8, !tbaa !9
  %64 = load ptr, ptr %13, align 8, !tbaa !5
  %65 = load i64, ptr %12, align 8, !tbaa !9
  %66 = call i32 @xstrnsrc(ptr noundef %62, i64 noundef %63, ptr noundef %64, i64 noundef %65)
  store i32 %66, ptr %14, align 4, !tbaa !11
  %67 = load i32, ptr %14, align 4, !tbaa !11
  %68 = icmp slt i32 %67, 0
  br i1 %68, label %69, label %70

69:                                               ; preds = %61
  store i8 0, ptr %4, align 1
  store i32 1, ptr %10, align 4
  br label %102

70:                                               ; preds = %61
  %71 = load i32, ptr %14, align 4, !tbaa !11
  %72 = sext i32 %71 to i64
  %73 = load i64, ptr %12, align 8, !tbaa !9
  %74 = add i64 %73, %72
  store i64 %74, ptr %12, align 8, !tbaa !9
  %75 = load i64, ptr %12, align 8, !tbaa !9
  %76 = load i64, ptr %6, align 8, !tbaa !9
  %77 = icmp uge i64 %75, %76
  br i1 %77, label %78, label %79

78:                                               ; preds = %70
  store i8 0, ptr %4, align 1
  store i32 1, ptr %10, align 4
  br label %102

79:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %80 = load ptr, ptr %5, align 8, !tbaa !5
  %81 = load i64, ptr %12, align 8, !tbaa !9
  %82 = getelementptr inbounds i8, ptr %80, i64 %81
  store ptr %82, ptr %15, align 8, !tbaa !5
  %83 = load i64, ptr %11, align 8, !tbaa !9
  %84 = icmp ne i64 %83, 0
  br i1 %84, label %85, label %96

85:                                               ; preds = %79
  %86 = load i64, ptr %11, align 8, !tbaa !9
  %87 = add i64 %86, 1
  %88 = load i64, ptr %9, align 8, !tbaa !9
  %89 = icmp eq i64 %87, %88
  br i1 %89, label %90, label %96

90:                                               ; preds = %85
  %91 = load ptr, ptr %13, align 8, !tbaa !5
  %92 = load ptr, ptr %15, align 8, !tbaa !5
  %93 = call zeroext i8 @xstrcmp(ptr noundef %91, ptr noundef %92)
  %94 = icmp ne i8 %93, 0
  br i1 %94, label %96, label %95

95:                                               ; preds = %90
  store i8 0, ptr %4, align 1
  store i32 1, ptr %10, align 4
  br label %101

96:                                               ; preds = %90, %85, %79
  %97 = load ptr, ptr %13, align 8, !tbaa !5
  %98 = call i64 @strlen(ptr noundef %97) #5
  %99 = load i64, ptr %12, align 8, !tbaa !9
  %100 = add i64 %99, %98
  store i64 %100, ptr %12, align 8, !tbaa !9
  store i32 0, ptr %10, align 4
  br label %101

101:                                              ; preds = %96, %95
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  br label %102

102:                                              ; preds = %101, %78, %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  %103 = load i32, ptr %10, align 4
  switch i32 %103, label %106 [
    i32 0, label %104
  ]

104:                                              ; preds = %102
  br label %105

105:                                              ; preds = %104, %46, %38
  store i32 0, ptr %10, align 4
  br label %106

106:                                              ; preds = %105, %102, %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  %107 = load i32, ptr %10, align 4
  switch i32 %107, label %113 [
    i32 0, label %108
  ]

108:                                              ; preds = %106
  br label %109

109:                                              ; preds = %108
  %110 = load i64, ptr %11, align 8, !tbaa !9
  %111 = add i64 %110, 1
  store i64 %111, ptr %11, align 8, !tbaa !9
  br label %34, !llvm.loop !13

112:                                              ; preds = %34
  store i8 1, ptr %4, align 1
  store i32 1, ptr %10, align 4
  br label %113

113:                                              ; preds = %112, %106
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %114

114:                                              ; preds = %113, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %115

115:                                              ; preds = %114, %21
  %116 = load i8, ptr %4, align 1
  ret i8 %116
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @xstrsplitd(ptr noundef, ptr noundef) #1

declare ptr @XArray_GetData(ptr noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @xstrnsrc(ptr noundef, i64 noundef, ptr noundef, i64 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 willreturn memory(read) "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 = { "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 }
attributes #5 = { nounwind willreturn memory(read) }

!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/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"

@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @xstrncmp(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @xstrcmp(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @xstrused(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #1

declare i64 @XArray_Used(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @xstrregex(ptr noundef %0, i64 noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = icmp ne ptr %0, null
  %5 = icmp ne ptr %2, null
  %or.cond = and i1 %4, %5
  br i1 %or.cond, label %6, label %.thread66

6:                                                ; preds = %3
  %7 = tail call ptr @xstrsplitd(ptr noundef nonnull %2, ptr noundef nonnull @.str.3)
  %8 = tail call i64 @XArray_Used(ptr noundef %7) #3
  %.not = icmp eq i64 %8, 0
  br i1 %.not, label %24, label %.preheader.preheader

.preheader.preheader:                             ; preds = %6
  %9 = tail call ptr @XArray_GetData(ptr noundef %7, i64 noundef 0) #3
  %10 = tail call zeroext i8 @xstrused(ptr noundef %9)
  %.not55.peel = icmp eq i8 %10, 0
  br i1 %.not55.peel, label %.thread.peel, label %11

11:                                               ; preds = %.preheader.preheader
  %12 = tail call zeroext i8 @xstrcmp(ptr noundef %9, ptr noundef nonnull @.str.3)
  %.not56.peel = icmp eq i8 %12, 0
  br i1 %.not56.peel, label %13, label %.thread.peel

13:                                               ; preds = %11
  %14 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %9) #4
  %15 = tail call zeroext i8 @xstrncmp(ptr noundef %9, ptr noundef nonnull %0, i64 noundef %14)
  %.not58.peel = icmp eq i8 %15, 0
  br i1 %.not58.peel, label %.thread66, label %16

16:                                               ; preds = %13
  %17 = tail call i32 @xstrnsrc(ptr noundef nonnull %0, i64 noundef %1, ptr noundef %9, i64 noundef 0)
  %18 = icmp slt i32 %17, 0
  br i1 %18, label %.thread66, label %19

19:                                               ; preds = %16
  %20 = zext nneg i32 %17 to i64
  %.not59.peel = icmp ult i64 %20, %1
  br i1 %.not59.peel, label %21, label %.thread66

21:                                               ; preds = %19
  %22 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %9) #4
  %23 = add i64 %22, %20
  br label %.thread.peel

.thread.peel:                                     ; preds = %21, %11, %.preheader.preheader
  %.44865.peel = phi i64 [ %23, %21 ], [ 0, %11 ], [ 0, %.preheader.preheader ]
  %exitcond.peel.not = icmp eq i64 %8, 1
  br i1 %exitcond.peel.not, label %.thread66, label %.preheader

24:                                               ; preds = %6
  %25 = tail call zeroext i8 @xstrcmp(ptr noundef nonnull %0, ptr noundef nonnull %2)
  br label %.thread66

.preheader:                                       ; preds = %.thread.peel, %.thread
  %.04375 = phi i64 [ %45, %.thread ], [ 1, %.thread.peel ]
  %.04474 = phi i64 [ %.44865, %.thread ], [ %.44865.peel, %.thread.peel ]
  %26 = tail call ptr @XArray_GetData(ptr noundef %7, i64 noundef %.04375) #3
  %27 = tail call zeroext i8 @xstrused(ptr noundef %26)
  %.not55 = icmp eq i8 %27, 0
  br i1 %.not55, label %.thread, label %28

28:                                               ; preds = %.preheader
  %29 = tail call zeroext i8 @xstrcmp(ptr noundef %26, ptr noundef nonnull @.str.3)
  %.not56 = icmp eq i8 %29, 0
  br i1 %.not56, label %30, label %.thread

30:                                               ; preds = %28
  %31 = tail call i32 @xstrnsrc(ptr noundef nonnull %0, i64 noundef %1, ptr noundef %26, i64 noundef %.04474)
  %32 = icmp slt i32 %31, 0
  br i1 %32, label %.thread66, label %33

33:                                               ; preds = %30
  %34 = zext nneg i32 %31 to i64
  %35 = add i64 %.04474, %34
  %.not59 = icmp ult i64 %35, %1
  br i1 %.not59, label %36, label %.thread66

36:                                               ; preds = %33
  %37 = add nuw i64 %.04375, 1
  %38 = icmp eq i64 %37, %8
  br i1 %38, label %39, label %42

39:                                               ; preds = %36
  %40 = getelementptr inbounds i8, ptr %0, i64 %35
  %41 = tail call zeroext i8 @xstrcmp(ptr noundef %26, ptr noundef nonnull %40)
  %.not60 = icmp eq i8 %41, 0
  br i1 %.not60, label %.thread66, label %42

42:                                               ; preds = %36, %39
  %43 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %26) #4
  %44 = add i64 %43, %35
  br label %.thread

.thread:                                          ; preds = %.preheader, %28, %42
  %.44865 = phi i64 [ %44, %42 ], [ %.04474, %28 ], [ %.04474, %.preheader ]
  %45 = add nuw i64 %.04375, 1
  %exitcond.not = icmp eq i64 %45, %8
  br i1 %exitcond.not, label %.thread66, label %.preheader, !llvm.loop !5

.thread66:                                        ; preds = %39, %33, %30, %.thread, %13, %16, %19, %.thread.peel, %24, %3
  %.7 = phi i8 [ 0, %3 ], [ %25, %24 ], [ 0, %13 ], [ 0, %16 ], [ 0, %19 ], [ 1, %.thread.peel ], [ 0, %39 ], [ 0, %33 ], [ 0, %30 ], [ 1, %.thread ]
  ret i8 %.7
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @xstrsplitd(ptr noundef, ptr noundef) local_unnamed_addr #0

declare ptr @XArray_GetData(ptr noundef, i64 noundef) local_unnamed_addr #2

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

attributes #0 = { 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 nofree nounwind willreturn memory(argmem: read) "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 = { "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 }
attributes #4 = { nounwind willreturn memory(read) }

!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, !7}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass