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

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @array_container_equal_bitset(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i16, align 2
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.bitset_container_s, ptr %12, i32 0, i32 0
  %14 = load i32, ptr %13, align 8, !tbaa !9
  %15 = icmp ne i32 %14, -1
  br i1 %15, label %16, label %26

16:                                               ; preds = %2
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.bitset_container_s, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !9
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.array_container_s, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !12
  %23 = icmp ne i32 %19, %22
  br i1 %23, label %24, label %25

24:                                               ; preds = %16
  store i1 false, ptr %3, align 1
  br label %99

25:                                               ; preds = %16
  br label %26

26:                                               ; preds = %25, %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !14
  br label %27

27:                                               ; preds = %87, %26
  %28 = load i32, ptr %7, align 4, !tbaa !14
  %29 = icmp slt i32 %28, 1024
  br i1 %29, label %31, label %30

30:                                               ; preds = %27
  store i32 2, ptr %8, align 4
  br label %90

31:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.bitset_container_s, ptr %32, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !15
  %35 = load i32, ptr %7, align 4, !tbaa !14
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds i64, ptr %34, i64 %36
  %38 = load i64, ptr %37, align 8, !tbaa !16
  store i64 %38, ptr %9, align 8, !tbaa !16
  br label %39

39:                                               ; preds = %82, %31
  %40 = load i64, ptr %9, align 8, !tbaa !16
  %41 = icmp ne i64 %40, 0
  br i1 %41, label %42, label %83

42:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %43 = load i64, ptr %9, align 8, !tbaa !16
  %44 = load i64, ptr %9, align 8, !tbaa !16
  %45 = xor i64 %44, -1
  %46 = add i64 %45, 1
  %47 = and i64 %43, %46
  store i64 %47, ptr %10, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 2, ptr %11) #3
  %48 = load i32, ptr %7, align 4, !tbaa !14
  %49 = mul nsw i32 %48, 64
  %50 = load i64, ptr %9, align 8, !tbaa !16
  %51 = call i64 @llvm.cttz.i64(i64 %50, i1 true)
  %52 = trunc i64 %51 to i32
  %53 = add nsw i32 %49, %52
  %54 = trunc i32 %53 to i16
  store i16 %54, ptr %11, align 2, !tbaa !18
  %55 = load i32, ptr %6, align 4, !tbaa !14
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.array_container_s, ptr %56, i32 0, i32 0
  %58 = load i32, ptr %57, align 8, !tbaa !12
  %59 = icmp sge i32 %55, %58
  br i1 %59, label %60, label %61

60:                                               ; preds = %42
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %80

61:                                               ; preds = %42
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.array_container_s, ptr %62, i32 0, i32 2
  %64 = load ptr, ptr %63, align 8, !tbaa !20
  %65 = load i32, ptr %6, align 4, !tbaa !14
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds i16, ptr %64, i64 %66
  %68 = load i16, ptr %67, align 2, !tbaa !18
  %69 = zext i16 %68 to i32
  %70 = load i16, ptr %11, align 2, !tbaa !18
  %71 = zext i16 %70 to i32
  %72 = icmp ne i32 %69, %71
  br i1 %72, label %73, label %74

73:                                               ; preds = %61
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %80

74:                                               ; preds = %61
  %75 = load i32, ptr %6, align 4, !tbaa !14
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %6, align 4, !tbaa !14
  %77 = load i64, ptr %10, align 8, !tbaa !16
  %78 = load i64, ptr %9, align 8, !tbaa !16
  %79 = xor i64 %78, %77
  store i64 %79, ptr %9, align 8, !tbaa !16
  store i32 0, ptr %8, align 4
  br label %80

80:                                               ; preds = %74, %73, %60
  call void @llvm.lifetime.end.p0(i64 2, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %81 = load i32, ptr %8, align 4
  switch i32 %81, label %84 [
    i32 0, label %82
  ]

82:                                               ; preds = %80
  br label %39, !llvm.loop !21

83:                                               ; preds = %39
  store i32 0, ptr %8, align 4
  br label %84

84:                                               ; preds = %83, %80
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  %85 = load i32, ptr %8, align 4
  switch i32 %85, label %90 [
    i32 0, label %86
  ]

86:                                               ; preds = %84
  br label %87

87:                                               ; preds = %86
  %88 = load i32, ptr %7, align 4, !tbaa !14
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %7, align 4, !tbaa !14
  br label %27, !llvm.loop !23

90:                                               ; preds = %84, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  %91 = load i32, ptr %8, align 4
  switch i32 %91, label %98 [
    i32 2, label %92
  ]

92:                                               ; preds = %90
  %93 = load i32, ptr %6, align 4, !tbaa !14
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.array_container_s, ptr %94, i32 0, i32 0
  %96 = load i32, ptr %95, align 8, !tbaa !12
  %97 = icmp eq i32 %93, %96
  store i1 %97, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %98

98:                                               ; preds = %92, %90
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %99

99:                                               ; preds = %98, %24
  %100 = load i1, ptr %3, align 1
  ret i1 %100
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.cttz.i64(i64, i1 immarg) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"bitset_container_s", !11, i64 0, !6, i64 8}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 0}
!13 = !{!"array_container_s", !11, i64 0, !11, i64 4, !6, i64 8}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !6, i64 8}
!16 = !{!17, !17, i64 0}
!17 = !{!"long", !7, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"short", !7, i64 0}
!20 = !{!13, !6, i64 8}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}


; 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(read, inaccessiblemem: none) uwtable
define dso_local zeroext i1 @array_container_equal_bitset(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = load i32, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i32 %3, -1
  br i1 %.not, label %6, label %4

4:                                                ; preds = %2
  %5 = load i32, ptr %0, align 8, !tbaa !11
  %.not39 = icmp eq i32 %3, %5
  br i1 %.not39, label %6, label %.loopexit

6:                                                ; preds = %4, %2
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  br label %10

10:                                               ; preds = %6, %._crit_edge
  %indvars.iv58 = phi i64 [ 0, %6 ], [ %indvars.iv.next59, %._crit_edge ]
  %.02756 = phi i32 [ 0, %6 ], [ %.128.lcssa, %._crit_edge ]
  %11 = getelementptr inbounds i64, ptr %8, i64 %indvars.iv58
  %12 = load i64, ptr %11, align 8, !tbaa !14
  %.not4052 = icmp eq i64 %12, 0
  br i1 %.not4052, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %10
  %13 = load i32, ptr %0, align 8, !tbaa !11
  %14 = sext i32 %.02756 to i64
  %smax = tail call i32 @llvm.smax.i32(i32 %.02756, i32 %13)
  %wide.trip.count = sext i32 %smax to i64
  %indvars.iv58.tr = trunc i64 %indvars.iv58 to i32
  %15 = shl i32 %indvars.iv58.tr, 6
  br label %16

16:                                               ; preds = %.lr.ph, %25
  %indvars.iv = phi i64 [ %14, %.lr.ph ], [ %indvars.iv.next, %25 ]
  %.03253 = phi i64 [ %12, %.lr.ph ], [ %27, %25 ]
  %exitcond.not = icmp eq i64 %indvars.iv, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %17

17:                                               ; preds = %16
  %18 = tail call range(i64 0, 65) i64 @llvm.cttz.i64(i64 %.03253, i1 true)
  %19 = trunc nuw nsw i64 %18 to i32
  %20 = or disjoint i32 %15, %19
  %21 = load ptr, ptr %9, align 8, !tbaa !16
  %22 = getelementptr inbounds i16, ptr %21, i64 %indvars.iv
  %23 = load i16, ptr %22, align 2, !tbaa !17
  %24 = zext i16 %23 to i32
  %.not42 = icmp eq i32 %20, %24
  br i1 %.not42, label %25, label %.loopexit

25:                                               ; preds = %17
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %26 = add i64 %.03253, -1
  %27 = and i64 %26, %.03253
  %.not40 = icmp eq i64 %27, 0
  br i1 %.not40, label %._crit_edge.loopexit, label %16, !llvm.loop !19

._crit_edge.loopexit:                             ; preds = %25
  %28 = trunc nsw i64 %indvars.iv.next to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %10
  %.128.lcssa = phi i32 [ %.02756, %10 ], [ %28, %._crit_edge.loopexit ]
  %indvars.iv.next59 = add nuw nsw i64 %indvars.iv58, 1
  %exitcond61 = icmp eq i64 %indvars.iv.next59, 1024
  br i1 %exitcond61, label %.thread47, label %10, !llvm.loop !21

.thread47:                                        ; preds = %._crit_edge
  %29 = load i32, ptr %0, align 8, !tbaa !11
  %30 = icmp eq i32 %.128.lcssa, %29
  br label %.loopexit

.loopexit:                                        ; preds = %16, %17, %.thread47, %4
  %.6 = phi i1 [ false, %4 ], [ %30, %.thread47 ], [ false, %17 ], [ false, %16 ]
  ret i1 %.6
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.cttz.i64(i64, i1 immarg) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #2

attributes #0 = { nofree norecurse nosync nounwind memory(read, 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" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"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, !7, i64 0}
!12 = !{!"array_container_s", !7, i64 0, !7, i64 4, !10, i64 8}
!13 = !{!6, !10, i64 8}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !8, i64 0}
!16 = !{!12, !10, i64 8}
!17 = !{!18, !18, i64 0}
!18 = !{!"short", !8, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass