; 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 }

@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 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 i32 @printf(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local void @run_container_printf_as_uint32_array(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i16, align 2
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i16, align 2
  %12 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.run_container_s, ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !11
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %18

17:                                               ; preds = %2
  br label %96

18:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.run_container_s, ptr %20, i32 0, i32 2
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = getelementptr inbounds %struct.rle16_s, ptr %22, i64 0
  %24 = getelementptr inbounds %struct.rle16_s, ptr %23, i32 0, i32 0
  %25 = load i16, ptr %24, align 2, !tbaa !14
  %26 = zext i16 %25 to i32
  %27 = add i32 %19, %26
  store i32 %27, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #3
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.run_container_s, ptr %28, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !13
  %31 = getelementptr inbounds %struct.rle16_s, ptr %30, i64 0
  %32 = getelementptr inbounds %struct.rle16_s, ptr %31, i32 0, i32 1
  %33 = load i16, ptr %32, align 2, !tbaa !17
  store i16 %33, ptr %6, align 2, !tbaa !18
  %34 = load i32, ptr %5, align 4, !tbaa !9
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %34)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 1, ptr %7, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %47, %18
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = load i16, ptr %6, align 2, !tbaa !18
  %39 = zext i16 %38 to i32
  %40 = icmp ule i32 %37, %39
  br i1 %40, label %42, label %41

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

42:                                               ; preds = %36
  %43 = load i32, ptr %5, align 4, !tbaa !9
  %44 = load i32, ptr %7, align 4, !tbaa !9
  %45 = add i32 %43, %44
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i32 noundef %45)
  br label %47

47:                                               ; preds = %42
  %48 = load i32, ptr %7, align 4, !tbaa !9
  %49 = add i32 %48, 1
  store i32 %49, ptr %7, align 4, !tbaa !9
  br label %36, !llvm.loop !19

50:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 1, ptr %8, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %93, %50
  %52 = load i32, ptr %8, align 4, !tbaa !9
  %53 = load ptr, ptr %3, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.run_container_s, ptr %53, i32 0, i32 0
  %55 = load i32, ptr %54, align 8, !tbaa !11
  %56 = icmp slt i32 %52, %55
  br i1 %56, label %58, label %57

57:                                               ; preds = %51
  store i32 5, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %96

58:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %59 = load i32, ptr %4, align 4, !tbaa !9
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.run_container_s, ptr %60, i32 0, i32 2
  %62 = load ptr, ptr %61, align 8, !tbaa !13
  %63 = load i32, ptr %8, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds %struct.rle16_s, ptr %62, i64 %64
  %66 = getelementptr inbounds %struct.rle16_s, ptr %65, i32 0, i32 0
  %67 = load i16, ptr %66, align 2, !tbaa !14
  %68 = zext i16 %67 to i32
  %69 = add i32 %59, %68
  store i32 %69, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 2, ptr %11) #3
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.run_container_s, ptr %70, i32 0, i32 2
  %72 = load ptr, ptr %71, align 8, !tbaa !13
  %73 = load i32, ptr %8, align 4, !tbaa !9
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds %struct.rle16_s, ptr %72, i64 %74
  %76 = getelementptr inbounds %struct.rle16_s, ptr %75, i32 0, i32 1
  %77 = load i16, ptr %76, align 2, !tbaa !17
  store i16 %77, ptr %11, align 2, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %78

78:                                               ; preds = %89, %58
  %79 = load i32, ptr %12, align 4, !tbaa !9
  %80 = load i16, ptr %11, align 2, !tbaa !18
  %81 = zext i16 %80 to i32
  %82 = icmp ule i32 %79, %81
  br i1 %82, label %84, label %83

83:                                               ; preds = %78
  store i32 8, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %92

84:                                               ; preds = %78
  %85 = load i32, ptr %10, align 4, !tbaa !9
  %86 = load i32, ptr %12, align 4, !tbaa !9
  %87 = add i32 %85, %86
  %88 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i32 noundef %87)
  br label %89

89:                                               ; preds = %84
  %90 = load i32, ptr %12, align 4, !tbaa !9
  %91 = add i32 %90, 1
  store i32 %91, ptr %12, align 4, !tbaa !9
  br label %78, !llvm.loop !21

92:                                               ; preds = %83
  call void @llvm.lifetime.end.p0(i64 2, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %93

93:                                               ; preds = %92
  %94 = load i32, ptr %8, align 4, !tbaa !9
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %8, align 4, !tbaa !9
  br label %51, !llvm.loop !22

96:                                               ; preds = %57, %17
  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, !10, i64 0}
!12 = !{!"run_container_s", !10, i64 0, !10, i64 4, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = !{!15, !16, i64 0}
!15 = !{!"rle16_s", !16, i64 0, !16, i64 2}
!16 = !{!"short", !7, i64 0}
!17 = !{!15, !16, i64 2}
!18 = !{!16, !16, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = distinct !{!22, !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"

%struct.rle16_s = type { i16, i16 }

@.str.5 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nofree nounwind uwtable
define dso_local void @run_container_printf_as_uint32_array(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = load i32, ptr %0, align 8, !tbaa !5
  %4 = icmp eq i32 %3, 0
  br i1 %4, label %.loopexit, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !11
  %8 = load i16, ptr %7, align 2, !tbaa !12
  %9 = zext i16 %8 to i32
  %10 = add i32 %9, %1
  %11 = getelementptr inbounds i8, ptr %7, i64 2
  %12 = load i16, ptr %11, align 2, !tbaa !15
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %10)
  %.not25 = icmp eq i16 %12, 0
  br i1 %.not25, label %.preheader, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %5
  %14 = zext i16 %12 to i32
  br label %.lr.ph

.preheader:                                       ; preds = %.lr.ph, %5
  %15 = load i32, ptr %0, align 8, !tbaa !5
  %16 = icmp sgt i32 %15, 1
  br i1 %16, label %.lr.ph29, label %.loopexit

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %.02226 = phi i32 [ %19, %.lr.ph ], [ 1, %.lr.ph.preheader ]
  %17 = add i32 %.02226, %10
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i32 noundef %17)
  %19 = add nuw nsw i32 %.02226, 1
  %exitcond.not = icmp eq i32 %.02226, %14
  br i1 %exitcond.not, label %.preheader, label %.lr.ph, !llvm.loop !16

.lr.ph29:                                         ; preds = %.preheader, %28
  %indvars.iv = phi i64 [ %indvars.iv.next, %28 ], [ 1, %.preheader ]
  %20 = load ptr, ptr %6, align 8, !tbaa !11
  %21 = getelementptr inbounds %struct.rle16_s, ptr %20, i64 %indvars.iv
  %22 = load i16, ptr %21, align 2, !tbaa !12
  %23 = zext i16 %22 to i32
  %24 = add i32 %23, %1
  %25 = getelementptr inbounds i8, ptr %21, i64 2
  %26 = load i16, ptr %25, align 2, !tbaa !15
  %27 = zext i16 %26 to i32
  br label %32

28:                                               ; preds = %32
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %29 = load i32, ptr %0, align 8, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = icmp slt i64 %indvars.iv.next, %30
  br i1 %31, label %.lr.ph29, label %.loopexit, !llvm.loop !18

32:                                               ; preds = %.lr.ph29, %32
  %.027 = phi i32 [ 0, %.lr.ph29 ], [ %35, %32 ]
  %33 = add i32 %24, %.027
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i32 noundef %33)
  %35 = add nuw nsw i32 %.027, 1
  %exitcond30.not = icmp eq i32 %.027, %27
  br i1 %exitcond30.not, label %28, label %32, !llvm.loop !19

.loopexit:                                        ; preds = %28, %.preheader, %2
  ret void
}

attributes #0 = { nofree 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 #1 = { nofree 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" }

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


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