; LLVM IR from google/zopfli :: src/zopfli (katajainen)

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

; Function Attrs: nounwind uwtable
define dso_local i32 @ZopfliLengthLimitedCodeLengths(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca %struct.NodePool, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = mul i64 %19, 24
  %21 = call noalias ptr @malloc(i64 noundef %20) #6
  store ptr %21, ptr %16, align 8, !tbaa !5
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %31, %4
  %23 = load i32, ptr %11, align 4, !tbaa !9
  %24 = load i32, ptr %7, align 4, !tbaa !9
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %26, label %34

26:                                               ; preds = %22
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = load i32, ptr %11, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds i32, ptr %27, i64 %29
  store i32 0, ptr %30, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %26
  %32 = load i32, ptr %11, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %11, align 4, !tbaa !9
  br label %22, !llvm.loop !11

34:                                               ; preds = %22
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %66, %34
  %36 = load i32, ptr %11, align 4, !tbaa !9
  %37 = load i32, ptr %7, align 4, !tbaa !9
  %38 = icmp slt i32 %36, %37
  br i1 %38, label %39, label %69

39:                                               ; preds = %35
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load i32, ptr %11, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds i64, ptr %40, i64 %42
  %44 = load i64, ptr %43, align 8, !tbaa !13
  %45 = icmp ne i64 %44, 0
  br i1 %45, label %46, label %65

46:                                               ; preds = %39
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = load i32, ptr %11, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds i64, ptr %47, i64 %49
  %51 = load i64, ptr %50, align 8, !tbaa !13
  %52 = load ptr, ptr %16, align 8, !tbaa !5
  %53 = load i32, ptr %12, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds %struct.Node, ptr %52, i64 %54
  %56 = getelementptr inbounds %struct.Node, ptr %55, i32 0, i32 0
  store i64 %51, ptr %56, align 8, !tbaa !15
  %57 = load i32, ptr %11, align 4, !tbaa !9
  %58 = load ptr, ptr %16, align 8, !tbaa !5
  %59 = load i32, ptr %12, align 4, !tbaa !9
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds %struct.Node, ptr %58, i64 %60
  %62 = getelementptr inbounds %struct.Node, ptr %61, i32 0, i32 2
  store i32 %57, ptr %62, align 8, !tbaa !17
  %63 = load i32, ptr %12, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %12, align 4, !tbaa !9
  br label %65

65:                                               ; preds = %46, %39
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %11, align 4, !tbaa !9
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %11, align 4, !tbaa !9
  br label %35, !llvm.loop !18

69:                                               ; preds = %35
  %70 = load i32, ptr %8, align 4, !tbaa !9
  %71 = shl i32 1, %70
  %72 = load i32, ptr %12, align 4, !tbaa !9
  %73 = icmp slt i32 %71, %72
  br i1 %73, label %74, label %76

74:                                               ; preds = %69
  %75 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %75) #5
  store i32 1, ptr %5, align 4
  store i32 1, ptr %17, align 4
  br label %234

76:                                               ; preds = %69
  %77 = load i32, ptr %12, align 4, !tbaa !9
  %78 = icmp eq i32 %77, 0
  br i1 %78, label %79, label %81

79:                                               ; preds = %76
  %80 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %80) #5
  store i32 0, ptr %5, align 4
  store i32 1, ptr %17, align 4
  br label %234

81:                                               ; preds = %76
  %82 = load i32, ptr %12, align 4, !tbaa !9
  %83 = icmp eq i32 %82, 1
  br i1 %83, label %84, label %93

84:                                               ; preds = %81
  %85 = load ptr, ptr %9, align 8, !tbaa !5
  %86 = load ptr, ptr %16, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.Node, ptr %86, i64 0
  %88 = getelementptr inbounds %struct.Node, ptr %87, i32 0, i32 2
  %89 = load i32, ptr %88, align 8, !tbaa !17
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds i32, ptr %85, i64 %90
  store i32 1, ptr %91, align 4, !tbaa !9
  %92 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %92) #5
  store i32 0, ptr %5, align 4
  store i32 1, ptr %17, align 4
  br label %234

93:                                               ; preds = %81
  %94 = load i32, ptr %12, align 4, !tbaa !9
  %95 = icmp eq i32 %94, 2
  br i1 %95, label %96, label %116

96:                                               ; preds = %93
  %97 = load ptr, ptr %9, align 8, !tbaa !5
  %98 = load ptr, ptr %16, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.Node, ptr %98, i64 0
  %100 = getelementptr inbounds %struct.Node, ptr %99, i32 0, i32 2
  %101 = load i32, ptr %100, align 8, !tbaa !17
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds i32, ptr %97, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !9
  %105 = add i32 %104, 1
  store i32 %105, ptr %103, align 4, !tbaa !9
  %106 = load ptr, ptr %9, align 8, !tbaa !5
  %107 = load ptr, ptr %16, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.Node, ptr %107, i64 1
  %109 = getelementptr inbounds %struct.Node, ptr %108, i32 0, i32 2
  %110 = load i32, ptr %109, align 8, !tbaa !17
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds i32, ptr %106, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !9
  %114 = add i32 %113, 1
  store i32 %114, ptr %112, align 4, !tbaa !9
  %115 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %115) #5
  store i32 0, ptr %5, align 4
  store i32 1, ptr %17, align 4
  br label %234

116:                                              ; preds = %93
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %117

117:                                              ; preds = %152, %116
  %118 = load i32, ptr %11, align 4, !tbaa !9
  %119 = load i32, ptr %12, align 4, !tbaa !9
  %120 = icmp slt i32 %118, %119
  br i1 %120, label %121, label %155

121:                                              ; preds = %117
  %122 = load ptr, ptr %16, align 8, !tbaa !5
  %123 = load i32, ptr %11, align 4, !tbaa !9
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds %struct.Node, ptr %122, i64 %124
  %126 = getelementptr inbounds %struct.Node, ptr %125, i32 0, i32 0
  %127 = load i64, ptr %126, align 8, !tbaa !15
  %128 = icmp uge i64 %127, 36028797018963968
  br i1 %128, label %129, label %131

129:                                              ; preds = %121
  %130 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %130) #5
  store i32 1, ptr %5, align 4
  store i32 1, ptr %17, align 4
  br label %234

131:                                              ; preds = %121
  %132 = load ptr, ptr %16, align 8, !tbaa !5
  %133 = load i32, ptr %11, align 4, !tbaa !9
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds %struct.Node, ptr %132, i64 %134
  %136 = getelementptr inbounds %struct.Node, ptr %135, i32 0, i32 0
  %137 = load i64, ptr %136, align 8, !tbaa !15
  %138 = shl i64 %137, 9
  %139 = load ptr, ptr %16, align 8, !tbaa !5
  %140 = load i32, ptr %11, align 4, !tbaa !9
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds %struct.Node, ptr %139, i64 %141
  %143 = getelementptr inbounds %struct.Node, ptr %142, i32 0, i32 2
  %144 = load i32, ptr %143, align 8, !tbaa !17
  %145 = sext i32 %144 to i64
  %146 = or i64 %138, %145
  %147 = load ptr, ptr %16, align 8, !tbaa !5
  %148 = load i32, ptr %11, align 4, !tbaa !9
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds %struct.Node, ptr %147, i64 %149
  %151 = getelementptr inbounds %struct.Node, ptr %150, i32 0, i32 0
  store i64 %146, ptr %151, align 8, !tbaa !15
  br label %152

152:                                              ; preds = %131
  %153 = load i32, ptr %11, align 4, !tbaa !9
  %154 = add nsw i32 %153, 1
  store i32 %154, ptr %11, align 4, !tbaa !9
  br label %117, !llvm.loop !19

155:                                              ; preds = %117
  %156 = load ptr, ptr %16, align 8, !tbaa !5
  %157 = load i32, ptr %12, align 4, !tbaa !9
  %158 = sext i32 %157 to i64
  call void @qsort(ptr noundef %156, i64 noundef %158, i64 noundef 24, ptr noundef @LeafComparator)
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %159

159:                                              ; preds = %171, %155
  %160 = load i32, ptr %11, align 4, !tbaa !9
  %161 = load i32, ptr %12, align 4, !tbaa !9
  %162 = icmp slt i32 %160, %161
  br i1 %162, label %163, label %174

163:                                              ; preds = %159
  %164 = load ptr, ptr %16, align 8, !tbaa !5
  %165 = load i32, ptr %11, align 4, !tbaa !9
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds %struct.Node, ptr %164, i64 %166
  %168 = getelementptr inbounds %struct.Node, ptr %167, i32 0, i32 0
  %169 = load i64, ptr %168, align 8, !tbaa !15
  %170 = lshr i64 %169, 9
  store i64 %170, ptr %168, align 8, !tbaa !15
  br label %171

171:                                              ; preds = %163
  %172 = load i32, ptr %11, align 4, !tbaa !9
  %173 = add nsw i32 %172, 1
  store i32 %173, ptr %11, align 4, !tbaa !9
  br label %159, !llvm.loop !20

174:                                              ; preds = %159
  %175 = load i32, ptr %12, align 4, !tbaa !9
  %176 = sub nsw i32 %175, 1
  %177 = load i32, ptr %8, align 4, !tbaa !9
  %178 = icmp slt i32 %176, %177
  br i1 %178, label %179, label %182

179:                                              ; preds = %174
  %180 = load i32, ptr %12, align 4, !tbaa !9
  %181 = sub nsw i32 %180, 1
  store i32 %181, ptr %8, align 4, !tbaa !9
  br label %182

182:                                              ; preds = %179, %174
  %183 = load i32, ptr %8, align 4, !tbaa !9
  %184 = mul nsw i32 %183, 2
  %185 = load i32, ptr %12, align 4, !tbaa !9
  %186 = mul nsw i32 %184, %185
  %187 = sext i32 %186 to i64
  %188 = mul i64 %187, 24
  %189 = call noalias ptr @malloc(i64 noundef %188) #6
  store ptr %189, ptr %14, align 8, !tbaa !5
  %190 = load ptr, ptr %14, align 8, !tbaa !5
  %191 = getelementptr inbounds %struct.NodePool, ptr %10, i32 0, i32 0
  store ptr %190, ptr %191, align 8, !tbaa !21
  %192 = load i32, ptr %8, align 4, !tbaa !9
  %193 = sext i32 %192 to i64
  %194 = mul i64 %193, 16
  %195 = call noalias ptr @malloc(i64 noundef %194) #6
  store ptr %195, ptr %15, align 8, !tbaa !5
  %196 = load ptr, ptr %16, align 8, !tbaa !5
  %197 = load i32, ptr %8, align 4, !tbaa !9
  %198 = load ptr, ptr %15, align 8, !tbaa !5
  call void @InitLists(ptr noundef %10, ptr noundef %196, i32 noundef %197, ptr noundef %198)
  %199 = load i32, ptr %12, align 4, !tbaa !9
  %200 = mul nsw i32 2, %199
  %201 = sub nsw i32 %200, 4
  store i32 %201, ptr %13, align 4, !tbaa !9
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %202

202:                                              ; preds = %213, %182
  %203 = load i32, ptr %11, align 4, !tbaa !9
  %204 = load i32, ptr %13, align 4, !tbaa !9
  %205 = sub nsw i32 %204, 1
  %206 = icmp slt i32 %203, %205
  br i1 %206, label %207, label %216

207:                                              ; preds = %202
  %208 = load ptr, ptr %15, align 8, !tbaa !5
  %209 = load ptr, ptr %16, align 8, !tbaa !5
  %210 = load i32, ptr %12, align 4, !tbaa !9
  %211 = load i32, ptr %8, align 4, !tbaa !9
  %212 = sub nsw i32 %211, 1
  call void @BoundaryPM(ptr noundef %208, ptr noundef %209, i32 noundef %210, ptr noundef %10, i32 noundef %212)
  br label %213

213:                                              ; preds = %207
  %214 = load i32, ptr %11, align 4, !tbaa !9
  %215 = add nsw i32 %214, 1
  store i32 %215, ptr %11, align 4, !tbaa !9
  br label %202, !llvm.loop !23

216:                                              ; preds = %202
  %217 = load ptr, ptr %15, align 8, !tbaa !5
  %218 = load ptr, ptr %16, align 8, !tbaa !5
  %219 = load i32, ptr %12, align 4, !tbaa !9
  %220 = load i32, ptr %8, align 4, !tbaa !9
  %221 = sub nsw i32 %220, 1
  call void @BoundaryPMFinal(ptr noundef %217, ptr noundef %218, i32 noundef %219, ptr noundef %10, i32 noundef %221)
  %222 = load ptr, ptr %15, align 8, !tbaa !5
  %223 = load i32, ptr %8, align 4, !tbaa !9
  %224 = sub nsw i32 %223, 1
  %225 = sext i32 %224 to i64
  %226 = getelementptr inbounds [2 x ptr], ptr %222, i64 %225
  %227 = getelementptr inbounds [2 x ptr], ptr %226, i64 0, i64 1
  %228 = load ptr, ptr %227, align 8, !tbaa !5
  %229 = load ptr, ptr %16, align 8, !tbaa !5
  %230 = load ptr, ptr %9, align 8, !tbaa !5
  call void @ExtractBitLengths(ptr noundef %228, ptr noundef %229, ptr noundef %230)
  %231 = load ptr, ptr %15, align 8, !tbaa !5
  call void @free(ptr noundef %231) #5
  %232 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %232) #5
  %233 = load ptr, ptr %14, align 8, !tbaa !5
  call void @free(ptr noundef %233) #5
  store i32 0, ptr %5, align 4
  store i32 1, ptr %17, align 4
  br label %234

234:                                              ; preds = %216, %129, %96, %84, %79, %74
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %235 = load i32, ptr %5, align 4
  ret i32 %235
}

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

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

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

declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare hidden i32 @LeafComparator(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @InitLists(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @BoundaryPM(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @BoundaryPMFinal(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @ExtractBitLengths(ptr noundef, ptr noundef, ptr noundef) #0

; 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 = { 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 #3 = { 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 #4 = { "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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !14, i64 0}
!16 = !{!"Node", !14, i64 0, !6, i64 8, !10, i64 16}
!17 = !{!16, !10, i64 16}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}
!21 = !{!22, !6, i64 0}
!22 = !{!"NodePool", !6, i64 0}
!23 = distinct !{!23, !12}


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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @ZopfliLengthLimitedCodeLengths(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = alloca %struct.NodePool, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #7
  %6 = sext i32 %1 to i64
  %7 = mul nsw i64 %6, 24
  %8 = tail call noalias ptr @malloc(i64 noundef %7) #8
  %9 = icmp sgt i32 %1, 0
  br i1 %9, label %.lr.ph96.preheader, label %._crit_edge

.lr.ph96.preheader:                               ; preds = %4
  %10 = zext nneg i32 %1 to i64
  %11 = shl nuw nsw i64 %10, 2
  tail call void @llvm.memset.p0.i64(ptr align 4 %3, i8 0, i64 %11, i1 false), !tbaa !5
  %wide.trip.count = zext nneg i32 %1 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %12 = icmp eq i32 %1, 1
  br i1 %12, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph96.preheader.new

.lr.ph96.preheader.new:                           ; preds = %.lr.ph96.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  br label %.lr.ph96

.lr.ph96:                                         ; preds = %29, %.lr.ph96.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph96.preheader.new ], [ %indvars.iv.next.1, %29 ]
  %.08494 = phi i32 [ 0, %.lr.ph96.preheader.new ], [ %.185.1, %29 ]
  %niter = phi i64 [ 0, %.lr.ph96.preheader.new ], [ %niter.next.1, %29 ]
  %13 = getelementptr inbounds i64, ptr %0, i64 %indvars.iv
  %14 = load i64, ptr %13, align 8, !tbaa !9
  %.not91 = icmp eq i64 %14, 0
  br i1 %.not91, label %.lr.ph96.1, label %15

15:                                               ; preds = %.lr.ph96
  %16 = sext i32 %.08494 to i64
  %17 = getelementptr inbounds %struct.Node, ptr %8, i64 %16
  store i64 %14, ptr %17, align 8, !tbaa !11
  %18 = getelementptr inbounds i8, ptr %17, i64 16
  %19 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %19, ptr %18, align 8, !tbaa !14
  %20 = add nsw i32 %.08494, 1
  br label %.lr.ph96.1

.lr.ph96.1:                                       ; preds = %.lr.ph96, %15
  %.185 = phi i32 [ %20, %15 ], [ %.08494, %.lr.ph96 ]
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %21 = getelementptr inbounds i64, ptr %0, i64 %indvars.iv.next
  %22 = load i64, ptr %21, align 8, !tbaa !9
  %.not91.1 = icmp eq i64 %22, 0
  br i1 %.not91.1, label %29, label %23

23:                                               ; preds = %.lr.ph96.1
  %24 = sext i32 %.185 to i64
  %25 = getelementptr inbounds %struct.Node, ptr %8, i64 %24
  store i64 %22, ptr %25, align 8, !tbaa !11
  %26 = getelementptr inbounds i8, ptr %25, i64 16
  %27 = trunc nuw nsw i64 %indvars.iv.next to i32
  store i32 %27, ptr %26, align 8, !tbaa !14
  %28 = add nsw i32 %.185, 1
  br label %29

29:                                               ; preds = %23, %.lr.ph96.1
  %.185.1 = phi i32 [ %28, %23 ], [ %.185, %.lr.ph96.1 ]
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph96, !llvm.loop !15

._crit_edge.loopexit.unr-lcssa:                   ; preds = %29, %.lr.ph96.preheader
  %.185.lcssa.ph = phi i32 [ poison, %.lr.ph96.preheader ], [ %.185.1, %29 ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph96.preheader ], [ %indvars.iv.next.1, %29 ]
  %.08494.unr = phi i32 [ 0, %.lr.ph96.preheader ], [ %.185.1, %29 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph96.epil

.lr.ph96.epil:                                    ; preds = %._crit_edge.loopexit.unr-lcssa
  %30 = getelementptr inbounds i64, ptr %0, i64 %indvars.iv.unr
  %31 = load i64, ptr %30, align 8, !tbaa !9
  %.not91.epil = icmp eq i64 %31, 0
  br i1 %.not91.epil, label %._crit_edge, label %32

32:                                               ; preds = %.lr.ph96.epil
  %33 = sext i32 %.08494.unr to i64
  %34 = getelementptr inbounds %struct.Node, ptr %8, i64 %33
  store i64 %31, ptr %34, align 8, !tbaa !11
  %35 = getelementptr inbounds i8, ptr %34, i64 16
  %36 = trunc nuw nsw i64 %indvars.iv.unr to i32
  store i32 %36, ptr %35, align 8, !tbaa !14
  %37 = add nsw i32 %.08494.unr, 1
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %32, %.lr.ph96.epil, %4
  %.084.lcssa = phi i32 [ 0, %4 ], [ %.185.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %37, %32 ], [ %.08494.unr, %.lr.ph96.epil ]
  %38 = shl nuw i32 1, %2
  %39 = icmp slt i32 %38, %.084.lcssa
  br i1 %39, label %40, label %41

40:                                               ; preds = %._crit_edge
  tail call void @free(ptr noundef %8) #7
  br label %107

41:                                               ; preds = %._crit_edge
  switch i32 %.084.lcssa, label %.preheader [
    i32 0, label %44
    i32 1, label %45
    i32 2, label %50
  ]

.preheader:                                       ; preds = %41
  %42 = icmp sgt i32 %.084.lcssa, 0
  br i1 %42, label %.lr.ph98.preheader, label %._crit_edge99.thread

._crit_edge99.thread:                             ; preds = %.preheader
  %43 = sext i32 %.084.lcssa to i64
  tail call void @qsort(ptr noundef %8, i64 noundef %43, i64 noundef 24, ptr noundef nonnull @LeafComparator) #7
  br label %._crit_edge103

.lr.ph98.preheader:                               ; preds = %.preheader
  %wide.trip.count113 = zext nneg i32 %.084.lcssa to i64
  br label %.lr.ph98

44:                                               ; preds = %41
  tail call void @free(ptr noundef %8) #7
  br label %107

45:                                               ; preds = %41
  %46 = getelementptr inbounds i8, ptr %8, i64 16
  %47 = load i32, ptr %46, align 8, !tbaa !14
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds i32, ptr %3, i64 %48
  store i32 1, ptr %49, align 4, !tbaa !5
  tail call void @free(ptr noundef %8) #7
  br label %107

50:                                               ; preds = %41
  %51 = getelementptr inbounds i8, ptr %8, i64 16
  %52 = load i32, ptr %51, align 8, !tbaa !14
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds i32, ptr %3, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = add i32 %55, 1
  store i32 %56, ptr %54, align 4, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %8, i64 40
  %58 = load i32, ptr %57, align 8, !tbaa !14
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds i32, ptr %3, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = add i32 %61, 1
  store i32 %62, ptr %60, align 4, !tbaa !5
  tail call void @free(ptr noundef %8) #7
  br label %107

.lr.ph98:                                         ; preds = %.lr.ph98.preheader, %67
  %indvars.iv110 = phi i64 [ 0, %.lr.ph98.preheader ], [ %indvars.iv.next111, %67 ]
  %63 = getelementptr inbounds %struct.Node, ptr %8, i64 %indvars.iv110
  %64 = load i64, ptr %63, align 8, !tbaa !11
  %65 = icmp ugt i64 %64, 36028797018963967
  br i1 %65, label %66, label %67

66:                                               ; preds = %.lr.ph98
  tail call void @free(ptr noundef nonnull %8) #7
  br label %107

67:                                               ; preds = %.lr.ph98
  %68 = shl nuw i64 %64, 9
  %69 = getelementptr inbounds i8, ptr %63, i64 16
  %70 = load i32, ptr %69, align 8, !tbaa !14
  %71 = sext i32 %70 to i64
  %72 = or i64 %68, %71
  store i64 %72, ptr %63, align 8, !tbaa !11
  %indvars.iv.next111 = add nuw nsw i64 %indvars.iv110, 1
  %exitcond114.not = icmp eq i64 %indvars.iv.next111, %wide.trip.count113
  br i1 %exitcond114.not, label %._crit_edge99, label %.lr.ph98, !llvm.loop !17

._crit_edge99:                                    ; preds = %67
  %73 = zext nneg i32 %.084.lcssa to i64
  tail call void @qsort(ptr noundef nonnull %8, i64 noundef %73, i64 noundef 24, ptr noundef nonnull @LeafComparator) #7
  br i1 %42, label %.lr.ph102.preheader, label %._crit_edge103

.lr.ph102.preheader:                              ; preds = %._crit_edge99
  %xtraiter122 = and i64 %wide.trip.count113, 3
  %74 = icmp ult i32 %.084.lcssa, 4
  br i1 %74, label %._crit_edge103.loopexit.unr-lcssa, label %.lr.ph102.preheader.new

.lr.ph102.preheader.new:                          ; preds = %.lr.ph102.preheader
  %unroll_iter124 = and i64 %wide.trip.count113, 2147483644
  br label %.lr.ph102

.lr.ph102:                                        ; preds = %.lr.ph102, %.lr.ph102.preheader.new
  %indvars.iv115 = phi i64 [ 0, %.lr.ph102.preheader.new ], [ %indvars.iv.next116.3, %.lr.ph102 ]
  %niter125 = phi i64 [ 0, %.lr.ph102.preheader.new ], [ %niter125.next.3, %.lr.ph102 ]
  %75 = getelementptr inbounds %struct.Node, ptr %8, i64 %indvars.iv115
  %76 = load i64, ptr %75, align 8, !tbaa !11
  %77 = lshr i64 %76, 9
  store i64 %77, ptr %75, align 8, !tbaa !11
  %indvars.iv.next116 = or disjoint i64 %indvars.iv115, 1
  %78 = getelementptr inbounds %struct.Node, ptr %8, i64 %indvars.iv.next116
  %79 = load i64, ptr %78, align 8, !tbaa !11
  %80 = lshr i64 %79, 9
  store i64 %80, ptr %78, align 8, !tbaa !11
  %indvars.iv.next116.1 = or disjoint i64 %indvars.iv115, 2
  %81 = getelementptr inbounds %struct.Node, ptr %8, i64 %indvars.iv.next116.1
  %82 = load i64, ptr %81, align 8, !tbaa !11
  %83 = lshr i64 %82, 9
  store i64 %83, ptr %81, align 8, !tbaa !11
  %indvars.iv.next116.2 = or disjoint i64 %indvars.iv115, 3
  %84 = getelementptr inbounds %struct.Node, ptr %8, i64 %indvars.iv.next116.2
  %85 = load i64, ptr %84, align 8, !tbaa !11
  %86 = lshr i64 %85, 9
  store i64 %86, ptr %84, align 8, !tbaa !11
  %indvars.iv.next116.3 = add nuw nsw i64 %indvars.iv115, 4
  %niter125.next.3 = add i64 %niter125, 4
  %niter125.ncmp.3 = icmp eq i64 %niter125.next.3, %unroll_iter124
  br i1 %niter125.ncmp.3, label %._crit_edge103.loopexit.unr-lcssa, label %.lr.ph102, !llvm.loop !18

._crit_edge103.loopexit.unr-lcssa:                ; preds = %.lr.ph102, %.lr.ph102.preheader
  %indvars.iv115.unr = phi i64 [ 0, %.lr.ph102.preheader ], [ %indvars.iv.next116.3, %.lr.ph102 ]
  %lcmp.mod123.not = icmp eq i64 %xtraiter122, 0
  br i1 %lcmp.mod123.not, label %._crit_edge103, label %.lr.ph102.epil

.lr.ph102.epil:                                   ; preds = %._crit_edge103.loopexit.unr-lcssa, %.lr.ph102.epil
  %indvars.iv115.epil = phi i64 [ %indvars.iv.next116.epil, %.lr.ph102.epil ], [ %indvars.iv115.unr, %._crit_edge103.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph102.epil ], [ 0, %._crit_edge103.loopexit.unr-lcssa ]
  %87 = getelementptr inbounds %struct.Node, ptr %8, i64 %indvars.iv115.epil
  %88 = load i64, ptr %87, align 8, !tbaa !11
  %89 = lshr i64 %88, 9
  store i64 %89, ptr %87, align 8, !tbaa !11
  %indvars.iv.next116.epil = add nuw nsw i64 %indvars.iv115.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter122
  br i1 %epil.iter.cmp.not, label %._crit_edge103, label %.lr.ph102.epil, !llvm.loop !19

._crit_edge103:                                   ; preds = %._crit_edge103.loopexit.unr-lcssa, %.lr.ph102.epil, %._crit_edge99.thread, %._crit_edge99
  %.not = icmp sgt i32 %.084.lcssa, %2
  %90 = add nsw i32 %.084.lcssa, -1
  %spec.select = select i1 %.not, i32 %2, i32 %90
  %91 = shl i32 %.084.lcssa, 1
  %92 = mul i32 %91, %spec.select
  %93 = sext i32 %92 to i64
  %94 = mul nsw i64 %93, 24
  %95 = tail call noalias ptr @malloc(i64 noundef %94) #8
  store ptr %95, ptr %5, align 8, !tbaa !21
  %96 = sext i32 %spec.select to i64
  %97 = shl nsw i64 %96, 4
  %98 = tail call noalias ptr @malloc(i64 noundef %97) #8
  call void @InitLists(ptr noundef nonnull %5, ptr noundef %8, i32 noundef %spec.select, ptr noundef %98)
  %99 = icmp sgt i32 %.084.lcssa, 2
  br i1 %99, label %.lr.ph106, label %._crit_edge103.._crit_edge107_crit_edge

._crit_edge103.._crit_edge107_crit_edge:          ; preds = %._crit_edge103
  %.pre = add nsw i32 %spec.select, -1
  br label %._crit_edge107

.lr.ph106:                                        ; preds = %._crit_edge103
  %100 = add i32 %91, -5
  %101 = add nsw i32 %spec.select, -1
  %smax = call i32 @llvm.smax.i32(i32 %100, i32 1)
  br label %102

102:                                              ; preds = %.lr.ph106, %102
  %.4104 = phi i32 [ 0, %.lr.ph106 ], [ %103, %102 ]
  call void @BoundaryPM(ptr noundef %98, ptr noundef %8, i32 noundef %.084.lcssa, ptr noundef nonnull %5, i32 noundef %101)
  %103 = add nuw nsw i32 %.4104, 1
  %exitcond120.not = icmp eq i32 %103, %smax
  br i1 %exitcond120.not, label %._crit_edge107, label %102, !llvm.loop !23

._crit_edge107:                                   ; preds = %102, %._crit_edge103.._crit_edge107_crit_edge
  %.pre-phi = phi i32 [ %.pre, %._crit_edge103.._crit_edge107_crit_edge ], [ %101, %102 ]
  call void @BoundaryPMFinal(ptr noundef %98, ptr noundef %8, i32 noundef %.084.lcssa, ptr noundef nonnull %5, i32 noundef %.pre-phi)
  %104 = sext i32 %.pre-phi to i64
  %105 = getelementptr inbounds [2 x ptr], ptr %98, i64 %104, i64 1
  %106 = load ptr, ptr %105, align 8, !tbaa !24
  call void @ExtractBitLengths(ptr noundef %106, ptr noundef %8, ptr noundef %3)
  call void @free(ptr noundef %98) #7
  call void @free(ptr noundef %8) #7
  call void @free(ptr noundef %95) #7
  br label %107

107:                                              ; preds = %._crit_edge107, %66, %50, %45, %44, %40
  %.0 = phi i32 [ 1, %40 ], [ 0, %44 ], [ 0, %45 ], [ 0, %50 ], [ 1, %66 ], [ 0, %._crit_edge107 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #7
  ret i32 %.0
}

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

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

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

; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare hidden i32 @LeafComparator(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @InitLists(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @BoundaryPM(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @BoundaryPMFinal(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @ExtractBitLengths(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { 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 #4 = { nofree "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind }
attributes #8 = { 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 = !{!"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, !10, i64 0}
!12 = !{!"Node", !10, i64 0, !13, i64 8, !6, i64 16}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!12, !6, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.unroll.disable"}
!21 = !{!22, !13, i64 0}
!22 = !{!"NodePool", !13, i64 0}
!23 = distinct !{!23, !16}
!24 = !{!13, !13, i64 0}


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