; LLVM IR from facebook/redex :: libredex (DexStoreUtil)

; 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 uwtable
define dso_local noundef zeroext i1 @_Z20is_in_non_root_storePK7DexTypeRKSt6vectorI8DexStoreSaIS3_EERK10XStoreRefsb(ptr noundef %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(2840) %2, i1 noundef zeroext %3) #1 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i8, align 1
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  %13 = zext i1 %3 to i8
  store i8 %13, ptr %9, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = call noundef i64 @_ZNK10XStoreRefs13get_store_idxEPK7DexType(ptr noundef nonnull align 8 dereferenceable(2840) %14, ptr noundef %15)
  store i64 %16, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = call noundef nonnull align 8 dereferenceable(137) ptr @_ZNKSt6vectorI8DexStoreSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %17, i64 noundef 0) #4
  %19 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8DexStore9get_dexenEv(ptr noundef nonnull align 8 dereferenceable(137) %18)
  %20 = call noundef i64 @_ZNKSt6vectorIS_IP8DexClassSaIS1_EESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %19) #4
  %21 = icmp eq i64 %20, 1
  %22 = zext i1 %21 to i64
  %23 = select i1 %21, i32 1, i32 2
  %24 = sext i32 %23 to i64
  store i64 %24, ptr %11, align 8, !tbaa !11
  %25 = load i8, ptr %9, align 1, !tbaa !9, !range !13, !noundef !14
  %26 = trunc i8 %25 to i1
  br i1 %26, label %31, label %27

27:                                               ; preds = %4
  %28 = load i64, ptr %10, align 8, !tbaa !11
  %29 = icmp eq i64 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %27
  store i1 true, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %38

31:                                               ; preds = %27, %4
  %32 = load i64, ptr %10, align 8, !tbaa !11
  %33 = load i64, ptr %11, align 8, !tbaa !11
  %34 = icmp uge i64 %32, %33
  br i1 %34, label %35, label %36

35:                                               ; preds = %31
  store i1 true, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %38

36:                                               ; preds = %31
  br label %37

37:                                               ; preds = %36
  store i1 false, ptr %5, align 1
  store i32 1, ptr %12, align 4
  br label %38

38:                                               ; preds = %37, %35, %30
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  %39 = load i1, ptr %5, align 1
  ret i1 %39
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNK10XStoreRefs13get_store_idxEPK7DexType(ptr noundef nonnull align 8 dereferenceable(2840), ptr noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(137) ptr @_ZNKSt6vectorI8DexStoreSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

declare noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8DexStore9get_dexenEv(ptr noundef nonnull align 8 dereferenceable(137)) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIS_IP8DexClassSaIS1_EESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 #3 = { "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 = { 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 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}


; 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 uwtable
define dso_local noundef zeroext i1 @_Z20is_in_non_root_storePK7DexTypeRKSt6vectorI8DexStoreSaIS3_EERK10XStoreRefsb(ptr noundef %0, ptr noundef nonnull align 8 dereferenceable(24) %1, ptr noundef nonnull align 8 dereferenceable(2840) %2, i1 noundef zeroext %3) local_unnamed_addr #0 {
  %5 = tail call noundef i64 @_ZNK10XStoreRefs13get_store_idxEPK7DexType(ptr noundef nonnull align 8 dereferenceable(2840) %2, ptr noundef %0)
  %6 = tail call noundef nonnull align 8 dereferenceable(137) ptr @_ZNKSt6vectorI8DexStoreSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef 0) #3
  %7 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8DexStore9get_dexenEv(ptr noundef nonnull align 8 dereferenceable(137) %6)
  %8 = tail call noundef i64 @_ZNKSt6vectorIS_IP8DexClassSaIS1_EESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #3
  %9 = icmp ne i64 %5, 0
  %or.cond.not = or i1 %9, %3
  br i1 %or.cond.not, label %10, label %13

10:                                               ; preds = %4
  %11 = icmp eq i64 %8, 1
  %12 = select i1 %11, i64 1, i64 2
  %.not = icmp uge i64 %5, %12
  br label %13

13:                                               ; preds = %10, %4
  %.0 = phi i1 [ true, %4 ], [ %.not, %10 ]
  ret i1 %.0
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNK10XStoreRefs13get_store_idxEPK7DexType(ptr noundef nonnull align 8 dereferenceable(2840), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(137) ptr @_ZNKSt6vectorI8DexStoreSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

declare noundef nonnull align 8 dereferenceable(24) ptr @_ZNK8DexStore9get_dexenEv(ptr noundef nonnull align 8 dereferenceable(137)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIS_IP8DexClassSaIS1_EESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass