; 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

declare i64 @bitset_flip_list_withcard(ptr noundef, i64 noundef, ptr noundef, i64 noundef) #1

declare ptr @array_container_from_bitset(ptr noundef) #1

declare void @bitset_container_free(ptr noundef) #1

; 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 zeroext i1 @array_array_container_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, 4096
  br i1 %20, label %21, label %29

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 %5, align 8, !tbaa !5
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  call void @array_container_xor(ptr noundef %25, ptr noundef %26, ptr noundef %28)
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %65

29:                                               ; preds = %3
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = call ptr @bitset_container_from_array(ptr noundef %30)
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %31, ptr %32, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #3
  store i8 1, ptr %10, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  store ptr %34, ptr %11, align 8, !tbaa !5
  %35 = load ptr, ptr %11, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.bitset_container_s, ptr %35, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !15
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.array_container_s, ptr %38, i32 0, i32 0
  %40 = load i32, ptr %39, align 8, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.array_container_s, ptr %42, i32 0, i32 2
  %44 = load ptr, ptr %43, align 8, !tbaa !17
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.array_container_s, ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 8, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = call i64 @bitset_flip_list_withcard(ptr noundef %37, i64 noundef %41, ptr noundef %44, i64 noundef %48)
  %50 = trunc i64 %49 to i32
  %51 = load ptr, ptr %11, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.bitset_container_s, ptr %51, i32 0, i32 0
  store i32 %50, ptr %52, align 8, !tbaa !18
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.bitset_container_s, ptr %53, i32 0, i32 0
  %55 = load i32, ptr %54, align 8, !tbaa !18
  %56 = icmp sle i32 %55, 4096
  br i1 %56, label %57, label %62

57:                                               ; preds = %29
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = call ptr @array_container_from_bitset(ptr noundef %58)
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %59, ptr %60, align 8, !tbaa !5
  %61 = load ptr, ptr %11, align 8, !tbaa !5
  call void @bitset_container_free(ptr noundef %61)
  store i8 0, ptr %10, align 1, !tbaa !13
  br label %62

62:                                               ; preds = %57, %29
  %63 = load i8, ptr %10, align 1, !tbaa !13, !range !19, !noundef !20
  %64 = trunc i8 %63 to i1
  store i1 %64, ptr %4, align 1
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #3
  br label %65

65:                                               ; preds = %62, %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %66 = load i1, ptr %4, align 1
  ret i1 %66
}

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

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 i64 @bitset_flip_list_withcard(ptr noundef, i64 noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

declare ptr @array_container_from_bitset(ptr noundef) local_unnamed_addr #0

declare void @bitset_container_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef zeroext i1 @array_array_container_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 slt i32 %6, 4097
  br i1 %7, label %8, label %10

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
  tail call void @array_container_xor(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef %9) #2
  br label %25

10:                                               ; preds = %3
  %11 = tail call ptr @bitset_container_from_array(ptr noundef nonnull %0) #2
  store ptr %11, ptr %2, align 8, !tbaa !11
  %12 = getelementptr inbounds i8, ptr %11, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !12
  %14 = load i32, ptr %0, align 8, !tbaa !5
  %15 = sext i32 %14 to i64
  %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
  %20 = tail call i64 @bitset_flip_list_withcard(ptr noundef %13, i64 noundef %15, ptr noundef %17, i64 noundef %19) #2
  %21 = trunc i64 %20 to i32
  store i32 %21, ptr %11, align 8, !tbaa !15
  %22 = icmp sgt i32 %21, 4096
  br i1 %22, label %25, label %23

23:                                               ; preds = %10
  %24 = tail call ptr @array_container_from_bitset(ptr noundef nonnull %11) #2
  store ptr %24, ptr %2, align 8, !tbaa !11
  tail call void @bitset_container_free(ptr noundef nonnull %11) #2
  br label %25

25:                                               ; preds = %10, %23, %8
  %.0 = phi i1 [ false, %8 ], [ false, %23 ], [ true, %10 ]
  ret i1 %.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

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: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass