; LLVM IR from Columbitech/rohc :: src/crtp_profile.ll (ZNK4ROHC11CRTPProfile17CalculateTSStrideEPKNS_6rtphdrE)

; 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.ROHC::rtphdr" = type { i16, i16, i32, i32 }
%"class.ROHC::CRTPProfile" = type <{ %"class.ROHC::CProfile", %"class.std::vector.0", i16, i16, %"struct.ROHC::rtphdr", i32, i32, i32, i32, %"class.ROHC::WLSB.5", i32, i8, [3 x i8] }>
%"class.ROHC::CProfile" = type { ptr, ptr, i16, i64, i32, i32, i32, i32, i64, i64, i32, i32, i16, %"class.ROHC::WLSB", i32, i32, i8, i32, i32, i32, %"struct.ROHC::iphdr", i16, i16, %"class.ROHC::WLSB", [11 x i64] }
%"struct.ROHC::iphdr" = type { i8, i8, i16, i16, i16, i8, i8, i16, i32, i32 }
%"class.ROHC::WLSB" = type { %"class.std::vector", i64, i64, i64, i32, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<ROHC::WLSB<int>::LSB, std::allocator<ROHC::WLSB<int>::LSB>>::_Vector_impl" }
%"struct.std::_Vector_base<ROHC::WLSB<int>::LSB, std::allocator<ROHC::WLSB<int>::LSB>>::_Vector_impl" = type { %"struct.std::_Vector_base<ROHC::WLSB<int>::LSB, std::allocator<ROHC::WLSB<int>::LSB>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ROHC::WLSB<int>::LSB, std::allocator<ROHC::WLSB<int>::LSB>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<ROHC::CRTPProfile::CSRCItem, std::allocator<ROHC::CRTPProfile::CSRCItem>>::_Vector_impl" }
%"struct.std::_Vector_base<ROHC::CRTPProfile::CSRCItem, std::allocator<ROHC::CRTPProfile::CSRCItem>>::_Vector_impl" = type { %"struct.std::_Vector_base<ROHC::CRTPProfile::CSRCItem, std::allocator<ROHC::CRTPProfile::CSRCItem>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ROHC::CRTPProfile::CSRCItem, std::allocator<ROHC::CRTPProfile::CSRCItem>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.ROHC::WLSB.5" = type { %"class.std::vector.6", i64, i64, i64, i32, i32 }
%"class.std::vector.6" = type { %"struct.std::_Vector_base.7" }
%"struct.std::_Vector_base.7" = type { %"struct.std::_Vector_base<ROHC::WLSB<unsigned int>::LSB, std::allocator<ROHC::WLSB<unsigned int>::LSB>>::_Vector_impl" }
%"struct.std::_Vector_base<ROHC::WLSB<unsigned int>::LSB, std::allocator<ROHC::WLSB<unsigned int>::LSB>>::_Vector_impl" = type { %"struct.std::_Vector_base<ROHC::WLSB<unsigned int>::LSB, std::allocator<ROHC::WLSB<unsigned int>::LSB>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ROHC::WLSB<unsigned int>::LSB, std::allocator<ROHC::WLSB<unsigned int>::LSB>>::_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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZN4ROHC10rohc_htonsEt(i16 noundef zeroext) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK4ROHC11CRTPProfile17CalculateTSStrideEPKNS_6rtphdrE(ptr noundef nonnull align 8 dereferenceable(445) %0, ptr noundef %1) #2 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i16, align 2
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = getelementptr inbounds %"struct.ROHC::rtphdr", ptr %9, i32 0, i32 1
  %11 = load i16, ptr %10, align 2, !tbaa !9
  %12 = zext i16 %11 to i32
  %13 = getelementptr inbounds %"class.ROHC::CRTPProfile", ptr %8, i32 0, i32 4
  %14 = getelementptr inbounds %"struct.ROHC::rtphdr", ptr %13, i32 0, i32 1
  %15 = load i16, ptr %14, align 2, !tbaa !13
  %16 = zext i16 %15 to i32
  %17 = icmp eq i32 %12, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  br label %45

19:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #3
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.ROHC::rtphdr", ptr %20, i32 0, i32 1
  %22 = load i16, ptr %21, align 2, !tbaa !9
  %23 = call noundef zeroext i16 @_ZN4ROHC10rohc_htonsEt(i16 noundef zeroext %22)
  %24 = zext i16 %23 to i32
  %25 = getelementptr inbounds %"class.ROHC::CRTPProfile", ptr %8, i32 0, i32 4
  %26 = getelementptr inbounds %"struct.ROHC::rtphdr", ptr %25, i32 0, i32 1
  %27 = load i16, ptr %26, align 2, !tbaa !13
  %28 = call noundef zeroext i16 @_ZN4ROHC10rohc_htonsEt(i16 noundef zeroext %27)
  %29 = zext i16 %28 to i32
  %30 = sub nsw i32 %24, %29
  %31 = trunc i32 %30 to i16
  store i16 %31, ptr %6, align 2, !tbaa !36
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.ROHC::rtphdr", ptr %32, i32 0, i32 2
  %34 = load i32, ptr %33, align 4, !tbaa !37
  %35 = call noundef i32 @_ZN4ROHC10rohc_htonlEj(i32 noundef %34)
  %36 = getelementptr inbounds %"class.ROHC::CRTPProfile", ptr %8, i32 0, i32 4
  %37 = getelementptr inbounds %"struct.ROHC::rtphdr", ptr %36, i32 0, i32 2
  %38 = load i32, ptr %37, align 4, !tbaa !38
  %39 = call noundef i32 @_ZN4ROHC10rohc_htonlEj(i32 noundef %38)
  %40 = sub i32 %35, %39
  store i32 %40, ptr %7, align 4, !tbaa !39
  %41 = load i32, ptr %7, align 4, !tbaa !39
  %42 = load i16, ptr %6, align 2, !tbaa !36
  %43 = zext i16 %42 to i32
  %44 = udiv i32 %41, %43
  store i32 %44, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #3
  br label %45

45:                                               ; preds = %19, %18
  %46 = load i32, ptr %3, align 4
  ret i32 %46
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4ROHC10rohc_htonlEj(i32 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 2}
!10 = !{!"_ZTSN4ROHC6rtphdrE", !7, i64 0, !7, i64 0, !7, i64 0, !7, i64 0, !7, i64 1, !7, i64 1, !11, i64 2, !12, i64 4, !12, i64 8}
!11 = !{!"short", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !11, i64 358}
!14 = !{!"_ZTSN4ROHC11CRTPProfileE", !15, i64 0, !27, i64 328, !11, i64 352, !11, i64 354, !10, i64 356, !12, i64 368, !12, i64 372, !12, i64 376, !12, i64 380, !31, i64 384, !12, i64 440, !24, i64 444}
!15 = !{!"_ZTSN4ROHC8CProfileE", !6, i64 8, !11, i64 16, !16, i64 24, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !16, i64 48, !16, i64 56, !12, i64 64, !12, i64 68, !11, i64 72, !17, i64 80, !22, i64 136, !23, i64 140, !24, i64 144, !25, i64 148, !12, i64 152, !12, i64 156, !26, i64 160, !11, i64 180, !11, i64 182, !17, i64 184, !7, i64 240}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTSN4ROHC4WLSBIiEE", !18, i64 0, !16, i64 24, !16, i64 32, !16, i64 40, !12, i64 48, !12, i64 52}
!18 = !{!"_ZTSSt6vectorIN4ROHC4WLSBIiE3LSBESaIS3_EE", !19, i64 0}
!19 = !{!"_ZTSSt12_Vector_baseIN4ROHC4WLSBIiE3LSBESaIS3_EE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIN4ROHC4WLSBIiE3LSBESaIS3_EE12_Vector_implE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIN4ROHC4WLSBIiE3LSBESaIS3_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!22 = !{!"_ZTSN4ROHC12Reordering_tE", !7, i64 0}
!23 = !{!"_ZTSN4ROHC15IPIDBehaviour_tE", !7, i64 0}
!24 = !{!"bool", !7, i64 0}
!25 = !{!"_ZTSN4ROHC8CProfileUt_E", !7, i64 0}
!26 = !{!"_ZTSN4ROHC5iphdrE", !7, i64 0, !7, i64 0, !7, i64 1, !11, i64 2, !11, i64 4, !11, i64 6, !7, i64 8, !7, i64 9, !11, i64 10, !12, i64 12, !12, i64 16}
!27 = !{!"_ZTSSt6vectorIN4ROHC11CRTPProfile8CSRCItemESaIS2_EE", !28, i64 0}
!28 = !{!"_ZTSSt12_Vector_baseIN4ROHC11CRTPProfile8CSRCItemESaIS2_EE", !29, i64 0}
!29 = !{!"_ZTSNSt12_Vector_baseIN4ROHC11CRTPProfile8CSRCItemESaIS2_EE12_Vector_implE", !30, i64 0}
!30 = !{!"_ZTSNSt12_Vector_baseIN4ROHC11CRTPProfile8CSRCItemESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!31 = !{!"_ZTSN4ROHC4WLSBIjEE", !32, i64 0, !16, i64 24, !16, i64 32, !16, i64 40, !12, i64 48, !12, i64 52}
!32 = !{!"_ZTSSt6vectorIN4ROHC4WLSBIjE3LSBESaIS3_EE", !33, i64 0}
!33 = !{!"_ZTSSt12_Vector_baseIN4ROHC4WLSBIjE3LSBESaIS3_EE", !34, i64 0}
!34 = !{!"_ZTSNSt12_Vector_baseIN4ROHC4WLSBIjE3LSBESaIS3_EE12_Vector_implE", !35, i64 0}
!35 = !{!"_ZTSNSt12_Vector_baseIN4ROHC4WLSBIjE3LSBESaIS3_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!36 = !{!11, !11, i64 0}
!37 = !{!10, !12, i64 4}
!38 = !{!14, !12, i64 360}
!39 = !{!12, !12, i64 0}


; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i16 @_ZN4ROHC10rohc_htonsEt(i16 noundef zeroext) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZNK4ROHC11CRTPProfile17CalculateTSStrideEPKNS_6rtphdrE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(445) %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %1, i64 2
  %4 = load i16, ptr %3, align 2, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 358
  %6 = load i16, ptr %5, align 2, !tbaa !11
  %7 = icmp eq i16 %4, %6
  br i1 %7, label %22, label %8

8:                                                ; preds = %2
  %9 = tail call noundef zeroext i16 @_ZN4ROHC10rohc_htonsEt(i16 noundef zeroext %4)
  %10 = load i16, ptr %5, align 2, !tbaa !11
  %11 = tail call noundef zeroext i16 @_ZN4ROHC10rohc_htonsEt(i16 noundef zeroext %10)
  %12 = sub i16 %9, %11
  %13 = getelementptr inbounds i8, ptr %1, i64 4
  %14 = load i32, ptr %13, align 4, !tbaa !35
  %15 = tail call noundef i32 @_ZN4ROHC10rohc_htonlEj(i32 noundef %14)
  %16 = getelementptr inbounds i8, ptr %0, i64 360
  %17 = load i32, ptr %16, align 8, !tbaa !36
  %18 = tail call noundef i32 @_ZN4ROHC10rohc_htonlEj(i32 noundef %17)
  %19 = sub i32 %15, %18
  %20 = zext i16 %12 to i32
  %21 = udiv i32 %19, %20
  br label %22

22:                                               ; preds = %2, %8
  %.0 = phi i32 [ %21, %8 ], [ 0, %2 ]
  ret i32 %.0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN4ROHC10rohc_htonlEj(i32 noundef) local_unnamed_addr #0

attributes #0 = { 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 #1 = { 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, !9, i64 2}
!6 = !{!"_ZTSN4ROHC6rtphdrE", !7, i64 0, !7, i64 0, !7, i64 0, !7, i64 0, !7, i64 1, !7, i64 1, !9, i64 2, !10, i64 4, !10, i64 8}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"short", !7, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !9, i64 358}
!12 = !{!"_ZTSN4ROHC11CRTPProfileE", !13, i64 0, !26, i64 328, !9, i64 352, !9, i64 354, !6, i64 356, !10, i64 368, !10, i64 372, !10, i64 376, !10, i64 380, !30, i64 384, !10, i64 440, !23, i64 444}
!13 = !{!"_ZTSN4ROHC8CProfileE", !14, i64 8, !9, i64 16, !15, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !15, i64 48, !15, i64 56, !10, i64 64, !10, i64 68, !9, i64 72, !16, i64 80, !21, i64 136, !22, i64 140, !23, i64 144, !24, i64 148, !10, i64 152, !10, i64 156, !25, i64 160, !9, i64 180, !9, i64 182, !16, i64 184, !7, i64 240}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!"_ZTSN4ROHC4WLSBIiEE", !17, i64 0, !15, i64 24, !15, i64 32, !15, i64 40, !10, i64 48, !10, i64 52}
!17 = !{!"_ZTSSt6vectorIN4ROHC4WLSBIiE3LSBESaIS3_EE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseIN4ROHC4WLSBIiE3LSBESaIS3_EE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIN4ROHC4WLSBIiE3LSBESaIS3_EE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIN4ROHC4WLSBIiE3LSBESaIS3_EE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!21 = !{!"_ZTSN4ROHC12Reordering_tE", !7, i64 0}
!22 = !{!"_ZTSN4ROHC15IPIDBehaviour_tE", !7, i64 0}
!23 = !{!"bool", !7, i64 0}
!24 = !{!"_ZTSN4ROHC8CProfileUt_E", !7, i64 0}
!25 = !{!"_ZTSN4ROHC5iphdrE", !7, i64 0, !7, i64 0, !7, i64 1, !9, i64 2, !9, i64 4, !9, i64 6, !7, i64 8, !7, i64 9, !9, i64 10, !10, i64 12, !10, i64 16}
!26 = !{!"_ZTSSt6vectorIN4ROHC11CRTPProfile8CSRCItemESaIS2_EE", !27, i64 0}
!27 = !{!"_ZTSSt12_Vector_baseIN4ROHC11CRTPProfile8CSRCItemESaIS2_EE", !28, i64 0}
!28 = !{!"_ZTSNSt12_Vector_baseIN4ROHC11CRTPProfile8CSRCItemESaIS2_EE12_Vector_implE", !29, i64 0}
!29 = !{!"_ZTSNSt12_Vector_baseIN4ROHC11CRTPProfile8CSRCItemESaIS2_EE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!30 = !{!"_ZTSN4ROHC4WLSBIjEE", !31, i64 0, !15, i64 24, !15, i64 32, !15, i64 40, !10, i64 48, !10, i64 52}
!31 = !{!"_ZTSSt6vectorIN4ROHC4WLSBIjE3LSBESaIS3_EE", !32, i64 0}
!32 = !{!"_ZTSSt12_Vector_baseIN4ROHC4WLSBIjE3LSBESaIS3_EE", !33, i64 0}
!33 = !{!"_ZTSNSt12_Vector_baseIN4ROHC4WLSBIjE3LSBESaIS3_EE12_Vector_implE", !34, i64 0}
!34 = !{!"_ZTSNSt12_Vector_baseIN4ROHC4WLSBIjE3LSBESaIS3_EE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!35 = !{!6, !10, i64 4}
!36 = !{!12, !10, i64 360}


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