; LLVM IR from jermp/2i_bench :: external/CRoaring/tests (util_unit)

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

@.str = external hidden unnamed_addr constant [84 x i8], align 1

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #2

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

declare void @bitset_set_list(ptr noundef, ptr noundef, i64 noundef) #3

declare void @_assert_int_equal(i64 noundef, i64 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind
declare void @free(ptr noundef) #4

; Function Attrs: nounwind uwtable
define dso_local void @setandextract_sse_uint16() #5 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #6
  store i32 65536, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1024, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %80, %0
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = icmp ult i32 %12, 65536
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %83

15:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = udiv i32 65536, %16
  store i32 %17, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = zext i32 %18 to i64
  %20 = mul i64 %19, 2
  %21 = call noalias ptr @malloc(i64 noundef %20) #7
  store ptr %21, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %22 = call noalias ptr @calloc(i64 noundef 1024, i64 noundef 8) #8
  store ptr %22, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %37, %15
  %24 = load i32, ptr %8, align 4, !tbaa !5
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = icmp ult i32 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %40

28:                                               ; preds = %23
  %29 = load i32, ptr %8, align 4, !tbaa !5
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = mul i32 %29, %30
  %32 = trunc i32 %31 to i16
  %33 = load ptr, ptr %6, align 8, !tbaa !9
  %34 = load i32, ptr %8, align 4, !tbaa !5
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds i16, ptr %33, i64 %35
  store i16 %32, ptr %36, align 2, !tbaa !11
  br label %37

37:                                               ; preds = %28
  %38 = load i32, ptr %8, align 4, !tbaa !5
  %39 = add i32 %38, 1
  store i32 %39, ptr %8, align 4, !tbaa !5
  br label %23, !llvm.loop !13

40:                                               ; preds = %27
  %41 = load ptr, ptr %7, align 8, !tbaa !9
  %42 = load ptr, ptr %6, align 8, !tbaa !9
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = zext i32 %43 to i64
  call void @bitset_set_list(ptr noundef %41, ptr noundef %42, i64 noundef %44)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #6
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = zext i32 %45 to i64
  %47 = mul i64 %46, 2
  %48 = add i64 %47, 64
  %49 = call noalias ptr @malloc(i64 noundef %48) #7
  store ptr %49, ptr %9, align 8, !tbaa !9
  %50 = load ptr, ptr %7, align 8, !tbaa !9
  %51 = load ptr, ptr %9, align 8, !tbaa !9
  %52 = load i32, ptr %5, align 4, !tbaa !5
  %53 = zext i32 %52 to i64
  %54 = call i64 @bitset_extract_setbits_sse_uint16(ptr noundef %50, i64 noundef 1024, ptr noundef %51, i64 noundef %53, i16 noundef zeroext 0)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %55

55:                                               ; preds = %73, %40
  %56 = load i32, ptr %10, align 4, !tbaa !5
  %57 = load i32, ptr %5, align 4, !tbaa !5
  %58 = icmp ult i32 %56, %57
  br i1 %58, label %60, label %59

59:                                               ; preds = %55
  store i32 8, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %76

60:                                               ; preds = %55
  %61 = load ptr, ptr %9, align 8, !tbaa !9
  %62 = load i32, ptr %10, align 4, !tbaa !5
  %63 = zext i32 %62 to i64
  %64 = getelementptr inbounds i16, ptr %61, i64 %63
  %65 = load i16, ptr %64, align 2, !tbaa !11
  %66 = zext i16 %65 to i64
  %67 = load ptr, ptr %6, align 8, !tbaa !9
  %68 = load i32, ptr %10, align 4, !tbaa !5
  %69 = zext i32 %68 to i64
  %70 = getelementptr inbounds i16, ptr %67, i64 %69
  %71 = load i16, ptr %70, align 2, !tbaa !11
  %72 = zext i16 %71 to i64
  call void @_assert_int_equal(i64 noundef %66, i64 noundef %72, ptr noundef @.str, i32 noundef 62)
  br label %73

73:                                               ; preds = %60
  %74 = load i32, ptr %10, align 4, !tbaa !5
  %75 = add i32 %74, 1
  store i32 %75, ptr %10, align 4, !tbaa !5
  br label %55, !llvm.loop !15

76:                                               ; preds = %59
  %77 = load ptr, ptr %6, align 8, !tbaa !9
  call void @free(ptr noundef %77) #6
  %78 = load ptr, ptr %9, align 8, !tbaa !9
  call void @free(ptr noundef %78) #6
  %79 = load ptr, ptr %7, align 8, !tbaa !9
  call void @free(ptr noundef %79) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  br label %80

80:                                               ; preds = %76
  %81 = load i32, ptr %3, align 4, !tbaa !5
  %82 = add i32 %81, 1
  store i32 %82, ptr %3, align 4, !tbaa !5
  br label %11, !llvm.loop !16

83:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #6
  ret void
}

declare i64 @bitset_extract_setbits_sse_uint16(ptr noundef, i64 noundef, ptr noundef, i64 noundef, i16 noundef zeroext) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(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 allocsize(0,1) "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 = { "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 #4 = { nounwind "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 #5 = { 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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { nounwind allocsize(0,1) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


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

@.str = external hidden unnamed_addr constant [84 x i8], align 1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #1

declare void @bitset_set_list(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

declare void @_assert_int_equal(i64 noundef, i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @setandextract_sse_uint16() local_unnamed_addr #4 {
  br label %.lr.ph.preheader

1:                                                ; preds = %._crit_edge34
  ret void

.lr.ph.preheader:                                 ; preds = %._crit_edge34, %0
  %indvars.iv43 = phi i64 [ 1, %0 ], [ %indvars.iv.next44, %._crit_edge34 ]
  %2 = trunc nuw nsw i64 %indvars.iv43 to i32
  %3 = udiv i32 65536, %2
  %4 = zext nneg i32 %3 to i64
  %5 = shl nuw nsw i64 %4, 1
  %6 = tail call noalias ptr @malloc(i64 noundef %5) #5
  %7 = tail call noalias dereferenceable_or_null(8192) ptr @calloc(i64 noundef 1024, i64 noundef 8) #6
  %8 = add nsw i64 %4, -1
  %xtraiter = and i64 %4, 3
  %9 = icmp ult i64 %8, 3
  br i1 %9, label %.lr.ph33.preheader.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %4, 131068
  br label %.lr.ph

.lr.ph33.preheader.unr-lcssa:                     ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph33.preheader, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.lr.ph33.preheader.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %.lr.ph33.preheader.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %.lr.ph33.preheader.unr-lcssa ]
  %10 = mul nuw nsw i64 %indvars.iv.epil, %indvars.iv43
  %11 = trunc i64 %10 to i16
  %12 = getelementptr inbounds i16, ptr %6, i64 %indvars.iv.epil
  store i16 %11, ptr %12, align 2, !tbaa !5
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.lr.ph33.preheader, label %.lr.ph.epil, !llvm.loop !9

.lr.ph33.preheader:                               ; preds = %.lr.ph.epil, %.lr.ph33.preheader.unr-lcssa
  tail call void @bitset_set_list(ptr noundef %7, ptr noundef nonnull %6, i64 noundef %4) #7
  %13 = add nuw nsw i64 %5, 64
  %14 = tail call noalias ptr @malloc(i64 noundef %13) #5
  %15 = tail call i64 @bitset_extract_setbits_sse_uint16(ptr noundef %7, i64 noundef 1024, ptr noundef %14, i64 noundef %4, i16 noundef zeroext 0) #7
  br label %.lr.ph33

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %16 = mul nuw nsw i64 %indvars.iv, %indvars.iv43
  %17 = trunc i64 %16 to i16
  %18 = getelementptr inbounds i16, ptr %6, i64 %indvars.iv
  store i16 %17, ptr %18, align 2, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %19 = mul nuw nsw i64 %indvars.iv.next, %indvars.iv43
  %20 = trunc i64 %19 to i16
  %21 = getelementptr inbounds i16, ptr %6, i64 %indvars.iv.next
  store i16 %20, ptr %21, align 2, !tbaa !5
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %22 = mul nuw nsw i64 %indvars.iv.next.1, %indvars.iv43
  %23 = trunc i64 %22 to i16
  %24 = getelementptr inbounds i16, ptr %6, i64 %indvars.iv.next.1
  store i16 %23, ptr %24, align 2, !tbaa !5
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %25 = mul nuw nsw i64 %indvars.iv.next.2, %indvars.iv43
  %26 = trunc i64 %25 to i16
  %27 = getelementptr inbounds i16, ptr %6, i64 %indvars.iv.next.2
  store i16 %26, ptr %27, align 2, !tbaa !5
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.lr.ph33.preheader.unr-lcssa, label %.lr.ph, !llvm.loop !11

._crit_edge34:                                    ; preds = %.lr.ph33
  tail call void @free(ptr noundef nonnull %6) #7
  tail call void @free(ptr noundef nonnull %14) #7
  tail call void @free(ptr noundef %7) #7
  %indvars.iv.next44 = add nuw nsw i64 %indvars.iv43, 1
  %exitcond46.not = icmp eq i64 %indvars.iv.next44, 65536
  br i1 %exitcond46.not, label %1, label %.lr.ph.preheader, !llvm.loop !13

.lr.ph33:                                         ; preds = %.lr.ph33.preheader, %.lr.ph33
  %indvars.iv38 = phi i64 [ 0, %.lr.ph33.preheader ], [ %indvars.iv.next39, %.lr.ph33 ]
  %28 = getelementptr inbounds i16, ptr %14, i64 %indvars.iv38
  %29 = load i16, ptr %28, align 2, !tbaa !5
  %30 = zext i16 %29 to i64
  %31 = getelementptr inbounds i16, ptr %6, i64 %indvars.iv38
  %32 = load i16, ptr %31, align 2, !tbaa !5
  %33 = zext i16 %32 to i64
  tail call void @_assert_int_equal(i64 noundef %30, i64 noundef %33, ptr noundef nonnull @.str, i32 noundef 62) #7
  %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
  %exitcond42.not = icmp eq i64 %indvars.iv.next39, %4
  br i1 %exitcond42.not, label %._crit_edge34, label %.lr.ph33, !llvm.loop !14
}

declare i64 @bitset_extract_setbits_sse_uint16(ptr noundef, i64 noundef, ptr noundef, i64 noundef, i16 noundef zeroext) local_unnamed_addr #2

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { "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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #4 = { 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 #5 = { nounwind allocsize(0) }
attributes #6 = { nounwind allocsize(0,1) }
attributes #7 = { 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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.unroll.disable"}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


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