; LLVM IR from openxrlab/xrsfm :: 3rdparty/apriltag/common (string_util)

; 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.1 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [12 x i8], align 1
@__PRETTY_FUNCTION__.str_split = external hidden unnamed_addr constant [48 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr 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: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #2

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

14:                                               ; preds = %2
  br label %16

15:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 143, ptr noundef @__PRETTY_FUNCTION__.str_split) #5
  unreachable

16:                                               ; preds = %14
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %19, label %20

19:                                               ; preds = %16
  br label %21

20:                                               ; preds = %16
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 144, ptr noundef @__PRETTY_FUNCTION__.str_split) #5
  unreachable

21:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %22 = call ptr @zarray_create(i64 noundef 8)
  store ptr %22, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %23 = call ptr @string_buffer_create()
  store ptr %23, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = call i64 @strlen(ptr noundef %24) #7
  store i64 %25, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = call i64 @strlen(ptr noundef %26) #7
  store i64 %27, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %28

28:                                               ; preds = %62, %21
  %29 = load i64, ptr %9, align 8, !tbaa !9
  %30 = load i64, ptr %8, align 8, !tbaa !9
  %31 = icmp ult i64 %29, %30
  br i1 %31, label %32, label %63

32:                                               ; preds = %28
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = load i64, ptr %9, align 8, !tbaa !9
  %35 = getelementptr inbounds i8, ptr %33, i64 %34
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = call zeroext i1 @str_starts_with(ptr noundef %35, ptr noundef %36)
  br i1 %37, label %38, label %54

38:                                               ; preds = %32
  %39 = load i64, ptr %7, align 8, !tbaa !9
  %40 = icmp ugt i64 %39, 0
  br i1 %40, label %41, label %54

41:                                               ; preds = %38
  %42 = load i64, ptr %7, align 8, !tbaa !9
  %43 = load i64, ptr %9, align 8, !tbaa !9
  %44 = add i64 %43, %42
  store i64 %44, ptr %9, align 8, !tbaa !9
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = call i64 @string_buffer_size(ptr noundef %45)
  %47 = icmp ugt i64 %46, 0
  br i1 %47, label %48, label %52

48:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = call ptr @string_buffer_to_string(ptr noundef %49)
  store ptr %50, ptr %10, align 8, !tbaa !5
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  call void @zarray_add(ptr noundef %51, ptr noundef %10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %52

52:                                               ; preds = %48, %41
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  call void @string_buffer_reset(ptr noundef %53)
  br label %62

54:                                               ; preds = %38, %32
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = load i64, ptr %9, align 8, !tbaa !9
  %58 = getelementptr inbounds i8, ptr %56, i64 %57
  %59 = load i8, ptr %58, align 1, !tbaa !11
  call void @string_buffer_append(ptr noundef %55, i8 noundef signext %59)
  %60 = load i64, ptr %9, align 8, !tbaa !9
  %61 = add i64 %60, 1
  store i64 %61, ptr %9, align 8, !tbaa !9
  br label %62

62:                                               ; preds = %54, %52
  br label %28, !llvm.loop !12

63:                                               ; preds = %28
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = call i64 @string_buffer_size(ptr noundef %64)
  %66 = icmp ugt i64 %65, 0
  br i1 %66, label %67, label %71

67:                                               ; preds = %63
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = call ptr @string_buffer_to_string(ptr noundef %68)
  store ptr %69, ptr %11, align 8, !tbaa !5
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  call void @zarray_add(ptr noundef %70, ptr noundef %11)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  br label %71

71:                                               ; preds = %67, %63
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  call void @string_buffer_destroy(ptr noundef %72)
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  ret ptr %73
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @zarray_create(i64 noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare dso_local zeroext i1 @str_starts_with(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i64 @string_buffer_size(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local ptr @string_buffer_to_string(ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @zarray_add(ptr noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @string_buffer_reset(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @string_buffer_append(ptr noundef, i8 noundef signext) #3

; Function Attrs: nounwind uwtable
declare dso_local void @string_buffer_destroy(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local ptr @string_buffer_create() #3

attributes #0 = { noreturn nounwind "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 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 = { 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 #4 = { inlinehint 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 #5 = { noreturn nounwind }
attributes #6 = { nounwind }
attributes #7 = { 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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.1 = external hidden unnamed_addr constant [88 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [12 x i8], align 1
@__PRETTY_FUNCTION__.str_split = external hidden unnamed_addr constant [48 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @str_split(ptr noundef %0, ptr noundef %1) local_unnamed_addr #3 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %5, label %6

5:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 143, ptr noundef nonnull @__PRETTY_FUNCTION__.str_split) #5
  unreachable

6:                                                ; preds = %2
  %.not28 = icmp eq ptr %1, null
  br i1 %.not28, label %7, label %8

7:                                                ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 144, ptr noundef nonnull @__PRETTY_FUNCTION__.str_split) #5
  unreachable

8:                                                ; preds = %6
  %9 = tail call ptr @zarray_create(i64 noundef 8)
  %10 = tail call ptr @string_buffer_create()
  %11 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %1) #6
  %.fr33 = freeze i64 %11
  %12 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %0) #6
  %.not32 = icmp eq i64 %12, 0
  br i1 %.not32, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %8
  %.not34 = icmp eq i64 %.fr33, 0
  br i1 %.not34, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.lr.ph.split.us
  %.031.us = phi i64 [ %.1.us, %.lr.ph.split.us ], [ 0, %.lr.ph ]
  %13 = getelementptr inbounds i8, ptr %0, i64 %.031.us
  %14 = tail call zeroext i1 @str_starts_with(ptr noundef nonnull %13, ptr noundef nonnull %1)
  %15 = load i8, ptr %13, align 1, !tbaa !5
  tail call void @string_buffer_append(ptr noundef %10, i8 noundef signext %15)
  %.1.us = add nuw i64 %.031.us, 1
  %exitcond.not = icmp eq i64 %.1.us, %12
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !8

.lr.ph.split:                                     ; preds = %.lr.ph, %25
  %.031 = phi i64 [ %.1, %25 ], [ 0, %.lr.ph ]
  %16 = getelementptr inbounds i8, ptr %0, i64 %.031
  %17 = call zeroext i1 @str_starts_with(ptr noundef nonnull %16, ptr noundef nonnull %1)
  br i1 %17, label %18, label %23

18:                                               ; preds = %.lr.ph.split
  %19 = call i64 @string_buffer_size(ptr noundef %10)
  %.not30 = icmp eq i64 %19, 0
  br i1 %.not30, label %22, label %20

20:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %21 = call ptr @string_buffer_to_string(ptr noundef %10)
  store ptr %21, ptr %3, align 8, !tbaa !10
  call void @zarray_add(ptr noundef %9, ptr noundef nonnull %3)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  br label %22

22:                                               ; preds = %20, %18
  call void @string_buffer_reset(ptr noundef %10)
  br label %25

23:                                               ; preds = %.lr.ph.split
  %24 = load i8, ptr %16, align 1, !tbaa !5
  call void @string_buffer_append(ptr noundef %10, i8 noundef signext %24)
  br label %25

25:                                               ; preds = %23, %22
  %.pn = phi i64 [ %.fr33, %22 ], [ 1, %23 ]
  %.1 = add i64 %.pn, %.031
  %26 = icmp ult i64 %.1, %12
  br i1 %26, label %.lr.ph.split, label %._crit_edge, !llvm.loop !8

._crit_edge:                                      ; preds = %25, %.lr.ph.split.us, %8
  %27 = call i64 @string_buffer_size(ptr noundef %10)
  %.not29 = icmp eq i64 %27, 0
  br i1 %.not29, label %30, label %28

28:                                               ; preds = %._crit_edge
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  %29 = call ptr @string_buffer_to_string(ptr noundef %10)
  store ptr %29, ptr %4, align 8, !tbaa !10
  call void @zarray_add(ptr noundef %9, ptr noundef nonnull %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  br label %30

30:                                               ; preds = %28, %._crit_edge
  call void @string_buffer_destroy(ptr noundef %10)
  ret ptr %9
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @zarray_create(i64 noundef) local_unnamed_addr #4

; Function Attrs: inlinehint nounwind uwtable
declare dso_local zeroext i1 @str_starts_with(ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare dso_local i64 @string_buffer_size(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local ptr @string_buffer_to_string(ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @zarray_add(ptr noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare dso_local void @string_buffer_reset(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @string_buffer_append(ptr noundef, i8 noundef signext) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @string_buffer_destroy(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local ptr @string_buffer_create() local_unnamed_addr #3

attributes #0 = { noreturn nounwind "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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { inlinehint 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 #5 = { noreturn nounwind }
attributes #6 = { nounwind willreturn memory(read) }
attributes #7 = { 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/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !6, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass