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

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

; 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 @get_copy_of_container(ptr noundef, ptr noundef, i1 noundef zeroext) #1

declare ptr @container_clone(ptr noundef, i8 noundef zeroext) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @extend_array(ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @ra_append_copy_range(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i1 noundef zeroext %4) #2 {
  %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 i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  %13 = zext i1 %4 to i8
  store i8 %13, ptr %10, align 1, !tbaa !11
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = load i32, ptr %9, align 4, !tbaa !9
  %16 = load i32, ptr %8, align 4, !tbaa !9
  %17 = sub nsw i32 %15, %16
  %18 = call zeroext i1 @extend_array(ptr noundef %14, i32 noundef %17)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %19 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %19, ptr %11, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %133, %5
  %21 = load i32, ptr %11, align 4, !tbaa !9
  %22 = load i32, ptr %9, align 4, !tbaa !9
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %25, label %24

24:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %136

25:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.roaring_array_s, ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !13
  store i32 %28, ptr %12, align 4, !tbaa !9
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.roaring_array_s, ptr %29, i32 0, i32 3
  %31 = load ptr, ptr %30, align 8, !tbaa !15
  %32 = load i32, ptr %11, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i16, ptr %31, i64 %33
  %35 = load i16, ptr %34, align 2, !tbaa !16
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.roaring_array_s, ptr %36, i32 0, i32 3
  %38 = load ptr, ptr %37, align 8, !tbaa !15
  %39 = load i32, ptr %12, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i16, ptr %38, i64 %40
  store i16 %35, ptr %41, align 2, !tbaa !16
  %42 = load i8, ptr %10, align 1, !tbaa !11, !range !18, !noundef !19
  %43 = trunc i8 %42 to i1
  br i1 %43, label %44, label %93

44:                                               ; preds = %25
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.roaring_array_s, ptr %45, i32 0, i32 2
  %47 = load ptr, ptr %46, align 8, !tbaa !20
  %48 = load i32, ptr %11, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds ptr, ptr %47, i64 %49
  %51 = load ptr, ptr %50, align 8, !tbaa !5
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.roaring_array_s, ptr %52, i32 0, i32 4
  %54 = load ptr, ptr %53, align 8, !tbaa !21
  %55 = load i32, ptr %11, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds i8, ptr %54, i64 %56
  %58 = load i8, ptr %10, align 1, !tbaa !11, !range !18, !noundef !19
  %59 = trunc i8 %58 to i1
  %60 = call ptr @get_copy_of_container(ptr noundef %51, ptr noundef %57, i1 noundef zeroext %59)
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.roaring_array_s, ptr %61, i32 0, i32 2
  %63 = load ptr, ptr %62, align 8, !tbaa !20
  %64 = load i32, ptr %11, align 4, !tbaa !9
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds ptr, ptr %63, i64 %65
  store ptr %60, ptr %66, align 8, !tbaa !5
  %67 = load ptr, ptr %7, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.roaring_array_s, ptr %67, i32 0, i32 2
  %69 = load ptr, ptr %68, align 8, !tbaa !20
  %70 = load i32, ptr %11, align 4, !tbaa !9
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds ptr, ptr %69, i64 %71
  %73 = load ptr, ptr %72, align 8, !tbaa !5
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.roaring_array_s, ptr %74, i32 0, i32 2
  %76 = load ptr, ptr %75, align 8, !tbaa !20
  %77 = load i32, ptr %12, align 4, !tbaa !9
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds ptr, ptr %76, i64 %78
  store ptr %73, ptr %79, align 8, !tbaa !5
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.roaring_array_s, ptr %80, i32 0, i32 4
  %82 = load ptr, ptr %81, align 8, !tbaa !21
  %83 = load i32, ptr %11, align 4, !tbaa !9
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds i8, ptr %82, i64 %84
  %86 = load i8, ptr %85, align 1, !tbaa !22
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.roaring_array_s, ptr %87, i32 0, i32 4
  %89 = load ptr, ptr %88, align 8, !tbaa !21
  %90 = load i32, ptr %12, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds i8, ptr %89, i64 %91
  store i8 %86, ptr %92, align 1, !tbaa !22
  br label %128

93:                                               ; preds = %25
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.roaring_array_s, ptr %94, i32 0, i32 2
  %96 = load ptr, ptr %95, align 8, !tbaa !20
  %97 = load i32, ptr %11, align 4, !tbaa !9
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds ptr, ptr %96, i64 %98
  %100 = load ptr, ptr %99, align 8, !tbaa !5
  %101 = load ptr, ptr %7, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.roaring_array_s, ptr %101, i32 0, i32 4
  %103 = load ptr, ptr %102, align 8, !tbaa !21
  %104 = load i32, ptr %11, align 4, !tbaa !9
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds i8, ptr %103, i64 %105
  %107 = load i8, ptr %106, align 1, !tbaa !22
  %108 = call ptr @container_clone(ptr noundef %100, i8 noundef zeroext %107)
  %109 = load ptr, ptr %6, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.roaring_array_s, ptr %109, i32 0, i32 2
  %111 = load ptr, ptr %110, align 8, !tbaa !20
  %112 = load i32, ptr %12, align 4, !tbaa !9
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds ptr, ptr %111, i64 %113
  store ptr %108, ptr %114, align 8, !tbaa !5
  %115 = load ptr, ptr %7, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.roaring_array_s, ptr %115, i32 0, i32 4
  %117 = load ptr, ptr %116, align 8, !tbaa !21
  %118 = load i32, ptr %11, align 4, !tbaa !9
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds i8, ptr %117, i64 %119
  %121 = load i8, ptr %120, align 1, !tbaa !22
  %122 = load ptr, ptr %6, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.roaring_array_s, ptr %122, i32 0, i32 4
  %124 = load ptr, ptr %123, align 8, !tbaa !21
  %125 = load i32, ptr %12, align 4, !tbaa !9
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds i8, ptr %124, i64 %126
  store i8 %121, ptr %127, align 1, !tbaa !22
  br label %128

128:                                              ; preds = %93, %44
  %129 = load ptr, ptr %6, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.roaring_array_s, ptr %129, i32 0, i32 0
  %131 = load i32, ptr %130, align 8, !tbaa !13
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %130, align 8, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %133

133:                                              ; preds = %128
  %134 = load i32, ptr %11, align 4, !tbaa !9
  %135 = add nsw i32 %134, 1
  store i32 %135, ptr %11, align 4, !tbaa !9
  br label %20, !llvm.loop !23

136:                                              ; preds = %24
  ret void
}

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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"roaring_array_s", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !7, i64 32}
!15 = !{!14, !6, i64 16}
!16 = !{!17, !17, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!14, !6, i64 8}
!21 = !{!14, !6, i64 24}
!22 = !{!7, !7, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


; 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 ptr @get_copy_of_container(ptr noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #0

declare ptr @container_clone(ptr noundef, i8 noundef zeroext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @extend_array(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @ra_append_copy_range(ptr noundef %0, ptr nocapture noundef readonly %1, i32 noundef %2, i32 noundef %3, i1 noundef zeroext %4) local_unnamed_addr #1 {
  %6 = sub nsw i32 %3, %2
  %7 = tail call zeroext i1 @extend_array(ptr noundef %0, i32 noundef %6)
  %8 = icmp slt i32 %2, %3
  br i1 %8, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %5
  %9 = getelementptr inbounds i8, ptr %1, i64 16
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = getelementptr inbounds i8, ptr %1, i64 24
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = sext i32 %2 to i64
  %.pre47 = load i32, ptr %0, align 8, !tbaa !5
  br i1 %4, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %.lr.ph.split.us
  %16 = phi i32 [ %42, %.lr.ph.split.us ], [ %.pre47, %.lr.ph ]
  %indvars.iv42 = phi i64 [ %indvars.iv.next43, %.lr.ph.split.us ], [ %15, %.lr.ph ]
  %17 = load ptr, ptr %9, align 8, !tbaa !11
  %18 = getelementptr inbounds i16, ptr %17, i64 %indvars.iv42
  %19 = load i16, ptr %18, align 2, !tbaa !12
  %20 = load ptr, ptr %10, align 8, !tbaa !11
  %21 = sext i32 %16 to i64
  %22 = getelementptr inbounds i16, ptr %20, i64 %21
  store i16 %19, ptr %22, align 2, !tbaa !12
  %23 = load ptr, ptr %11, align 8, !tbaa !14
  %24 = getelementptr inbounds ptr, ptr %23, i64 %indvars.iv42
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  %26 = load ptr, ptr %12, align 8, !tbaa !16
  %27 = getelementptr inbounds i8, ptr %26, i64 %indvars.iv42
  %28 = tail call ptr @get_copy_of_container(ptr noundef %25, ptr noundef %27, i1 noundef zeroext true) #2
  %29 = load ptr, ptr %11, align 8, !tbaa !14
  %30 = getelementptr inbounds ptr, ptr %29, i64 %indvars.iv42
  store ptr %28, ptr %30, align 8, !tbaa !15
  %31 = load ptr, ptr %11, align 8, !tbaa !14
  %32 = getelementptr inbounds ptr, ptr %31, i64 %indvars.iv42
  %33 = load ptr, ptr %32, align 8, !tbaa !15
  %34 = load ptr, ptr %13, align 8, !tbaa !14
  %35 = getelementptr inbounds ptr, ptr %34, i64 %21
  store ptr %33, ptr %35, align 8, !tbaa !15
  %36 = load ptr, ptr %12, align 8, !tbaa !16
  %37 = getelementptr inbounds i8, ptr %36, i64 %indvars.iv42
  %38 = load i8, ptr %37, align 1, !tbaa !17
  %39 = load ptr, ptr %14, align 8, !tbaa !16
  %40 = getelementptr inbounds i8, ptr %39, i64 %21
  store i8 %38, ptr %40, align 1, !tbaa !17
  %41 = load i32, ptr %0, align 8, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %0, align 8, !tbaa !5
  %indvars.iv.next43 = add nsw i64 %indvars.iv42, 1
  %lftr.wideiv45 = trunc i64 %indvars.iv.next43 to i32
  %exitcond46.not = icmp eq i32 %lftr.wideiv45, %3
  br i1 %exitcond46.not, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !18

._crit_edge:                                      ; preds = %.lr.ph.split, %.lr.ph.split.us, %5
  ret void

.lr.ph.split:                                     ; preds = %.lr.ph, %.lr.ph.split
  %43 = phi i32 [ %65, %.lr.ph.split ], [ %.pre47, %.lr.ph ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph.split ], [ %15, %.lr.ph ]
  %44 = load ptr, ptr %9, align 8, !tbaa !11
  %45 = getelementptr inbounds i16, ptr %44, i64 %indvars.iv
  %46 = load i16, ptr %45, align 2, !tbaa !12
  %47 = load ptr, ptr %10, align 8, !tbaa !11
  %48 = sext i32 %43 to i64
  %49 = getelementptr inbounds i16, ptr %47, i64 %48
  store i16 %46, ptr %49, align 2, !tbaa !12
  %50 = load ptr, ptr %11, align 8, !tbaa !14
  %51 = getelementptr inbounds ptr, ptr %50, i64 %indvars.iv
  %52 = load ptr, ptr %51, align 8, !tbaa !15
  %53 = load ptr, ptr %12, align 8, !tbaa !16
  %54 = getelementptr inbounds i8, ptr %53, i64 %indvars.iv
  %55 = load i8, ptr %54, align 1, !tbaa !17
  %56 = tail call ptr @container_clone(ptr noundef %52, i8 noundef zeroext %55) #2
  %57 = load ptr, ptr %13, align 8, !tbaa !14
  %58 = getelementptr inbounds ptr, ptr %57, i64 %48
  store ptr %56, ptr %58, align 8, !tbaa !15
  %59 = load ptr, ptr %12, align 8, !tbaa !16
  %60 = getelementptr inbounds i8, ptr %59, i64 %indvars.iv
  %61 = load i8, ptr %60, align 1, !tbaa !17
  %62 = load ptr, ptr %14, align 8, !tbaa !16
  %63 = getelementptr inbounds i8, ptr %62, i64 %48
  store i8 %61, ptr %63, align 1, !tbaa !17
  %64 = load i32, ptr %0, align 8, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %0, align 8, !tbaa !5
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  %exitcond.not = icmp eq i32 %lftr.wideiv, %3
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph.split, !llvm.loop !18
}

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 = !{!"roaring_array_s", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !8, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 16}
!12 = !{!13, !13, i64 0}
!13 = !{!"short", !8, i64 0}
!14 = !{!6, !10, i64 8}
!15 = !{!10, !10, i64 0}
!16 = !{!6, !10, i64 24}
!17 = !{!8, !8, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass