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

; 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.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 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4ROHC11CRTPProfile12AdvanceStateEbb(ptr noundef nonnull align 8 dereferenceable(445) %0, i1 noundef zeroext %1, i1 noundef zeroext %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  store ptr %0, ptr %4, align 8, !tbaa !5
  %7 = zext i1 %1 to i8
  store i8 %7, ptr %5, align 1, !tbaa !9
  %8 = zext i1 %2 to i8
  store i8 %8, ptr %6, align 1, !tbaa !9
  %9 = load ptr, ptr %4, align 8
  %10 = getelementptr inbounds %"class.ROHC::CProfile", ptr %9, i32 0, i32 17
  %11 = load i32, ptr %10, align 4, !tbaa !11
  %12 = icmp eq i32 0, %11
  br i1 %12, label %13, label %32

13:                                               ; preds = %3
  %14 = load i8, ptr %5, align 1, !tbaa !9, !range !25, !noundef !26
  %15 = trunc i8 %14 to i1
  br i1 %15, label %16, label %21

16:                                               ; preds = %13
  %17 = load i8, ptr %6, align 1, !tbaa !9, !range !25, !noundef !26
  %18 = trunc i8 %17 to i1
  br i1 %18, label %19, label %21

19:                                               ; preds = %16
  %20 = getelementptr inbounds %"class.ROHC::CProfile", ptr %9, i32 0, i32 17
  store i32 1, ptr %20, align 4, !tbaa !11
  br label %31

21:                                               ; preds = %16, %13
  %22 = getelementptr inbounds %"class.ROHC::CProfile", ptr %9, i32 0, i32 10
  %23 = load i32, ptr %22, align 8, !tbaa !27
  %24 = getelementptr inbounds %"class.ROHC::CProfile", ptr %9, i32 0, i32 1
  %25 = load ptr, ptr %24, align 8, !tbaa !28
  %26 = call noundef i32 @_ZNK4ROHC10Compressor23NumberOfIRPacketsToSendEv(ptr noundef nonnull align 8 dereferenceable(368) %25)
  %27 = icmp uge i32 %23, %26
  br i1 %27, label %28, label %30

28:                                               ; preds = %21
  %29 = getelementptr inbounds %"class.ROHC::CProfile", ptr %9, i32 0, i32 17
  store i32 1, ptr %29, align 4, !tbaa !11
  br label %30

30:                                               ; preds = %28, %21
  br label %31

31:                                               ; preds = %30, %19
  br label %62

32:                                               ; preds = %3
  %33 = getelementptr inbounds %"class.ROHC::CProfile", ptr %9, i32 0, i32 17
  %34 = load i32, ptr %33, align 4, !tbaa !11
  %35 = icmp eq i32 1, %34
  br i1 %35, label %36, label %55

36:                                               ; preds = %32
  %37 = load i8, ptr %5, align 1, !tbaa !9, !range !25, !noundef !26
  %38 = trunc i8 %37 to i1
  br i1 %38, label %39, label %44

39:                                               ; preds = %36
  %40 = load i8, ptr %6, align 1, !tbaa !9, !range !25, !noundef !26
  %41 = trunc i8 %40 to i1
  br i1 %41, label %42, label %44

42:                                               ; preds = %39
  %43 = getelementptr inbounds %"class.ROHC::CProfile", ptr %9, i32 0, i32 17
  store i32 2, ptr %43, align 4, !tbaa !11
  br label %54

44:                                               ; preds = %39, %36
  %45 = getelementptr inbounds %"class.ROHC::CProfile", ptr %9, i32 0, i32 11
  %46 = load i32, ptr %45, align 4, !tbaa !29
  %47 = getelementptr inbounds %"class.ROHC::CProfile", ptr %9, i32 0, i32 1
  %48 = load ptr, ptr %47, align 8, !tbaa !28
  %49 = call noundef i32 @_ZNK4ROHC10Compressor23NumberOfFOPacketsToSendEv(ptr noundef nonnull align 8 dereferenceable(368) %48)
  %50 = icmp uge i32 %46, %49
  br i1 %50, label %51, label %53

51:                                               ; preds = %44
  %52 = getelementptr inbounds %"class.ROHC::CProfile", ptr %9, i32 0, i32 17
  store i32 2, ptr %52, align 4, !tbaa !11
  br label %53

53:                                               ; preds = %51, %44
  br label %54

54:                                               ; preds = %53, %42
  br label %61

55:                                               ; preds = %32
  %56 = getelementptr inbounds %"class.ROHC::CProfile", ptr %9, i32 0, i32 17
  %57 = load i32, ptr %56, align 4, !tbaa !11
  %58 = icmp eq i32 2, %57
  br i1 %58, label %59, label %60

59:                                               ; preds = %55
  br label %60

60:                                               ; preds = %59, %55
  br label %61

61:                                               ; preds = %60, %54
  br label %62

62:                                               ; preds = %61, %31
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4ROHC10Compressor23NumberOfIRPacketsToSendEv(ptr noundef nonnull align 8 dereferenceable(368)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4ROHC10Compressor23NumberOfFOPacketsToSendEv(ptr noundef nonnull align 8 dereferenceable(368)) #1 align 2

attributes #0 = { 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 #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, !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 = !{!"bool", !7, i64 0}
!11 = !{!12, !23, i64 148}
!12 = !{!"_ZTSN4ROHC8CProfileE", !6, i64 8, !13, i64 16, !14, i64 24, !15, i64 32, !15, i64 36, !15, i64 40, !15, i64 44, !14, i64 48, !14, i64 56, !15, i64 64, !15, i64 68, !13, i64 72, !16, i64 80, !21, i64 136, !22, i64 140, !10, i64 144, !23, i64 148, !15, i64 152, !15, i64 156, !24, i64 160, !13, i64 180, !13, i64 182, !16, i64 184, !7, i64 240}
!13 = !{!"short", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTSN4ROHC4WLSBIiEE", !17, i64 0, !14, i64 24, !14, i64 32, !14, i64 40, !15, i64 48, !15, 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", !6, i64 0, !6, i64 8, !6, i64 16}
!21 = !{!"_ZTSN4ROHC12Reordering_tE", !7, i64 0}
!22 = !{!"_ZTSN4ROHC15IPIDBehaviour_tE", !7, i64 0}
!23 = !{!"_ZTSN4ROHC8CProfileUt_E", !7, i64 0}
!24 = !{!"_ZTSN4ROHC5iphdrE", !7, i64 0, !7, i64 0, !7, i64 1, !13, i64 2, !13, i64 4, !13, i64 6, !7, i64 8, !7, i64 9, !13, i64 10, !15, i64 12, !15, i64 16}
!25 = !{i8 0, i8 2}
!26 = !{}
!27 = !{!12, !15, i64 64}
!28 = !{!12, !6, i64 8}
!29 = !{!12, !15, i64 68}


; 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
define dso_local void @_ZN4ROHC11CRTPProfile12AdvanceStateEbb(ptr nocapture noundef nonnull align 8 dereferenceable(445) %0, i1 noundef zeroext %1, i1 noundef zeroext %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 148
  %5 = load i32, ptr %4, align 4, !tbaa !5
  switch i32 %5, label %20 [
    i32 0, label %6
    i32 1, label %13
  ]

6:                                                ; preds = %3
  %brmerge.demorgan = and i1 %1, %2
  br i1 %brmerge.demorgan, label %.sink.split, label %7

7:                                                ; preds = %6
  %8 = getelementptr inbounds i8, ptr %0, i64 64
  %9 = load i32, ptr %8, align 8, !tbaa !23
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !24
  %12 = tail call noundef i32 @_ZNK4ROHC10Compressor23NumberOfIRPacketsToSendEv(ptr noundef nonnull align 8 dereferenceable(368) %11)
  %.not4 = icmp ult i32 %9, %12
  br i1 %.not4, label %20, label %.sink.split

13:                                               ; preds = %3
  %brmerge9.demorgan = and i1 %1, %2
  br i1 %brmerge9.demorgan, label %.sink.split, label %14

14:                                               ; preds = %13
  %15 = getelementptr inbounds i8, ptr %0, i64 68
  %16 = load i32, ptr %15, align 4, !tbaa !25
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = load ptr, ptr %17, align 8, !tbaa !24
  %19 = tail call noundef i32 @_ZNK4ROHC10Compressor23NumberOfFOPacketsToSendEv(ptr noundef nonnull align 8 dereferenceable(368) %18)
  %.not = icmp ult i32 %16, %19
  br i1 %.not, label %20, label %.sink.split

.sink.split:                                      ; preds = %14, %13, %7, %6
  %.sink = phi i32 [ 1, %6 ], [ 1, %7 ], [ 2, %13 ], [ 2, %14 ]
  store i32 %.sink, ptr %4, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %.sink.split, %3, %14, %7
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4ROHC10Compressor23NumberOfIRPacketsToSendEv(ptr noundef nonnull align 8 dereferenceable(368)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK4ROHC10Compressor23NumberOfFOPacketsToSendEv(ptr noundef nonnull align 8 dereferenceable(368)) local_unnamed_addr #0 align 2

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

!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, !21, i64 148}
!6 = !{!"_ZTSN4ROHC8CProfileE", !7, i64 8, !10, i64 16, !11, i64 24, !12, i64 32, !12, i64 36, !12, i64 40, !12, i64 44, !11, i64 48, !11, i64 56, !12, i64 64, !12, i64 68, !10, i64 72, !13, i64 80, !18, i64 136, !19, i64 140, !20, i64 144, !21, i64 148, !12, i64 152, !12, i64 156, !22, i64 160, !10, i64 180, !10, i64 182, !13, i64 184, !8, i64 240}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"_ZTSN4ROHC4WLSBIiEE", !14, i64 0, !11, i64 24, !11, i64 32, !11, i64 40, !12, i64 48, !12, i64 52}
!14 = !{!"_ZTSSt6vectorIN4ROHC4WLSBIiE3LSBESaIS3_EE", !15, i64 0}
!15 = !{!"_ZTSSt12_Vector_baseIN4ROHC4WLSBIiE3LSBESaIS3_EE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIN4ROHC4WLSBIiE3LSBESaIS3_EE12_Vector_implE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN4ROHC4WLSBIiE3LSBESaIS3_EE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!18 = !{!"_ZTSN4ROHC12Reordering_tE", !8, i64 0}
!19 = !{!"_ZTSN4ROHC15IPIDBehaviour_tE", !8, i64 0}
!20 = !{!"bool", !8, i64 0}
!21 = !{!"_ZTSN4ROHC8CProfileUt_E", !8, i64 0}
!22 = !{!"_ZTSN4ROHC5iphdrE", !8, i64 0, !8, i64 0, !8, i64 1, !10, i64 2, !10, i64 4, !10, i64 6, !8, i64 8, !8, i64 9, !10, i64 10, !12, i64 12, !12, i64 16}
!23 = !{!6, !12, i64 64}
!24 = !{!6, !7, i64 8}
!25 = !{!6, !12, i64 68}


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