; LLVM IR from itchio/go-brotli :: enc (compress_fragment)

; 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 hidden void @BrotliCompressFragmentFast(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, i64 noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef %10, ptr noundef %11) #0 {
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca i64, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca ptr, align 8
  %23 = alloca ptr, align 8
  %24 = alloca ptr, align 8
  %25 = alloca i64, align 8
  %26 = alloca i64, align 8
  %27 = alloca i32, align 4
  store ptr %0, ptr %13, align 8, !tbaa !5
  store ptr %1, ptr %14, align 8, !tbaa !5
  store i64 %2, ptr %15, align 8, !tbaa !9
  store i32 %3, ptr %16, align 4, !tbaa !11
  store ptr %4, ptr %17, align 8, !tbaa !5
  store i64 %5, ptr %18, align 8, !tbaa !9
  store ptr %6, ptr %19, align 8, !tbaa !5
  store ptr %7, ptr %20, align 8, !tbaa !5
  store ptr %8, ptr %21, align 8, !tbaa !5
  store ptr %9, ptr %22, align 8, !tbaa !5
  store ptr %10, ptr %23, align 8, !tbaa !5
  store ptr %11, ptr %24, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #4
  %28 = load ptr, ptr %23, align 8, !tbaa !5
  %29 = load i64, ptr %28, align 8, !tbaa !9
  store i64 %29, ptr %25, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #4
  %30 = load i64, ptr %18, align 8, !tbaa !9
  %31 = call i32 @Log2FloorNonZero(i64 noundef %30)
  %32 = zext i32 %31 to i64
  store i64 %32, ptr %26, align 8, !tbaa !9
  %33 = load i64, ptr %15, align 8, !tbaa !9
  %34 = icmp eq i64 %33, 0
  br i1 %34, label %35, label %45

35:                                               ; preds = %12
  %36 = load ptr, ptr %23, align 8, !tbaa !5
  %37 = load ptr, ptr %24, align 8, !tbaa !5
  call void @BrotliWriteBits(i64 noundef 1, i64 noundef 1, ptr noundef %36, ptr noundef %37)
  %38 = load ptr, ptr %23, align 8, !tbaa !5
  %39 = load ptr, ptr %24, align 8, !tbaa !5
  call void @BrotliWriteBits(i64 noundef 1, i64 noundef 1, ptr noundef %38, ptr noundef %39)
  %40 = load ptr, ptr %23, align 8, !tbaa !5
  %41 = load i64, ptr %40, align 8, !tbaa !9
  %42 = add i64 %41, 7
  %43 = and i64 %42, 4294967288
  %44 = load ptr, ptr %23, align 8, !tbaa !5
  store i64 %43, ptr %44, align 8, !tbaa !9
  store i32 1, ptr %27, align 4
  br label %127

45:                                               ; preds = %12
  %46 = load i64, ptr %26, align 8, !tbaa !9
  switch i64 %46, label %95 [
    i64 9, label %47
    i64 11, label %59
    i64 13, label %71
    i64 15, label %83
  ]

47:                                               ; preds = %45
  %48 = load ptr, ptr %13, align 8, !tbaa !5
  %49 = load ptr, ptr %14, align 8, !tbaa !5
  %50 = load i64, ptr %15, align 8, !tbaa !9
  %51 = load i32, ptr %16, align 4, !tbaa !11
  %52 = load ptr, ptr %17, align 8, !tbaa !5
  %53 = load ptr, ptr %19, align 8, !tbaa !5
  %54 = load ptr, ptr %20, align 8, !tbaa !5
  %55 = load ptr, ptr %21, align 8, !tbaa !5
  %56 = load ptr, ptr %22, align 8, !tbaa !5
  %57 = load ptr, ptr %23, align 8, !tbaa !5
  %58 = load ptr, ptr %24, align 8, !tbaa !5
  call void @BrotliCompressFragmentFastImpl9(ptr noundef %48, ptr noundef %49, i64 noundef %50, i32 noundef %51, ptr noundef %52, ptr noundef %53, ptr noundef %54, ptr noundef %55, ptr noundef %56, ptr noundef %57, ptr noundef %58)
  br label %96

59:                                               ; preds = %45
  %60 = load ptr, ptr %13, align 8, !tbaa !5
  %61 = load ptr, ptr %14, align 8, !tbaa !5
  %62 = load i64, ptr %15, align 8, !tbaa !9
  %63 = load i32, ptr %16, align 4, !tbaa !11
  %64 = load ptr, ptr %17, align 8, !tbaa !5
  %65 = load ptr, ptr %19, align 8, !tbaa !5
  %66 = load ptr, ptr %20, align 8, !tbaa !5
  %67 = load ptr, ptr %21, align 8, !tbaa !5
  %68 = load ptr, ptr %22, align 8, !tbaa !5
  %69 = load ptr, ptr %23, align 8, !tbaa !5
  %70 = load ptr, ptr %24, align 8, !tbaa !5
  call void @BrotliCompressFragmentFastImpl11(ptr noundef %60, ptr noundef %61, i64 noundef %62, i32 noundef %63, ptr noundef %64, ptr noundef %65, ptr noundef %66, ptr noundef %67, ptr noundef %68, ptr noundef %69, ptr noundef %70)
  br label %96

71:                                               ; preds = %45
  %72 = load ptr, ptr %13, align 8, !tbaa !5
  %73 = load ptr, ptr %14, align 8, !tbaa !5
  %74 = load i64, ptr %15, align 8, !tbaa !9
  %75 = load i32, ptr %16, align 4, !tbaa !11
  %76 = load ptr, ptr %17, align 8, !tbaa !5
  %77 = load ptr, ptr %19, align 8, !tbaa !5
  %78 = load ptr, ptr %20, align 8, !tbaa !5
  %79 = load ptr, ptr %21, align 8, !tbaa !5
  %80 = load ptr, ptr %22, align 8, !tbaa !5
  %81 = load ptr, ptr %23, align 8, !tbaa !5
  %82 = load ptr, ptr %24, align 8, !tbaa !5
  call void @BrotliCompressFragmentFastImpl13(ptr noundef %72, ptr noundef %73, i64 noundef %74, i32 noundef %75, ptr noundef %76, ptr noundef %77, ptr noundef %78, ptr noundef %79, ptr noundef %80, ptr noundef %81, ptr noundef %82)
  br label %96

83:                                               ; preds = %45
  %84 = load ptr, ptr %13, align 8, !tbaa !5
  %85 = load ptr, ptr %14, align 8, !tbaa !5
  %86 = load i64, ptr %15, align 8, !tbaa !9
  %87 = load i32, ptr %16, align 4, !tbaa !11
  %88 = load ptr, ptr %17, align 8, !tbaa !5
  %89 = load ptr, ptr %19, align 8, !tbaa !5
  %90 = load ptr, ptr %20, align 8, !tbaa !5
  %91 = load ptr, ptr %21, align 8, !tbaa !5
  %92 = load ptr, ptr %22, align 8, !tbaa !5
  %93 = load ptr, ptr %23, align 8, !tbaa !5
  %94 = load ptr, ptr %24, align 8, !tbaa !5
  call void @BrotliCompressFragmentFastImpl15(ptr noundef %84, ptr noundef %85, i64 noundef %86, i32 noundef %87, ptr noundef %88, ptr noundef %89, ptr noundef %90, ptr noundef %91, ptr noundef %92, ptr noundef %93, ptr noundef %94)
  br label %96

95:                                               ; preds = %45
  br label %96

96:                                               ; preds = %95, %83, %71, %59, %47
  %97 = load ptr, ptr %23, align 8, !tbaa !5
  %98 = load i64, ptr %97, align 8, !tbaa !9
  %99 = load i64, ptr %25, align 8, !tbaa !9
  %100 = sub i64 %98, %99
  %101 = load i64, ptr %15, align 8, !tbaa !9
  %102 = shl i64 %101, 3
  %103 = add i64 31, %102
  %104 = icmp ugt i64 %100, %103
  br i1 %104, label %105, label %113

105:                                              ; preds = %96
  %106 = load ptr, ptr %14, align 8, !tbaa !5
  %107 = load ptr, ptr %14, align 8, !tbaa !5
  %108 = load i64, ptr %15, align 8, !tbaa !9
  %109 = getelementptr inbounds i8, ptr %107, i64 %108
  %110 = load i64, ptr %25, align 8, !tbaa !9
  %111 = load ptr, ptr %23, align 8, !tbaa !5
  %112 = load ptr, ptr %24, align 8, !tbaa !5
  call void @EmitUncompressedMetaBlock(ptr noundef %106, ptr noundef %109, i64 noundef %110, ptr noundef %111, ptr noundef %112)
  br label %113

113:                                              ; preds = %105, %96
  %114 = load i32, ptr %16, align 4, !tbaa !11
  %115 = icmp ne i32 %114, 0
  br i1 %115, label %116, label %126

116:                                              ; preds = %113
  %117 = load ptr, ptr %23, align 8, !tbaa !5
  %118 = load ptr, ptr %24, align 8, !tbaa !5
  call void @BrotliWriteBits(i64 noundef 1, i64 noundef 1, ptr noundef %117, ptr noundef %118)
  %119 = load ptr, ptr %23, align 8, !tbaa !5
  %120 = load ptr, ptr %24, align 8, !tbaa !5
  call void @BrotliWriteBits(i64 noundef 1, i64 noundef 1, ptr noundef %119, ptr noundef %120)
  %121 = load ptr, ptr %23, align 8, !tbaa !5
  %122 = load i64, ptr %121, align 8, !tbaa !9
  %123 = add i64 %122, 7
  %124 = and i64 %123, 4294967288
  %125 = load ptr, ptr %23, align 8, !tbaa !5
  store i64 %124, ptr %125, align 8, !tbaa !9
  br label %126

126:                                              ; preds = %116, %113
  store i32 0, ptr %27, align 4
  br label %127

127:                                              ; preds = %126, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #4
  %128 = load i32, ptr %27, align 4
  switch i32 %128, label %130 [
    i32 0, label %129
    i32 1, label %129
  ]

129:                                              ; preds = %127, %127
  ret void

130:                                              ; preds = %127
  unreachable
}

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @Log2FloorNonZero(i64 noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @BrotliWriteBits(i64 noundef, i64 noundef, ptr noalias noundef, ptr noalias noundef) #2

; Function Attrs: noinline nounwind uwtable
declare hidden void @BrotliCompressFragmentFastImpl9(ptr noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: noinline nounwind uwtable
declare hidden void @BrotliCompressFragmentFastImpl11(ptr noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: noinline nounwind uwtable
declare hidden void @BrotliCompressFragmentFastImpl13(ptr noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: noinline nounwind uwtable
declare hidden void @BrotliCompressFragmentFastImpl15(ptr noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @EmitUncompressedMetaBlock(ptr noundef, ptr noundef, i64 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 = { alwaysinline nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { noinline 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 #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


; 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 hidden void @BrotliCompressFragmentFast(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, i64 noundef %5, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef %10, ptr noundef %11) local_unnamed_addr #0 {
  %13 = load i64, ptr %10, align 8, !tbaa !5
  %14 = tail call i32 @Log2FloorNonZero(i64 noundef %5)
  %15 = icmp eq i64 %2, 0
  br i1 %15, label %.sink.split, label %16

16:                                               ; preds = %12
  switch i32 %14, label %21 [
    i32 9, label %17
    i32 11, label %18
    i32 13, label %19
    i32 15, label %20
  ]

17:                                               ; preds = %16
  tail call void @BrotliCompressFragmentFastImpl9(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef nonnull %10, ptr noundef %11)
  br label %21

18:                                               ; preds = %16
  tail call void @BrotliCompressFragmentFastImpl11(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef nonnull %10, ptr noundef %11)
  br label %21

19:                                               ; preds = %16
  tail call void @BrotliCompressFragmentFastImpl13(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef nonnull %10, ptr noundef %11)
  br label %21

20:                                               ; preds = %16
  tail call void @BrotliCompressFragmentFastImpl15(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef %6, ptr noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef nonnull %10, ptr noundef %11)
  br label %21

21:                                               ; preds = %16, %20, %19, %18, %17
  %22 = load i64, ptr %10, align 8, !tbaa !5
  %23 = sub i64 %22, %13
  %24 = shl i64 %2, 3
  %25 = add i64 %24, 31
  %26 = icmp ugt i64 %23, %25
  br i1 %26, label %27, label %29

27:                                               ; preds = %21
  %28 = getelementptr inbounds i8, ptr %1, i64 %2
  tail call void @EmitUncompressedMetaBlock(ptr noundef %1, ptr noundef nonnull %28, i64 noundef %13, ptr noundef nonnull %10, ptr noundef %11)
  br label %29

29:                                               ; preds = %27, %21
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %33, label %.sink.split

.sink.split:                                      ; preds = %29, %12
  tail call void @BrotliWriteBits(i64 noundef 1, i64 noundef 1, ptr noundef nonnull %10, ptr noundef %11)
  tail call void @BrotliWriteBits(i64 noundef 1, i64 noundef 1, ptr noundef nonnull %10, ptr noundef %11)
  %30 = load i64, ptr %10, align 8, !tbaa !5
  %31 = add i64 %30, 7
  %32 = and i64 %31, 4294967288
  store i64 %32, ptr %10, align 8, !tbaa !5
  br label %33

33:                                               ; preds = %.sink.split, %29
  ret void
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @Log2FloorNonZero(i64 noundef) local_unnamed_addr #1

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @BrotliWriteBits(i64 noundef, i64 noundef, ptr noalias noundef, ptr noalias noundef) local_unnamed_addr #1

; Function Attrs: noinline nounwind uwtable
declare hidden void @BrotliCompressFragmentFastImpl9(ptr noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: noinline nounwind uwtable
declare hidden void @BrotliCompressFragmentFastImpl11(ptr noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: noinline nounwind uwtable
declare hidden void @BrotliCompressFragmentFastImpl13(ptr noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: noinline nounwind uwtable
declare hidden void @BrotliCompressFragmentFastImpl15(ptr noundef, ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

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 = { alwaysinline 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 #2 = { noinline nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass