; LLVM IR from facebook/redex :: libresource/ResourceTypes.ll (ZNK7android15DynamicRefTable14requiresLookupEPKNS_9Res_valueE)

; 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.android::Res_value" = type { i16, i8, i8, i32 }
%"class.android::DynamicRefTable" = type <{ ptr, i8, [256 x i8], [7 x i8], %"class.android::KeyedVector", i8, [7 x i8] }>
%"class.android::KeyedVector" = type { %"class.android::SortedVector" }
%"class.android::SortedVector" = type { %"class.android::SortedVectorImpl" }
%"class.android::SortedVectorImpl" = type { %"class.android::VectorImpl" }
%"class.android::VectorImpl" = type { ptr, ptr, i64, i32, i64 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK7android15DynamicRefTable14requiresLookupEPKNS_9Res_valueE(ptr noundef nonnull align 8 dereferenceable(313) %0, ptr noundef %1) #0 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = load ptr, ptr %4, align 8
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = getelementptr inbounds %"struct.android::Res_value", ptr %7, i32 0, i32 2
  %9 = load i8, ptr %8, align 1, !tbaa !9
  %10 = zext i8 %9 to i32
  %11 = icmp eq i32 %10, 1
  br i1 %11, label %18, label %12

12:                                               ; preds = %2
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.android::Res_value", ptr %13, i32 0, i32 2
  %15 = load i8, ptr %14, align 1, !tbaa !9
  %16 = zext i8 %15 to i32
  %17 = icmp eq i32 %16, 2
  br i1 %17, label %18, label %31

18:                                               ; preds = %12, %2
  %19 = getelementptr inbounds %"class.android::DynamicRefTable", ptr %6, i32 0, i32 5
  %20 = load i8, ptr %19, align 8, !tbaa !13, !range !21, !noundef !22
  %21 = trunc i8 %20 to i1
  br i1 %21, label %30, label %22

22:                                               ; preds = %18
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.android::Res_value", ptr %23, i32 0, i32 3
  %25 = load i32, ptr %24, align 4, !tbaa !23
  %26 = lshr i32 %25, 24
  %27 = sub i32 %26, 1
  %28 = add i32 %27, 1
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %22, %18
  store i1 true, ptr %3, align 1
  br label %45

31:                                               ; preds = %22, %12
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.android::Res_value", ptr %32, i32 0, i32 2
  %34 = load i8, ptr %33, align 1, !tbaa !9
  %35 = zext i8 %34 to i32
  %36 = icmp eq i32 %35, 8
  br i1 %36, label %43, label %37

37:                                               ; preds = %31
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.android::Res_value", ptr %38, i32 0, i32 2
  %40 = load i8, ptr %39, align 1, !tbaa !9
  %41 = zext i8 %40 to i32
  %42 = icmp eq i32 %41, 7
  br label %43

43:                                               ; preds = %37, %31
  %44 = phi i1 [ true, %31 ], [ %42, %37 ]
  store i1 %44, ptr %3, align 1
  br label %45

45:                                               ; preds = %43, %30
  %46 = load i1, ptr %3, align 1
  ret i1 %46
}

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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !7, i64 3}
!10 = !{!"_ZTSN7android9Res_valueE", !11, i64 0, !7, i64 2, !7, i64 3, !12, i64 4}
!11 = !{!"short", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !20, i64 312}
!14 = !{!"_ZTSN7android15DynamicRefTableE", !7, i64 8, !7, i64 9, !15, i64 272, !20, i64 312}
!15 = !{!"_ZTSN7android11KeyedVectorINS_8String16EhEE", !16, i64 0}
!16 = !{!"_ZTSN7android12SortedVectorINS_16key_value_pair_tINS_8String16EhEEEE", !17, i64 0}
!17 = !{!"_ZTSN7android16SortedVectorImplE", !18, i64 0}
!18 = !{!"_ZTSN7android10VectorImplE", !6, i64 8, !19, i64 16, !12, i64 24, !19, i64 32}
!19 = !{!"long", !7, i64 0}
!20 = !{!"bool", !7, i64 0}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!10, !12, i64 4}


; 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 noundef zeroext i1 @_ZNK7android15DynamicRefTable14requiresLookupEPKNS_9Res_valueE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(313) %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %1, i64 3
  %4 = load i8, ptr %3, align 1, !tbaa !5
  %.off = add i8 %4, -1
  %switch = icmp ult i8 %.off, 2
  br i1 %switch, label %5, label %13

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 312
  %7 = load i8, ptr %6, align 8, !tbaa !11, !range !20, !noundef !21
  %8 = trunc nuw i8 %7 to i1
  br i1 %8, label %15, label %9

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %1, i64 4
  %11 = load i32, ptr %10, align 4, !tbaa !22
  %12 = icmp ult i32 %11, 16777216
  br i1 %12, label %15, label %13

13:                                               ; preds = %2, %9
  %14 = add i8 %4, -7
  %spec.select = icmp ult i8 %14, 2
  br label %15

15:                                               ; preds = %5, %9, %13
  %.0 = phi i1 [ %spec.select, %13 ], [ true, %9 ], [ true, %5 ]
  ret i1 %.0
}

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, !8, i64 3}
!6 = !{!"_ZTSN7android9Res_valueE", !7, i64 0, !8, i64 2, !8, i64 3, !10, i64 4}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !19, i64 312}
!12 = !{!"_ZTSN7android15DynamicRefTableE", !8, i64 8, !8, i64 9, !13, i64 272, !19, i64 312}
!13 = !{!"_ZTSN7android11KeyedVectorINS_8String16EhEE", !14, i64 0}
!14 = !{!"_ZTSN7android12SortedVectorINS_16key_value_pair_tINS_8String16EhEEEE", !15, i64 0}
!15 = !{!"_ZTSN7android16SortedVectorImplE", !16, i64 0}
!16 = !{!"_ZTSN7android10VectorImplE", !17, i64 8, !18, i64 16, !10, i64 24, !18, i64 32}
!17 = !{!"any pointer", !8, i64 0}
!18 = !{!"long", !8, i64 0}
!19 = !{!"bool", !8, i64 0}
!20 = !{i8 0, i8 2}
!21 = !{}
!22 = !{!6, !10, i64 4}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass