; LLVM IR from yinqiwen/ardb :: src/common/redis (listpack)

; 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: nounwind uwtable
define dso_local i64 @lpDecodeBacklen(ptr noundef %0) #1 {
  %2 = alloca i64, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  store i64 0, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %7

7:                                                ; preds = %34, %1
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %8, i64 0
  %10 = load i8, ptr %9, align 1, !tbaa !11
  %11 = zext i8 %10 to i32
  %12 = and i32 %11, 127
  %13 = sext i32 %12 to i64
  %14 = load i64, ptr %5, align 8, !tbaa !9
  %15 = shl i64 %13, %14
  %16 = load i64, ptr %4, align 8, !tbaa !9
  %17 = or i64 %16, %15
  store i64 %17, ptr %4, align 8, !tbaa !9
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 0
  %20 = load i8, ptr %19, align 1, !tbaa !11
  %21 = zext i8 %20 to i32
  %22 = and i32 %21, 128
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %25, label %24

24:                                               ; preds = %7
  br label %35

25:                                               ; preds = %7
  %26 = load i64, ptr %5, align 8, !tbaa !9
  %27 = add i64 %26, 7
  store i64 %27, ptr %5, align 8, !tbaa !9
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i32 -1
  store ptr %29, ptr %3, align 8, !tbaa !5
  %30 = load i64, ptr %5, align 8, !tbaa !9
  %31 = icmp ugt i64 %30, 28
  br i1 %31, label %32, label %33

32:                                               ; preds = %25
  store i64 -1, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %37

33:                                               ; preds = %25
  br label %34

34:                                               ; preds = %33
  br i1 true, label %7, label %35

35:                                               ; preds = %34, %24
  %36 = load i64, ptr %4, align 8, !tbaa !9
  store i64 %36, ptr %2, align 8
  store i32 1, ptr %6, align 4
  br label %37

37:                                               ; preds = %35, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  %38 = load i64, ptr %2, align 8
  ret i64 %38
}

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 = { 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}


; 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 nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local i64 @lpDecodeBacklen(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load i8, ptr %0, align 1, !tbaa !5
  %3 = and i8 %2, 127
  %4 = zext nneg i8 %3 to i64
  %.not = icmp sgt i8 %2, -1
  br i1 %.not, label %33, label %5

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 -1
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %8 = and i8 %7, 127
  %9 = zext nneg i8 %8 to i64
  %10 = shl nuw nsw i64 %9, 7
  %11 = or disjoint i64 %10, %4
  %.not.1 = icmp sgt i8 %7, -1
  br i1 %.not.1, label %33, label %12

12:                                               ; preds = %5
  %13 = getelementptr inbounds i8, ptr %0, i64 -2
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %15 = and i8 %14, 127
  %16 = zext nneg i8 %15 to i64
  %17 = shl nuw nsw i64 %16, 14
  %18 = or disjoint i64 %17, %11
  %.not.2 = icmp sgt i8 %14, -1
  br i1 %.not.2, label %33, label %19

19:                                               ; preds = %12
  %20 = getelementptr inbounds i8, ptr %0, i64 -3
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %22 = and i8 %21, 127
  %23 = zext nneg i8 %22 to i64
  %24 = shl nuw nsw i64 %23, 21
  %25 = or disjoint i64 %24, %18
  %.not.3 = icmp sgt i8 %21, -1
  br i1 %.not.3, label %33, label %26

26:                                               ; preds = %19
  %27 = getelementptr inbounds i8, ptr %0, i64 -4
  %28 = load i8, ptr %27, align 1, !tbaa !5
  %29 = and i8 %28, 127
  %30 = zext nneg i8 %29 to i64
  %31 = shl nuw nsw i64 %30, 28
  %32 = or disjoint i64 %31, %25
  %.not.4 = icmp sgt i8 %28, -1
  %spec.select = select i1 %.not.4, i64 %32, i64 -1
  br label %33

33:                                               ; preds = %26, %19, %12, %5, %1
  %.010 = phi i64 [ %4, %1 ], [ %11, %5 ], [ %18, %12 ], [ %25, %19 ], [ %spec.select, %26 ]
  ret i64 %.010
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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/C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass