; LLVM IR from facebook/redex :: libresource/LocaleData.ll (ZN7android10findParentEjPKc)

; 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.anon = type { [4 x i8], ptr }
%"struct.std::__detail::_Node_const_iterator" = type { %"struct.std::__detail::_Node_iterator_base" }
%"struct.std::__detail::_Node_iterator_base" = type { ptr }
%"struct.std::pair.43" = type { i32, i32 }

@_ZN7androidL14SCRIPT_PARENTSE = external hidden constant [4 x %struct.anon], align 16

; 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 i32 @_ZN7android10findParentEjPKc(i32 noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca %"struct.std::__detail::_Node_const_iterator", align 8
  %10 = alloca %"struct.std::__detail::_Node_const_iterator", align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = call noundef zeroext i1 @_ZN7android9hasRegionEj(i32 noundef %11)
  br i1 %12, label %13, label %55

13:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store i64 0, ptr %6, align 8, !tbaa !11
  br label %14

14:                                               ; preds = %47, %13
  %15 = load i64, ptr %6, align 8, !tbaa !11
  %16 = icmp ult i64 %15, 4
  br i1 %16, label %18, label %17

17:                                               ; preds = %14
  store i32 2, ptr %7, align 4
  br label %50

18:                                               ; preds = %14
  %19 = load ptr, ptr %5, align 8, !tbaa !9
  %20 = load i64, ptr %6, align 8, !tbaa !11
  %21 = getelementptr inbounds [4 x %struct.anon], ptr @_ZN7androidL14SCRIPT_PARENTSE, i64 0, i64 %20
  %22 = getelementptr inbounds %struct.anon, ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds [4 x i8], ptr %22, i64 0, i64 0
  %24 = call i32 @memcmp(ptr noundef %19, ptr noundef %23, i64 noundef 4) #6
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %46

26:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %27 = load i64, ptr %6, align 8, !tbaa !11
  %28 = getelementptr inbounds [4 x %struct.anon], ptr @_ZN7androidL14SCRIPT_PARENTSE, i64 0, i64 %27
  %29 = getelementptr inbounds %struct.anon, ptr %28, i32 0, i32 1
  %30 = load ptr, ptr %29, align 8, !tbaa !13
  store ptr %30, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %31 = load ptr, ptr %8, align 8, !tbaa !9
  %32 = call ptr @_ZNKSt13unordered_mapIjjSt4hashIjESt8equal_toIjESaISt4pairIKjjEEE4findERS5_(ptr noundef nonnull align 8 dereferenceable(56) %31, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %33 = getelementptr inbounds %"struct.std::__detail::_Node_const_iterator", ptr %9, i32 0, i32 0
  %34 = getelementptr inbounds %"struct.std::__detail::_Node_iterator_base", ptr %33, i32 0, i32 0
  store ptr %32, ptr %34, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %35 = load ptr, ptr %8, align 8, !tbaa !9
  %36 = call ptr @_ZNKSt13unordered_mapIjjSt4hashIjESt8equal_toIjESaISt4pairIKjjEEE3endEv(ptr noundef nonnull align 8 dereferenceable(56) %35) #5
  %37 = getelementptr inbounds %"struct.std::__detail::_Node_const_iterator", ptr %10, i32 0, i32 0
  %38 = getelementptr inbounds %"struct.std::__detail::_Node_iterator_base", ptr %37, i32 0, i32 0
  store ptr %36, ptr %38, align 8
  %39 = call noundef zeroext i1 @_ZNSt8__detailneERKNS_19_Node_iterator_baseISt4pairIKjjELb0EEES6_(ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br i1 %39, label %40, label %44

40:                                               ; preds = %26
  %41 = call noundef ptr @_ZNKSt8__detail20_Node_const_iteratorISt4pairIKjjELb0ELb0EEptEv(ptr noundef nonnull align 8 dereferenceable(8) %9) #5
  %42 = getelementptr inbounds %"struct.std::pair.43", ptr %41, i32 0, i32 1
  %43 = load i32, ptr %42, align 4, !tbaa !15
  store i32 %43, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %45

44:                                               ; preds = %26
  store i32 2, ptr %7, align 4
  br label %45

45:                                               ; preds = %44, %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %50

46:                                               ; preds = %18
  br label %47

47:                                               ; preds = %46
  %48 = load i64, ptr %6, align 8, !tbaa !11
  %49 = add i64 %48, 1
  store i64 %49, ptr %6, align 8, !tbaa !11
  br label %14, !llvm.loop !17

50:                                               ; preds = %45, %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %51 = load i32, ptr %7, align 4
  switch i32 %51, label %58 [
    i32 2, label %52
    i32 1, label %56
  ]

52:                                               ; preds = %50
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = call noundef i32 @_ZN7android10dropRegionEj(i32 noundef %53)
  store i32 %54, ptr %3, align 4
  br label %56

55:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  br label %56

56:                                               ; preds = %55, %52, %50
  %57 = load i32, ptr %3, align 4
  ret i32 %57

58:                                               ; preds = %50
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN7android9hasRegionEj(i32 noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local ptr @_ZNKSt13unordered_mapIjjSt4hashIjESt8equal_toIjESaISt4pairIKjjEEE4findERS5_(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 4 dereferenceable(4)) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNKSt13unordered_mapIjjSt4hashIjESt8equal_toIjESaISt4pairIKjjEEE3endEv(ptr noundef nonnull align 8 dereferenceable(56)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt8__detail20_Node_const_iteratorISt4pairIKjjELb0ELb0EEptEv(ptr noundef nonnull align 8 dereferenceable(8)) #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN7android10dropRegionEj(i32 noundef) #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 = { inlinehint 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 #3 = { nounwind willreturn memory(read) "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 = { 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 }
attributes #6 = { nounwind willreturn memory(read) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !10, i64 8}
!14 = !{!"_ZTSN7android3$_0E", !7, i64 0, !10, i64 8}
!15 = !{!16, !6, i64 4}
!16 = !{!"_ZTSSt4pairIKjjE", !6, i64 0, !6, i64 4}
!17 = distinct !{!17, !18}
!18 = !{!"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.anon = type { [4 x i8], ptr }
%"struct.std::__detail::_Node_const_iterator" = type { %"struct.std::__detail::_Node_iterator_base" }
%"struct.std::__detail::_Node_iterator_base" = type { ptr }

@_ZN7androidL14SCRIPT_PARENTSE = external hidden constant [4 x %struct.anon], align 16

; 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 i32 @_ZN7android10findParentEjPKc(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = alloca i32, align 4
  %4 = alloca %"struct.std::__detail::_Node_const_iterator", align 8
  %5 = alloca %"struct.std::__detail::_Node_const_iterator", align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  %6 = tail call noundef zeroext i1 @_ZN7android9hasRegionEj(i32 noundef %0)
  br i1 %6, label %.preheader.preheader, label %23

.preheader.preheader:                             ; preds = %2
  %bcmp = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(4) %1, ptr noundef nonnull dereferenceable(4) @_ZN7androidL14SCRIPT_PARENTSE, i64 4)
  %7 = icmp eq i32 %bcmp, 0
  br i1 %7, label %11, label %.preheader.1

.preheader.1:                                     ; preds = %.preheader.preheader
  %bcmp.1 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(4) %1, ptr noundef nonnull dereferenceable(4) getelementptr inbounds (i8, ptr @_ZN7androidL14SCRIPT_PARENTSE, i64 16), i64 4)
  %8 = icmp eq i32 %bcmp.1, 0
  br i1 %8, label %11, label %.preheader.2

.preheader.2:                                     ; preds = %.preheader.1
  %bcmp.2 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(4) %1, ptr noundef nonnull dereferenceable(4) getelementptr inbounds (i8, ptr @_ZN7androidL14SCRIPT_PARENTSE, i64 32), i64 4)
  %9 = icmp eq i32 %bcmp.2, 0
  br i1 %9, label %11, label %.preheader.3

.preheader.3:                                     ; preds = %.preheader.2
  %bcmp.3 = tail call i32 @bcmp(ptr noundef nonnull dereferenceable(4) %1, ptr noundef nonnull dereferenceable(4) getelementptr inbounds (i8, ptr @_ZN7androidL14SCRIPT_PARENTSE, i64 48), i64 4)
  %10 = icmp eq i32 %bcmp.3, 0
  br i1 %10, label %11, label %.thread

11:                                               ; preds = %.preheader.3, %.preheader.2, %.preheader.1, %.preheader.preheader
  %.lcssa = phi ptr [ @_ZN7androidL14SCRIPT_PARENTSE, %.preheader.preheader ], [ getelementptr inbounds (i8, ptr @_ZN7androidL14SCRIPT_PARENTSE, i64 16), %.preheader.1 ], [ getelementptr inbounds (i8, ptr @_ZN7androidL14SCRIPT_PARENTSE, i64 32), %.preheader.2 ], [ getelementptr inbounds (i8, ptr @_ZN7androidL14SCRIPT_PARENTSE, i64 48), %.preheader.3 ]
  %12 = getelementptr inbounds i8, ptr %.lcssa, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %14 = call ptr @_ZNKSt13unordered_mapIjjSt4hashIjESt8equal_toIjESaISt4pairIKjjEEE4findERS5_(ptr noundef nonnull align 8 dereferenceable(56) %13, ptr noundef nonnull align 4 dereferenceable(4) %3)
  store ptr %14, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %15 = call ptr @_ZNKSt13unordered_mapIjjSt4hashIjESt8equal_toIjESaISt4pairIKjjEEE3endEv(ptr noundef nonnull align 8 dereferenceable(56) %13) #5
  store ptr %15, ptr %5, align 8
  %16 = call noundef zeroext i1 @_ZNSt8__detailneERKNS_19_Node_iterator_baseISt4pairIKjjELb0EEES6_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  br i1 %16, label %17, label %.thread15

.thread15:                                        ; preds = %11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  %.pre = load i32, ptr %3, align 4, !tbaa !5
  br label %.thread

17:                                               ; preds = %11
  %18 = call noundef ptr @_ZNKSt8__detail20_Node_const_iteratorISt4pairIKjjELb0ELb0EEptEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  %19 = getelementptr inbounds i8, ptr %18, i64 4
  %20 = load i32, ptr %19, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %23

.thread:                                          ; preds = %.preheader.3, %.thread15
  %21 = phi i32 [ %.pre, %.thread15 ], [ %0, %.preheader.3 ]
  %22 = call noundef i32 @_ZN7android10dropRegionEj(i32 noundef %21)
  br label %23

23:                                               ; preds = %17, %2, %.thread
  %.2 = phi i32 [ %20, %17 ], [ %22, %.thread ], [ 0, %2 ]
  ret i32 %.2
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN7android9hasRegionEj(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local ptr @_ZNKSt13unordered_mapIjjSt4hashIjESt8equal_toIjESaISt4pairIKjjEEE4findERS5_(ptr noundef nonnull align 8 dereferenceable(56), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNKSt13unordered_mapIjjSt4hashIjESt8equal_toIjESaISt4pairIKjjEEE3endEv(ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNKSt8__detail20_Node_const_iteratorISt4pairIKjjELb0ELb0EEptEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN7android10dropRegionEj(i32 noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #4

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 = { inlinehint 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 #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 = { nofree nounwind willreturn memory(argmem: read) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 8}
!10 = !{!"_ZTSN7android3$_0E", !7, i64 0, !11, i64 8}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !6, i64 4}
!13 = !{!"_ZTSSt4pairIKjjE", !6, i64 0, !6, i64 4}


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