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

; 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::ResXMLParser" = type <{ ptr, i32, [4 x i8], ptr, ptr, i32, [4 x i8] }>
%"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_endElementExt" = type { %"struct.android::ResStringPool_ref", %"struct.android::ResStringPool_ref" }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK7android12ResXMLParser16getElementNameIDEv(ptr noundef nonnull align 8 dereferenceable(36) %0) #0 align 2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8
  %5 = getelementptr inbounds %"class.android::ResXMLParser", ptr %4, i32 0, i32 1
  %6 = load i32, ptr %5, align 8, !tbaa !9
  %7 = icmp eq i32 %6, 258
  br i1 %7, label %8, label %14

8:                                                ; preds = %1
  %9 = getelementptr inbounds %"class.android::ResXMLParser", ptr %4, i32 0, i32 4
  %10 = load ptr, ptr %9, align 8, !tbaa !13
  %11 = getelementptr inbounds %"struct.android::ResXMLTree_attrExt", ptr %10, i32 0, i32 1
  %12 = getelementptr inbounds %"struct.android::ResStringPool_ref", ptr %11, i32 0, i32 0
  %13 = load i32, ptr %12, align 4, !tbaa !14
  store i32 %13, ptr %2, align 4
  br label %25

14:                                               ; preds = %1
  %15 = getelementptr inbounds %"class.android::ResXMLParser", ptr %4, i32 0, i32 1
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = icmp eq i32 %16, 259
  br i1 %17, label %18, label %24

18:                                               ; preds = %14
  %19 = getelementptr inbounds %"class.android::ResXMLParser", ptr %4, i32 0, i32 4
  %20 = load ptr, ptr %19, align 8, !tbaa !13
  %21 = getelementptr inbounds %"struct.android::ResXMLTree_endElementExt", ptr %20, i32 0, i32 1
  %22 = getelementptr inbounds %"struct.android::ResStringPool_ref", ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 4, !tbaa !18
  store i32 %23, ptr %2, align 4
  br label %25

24:                                               ; preds = %14
  store i32 -1, ptr %2, align 4
  br label %25

25:                                               ; preds = %24, %18, %8
  %26 = load i32, ptr %2, align 4
  ret i32 %26
}

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

!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 8}
!10 = !{!"_ZTSN7android12ResXMLParserE", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !12, i64 32}
!11 = !{!"_ZTSN7android12ResXMLParser12event_code_tE", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !6, i64 24}
!14 = !{!15, !12, i64 4}
!15 = !{!"_ZTSN7android18ResXMLTree_attrExtE", !16, i64 0, !16, i64 4, !17, i64 8, !17, i64 10, !17, i64 12, !17, i64 14, !17, i64 16, !17, i64 18}
!16 = !{!"_ZTSN7android17ResStringPool_refE", !12, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = !{!19, !12, i64 4}
!19 = !{!"_ZTSN7android24ResXMLTree_endElementExtE", !16, i64 0, !16, i64 4}


; 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 nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef i32 @_ZNK7android12ResXMLParser16getElementNameIDEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(36) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = and i32 %3, -2
  %switch = icmp eq i32 %4, 258
  br i1 %switch, label %.sink.split, label %9

.sink.split:                                      ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %6, i64 4
  %8 = load i32, ptr %7, align 4, !tbaa !13
  br label %9

9:                                                ; preds = %1, %.sink.split
  %.0 = phi i32 [ -1, %1 ], [ %8, %.sink.split ]
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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, !10, i64 8}
!6 = !{!"_ZTSN7android12ResXMLParserE", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 24, !11, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN7android12ResXMLParser12event_code_tE", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !7, i64 24}
!13 = !{!11, !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass