; LLVM IR from Adlik/Adlik :: cub/string/scanner.ll (ZN3cub7Scanner3anyESt8functionIFbcEE)

; 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.cub::Scanner" = type <{ %"struct.cub::StringView", ptr, ptr, i8, [7 x i8] }>
%"struct.cub::StringView" = type { ptr, i64 }

declare noundef zeroext i1 @_ZNK3cub10StringView5emptyEv(ptr noundef nonnull align 8 dereferenceable(16)) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNKSt8functionIFbcEEclEc(ptr noundef nonnull align 8 dereferenceable(32), i8 noundef signext) #1 align 2

declare noundef signext i8 @_ZNK3cub10StringViewixEm(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) #0

declare void @_ZN3cub10StringView12removePrefixEm(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 8 dereferenceable(33) ptr @_ZN3cub7Scanner3anyESt8functionIFbcEE(ptr noundef nonnull align 8 dereferenceable(33) %0, ptr noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8
  br label %6

6:                                                ; preds = %15, %2
  %7 = getelementptr inbounds %"struct.cub::Scanner", ptr %5, i32 0, i32 0
  %8 = call noundef zeroext i1 @_ZNK3cub10StringView5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %7)
  br i1 %8, label %13, label %9

9:                                                ; preds = %6
  %10 = getelementptr inbounds %"struct.cub::Scanner", ptr %5, i32 0, i32 0
  %11 = call noundef signext i8 @_ZNK3cub10StringViewixEm(ptr noundef nonnull align 8 dereferenceable(16) %10, i64 noundef 0)
  %12 = call noundef zeroext i1 @_ZNKSt8functionIFbcEEclEc(ptr noundef nonnull align 8 dereferenceable(32) %1, i8 noundef signext %11)
  br label %13

13:                                               ; preds = %9, %6
  %14 = phi i1 [ false, %6 ], [ %12, %9 ]
  br i1 %14, label %15, label %17

15:                                               ; preds = %13
  %16 = getelementptr inbounds %"struct.cub::Scanner", ptr %5, i32 0, i32 0
  call void @_ZN3cub10StringView12removePrefixEm(ptr noundef nonnull align 8 dereferenceable(16) %16, i64 noundef 1)
  br label %6, !llvm.loop !9

17:                                               ; preds = %13
  ret ptr %5
}

attributes #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 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" }

!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 = distinct !{!9, !10}
!10 = !{!"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"

declare noundef zeroext i1 @_ZNK3cub10StringView5emptyEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNKSt8functionIFbcEEclEc(ptr noundef nonnull align 8 dereferenceable(32), i8 noundef signext) local_unnamed_addr #1 align 2

declare noundef signext i8 @_ZNK3cub10StringViewixEm(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) local_unnamed_addr #0

declare void @_ZN3cub10StringView12removePrefixEm(ptr noundef nonnull align 8 dereferenceable(16), i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 8 dereferenceable(33) ptr @_ZN3cub7Scanner3anyESt8functionIFbcEE(ptr noundef nonnull returned align 8 dereferenceable(33) %0, ptr noundef %1) local_unnamed_addr #1 align 2 {
  %3 = tail call noundef zeroext i1 @_ZNK3cub10StringView5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  br i1 %3, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %6
  %4 = tail call noundef signext i8 @_ZNK3cub10StringViewixEm(ptr noundef nonnull align 8 dereferenceable(16) %0, i64 noundef 0)
  %5 = tail call noundef zeroext i1 @_ZNKSt8functionIFbcEEclEc(ptr noundef nonnull align 8 dereferenceable(32) %1, i8 noundef signext %4)
  br i1 %5, label %6, label %.critedge

6:                                                ; preds = %.lr.ph
  tail call void @_ZN3cub10StringView12removePrefixEm(ptr noundef nonnull align 8 dereferenceable(16) %0, i64 noundef 1)
  %7 = tail call noundef zeroext i1 @_ZNK3cub10StringView5emptyEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  br i1 %7, label %.critedge, label %.lr.ph, !llvm.loop !5

.critedge:                                        ; preds = %.lr.ph, %6, %2
  ret ptr %0
}

attributes #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 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" }

!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,GlobalOptPass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass