; LLVM IR from intel/qpl :: tools/utils/generators/index_table.ll (ZN10IndexTable5resetEjj)

; 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.__gnu_cxx::__normal_iterator" = type { ptr }
%struct.Index = type { i32, i32 }
%class.IndexTable = type <{ %"class.std::vector", i32, i32, i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Index, std::allocator<Index>>::_Vector_impl" }
%"struct.std::_Vector_base<Index, std::allocator<Index>>::_Vector_impl" = type { %"struct.std::_Vector_base<Index, std::allocator<Index>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Index, std::allocator<Index>>::_Vector_impl_data" = 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 @_ZN10IndexTable5resetEjj(ptr noundef nonnull align 8 dereferenceable(36) %0, i32 noundef %1, i32 noundef %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %8 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %9 = alloca %struct.Index, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %10 = load ptr, ptr %4, align 8
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = getelementptr inbounds %class.IndexTable, ptr %10, i32 0, i32 3
  store i32 %11, ptr %12, align 8, !tbaa !11
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = getelementptr inbounds %class.IndexTable, ptr %10, i32 0, i32 2
  store i32 %13, ptr %14, align 4, !tbaa !17
  %15 = getelementptr inbounds %class.IndexTable, ptr %10, i32 0, i32 2
  %16 = load i32, ptr %15, align 4, !tbaa !17
  %17 = getelementptr inbounds %class.IndexTable, ptr %10, i32 0, i32 3
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = add i32 %16, %18
  %20 = sub i32 %19, 1
  %21 = getelementptr inbounds %class.IndexTable, ptr %10, i32 0, i32 3
  %22 = load i32, ptr %21, align 8, !tbaa !11
  %23 = udiv i32 %20, %22
  %24 = getelementptr inbounds %class.IndexTable, ptr %10, i32 0, i32 1
  store i32 %23, ptr %24, align 8, !tbaa !18
  %25 = getelementptr inbounds %class.IndexTable, ptr %10, i32 0, i32 0
  %26 = getelementptr inbounds %class.IndexTable, ptr %10, i32 0, i32 1
  %27 = load i32, ptr %26, align 8, !tbaa !18
  %28 = mul i32 %27, 2
  %29 = getelementptr inbounds %class.IndexTable, ptr %10, i32 0, i32 2
  %30 = load i32, ptr %29, align 4, !tbaa !17
  %31 = add i32 %28, %30
  %32 = add i32 %31, 1
  %33 = zext i32 %32 to i64
  call void @_ZNSt6vectorI5IndexSaIS0_EE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %25, i64 noundef %33)
  %34 = getelementptr inbounds %class.IndexTable, ptr %10, i32 0, i32 0
  %35 = call ptr @_ZNSt6vectorI5IndexSaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %34) #4
  %36 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %7, i32 0, i32 0
  store ptr %35, ptr %36, align 8
  %37 = getelementptr inbounds %class.IndexTable, ptr %10, i32 0, i32 0
  %38 = call ptr @_ZNSt6vectorI5IndexSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %37) #4
  %39 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %8, i32 0, i32 0
  store ptr %38, ptr %39, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %40 = getelementptr inbounds %struct.Index, ptr %9, i32 0, i32 0
  store i32 0, ptr %40, align 4, !tbaa !19
  %41 = getelementptr inbounds %struct.Index, ptr %9, i32 0, i32 1
  store i32 0, ptr %41, align 4, !tbaa !21
  %42 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %7, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8
  %44 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %8, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8
  call void @_ZSt4fillIN9__gnu_cxx17__normal_iteratorIP5IndexSt6vectorIS2_SaIS2_EEEES2_EvT_S8_RKT0_(ptr %43, ptr %45, ptr noundef nonnull align 4 dereferenceable(8) %9)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret void
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIN9__gnu_cxx17__normal_iteratorIP5IndexSt6vectorIS2_SaIS2_EEEES2_EvT_S8_RKT0_(ptr, ptr, ptr noundef nonnull align 4 dereferenceable(8)) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorI5IndexSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) #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 = { 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 = { 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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 32}
!12 = !{!"_ZTS10IndexTable", !13, i64 0, !10, i64 24, !10, i64 28, !10, i64 32}
!13 = !{!"_ZTSSt6vectorI5IndexSaIS0_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseI5IndexSaIS0_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseI5IndexSaIS0_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseI5IndexSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!12, !10, i64 28}
!18 = !{!12, !10, i64 24}
!19 = !{!20, !10, i64 0}
!20 = !{!"_ZTS5Index", !10, i64 0, !10, i64 4}
!21 = !{!20, !10, 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"

%struct.Index = type { i32, i32 }

; 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 @_ZN10IndexTable5resetEjj(ptr noundef nonnull align 8 dereferenceable(36) %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #1 align 2 {
  %4 = alloca %struct.Index, align 4
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 %2, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 %1, ptr %6, align 4, !tbaa !15
  %7 = add i32 %1, -1
  %8 = add i32 %7, %2
  %9 = udiv i32 %8, %2
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %9, ptr %10, align 8, !tbaa !16
  %11 = shl i32 %9, 1
  %12 = add i32 %1, 1
  %13 = add i32 %12, %11
  %14 = zext i32 %13 to i64
  tail call void @_ZNSt6vectorI5IndexSaIS0_EE6resizeEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %14)
  %15 = tail call ptr @_ZNSt6vectorI5IndexSaIS0_EE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  %16 = tail call ptr @_ZNSt6vectorI5IndexSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  store i32 0, ptr %4, align 4, !tbaa !17
  %17 = getelementptr inbounds i8, ptr %4, i64 4
  store i32 0, ptr %17, align 4, !tbaa !19
  call void @_ZSt4fillIN9__gnu_cxx17__normal_iteratorIP5IndexSt6vectorIS2_SaIS2_EEEES2_EvT_S8_RKT0_(ptr %15, ptr %16, ptr noundef nonnull align 4 dereferenceable(8) %4)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  ret void
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4fillIN9__gnu_cxx17__normal_iteratorIP5IndexSt6vectorIS2_SaIS2_EEEES2_EvT_S8_RKT0_(ptr, ptr, ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorI5IndexSaIS0_EE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) local_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 = { 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 = { 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, !14, i64 32}
!6 = !{!"_ZTS10IndexTable", !7, i64 0, !14, i64 24, !14, i64 28, !14, i64 32}
!7 = !{!"_ZTSSt6vectorI5IndexSaIS0_EE", !8, i64 0}
!8 = !{!"_ZTSSt12_Vector_baseI5IndexSaIS0_EE", !9, i64 0}
!9 = !{!"_ZTSNSt12_Vector_baseI5IndexSaIS0_EE12_Vector_implE", !10, i64 0}
!10 = !{!"_ZTSNSt12_Vector_baseI5IndexSaIS0_EE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"int", !12, i64 0}
!15 = !{!6, !14, i64 28}
!16 = !{!6, !14, i64 24}
!17 = !{!18, !14, i64 0}
!18 = !{!"_ZTS5Index", !14, i64 0, !14, i64 4}
!19 = !{!18, !14, i64 4}


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