; LLVM IR from bbenligiray/stag :: src/Decoder.ll (ZN7Decoder6decodeERKSt6bitsetILm48EEiRiS4_)

; 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.std::bitset" = type { %"struct.std::_Base_bitset" }
%"struct.std::_Base_bitset" = type { i64 }
%class.Decoder = type { i32, i32, %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::bitset<48>, std::allocator<std::bitset<48>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::bitset<48>, std::allocator<std::bitset<48>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::bitset<48>, std::allocator<std::bitset<48>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::bitset<48>, std::allocator<std::bitset<48>>>::_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 nounwind uwtable
define dso_local noundef zeroext i1 @_ZN7Decoder6decodeERKSt6bitsetILm48EEiRiS4_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef %2, ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4) #1 align 2 {
  %6 = alloca i1, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca %"class.std::bitset", align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  %15 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %51, %5
  %17 = load i32, ptr %12, align 4, !tbaa !9
  %18 = zext i32 %17 to i64
  %19 = getelementptr inbounds %class.Decoder, ptr %15, i32 0, i32 2
  %20 = call noundef i64 @_ZNKSt6vectorISt6bitsetILm48EESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %19) #3
  %21 = icmp ult i64 %18, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %16
  store i32 2, ptr %13, align 4
  br label %54

23:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = getelementptr inbounds %class.Decoder, ptr %15, i32 0, i32 2
  %26 = load i32, ptr %12, align 4, !tbaa !9
  %27 = zext i32 %26 to i64
  %28 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorISt6bitsetILm48EESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %25, i64 noundef %27) #3
  %29 = call i64 @_ZSteoILm48EESt6bitsetIXT_EERKS1_S3_(ptr noundef nonnull align 8 dereferenceable(8) %24, ptr noundef nonnull align 8 dereferenceable(8) %28) #3
  %30 = getelementptr inbounds %"class.std::bitset", ptr %14, i32 0, i32 0
  %31 = getelementptr inbounds %"struct.std::_Base_bitset", ptr %30, i32 0, i32 0
  store i64 %29, ptr %31, align 8
  %32 = call noundef i64 @_ZNKSt6bitsetILm48EE5countEv(ptr noundef nonnull align 8 dereferenceable(8) %14) #3
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = icmp ule i64 %32, %34
  br i1 %35, label %36, label %47

36:                                               ; preds = %23
  %37 = load i32, ptr %12, align 4, !tbaa !9
  %38 = getelementptr inbounds %class.Decoder, ptr %15, i32 0, i32 1
  %39 = load i32, ptr %38, align 4, !tbaa !11
  %40 = urem i32 %37, %39
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 %40, ptr %41, align 4, !tbaa !9
  %42 = load i32, ptr %12, align 4, !tbaa !9
  %43 = getelementptr inbounds %class.Decoder, ptr %15, i32 0, i32 1
  %44 = load i32, ptr %43, align 4, !tbaa !11
  %45 = udiv i32 %42, %44
  %46 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 %45, ptr %46, align 4, !tbaa !9
  store i1 true, ptr %6, align 1
  store i32 1, ptr %13, align 4
  br label %48

47:                                               ; preds = %23
  store i32 0, ptr %13, align 4
  br label %48

48:                                               ; preds = %47, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %49 = load i32, ptr %13, align 4
  switch i32 %49, label %54 [
    i32 0, label %50
  ]

50:                                               ; preds = %48
  br label %51

51:                                               ; preds = %50
  %52 = load i32, ptr %12, align 4, !tbaa !9
  %53 = add i32 %52, 1
  store i32 %53, ptr %12, align 4, !tbaa !9
  br label %16, !llvm.loop !17

54:                                               ; preds = %48, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  %55 = load i32, ptr %13, align 4
  switch i32 %55, label %59 [
    i32 2, label %56
    i32 1, label %57
  ]

56:                                               ; preds = %54
  store i1 false, ptr %6, align 1
  br label %57

57:                                               ; preds = %56, %54
  %58 = load i1, ptr %6, align 1
  ret i1 %58

59:                                               ; preds = %54
  unreachable
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local i64 @_ZSteoILm48EESt6bitsetIXT_EERKS1_S3_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 4}
!12 = !{!"_ZTS7Decoder", !10, i64 0, !10, i64 4, !13, i64 8}
!13 = !{!"_ZTSSt6vectorISt6bitsetILm48EESaIS1_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseISt6bitsetILm48EESaIS1_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseISt6bitsetILm48EESaIS1_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseISt6bitsetILm48EESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; 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.std::bitset" = type { %"struct.std::_Base_bitset" }
%"struct.std::_Base_bitset" = type { i64 }

; 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 nounwind uwtable
define dso_local noundef zeroext i1 @_ZN7Decoder6decodeERKSt6bitsetILm48EEiRiS4_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef %2, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %3, ptr nocapture noundef nonnull writeonly align 4 dereferenceable(4) %4) local_unnamed_addr #1 align 2 {
  %6 = alloca %"class.std::bitset", align 8
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = tail call noundef i64 @_ZNKSt6vectorISt6bitsetILm48EESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #3
  %.not1620.not = icmp eq i64 %8, 0
  br i1 %.not1620.not, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %5
  %9 = sext i32 %2 to i64
  br label %10

10:                                               ; preds = %.lr.ph, %.critedge
  %11 = phi i64 [ 0, %.lr.ph ], [ %22, %.critedge ]
  %.01221 = phi i32 [ 0, %.lr.ph ], [ %21, %.critedge ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  %12 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorISt6bitsetILm48EESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %11) #3
  %13 = call i64 @_ZSteoILm48EESt6bitsetIXT_EERKS1_S3_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %12) #3
  store i64 %13, ptr %6, align 8
  %14 = call noundef i64 @_ZNKSt6bitsetILm48EE5countEv(ptr noundef nonnull align 8 dereferenceable(8) %6) #3
  %.not = icmp ugt i64 %14, %9
  br i1 %.not, label %.critedge, label %15

15:                                               ; preds = %10
  %16 = getelementptr inbounds i8, ptr %0, i64 4
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = urem i32 %.01221, %17
  store i32 %18, ptr %3, align 4, !tbaa !15
  %19 = load i32, ptr %16, align 4, !tbaa !5
  %20 = udiv i32 %.01221, %19
  store i32 %20, ptr %4, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  br label %.loopexit

.critedge:                                        ; preds = %10
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  %21 = add i32 %.01221, 1
  %22 = zext i32 %21 to i64
  %23 = call noundef i64 @_ZNKSt6vectorISt6bitsetILm48EESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #3
  %.not16 = icmp ugt i64 %23, %22
  br i1 %.not16, label %10, label %.loopexit, !llvm.loop !16

.loopexit:                                        ; preds = %.critedge, %5, %15
  %.not1618 = phi i1 [ true, %15 ], [ false, %5 ], [ false, %.critedge ]
  ret i1 %.not1618
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local i64 @_ZSteoILm48EESt6bitsetIXT_EERKS1_S3_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 #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, !7, i64 4}
!6 = !{!"_ZTS7Decoder", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorISt6bitsetILm48EESaIS1_EE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseISt6bitsetILm48EESaIS1_EE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseISt6bitsetILm48EESaIS1_EE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseISt6bitsetILm48EESaIS1_EE17_Vector_impl_dataE", !14, i64 0, !14, i64 8, !14, i64 16}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass