; LLVM IR from asllop/AppOS :: core/mem (mem)

; 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.BlockStruct = type { ptr, i64 }

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

declare i32 @core_lock(i32 noundef) #1

declare ptr @get_blocks(ptr noundef) #1

declare i32 @core_unlock(i32 noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local i64 @core_avail(i32 noundef %0) #2 {
  %2 = alloca i64, align 8
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca i64, align 8
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca i8, align 1
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i8, align 1
  %17 = alloca ptr, align 8
  %18 = alloca i8, align 1
  %19 = alloca i64, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i64, align 8
  %22 = alloca i16, align 2
  store i32 %0, ptr %3, align 4, !tbaa !5
  %23 = load i32, ptr %3, align 4, !tbaa !5
  switch i32 %23, label %175 [
    i32 0, label %24
    i32 1, label %49
    i32 2, label %110
  ]

24:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store i64 0, ptr %4, align 8, !tbaa !9
  %25 = call i32 @core_lock(i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %26 = call ptr @get_blocks(ptr noundef %5)
  store ptr %26, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  store i8 0, ptr %7, align 1, !tbaa !13
  br label %27

27:                                               ; preds = %43, %24
  %28 = load i8, ptr %7, align 1, !tbaa !13
  %29 = zext i8 %28 to i32
  %30 = load i8, ptr %5, align 1, !tbaa !13
  %31 = zext i8 %30 to i32
  %32 = icmp slt i32 %29, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  br label %46

34:                                               ; preds = %27
  %35 = load ptr, ptr %6, align 8, !tbaa !11
  %36 = load i8, ptr %7, align 1, !tbaa !13
  %37 = zext i8 %36 to i64
  %38 = getelementptr inbounds %struct.BlockStruct, ptr %35, i64 %37
  %39 = getelementptr inbounds %struct.BlockStruct, ptr %38, i32 0, i32 1
  %40 = load i64, ptr %39, align 8, !tbaa !14
  %41 = load i64, ptr %4, align 8, !tbaa !9
  %42 = add i64 %41, %40
  store i64 %42, ptr %4, align 8, !tbaa !9
  br label %43

43:                                               ; preds = %34
  %44 = load i8, ptr %7, align 1, !tbaa !13
  %45 = add i8 %44, 1
  store i8 %45, ptr %7, align 1, !tbaa !13
  br label %27, !llvm.loop !16

46:                                               ; preds = %33
  %47 = call i32 @core_unlock(i32 noundef 0)
  %48 = load i64, ptr %4, align 8, !tbaa !9
  store i64 %48, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %176

49:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 0, ptr %8, align 8, !tbaa !9
  %50 = call i32 @core_lock(i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %51 = call ptr @get_blocks(ptr noundef %9)
  store ptr %51, ptr %10, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #3
  store i8 0, ptr %11, align 1, !tbaa !13
  br label %52

52:                                               ; preds = %104, %49
  %53 = load i8, ptr %11, align 1, !tbaa !13
  %54 = zext i8 %53 to i32
  %55 = load i8, ptr %9, align 1, !tbaa !13
  %56 = zext i8 %55 to i32
  %57 = icmp slt i32 %54, %56
  br i1 %57, label %59, label %58

58:                                               ; preds = %52
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #3
  br label %107

59:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %60 = load ptr, ptr %10, align 8, !tbaa !11
  %61 = load i8, ptr %11, align 1, !tbaa !13
  %62 = zext i8 %61 to i64
  %63 = getelementptr inbounds %struct.BlockStruct, ptr %60, i64 %62
  %64 = getelementptr inbounds %struct.BlockStruct, ptr %63, i32 0, i32 1
  %65 = load i64, ptr %64, align 8, !tbaa !14
  %66 = udiv i64 %65, 256
  store i64 %66, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %67 = load ptr, ptr %10, align 8, !tbaa !11
  %68 = load i8, ptr %11, align 1, !tbaa !13
  %69 = zext i8 %68 to i64
  %70 = getelementptr inbounds %struct.BlockStruct, ptr %67, i64 %69
  %71 = getelementptr inbounds %struct.BlockStruct, ptr %70, i32 0, i32 0
  %72 = load ptr, ptr %71, align 8, !tbaa !18
  store ptr %72, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  store i64 0, ptr %14, align 8, !tbaa !9
  br label %73

73:                                               ; preds = %93, %59
  %74 = load i64, ptr %14, align 8, !tbaa !9
  %75 = load i64, ptr %12, align 8, !tbaa !9
  %76 = icmp ult i64 %74, %75
  br i1 %76, label %77, label %103

77:                                               ; preds = %73
  %78 = load ptr, ptr %13, align 8, !tbaa !11
  %79 = load i16, ptr %78, align 2, !tbaa !19
  %80 = zext i16 %79 to i32
  %81 = icmp eq i32 %80, 0
  br i1 %81, label %82, label %87

82:                                               ; preds = %77
  %83 = load i64, ptr %14, align 8, !tbaa !9
  %84 = add i64 %83, 1
  store i64 %84, ptr %14, align 8, !tbaa !9
  %85 = load i64, ptr %8, align 8, !tbaa !9
  %86 = add i64 %85, 256
  store i64 %86, ptr %8, align 8, !tbaa !9
  br label %93

87:                                               ; preds = %77
  %88 = load ptr, ptr %13, align 8, !tbaa !11
  %89 = load i16, ptr %88, align 2, !tbaa !19
  %90 = zext i16 %89 to i64
  %91 = load i64, ptr %14, align 8, !tbaa !9
  %92 = add i64 %91, %90
  store i64 %92, ptr %14, align 8, !tbaa !9
  br label %93

93:                                               ; preds = %87, %82
  %94 = load ptr, ptr %10, align 8, !tbaa !11
  %95 = load i8, ptr %11, align 1, !tbaa !13
  %96 = zext i8 %95 to i64
  %97 = getelementptr inbounds %struct.BlockStruct, ptr %94, i64 %96
  %98 = getelementptr inbounds %struct.BlockStruct, ptr %97, i32 0, i32 0
  %99 = load ptr, ptr %98, align 8, !tbaa !18
  %100 = load i64, ptr %14, align 8, !tbaa !9
  %101 = mul i64 256, %100
  %102 = getelementptr inbounds i8, ptr %99, i64 %101
  store ptr %102, ptr %13, align 8, !tbaa !11
  br label %73, !llvm.loop !21

103:                                              ; preds = %73
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %104

104:                                              ; preds = %103
  %105 = load i8, ptr %11, align 1, !tbaa !13
  %106 = add i8 %105, 1
  store i8 %106, ptr %11, align 1, !tbaa !13
  br label %52, !llvm.loop !22

107:                                              ; preds = %58
  %108 = call i32 @core_unlock(i32 noundef 0)
  %109 = load i64, ptr %8, align 8, !tbaa !9
  store i64 %109, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  br label %176

110:                                              ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  store i64 0, ptr %15, align 8, !tbaa !9
  %111 = call i32 @core_lock(i32 noundef 0)
  call void @llvm.lifetime.start.p0(i64 1, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %112 = call ptr @get_blocks(ptr noundef %16)
  store ptr %112, ptr %17, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %18) #3
  store i8 0, ptr %18, align 1, !tbaa !13
  br label %113

113:                                              ; preds = %169, %110
  %114 = load i8, ptr %18, align 1, !tbaa !13
  %115 = zext i8 %114 to i32
  %116 = load i8, ptr %16, align 1, !tbaa !13
  %117 = zext i8 %116 to i32
  %118 = icmp slt i32 %115, %117
  br i1 %118, label %120, label %119

119:                                              ; preds = %113
  call void @llvm.lifetime.end.p0(i64 1, ptr %18) #3
  br label %172

120:                                              ; preds = %113
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  %121 = load ptr, ptr %17, align 8, !tbaa !11
  %122 = load i8, ptr %18, align 1, !tbaa !13
  %123 = zext i8 %122 to i64
  %124 = getelementptr inbounds %struct.BlockStruct, ptr %121, i64 %123
  %125 = getelementptr inbounds %struct.BlockStruct, ptr %124, i32 0, i32 1
  %126 = load i64, ptr %125, align 8, !tbaa !14
  %127 = udiv i64 %126, 256
  store i64 %127, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #3
  %128 = load ptr, ptr %17, align 8, !tbaa !11
  %129 = load i8, ptr %18, align 1, !tbaa !13
  %130 = zext i8 %129 to i64
  %131 = getelementptr inbounds %struct.BlockStruct, ptr %128, i64 %130
  %132 = getelementptr inbounds %struct.BlockStruct, ptr %131, i32 0, i32 0
  %133 = load ptr, ptr %132, align 8, !tbaa !18
  store ptr %133, ptr %20, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #3
  store i64 0, ptr %21, align 8, !tbaa !9
  br label %134

134:                                              ; preds = %158, %120
  %135 = load i64, ptr %21, align 8, !tbaa !9
  %136 = load i64, ptr %19, align 8, !tbaa !9
  %137 = icmp ult i64 %135, %136
  br i1 %137, label %138, label %168

138:                                              ; preds = %134
  call void @llvm.lifetime.start.p0(i64 2, ptr %22) #3
  %139 = load ptr, ptr %20, align 8, !tbaa !11
  %140 = load i16, ptr %139, align 2, !tbaa !19
  store i16 %140, ptr %22, align 2, !tbaa !19
  %141 = load i16, ptr %22, align 2, !tbaa !19
  %142 = zext i16 %141 to i32
  %143 = icmp eq i32 %142, 0
  br i1 %143, label %144, label %147

144:                                              ; preds = %138
  %145 = load i64, ptr %21, align 8, !tbaa !9
  %146 = add i64 %145, 1
  store i64 %146, ptr %21, align 8, !tbaa !9
  br label %158

147:                                              ; preds = %138
  %148 = load i16, ptr %22, align 2, !tbaa !19
  %149 = zext i16 %148 to i64
  %150 = load i64, ptr %21, align 8, !tbaa !9
  %151 = add i64 %150, %149
  store i64 %151, ptr %21, align 8, !tbaa !9
  %152 = load i16, ptr %22, align 2, !tbaa !19
  %153 = zext i16 %152 to i32
  %154 = mul nsw i32 256, %153
  %155 = sext i32 %154 to i64
  %156 = load i64, ptr %15, align 8, !tbaa !9
  %157 = add i64 %156, %155
  store i64 %157, ptr %15, align 8, !tbaa !9
  br label %158

158:                                              ; preds = %147, %144
  %159 = load ptr, ptr %17, align 8, !tbaa !11
  %160 = load i8, ptr %18, align 1, !tbaa !13
  %161 = zext i8 %160 to i64
  %162 = getelementptr inbounds %struct.BlockStruct, ptr %159, i64 %161
  %163 = getelementptr inbounds %struct.BlockStruct, ptr %162, i32 0, i32 0
  %164 = load ptr, ptr %163, align 8, !tbaa !18
  %165 = load i64, ptr %21, align 8, !tbaa !9
  %166 = mul i64 256, %165
  %167 = getelementptr inbounds i8, ptr %164, i64 %166
  store ptr %167, ptr %20, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 2, ptr %22) #3
  br label %134, !llvm.loop !23

168:                                              ; preds = %134
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  br label %169

169:                                              ; preds = %168
  %170 = load i8, ptr %18, align 1, !tbaa !13
  %171 = add i8 %170, 1
  store i8 %171, ptr %18, align 1, !tbaa !13
  br label %113, !llvm.loop !24

172:                                              ; preds = %119
  %173 = call i32 @core_unlock(i32 noundef 0)
  %174 = load i64, ptr %15, align 8, !tbaa !9
  store i64 %174, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  br label %176

175:                                              ; preds = %1
  store i64 0, ptr %2, align 8
  br label %176

176:                                              ; preds = %175, %172, %107, %46
  %177 = load i64, ptr %2, align 8
  ret i64 %177
}

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 = !{!"int", !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 = !{!"any pointer", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !10, i64 8}
!15 = !{!"BlockStruct", !12, i64 0, !10, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!15, !12, i64 0}
!19 = !{!20, !20, i64 0}
!20 = !{!"short", !7, i64 0}
!21 = distinct !{!21, !17}
!22 = distinct !{!22, !17}
!23 = distinct !{!23, !17}
!24 = distinct !{!24, !17}


; 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.BlockStruct = type { ptr, i64 }

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

declare i32 @core_lock(i32 noundef) local_unnamed_addr #1

declare ptr @get_blocks(ptr noundef) local_unnamed_addr #1

declare i32 @core_unlock(i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local i64 @core_avail(i32 noundef %0) local_unnamed_addr #2 {
  %2 = alloca i8, align 1
  %3 = alloca i8, align 1
  %4 = alloca i8, align 1
  switch i32 %0, label %56 [
    i32 0, label %5
    i32 1, label %22
    i32 2, label %38
  ]

5:                                                ; preds = %1
  %6 = tail call i32 @core_lock(i32 noundef 0) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %2) #4
  %7 = call ptr @get_blocks(ptr noundef nonnull %2) #4
  %8 = load i8, ptr %2, align 1, !tbaa !5
  %.not89 = icmp eq i8 %8, 0
  br i1 %.not89, label %._crit_edge84, label %.lr.ph83.preheader

.lr.ph83.preheader:                               ; preds = %5
  %wide.trip.count100 = zext i8 %8 to i64
  %min.iters.check = icmp ult i8 %8, 5
  br i1 %min.iters.check, label %.lr.ph83.preheader107, label %vector.ph

.lr.ph83.preheader107:                            ; preds = %middle.block, %.lr.ph83.preheader
  %indvars.iv97.ph = phi i64 [ 0, %.lr.ph83.preheader ], [ %n.vec, %middle.block ]
  %.04581.ph = phi i64 [ 0, %.lr.ph83.preheader ], [ %17, %middle.block ]
  br label %.lr.ph83

vector.ph:                                        ; preds = %.lr.ph83.preheader
  %n.mod.vf = and i64 %wide.trip.count100, 3
  %9 = icmp eq i64 %n.mod.vf, 0
  %10 = select i1 %9, i64 4, i64 %n.mod.vf
  %n.vec = sub nsw i64 %wide.trip.count100, %10
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %14, %vector.body ]
  %vec.phi104 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %15, %vector.body ]
  %11 = or disjoint i64 %index, 2
  %12 = getelementptr inbounds %struct.BlockStruct, ptr %7, i64 %index, i32 1
  %13 = getelementptr inbounds %struct.BlockStruct, ptr %7, i64 %11, i32 1
  %wide.vec = load <4 x i64>, ptr %12, align 8, !tbaa !8
  %wide.vec105 = load <4 x i64>, ptr %13, align 8, !tbaa !8
  %strided.vec = shufflevector <4 x i64> %wide.vec, <4 x i64> poison, <2 x i32> <i32 0, i32 2>
  %strided.vec106 = shufflevector <4 x i64> %wide.vec105, <4 x i64> poison, <2 x i32> <i32 0, i32 2>
  %14 = add <2 x i64> %strided.vec, %vec.phi
  %15 = add <2 x i64> %strided.vec106, %vec.phi104
  %index.next = add nuw i64 %index, 4
  %16 = icmp eq i64 %index.next, %n.vec
  br i1 %16, label %middle.block, label %vector.body, !llvm.loop !12

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %15, %14
  %17 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  br label %.lr.ph83.preheader107

._crit_edge84:                                    ; preds = %.lr.ph83, %5
  %.045.lcssa = phi i64 [ 0, %5 ], [ %21, %.lr.ph83 ]
  %18 = call i32 @core_unlock(i32 noundef 0) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %2) #4
  br label %56

.lr.ph83:                                         ; preds = %.lr.ph83.preheader107, %.lr.ph83
  %indvars.iv97 = phi i64 [ %indvars.iv.next98, %.lr.ph83 ], [ %indvars.iv97.ph, %.lr.ph83.preheader107 ]
  %.04581 = phi i64 [ %21, %.lr.ph83 ], [ %.04581.ph, %.lr.ph83.preheader107 ]
  %19 = getelementptr inbounds %struct.BlockStruct, ptr %7, i64 %indvars.iv97, i32 1
  %20 = load i64, ptr %19, align 8, !tbaa !8
  %21 = add i64 %20, %.04581
  %indvars.iv.next98 = add nuw nsw i64 %indvars.iv97, 1
  %exitcond101.not = icmp eq i64 %indvars.iv.next98, %wide.trip.count100
  br i1 %exitcond101.not, label %._crit_edge84, label %.lr.ph83, !llvm.loop !16

22:                                               ; preds = %1
  %23 = tail call i32 @core_lock(i32 noundef 0) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #4
  %24 = call ptr @get_blocks(ptr noundef nonnull %3) #4
  %25 = load i8, ptr %3, align 1, !tbaa !5
  %.not87 = icmp eq i8 %25, 0
  br i1 %.not87, label %._crit_edge78, label %.lr.ph77.preheader

.lr.ph77.preheader:                               ; preds = %22
  %wide.trip.count95 = zext i8 %25 to i64
  br label %.lr.ph77

._crit_edge78:                                    ; preds = %._crit_edge72, %22
  %.053.lcssa = phi i64 [ 0, %22 ], [ %.154.lcssa, %._crit_edge72 ]
  %26 = call i32 @core_unlock(i32 noundef 0) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #4
  br label %56

.lr.ph77:                                         ; preds = %.lr.ph77.preheader, %._crit_edge72
  %indvars.iv92 = phi i64 [ 0, %.lr.ph77.preheader ], [ %indvars.iv.next93, %._crit_edge72 ]
  %.05375 = phi i64 [ 0, %.lr.ph77.preheader ], [ %.154.lcssa, %._crit_edge72 ]
  %27 = getelementptr inbounds %struct.BlockStruct, ptr %24, i64 %indvars.iv92
  %28 = getelementptr inbounds i8, ptr %27, i64 8
  %29 = load i64, ptr %28, align 8, !tbaa !8
  %30 = lshr i64 %29, 8
  %31 = load ptr, ptr %27, align 8, !tbaa !17
  %.not88 = icmp ult i64 %29, 256
  br i1 %.not88, label %._crit_edge72, label %.lr.ph71

.lr.ph71:                                         ; preds = %.lr.ph77, %.lr.ph71
  %.05069 = phi i64 [ %.151, %.lr.ph71 ], [ 0, %.lr.ph77 ]
  %.05268 = phi ptr [ %36, %.lr.ph71 ], [ %31, %.lr.ph77 ]
  %.15467 = phi i64 [ %.255, %.lr.ph71 ], [ %.05375, %.lr.ph77 ]
  %32 = load i16, ptr %.05268, align 2, !tbaa !18
  %33 = icmp eq i16 %32, 0
  %34 = add i64 %.15467, 256
  %.255 = select i1 %33, i64 %34, i64 %.15467
  %narrow = call i16 @llvm.umax.i16(i16 %32, i16 1)
  %.151.v = zext i16 %narrow to i64
  %.151 = add nuw nsw i64 %.05069, %.151.v
  %35 = shl i64 %.151, 8
  %36 = getelementptr inbounds i8, ptr %31, i64 %35
  %37 = icmp ult i64 %.151, %30
  br i1 %37, label %.lr.ph71, label %._crit_edge72, !llvm.loop !20

._crit_edge72:                                    ; preds = %.lr.ph71, %.lr.ph77
  %.154.lcssa = phi i64 [ %.05375, %.lr.ph77 ], [ %.255, %.lr.ph71 ]
  %indvars.iv.next93 = add nuw nsw i64 %indvars.iv92, 1
  %exitcond96.not = icmp eq i64 %indvars.iv.next93, %wide.trip.count95
  br i1 %exitcond96.not, label %._crit_edge78, label %.lr.ph77, !llvm.loop !21

38:                                               ; preds = %1
  %39 = tail call i32 @core_lock(i32 noundef 0) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #4
  %40 = call ptr @get_blocks(ptr noundef nonnull %4) #4
  %41 = load i8, ptr %4, align 1, !tbaa !5
  %.not = icmp eq i8 %41, 0
  br i1 %.not, label %._crit_edge65, label %.lr.ph64.preheader

.lr.ph64.preheader:                               ; preds = %38
  %wide.trip.count = zext i8 %41 to i64
  br label %.lr.ph64

._crit_edge65:                                    ; preds = %._crit_edge, %38
  %.048.lcssa = phi i64 [ 0, %38 ], [ %.149.lcssa, %._crit_edge ]
  %42 = call i32 @core_unlock(i32 noundef 0) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #4
  br label %56

.lr.ph64:                                         ; preds = %.lr.ph64.preheader, %._crit_edge
  %indvars.iv = phi i64 [ 0, %.lr.ph64.preheader ], [ %indvars.iv.next, %._crit_edge ]
  %.04861 = phi i64 [ 0, %.lr.ph64.preheader ], [ %.149.lcssa, %._crit_edge ]
  %43 = getelementptr inbounds %struct.BlockStruct, ptr %40, i64 %indvars.iv
  %44 = getelementptr inbounds i8, ptr %43, i64 8
  %45 = load i64, ptr %44, align 8, !tbaa !8
  %46 = lshr i64 %45, 8
  %47 = load ptr, ptr %43, align 8, !tbaa !17
  %.not86 = icmp ult i64 %45, 256
  br i1 %.not86, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph64, %.lr.ph
  %.04360 = phi i64 [ %.1, %.lr.ph ], [ 0, %.lr.ph64 ]
  %.04459 = phi ptr [ %54, %.lr.ph ], [ %47, %.lr.ph64 ]
  %.14958 = phi i64 [ %52, %.lr.ph ], [ %.04861, %.lr.ph64 ]
  %48 = load i16, ptr %.04459, align 2, !tbaa !18
  %49 = icmp eq i16 %48, 0
  %50 = zext i16 %48 to i64
  %51 = shl nuw nsw i64 %50, 8
  %52 = add i64 %51, %.14958
  %.1.v = select i1 %49, i64 1, i64 %50
  %.1 = add nuw nsw i64 %.1.v, %.04360
  %53 = shl i64 %.1, 8
  %54 = getelementptr inbounds i8, ptr %47, i64 %53
  %55 = icmp ult i64 %.1, %46
  br i1 %55, label %.lr.ph, label %._crit_edge, !llvm.loop !22

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph64
  %.149.lcssa = phi i64 [ %.04861, %.lr.ph64 ], [ %52, %.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 %._crit_edge65, label %.lr.ph64, !llvm.loop !23

56:                                               ; preds = %1, %._crit_edge65, %._crit_edge78, %._crit_edge84
  %.0 = phi i64 [ %.048.lcssa, %._crit_edge65 ], [ %.053.lcssa, %._crit_edge78 ], [ %.045.lcssa, %._crit_edge84 ], [ 0, %1 ]
  ret i64 %.0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i16 @llvm.umax.i16(i16, i16) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #3

attributes #0 = { mustprogress 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !11, i64 8}
!9 = !{!"BlockStruct", !10, i64 0, !11, i64 8}
!10 = !{!"any pointer", !6, i64 0}
!11 = !{!"long", !6, i64 0}
!12 = distinct !{!12, !13, !14, !15}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!"llvm.loop.isvectorized", i32 1}
!15 = !{!"llvm.loop.unroll.runtime.disable"}
!16 = distinct !{!16, !13, !15, !14}
!17 = !{!9, !10, i64 0}
!18 = !{!19, !19, i64 0}
!19 = !{!"short", !6, i64 0}
!20 = distinct !{!20, !13}
!21 = distinct !{!21, !13}
!22 = distinct !{!22, !13}
!23 = distinct !{!23, !13}


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