; LLVM IR from DanEngelbrecht/longtail :: lib/brotli/ext/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) #0 {
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store i64 %2, ptr %11, align 8, !tbaa !9
  store i32 %3, ptr %12, align 4, !tbaa !11
  store ptr %4, ptr %13, align 8, !tbaa !5
  store i64 %5, ptr %14, align 8, !tbaa !9
  store ptr %6, ptr %15, align 8, !tbaa !5
  store ptr %7, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %20 = load ptr, ptr %15, align 8, !tbaa !5
  %21 = load i64, ptr %20, align 8, !tbaa !9
  store i64 %21, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %22 = load i64, ptr %14, align 8, !tbaa !9
  %23 = call i32 @Log2FloorNonZero(i64 noundef %22)
  %24 = zext i32 %23 to i64
  store i64 %24, ptr %18, align 8, !tbaa !9
  %25 = load i64, ptr %11, align 8, !tbaa !9
  %26 = icmp eq i64 %25, 0
  br i1 %26, label %27, label %37

27:                                               ; preds = %8
  %28 = load ptr, ptr %15, align 8, !tbaa !5
  %29 = load ptr, ptr %16, align 8, !tbaa !5
  call void @BrotliWriteBits(i64 noundef 1, i64 noundef 1, ptr noundef %28, ptr noundef %29)
  %30 = load ptr, ptr %15, align 8, !tbaa !5
  %31 = load ptr, ptr %16, align 8, !tbaa !5
  call void @BrotliWriteBits(i64 noundef 1, i64 noundef 1, ptr noundef %30, ptr noundef %31)
  %32 = load ptr, ptr %15, align 8, !tbaa !5
  %33 = load i64, ptr %32, align 8, !tbaa !9
  %34 = add i64 %33, 7
  %35 = and i64 %34, 4294967288
  %36 = load ptr, ptr %15, align 8, !tbaa !5
  store i64 %35, ptr %36, align 8, !tbaa !9
  store i32 1, ptr %19, align 4
  br label %103

37:                                               ; preds = %8
  %38 = load i64, ptr %18, align 8, !tbaa !9
  switch i64 %38, label %71 [
    i64 9, label %39
    i64 11, label %47
    i64 13, label %55
    i64 15, label %63
  ]

39:                                               ; preds = %37
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = load i64, ptr %11, align 8, !tbaa !9
  %43 = load i32, ptr %12, align 4, !tbaa !11
  %44 = load ptr, ptr %13, align 8, !tbaa !5
  %45 = load ptr, ptr %15, align 8, !tbaa !5
  %46 = load ptr, ptr %16, align 8, !tbaa !5
  call void @BrotliCompressFragmentFastImpl9(ptr noundef %40, ptr noundef %41, i64 noundef %42, i32 noundef %43, ptr noundef %44, ptr noundef %45, ptr noundef %46)
  br label %72

47:                                               ; preds = %37
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = load i64, ptr %11, align 8, !tbaa !9
  %51 = load i32, ptr %12, align 4, !tbaa !11
  %52 = load ptr, ptr %13, align 8, !tbaa !5
  %53 = load ptr, ptr %15, align 8, !tbaa !5
  %54 = load ptr, ptr %16, align 8, !tbaa !5
  call void @BrotliCompressFragmentFastImpl11(ptr noundef %48, ptr noundef %49, i64 noundef %50, i32 noundef %51, ptr noundef %52, ptr noundef %53, ptr noundef %54)
  br label %72

55:                                               ; preds = %37
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = load ptr, ptr %10, align 8, !tbaa !5
  %58 = load i64, ptr %11, align 8, !tbaa !9
  %59 = load i32, ptr %12, align 4, !tbaa !11
  %60 = load ptr, ptr %13, align 8, !tbaa !5
  %61 = load ptr, ptr %15, align 8, !tbaa !5
  %62 = load ptr, ptr %16, align 8, !tbaa !5
  call void @BrotliCompressFragmentFastImpl13(ptr noundef %56, ptr noundef %57, i64 noundef %58, i32 noundef %59, ptr noundef %60, ptr noundef %61, ptr noundef %62)
  br label %72

63:                                               ; preds = %37
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  %66 = load i64, ptr %11, align 8, !tbaa !9
  %67 = load i32, ptr %12, align 4, !tbaa !11
  %68 = load ptr, ptr %13, align 8, !tbaa !5
  %69 = load ptr, ptr %15, align 8, !tbaa !5
  %70 = load ptr, ptr %16, align 8, !tbaa !5
  call void @BrotliCompressFragmentFastImpl15(ptr noundef %64, ptr noundef %65, i64 noundef %66, i32 noundef %67, ptr noundef %68, ptr noundef %69, ptr noundef %70)
  br label %72

71:                                               ; preds = %37
  br label %72

72:                                               ; preds = %71, %63, %55, %47, %39
  %73 = load ptr, ptr %15, align 8, !tbaa !5
  %74 = load i64, ptr %73, align 8, !tbaa !9
  %75 = load i64, ptr %17, align 8, !tbaa !9
  %76 = sub i64 %74, %75
  %77 = load i64, ptr %11, align 8, !tbaa !9
  %78 = shl i64 %77, 3
  %79 = add i64 31, %78
  %80 = icmp ugt i64 %76, %79
  br i1 %80, label %81, label %89

81:                                               ; preds = %72
  %82 = load ptr, ptr %10, align 8, !tbaa !5
  %83 = load ptr, ptr %10, align 8, !tbaa !5
  %84 = load i64, ptr %11, align 8, !tbaa !9
  %85 = getelementptr inbounds i8, ptr %83, i64 %84
  %86 = load i64, ptr %17, align 8, !tbaa !9
  %87 = load ptr, ptr %15, align 8, !tbaa !5
  %88 = load ptr, ptr %16, align 8, !tbaa !5
  call void @EmitUncompressedMetaBlock(ptr noundef %82, ptr noundef %85, i64 noundef %86, ptr noundef %87, ptr noundef %88)
  br label %89

89:                                               ; preds = %81, %72
  %90 = load i32, ptr %12, align 4, !tbaa !11
  %91 = icmp ne i32 %90, 0
  br i1 %91, label %92, label %102

92:                                               ; preds = %89
  %93 = load ptr, ptr %15, align 8, !tbaa !5
  %94 = load ptr, ptr %16, align 8, !tbaa !5
  call void @BrotliWriteBits(i64 noundef 1, i64 noundef 1, ptr noundef %93, ptr noundef %94)
  %95 = load ptr, ptr %15, align 8, !tbaa !5
  %96 = load ptr, ptr %16, align 8, !tbaa !5
  call void @BrotliWriteBits(i64 noundef 1, i64 noundef 1, ptr noundef %95, ptr noundef %96)
  %97 = load ptr, ptr %15, align 8, !tbaa !5
  %98 = load i64, ptr %97, align 8, !tbaa !9
  %99 = add i64 %98, 7
  %100 = and i64 %99, 4294967288
  %101 = load ptr, ptr %15, align 8, !tbaa !5
  store i64 %100, ptr %101, align 8, !tbaa !9
  br label %102

102:                                              ; preds = %92, %89
  store i32 0, ptr %19, align 4
  br label %103

103:                                              ; preds = %102, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  %104 = load i32, ptr %19, align 4
  switch i32 %104, label %106 [
    i32 0, label %105
    i32 1, label %105
  ]

105:                                              ; preds = %103, %103
  ret void

106:                                              ; preds = %103
  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) #3

; Function Attrs: noinline nounwind uwtable
declare hidden void @BrotliCompressFragmentFastImpl11(ptr noundef, ptr noundef, i64 noundef, i32 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) #3

; Function Attrs: noinline nounwind uwtable
declare hidden void @BrotliCompressFragmentFastImpl15(ptr noundef, ptr noundef, i64 noundef, i32 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) local_unnamed_addr #0 {
  %9 = load i64, ptr %6, align 8, !tbaa !5
  %10 = tail call i32 @Log2FloorNonZero(i64 noundef %5)
  %11 = icmp eq i64 %2, 0
  br i1 %11, label %.sink.split, label %12

12:                                               ; preds = %8
  switch i32 %10, label %17 [
    i32 9, label %13
    i32 11, label %14
    i32 13, label %15
    i32 15, label %16
  ]

13:                                               ; preds = %12
  tail call void @BrotliCompressFragmentFastImpl9(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef nonnull %6, ptr noundef %7)
  br label %17

14:                                               ; preds = %12
  tail call void @BrotliCompressFragmentFastImpl11(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef nonnull %6, ptr noundef %7)
  br label %17

15:                                               ; preds = %12
  tail call void @BrotliCompressFragmentFastImpl13(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef nonnull %6, ptr noundef %7)
  br label %17

16:                                               ; preds = %12
  tail call void @BrotliCompressFragmentFastImpl15(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3, ptr noundef %4, ptr noundef nonnull %6, ptr noundef %7)
  br label %17

17:                                               ; preds = %12, %16, %15, %14, %13
  %18 = load i64, ptr %6, align 8, !tbaa !5
  %19 = sub i64 %18, %9
  %20 = shl i64 %2, 3
  %21 = add i64 %20, 31
  %22 = icmp ugt i64 %19, %21
  br i1 %22, label %23, label %25

23:                                               ; preds = %17
  %24 = getelementptr inbounds i8, ptr %1, i64 %2
  tail call void @EmitUncompressedMetaBlock(ptr noundef %1, ptr noundef nonnull %24, i64 noundef %9, ptr noundef nonnull %6, ptr noundef %7)
  br label %25

25:                                               ; preds = %23, %17
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %29, label %.sink.split

.sink.split:                                      ; preds = %25, %8
  tail call void @BrotliWriteBits(i64 noundef 1, i64 noundef 1, ptr noundef nonnull %6, ptr noundef %7)
  tail call void @BrotliWriteBits(i64 noundef 1, i64 noundef 1, ptr noundef nonnull %6, ptr noundef %7)
  %26 = load i64, ptr %6, align 8, !tbaa !5
  %27 = add i64 %26, 7
  %28 = and i64 %27, 4294967288
  store i64 %28, ptr %6, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %.sink.split, %25
  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) 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) 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) 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) 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