; 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::ResTable_entry" = type { i16, i16, %"struct.android::ResStringPool_ref" }
%"struct.android::ResStringPool_ref" = type { i32 }
%"struct.android::ResTable_map_entry" = type { %"struct.android::ResTable_entry", %"struct.android::ResTable_ref", i32 }
%"struct.android::ResTable_ref" = type { i32 }

; 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 @_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 %4) #1 align 2 {
  %6 = alloca i1, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i64, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  %18 = load ptr, ptr %7, align 8
  %19 = load ptr, ptr %11, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %22, label %21

21:                                               ; preds = %5
  store i1 true, ptr %6, align 1
  br label %107

22:                                               ; preds = %5
  %23 = load ptr, ptr %11, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.android::ResTable_entry", ptr %23, i32 0, i32 1
  %25 = load i16, ptr %24, align 2, !tbaa !9
  %26 = zext i16 %25 to i32
  %27 = and i32 %26, 1
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %84

29:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %30 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %30, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  %31 = load ptr, ptr %12, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.android::ResTable_map_entry", ptr %31, i32 0, i32 2
  %33 = load i32, ptr %32, align 4, !tbaa !14
  store i32 %33, ptr %13, align 4, !tbaa !17
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  %37 = load ptr, ptr %12, align 8, !tbaa !5
  %38 = load ptr, ptr %18, align 8, !tbaa !18
  %39 = getelementptr inbounds ptr, ptr %38, i64 11
  %40 = load ptr, ptr %39, align 8
  %41 = call noundef zeroext i1 %40(ptr noundef nonnull align 8 dereferenceable(24) %18, ptr noundef %34, ptr noundef %35, ptr noundef %36, ptr noundef %37)
  br i1 %41, label %43, label %42

42:                                               ; preds = %29
  store i1 false, ptr %6, align 1
  store i32 1, ptr %14, align 4
  br label %81

43:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  store i64 0, ptr %15, align 8, !tbaa !20
  br label %44

44:                                               ; preds = %75, %43
  %45 = load i64, ptr %15, align 8, !tbaa !20
  %46 = load i32, ptr %13, align 4, !tbaa !17
  %47 = zext i32 %46 to i64
  %48 = icmp ult i64 %45, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %44
  store i32 2, ptr %14, align 4
  br label %78

50:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = load ptr, ptr %11, align 8, !tbaa !5
  %53 = getelementptr inbounds %"struct.android::ResTable_entry", ptr %52, i32 0, i32 0
  %54 = load i16, ptr %53, align 4, !tbaa !22
  %55 = zext i16 %54 to i32
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i8, ptr %51, i64 %56
  %58 = load i64, ptr %15, align 8, !tbaa !20
  %59 = mul i64 %58, 12
  %60 = getelementptr inbounds i8, ptr %57, i64 %59
  store ptr %60, ptr %16, align 8, !tbaa !5
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = load ptr, ptr %10, align 8, !tbaa !5
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  %65 = load ptr, ptr %16, align 8, !tbaa !5
  %66 = load ptr, ptr %18, align 8, !tbaa !18
  %67 = getelementptr inbounds ptr, ptr %66, i64 12
  %68 = load ptr, ptr %67, align 8
  %69 = call noundef zeroext i1 %68(ptr noundef nonnull align 8 dereferenceable(24) %18, ptr noundef %61, ptr noundef %62, ptr noundef %63, ptr noundef %64, ptr noundef %65)
  br i1 %69, label %71, label %70

70:                                               ; preds = %50
  store i1 false, ptr %6, align 1
  store i32 1, ptr %14, align 4
  br label %72

71:                                               ; preds = %50
  store i32 0, ptr %14, align 4
  br label %72

72:                                               ; preds = %71, %70
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  %73 = load i32, ptr %14, align 4
  switch i32 %73, label %78 [
    i32 0, label %74
  ]

74:                                               ; preds = %72
  br label %75

75:                                               ; preds = %74
  %76 = load i64, ptr %15, align 8, !tbaa !20
  %77 = add i64 %76, 1
  store i64 %77, ptr %15, align 8, !tbaa !20
  br label %44, !llvm.loop !23

78:                                               ; preds = %72, %49
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  %79 = load i32, ptr %14, align 4
  switch i32 %79, label %81 [
    i32 2, label %80
  ]

80:                                               ; preds = %78
  store i32 0, ptr %14, align 4
  br label %81

81:                                               ; preds = %80, %78, %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  %82 = load i32, ptr %14, align 4
  switch i32 %82, label %109 [
    i32 0, label %83
    i32 1, label %107
  ]

83:                                               ; preds = %81
  br label %106

84:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #2
  %85 = load ptr, ptr %11, align 8, !tbaa !5
  %86 = load ptr, ptr %11, align 8, !tbaa !5
  %87 = getelementptr inbounds %"struct.android::ResTable_entry", ptr %86, i32 0, i32 0
  %88 = load i16, ptr %87, align 4, !tbaa !22
  %89 = zext i16 %88 to i32
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds i8, ptr %85, i64 %90
  store ptr %91, ptr %17, align 8, !tbaa !5
  %92 = load ptr, ptr %8, align 8, !tbaa !5
  %93 = load ptr, ptr %9, align 8, !tbaa !5
  %94 = load ptr, ptr %10, align 8, !tbaa !5
  %95 = load ptr, ptr %11, align 8, !tbaa !5
  %96 = load ptr, ptr %17, align 8, !tbaa !5
  %97 = load ptr, ptr %18, align 8, !tbaa !18
  %98 = getelementptr inbounds ptr, ptr %97, i64 10
  %99 = load ptr, ptr %98, align 8
  %100 = call noundef zeroext i1 %99(ptr noundef nonnull align 8 dereferenceable(24) %18, ptr noundef %92, ptr noundef %93, ptr noundef %94, ptr noundef %95, ptr noundef %96)
  br i1 %100, label %102, label %101

101:                                              ; preds = %84
  store i1 false, ptr %6, align 1
  store i32 1, ptr %14, align 4
  br label %103

102:                                              ; preds = %84
  store i32 0, ptr %14, align 4
  br label %103

103:                                              ; preds = %102, %101
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #2
  %104 = load i32, ptr %14, align 4
  switch i32 %104, label %109 [
    i32 0, label %105
    i32 1, label %107
  ]

105:                                              ; preds = %103
  br label %106

106:                                              ; preds = %105, %83
  store i1 true, ptr %6, align 1
  br label %107

107:                                              ; preds = %106, %103, %81, %21
  %108 = load i1, ptr %6, align 1
  ret i1 %108

109:                                              ; preds = %103, %81
  unreachable
}

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 = { 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, !11, i64 2}
!10 = !{!"_ZTSN7android14ResTable_entryE", !11, i64 0, !11, i64 2, !12, i64 4}
!11 = !{!"short", !7, i64 0}
!12 = !{!"_ZTSN7android17ResStringPool_refE", !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !13, i64 12}
!15 = !{!"_ZTSN7android18ResTable_map_entryE", !10, i64 0, !16, i64 8, !13, i64 12}
!16 = !{!"_ZTSN7android12ResTable_refE", !13, i64 0}
!17 = !{!13, !13, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"vtable pointer", !8, i64 0}
!20 = !{!21, !21, i64 0}
!21 = !{!"long", !7, i64 0}
!22 = !{!10, !11, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"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"

; Function Attrs: mustprogress uwtable
define dso_local 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 %4) local_unnamed_addr #0 align 2 {
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %.thread, label %6

6:                                                ; preds = %5
  %7 = getelementptr inbounds i8, ptr %4, i64 2
  %8 = load i16, ptr %7, align 2, !tbaa !5
  %9 = and i16 %8, 1
  %.not38 = icmp eq i16 %9, 0
  br i1 %.not38, label %29, label %10

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %4, i64 12
  %12 = load i32, ptr %11, align 4, !tbaa !12
  %13 = load ptr, ptr %0, align 8, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %13, i64 88
  %15 = load ptr, ptr %14, align 8
  %16 = tail call noundef zeroext i1 %15(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef nonnull %4)
  br i1 %16, label %.preheader, label %.thread

.preheader:                                       ; preds = %10
  %17 = zext i32 %12 to i64
  %.not3943.not = icmp eq i32 %12, 0
  br i1 %.not3943.not, label %.loopexit, label %.lr.ph

18:                                               ; preds = %.lr.ph
  %19 = add nuw nsw i64 %.03644, 1
  %exitcond.not = icmp eq i64 %19, %17
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !17

.lr.ph:                                           ; preds = %.preheader, %18
  %.03644 = phi i64 [ %19, %18 ], [ 0, %.preheader ]
  %20 = load i16, ptr %4, align 4, !tbaa !19
  %21 = zext i16 %20 to i64
  %22 = getelementptr inbounds i8, ptr %4, i64 %21
  %23 = mul nuw nsw i64 %.03644, 12
  %24 = getelementptr inbounds i8, ptr %22, i64 %23
  %25 = load ptr, ptr %0, align 8, !tbaa !15
  %26 = getelementptr inbounds i8, ptr %25, i64 96
  %27 = load ptr, ptr %26, align 8
  %28 = tail call noundef zeroext i1 %27(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef nonnull %4, ptr noundef nonnull %24)
  br i1 %28, label %18, label %.thread

29:                                               ; preds = %6
  %30 = load i16, ptr %4, align 4, !tbaa !19
  %31 = zext i16 %30 to i64
  %32 = getelementptr inbounds i8, ptr %4, i64 %31
  %33 = load ptr, ptr %0, align 8, !tbaa !15
  %34 = getelementptr inbounds i8, ptr %33, i64 80
  %35 = load ptr, ptr %34, align 8
  %36 = tail call noundef zeroext i1 %35(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef nonnull %4, ptr noundef nonnull %32)
  br i1 %36, label %.loopexit, label %.thread

.loopexit:                                        ; preds = %18, %.preheader, %29
  br label %.thread

.thread:                                          ; preds = %.lr.ph, %10, %29, %5, %.loopexit
  %.5 = phi i1 [ true, %.loopexit ], [ false, %29 ], [ true, %5 ], [ false, %10 ], [ false, %.lr.ph ]
  ret i1 %.5
}

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

!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, !7, i64 2}
!6 = !{!"_ZTSN7android14ResTable_entryE", !7, i64 0, !7, i64 2, !10, i64 4}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN7android17ResStringPool_refE", !11, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!13, !11, i64 12}
!13 = !{!"_ZTSN7android18ResTable_map_entryE", !6, i64 0, !14, i64 8, !11, i64 12}
!14 = !{!"_ZTSN7android12ResTable_refE", !11, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !9, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!6, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass