; LLVM IR from evanxg852000/rockstartdev :: mastering-ds-in-c/c-src/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 i64, align 8
  %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 8, 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 %191

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 = %180, %57
  %62 = load i32, ptr %16, align 4, !tbaa !9
  %63 = icmp sgt i32 %62, 0
  br i1 %63, label %64, label %184

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 %84

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

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

89:                                               ; preds = %84, %69
  %90 = load i64, ptr %8, align 8, !tbaa !14
  %91 = trunc i64 %90 to i32
  %92 = call i32 @__bswap_32(i32 noundef %91)
  %93 = zext i32 %92 to i64
  store i64 %93, ptr %8, align 8, !tbaa !14
  store i32 0, ptr %22, align 4, !tbaa !9
  br label %94

94:                                               ; preds = %128, %89
  %95 = load i32, ptr %22, align 4, !tbaa !9
  %96 = load i32, ptr %17, align 4, !tbaa !9
  %97 = icmp slt i32 %95, %96
  br i1 %97, label %98, label %131

98:                                               ; preds = %94
  %99 = load i32, ptr %20, align 4, !tbaa !9
  %100 = srem i32 %99, 8
  %101 = icmp eq i32 %100, 0
  br i1 %101, label %102, label %114

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

110:                                              ; preds = %102
  %111 = load ptr, ptr %11, align 8, !tbaa !5
  call void @free(ptr noundef %111) #9
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %23, align 4
  br label %191

112:                                              ; preds = %102
  %113 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %113, ptr %11, align 8, !tbaa !5
  br label %114

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

128:                                              ; preds = %114
  %129 = load i32, ptr %22, align 4, !tbaa !9
  %130 = add nsw i32 %129, 1
  store i32 %130, ptr %22, align 4, !tbaa !9
  br label %94, !llvm.loop !16

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

157:                                              ; preds = %177, %131
  %158 = load i32, ptr %22, align 4, !tbaa !9
  %159 = icmp slt i32 %158, 32
  br i1 %159, label %160, label %164

160:                                              ; preds = %157
  %161 = load i32, ptr %19, align 4, !tbaa !9
  %162 = load i32, ptr %7, align 4, !tbaa !9
  %163 = icmp slt i32 %161, %162
  br label %164

164:                                              ; preds = %160, %157
  %165 = phi i1 [ false, %157 ], [ %163, %160 ]
  br i1 %165, label %166, label %180

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

177:                                              ; preds = %166
  %178 = load i32, ptr %22, align 4, !tbaa !9
  %179 = add nsw i32 %178, 1
  store i32 %179, ptr %22, align 4, !tbaa !9
  br label %157, !llvm.loop !17

180:                                              ; preds = %164
  %181 = load i32, ptr %16, align 4, !tbaa !9
  %182 = load i32, ptr %15, align 4, !tbaa !9
  %183 = sub nsw i32 %181, %182
  store i32 %183, ptr %16, align 4, !tbaa !9
  br label %61, !llvm.loop !18

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

191:                                              ; preds = %184, %110, %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 8, ptr %8) #9
  %192 = load i32, ptr %4, align 4
  ret i32 %192
}

; 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 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = distinct !{!16, !13}
!17 = distinct !{!17, !13}
!18 = distinct !{!18, !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 i64, align 8
  %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 8, 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 %75, 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 [ %47, %._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 [ %71, %._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 %28, 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 = or i32 %22, 33554432
  %24 = sext i32 %23 to i64
  %25 = load i8, ptr %7, align 1, !tbaa !9
  %26 = zext i8 %25 to i64
  %27 = or disjoint i64 %24, %26
  br label %31

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

31:                                               ; preds = %28, %18
  %storemerge = phi i64 [ %30, %28 ], [ %27, %18 ]
  %.059 = phi i32 [ 9, %28 ], [ 26, %18 ]
  store i64 %storemerge, ptr %4, align 8, !tbaa !12
  %32 = trunc nsw i64 %storemerge to i32
  %33 = call i32 @__bswap_32(i32 noundef %32)
  %34 = zext i32 %33 to i64
  store i64 %34, ptr %4, align 8, !tbaa !12
  br label %35

35:                                               ; preds = %31, %45
  %.173 = phi i32 [ 0, %31 ], [ %48, %45 ]
  %.15272 = phi i32 [ %.05181, %31 ], [ %47, %45 ]
  %.15771 = phi ptr [ %.05679, %31 ], [ %.258, %45 ]
  %36 = and i32 %.15272, 7
  %37 = icmp eq i32 %36, 0
  br i1 %37, label %38, label %45

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

44:                                               ; preds = %38
  call void @free(ptr noundef %.15771) #11
  br label %75

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

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

.lr.ph76.preheader:                               ; preds = %49
  %scevgep = getelementptr i8, ptr %6, i64 %58
  %62 = sext i32 %.15480 to i64
  %scevgep96 = getelementptr i8, ptr %0, i64 %62
  %63 = xor i32 %.15480, -1
  %64 = add i32 %63, %2
  %65 = call i32 @llvm.umin.i32(i32 %64, i32 %17)
  %narrow105 = add nuw i32 %65, 1
  %66 = 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 %66, i1 false), !tbaa !9
  br label %.lr.ph76

.lr.ph76:                                         ; preds = %.lr.ph76.preheader, %.lr.ph76
  %indvars.iv98 = phi i64 [ %62, %.lr.ph76.preheader ], [ %indvars.iv.next99, %.lr.ph76 ]
  %indvars.iv = phi i64 [ %58, %.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
  %67 = icmp slt i64 %indvars.iv, 31
  %68 = icmp slt i64 %indvars.iv.next99, %16
  %69 = select i1 %67, i1 %68, i1 false
  br i1 %69, label %.lr.ph76, label %._crit_edge.loopexit, !llvm.loop !16

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

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %49
  %.255.lcssa = phi i32 [ %.15480, %49 ], [ %70, %._crit_edge.loopexit ]
  %71 = sub nsw i32 %.06078, %50
  %72 = icmp sgt i32 %71, 0
  br i1 %72, label %.lr.ph82, label %._crit_edge83.loopexit, !llvm.loop !17

._crit_edge83.loopexit:                           ; preds = %._crit_edge
  %73 = sdiv i32 %.15272, 8
  %74 = add nsw i32 %73, 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 [ %74, %._crit_edge83.loopexit ], [ 4, %11 ]
  store ptr %.056.lcssa, ptr %1, align 8, !tbaa !5
  br label %75

75:                                               ; preds = %3, %._crit_edge83, %44
  %.050 = phi i32 [ -1, %44 ], [ %.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 8, 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 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15}


; 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