; LLVM IR from facebook/redex :: libresource (Serialize)

; 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.arsc::ResFileManipulator" = type { %"class.std::unordered_map.188", %"class.std::unordered_map.208", ptr, i64 }
%"class.std::unordered_map.188" = type { %"class.std::_Hashtable.189" }
%"class.std::_Hashtable.189" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }
%"class.std::unordered_map.208" = type { %"class.std::_Hashtable.209" }
%"class.std::_Hashtable.209" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.android::ResChunk_header" = type { i16, i16, i32 }
%"struct.android::ResStringPool_header" = type { %"struct.android::ResChunk_header", i32, i32, i32, i32, i32 }

declare i32 @__gxx_personality_v0(...)

; 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 void @_ZN4arsc23replace_xml_string_poolEPN7android15ResChunk_headerEmRNS_20ResStringPoolBuilderEPNS0_6VectorIcEE(ptr noundef %0, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(56) %2, ptr noundef %3) #1 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i16, align 2
  %11 = alloca ptr, align 8
  %12 = alloca %"class.arsc::ResFileManipulator", align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %15, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %10) #4
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.android::ResChunk_header", ptr %16, i32 0, i32 1
  %18 = load i16, ptr %17, align 2, !tbaa !11
  store i16 %18, ptr %10, align 2, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = load i16, ptr %10, align 2, !tbaa !15
  %21 = zext i16 %20 to i32
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds i8, ptr %19, i64 %22
  store ptr %23, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 128, ptr %12) #4
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = load i64, ptr %6, align 8, !tbaa !9
  call void @_ZN4arsc18ResFileManipulatorC2EPcm(ptr noundef nonnull align 8 dereferenceable(128) %12, ptr noundef %24, i64 noundef %25)
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  %27 = load ptr, ptr %11, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.android::ResStringPool_header", ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds %"struct.android::ResChunk_header", ptr %28, i32 0, i32 2
  %30 = load i32, ptr %29, align 4, !tbaa !16
  %31 = zext i32 %30 to i64
  invoke void @_ZN4arsc18ResFileManipulator9delete_atEPvm(ptr noundef nonnull align 8 dereferenceable(128) %12, ptr noundef %26, i64 noundef %31)
          to label %32 unwind label %38

32:                                               ; preds = %4
  %33 = load ptr, ptr %11, align 8, !tbaa !5
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  invoke void @_ZN4arsc18ResFileManipulator19add_serializable_atINS_20ResStringPoolBuilderEEEvPvRT_(ptr noundef nonnull align 8 dereferenceable(128) %12, ptr noundef %33, ptr noundef nonnull align 8 dereferenceable(56) %34)
          to label %35 unwind label %38

35:                                               ; preds = %32
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  invoke void @_ZN4arsc18ResFileManipulator9serializeEPN7android6VectorIcEE(ptr noundef nonnull align 8 dereferenceable(128) %12, ptr noundef %36)
          to label %37 unwind label %38

37:                                               ; preds = %35
  call void @_ZN4arsc18ResFileManipulatorD2Ev(ptr noundef nonnull align 8 dereferenceable(128) %12) #4
  call void @llvm.lifetime.end.p0(i64 128, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret void

38:                                               ; preds = %35, %32, %4
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %13, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %14, align 4
  call void @_ZN4arsc18ResFileManipulatorD2Ev(ptr noundef nonnull align 8 dereferenceable(128) %12) #4
  call void @llvm.lifetime.end.p0(i64 128, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 2, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %42

42:                                               ; preds = %38
  %43 = load ptr, ptr %13, align 8
  %44 = load i32, ptr %14, align 4
  %45 = insertvalue { ptr, i32 } poison, ptr %43, 0
  %46 = insertvalue { ptr, i32 } %45, i32 %44, 1
  resume { ptr, i32 } %46
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4arsc18ResFileManipulatorC2EPcm(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef, i64 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4arsc18ResFileManipulator9delete_atEPvm(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef, i64 noundef) #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4arsc18ResFileManipulator9serializeEPN7android6VectorIcEE(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4arsc18ResFileManipulatorD2Ev(ptr noundef nonnull align 8 dereferenceable(128)) unnamed_addr #3 align 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 = { 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 = { 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 #4 = { 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !13, i64 2}
!12 = !{!"_ZTSN7android15ResChunk_headerE", !13, i64 0, !13, i64 2, !14, i64 4}
!13 = !{!"short", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!13, !13, i64 0}
!16 = !{!17, !14, i64 4}
!17 = !{!"_ZTSN7android20ResStringPool_headerE", !12, i64 0, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20, !14, i64 24}


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

%"class.arsc::ResFileManipulator" = type { %"class.std::unordered_map.188", %"class.std::unordered_map.208", ptr, i64 }
%"class.std::unordered_map.188" = type { %"class.std::_Hashtable.189" }
%"class.std::_Hashtable.189" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }
%"struct.std::__detail::_Hash_node_base" = type { ptr }
%"struct.std::__detail::_Prime_rehash_policy" = type { float, i64 }
%"class.std::unordered_map.208" = type { %"class.std::_Hashtable.209" }
%"class.std::_Hashtable.209" = type { ptr, i64, %"struct.std::__detail::_Hash_node_base", i64, %"struct.std::__detail::_Prime_rehash_policy", ptr }

declare i32 @__gxx_personality_v0(...)

; 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 void @_ZN4arsc23replace_xml_string_poolEPN7android15ResChunk_headerEmRNS_20ResStringPoolBuilderEPNS0_6VectorIcEE(ptr noundef %0, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(56) %2, ptr noundef %3) local_unnamed_addr #1 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.arsc::ResFileManipulator", align 8
  %6 = getelementptr inbounds i8, ptr %0, i64 2
  %7 = load i16, ptr %6, align 2, !tbaa !5
  %8 = zext i16 %7 to i64
  %9 = getelementptr inbounds i8, ptr %0, i64 %8
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %5) #4
  call void @_ZN4arsc18ResFileManipulatorC2EPcm(ptr noundef nonnull align 8 dereferenceable(128) %5, ptr noundef %0, i64 noundef %1)
  %10 = getelementptr inbounds i8, ptr %9, i64 4
  %11 = load i32, ptr %10, align 4, !tbaa !11
  %12 = zext i32 %11 to i64
  invoke void @_ZN4arsc18ResFileManipulator9delete_atEPvm(ptr noundef nonnull align 8 dereferenceable(128) %5, ptr noundef nonnull %9, i64 noundef %12)
          to label %13 unwind label %16

13:                                               ; preds = %4
  invoke void @_ZN4arsc18ResFileManipulator19add_serializable_atINS_20ResStringPoolBuilderEEEvPvRT_(ptr noundef nonnull align 8 dereferenceable(128) %5, ptr noundef nonnull %9, ptr noundef nonnull align 8 dereferenceable(56) %2)
          to label %14 unwind label %16

14:                                               ; preds = %13
  invoke void @_ZN4arsc18ResFileManipulator9serializeEPN7android6VectorIcEE(ptr noundef nonnull align 8 dereferenceable(128) %5, ptr noundef %3)
          to label %15 unwind label %16

15:                                               ; preds = %14
  call void @_ZN4arsc18ResFileManipulatorD2Ev(ptr noundef nonnull align 8 dereferenceable(128) %5) #4
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %5) #4
  ret void

16:                                               ; preds = %14, %13, %4
  %17 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN4arsc18ResFileManipulatorD2Ev(ptr noundef nonnull align 8 dereferenceable(128) %5) #4
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %5) #4
  resume { ptr, i32 } %17
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4arsc18ResFileManipulatorC2EPcm(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef, i64 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4arsc18ResFileManipulator9delete_atEPvm(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef, i64 noundef) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4arsc18ResFileManipulator9serializeEPN7android6VectorIcEE(ptr noundef nonnull align 8 dereferenceable(128), ptr noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4arsc18ResFileManipulatorD2Ev(ptr noundef nonnull align 8 dereferenceable(128)) unnamed_addr #3 align 2

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 = { 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 = { 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 #4 = { 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, !7, i64 2}
!6 = !{!"_ZTSN7android15ResChunk_headerE", !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 = !{!"int", !8, i64 0}
!11 = !{!12, !10, i64 4}
!12 = !{!"_ZTSN7android20ResStringPool_headerE", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24}


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