; LLVM IR from facebook/redex :: service/kotlin-instance-rewrite (KotlinInstanceRewriter)

; 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.KotlinInstanceRewriter::Stats" = type { i64, i64, i64, i64, i64 }
%class.anon = type { ptr, ptr, ptr }

; 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 @_ZN22KotlinInstanceRewriter22collect_instance_usageERKSt6vectorIP8DexClassSaIS2_EER13ConcurrentMapIP11DexFieldRefSt3setISt4pairIP13IRInstructionP9DexMethodESt4lessISG_ESaISG_EESt4hashIS9_ESt8equal_toIS9_ELm83EESt8functionIFbS2_EE(ptr dead_on_unwind noalias writable sret(%"struct.KotlinInstanceRewriter::Stats") align 8 %0, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(5984) %3, ptr noundef %4) #1 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca %class.anon, align 8
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  store ptr %4, ptr %9, align 8, !tbaa !5
  %11 = load ptr, ptr %6, align 8
  %12 = getelementptr inbounds %"struct.KotlinInstanceRewriter::Stats", ptr %0, i32 0, i32 0
  store i64 0, ptr %12, align 8, !tbaa !9
  %13 = getelementptr inbounds %"struct.KotlinInstanceRewriter::Stats", ptr %0, i32 0, i32 1
  store i64 0, ptr %13, align 8, !tbaa !12
  %14 = getelementptr inbounds %"struct.KotlinInstanceRewriter::Stats", ptr %0, i32 0, i32 2
  store i64 0, ptr %14, align 8, !tbaa !13
  %15 = getelementptr inbounds %"struct.KotlinInstanceRewriter::Stats", ptr %0, i32 0, i32 3
  store i64 0, ptr %15, align 8, !tbaa !14
  %16 = getelementptr inbounds %"struct.KotlinInstanceRewriter::Stats", ptr %0, i32 0, i32 4
  store i64 0, ptr %16, align 8, !tbaa !15
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #3
  %18 = getelementptr inbounds %class.anon, ptr %10, i32 0, i32 0
  store ptr %11, ptr %18, align 8, !tbaa !16
  %19 = getelementptr inbounds %class.anon, ptr %10, i32 0, i32 1
  store ptr %4, ptr %19, align 8, !tbaa !5
  %20 = getelementptr inbounds %class.anon, ptr %10, i32 0, i32 2
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %21, ptr %20, align 8, !tbaa !5
  %22 = call noundef i64 @_ZN14redex_parallel19default_num_threadsEv()
  call void @"_ZN4walk8parallel7classesISt6vectorIP8DexClassSaIS4_EEZN22KotlinInstanceRewriter22collect_instance_usageERKS6_R13ConcurrentMapIP11DexFieldRefSt3setISt4pairIP13IRInstructionP9DexMethodESt4lessISJ_ESaISJ_EESt4hashISC_ESt8equal_toISC_ELm83EESt8functionIFbS4_EEE3$_0EEvRKT_RKT0_m"(ptr noundef nonnull align 8 dereferenceable(24) %17, ptr noundef nonnull align 8 dereferenceable(24) %10, i64 noundef %22)
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #3
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = call noundef i64 @_ZNK19ConcurrentContainerISt13unordered_mapIP11DexFieldRefSt3setISt4pairIP13IRInstructionP9DexMethodESt4lessIS9_ESaIS9_EESt4hashIS2_ESt8equal_toIS2_ESaIS4_IKS2_SD_EEELm83EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(2664) %23)
  %25 = getelementptr inbounds %"struct.KotlinInstanceRewriter::Stats", ptr %0, i32 0, i32 0
  store i64 %24, ptr %25, align 8, !tbaa !9
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZN4walk8parallel7classesISt6vectorIP8DexClassSaIS4_EEZN22KotlinInstanceRewriter22collect_instance_usageERKS6_R13ConcurrentMapIP11DexFieldRefSt3setISt4pairIP13IRInstructionP9DexMethodESt4lessISJ_ESaISJ_EESt4hashISC_ESt8equal_toISC_ELm83EESt8functionIFbS4_EEE3$_0EEvRKT_RKT0_m"(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZN14redex_parallel19default_num_threadsEv() #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNK19ConcurrentContainerISt13unordered_mapIP11DexFieldRefSt3setISt4pairIP13IRInstructionP9DexMethodESt4lessIS9_ESaIS9_EESt4hashIS2_ESt8equal_toIS2_ESaIS4_IKS2_SD_EEELm83EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(2664)) #1 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 = { inlinehint 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 = { 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, !11, i64 0}
!10 = !{!"_ZTSN22KotlinInstanceRewriter5StatsE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!10, !11, i64 16}
!14 = !{!10, !11, i64 24}
!15 = !{!10, !11, i64 32}
!16 = !{!17, !6, i64 0}
!17 = !{!"_ZTSZN22KotlinInstanceRewriter22collect_instance_usageERKSt6vectorIP8DexClassSaIS2_EER13ConcurrentMapIP11DexFieldRefSt3setISt4pairIP13IRInstructionP9DexMethodESt4lessISG_ESaISG_EESt4hashIS9_ESt8equal_toIS9_ELm83EESt8functionIFbS2_EEE3$_0", !6, i64 0, !6, i64 8, !6, i64 16}


; 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.KotlinInstanceRewriter::Stats" = type { i64, i64, i64, i64, i64 }
%class.anon = type { ptr, ptr, ptr }

; 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 @_ZN22KotlinInstanceRewriter22collect_instance_usageERKSt6vectorIP8DexClassSaIS2_EER13ConcurrentMapIP11DexFieldRefSt3setISt4pairIP13IRInstructionP9DexMethodESt4lessISG_ESaISG_EESt4hashIS9_ESt8equal_toIS9_ELm83EESt8functionIFbS2_EE(ptr dead_on_unwind noalias nocapture writable writeonly sret(%"struct.KotlinInstanceRewriter::Stats") align 8 %0, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(5984) %3, ptr noundef %4) local_unnamed_addr #1 align 2 {
  %6 = alloca %class.anon, align 8
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %7, i8 0, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #4
  store ptr %1, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr %4, ptr %8, align 8, !tbaa !10
  %9 = getelementptr inbounds i8, ptr %6, i64 16
  store ptr %3, ptr %9, align 8, !tbaa !10
  %10 = tail call noundef i64 @_ZN14redex_parallel19default_num_threadsEv()
  call void @"_ZN4walk8parallel7classesISt6vectorIP8DexClassSaIS4_EEZN22KotlinInstanceRewriter22collect_instance_usageERKS6_R13ConcurrentMapIP11DexFieldRefSt3setISt4pairIP13IRInstructionP9DexMethodESt4lessISJ_ESaISJ_EESt4hashISC_ESt8equal_toISC_ELm83EESt8functionIFbS4_EEE3$_0EEvRKT_RKT0_m"(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %10)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #4
  %11 = call noundef i64 @_ZNK19ConcurrentContainerISt13unordered_mapIP11DexFieldRefSt3setISt4pairIP13IRInstructionP9DexMethodESt4lessIS9_ESaIS9_EESt4hashIS2_ESt8equal_toIS2_ESaIS4_IKS2_SD_EEELm83EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(2664) %3)
  store i64 %11, ptr %0, align 8, !tbaa !11
  ret void
}

; Function Attrs: mustprogress uwtable
declare hidden void @"_ZN4walk8parallel7classesISt6vectorIP8DexClassSaIS4_EEZN22KotlinInstanceRewriter22collect_instance_usageERKS6_R13ConcurrentMapIP11DexFieldRefSt3setISt4pairIP13IRInstructionP9DexMethodESt4lessISJ_ESaISJ_EESt4hashISC_ESt8equal_toISC_ELm83EESt8functionIFbS4_EEE3$_0EEvRKT_RKT0_m"(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i64 @_ZN14redex_parallel19default_num_threadsEv() local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNK19ConcurrentContainerISt13unordered_mapIP11DexFieldRefSt3setISt4pairIP13IRInstructionP9DexMethodESt4lessIS9_ESaIS9_EESt4hashIS2_ESt8equal_toIS2_ESaIS4_IKS2_SD_EEELm83EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(2664)) local_unnamed_addr #1 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 0}
!6 = !{!"_ZTSZN22KotlinInstanceRewriter22collect_instance_usageERKSt6vectorIP8DexClassSaIS2_EER13ConcurrentMapIP11DexFieldRefSt3setISt4pairIP13IRInstructionP9DexMethodESt4lessISG_ESaISG_EESt4hashIS9_ESt8equal_toIS9_ELm83EESt8functionIFbS2_EEE3$_0", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTSN22KotlinInstanceRewriter5StatsE", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32}
!13 = !{!"long", !8, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass