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

; 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::ResXMLTree" = type <{ %"class.android::ResXMLParser.base", [4 x i8], %"class.std::shared_ptr", i32, [4 x i8], ptr, ptr, i64, ptr, %"class.android::ResStringPool", ptr, i64, ptr, ptr, i32, [4 x i8] }>
%"class.android::ResXMLParser.base" = type <{ ptr, i32, [4 x i8], ptr, ptr, i32 }>
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.android::ResStringPool" = type <{ ptr, i32, [4 x i8], ptr, ptr, i64, %"class.std::mutex", ptr, ptr, ptr, ptr, i32, [4 x i8], ptr, i32, [4 x i8] }>
%"class.std::mutex" = type { %"class.std::__mutex_base" }
%"class.std::__mutex_base" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7android13ResStringPool6uninitEv(ptr noundef nonnull align 8 dereferenceable(132)) #0 align 2

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7android12ResXMLParser7restartEv(ptr noundef nonnull align 8 dereferenceable(36)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7android10ResXMLTree6uninitEv(ptr noundef nonnull align 8 dereferenceable(268) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %"class.android::ResXMLTree", ptr %3, i32 0, i32 3
  store i32 -19, ptr %4, align 8, !tbaa !9
  %5 = getelementptr inbounds %"class.android::ResXMLTree", ptr %3, i32 0, i32 9
  call void @_ZN7android13ResStringPool6uninitEv(ptr noundef nonnull align 8 dereferenceable(132) %5)
  %6 = getelementptr inbounds %"class.android::ResXMLTree", ptr %3, i32 0, i32 5
  %7 = load ptr, ptr %6, align 8, !tbaa !21
  %8 = icmp ne ptr %7, null
  br i1 %8, label %9, label %13

9:                                                ; preds = %1
  %10 = getelementptr inbounds %"class.android::ResXMLTree", ptr %3, i32 0, i32 5
  %11 = load ptr, ptr %10, align 8, !tbaa !21
  call void @free(ptr noundef %11) #2
  %12 = getelementptr inbounds %"class.android::ResXMLTree", ptr %3, i32 0, i32 5
  store ptr null, ptr %12, align 8, !tbaa !21
  br label %13

13:                                               ; preds = %9, %1
  call void @_ZN7android12ResXMLParser7restartEv(ptr noundef nonnull align 8 dereferenceable(36) %3)
  ret void
}

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 = { 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 = { 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 56}
!10 = !{!"_ZTSN7android10ResXMLTreeE", !11, i64 0, !14, i64 40, !13, i64 56, !6, i64 64, !6, i64 72, !17, i64 80, !6, i64 88, !18, i64 96, !6, i64 232, !17, i64 240, !6, i64 248, !6, i64 256, !12, i64 264}
!11 = !{!"_ZTSN7android12ResXMLParserE", !6, i64 0, !12, i64 8, !6, i64 16, !6, i64 24, !13, i64 32}
!12 = !{!"_ZTSN7android12ResXMLParser12event_code_tE", !7, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSSt10shared_ptrIKN7android15DynamicRefTableEE", !15, i64 0}
!15 = !{!"_ZTSSt12__shared_ptrIKN7android15DynamicRefTableELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !16, i64 8}
!16 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!"_ZTSN7android13ResStringPoolE", !13, i64 8, !6, i64 16, !6, i64 24, !17, i64 32, !19, i64 40, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !13, i64 112, !6, i64 120, !13, i64 128}
!19 = !{!"_ZTSSt5mutex", !20, i64 0}
!20 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!21 = !{!10, !6, i64 64}


; 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 nounwind uwtable
declare dso_local void @_ZN7android13ResStringPool6uninitEv(ptr noundef nonnull align 8 dereferenceable(132)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7android12ResXMLParser7restartEv(ptr noundef nonnull align 8 dereferenceable(36)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN7android10ResXMLTree6uninitEv(ptr noundef nonnull align 8 dereferenceable(268) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 56
  store i32 -19, ptr %2, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 96
  tail call void @_ZN7android13ResStringPool6uninitEv(ptr noundef nonnull align 8 dereferenceable(132) %3)
  %4 = getelementptr inbounds i8, ptr %0, i64 64
  %5 = load ptr, ptr %4, align 8, !tbaa !20
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %7, label %6

6:                                                ; preds = %1
  tail call void @free(ptr noundef nonnull %5) #2
  store ptr null, ptr %4, align 8, !tbaa !20
  br label %7

7:                                                ; preds = %6, %1
  tail call void @_ZN7android12ResXMLParser7restartEv(ptr noundef nonnull align 8 dereferenceable(36) %0)
  ret void
}

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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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, !12, i64 56}
!6 = !{!"_ZTSN7android10ResXMLTreeE", !7, i64 0, !13, i64 40, !12, i64 56, !8, i64 64, !8, i64 72, !16, i64 80, !8, i64 88, !17, i64 96, !8, i64 232, !16, i64 240, !8, i64 248, !8, i64 256, !11, i64 264}
!7 = !{!"_ZTSN7android12ResXMLParserE", !8, i64 0, !11, i64 8, !8, i64 16, !8, i64 24, !12, i64 32}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN7android12ResXMLParser12event_code_tE", !9, i64 0}
!12 = !{!"int", !9, i64 0}
!13 = !{!"_ZTSSt10shared_ptrIKN7android15DynamicRefTableEE", !14, i64 0}
!14 = !{!"_ZTSSt12__shared_ptrIKN7android15DynamicRefTableELN9__gnu_cxx12_Lock_policyE2EE", !8, i64 0, !15, i64 8}
!15 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !8, i64 0}
!16 = !{!"long", !9, i64 0}
!17 = !{!"_ZTSN7android13ResStringPoolE", !12, i64 8, !8, i64 16, !8, i64 24, !16, i64 32, !18, i64 40, !8, i64 80, !8, i64 88, !8, i64 96, !8, i64 104, !12, i64 112, !8, i64 120, !12, i64 128}
!18 = !{!"_ZTSSt5mutex", !19, i64 0}
!19 = !{!"_ZTSSt12__mutex_base", !9, i64 0}
!20 = !{!6, !8, i64 64}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass