; LLVM IR from facebook/redex :: libresource (Visitor)

; 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::TypeVariant" = type { ptr, i64 }
%"class.android::TypeVariant::iterator" = type <{ ptr, i32, [4 x i8] }>

; 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 @_ZN4arsc20ResourceTableVisitor10visit_typeEPN7android16ResTable_packageEPNS1_17ResTable_typeSpecEPNS1_13ResTable_typeE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) unnamed_addr #1 align 2 {
  %5 = alloca i1, align 1
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %"struct.android::TypeVariant", align 8
  %11 = alloca %"class.android::TypeVariant::iterator", align 8
  %12 = alloca { ptr, i32 }, align 8
  %13 = alloca %"class.android::TypeVariant::iterator", align 8
  %14 = alloca { ptr, i32 }, align 8
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  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
  store ptr %3, ptr %9, align 8, !tbaa !5
  %17 = load ptr, ptr %6, align 8
  br label %18

18:                                               ; preds = %4
  br label %19

19:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #5
  %20 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZN7android11TypeVariantC1EPKNS_13ResTable_typeE(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef %20)
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #5
  %21 = call { ptr, i32 } @_ZNK7android11TypeVariant12beginEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %10)
  store { ptr, i32 } %21, ptr %12, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %12, i64 12, i1 false)
  br label %22

22:                                               ; preds = %38, %19
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #5
  %23 = call { ptr, i32 } @_ZNK7android11TypeVariant10endEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %10)
  store { ptr, i32 } %23, ptr %14, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %14, i64 12, i1 false)
  %24 = call noundef zeroext i1 @_ZNK7android11TypeVariant8iteratorneERKS1_(ptr noundef nonnull align 8 dereferenceable(12) %11, ptr noundef nonnull align 8 dereferenceable(12) %13)
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #5
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  store i32 4, ptr %15, align 4
  br label %40

26:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %27 = call noundef ptr @_ZNK7android11TypeVariant8iteratordeEv(ptr noundef nonnull align 8 dereferenceable(12) %11)
  store ptr %27, ptr %16, align 8, !tbaa !5
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = load ptr, ptr %16, align 8, !tbaa !5
  %32 = call noundef zeroext i1 @_ZN4arsc20ResourceTableVisitor17begin_visit_entryEPN7android16ResTable_packageEPNS1_17ResTable_typeSpecEPNS1_13ResTable_typeEPNS1_14ResTable_entryE(ptr noundef nonnull align 8 dereferenceable(24) %17, ptr noundef %28, ptr noundef %29, ptr noundef %30, ptr noundef %31)
  br i1 %32, label %34, label %33

33:                                               ; preds = %26
  store i1 false, ptr %5, align 1
  store i32 1, ptr %15, align 4
  br label %35

34:                                               ; preds = %26
  store i32 0, ptr %15, align 4
  br label %35

35:                                               ; preds = %34, %33
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  %36 = load i32, ptr %15, align 4
  switch i32 %36, label %40 [
    i32 0, label %37
  ]

37:                                               ; preds = %35
  br label %38

38:                                               ; preds = %37
  %39 = call noundef nonnull align 8 dereferenceable(12) ptr @_ZN7android11TypeVariant8iteratorppEv(ptr noundef nonnull align 8 dereferenceable(12) %11)
  br label %22, !llvm.loop !9

40:                                               ; preds = %35, %25
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #5
  %41 = load i32, ptr %15, align 4
  switch i32 %41, label %43 [
    i32 4, label %42
  ]

42:                                               ; preds = %40
  store i1 true, ptr %5, align 1
  store i32 1, ptr %15, align 4
  br label %43

43:                                               ; preds = %42, %40
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #5
  %44 = load i1, ptr %5, align 1
  ret i1 %44
}

declare void @_ZN7android11TypeVariantC1EPKNS_13ResTable_typeE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i32 } @_ZNK7android11TypeVariant12beginEntriesEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7android11TypeVariant8iteratorneERKS1_(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef nonnull align 8 dereferenceable(12)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i32 } @_ZNK7android11TypeVariant10endEntriesEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

declare noundef ptr @_ZNK7android11TypeVariant8iteratordeEv(ptr noundef nonnull align 8 dereferenceable(12)) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4arsc20ResourceTableVisitor17begin_visit_entryEPN7android16ResTable_packageEPNS1_17ResTable_typeSpecEPNS1_13ResTable_typeEPNS1_14ResTable_entryE(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1 align 2

declare noundef nonnull align 8 dereferenceable(12) ptr @_ZN7android11TypeVariant8iteratorppEv(ptr noundef nonnull align 8 dereferenceable(12)) #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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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 = distinct !{!9, !10}
!10 = !{!"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"

%"struct.android::TypeVariant" = type { ptr, i64 }
%"class.android::TypeVariant::iterator" = type <{ ptr, i32, [4 x i8] }>

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress 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 @_ZN4arsc20ResourceTableVisitor10visit_typeEPN7android16ResTable_packageEPNS1_17ResTable_typeSpecEPNS1_13ResTable_typeE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) unnamed_addr #1 align 2 {
  %5 = alloca %"struct.android::TypeVariant", align 8
  %6 = alloca %"class.android::TypeVariant::iterator", align 8
  %7 = alloca %"class.android::TypeVariant::iterator", align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  call void @_ZN7android11TypeVariantC1EPKNS_13ResTable_typeE(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef %3)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #4
  %8 = call { ptr, i32 } @_ZNK7android11TypeVariant12beginEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  %.fca.0.extract3 = extractvalue { ptr, i32 } %8, 0
  %.fca.1.extract4 = extractvalue { ptr, i32 } %8, 1
  store ptr %.fca.0.extract3, ptr %6, align 8
  %.sroa.26.0..sroa_idx = getelementptr inbounds i8, ptr %6, i64 8
  store i32 %.fca.1.extract4, ptr %.sroa.26.0..sroa_idx, align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #4
  %9 = call { ptr, i32 } @_ZNK7android11TypeVariant10endEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  %.fca.0.extract16 = extractvalue { ptr, i32 } %9, 0
  %.fca.1.extract17 = extractvalue { ptr, i32 } %9, 1
  store ptr %.fca.0.extract16, ptr %7, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %7, i64 8
  store i32 %.fca.1.extract17, ptr %.sroa.2.0..sroa_idx, align 8
  %10 = call noundef zeroext i1 @_ZNK7android11TypeVariant8iteratorneERKS1_(ptr noundef nonnull align 8 dereferenceable(12) %6, ptr noundef nonnull align 8 dereferenceable(12) %7)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #4
  br i1 %10, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %4, %13
  %11 = call noundef ptr @_ZNK7android11TypeVariant8iteratordeEv(ptr noundef nonnull align 8 dereferenceable(12) %6)
  %12 = call noundef zeroext i1 @_ZN4arsc20ResourceTableVisitor17begin_visit_entryEPN7android16ResTable_packageEPNS1_17ResTable_typeSpecEPNS1_13ResTable_typeEPNS1_14ResTable_entryE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %11)
  br i1 %12, label %13, label %17

13:                                               ; preds = %.lr.ph
  %14 = call noundef nonnull align 8 dereferenceable(12) ptr @_ZN7android11TypeVariant8iteratorppEv(ptr noundef nonnull align 8 dereferenceable(12) %6)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #4
  %15 = call { ptr, i32 } @_ZNK7android11TypeVariant10endEntriesEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  %.fca.0.extract = extractvalue { ptr, i32 } %15, 0
  %.fca.1.extract = extractvalue { ptr, i32 } %15, 1
  store ptr %.fca.0.extract, ptr %7, align 8
  store i32 %.fca.1.extract, ptr %.sroa.2.0..sroa_idx, align 8
  %16 = call noundef zeroext i1 @_ZNK7android11TypeVariant8iteratorneERKS1_(ptr noundef nonnull align 8 dereferenceable(12) %6, ptr noundef nonnull align 8 dereferenceable(12) %7)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #4
  br i1 %16, label %.lr.ph, label %.critedge, !llvm.loop !5

17:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  br label %18

.critedge:                                        ; preds = %13, %4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  br label %18

18:                                               ; preds = %17, %.critedge
  %.3 = phi i1 [ false, %17 ], [ true, %.critedge ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  ret i1 %.3
}

declare void @_ZN7android11TypeVariantC1EPKNS_13ResTable_typeE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i32 } @_ZNK7android11TypeVariant12beginEntriesEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK7android11TypeVariant8iteratorneERKS1_(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i32 } @_ZNK7android11TypeVariant10endEntriesEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

declare noundef ptr @_ZNK7android11TypeVariant8iteratordeEv(ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4arsc20ResourceTableVisitor17begin_visit_entryEPN7android16ResTable_packageEPNS1_17ResTable_typeSpecEPNS1_13ResTable_typeEPNS1_14ResTable_entryE(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1 align 2

declare noundef nonnull align 8 dereferenceable(12) ptr @_ZN7android11TypeVariant8iteratorppEv(ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #2

attributes #0 = { mustprogress 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 = { "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 = { 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass