; 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_xor_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 = %37, %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 %40

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 %28, %32
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = load i64, ptr %10, align 8, !tbaa !12
  %36 = getelementptr inbounds i64, ptr %34, i64 %35
  store i64 %33, ptr %36, align 8, !tbaa !12
  br label %37

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

40:                                               ; preds = %23
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.bitset_container_s, ptr %41, i32 0, i32 0
  store i32 -1, ptr %42, align 8, !tbaa !16
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.bitset_container_s, ptr %43, i32 0, i32 0
  %45 = load i32, ptr %44, 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 %45
}

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_xor_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, %wide.load
  %19 = xor <2 x i64> %wide.load16, %wide.load14
  %20 = getelementptr inbounds i64, ptr %8, i64 %index
  %21 = getelementptr inbounds i8, ptr %20, i64 16
  store <2 x i64> %18, ptr %20, align 8, !tbaa !11
  store <2 x i64> %19, ptr %21, align 8, !tbaa !11
  %index.next = or disjoint i64 %index, 4
  %22 = getelementptr inbounds i64, ptr %4, i64 %index.next
  %23 = getelementptr inbounds i8, ptr %22, i64 16
  %wide.load.1 = load <2 x i64>, ptr %22, align 8, !tbaa !11
  %wide.load14.1 = load <2 x i64>, ptr %23, align 8, !tbaa !11
  %24 = getelementptr inbounds i64, ptr %6, i64 %index.next
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  %wide.load15.1 = load <2 x i64>, ptr %24, align 8, !tbaa !11
  %wide.load16.1 = load <2 x i64>, ptr %25, align 8, !tbaa !11
  %26 = xor <2 x i64> %wide.load15.1, %wide.load.1
  %27 = xor <2 x i64> %wide.load16.1, %wide.load14.1
  %28 = getelementptr inbounds i64, ptr %8, i64 %index.next
  %29 = getelementptr inbounds i8, ptr %28, i64 16
  store <2 x i64> %26, ptr %28, align 8, !tbaa !11
  store <2 x i64> %27, ptr %29, align 8, !tbaa !11
  %index.next.1 = add nuw nsw i64 %index, 8
  %30 = icmp eq i64 %index.next.1, 1024
  br i1 %30, 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 [ %58, %scalar.ph ], [ 0, %vector.memcheck ]
  %31 = getelementptr inbounds i64, ptr %4, i64 %.012
  %32 = load i64, ptr %31, align 8, !tbaa !11
  %33 = getelementptr inbounds i64, ptr %6, i64 %.012
  %34 = load i64, ptr %33, align 8, !tbaa !11
  %35 = xor i64 %34, %32
  %36 = getelementptr inbounds i64, ptr %8, i64 %.012
  store i64 %35, ptr %36, align 8, !tbaa !11
  %37 = or disjoint i64 %.012, 1
  %38 = getelementptr inbounds i64, ptr %4, i64 %37
  %39 = load i64, ptr %38, align 8, !tbaa !11
  %40 = getelementptr inbounds i64, ptr %6, i64 %37
  %41 = load i64, ptr %40, align 8, !tbaa !11
  %42 = xor i64 %41, %39
  %43 = getelementptr inbounds i64, ptr %8, i64 %37
  store i64 %42, ptr %43, align 8, !tbaa !11
  %44 = or disjoint i64 %.012, 2
  %45 = getelementptr inbounds i64, ptr %4, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !11
  %47 = getelementptr inbounds i64, ptr %6, i64 %44
  %48 = load i64, ptr %47, align 8, !tbaa !11
  %49 = xor i64 %48, %46
  %50 = getelementptr inbounds i64, ptr %8, i64 %44
  store i64 %49, ptr %50, align 8, !tbaa !11
  %51 = or disjoint i64 %.012, 3
  %52 = getelementptr inbounds i64, ptr %4, i64 %51
  %53 = load i64, ptr %52, align 8, !tbaa !11
  %54 = getelementptr inbounds i64, ptr %6, i64 %51
  %55 = load i64, ptr %54, align 8, !tbaa !11
  %56 = xor i64 %55, %53
  %57 = getelementptr inbounds i64, ptr %8, i64 %51
  store i64 %56, ptr %57, align 8, !tbaa !11
  %58 = add nuw nsw i64 %.012, 4
  %exitcond.not.3 = icmp eq i64 %58, 1024
  br i1 %exitcond.not.3, 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