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

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

; 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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
define dso_local ptr @run_container_deserialize(ptr noundef %0, i64 noundef %1) #4 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %12 = load i64, ptr %5, align 8, !tbaa !9
  %13 = icmp ult i64 %12, 8
  br i1 %13, label %14, label %15

14:                                               ; preds = %2
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %106

15:                                               ; preds = %2
  %16 = load i64, ptr %5, align 8, !tbaa !9
  %17 = sub i64 %16, 8
  store i64 %17, ptr %5, align 8, !tbaa !9
  br label %18

18:                                               ; preds = %15
  %19 = call noalias ptr @malloc(i64 noundef 16) #6
  store ptr %19, ptr %6, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %104

21:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.run_container_s, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  store i32 4, ptr %9, align 4, !tbaa !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %23, ptr align 1 %24, i64 4, i1 false)
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.run_container_s, ptr %25, i32 0, i32 1
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load i32, ptr %9, align 4, !tbaa !11
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds i8, ptr %27, i64 %29
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %26, ptr align 1 %30, i64 4, i1 false)
  %31 = load i32, ptr %9, align 4, !tbaa !11
  %32 = add nsw i32 %31, 4
  store i32 %32, ptr %9, align 4, !tbaa !11
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.run_container_s, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %34, align 8, !tbaa !13
  %36 = sext i32 %35 to i64
  %37 = mul i64 4, %36
  store i64 %37, ptr %8, align 8, !tbaa !9
  %38 = load i64, ptr %8, align 8, !tbaa !9
  %39 = load i64, ptr %5, align 8, !tbaa !9
  %40 = icmp ne i64 %38, %39
  br i1 %40, label %41, label %43

41:                                               ; preds = %21
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %42) #5
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %101

43:                                               ; preds = %21
  %44 = load i64, ptr %8, align 8, !tbaa !9
  %45 = call noalias ptr @malloc(i64 noundef %44) #6
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.run_container_s, ptr %46, i32 0, i32 2
  store ptr %45, ptr %47, align 8, !tbaa !15
  %48 = icmp eq ptr %45, null
  br i1 %48, label %49, label %51

49:                                               ; preds = %43
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %50) #5
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %101

51:                                               ; preds = %43
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.run_container_s, ptr %52, i32 0, i32 2
  %54 = load ptr, ptr %53, align 8, !tbaa !15
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = load i32, ptr %9, align 4, !tbaa !11
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds i8, ptr %55, i64 %57
  %59 = load i64, ptr %8, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %54, ptr align 1 %58, i64 %59, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %60

60:                                               ; preds = %95, %51
  %61 = load i32, ptr %10, align 4, !tbaa !11
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.run_container_s, ptr %62, i32 0, i32 0
  %64 = load i32, ptr %63, align 8, !tbaa !13
  %65 = icmp slt i32 %61, %64
  br i1 %65, label %67, label %66

66:                                               ; preds = %60
  store i32 2, ptr %7, align 4
  br label %98

67:                                               ; preds = %60
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.run_container_s, ptr %68, i32 0, i32 2
  %70 = load ptr, ptr %69, align 8, !tbaa !15
  %71 = load i32, ptr %10, align 4, !tbaa !11
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds %struct.rle16_s, ptr %70, i64 %72
  %74 = getelementptr inbounds %struct.rle16_s, ptr %73, i32 0, i32 0
  %75 = load i16, ptr %74, align 2, !tbaa !16
  %76 = zext i16 %75 to i32
  %77 = load i32, ptr %11, align 4, !tbaa !11
  %78 = icmp slt i32 %76, %77
  br i1 %78, label %79, label %84

79:                                               ; preds = %67
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.run_container_s, ptr %80, i32 0, i32 2
  %82 = load ptr, ptr %81, align 8, !tbaa !15
  call void @free(ptr noundef %82) #5
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %83) #5
  store ptr null, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %98

84:                                               ; preds = %67
  %85 = load ptr, ptr %6, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.run_container_s, ptr %85, i32 0, i32 2
  %87 = load ptr, ptr %86, align 8, !tbaa !15
  %88 = load i32, ptr %10, align 4, !tbaa !11
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds %struct.rle16_s, ptr %87, i64 %89
  %91 = getelementptr inbounds %struct.rle16_s, ptr %90, i32 0, i32 0
  %92 = load i16, ptr %91, align 2, !tbaa !16
  %93 = zext i16 %92 to i32
  store i32 %93, ptr %11, align 4, !tbaa !11
  br label %94

94:                                               ; preds = %84
  br label %95

95:                                               ; preds = %94
  %96 = load i32, ptr %10, align 4, !tbaa !11
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %10, align 4, !tbaa !11
  br label %60, !llvm.loop !19

98:                                               ; preds = %79, %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  %99 = load i32, ptr %7, align 4
  switch i32 %99, label %101 [
    i32 2, label %100
  ]

100:                                              ; preds = %98
  store i32 0, ptr %7, align 4
  br label %101

101:                                              ; preds = %100, %98, %49, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %102 = load i32, ptr %7, align 4
  switch i32 %102, label %106 [
    i32 0, label %103
  ]

103:                                              ; preds = %101
  br label %104

104:                                              ; preds = %103, %18
  %105 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %105, ptr %3, align 8
  store i32 1, ptr %7, align 4
  br label %106

106:                                              ; preds = %104, %101, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %107 = load ptr, ptr %3, align 8
  ret ptr %107
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(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 "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"run_container_s", !12, i64 0, !12, i64 4, !6, i64 8}
!15 = !{!14, !6, i64 8}
!16 = !{!17, !18, i64 0}
!17 = !{!"rle16_s", !18, i64 0, !18, i64 2}
!18 = !{!"short", !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"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"

%struct.rle16_s = type { i16, i16 }

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @run_container_deserialize(ptr nocapture noundef readonly %0, i64 noundef %1) local_unnamed_addr #3 {
  %3 = icmp ult i64 %1, 8
  br i1 %3, label %.critedge, label %4

4:                                                ; preds = %2
  %5 = tail call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #4
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %.critedge, label %6

6:                                                ; preds = %4
  %7 = add i64 %1, -8
  %8 = load <2 x i32>, ptr %0, align 1
  store <2 x i32> %8, ptr %5, align 8
  %9 = extractelement <2 x i32> %8, i64 0
  %10 = sext i32 %9 to i64
  %11 = shl nsw i64 %10, 2
  %.not42 = icmp eq i64 %11, %7
  br i1 %.not42, label %13, label %12

12:                                               ; preds = %6
  tail call void @free(ptr noundef nonnull %5) #5
  br label %.critedge

13:                                               ; preds = %6
  %14 = tail call noalias ptr @malloc(i64 noundef %7) #4
  %15 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %14, ptr %15, align 8, !tbaa !5
  %16 = icmp eq ptr %14, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %13
  tail call void @free(ptr noundef nonnull %5) #5
  br label %.critedge

18:                                               ; preds = %13
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 2 %14, ptr nonnull align 1 %19, i64 %7, i1 false)
  %.not43.not46 = icmp sgt i32 %9, 0
  br i1 %.not43.not46, label %.lr.ph.preheader, label %.critedge

.lr.ph.preheader:                                 ; preds = %18
  %wide.trip.count = zext nneg i32 %9 to i64
  br label %.lr.ph

20:                                               ; preds = %.lr.ph
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.critedge, label %.lr.ph, !llvm.loop !11

.lr.ph:                                           ; preds = %.lr.ph.preheader, %20
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %20 ]
  %.048 = phi i32 [ 0, %.lr.ph.preheader ], [ %23, %20 ]
  %21 = getelementptr inbounds %struct.rle16_s, ptr %14, i64 %indvars.iv
  %22 = load i16, ptr %21, align 2, !tbaa !13
  %23 = zext i16 %22 to i32
  %24 = icmp ugt i32 %.048, %23
  br i1 %24, label %25, label %20

25:                                               ; preds = %.lr.ph
  tail call void @free(ptr noundef nonnull %14) #5
  tail call void @free(ptr noundef %5) #5
  br label %.critedge

.critedge:                                        ; preds = %20, %18, %4, %25, %12, %17, %2
  %.2 = phi ptr [ null, %25 ], [ null, %2 ], [ null, %17 ], [ null, %12 ], [ null, %4 ], [ %5, %18 ], [ %5, %20 ]
  ret ptr %.2
}

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 allocsize(0) }
attributes #5 = { 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, !10, i64 8}
!6 = !{!"run_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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !15, i64 0}
!14 = !{!"rle16_s", !15, i64 0, !15, i64 2}
!15 = !{!"short", !8, i64 0}


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