; LLVM IR from jermp/2i_bench :: external/CRoaring/src/containers (bitset)

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

%struct.bitset_container_s = type { i32, 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: nounwind uwtable
define dso_local i32 @bitset_container_andnot_nocard(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.bitset_container_s, ptr %11, i32 0, i32 1
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  store ptr %13, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.bitset_container_s, ptr %14, i32 0, i32 1
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  store ptr %16, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.bitset_container_s, ptr %17, i32 0, i32 1
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  store ptr %19, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  store i64 0, ptr %10, align 8, !tbaa !12
  br label %20

20:                                               ; preds = %38, %3
  %21 = load i64, ptr %10, align 8, !tbaa !12
  %22 = icmp ult i64 %21, 1024
  br i1 %22, label %24, label %23

23:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  br label %41

24:                                               ; preds = %20
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = load i64, ptr %10, align 8, !tbaa !12
  %27 = getelementptr inbounds i64, ptr %25, i64 %26
  %28 = load i64, ptr %27, align 8, !tbaa !12
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = load i64, ptr %10, align 8, !tbaa !12
  %31 = getelementptr inbounds i64, ptr %29, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !12
  %33 = xor i64 %32, -1
  %34 = and i64 %28, %33
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = load i64, ptr %10, align 8, !tbaa !12
  %37 = getelementptr inbounds i64, ptr %35, i64 %36
  store i64 %34, ptr %37, align 8, !tbaa !12
  br label %38

38:                                               ; preds = %24
  %39 = load i64, ptr %10, align 8, !tbaa !12
  %40 = add i64 %39, 1
  store i64 %40, ptr %10, align 8, !tbaa !12
  br label %20, !llvm.loop !14

41:                                               ; preds = %23
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.bitset_container_s, ptr %42, i32 0, i32 0
  store i32 -1, ptr %43, align 8, !tbaa !16
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.bitset_container_s, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %45, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret i32 %46
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"bitset_container_s", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!10, !11, i64 0}


; 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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local noundef i32 @bitset_container_andnot_nocard(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef %2) local_unnamed_addr #0 {
vector.memcheck:
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %2, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = ptrtoint ptr %8 to i64
  %10 = ptrtoint ptr %6 to i64
  %11 = ptrtoint ptr %4 to i64
  %12 = sub i64 %9, %11
  %diff.check = icmp ult i64 %12, 32
  %13 = sub i64 %9, %10
  %diff.check13 = icmp ult i64 %13, 32
  %conflict.rdx = or i1 %diff.check, %diff.check13
  br i1 %conflict.rdx, label %scalar.ph, label %vector.body

vector.body:                                      ; preds = %vector.memcheck, %vector.body
  %index = phi i64 [ %index.next.1, %vector.body ], [ 0, %vector.memcheck ]
  %14 = getelementptr inbounds i64, ptr %4, i64 %index
  %15 = getelementptr inbounds i8, ptr %14, i64 16
  %wide.load = load <2 x i64>, ptr %14, align 8, !tbaa !11
  %wide.load14 = load <2 x i64>, ptr %15, align 8, !tbaa !11
  %16 = getelementptr inbounds i64, ptr %6, i64 %index
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  %wide.load15 = load <2 x i64>, ptr %16, align 8, !tbaa !11
  %wide.load16 = load <2 x i64>, ptr %17, align 8, !tbaa !11
  %18 = xor <2 x i64> %wide.load15, <i64 -1, i64 -1>
  %19 = xor <2 x i64> %wide.load16, <i64 -1, i64 -1>
  %20 = and <2 x i64> %wide.load, %18
  %21 = and <2 x i64> %wide.load14, %19
  %22 = getelementptr inbounds i64, ptr %8, i64 %index
  %23 = getelementptr inbounds i8, ptr %22, i64 16
  store <2 x i64> %20, ptr %22, align 8, !tbaa !11
  store <2 x i64> %21, ptr %23, align 8, !tbaa !11
  %index.next = or disjoint i64 %index, 4
  %24 = getelementptr inbounds i64, ptr %4, i64 %index.next
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  %wide.load.1 = load <2 x i64>, ptr %24, align 8, !tbaa !11
  %wide.load14.1 = load <2 x i64>, ptr %25, align 8, !tbaa !11
  %26 = getelementptr inbounds i64, ptr %6, i64 %index.next
  %27 = getelementptr inbounds i8, ptr %26, i64 16
  %wide.load15.1 = load <2 x i64>, ptr %26, align 8, !tbaa !11
  %wide.load16.1 = load <2 x i64>, ptr %27, align 8, !tbaa !11
  %28 = xor <2 x i64> %wide.load15.1, <i64 -1, i64 -1>
  %29 = xor <2 x i64> %wide.load16.1, <i64 -1, i64 -1>
  %30 = and <2 x i64> %wide.load.1, %28
  %31 = and <2 x i64> %wide.load14.1, %29
  %32 = getelementptr inbounds i64, ptr %8, i64 %index.next
  %33 = getelementptr inbounds i8, ptr %32, i64 16
  store <2 x i64> %30, ptr %32, align 8, !tbaa !11
  store <2 x i64> %31, ptr %33, align 8, !tbaa !11
  %index.next.1 = add nuw nsw i64 %index, 8
  %34 = icmp eq i64 %index.next.1, 1024
  br i1 %34, label %middle.block, label %vector.body, !llvm.loop !13

middle.block:                                     ; preds = %vector.body, %scalar.ph
  store i32 -1, ptr %2, align 8, !tbaa !17
  ret i32 -1

scalar.ph:                                        ; preds = %vector.memcheck, %scalar.ph
  %.012 = phi i64 [ %50, %scalar.ph ], [ 0, %vector.memcheck ]
  %35 = getelementptr inbounds i64, ptr %4, i64 %.012
  %36 = load i64, ptr %35, align 8, !tbaa !11
  %37 = getelementptr inbounds i64, ptr %6, i64 %.012
  %38 = load i64, ptr %37, align 8, !tbaa !11
  %39 = xor i64 %38, -1
  %40 = and i64 %36, %39
  %41 = getelementptr inbounds i64, ptr %8, i64 %.012
  store i64 %40, ptr %41, align 8, !tbaa !11
  %42 = or disjoint i64 %.012, 1
  %43 = getelementptr inbounds i64, ptr %4, i64 %42
  %44 = load i64, ptr %43, align 8, !tbaa !11
  %45 = getelementptr inbounds i64, ptr %6, i64 %42
  %46 = load i64, ptr %45, align 8, !tbaa !11
  %47 = xor i64 %46, -1
  %48 = and i64 %44, %47
  %49 = getelementptr inbounds i64, ptr %8, i64 %42
  store i64 %48, ptr %49, align 8, !tbaa !11
  %50 = add nuw nsw i64 %.012, 2
  %exitcond.not.1 = icmp eq i64 %50, 1024
  br i1 %exitcond.not.1, label %middle.block, label %scalar.ph, !llvm.loop !18
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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" }

!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, !10, i64 8}
!6 = !{!"bitset_container_s", !7, i64 0, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = distinct !{!13, !14, !15, !16}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!"llvm.loop.isvectorized", i32 1}
!16 = !{!"llvm.loop.unroll.runtime.disable"}
!17 = !{!6, !7, i64 0}
!18 = distinct !{!18, !14, !15}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopLoadEliminationPass,LoopRotatePass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass