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

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

@_ZL4HD11 = external hidden constant [89236 x i64], align 16
@_ZL4HD13 = external hidden constant [11536 x i64], align 16
@_ZL4HD15 = external hidden constant [3064 x i64], align 16
@_ZL4HD17 = external hidden constant [628 x i64], align 16
@_ZL4HD19 = external hidden constant [152 x i64], align 16
@_ZL4HD21 = external hidden constant [48 x i64], align 16
@_ZL4HD23 = external hidden constant [24 x i64], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7DecoderC2Ei(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %1) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %"class.std::bitset", align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %10 = load ptr, ptr %3, align 8
  %11 = getelementptr inbounds %class.Decoder, ptr %10, i32 0, i32 0
  store i32 48, ptr %11, align 8, !tbaa !11
  %12 = getelementptr inbounds %class.Decoder, ptr %10, i32 0, i32 2
  call void @_ZNSt6vectorISt6bitsetILm48EESaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store ptr null, ptr %5, align 8, !tbaa !5
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = icmp eq i32 %13, 11
  br i1 %14, label %15, label %17

15:                                               ; preds = %2
  store ptr @_ZL4HD11, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %class.Decoder, ptr %10, i32 0, i32 1
  store i32 22309, ptr %16, align 4, !tbaa !17
  br label %53

17:                                               ; preds = %2
  %18 = load i32, ptr %4, align 4, !tbaa !9
  %19 = icmp eq i32 %18, 13
  br i1 %19, label %20, label %22

20:                                               ; preds = %17
  store ptr @_ZL4HD13, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %class.Decoder, ptr %10, i32 0, i32 1
  store i32 2884, ptr %21, align 4, !tbaa !17
  br label %52

22:                                               ; preds = %17
  %23 = load i32, ptr %4, align 4, !tbaa !9
  %24 = icmp eq i32 %23, 15
  br i1 %24, label %25, label %27

25:                                               ; preds = %22
  store ptr @_ZL4HD15, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %class.Decoder, ptr %10, i32 0, i32 1
  store i32 766, ptr %26, align 4, !tbaa !17
  br label %51

27:                                               ; preds = %22
  %28 = load i32, ptr %4, align 4, !tbaa !9
  %29 = icmp eq i32 %28, 17
  br i1 %29, label %30, label %32

30:                                               ; preds = %27
  store ptr @_ZL4HD17, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %class.Decoder, ptr %10, i32 0, i32 1
  store i32 157, ptr %31, align 4, !tbaa !17
  br label %50

32:                                               ; preds = %27
  %33 = load i32, ptr %4, align 4, !tbaa !9
  %34 = icmp eq i32 %33, 19
  br i1 %34, label %35, label %37

35:                                               ; preds = %32
  store ptr @_ZL4HD19, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %class.Decoder, ptr %10, i32 0, i32 1
  store i32 38, ptr %36, align 4, !tbaa !17
  br label %49

37:                                               ; preds = %32
  %38 = load i32, ptr %4, align 4, !tbaa !9
  %39 = icmp eq i32 %38, 21
  br i1 %39, label %40, label %42

40:                                               ; preds = %37
  store ptr @_ZL4HD21, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %class.Decoder, ptr %10, i32 0, i32 1
  store i32 12, ptr %41, align 4, !tbaa !17
  br label %48

42:                                               ; preds = %37
  %43 = load i32, ptr %4, align 4, !tbaa !9
  %44 = icmp eq i32 %43, 23
  br i1 %44, label %45, label %47

45:                                               ; preds = %42
  store ptr @_ZL4HD23, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %class.Decoder, ptr %10, i32 0, i32 1
  store i32 6, ptr %46, align 4, !tbaa !17
  br label %47

47:                                               ; preds = %45, %42
  br label %48

48:                                               ; preds = %47, %40
  br label %49

49:                                               ; preds = %48, %35
  br label %50

50:                                               ; preds = %49, %30
  br label %51

51:                                               ; preds = %50, %25
  br label %52

52:                                               ; preds = %51, %20
  br label %53

53:                                               ; preds = %52, %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %69, %53
  %55 = load i32, ptr %6, align 4, !tbaa !9
  %56 = getelementptr inbounds %class.Decoder, ptr %10, i32 0, i32 1
  %57 = load i32, ptr %56, align 4, !tbaa !17
  %58 = mul nsw i32 %57, 4
  %59 = icmp ult i32 %55, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %76

61:                                               ; preds = %54
  %62 = getelementptr inbounds %class.Decoder, ptr %10, i32 0, i32 2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load i32, ptr %6, align 4, !tbaa !9
  %65 = zext i32 %64 to i64
  %66 = getelementptr inbounds i64, ptr %63, i64 %65
  %67 = load i64, ptr %66, align 8, !tbaa !18
  call void @_ZNSt6bitsetILm48EEC2Ey(ptr noundef nonnull align 8 dereferenceable(8) %7, i64 noundef %67) #3
  invoke void @_ZNSt6vectorISt6bitsetILm48EESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) %62, ptr noundef nonnull align 8 dereferenceable(8) %7)
          to label %68 unwind label %72

68:                                               ; preds = %61
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  br label %69

69:                                               ; preds = %68
  %70 = load i32, ptr %6, align 4, !tbaa !9
  %71 = add i32 %70, 1
  store i32 %71, ptr %6, align 4, !tbaa !9
  br label %54, !llvm.loop !20

72:                                               ; preds = %61
  %73 = landingpad { ptr, i32 }
          cleanup
  %74 = extractvalue { ptr, i32 } %73, 0
  store ptr %74, ptr %8, align 8
  %75 = extractvalue { ptr, i32 } %73, 1
  store i32 %75, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @_ZNSt6vectorISt6bitsetILm48EESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %12) #3
  br label %77

76:                                               ; preds = %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void

77:                                               ; preds = %72
  %78 = load ptr, ptr %8, align 8
  %79 = load i32, ptr %9, align 4
  %80 = insertvalue { ptr, i32 } poison, ptr %78, 0
  %81 = insertvalue { ptr, i32 } %80, i32 %79, 1
  resume { ptr, i32 } %81
}

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorISt6bitsetILm48EESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #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" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 0}
!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 = !{!12, !10, i64 4}
!18 = !{!19, !19, i64 0}
!19 = !{!"long long", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"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 }

@_ZL4HD11 = external hidden local_unnamed_addr constant [89236 x i64], align 16
@_ZL4HD13 = external hidden local_unnamed_addr constant [11536 x i64], align 16
@_ZL4HD15 = external hidden local_unnamed_addr constant [3064 x i64], align 16
@_ZL4HD17 = external hidden local_unnamed_addr constant [628 x i64], align 16
@_ZL4HD19 = external hidden local_unnamed_addr constant [152 x i64], align 16
@_ZL4HD21 = external hidden local_unnamed_addr constant [48 x i64], align 16
@_ZL4HD23 = external hidden local_unnamed_addr constant [24 x i64], align 16
@switch.table._ZN7DecoderC2Ei = private unnamed_addr constant [13 x i32] [i32 22309, i32 22309, i32 2884, i32 22309, i32 766, i32 22309, i32 157, i32 22309, i32 38, i32 22309, i32 12, i32 22309, i32 6], align 4
@switch.table._ZN7DecoderC2Ei.1 = private unnamed_addr constant [13 x ptr] [ptr @_ZL4HD11, ptr @_ZL4HD11, ptr @_ZL4HD13, ptr @_ZL4HD11, ptr @_ZL4HD15, ptr @_ZL4HD11, ptr @_ZL4HD17, ptr @_ZL4HD11, ptr @_ZL4HD19, ptr @_ZL4HD11, ptr @_ZL4HD21, ptr @_ZL4HD11, ptr @_ZL4HD23], align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7DecoderC2Ei(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %1) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.std::bitset", align 8
  store i32 48, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZNSt6vectorISt6bitsetILm48EESaIS1_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #3
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 4
  %switch.tableidx = add i32 %1, -11
  %5 = icmp ult i32 %switch.tableidx, 13
  br i1 %5, label %switch.hole_check, label %8

switch.hole_check:                                ; preds = %2
  %switch.maskindex = trunc nuw i32 %switch.tableidx to i16
  %switch.shifted = lshr i16 5461, %switch.maskindex
  %switch.lobit = trunc i16 %switch.shifted to i1
  br i1 %switch.lobit, label %switch.lookup, label %8

switch.lookup:                                    ; preds = %switch.hole_check
  %6 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [13 x i32], ptr @switch.table._ZN7DecoderC2Ei, i64 0, i64 %6
  %switch.load = load i32, ptr %switch.gep, align 4
  %7 = zext nneg i32 %switch.tableidx to i64
  %switch.gep21 = getelementptr inbounds [13 x ptr], ptr @switch.table._ZN7DecoderC2Ei.1, i64 0, i64 %7
  %switch.load22 = load ptr, ptr %switch.gep21, align 8
  store i32 %switch.load, ptr %.phi.trans.insert, align 4, !tbaa !15
  br label %.lr.ph.preheader

8:                                                ; preds = %switch.hole_check, %2
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !15
  %9 = icmp eq i32 %.pre, 0
  br i1 %9, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %switch.lookup, %8
  %.020 = phi ptr [ %switch.load22, %switch.lookup ], [ null, %8 ]
  %10 = getelementptr inbounds i8, ptr %0, i64 4
  br label %.lr.ph

._crit_edge:                                      ; preds = %13, %8
  ret void

.lr.ph:                                           ; preds = %.lr.ph.preheader, %13
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %13 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %11 = getelementptr inbounds i64, ptr %.020, i64 %indvars.iv
  %12 = load i64, ptr %11, align 8, !tbaa !16
  call void @_ZNSt6bitsetILm48EEC2Ey(ptr noundef nonnull align 8 dereferenceable(8) %3, i64 noundef %12) #3
  invoke void @_ZNSt6vectorISt6bitsetILm48EESaIS1_EE9push_backEOS1_(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(8) %3)
          to label %13 unwind label %18

13:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %14 = load i32, ptr %10, align 4, !tbaa !15
  %15 = shl nsw i32 %14, 2
  %16 = zext i32 %15 to i64
  %17 = icmp ult i64 %indvars.iv.next, %16
  br i1 %17, label %.lr.ph, label %._crit_edge, !llvm.loop !18

18:                                               ; preds = %.lr.ph
  %19 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  call void @_ZNSt6vectorISt6bitsetILm48EESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #3
  resume { ptr, i32 } %19
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorISt6bitsetILm48EESaIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #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" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 0}
!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 = !{!6, !7, i64 4}
!16 = !{!17, !17, i64 0}
!17 = !{!"long long", !8, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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