; 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: nounwind uwtable
define dso_local void @setandextract_uint16() #0 {
  %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 = %77, %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 %80

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 = call noalias ptr @malloc(i64 noundef %47) #7
  store ptr %48, ptr %9, align 8, !tbaa !9
  %49 = load ptr, ptr %7, align 8, !tbaa !9
  %50 = load ptr, ptr %9, align 8, !tbaa !9
  %51 = call i64 @bitset_extract_setbits_uint16(ptr noundef %49, i64 noundef 1024, ptr noundef %50, 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 %52

52:                                               ; preds = %70, %40
  %53 = load i32, ptr %10, align 4, !tbaa !5
  %54 = load i32, ptr %5, align 4, !tbaa !5
  %55 = icmp ult i32 %53, %54
  br i1 %55, label %57, label %56

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

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

70:                                               ; preds = %57
  %71 = load i32, ptr %10, align 4, !tbaa !5
  %72 = add i32 %71, 1
  store i32 %72, ptr %10, align 4, !tbaa !5
  br label %52, !llvm.loop !15

73:                                               ; preds = %56
  %74 = load ptr, ptr %6, align 8, !tbaa !9
  call void @free(ptr noundef %74) #6
  %75 = load ptr, ptr %9, align 8, !tbaa !9
  call void @free(ptr noundef %75) #6
  %76 = load ptr, ptr %7, align 8, !tbaa !9
  call void @free(ptr noundef %76) #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 %77

77:                                               ; preds = %73
  %78 = load i32, ptr %3, align 4, !tbaa !5
  %79 = add i32 %78, 1
  store i32 %79, ptr %3, align 4, !tbaa !5
  br label %11, !llvm.loop !16

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

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

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

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

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

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

declare i64 @bitset_extract_setbits_uint16(ptr noundef, i64 noundef, ptr noundef, i16 noundef zeroext) #4

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

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

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { "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 "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: nounwind uwtable
define dso_local void @setandextract_uint16() local_unnamed_addr #0 {
  br label %.lr.ph.preheader

1:                                                ; preds = %._crit_edge33
  ret void

.lr.ph.preheader:                                 ; preds = %._crit_edge33, %0
  %indvars.iv42 = phi i64 [ 1, %0 ], [ %indvars.iv.next43, %._crit_edge33 ]
  %2 = trunc nuw nsw i64 %indvars.iv42 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.ph32.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.ph32.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.ph32.preheader, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.lr.ph32.preheader.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %.lr.ph32.preheader.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %.lr.ph32.preheader.unr-lcssa ]
  %10 = mul nuw nsw i64 %indvars.iv.epil, %indvars.iv42
  %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.ph32.preheader, label %.lr.ph.epil, !llvm.loop !9

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

.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 ]
  %15 = mul nuw nsw i64 %indvars.iv, %indvars.iv42
  %16 = trunc i64 %15 to i16
  %17 = getelementptr inbounds i16, ptr %6, i64 %indvars.iv
  store i16 %16, ptr %17, align 2, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %18 = mul nuw nsw i64 %indvars.iv.next, %indvars.iv42
  %19 = trunc i64 %18 to i16
  %20 = getelementptr inbounds i16, ptr %6, i64 %indvars.iv.next
  store i16 %19, ptr %20, align 2, !tbaa !5
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %21 = mul nuw nsw i64 %indvars.iv.next.1, %indvars.iv42
  %22 = trunc i64 %21 to i16
  %23 = getelementptr inbounds i16, ptr %6, i64 %indvars.iv.next.1
  store i16 %22, ptr %23, align 2, !tbaa !5
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %24 = mul nuw nsw i64 %indvars.iv.next.2, %indvars.iv42
  %25 = trunc i64 %24 to i16
  %26 = getelementptr inbounds i16, ptr %6, i64 %indvars.iv.next.2
  store i16 %25, ptr %26, 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.ph32.preheader.unr-lcssa, label %.lr.ph, !llvm.loop !11

._crit_edge33:                                    ; preds = %.lr.ph32
  tail call void @free(ptr noundef nonnull %6) #7
  tail call void @free(ptr noundef nonnull %13) #7
  tail call void @free(ptr noundef %7) #7
  %indvars.iv.next43 = add nuw nsw i64 %indvars.iv42, 1
  %exitcond45.not = icmp eq i64 %indvars.iv.next43, 65536
  br i1 %exitcond45.not, label %1, label %.lr.ph.preheader, !llvm.loop !13

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

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

; 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 #2

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

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

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

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

attributes #0 = { 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 = { 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 #2 = { 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 #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 = { 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 #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