; LLVM IR from yourtion/LearningMasteringAlgorithms-C :: source (lz77)

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

; Function Attrs: nounwind uwtable
define dso_local i32 @lz77_compress(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca [4096 x i8], align 16
  %10 = alloca [32 x i8], align 16
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i8, align 1
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #9
  call void @llvm.lifetime.start.p0(i64 4096, ptr %9) #9
  call void @llvm.lifetime.start.p0(i64 32, ptr %10) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #9
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #9
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #9
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr null, ptr %24, align 8, !tbaa !5
  store i32 4, ptr %18, align 4, !tbaa !9
  %25 = load i32, ptr %18, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = call noalias ptr @malloc(i64 noundef %26) #10
  store ptr %27, ptr %11, align 8, !tbaa !5
  %28 = icmp eq ptr %27, null
  br i1 %28, label %29, label %30

29:                                               ; preds = %3
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %23, align 4
  br label %187

30:                                               ; preds = %3
  %31 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %31, ptr align 4 %7, i64 4, i1 false)
  %32 = getelementptr inbounds [4096 x i8], ptr %9, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %32, i8 0, i64 4096, i1 false)
  %33 = getelementptr inbounds [32 x i8], ptr %10, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %33, i8 0, i64 32, i1 false)
  store i32 0, ptr %19, align 4, !tbaa !9
  store i32 0, ptr %22, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %54, %30
  %35 = load i32, ptr %22, align 4, !tbaa !9
  %36 = icmp slt i32 %35, 32
  br i1 %36, label %37, label %41

37:                                               ; preds = %34
  %38 = load i32, ptr %19, align 4, !tbaa !9
  %39 = load i32, ptr %7, align 4, !tbaa !9
  %40 = icmp slt i32 %38, %39
  br label %41

41:                                               ; preds = %37, %34
  %42 = phi i1 [ false, %34 ], [ %40, %37 ]
  br i1 %42, label %43, label %57

43:                                               ; preds = %41
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load i32, ptr %19, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds i8, ptr %44, i64 %46
  %48 = load i8, ptr %47, align 1, !tbaa !11
  %49 = load i32, ptr %22, align 4, !tbaa !9
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [32 x i8], ptr %10, i64 0, i64 %50
  store i8 %48, ptr %51, align 1, !tbaa !11
  %52 = load i32, ptr %19, align 4, !tbaa !9
  %53 = add nsw i32 %52, 1
  store i32 %53, ptr %19, align 4, !tbaa !9
  br label %54

54:                                               ; preds = %43
  %55 = load i32, ptr %22, align 4, !tbaa !9
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %22, align 4, !tbaa !9
  br label %34, !llvm.loop !12

57:                                               ; preds = %41
  %58 = load i32, ptr %18, align 4, !tbaa !9
  %59 = mul nsw i32 %58, 8
  store i32 %59, ptr %20, align 4, !tbaa !9
  %60 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %60, ptr %16, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %176, %57
  %62 = load i32, ptr %16, align 4, !tbaa !9
  %63 = icmp sgt i32 %62, 0
  br i1 %63, label %64, label %180

64:                                               ; preds = %61
  %65 = getelementptr inbounds [4096 x i8], ptr %9, i64 0, i64 0
  %66 = getelementptr inbounds [32 x i8], ptr %10, i64 0, i64 0
  %67 = call i32 @compare_win(ptr noundef %65, ptr noundef %66, ptr noundef %14, ptr noundef %13)
  store i32 %67, ptr %15, align 4, !tbaa !9
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %69, label %82

69:                                               ; preds = %64
  store i32 33554432, ptr %8, align 4, !tbaa !9
  %70 = load i32, ptr %8, align 4, !tbaa !9
  %71 = load i32, ptr %14, align 4, !tbaa !9
  %72 = shl i32 %71, 13
  %73 = or i32 %70, %72
  store i32 %73, ptr %8, align 4, !tbaa !9
  %74 = load i32, ptr %8, align 4, !tbaa !9
  %75 = load i32, ptr %15, align 4, !tbaa !9
  %76 = shl i32 %75, 8
  %77 = or i32 %74, %76
  store i32 %77, ptr %8, align 4, !tbaa !9
  %78 = load i32, ptr %8, align 4, !tbaa !9
  %79 = load i8, ptr %13, align 1, !tbaa !11
  %80 = zext i8 %79 to i32
  %81 = or i32 %78, %80
  store i32 %81, ptr %8, align 4, !tbaa !9
  store i32 26, ptr %17, align 4, !tbaa !9
  br label %87

82:                                               ; preds = %64
  store i32 0, ptr %8, align 4, !tbaa !9
  %83 = load i32, ptr %8, align 4, !tbaa !9
  %84 = load i8, ptr %13, align 1, !tbaa !11
  %85 = zext i8 %84 to i32
  %86 = or i32 %83, %85
  store i32 %86, ptr %8, align 4, !tbaa !9
  store i32 9, ptr %17, align 4, !tbaa !9
  br label %87

87:                                               ; preds = %82, %69
  %88 = load i32, ptr %8, align 4, !tbaa !9
  %89 = call i32 @__bswap_32(i32 noundef %88)
  store i32 %89, ptr %8, align 4, !tbaa !9
  store i32 0, ptr %22, align 4, !tbaa !9
  br label %90

90:                                               ; preds = %124, %87
  %91 = load i32, ptr %22, align 4, !tbaa !9
  %92 = load i32, ptr %17, align 4, !tbaa !9
  %93 = icmp slt i32 %91, %92
  br i1 %93, label %94, label %127

94:                                               ; preds = %90
  %95 = load i32, ptr %20, align 4, !tbaa !9
  %96 = srem i32 %95, 8
  %97 = icmp eq i32 %96, 0
  br i1 %97, label %98, label %110

98:                                               ; preds = %94
  %99 = load ptr, ptr %11, align 8, !tbaa !5
  %100 = load i32, ptr %20, align 4, !tbaa !9
  %101 = sdiv i32 %100, 8
  %102 = add nsw i32 %101, 1
  %103 = sext i32 %102 to i64
  %104 = call ptr @realloc(ptr noundef %99, i64 noundef %103) #11
  store ptr %104, ptr %12, align 8, !tbaa !5
  %105 = icmp eq ptr %104, null
  br i1 %105, label %106, label %108

106:                                              ; preds = %98
  %107 = load ptr, ptr %11, align 8, !tbaa !5
  call void @free(ptr noundef %107) #9
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %23, align 4
  br label %187

108:                                              ; preds = %98
  %109 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %109, ptr %11, align 8, !tbaa !5
  br label %110

110:                                              ; preds = %108, %94
  %111 = load i32, ptr %17, align 4, !tbaa !9
  %112 = sext i32 %111 to i64
  %113 = sub i64 32, %112
  %114 = load i32, ptr %22, align 4, !tbaa !9
  %115 = sext i32 %114 to i64
  %116 = add i64 %113, %115
  %117 = trunc i64 %116 to i32
  store i32 %117, ptr %21, align 4, !tbaa !9
  %118 = load ptr, ptr %11, align 8, !tbaa !5
  %119 = load i32, ptr %20, align 4, !tbaa !9
  %120 = load i32, ptr %21, align 4, !tbaa !9
  %121 = call i32 @bit_get(ptr noundef %8, i32 noundef %120)
  call void @bit_set(ptr noundef %118, i32 noundef %119, i32 noundef %121)
  %122 = load i32, ptr %20, align 4, !tbaa !9
  %123 = add nsw i32 %122, 1
  store i32 %123, ptr %20, align 4, !tbaa !9
  br label %124

124:                                              ; preds = %110
  %125 = load i32, ptr %22, align 4, !tbaa !9
  %126 = add nsw i32 %125, 1
  store i32 %126, ptr %22, align 4, !tbaa !9
  br label %90, !llvm.loop !14

127:                                              ; preds = %90
  %128 = load i32, ptr %15, align 4, !tbaa !9
  %129 = add nsw i32 %128, 1
  store i32 %129, ptr %15, align 4, !tbaa !9
  %130 = getelementptr inbounds [4096 x i8], ptr %9, i64 0, i64 0
  %131 = load i32, ptr %15, align 4, !tbaa !9
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [4096 x i8], ptr %9, i64 0, i64 %132
  %134 = load i32, ptr %15, align 4, !tbaa !9
  %135 = sub nsw i32 4096, %134
  %136 = sext i32 %135 to i64
  call void @llvm.memmove.p0.p0.i64(ptr align 16 %130, ptr align 1 %133, i64 %136, i1 false)
  %137 = load i32, ptr %15, align 4, !tbaa !9
  %138 = sub nsw i32 4096, %137
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [4096 x i8], ptr %9, i64 0, i64 %139
  %141 = getelementptr inbounds [32 x i8], ptr %10, i64 0, i64 0
  %142 = load i32, ptr %15, align 4, !tbaa !9
  %143 = sext i32 %142 to i64
  call void @llvm.memmove.p0.p0.i64(ptr align 1 %140, ptr align 16 %141, i64 %143, i1 false)
  %144 = getelementptr inbounds [32 x i8], ptr %10, i64 0, i64 0
  %145 = load i32, ptr %15, align 4, !tbaa !9
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [32 x i8], ptr %10, i64 0, i64 %146
  %148 = load i32, ptr %15, align 4, !tbaa !9
  %149 = sub nsw i32 32, %148
  %150 = sext i32 %149 to i64
  call void @llvm.memmove.p0.p0.i64(ptr align 16 %144, ptr align 1 %147, i64 %150, i1 false)
  %151 = load i32, ptr %15, align 4, !tbaa !9
  %152 = sub nsw i32 32, %151
  store i32 %152, ptr %22, align 4, !tbaa !9
  br label %153

153:                                              ; preds = %173, %127
  %154 = load i32, ptr %22, align 4, !tbaa !9
  %155 = icmp slt i32 %154, 32
  br i1 %155, label %156, label %160

156:                                              ; preds = %153
  %157 = load i32, ptr %19, align 4, !tbaa !9
  %158 = load i32, ptr %7, align 4, !tbaa !9
  %159 = icmp slt i32 %157, %158
  br label %160

160:                                              ; preds = %156, %153
  %161 = phi i1 [ false, %153 ], [ %159, %156 ]
  br i1 %161, label %162, label %176

162:                                              ; preds = %160
  %163 = load ptr, ptr %5, align 8, !tbaa !5
  %164 = load i32, ptr %19, align 4, !tbaa !9
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds i8, ptr %163, i64 %165
  %167 = load i8, ptr %166, align 1, !tbaa !11
  %168 = load i32, ptr %22, align 4, !tbaa !9
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [32 x i8], ptr %10, i64 0, i64 %169
  store i8 %167, ptr %170, align 1, !tbaa !11
  %171 = load i32, ptr %19, align 4, !tbaa !9
  %172 = add nsw i32 %171, 1
  store i32 %172, ptr %19, align 4, !tbaa !9
  br label %173

173:                                              ; preds = %162
  %174 = load i32, ptr %22, align 4, !tbaa !9
  %175 = add nsw i32 %174, 1
  store i32 %175, ptr %22, align 4, !tbaa !9
  br label %153, !llvm.loop !15

176:                                              ; preds = %160
  %177 = load i32, ptr %16, align 4, !tbaa !9
  %178 = load i32, ptr %15, align 4, !tbaa !9
  %179 = sub nsw i32 %177, %178
  store i32 %179, ptr %16, align 4, !tbaa !9
  br label %61, !llvm.loop !16

180:                                              ; preds = %61
  %181 = load ptr, ptr %11, align 8, !tbaa !5
  %182 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %181, ptr %182, align 8, !tbaa !5
  %183 = load i32, ptr %20, align 4, !tbaa !9
  %184 = sub nsw i32 %183, 1
  %185 = sdiv i32 %184, 8
  %186 = add nsw i32 %185, 1
  store i32 %186, ptr %4, align 4
  store i32 1, ptr %23, align 4
  br label %187

187:                                              ; preds = %180, %106, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #9
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #9
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #9
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #9
  call void @llvm.lifetime.end.p0(i64 4096, ptr %9) #9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #9
  %188 = load i32, ptr %4, align 4
  ret i32 %188
}

; 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: 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @__bswap_32(i32 noundef) #5

; Function Attrs: nounwind allocsize(1)
declare ptr @realloc(ptr noundef, i64 noundef) #6

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

declare void @bit_set(ptr noundef, i32 noundef, i32 noundef) #8

declare i32 @bit_get(ptr noundef, i32 noundef) #8

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

; 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { inlinehint 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 #6 = { nounwind allocsize(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 #7 = { 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 #8 = { "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 #9 = { nounwind }
attributes #10 = { nounwind allocsize(0) }
attributes #11 = { nounwind allocsize(1) }

!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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}


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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -268435455, 268435457) i32 @lz77_compress(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca i32, align 4
  %5 = alloca [4096 x i8], align 16
  %6 = alloca [32 x i8], align 16
  %7 = alloca i8, align 1
  %8 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #11
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %5) #11
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #11
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %7) #11
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #11
  store ptr null, ptr %1, align 8, !tbaa !5
  %9 = tail call noalias dereferenceable_or_null(4) ptr @malloc(i64 noundef 4) #12
  %10 = icmp eq ptr %9, null
  br i1 %10, label %72, label %11

11:                                               ; preds = %3
  store i32 %2, ptr %9, align 1
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(4096) %5, i8 0, i64 4096, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %6, i8 0, i64 32, i1 false)
  %12 = icmp sgt i32 %2, 0
  br i1 %12, label %.lr.ph82.preheader, label %._crit_edge83

.lr.ph82.preheader:                               ; preds = %11
  %13 = add nsw i32 %2, -1
  %14 = tail call i32 @llvm.umin.i32(i32 %13, i32 31)
  %narrow = add nuw nsw i32 %14, 1
  %15 = zext nneg i32 %narrow to i64
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(1) %6, ptr noundef nonnull align 1 dereferenceable(1) %0, i64 %15, i1 false), !tbaa !9
  %16 = zext nneg i32 %2 to i64
  br label %.lr.ph82

.lr.ph82:                                         ; preds = %.lr.ph82.preheader, %._crit_edge
  %.05181 = phi i32 [ %44, %._crit_edge ], [ 32, %.lr.ph82.preheader ]
  %.15480 = phi i32 [ %.255.lcssa, %._crit_edge ], [ %narrow, %.lr.ph82.preheader ]
  %.05679 = phi ptr [ %.258, %._crit_edge ], [ %9, %.lr.ph82.preheader ]
  %.06078 = phi i32 [ %68, %._crit_edge ], [ %2, %.lr.ph82.preheader ]
  %17 = call i32 @compare_win(ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %8, ptr noundef nonnull %7)
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %27, label %18

18:                                               ; preds = %.lr.ph82
  %19 = load i32, ptr %8, align 4, !tbaa !10
  %20 = shl i32 %19, 13
  %21 = shl i32 %17, 8
  %22 = or i32 %21, %20
  %23 = load i8, ptr %7, align 1, !tbaa !9
  %24 = zext i8 %23 to i32
  %25 = or disjoint i32 %22, %24
  %26 = or i32 %25, 33554432
  br label %30

27:                                               ; preds = %.lr.ph82
  %28 = load i8, ptr %7, align 1, !tbaa !9
  %29 = zext i8 %28 to i32
  br label %30

30:                                               ; preds = %27, %18
  %storemerge = phi i32 [ %29, %27 ], [ %26, %18 ]
  %.059 = phi i32 [ 9, %27 ], [ 26, %18 ]
  store i32 %storemerge, ptr %4, align 4, !tbaa !10
  %31 = call i32 @__bswap_32(i32 noundef %storemerge)
  store i32 %31, ptr %4, align 4, !tbaa !10
  br label %32

32:                                               ; preds = %30, %42
  %.173 = phi i32 [ 0, %30 ], [ %45, %42 ]
  %.15272 = phi i32 [ %.05181, %30 ], [ %44, %42 ]
  %.15771 = phi ptr [ %.05679, %30 ], [ %.258, %42 ]
  %33 = and i32 %.15272, 7
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %42

35:                                               ; preds = %32
  %36 = ashr exact i32 %.15272, 3
  %37 = add nsw i32 %36, 1
  %38 = sext i32 %37 to i64
  %39 = call ptr @realloc(ptr noundef %.15771, i64 noundef %38) #13
  %40 = icmp eq ptr %39, null
  br i1 %40, label %41, label %42

41:                                               ; preds = %35
  call void @free(ptr noundef %.15771) #11
  br label %72

42:                                               ; preds = %35, %32
  %.258 = phi ptr [ %.15771, %32 ], [ %39, %35 ]
  %reass.sub86 = sub nsw i32 %.173, %.059
  %narrow64 = add nsw i32 %reass.sub86, 32
  %43 = call i32 @bit_get(ptr noundef nonnull %4, i32 noundef %narrow64) #11
  call void @bit_set(ptr noundef %.258, i32 noundef %.15272, i32 noundef %43) #11
  %44 = add nsw i32 %.15272, 1
  %45 = add nuw nsw i32 %.173, 1
  %exitcond.not = icmp eq i32 %45, %.059
  br i1 %exitcond.not, label %46, label %32, !llvm.loop !12

46:                                               ; preds = %42
  %47 = add nsw i32 %17, 1
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [4096 x i8], ptr %5, i64 0, i64 %48
  %50 = sub nsw i32 4095, %17
  %51 = sext i32 %50 to i64
  call void @llvm.memmove.p0.p0.i64(ptr nonnull align 16 %5, ptr nonnull align 1 %49, i64 %51, i1 false)
  %52 = getelementptr inbounds [4096 x i8], ptr %5, i64 0, i64 %51
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %52, ptr nonnull align 16 %6, i64 %48, i1 false)
  %53 = getelementptr inbounds [32 x i8], ptr %6, i64 0, i64 %48
  %54 = sub i32 31, %17
  %55 = sext i32 %54 to i64
  call void @llvm.memmove.p0.p0.i64(ptr nonnull align 16 %6, ptr nonnull align 1 %53, i64 %55, i1 false)
  %56 = icmp sgt i32 %17, -1
  %57 = icmp slt i32 %.15480, %2
  %58 = select i1 %56, i1 %57, i1 false
  br i1 %58, label %.lr.ph76.preheader, label %._crit_edge

.lr.ph76.preheader:                               ; preds = %46
  %scevgep = getelementptr i8, ptr %6, i64 %55
  %59 = sext i32 %.15480 to i64
  %scevgep96 = getelementptr i8, ptr %0, i64 %59
  %60 = xor i32 %.15480, -1
  %61 = add i32 %60, %2
  %62 = call i32 @llvm.umin.i32(i32 %61, i32 %17)
  %narrow105 = add nuw i32 %62, 1
  %63 = zext i32 %narrow105 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(1) %scevgep, ptr noundef nonnull align 1 dereferenceable(1) %scevgep96, i64 %63, i1 false), !tbaa !9
  br label %.lr.ph76

.lr.ph76:                                         ; preds = %.lr.ph76.preheader, %.lr.ph76
  %indvars.iv98 = phi i64 [ %59, %.lr.ph76.preheader ], [ %indvars.iv.next99, %.lr.ph76 ]
  %indvars.iv = phi i64 [ %55, %.lr.ph76.preheader ], [ %indvars.iv.next, %.lr.ph76 ]
  %indvars.iv.next99 = add nsw i64 %indvars.iv98, 1
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %64 = icmp slt i64 %indvars.iv, 31
  %65 = icmp slt i64 %indvars.iv.next99, %16
  %66 = select i1 %64, i1 %65, i1 false
  br i1 %66, label %.lr.ph76, label %._crit_edge.loopexit, !llvm.loop !14

._crit_edge.loopexit:                             ; preds = %.lr.ph76
  %67 = trunc i64 %indvars.iv.next99 to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %46
  %.255.lcssa = phi i32 [ %.15480, %46 ], [ %67, %._crit_edge.loopexit ]
  %68 = sub nsw i32 %.06078, %47
  %69 = icmp sgt i32 %68, 0
  br i1 %69, label %.lr.ph82, label %._crit_edge83.loopexit, !llvm.loop !15

._crit_edge83.loopexit:                           ; preds = %._crit_edge
  %70 = sdiv i32 %.15272, 8
  %71 = add nsw i32 %70, 1
  br label %._crit_edge83

._crit_edge83:                                    ; preds = %11, %._crit_edge83.loopexit
  %.056.lcssa = phi ptr [ %.258, %._crit_edge83.loopexit ], [ %9, %11 ]
  %.051.lcssa = phi i32 [ %71, %._crit_edge83.loopexit ], [ 4, %11 ]
  store ptr %.056.lcssa, ptr %1, align 8, !tbaa !5
  br label %72

72:                                               ; preds = %3, %._crit_edge83, %41
  %.050 = phi i32 [ -1, %41 ], [ %.051.lcssa, %._crit_edge83 ], [ -1, %3 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #11
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %7) #11
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #11
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %5) #11
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #11
  ret i32 %.050
}

; 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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @__bswap_32(i32 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias noundef ptr @realloc(ptr allocptr nocapture noundef, i64 noundef) local_unnamed_addr #5

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

declare void @bit_set(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #7

declare i32 @bit_get(ptr noundef, i32 noundef) local_unnamed_addr #7

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

; 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: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #9

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

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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { inlinehint 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 = { mustprogress nounwind willreturn allockind("realloc") allocsize(1) 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 #6 = { 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 #7 = { "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 #8 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #9 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #10 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #11 = { nounwind }
attributes #12 = { nounwind allocsize(0) }
attributes #13 = { nounwind allocsize(1) }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}


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