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

; 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.array_container_s = type { i32, i32, ptr }
%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

declare void @bitset_flip_list(ptr noundef, ptr noundef, i64 noundef) #1

declare ptr @array_container_create_given_capacity(i32 noundef) #1

declare void @array_container_xor(ptr noundef, ptr noundef, ptr noundef) #1

declare ptr @bitset_container_from_array(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @array_array_container_lazy_xor(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.array_container_s, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !9
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.array_container_s, ptr %15, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !9
  %18 = add nsw i32 %14, %17
  store i32 %18, ptr %8, align 4, !tbaa !12
  %19 = load i32, ptr %8, align 4, !tbaa !12
  %20 = icmp sle i32 %19, 1024
  br i1 %20, label %21, label %34

21:                                               ; preds = %3
  %22 = load i32, ptr %8, align 4, !tbaa !12
  %23 = call ptr @array_container_create_given_capacity(i32 noundef %22)
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %23, ptr %24, align 8, !tbaa !5
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %33

28:                                               ; preds = %21
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  call void @array_container_xor(ptr noundef %29, ptr noundef %30, ptr noundef %32)
  br label %33

33:                                               ; preds = %28, %21
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %59

34:                                               ; preds = %3
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = call ptr @bitset_container_from_array(ptr noundef %35)
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %36, ptr %37, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #3
  store i8 1, ptr %10, align 1, !tbaa !13
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %56

41:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  store ptr %43, ptr %11, align 8, !tbaa !5
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.bitset_container_s, ptr %44, i32 0, i32 1
  %46 = load ptr, ptr %45, align 8, !tbaa !15
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.array_container_s, ptr %47, i32 0, i32 2
  %49 = load ptr, ptr %48, align 8, !tbaa !17
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.array_container_s, ptr %50, i32 0, i32 0
  %52 = load i32, ptr %51, align 8, !tbaa !9
  %53 = sext i32 %52 to i64
  call void @bitset_flip_list(ptr noundef %46, ptr noundef %49, i64 noundef %53)
  %54 = load ptr, ptr %11, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.bitset_container_s, ptr %54, i32 0, i32 0
  store i32 -1, ptr %55, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  br label %56

56:                                               ; preds = %41, %34
  %57 = load i8, ptr %10, align 1, !tbaa !13, !range !19, !noundef !20
  %58 = trunc i8 %57 to i1
  store i1 %58, ptr %4, align 1
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #3
  br label %59

59:                                               ; preds = %56, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %60 = load i1, ptr %4, align 1
  ret i1 %60
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #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 #2 = { 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 #3 = { 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, !11, i64 0}
!10 = !{!"array_container_s", !11, i64 0, !11, i64 4, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!16, !6, i64 8}
!16 = !{!"bitset_container_s", !11, i64 0, !6, i64 8}
!17 = !{!10, !6, i64 8}
!18 = !{!16, !11, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}


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

declare void @bitset_flip_list(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

declare ptr @array_container_create_given_capacity(i32 noundef) local_unnamed_addr #0

declare void @array_container_xor(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare ptr @bitset_container_from_array(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @array_array_container_lazy_xor(ptr noundef %0, ptr noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = load i32, ptr %0, align 8, !tbaa !5
  %5 = load i32, ptr %1, align 8, !tbaa !5
  %6 = add nsw i32 %5, %4
  %7 = icmp sgt i32 %6, 1024
  br i1 %7, label %11, label %8

8:                                                ; preds = %3
  %9 = tail call ptr @array_container_create_given_capacity(i32 noundef %6) #2
  store ptr %9, ptr %2, align 8, !tbaa !11
  %.not21 = icmp eq ptr %9, null
  br i1 %.not21, label %20, label %10

10:                                               ; preds = %8
  tail call void @array_container_xor(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %9) #2
  br label %20

11:                                               ; preds = %3
  %12 = tail call ptr @bitset_container_from_array(ptr noundef nonnull %0) #2
  store ptr %12, ptr %2, align 8, !tbaa !11
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %20, label %13

13:                                               ; preds = %11
  %14 = getelementptr inbounds i8, ptr %12, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  %16 = getelementptr inbounds i8, ptr %1, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = load i32, ptr %1, align 8, !tbaa !5
  %19 = sext i32 %18 to i64
  tail call void @bitset_flip_list(ptr noundef %15, ptr noundef %17, i64 noundef %19) #2
  store i32 -1, ptr %12, align 8, !tbaa !15
  br label %20

20:                                               ; preds = %11, %13, %8, %10
  ret i1 %7
}

attributes #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 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, !7, i64 0}
!6 = !{!"array_container_s", !7, i64 0, !7, i64 4, !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 = !{!10, !10, i64 0}
!12 = !{!13, !10, i64 8}
!13 = !{!"bitset_container_s", !7, i64 0, !10, i64 8}
!14 = !{!6, !10, i64 8}
!15 = !{!13, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass