; LLVM IR from jermp/2i_bench :: external/CRoaring/tests (bitset_container_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.1 = external hidden unnamed_addr constant [96 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [33 x i8], align 1

; 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 ptr @bitset_container_create() #1

declare void @bitset_container_free(ptr noundef) #1

declare void @_assert_true(i64 noundef, ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @bitset_container_set(ptr noundef, i16 noundef zeroext) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @bitset_container_unset(ptr noundef, i16 noundef zeroext) #2

; Function Attrs: nounwind uwtable
define dso_local void @xor_test() #3 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  %8 = call ptr @bitset_container_create()
  store ptr %8, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  %9 = call ptr @bitset_container_create()
  store ptr %9, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %10 = call ptr @bitset_container_create()
  store ptr %10, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %11 = call ptr @bitset_container_create()
  store ptr %11, ptr %4, align 8, !tbaa !5
  %12 = load ptr, ptr %1, align 8, !tbaa !5
  %13 = ptrtoint ptr %12 to i64
  call void @_assert_true(i64 noundef %13, ptr noundef @.str.7, ptr noundef @.str.1, i32 noundef 135)
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = ptrtoint ptr %14 to i64
  call void @_assert_true(i64 noundef %15, ptr noundef @.str.8, ptr noundef @.str.1, i32 noundef 136)
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = ptrtoint ptr %16 to i64
  call void @_assert_true(i64 noundef %17, ptr noundef @.str.9, ptr noundef @.str.1, i32 noundef 137)
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = ptrtoint ptr %18 to i64
  call void @_assert_true(i64 noundef %19, ptr noundef @.str.11, ptr noundef @.str.1, i32 noundef 138)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %20

20:                                               ; preds = %31, %0
  %21 = load i64, ptr %5, align 8, !tbaa !9
  %22 = icmp ult i64 %21, 65536
  br i1 %22, label %24, label %23

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

24:                                               ; preds = %20
  %25 = load ptr, ptr %1, align 8, !tbaa !5
  %26 = load i64, ptr %5, align 8, !tbaa !9
  %27 = trunc i64 %26 to i16
  call void @bitset_container_set(ptr noundef %25, i16 noundef zeroext %27)
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = load i64, ptr %5, align 8, !tbaa !9
  %30 = trunc i64 %29 to i16
  call void @bitset_container_set(ptr noundef %28, i16 noundef zeroext %30)
  br label %31

31:                                               ; preds = %24
  %32 = load i64, ptr %5, align 8, !tbaa !9
  %33 = add i64 %32, 3
  store i64 %33, ptr %5, align 8, !tbaa !9
  br label %20, !llvm.loop !11

34:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %35

35:                                               ; preds = %46, %34
  %36 = load i64, ptr %6, align 8, !tbaa !9
  %37 = icmp ult i64 %36, 65536
  br i1 %37, label %39, label %38

38:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  br label %49

39:                                               ; preds = %35
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = load i64, ptr %6, align 8, !tbaa !9
  %42 = trunc i64 %41 to i16
  call void @bitset_container_set(ptr noundef %40, i16 noundef zeroext %42)
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = load i64, ptr %6, align 8, !tbaa !9
  %45 = trunc i64 %44 to i16
  call void @bitset_container_set(ptr noundef %43, i16 noundef zeroext %45)
  br label %46

46:                                               ; preds = %39
  %47 = load i64, ptr %6, align 8, !tbaa !9
  %48 = add i64 %47, 62
  store i64 %48, ptr %6, align 8, !tbaa !9
  br label %35, !llvm.loop !13

49:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %50

50:                                               ; preds = %58, %49
  %51 = load i64, ptr %7, align 8, !tbaa !9
  %52 = icmp ult i64 %51, 65536
  br i1 %52, label %54, label %53

53:                                               ; preds = %50
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %61

54:                                               ; preds = %50
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = load i64, ptr %7, align 8, !tbaa !9
  %57 = trunc i64 %56 to i16
  call void @bitset_container_unset(ptr noundef %55, i16 noundef zeroext %57)
  br label %58

58:                                               ; preds = %54
  %59 = load i64, ptr %7, align 8, !tbaa !9
  %60 = add i64 %59, 186
  store i64 %60, ptr %7, align 8, !tbaa !9
  br label %50, !llvm.loop !14

61:                                               ; preds = %53
  %62 = load ptr, ptr %1, align 8, !tbaa !5
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  %65 = call i32 @bitset_container_xor(ptr noundef %62, ptr noundef %63, ptr noundef %64)
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = load ptr, ptr %3, align 8, !tbaa !5
  %68 = call zeroext i1 @bitset_container_equals(ptr noundef %66, ptr noundef %67)
  %69 = zext i1 %68 to i64
  call void @_assert_true(i64 noundef %69, ptr noundef @.str.12, ptr noundef @.str.1, i32 noundef 156)
  %70 = load ptr, ptr %1, align 8, !tbaa !5
  call void @bitset_container_free(ptr noundef %70)
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  call void @bitset_container_free(ptr noundef %71)
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  call void @bitset_container_free(ptr noundef %72)
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  call void @bitset_container_free(ptr noundef %73)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret void
}

declare i32 @bitset_container_xor(ptr noundef, ptr noundef, ptr noundef) #1

declare zeroext i1 @bitset_container_equals(ptr noundef, 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 = { inlinehint 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 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 #4 = { 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


; 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.1 = external hidden unnamed_addr constant [96 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [33 x i8], align 1

declare ptr @bitset_container_create() local_unnamed_addr #0

declare void @bitset_container_free(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @bitset_container_set(ptr noundef, i16 noundef zeroext) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @bitset_container_unset(ptr noundef, i16 noundef zeroext) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @xor_test() local_unnamed_addr #2 {
  %1 = tail call ptr @bitset_container_create() #3
  %2 = tail call ptr @bitset_container_create() #3
  %3 = tail call ptr @bitset_container_create() #3
  %4 = tail call ptr @bitset_container_create() #3
  %5 = ptrtoint ptr %1 to i64
  tail call void @_assert_true(i64 noundef %5, ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.1, i32 noundef 135) #3
  %6 = ptrtoint ptr %2 to i64
  tail call void @_assert_true(i64 noundef %6, ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.1, i32 noundef 136) #3
  %7 = ptrtoint ptr %3 to i64
  tail call void @_assert_true(i64 noundef %7, ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.1, i32 noundef 137) #3
  %8 = ptrtoint ptr %4 to i64
  tail call void @_assert_true(i64 noundef %8, ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.1, i32 noundef 138) #3
  br label %9

9:                                                ; preds = %0, %9
  %.02931 = phi i64 [ 0, %0 ], [ %11, %9 ]
  %10 = trunc nuw i64 %.02931 to i16
  tail call void @bitset_container_set(ptr noundef %1, i16 noundef zeroext %10)
  tail call void @bitset_container_set(ptr noundef %3, i16 noundef zeroext %10)
  %11 = add nuw nsw i64 %.02931, 3
  %12 = icmp ult i64 %.02931, 65533
  br i1 %12, label %9, label %.preheader30, !llvm.loop !5

.preheader30:                                     ; preds = %9, %.preheader30
  %.02832 = phi i64 [ %14, %.preheader30 ], [ 0, %9 ]
  %13 = trunc nuw i64 %.02832 to i16
  tail call void @bitset_container_set(ptr noundef %2, i16 noundef zeroext %13)
  tail call void @bitset_container_set(ptr noundef %3, i16 noundef zeroext %13)
  %14 = add nuw nsw i64 %.02832, 62
  %15 = icmp ult i64 %.02832, 65474
  br i1 %15, label %.preheader30, label %.preheader, !llvm.loop !7

16:                                               ; preds = %.preheader
  %17 = tail call i32 @bitset_container_xor(ptr noundef %1, ptr noundef %2, ptr noundef %4) #3
  %18 = tail call zeroext i1 @bitset_container_equals(ptr noundef %4, ptr noundef %3) #3
  %19 = zext i1 %18 to i64
  tail call void @_assert_true(i64 noundef %19, ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.1, i32 noundef 156) #3
  tail call void @bitset_container_free(ptr noundef %1) #3
  tail call void @bitset_container_free(ptr noundef %2) #3
  tail call void @bitset_container_free(ptr noundef %3) #3
  tail call void @bitset_container_free(ptr noundef %4) #3
  ret void

.preheader:                                       ; preds = %.preheader30, %.preheader
  %.033 = phi i64 [ %21, %.preheader ], [ 0, %.preheader30 ]
  %20 = trunc nuw i64 %.033 to i16
  tail call void @bitset_container_unset(ptr noundef %3, i16 noundef zeroext %20)
  %21 = add nuw nsw i64 %.033, 186
  %22 = icmp ult i64 %.033, 65350
  br i1 %22, label %.preheader, label %16, !llvm.loop !8
}

declare i32 @bitset_container_xor(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

declare zeroext i1 @bitset_container_equals(ptr noundef, 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 = { inlinehint 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 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = distinct !{!8, !6}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass