; 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::ResXMLTree_attrExt" = type { %"struct.android::ResStringPool_ref", %"struct.android::ResStringPool_ref", i16, i16, i16, i16, i16, i16 }
%"struct.android::ResStringPool_ref" = type { i32 }
%"struct.android::ResXMLTree_attribute" = type { %"struct.android::ResStringPool_ref", %"struct.android::ResStringPool_ref", %"struct.android::ResStringPool_ref", %"struct.android::Res_value" }
%"struct.android::Res_value" = type { i16, i8, i8, i32 }

@stderr = external global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [63 x i8], align 1

; 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 nounwind uwtable
declare dso_local noundef ptr @_ZN4arsc21get_attribute_pointerEPN7android18ResXMLTree_attrExtE(ptr noundef) #1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4arsc14XmlFileVisitor15visit_start_tagEPN7android15ResXMLTree_nodeEPNS1_18ResXMLTree_attrExtE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1, ptr noundef %2) unnamed_addr #3 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i16, align 2
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8
  br label %13

13:                                               ; preds = %3
  br label %14

14:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 2, ptr %8) #5
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.android::ResXMLTree_attrExt", ptr %15, i32 0, i32 4
  %17 = load i16, ptr %16, align 4, !tbaa !9
  store i16 %17, ptr %8, align 2, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = call noundef ptr @_ZN4arsc21get_attribute_pointerEPN7android18ResXMLTree_attrExtE(ptr noundef %18)
  store ptr %19, ptr %9, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %14
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.android::ResXMLTree_attrExt", ptr %21, i32 0, i32 3
  %23 = load i16, ptr %22, align 2, !tbaa !15
  %24 = zext i16 %23 to i64
  %25 = icmp ne i64 %24, 20
  br i1 %25, label %26, label %45

26:                                               ; preds = %20
  br label %27

27:                                               ; preds = %26
  %28 = load ptr, ptr @stderr, align 8, !tbaa !5
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %28, ptr noundef @.str.29) #5
  %30 = load ptr, ptr @stderr, align 8, !tbaa !5
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef @.str.30) #5
  %32 = load ptr, ptr @stderr, align 8, !tbaa !5
  %33 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef @.str.5) #5
  br label %34

34:                                               ; preds = %27
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  %37 = load ptr, ptr @stderr, align 8, !tbaa !5
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %37, ptr noundef @.str.29) #5
  %39 = load ptr, ptr @stderr, align 8, !tbaa !5
  %40 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %39, ptr noundef @.str.31) #5
  %41 = load ptr, ptr @stderr, align 8, !tbaa !5
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %41, ptr noundef @.str.5) #5
  br label %43

43:                                               ; preds = %36
  br label %44

44:                                               ; preds = %43
  call void @abort() #6
  unreachable

45:                                               ; preds = %20
  br label %46

46:                                               ; preds = %45
  br label %47

47:                                               ; preds = %46
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %"struct.android::ResXMLTree_attrExt", ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %12, align 8, !tbaa !16
  %51 = getelementptr inbounds ptr, ptr %50, i64 13
  %52 = load ptr, ptr %51, align 8
  %53 = call noundef zeroext i1 %52(ptr noundef nonnull align 8 dereferenceable(24) %12, ptr noundef %49)
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %"struct.android::ResXMLTree_attrExt", ptr %54, i32 0, i32 1
  %56 = load ptr, ptr %12, align 8, !tbaa !16
  %57 = getelementptr inbounds ptr, ptr %56, i64 13
  %58 = load ptr, ptr %57, align 8
  %59 = call noundef zeroext i1 %58(ptr noundef nonnull align 8 dereferenceable(24) %12, ptr noundef %55)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  store i64 0, ptr %10, align 8, !tbaa !18
  br label %60

60:                                               ; preds = %77, %47
  %61 = load i64, ptr %10, align 8, !tbaa !18
  %62 = load i16, ptr %8, align 2, !tbaa !14
  %63 = zext i16 %62 to i64
  %64 = icmp ult i64 %61, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %60
  store i32 10, ptr %11, align 4
  br label %80

66:                                               ; preds = %60
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = getelementptr inbounds %"struct.android::ResXMLTree_attribute", ptr %69, i32 1
  store ptr %70, ptr %9, align 8, !tbaa !5
  %71 = load ptr, ptr %12, align 8, !tbaa !16
  %72 = getelementptr inbounds ptr, ptr %71, i64 10
  %73 = load ptr, ptr %72, align 8
  %74 = call noundef zeroext i1 %73(ptr noundef nonnull align 8 dereferenceable(24) %12, ptr noundef %67, ptr noundef %68, ptr noundef %69)
  br i1 %74, label %76, label %75

75:                                               ; preds = %66
  store i1 false, ptr %4, align 1
  store i32 1, ptr %11, align 4
  br label %80

76:                                               ; preds = %66
  br label %77

77:                                               ; preds = %76
  %78 = load i64, ptr %10, align 8, !tbaa !18
  %79 = add i64 %78, 1
  store i64 %79, ptr %10, align 8, !tbaa !18
  br label %60, !llvm.loop !20

80:                                               ; preds = %75, %65
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %81 = load i32, ptr %11, align 4
  switch i32 %81, label %83 [
    i32 10, label %82
  ]

82:                                               ; preds = %80
  store i1 true, ptr %4, align 1
  store i32 1, ptr %11, align 4
  br label %83

83:                                               ; preds = %82, %80
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #5
  %84 = load i1, ptr %4, align 1
  ret i1 %84
}

; Function Attrs: noreturn nounwind
declare void @abort() #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nounwind "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 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 = { noreturn nounwind "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 }
attributes #6 = { noreturn 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, !13, i64 12}
!10 = !{!"_ZTSN7android18ResXMLTree_attrExtE", !11, i64 0, !11, i64 4, !13, i64 8, !13, i64 10, !13, i64 12, !13, i64 14, !13, i64 16, !13, i64 18}
!11 = !{!"_ZTSN7android17ResStringPool_refE", !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!10, !13, i64 10}
!16 = !{!17, !17, i64 0}
!17 = !{!"vtable pointer", !8, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"long", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [63 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN4arsc21get_attribute_pointerEPN7android18ResXMLTree_attrExtE(ptr noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4arsc14XmlFileVisitor15visit_start_tagEPN7android15ResXMLTree_nodeEPNS1_18ResXMLTree_attrExtE(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1, ptr noundef %2) unnamed_addr #2 align 2 {
  %4 = getelementptr inbounds i8, ptr %2, i64 12
  %5 = load i16, ptr %4, align 4, !tbaa !5
  %6 = tail call noundef ptr @_ZN4arsc21get_attribute_pointerEPN7android18ResXMLTree_attrExtE(ptr noundef %2)
  %7 = getelementptr inbounds i8, ptr %2, i64 10
  %8 = load i16, ptr %7, align 2, !tbaa !12
  %.not = icmp eq i16 %8, 20
  br i1 %.not, label %22, label %9

9:                                                ; preds = %3
  %10 = load ptr, ptr @stderr, align 8, !tbaa !13
  %11 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %10, ptr noundef nonnull @.str.29) #4
  %12 = load ptr, ptr @stderr, align 8, !tbaa !13
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %12, ptr noundef nonnull @.str.30) #4
  %14 = load ptr, ptr @stderr, align 8, !tbaa !13
  %15 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.5) #4
  %16 = load ptr, ptr @stderr, align 8, !tbaa !13
  %17 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.29) #4
  %18 = load ptr, ptr @stderr, align 8, !tbaa !13
  %19 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %18, ptr noundef nonnull @.str.31) #4
  %20 = load ptr, ptr @stderr, align 8, !tbaa !13
  %21 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %20, ptr noundef nonnull @.str.5) #4
  tail call void @abort() #5
  unreachable

22:                                               ; preds = %3
  %23 = load ptr, ptr %0, align 8, !tbaa !15
  %24 = getelementptr inbounds i8, ptr %23, i64 104
  %25 = load ptr, ptr %24, align 8
  %26 = tail call noundef zeroext i1 %25(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull %2)
  %27 = getelementptr inbounds i8, ptr %2, i64 4
  %28 = load ptr, ptr %0, align 8, !tbaa !15
  %29 = getelementptr inbounds i8, ptr %28, i64 104
  %30 = load ptr, ptr %29, align 8
  %31 = tail call noundef zeroext i1 %30(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull %27)
  %32 = zext i16 %5 to i64
  %.not1617 = icmp eq i16 %5, 0
  br i1 %.not1617, label %.critedge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %22
  %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 %6)
  br i1 %36, label %.lr.ph25, label %.critedge

.lr.ph:                                           ; preds = %.lr.ph25
  %37 = getelementptr inbounds i8, ptr %.0141824, i64 20
  %38 = load ptr, ptr %0, align 8, !tbaa !15
  %39 = getelementptr inbounds i8, ptr %38, i64 80
  %40 = load ptr, ptr %39, align 8
  %41 = tail call noundef zeroext i1 %40(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1, ptr noundef %2, ptr noundef nonnull %37)
  br i1 %41, label %.lr.ph25, label %.critedge.loopexit, !llvm.loop !17

.lr.ph25:                                         ; preds = %.lr.ph.preheader, %.lr.ph
  %.0141824 = phi ptr [ %37, %.lr.ph ], [ %6, %.lr.ph.preheader ]
  %.0131923 = phi i64 [ %42, %.lr.ph ], [ 0, %.lr.ph.preheader ]
  %42 = add nuw nsw i64 %.0131923, 1
  %exitcond = icmp eq i64 %42, %32
  br i1 %exitcond, label %.critedge.loopexit, label %.lr.ph, !llvm.loop !17

.critedge.loopexit:                               ; preds = %.lr.ph, %.lr.ph25
  %.not16.le = icmp uge i64 %42, %32
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %.lr.ph.preheader, %22
  %.not16.lcssa = phi i1 [ true, %22 ], [ false, %.lr.ph.preheader ], [ %.not16.le, %.critedge.loopexit ]
  ret i1 %.not16.lcssa
}

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #3

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" }
attributes #1 = { nofree nounwind "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 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 = { noreturn nounwind "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 = { cold nounwind }
attributes #5 = { noreturn 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, !11, i64 12}
!6 = !{!"_ZTSN7android18ResXMLTree_attrExtE", !7, i64 0, !7, i64 4, !11, i64 8, !11, i64 10, !11, i64 12, !11, i64 14, !11, i64 16, !11, i64 18}
!7 = !{!"_ZTSN7android17ResStringPool_refE", !8, i64 0}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"short", !9, i64 0}
!12 = !{!6, !11, i64 10}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !9, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !10, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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