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

%struct.XArrayData = type { ptr, ptr, i64, i32 }

@.str.2 = 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 @xstrnmatch(ptr noundef, i64 noundef, ptr noundef, i64 noundef) #1

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

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

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

21:                                               ; preds = %4
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %25, label %24

24:                                               ; preds = %21, %4
  store i8 0, ptr %5, align 1
  br label %108

25:                                               ; preds = %21
  %26 = load i64, ptr %7, align 8, !tbaa !9
  %27 = icmp ne i64 %26, 0
  br i1 %27, label %36, label %28

28:                                               ; preds = %25
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = call zeroext i8 @xstrused(ptr noundef %29)
  %31 = icmp ne i8 %30, 0
  %32 = xor i1 %31, true
  %33 = zext i1 %32 to i64
  %34 = select i1 %32, i32 1, i32 0
  %35 = trunc i32 %34 to i8
  store i8 %35, ptr %5, align 1
  br label %108

36:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = icmp eq ptr %37, null
  br i1 %38, label %39, label %40

39:                                               ; preds = %36
  br label %42

40:                                               ; preds = %36
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  br label %42

42:                                               ; preds = %40, %39
  %43 = phi ptr [ @.str.2, %39 ], [ %41, %40 ]
  store ptr %43, ptr %10, align 8, !tbaa !5
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = call i32 @xstrsrc(ptr noundef %44, ptr noundef %45)
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %53, label %48

48:                                               ; preds = %42
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = load i64, ptr %7, align 8, !tbaa !9
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = call zeroext i8 @xstrmatch(ptr noundef %49, i64 noundef %50, ptr noundef %51)
  store i8 %52, ptr %5, align 1
  store i32 1, ptr %11, align 4
  br label %107

53:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  %55 = load ptr, ptr %10, align 8, !tbaa !5
  %56 = call ptr @xstrsplit(ptr noundef %54, ptr noundef %55)
  store ptr %56, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %57 = load ptr, ptr %12, align 8, !tbaa !5
  %58 = call i64 @XArray_Used(ptr noundef %57)
  store i64 %58, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #3
  store i8 0, ptr %15, align 1, !tbaa !11
  store i64 0, ptr %13, align 8, !tbaa !9
  br label %59

59:                                               ; preds = %101, %53
  %60 = load i64, ptr %13, align 8, !tbaa !9
  %61 = load i64, ptr %14, align 8, !tbaa !9
  %62 = icmp ult i64 %60, %61
  br i1 %62, label %63, label %104

63:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  %65 = load i64, ptr %13, align 8, !tbaa !9
  %66 = call ptr @XArray_Get(ptr noundef %64, i64 noundef %65)
  store ptr %66, ptr %16, align 8, !tbaa !5
  %67 = load ptr, ptr %16, align 8, !tbaa !5
  %68 = icmp eq ptr %67, null
  br i1 %68, label %79, label %69

69:                                               ; preds = %63
  %70 = load ptr, ptr %16, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.XArrayData, ptr %70, i32 0, i32 1
  %72 = load ptr, ptr %71, align 8, !tbaa !12
  %73 = icmp eq ptr %72, null
  br i1 %73, label %79, label %74

74:                                               ; preds = %69
  %75 = load ptr, ptr %16, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.XArrayData, ptr %75, i32 0, i32 2
  %77 = load i64, ptr %76, align 8, !tbaa !15
  %78 = icmp ne i64 %77, 0
  br i1 %78, label %80, label %79

79:                                               ; preds = %74, %69, %63
  store i32 4, ptr %11, align 4
  br label %98

80:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %81 = load ptr, ptr %16, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.XArrayData, ptr %81, i32 0, i32 1
  %83 = load ptr, ptr %82, align 8, !tbaa !12
  store ptr %83, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  %84 = load ptr, ptr %16, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.XArrayData, ptr %84, i32 0, i32 2
  %86 = load i64, ptr %85, align 8, !tbaa !15
  %87 = sub i64 %86, 1
  store i64 %87, ptr %18, align 8, !tbaa !9
  %88 = load ptr, ptr %6, align 8, !tbaa !5
  %89 = load i64, ptr %7, align 8, !tbaa !9
  %90 = load ptr, ptr %17, align 8, !tbaa !5
  %91 = load i64, ptr %18, align 8, !tbaa !9
  %92 = call zeroext i8 @xstrnmatch(ptr noundef %88, i64 noundef %89, ptr noundef %90, i64 noundef %91)
  store i8 %92, ptr %15, align 1, !tbaa !11
  %93 = load i8, ptr %15, align 1, !tbaa !11
  %94 = icmp ne i8 %93, 0
  br i1 %94, label %95, label %96

95:                                               ; preds = %80
  store i32 2, ptr %11, align 4
  br label %97

96:                                               ; preds = %80
  store i32 0, ptr %11, align 4
  br label %97

97:                                               ; preds = %96, %95
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  br label %98

98:                                               ; preds = %97, %79
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  %99 = load i32, ptr %11, align 4
  switch i32 %99, label %110 [
    i32 0, label %100
    i32 4, label %101
    i32 2, label %104
  ]

100:                                              ; preds = %98
  br label %101

101:                                              ; preds = %100, %98
  %102 = load i64, ptr %13, align 8, !tbaa !9
  %103 = add i64 %102, 1
  store i64 %103, ptr %13, align 8, !tbaa !9
  br label %59, !llvm.loop !16

104:                                              ; preds = %98, %59
  %105 = load ptr, ptr %12, align 8, !tbaa !5
  call void @XArray_Destroy(ptr noundef %105)
  %106 = load i8, ptr %15, align 1, !tbaa !11
  store i8 %106, ptr %5, align 1
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %107

107:                                              ; preds = %104, %48
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %108

108:                                              ; preds = %107, %28, %24
  %109 = load i8, ptr %5, align 1
  ret i8 %109

110:                                              ; preds = %98
  unreachable
}

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

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

declare i64 @XArray_Used(ptr noundef) #2

declare ptr @XArray_Get(ptr noundef, i64 noundef) #2

declare void @XArray_Destroy(ptr noundef) #2

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 = { "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 = !{!"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 = !{!7, !7, i64 0}
!12 = !{!13, !6, i64 8}
!13 = !{!"XArrayData", !6, i64 0, !6, i64 8, !10, i64 16, !14, i64 24}
!14 = !{!"int", !7, i64 0}
!15 = !{!13, !10, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"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.2 = external hidden unnamed_addr constant [2 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @xstrmatch(ptr noundef, i64 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: nounwind uwtable
define dso_local zeroext i8 @xstrmatchm(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = icmp ne ptr %0, null
  %6 = icmp ne ptr %2, null
  %or.cond = and i1 %5, %6
  br i1 %or.cond, label %7, label %33

7:                                                ; preds = %4
  %.not = icmp eq i64 %1, 0
  br i1 %.not, label %8, label %11

8:                                                ; preds = %7
  %9 = tail call zeroext i8 @xstrused(ptr noundef nonnull %2)
  %.not44 = icmp eq i8 %9, 0
  %10 = zext i1 %.not44 to i8
  br label %33

11:                                               ; preds = %7
  %12 = icmp eq ptr %3, null
  %13 = select i1 %12, ptr @.str.2, ptr %3
  %14 = tail call i32 @xstrsrc(ptr noundef nonnull %2, ptr noundef nonnull %13)
  %.not45 = icmp eq i32 %14, 0
  br i1 %.not45, label %15, label %17

15:                                               ; preds = %11
  %16 = tail call zeroext i8 @xstrmatch(ptr noundef nonnull %0, i64 noundef %1, ptr noundef nonnull %2)
  br label %33

17:                                               ; preds = %11
  %18 = tail call ptr @xstrsplit(ptr noundef nonnull %2, ptr noundef nonnull %13)
  %19 = tail call i64 @XArray_Used(ptr noundef %18) #2
  %.not57 = icmp eq i64 %19, 0
  br i1 %.not57, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %17, %.thread
  %.03554 = phi i64 [ %32, %.thread ], [ 0, %17 ]
  %20 = tail call ptr @XArray_Get(ptr noundef %18, i64 noundef %.03554) #2
  %21 = icmp eq ptr %20, null
  br i1 %21, label %.thread, label %22

22:                                               ; preds = %.lr.ph
  %23 = getelementptr inbounds i8, ptr %20, i64 8
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = icmp eq ptr %24, null
  br i1 %25, label %.thread, label %26

26:                                               ; preds = %22
  %27 = getelementptr inbounds i8, ptr %20, i64 16
  %28 = load i64, ptr %27, align 8, !tbaa !12
  %.not46 = icmp eq i64 %28, 0
  br i1 %.not46, label %.thread, label %29

29:                                               ; preds = %26
  %30 = add i64 %28, -1
  %31 = tail call zeroext i8 @xstrnmatch(ptr noundef nonnull %0, i64 noundef %1, ptr noundef nonnull %24, i64 noundef %30)
  %.not47.not = icmp eq i8 %31, 0
  br i1 %.not47.not, label %.thread, label %._crit_edge

.thread:                                          ; preds = %.lr.ph, %22, %26, %29
  %32 = add nuw i64 %.03554, 1
  %exitcond.not = icmp eq i64 %32, %19
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !13

._crit_edge:                                      ; preds = %.thread, %29, %17
  %.2 = phi i8 [ 0, %17 ], [ %31, %29 ], [ 0, %.thread ]
  tail call void @XArray_Destroy(ptr noundef %18) #2
  br label %33

33:                                               ; preds = %15, %._crit_edge, %4, %8
  %.1 = phi i8 [ %10, %8 ], [ 0, %4 ], [ %.2, %._crit_edge ], [ %16, %15 ]
  ret i8 %.1
}

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

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

declare i64 @XArray_Used(ptr noundef) local_unnamed_addr #1

declare ptr @XArray_Get(ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @XArray_Destroy(ptr noundef) local_unnamed_addr #1

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 = { "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, !7, i64 8}
!6 = !{!"XArrayData", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !10, i64 16}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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