; LLVM IR from intel/qpl :: tools/utils/common (source_provider)

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

; 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
declare dso_local noundef i32 @_ZN3qpl4test15source_provider26get_prle_header_bytes_sizeEj(i32 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3qpl4test15source_provider17store_prle_headerERN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEEjNS1_15prle_encoding_tE(ptr noundef nonnull align 8 dereferenceable(8) %0, i32 noundef %1, i8 noundef zeroext %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %12 = alloca ptr, align 8
  %13 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i8 %2, ptr %6, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store i64 0, ptr %7, align 8, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = call noundef i32 @_ZN3qpl4test15source_provider26get_prle_header_bytes_sizeEj(i32 noundef %14)
  store i32 %15, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  store i64 63, ptr %10, align 8, !tbaa !13
  %16 = load i8, ptr %6, align 1, !tbaa !11
  %17 = icmp eq i8 0, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %3
  store i64 1, ptr %7, align 8, !tbaa !13
  br label %19

19:                                               ; preds = %18, %3
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = zext i32 %20 to i64
  %22 = load i64, ptr %10, align 8, !tbaa !13
  %23 = and i64 %21, %22
  %24 = shl i64 %23, 1
  %25 = load i64, ptr %7, align 8, !tbaa !13
  %26 = or i64 %25, %24
  store i64 %26, ptr %7, align 8, !tbaa !13
  %27 = load i32, ptr %9, align 4, !tbaa !9
  %28 = icmp ugt i32 %27, 1
  br i1 %28, label %29, label %32

29:                                               ; preds = %19
  %30 = load i64, ptr %7, align 8, !tbaa !13
  %31 = or i64 %30, 128
  store i64 %31, ptr %7, align 8, !tbaa !13
  br label %32

32:                                               ; preds = %29, %19
  %33 = load i64, ptr %7, align 8, !tbaa !13
  %34 = trunc i64 %33 to i8
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %35) #2
  store i8 %34, ptr %36, align 1, !tbaa !15
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = add i32 %37, -1
  store i32 %38, ptr %9, align 4, !tbaa !9
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = call ptr @_ZN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %39, i32 noundef 0) #2
  %41 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %11, i32 0, i32 0
  store ptr %40, ptr %41, align 8
  store i64 0, ptr %7, align 8, !tbaa !13
  store i64 127, ptr %10, align 8, !tbaa !13
  %42 = load i32, ptr %5, align 4, !tbaa !9
  %43 = lshr i32 %42, 6
  store i32 %43, ptr %5, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %91, %32
  %45 = load i32, ptr %9, align 4, !tbaa !9
  %46 = icmp ugt i32 %45, 0
  br i1 %46, label %47, label %92

47:                                               ; preds = %44
  %48 = load i32, ptr %5, align 4, !tbaa !9
  %49 = zext i32 %48 to i64
  %50 = load i64, ptr %10, align 8, !tbaa !13
  %51 = and i64 %49, %50
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = zext i32 %52 to i64
  %54 = shl i64 %51, %53
  %55 = load i64, ptr %7, align 8, !tbaa !13
  %56 = or i64 %55, %54
  store i64 %56, ptr %7, align 8, !tbaa !13
  %57 = load i32, ptr %5, align 4, !tbaa !9
  %58 = lshr i32 %57, 7
  store i32 %58, ptr %5, align 4, !tbaa !9
  %59 = load i32, ptr %8, align 4, !tbaa !9
  %60 = add i32 %59, 7
  store i32 %60, ptr %8, align 4, !tbaa !9
  %61 = load i32, ptr %9, align 4, !tbaa !9
  %62 = add i32 %61, -1
  store i32 %62, ptr %9, align 4, !tbaa !9
  %63 = load i32, ptr %9, align 4, !tbaa !9
  %64 = icmp ugt i32 %63, 0
  br i1 %64, label %65, label %73

65:                                               ; preds = %47
  %66 = load i32, ptr %8, align 4, !tbaa !9
  %67 = zext i32 %66 to i64
  %68 = shl i64 1, %67
  %69 = load i64, ptr %7, align 8, !tbaa !13
  %70 = or i64 %69, %68
  store i64 %70, ptr %7, align 8, !tbaa !13
  %71 = load i32, ptr %8, align 4, !tbaa !9
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %8, align 4, !tbaa !9
  br label %73

73:                                               ; preds = %65, %47
  %74 = load i32, ptr %8, align 4, !tbaa !9
  %75 = sext i32 %74 to i64
  %76 = icmp uge i64 %75, 32
  br i1 %76, label %77, label %91

77:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %78) #2
  store ptr %79, ptr %12, align 8, !tbaa !5
  %80 = load i64, ptr %7, align 8, !tbaa !13
  %81 = trunc i64 %80 to i32
  %82 = load ptr, ptr %12, align 8, !tbaa !5
  store i32 %81, ptr %82, align 4, !tbaa !9
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEpLEl(ptr noundef nonnull align 8 dereferenceable(8) %83, i64 noundef 4) #2
  %85 = load i64, ptr %7, align 8, !tbaa !13
  %86 = lshr i64 %85, 32
  store i64 %86, ptr %7, align 8, !tbaa !13
  %87 = load i32, ptr %8, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = sub i64 %88, 32
  %90 = trunc i64 %89 to i32
  store i32 %90, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  br label %91

91:                                               ; preds = %77, %73
  br label %44, !llvm.loop !16

92:                                               ; preds = %44
  br label %93

93:                                               ; preds = %96, %92
  %94 = load i32, ptr %8, align 4, !tbaa !9
  %95 = icmp slt i32 0, %94
  br i1 %95, label %96, label %108

96:                                               ; preds = %93
  %97 = load i64, ptr %7, align 8, !tbaa !13
  %98 = trunc i64 %97 to i8
  %99 = load ptr, ptr %4, align 8, !tbaa !5
  %100 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %99) #2
  store i8 %98, ptr %100, align 1, !tbaa !15
  %101 = load ptr, ptr %4, align 8, !tbaa !5
  %102 = call ptr @_ZN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %101, i32 noundef 0) #2
  %103 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %13, i32 0, i32 0
  store ptr %102, ptr %103, align 8
  %104 = load i64, ptr %7, align 8, !tbaa !13
  %105 = lshr i64 %104, 8
  store i64 %105, ptr %7, align 8, !tbaa !13
  %106 = load i32, ptr %8, align 4, !tbaa !9
  %107 = sub i32 %106, 8
  store i32 %107, ptr %8, align 4, !tbaa !9
  br label %93, !llvm.loop !18

108:                                              ; preds = %93
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret void
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEpLEl(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #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 = { 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, !12, i64 0}
!12 = !{!"_ZTSN3qpl4test15source_provider15prle_encoding_tE", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


; 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
declare dso_local noundef i32 @_ZN3qpl4test15source_provider26get_prle_header_bytes_sizeEj(i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3qpl4test15source_provider17store_prle_headerERN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEEjNS1_15prle_encoding_tE(ptr noundef nonnull align 8 dereferenceable(8) %0, i32 noundef %1, i8 noundef zeroext %2) local_unnamed_addr #0 align 2 {
  %4 = tail call noundef i32 @_ZN3qpl4test15source_provider26get_prle_header_bytes_sizeEj(i32 noundef %1)
  %5 = icmp eq i8 %2, 0
  %6 = shl i32 %1, 1
  %7 = and i32 %6, 126
  %8 = zext i1 %5 to i32
  %9 = or disjoint i32 %7, %8
  %10 = trunc nuw nsw i32 %9 to i8
  %11 = icmp ugt i32 %4, 1
  %12 = or disjoint i8 %10, -128
  %.1 = select i1 %11, i8 %12, i8 %10
  %13 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %0) #1
  store i8 %.1, ptr %13, align 1, !tbaa !5
  %14 = add i32 %4, -1
  %15 = tail call ptr @_ZN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %0, i32 noundef 0) #1
  %.not45 = icmp eq i32 %14, 0
  br i1 %.not45, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %3
  %16 = lshr i32 %1, 6
  br label %.lr.ph

.preheader:                                       ; preds = %37
  %17 = icmp sgt i32 %.240, 0
  br i1 %17, label %.lr.ph53, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph.preheader, %37
  %.049 = phi i32 [ %22, %37 ], [ %16, %.lr.ph.preheader ]
  %.248 = phi i64 [ %.4, %37 ], [ 0, %.lr.ph.preheader ]
  %.03847 = phi i32 [ %.240, %37 ], [ 0, %.lr.ph.preheader ]
  %.04246 = phi i32 [ %24, %37 ], [ %14, %.lr.ph.preheader ]
  %18 = and i32 %.049, 127
  %19 = zext nneg i32 %18 to i64
  %20 = zext nneg i32 %.03847 to i64
  %21 = shl i64 %19, %20
  %22 = lshr i32 %.049, 7
  %23 = add nuw i32 %.03847, 7
  %24 = add i32 %.04246, -1
  %.not44 = icmp eq i32 %24, 0
  %25 = zext nneg i32 %23 to i64
  %26 = shl nuw i64 1, %25
  %27 = add nuw i32 %.03847, 8
  %.139 = select i1 %.not44, i32 %23, i32 %27
  %28 = select i1 %.not44, i64 0, i64 %26
  %29 = or i64 %28, %.248
  %.3 = or i64 %29, %21
  %30 = icmp ugt i32 %.139, 31
  br i1 %30, label %31, label %37

31:                                               ; preds = %.lr.ph
  %32 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %0) #1
  %33 = trunc i64 %.3 to i32
  store i32 %33, ptr %32, align 4, !tbaa !8
  %34 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEpLEl(ptr noundef nonnull align 8 dereferenceable(8) %0, i64 noundef 4) #1
  %35 = lshr i64 %.3, 32
  %36 = add i32 %.139, -32
  br label %37

37:                                               ; preds = %31, %.lr.ph
  %.240 = phi i32 [ %36, %31 ], [ %.139, %.lr.ph ]
  %.4 = phi i64 [ %35, %31 ], [ %.3, %.lr.ph ]
  br i1 %.not44, label %.preheader, label %.lr.ph, !llvm.loop !10

.lr.ph53:                                         ; preds = %.preheader, %.lr.ph53
  %.552 = phi i64 [ %41, %.lr.ph53 ], [ %.4, %.preheader ]
  %.34151 = phi i32 [ %42, %.lr.ph53 ], [ %.240, %.preheader ]
  %38 = trunc i64 %.552 to i8
  %39 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %0) #1
  store i8 %38, ptr %39, align 1, !tbaa !5
  %40 = tail call ptr @_ZN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEppEi(ptr noundef nonnull align 8 dereferenceable(8) %0, i32 noundef 0) #1
  %41 = lshr i64 %.552, 8
  %42 = add nsw i32 %.34151, -8
  %43 = icmp ugt i32 %.34151, 8
  br i1 %43, label %.lr.ph53, label %._crit_edge, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph53, %3, %.preheader
  ret void
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPhSt6vectorIhSaIhEEEpLEl(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) 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" }
attributes #1 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


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