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

; 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.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 }

@_ZTVN7android15DynamicRefTableE = external dso_local unnamed_addr constant { [5 x ptr] }, align 8

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7android15DynamicRefTableC2Ehb(ptr noundef nonnull align 8 dereferenceable(313) %0, i8 noundef zeroext %1, i1 noundef zeroext %2) unnamed_addr #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i8 %1, ptr %5, align 1, !tbaa !9
  %7 = zext i1 %2 to i8
  store i8 %7, ptr %6, align 1, !tbaa !10
  %8 = load ptr, ptr %4, align 8
  store ptr getelementptr inbounds inrange(-16, 24) ({ [5 x ptr] }, ptr @_ZTVN7android15DynamicRefTableE, i32 0, i32 0, i32 2), ptr %8, align 8, !tbaa !12
  %9 = getelementptr inbounds %"class.android::DynamicRefTable", ptr %8, i32 0, i32 1
  %10 = load i8, ptr %5, align 1, !tbaa !9
  store i8 %10, ptr %9, align 8, !tbaa !14
  %11 = getelementptr inbounds %"class.android::DynamicRefTable", ptr %8, i32 0, i32 4
  call void @_ZN7android11KeyedVectorINS_8String16EhEC2Ev(ptr noundef nonnull align 8 dereferenceable(40) %11)
  %12 = getelementptr inbounds %"class.android::DynamicRefTable", ptr %8, i32 0, i32 5
  %13 = load i8, ptr %6, align 1, !tbaa !10, !range !22, !noundef !23
  %14 = trunc i8 %13 to i1
  %15 = zext i1 %14 to i8
  store i8 %15, ptr %12, align 8, !tbaa !24
  %16 = getelementptr inbounds %"class.android::DynamicRefTable", ptr %8, i32 0, i32 2
  %17 = getelementptr inbounds [256 x i8], ptr %16, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 1 %17, i8 0, i64 256, i1 false)
  %18 = getelementptr inbounds %"class.android::DynamicRefTable", ptr %8, i32 0, i32 2
  %19 = getelementptr inbounds [256 x i8], ptr %18, i64 0, i64 127
  store i8 127, ptr %19, align 1, !tbaa !9
  %20 = getelementptr inbounds %"class.android::DynamicRefTable", ptr %8, i32 0, i32 2
  %21 = getelementptr inbounds [256 x i8], ptr %20, i64 0, i64 1
  store i8 1, ptr %21, align 1, !tbaa !9
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7android11KeyedVectorINS_8String16EhEC2Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #2 align 2

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

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


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

@_ZTVN7android15DynamicRefTableE = external dso_local unnamed_addr constant { [5 x ptr] }, align 8

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7android15DynamicRefTableC2Ehb(ptr noundef nonnull align 8 dereferenceable(313) %0, i8 noundef zeroext %1, i1 noundef zeroext %2) unnamed_addr #1 align 2 {
  %4 = zext i1 %2 to i8
  store ptr getelementptr inbounds inrange(-16, 24) (i8, ptr @_ZTVN7android15DynamicRefTableE, i64 16), ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  store i8 %1, ptr %5, align 8, !tbaa !8
  %6 = getelementptr inbounds i8, ptr %0, i64 272
  tail call void @_ZN7android11KeyedVectorINS_8String16EhEC2Ev(ptr noundef nonnull align 8 dereferenceable(40) %6)
  %7 = getelementptr inbounds i8, ptr %0, i64 312
  store i8 %4, ptr %7, align 8, !tbaa !19
  %8 = getelementptr inbounds i8, ptr %0, i64 9
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(256) %8, i8 0, i64 256, i1 false)
  %9 = getelementptr inbounds i8, ptr %0, i64 136
  store i8 127, ptr %9, align 8, !tbaa !20
  %10 = getelementptr inbounds i8, ptr %0, i64 10
  store i8 1, ptr %10, align 2, !tbaa !20
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7android11KeyedVectorINS_8String16EhEC2Ev(ptr noundef nonnull align 8 dereferenceable(40)) unnamed_addr #2 align 2

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { inlinehint 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" }

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


; Effective O3 passes: EarlyCSEPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass