; LLVM IR from WayneLin92/SSeqCpp :: thirdparty/fmt/test (scan-test)

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

%"class.fmt::v10::detail::scan_buffer::iterator" = type <{ ptr, ptr, i8, [7 x i8] }>
%"struct.fmt::v10::detail::maybe_contiguous_range" = type { ptr, ptr }
%"class.fmt::v10::basic_string_view" = type { ptr, i64 }

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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: mustprogress uwtable
define dso_local void @_ZN3fmt3v106detail4readENS1_11scan_buffer8iteratorERNS0_17basic_string_viewIcEERKNS0_12format_specsIcEE(ptr dead_on_unwind noalias writable sret(%"class.fmt::v10::detail::scan_buffer::iterator") align 8 %0, ptr noundef byval(%"class.fmt::v10::detail::scan_buffer::iterator") align 8 %1, ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(16) %3) #2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca %"struct.fmt::v10::detail::maybe_contiguous_range", align 8
  %8 = alloca %"class.fmt::v10::detail::scan_buffer::iterator", align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca %"class.fmt::v10::basic_string_view", align 8
  %12 = alloca %"class.fmt::v10::detail::scan_buffer::iterator", align 8
  store ptr %2, ptr %5, align 8, !tbaa !5
  store ptr %3, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %8, ptr align 8 %1, i64 24, i1 false), !tbaa.struct !9
  %13 = call { ptr, ptr } @_ZN3fmt3v106detail13to_contiguousENS1_11scan_buffer8iteratorE(ptr noundef byval(%"class.fmt::v10::detail::scan_buffer::iterator") align 8 %8)
  %14 = getelementptr inbounds { ptr, ptr }, ptr %7, i32 0, i32 0
  %15 = extractvalue { ptr, ptr } %13, 0
  store ptr %15, ptr %14, align 8
  %16 = getelementptr inbounds { ptr, ptr }, ptr %7, i32 0, i32 1
  %17 = extractvalue { ptr, ptr } %13, 1
  store ptr %17, ptr %16, align 8
  %18 = call noundef zeroext i1 @_ZNK3fmt3v106detail22maybe_contiguous_rangecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %7)
  br i1 %18, label %20, label %19

19:                                               ; preds = %4
  call void @_ZN3fmt3v106detail18throw_format_errorEPKc(ptr noundef @.str) #6
  unreachable

20:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %21 = getelementptr inbounds %"struct.fmt::v10::detail::maybe_contiguous_range", ptr %7, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  store ptr %22, ptr %9, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %35, %20
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.fmt::v10::detail::maybe_contiguous_range", ptr %7, i32 0, i32 1
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = icmp ne ptr %24, %26
  br i1 %27, label %28, label %33

28:                                               ; preds = %23
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = load i8, ptr %29, align 1, !tbaa !10
  %31 = sext i8 %30 to i32
  %32 = icmp ne i32 %31, 32
  br label %33

33:                                               ; preds = %28, %23
  %34 = phi i1 [ false, %23 ], [ %32, %28 ]
  br i1 %34, label %35, label %38

35:                                               ; preds = %33
  %36 = load ptr, ptr %9, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %36, i32 1
  store ptr %37, ptr %9, align 8, !tbaa !5
  br label %23, !llvm.loop !14

38:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds %"struct.fmt::v10::detail::maybe_contiguous_range", ptr %7, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !11
  %42 = ptrtoint ptr %39 to i64
  %43 = ptrtoint ptr %41 to i64
  %44 = sub i64 %42, %43
  %45 = call noundef i64 @_ZN3fmt3v106detail11to_unsignedIlEENSt13make_unsignedIT_E4typeES4_(i64 noundef %44)
  store i64 %45, ptr %10, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #5
  %46 = getelementptr inbounds %"struct.fmt::v10::detail::maybe_contiguous_range", ptr %7, i32 0, i32 0
  %47 = load ptr, ptr %46, align 8, !tbaa !11
  %48 = load i64, ptr %10, align 8, !tbaa !16
  call void @_ZN3fmt3v1017basic_string_viewIcEC2EPKcm(ptr noundef nonnull align 8 dereferenceable(16) %11, ptr noundef %47, i64 noundef %48) #5
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %49, ptr align 8 %11, i64 16, i1 false), !tbaa.struct !18
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %12, ptr align 8 %1, i64 24, i1 false), !tbaa.struct !9
  %50 = load i64, ptr %10, align 8, !tbaa !16
  call void @_ZN3fmt3v106detail7advanceENS1_11scan_buffer8iteratorEm(ptr dead_on_unwind writable sret(%"class.fmt::v10::detail::scan_buffer::iterator") align 8 %0, ptr noundef byval(%"class.fmt::v10::detail::scan_buffer::iterator") align 8 %12, i64 noundef %50)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #5
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, ptr } @_ZN3fmt3v106detail13to_contiguousENS1_11scan_buffer8iteratorE(ptr noundef byval(%"class.fmt::v10::detail::scan_buffer::iterator") align 8) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3fmt3v106detail22maybe_contiguous_rangecvbEv(ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

; Function Attrs: noreturn
declare void @_ZN3fmt3v106detail18throw_format_errorEPKc(ptr noundef) #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN3fmt3v106detail11to_unsignedIlEENSt13make_unsignedIT_E4typeES4_(i64 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3fmt3v1017basic_string_viewIcEC2EPKcm(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, i64 noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3fmt3v106detail7advanceENS1_11scan_buffer8iteratorEm(ptr dead_on_unwind noalias writable sret(%"class.fmt::v10::detail::scan_buffer::iterator") align 8, ptr noundef byval(%"class.fmt::v10::detail::scan_buffer::iterator") align 8, i64 noundef) #2

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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" }
attributes #3 = { 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 #4 = { noreturn "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 = { nounwind }
attributes #6 = { noreturn }

!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 = !{i64 0, i64 8, !5, i64 8, i64 8, !5, i64 16, i64 1, !10}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTSN3fmt3v106detail22maybe_contiguous_rangeE", !6, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !17, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{i64 0, i64 8, !5, i64 8, i64 8, !16}


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

%"class.fmt::v10::detail::scan_buffer::iterator" = type <{ ptr, ptr, i8, [7 x i8] }>
%"struct.fmt::v10::detail::maybe_contiguous_range" = type { ptr, ptr }
%"class.fmt::v10::basic_string_view" = type { ptr, i64 }

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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 uwtable
define dso_local void @_ZN3fmt3v106detail4readENS1_11scan_buffer8iteratorERNS0_17basic_string_viewIcEERKNS0_12format_specsIcEE(ptr dead_on_unwind noalias writable sret(%"class.fmt::v10::detail::scan_buffer::iterator") align 8 %0, ptr nocapture noundef readonly byval(%"class.fmt::v10::detail::scan_buffer::iterator") align 8 %1, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(16) %2, ptr nocapture noundef nonnull readnone align 4 dereferenceable(16) %3) local_unnamed_addr #2 {
  %5 = alloca %"struct.fmt::v10::detail::maybe_contiguous_range", align 8
  %6 = alloca %"class.fmt::v10::basic_string_view", align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #5
  %7 = tail call { ptr, ptr } @_ZN3fmt3v106detail13to_contiguousENS1_11scan_buffer8iteratorE(ptr noundef nonnull byval(%"class.fmt::v10::detail::scan_buffer::iterator") align 8 %1)
  %8 = extractvalue { ptr, ptr } %7, 0
  store ptr %8, ptr %5, align 8
  %9 = getelementptr inbounds i8, ptr %5, i64 8
  %10 = extractvalue { ptr, ptr } %7, 1
  store ptr %10, ptr %9, align 8
  %11 = call noundef zeroext i1 @_ZNK3fmt3v106detail22maybe_contiguous_rangecvbEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  br i1 %11, label %13, label %12

12:                                               ; preds = %4
  call void @_ZN3fmt3v106detail18throw_format_errorEPKc(ptr noundef nonnull @.str) #6
  unreachable

13:                                               ; preds = %4
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = ptrtoint ptr %14 to i64
  %16 = load ptr, ptr %9, align 8, !tbaa !10
  %.not7 = icmp eq ptr %14, %16
  br i1 %.not7, label %.critedge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %13
  %17 = ptrtoint ptr %16 to i64
  %18 = sub i64 %17, %15
  %scevgep = getelementptr i8, ptr %14, i64 %18
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %20
  %.08 = phi ptr [ %21, %20 ], [ %14, %.lr.ph.preheader ]
  %19 = load i8, ptr %.08, align 1, !tbaa !11
  %.not6 = icmp eq i8 %19, 32
  br i1 %.not6, label %.critedge.loopexit, label %20

20:                                               ; preds = %.lr.ph
  %21 = getelementptr inbounds i8, ptr %.08, i64 1
  %.not = icmp eq ptr %21, %16
  br i1 %.not, label %.critedge.loopexit, label %.lr.ph, !llvm.loop !12

.critedge.loopexit:                               ; preds = %20, %.lr.ph
  %.0.lcssa.ph = phi ptr [ %.08, %.lr.ph ], [ %scevgep, %20 ]
  %.pre = ptrtoint ptr %.0.lcssa.ph to i64
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %13
  %.pre-phi = phi i64 [ %.pre, %.critedge.loopexit ], [ %15, %13 ]
  %22 = sub i64 %.pre-phi, %15
  %23 = call noundef i64 @_ZN3fmt3v106detail11to_unsignedIlEENSt13make_unsignedIT_E4typeES4_(i64 noundef %22)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN3fmt3v1017basic_string_viewIcEC2EPKcm(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef %24, i64 noundef %23) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(16) %6, i64 16, i1 false), !tbaa.struct !14
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #5
  call void @_ZN3fmt3v106detail7advanceENS1_11scan_buffer8iteratorEm(ptr dead_on_unwind writable sret(%"class.fmt::v10::detail::scan_buffer::iterator") align 8 %0, ptr noundef nonnull byval(%"class.fmt::v10::detail::scan_buffer::iterator") align 8 %1, i64 noundef %23)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #5
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, ptr } @_ZN3fmt3v106detail13to_contiguousENS1_11scan_buffer8iteratorE(ptr noundef byval(%"class.fmt::v10::detail::scan_buffer::iterator") align 8) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3fmt3v106detail22maybe_contiguous_rangecvbEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #3 align 2

; Function Attrs: noreturn
declare void @_ZN3fmt3v106detail18throw_format_errorEPKc(ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN3fmt3v106detail11to_unsignedIlEENSt13make_unsignedIT_E4typeES4_(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3fmt3v1017basic_string_viewIcEC2EPKcm(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, i64 noundef) unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3fmt3v106detail7advanceENS1_11scan_buffer8iteratorEm(ptr dead_on_unwind noalias writable sret(%"class.fmt::v10::detail::scan_buffer::iterator") align 8, ptr noundef byval(%"class.fmt::v10::detail::scan_buffer::iterator") align 8, i64 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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" }
attributes #3 = { 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 #4 = { noreturn "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 = { nounwind }
attributes #6 = { noreturn }

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


; Effective O3 passes: BDCEPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass