; LLVM IR from nsccgz-storage/nvlsm :: util/logging.ll (ZN7leveldb20ConsumeDecimalNumberEPNS_5SliceEPm)

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

; 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: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK7leveldb5Slice4sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7leveldb20ConsumeDecimalNumberEPNS_5SliceEPm(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i8, align 1
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i8, align 1
  %13 = alloca i32, align 4
  %14 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 -1, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  store i8 53, ptr %7, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = call noundef ptr @_ZNK7leveldb5Slice4dataEv(ptr noundef nonnull align 8 dereferenceable(16) %15)
  store ptr %16, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = call noundef i64 @_ZNK7leveldb5Slice4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %18)
  %20 = getelementptr inbounds i8, ptr %17, i64 %19
  store ptr %20, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %21, ptr %11, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %59, %2
  %23 = load ptr, ptr %11, align 8, !tbaa !5
  %24 = load ptr, ptr %10, align 8, !tbaa !5
  %25 = icmp ne ptr %23, %24
  br i1 %25, label %26, label %62

26:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #3
  %27 = load ptr, ptr %11, align 8, !tbaa !5
  %28 = load i8, ptr %27, align 1, !tbaa !11
  store i8 %28, ptr %12, align 1, !tbaa !11
  %29 = load i8, ptr %12, align 1, !tbaa !11
  %30 = zext i8 %29 to i32
  %31 = icmp slt i32 %30, 48
  br i1 %31, label %36, label %32

32:                                               ; preds = %26
  %33 = load i8, ptr %12, align 1, !tbaa !11
  %34 = zext i8 %33 to i32
  %35 = icmp sgt i32 %34, 57
  br i1 %35, label %36, label %37

36:                                               ; preds = %32, %26
  store i32 2, ptr %13, align 4
  br label %56

37:                                               ; preds = %32
  %38 = load i64, ptr %8, align 8, !tbaa !9
  %39 = icmp ugt i64 %38, 1844674407370955161
  br i1 %39, label %47, label %40

40:                                               ; preds = %37
  %41 = load i64, ptr %8, align 8, !tbaa !9
  %42 = icmp eq i64 %41, 1844674407370955161
  br i1 %42, label %43, label %48

43:                                               ; preds = %40
  %44 = load i8, ptr %12, align 1, !tbaa !11
  %45 = zext i8 %44 to i32
  %46 = icmp sgt i32 %45, 53
  br i1 %46, label %47, label %48

47:                                               ; preds = %43, %37
  store i1 false, ptr %3, align 1
  store i32 1, ptr %13, align 4
  br label %56

48:                                               ; preds = %43, %40
  %49 = load i64, ptr %8, align 8, !tbaa !9
  %50 = mul i64 %49, 10
  %51 = load i8, ptr %12, align 1, !tbaa !11
  %52 = zext i8 %51 to i32
  %53 = sub nsw i32 %52, 48
  %54 = sext i32 %53 to i64
  %55 = add i64 %50, %54
  store i64 %55, ptr %8, align 8, !tbaa !9
  store i32 0, ptr %13, align 4
  br label %56

56:                                               ; preds = %48, %47, %36
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #3
  %57 = load i32, ptr %13, align 4
  switch i32 %57, label %74 [
    i32 0, label %58
    i32 2, label %62
  ]

58:                                               ; preds = %56
  br label %59

59:                                               ; preds = %58
  %60 = load ptr, ptr %11, align 8, !tbaa !5
  %61 = getelementptr inbounds i8, ptr %60, i32 1
  store ptr %61, ptr %11, align 8, !tbaa !5
  br label %22, !llvm.loop !12

62:                                               ; preds = %56, %22
  %63 = load i64, ptr %8, align 8, !tbaa !9
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  store i64 %63, ptr %64, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %65 = load ptr, ptr %11, align 8, !tbaa !5
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = ptrtoint ptr %65 to i64
  %68 = ptrtoint ptr %66 to i64
  %69 = sub i64 %67, %68
  store i64 %69, ptr %14, align 8, !tbaa !9
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = load i64, ptr %14, align 8, !tbaa !9
  call void @_ZN7leveldb5Slice13remove_prefixEm(ptr noundef nonnull align 8 dereferenceable(16) %70, i64 noundef %71)
  %72 = load i64, ptr %14, align 8, !tbaa !9
  %73 = icmp ne i64 %72, 0
  store i1 %73, ptr %3, align 1
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  br label %74

74:                                               ; preds = %62, %56
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %75 = load i1, ptr %3, align 1
  ret i1 %75
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK7leveldb5Slice4dataEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK7leveldb5Slice4sizeEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN7leveldb20ConsumeDecimalNumberEPNS_5SliceEPm(ptr noundef nonnull %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 {
  %3 = tail call noundef ptr @_ZNK7leveldb5Slice4dataEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %4 = tail call noundef i64 @_ZNK7leveldb5Slice4sizeEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %5 = getelementptr i8, ptr %3, i64 %4
  %.not42 = icmp eq i64 %4, 0
  br i1 %.not42, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %13
  %.02944 = phi i64 [ %17, %13 ], [ 0, %2 ]
  %.03243 = phi ptr [ %18, %13 ], [ %3, %2 ]
  %6 = load i8, ptr %.03243, align 1, !tbaa !5
  %7 = add i8 %6, -58
  %or.cond = icmp ult i8 %7, -10
  br i1 %or.cond, label %._crit_edge, label %8

8:                                                ; preds = %.lr.ph
  %9 = icmp ugt i64 %.02944, 1844674407370955161
  br i1 %9, label %.thread, label %10

10:                                               ; preds = %8
  %11 = icmp eq i64 %.02944, 1844674407370955161
  %12 = icmp ugt i8 %6, 53
  %or.cond5 = and i1 %11, %12
  br i1 %or.cond5, label %.thread, label %13

13:                                               ; preds = %10
  %14 = mul nuw i64 %.02944, 10
  %15 = and i8 %6, 15
  %16 = zext nneg i8 %15 to i64
  %17 = add i64 %14, %16
  %18 = getelementptr inbounds i8, ptr %.03243, i64 1
  %.not = icmp eq ptr %18, %5
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !8

._crit_edge:                                      ; preds = %13, %.lr.ph, %2
  %.032.lcssa = phi ptr [ %3, %2 ], [ %.03243, %.lr.ph ], [ %5, %13 ]
  %.029.lcssa = phi i64 [ 0, %2 ], [ %.02944, %.lr.ph ], [ %17, %13 ]
  store i64 %.029.lcssa, ptr %1, align 8, !tbaa !10
  %19 = ptrtoint ptr %.032.lcssa to i64
  %20 = ptrtoint ptr %3 to i64
  %21 = sub i64 %19, %20
  tail call void @_ZN7leveldb5Slice13remove_prefixEm(ptr noundef nonnull align 8 dereferenceable(16) %0, i64 noundef %21)
  %22 = icmp ne ptr %.032.lcssa, %3
  br label %.thread

.thread:                                          ; preds = %8, %10, %._crit_edge
  %.2 = phi i1 [ %22, %._crit_edge ], [ false, %10 ], [ false, %8 ]
  ret i1 %.2
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK7leveldb5Slice4dataEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

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

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

!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++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !6, i64 0}


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