; LLVM IR from indygreg/python-zstandard :: zstd (zstd)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.FASTCOVER_accel_t = type { i32, i32 }
%struct.ZDICT_params_t = type { i32, i32, i32 }
%struct.ZDICT_fastCover_params_t = type { i32, i32, i32, i32, i32, double, i32, i32, i32, %struct.ZDICT_params_t }
%struct.FASTCOVER_ctx_t = type { ptr, ptr, ptr, i64, i64, i64, i64, ptr, i32, i32, %struct.FASTCOVER_accel_t }
%struct.ZDICT_cover_params_t = type { i32, i32, i32, i32, double, i32, i32, %struct.ZDICT_params_t }

@stderr = external global ptr, align 8
@g_displayLevel = external hidden global i32, align 4
@.str.39 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.52 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.53 = external hidden unnamed_addr constant [45 x i8], align 1
@FASTCOVER_defaultAccelParameters = external hidden constant [11 x %struct.FASTCOVER_accel_t], align 16

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

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

; 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) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ZSTD_isError(i64 noundef) #2

; Function Attrs: 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 dso_local void @COVER_warnOnSmallCorpus(i64 noundef, i64 noundef, i32 noundef) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #4

declare i32 @fflush(ptr noundef) #5

; Function Attrs: nounwind uwtable
declare dso_local i64 @ZDICT_finalizeDictionary(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef byval(%struct.ZDICT_params_t) align 8) #2

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

; Function Attrs: nounwind uwtable
define dso_local i64 @ZDICT_trainFromBuffer_fastCover(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef byval(%struct.ZDICT_fastCover_params_t) align 8 %5) #2 {
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca %struct.FASTCOVER_ctx_t, align 8
  %15 = alloca %struct.ZDICT_cover_params_t, align 8
  %16 = alloca %struct.FASTCOVER_accel_t, align 4
  %17 = alloca i32, align 4
  %18 = alloca i64, align 8
  %19 = alloca ptr, align 8
  %20 = alloca i64, align 8
  %21 = alloca i32, align 4
  %22 = alloca i64, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i64 %1, ptr %9, align 8, !tbaa !9
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store i32 %4, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %23, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 80, ptr %14) #7
  call void @llvm.lifetime.start.p0(i64 48, ptr %15) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %24 = getelementptr inbounds %struct.ZDICT_fastCover_params_t, ptr %5, i32 0, i32 9
  %25 = getelementptr inbounds %struct.ZDICT_params_t, ptr %24, i32 0, i32 1
  %26 = load i32, ptr %25, align 4, !tbaa !13
  store i32 %26, ptr @g_displayLevel, align 4, !tbaa !11
  %27 = getelementptr inbounds %struct.ZDICT_fastCover_params_t, ptr %5, i32 0, i32 5
  store double 1.000000e+00, ptr %27, align 8, !tbaa !17
  %28 = getelementptr inbounds %struct.ZDICT_fastCover_params_t, ptr %5, i32 0, i32 2
  %29 = load i32, ptr %28, align 8, !tbaa !18
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %6
  br label %35

32:                                               ; preds = %6
  %33 = getelementptr inbounds %struct.ZDICT_fastCover_params_t, ptr %5, i32 0, i32 2
  %34 = load i32, ptr %33, align 8, !tbaa !18
  br label %35

35:                                               ; preds = %32, %31
  %36 = phi i32 [ 20, %31 ], [ %34, %32 ]
  %37 = getelementptr inbounds %struct.ZDICT_fastCover_params_t, ptr %5, i32 0, i32 2
  store i32 %36, ptr %37, align 8, !tbaa !18
  %38 = getelementptr inbounds %struct.ZDICT_fastCover_params_t, ptr %5, i32 0, i32 6
  %39 = load i32, ptr %38, align 8, !tbaa !19
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %41, label %42

41:                                               ; preds = %35
  br label %45

42:                                               ; preds = %35
  %43 = getelementptr inbounds %struct.ZDICT_fastCover_params_t, ptr %5, i32 0, i32 6
  %44 = load i32, ptr %43, align 8, !tbaa !19
  br label %45

45:                                               ; preds = %42, %41
  %46 = phi i32 [ 1, %41 ], [ %44, %42 ]
  %47 = getelementptr inbounds %struct.ZDICT_fastCover_params_t, ptr %5, i32 0, i32 6
  store i32 %46, ptr %47, align 8, !tbaa !19
  call void @llvm.memset.p0.i64(ptr align 8 %15, i8 0, i64 48, i1 false)
  call void @FASTCOVER_convertToCoverParams(ptr noundef byval(%struct.ZDICT_fastCover_params_t) align 8 %5, ptr noundef %15)
  %48 = load i64, ptr %9, align 8, !tbaa !9
  %49 = getelementptr inbounds %struct.ZDICT_fastCover_params_t, ptr %5, i32 0, i32 2
  %50 = load i32, ptr %49, align 8, !tbaa !18
  %51 = getelementptr inbounds %struct.ZDICT_fastCover_params_t, ptr %5, i32 0, i32 6
  %52 = load i32, ptr %51, align 8, !tbaa !19
  %53 = call i32 @FASTCOVER_checkParameters(ptr noundef byval(%struct.ZDICT_cover_params_t) align 8 %15, i64 noundef %48, i32 noundef %50, i32 noundef %52)
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %64, label %55

55:                                               ; preds = %45
  %56 = load i32, ptr @g_displayLevel, align 4, !tbaa !11
  %57 = icmp sge i32 %56, 1
  br i1 %57, label %58, label %63

58:                                               ; preds = %55
  %59 = load ptr, ptr @stderr, align 8, !tbaa !5
  %60 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %59, ptr noundef @.str.52) #7
  %61 = load ptr, ptr @stderr, align 8, !tbaa !5
  %62 = call i32 @fflush(ptr noundef %61)
  br label %63

63:                                               ; preds = %58, %55
  store i64 -42, ptr %7, align 8
  store i32 1, ptr %17, align 4
  br label %183

64:                                               ; preds = %45
  %65 = load i32, ptr %12, align 4, !tbaa !11
  %66 = icmp eq i32 %65, 0
  br i1 %66, label %67, label %76

67:                                               ; preds = %64
  %68 = load i32, ptr @g_displayLevel, align 4, !tbaa !11
  %69 = icmp sge i32 %68, 1
  br i1 %69, label %70, label %75

70:                                               ; preds = %67
  %71 = load ptr, ptr @stderr, align 8, !tbaa !5
  %72 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %71, ptr noundef @.str.53) #7
  %73 = load ptr, ptr @stderr, align 8, !tbaa !5
  %74 = call i32 @fflush(ptr noundef %73)
  br label %75

75:                                               ; preds = %70, %67
  store i64 -72, ptr %7, align 8
  store i32 1, ptr %17, align 4
  br label %183

76:                                               ; preds = %64
  %77 = load i64, ptr %9, align 8, !tbaa !9
  %78 = icmp ult i64 %77, 256
  br i1 %78, label %79, label %88

79:                                               ; preds = %76
  %80 = load i32, ptr @g_displayLevel, align 4, !tbaa !11
  %81 = icmp sge i32 %80, 1
  br i1 %81, label %82, label %87

82:                                               ; preds = %79
  %83 = load ptr, ptr @stderr, align 8, !tbaa !5
  %84 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %83, ptr noundef @.str.39, i32 noundef 256) #7
  %85 = load ptr, ptr @stderr, align 8, !tbaa !5
  %86 = call i32 @fflush(ptr noundef %85)
  br label %87

87:                                               ; preds = %82, %79
  store i64 -70, ptr %7, align 8
  store i32 1, ptr %17, align 4
  br label %183

88:                                               ; preds = %76
  %89 = getelementptr inbounds %struct.ZDICT_fastCover_params_t, ptr %5, i32 0, i32 6
  %90 = load i32, ptr %89, align 8, !tbaa !19
  %91 = zext i32 %90 to i64
  %92 = getelementptr inbounds [11 x %struct.FASTCOVER_accel_t], ptr @FASTCOVER_defaultAccelParameters, i64 0, i64 %91
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 8 %92, i64 8, i1 false), !tbaa.struct !20
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %93 = load ptr, ptr %10, align 8, !tbaa !5
  %94 = load ptr, ptr %11, align 8, !tbaa !5
  %95 = load i32, ptr %12, align 4, !tbaa !11
  %96 = getelementptr inbounds %struct.ZDICT_cover_params_t, ptr %15, i32 0, i32 1
  %97 = load i32, ptr %96, align 4, !tbaa !21
  %98 = getelementptr inbounds %struct.ZDICT_fastCover_params_t, ptr %5, i32 0, i32 5
  %99 = load double, ptr %98, align 8, !tbaa !17
  %100 = getelementptr inbounds %struct.ZDICT_fastCover_params_t, ptr %5, i32 0, i32 2
  %101 = load i32, ptr %100, align 8, !tbaa !18
  %102 = load i64, ptr %16, align 4
  %103 = call i64 @FASTCOVER_ctx_init(ptr noundef %14, ptr noundef %93, ptr noundef %94, i32 noundef %95, i32 noundef %97, double noundef %99, i32 noundef %101, i64 %102)
  store i64 %103, ptr %18, align 8, !tbaa !9
  %104 = load i64, ptr %18, align 8, !tbaa !9
  %105 = call i32 @ZSTD_isError(i64 noundef %104)
  %106 = icmp ne i32 %105, 0
  br i1 %106, label %107, label %117

107:                                              ; preds = %88
  %108 = load i32, ptr @g_displayLevel, align 4, !tbaa !11
  %109 = icmp sge i32 %108, 1
  br i1 %109, label %110, label %115

110:                                              ; preds = %107
  %111 = load ptr, ptr @stderr, align 8, !tbaa !5
  %112 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %111, ptr noundef @.str.46) #7
  %113 = load ptr, ptr @stderr, align 8, !tbaa !5
  %114 = call i32 @fflush(ptr noundef %113)
  br label %115

115:                                              ; preds = %110, %107
  %116 = load i64, ptr %18, align 8, !tbaa !9
  store i64 %116, ptr %7, align 8
  store i32 1, ptr %17, align 4
  br label %118

117:                                              ; preds = %88
  store i32 0, ptr %17, align 4
  br label %118

118:                                              ; preds = %117, %115
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  %119 = load i32, ptr %17, align 4
  switch i32 %119, label %183 [
    i32 0, label %120
  ]

120:                                              ; preds = %118
  %121 = load i64, ptr %9, align 8, !tbaa !9
  %122 = getelementptr inbounds %struct.FASTCOVER_ctx_t, ptr %14, i32 0, i32 6
  %123 = load i64, ptr %122, align 8, !tbaa !23
  %124 = load i32, ptr @g_displayLevel, align 4, !tbaa !11
  call void @COVER_warnOnSmallCorpus(i64 noundef %121, i64 noundef %123, i32 noundef %124)
  %125 = load i32, ptr @g_displayLevel, align 4, !tbaa !11
  %126 = icmp sge i32 %125, 2
  br i1 %126, label %127, label %132

127:                                              ; preds = %120
  %128 = load ptr, ptr @stderr, align 8, !tbaa !5
  %129 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %128, ptr noundef @.str.41) #7
  %130 = load ptr, ptr @stderr, align 8, !tbaa !5
  %131 = call i32 @fflush(ptr noundef %130)
  br label %132

132:                                              ; preds = %127, %120
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %133 = getelementptr inbounds %struct.ZDICT_fastCover_params_t, ptr %5, i32 0, i32 2
  %134 = load i32, ptr %133, align 8, !tbaa !18
  %135 = zext i32 %134 to i64
  %136 = shl i64 1, %135
  %137 = call noalias ptr @calloc(i64 noundef %136, i64 noundef 2) #8
  store ptr %137, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  %138 = getelementptr inbounds %struct.FASTCOVER_ctx_t, ptr %14, i32 0, i32 7
  %139 = load ptr, ptr %138, align 8, !tbaa !26
  %140 = load ptr, ptr %8, align 8, !tbaa !5
  %141 = load i64, ptr %9, align 8, !tbaa !9
  %142 = load ptr, ptr %19, align 8, !tbaa !5
  %143 = call i64 @FASTCOVER_buildDictionary(ptr noundef %14, ptr noundef %139, ptr noundef %140, i64 noundef %141, ptr noundef byval(%struct.ZDICT_cover_params_t) align 8 %15, ptr noundef %142)
  store i64 %143, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #7
  %144 = getelementptr inbounds %struct.FASTCOVER_ctx_t, ptr %14, i32 0, i32 4
  %145 = load i64, ptr %144, align 8, !tbaa !27
  %146 = getelementptr inbounds %struct.FASTCOVER_ctx_t, ptr %14, i32 0, i32 10
  %147 = getelementptr inbounds %struct.FASTCOVER_accel_t, ptr %146, i32 0, i32 0
  %148 = load i32, ptr %147, align 8, !tbaa !28
  %149 = zext i32 %148 to i64
  %150 = mul i64 %145, %149
  %151 = udiv i64 %150, 100
  %152 = trunc i64 %151 to i32
  store i32 %152, ptr %21, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #7
  %153 = load ptr, ptr %13, align 8, !tbaa !5
  %154 = load i64, ptr %9, align 8, !tbaa !9
  %155 = load ptr, ptr %13, align 8, !tbaa !5
  %156 = load i64, ptr %20, align 8, !tbaa !9
  %157 = getelementptr inbounds i8, ptr %155, i64 %156
  %158 = load i64, ptr %9, align 8, !tbaa !9
  %159 = load i64, ptr %20, align 8, !tbaa !9
  %160 = sub i64 %158, %159
  %161 = load ptr, ptr %10, align 8, !tbaa !5
  %162 = load ptr, ptr %11, align 8, !tbaa !5
  %163 = load i32, ptr %21, align 4, !tbaa !11
  %164 = getelementptr inbounds %struct.ZDICT_cover_params_t, ptr %15, i32 0, i32 7
  %165 = call i64 @ZDICT_finalizeDictionary(ptr noundef %153, i64 noundef %154, ptr noundef %157, i64 noundef %160, ptr noundef %161, ptr noundef %162, i32 noundef %163, ptr noundef byval(%struct.ZDICT_params_t) align 8 %164)
  store i64 %165, ptr %22, align 8, !tbaa !9
  %166 = load i64, ptr %22, align 8, !tbaa !9
  %167 = call i32 @ZSTD_isError(i64 noundef %166)
  %168 = icmp ne i32 %167, 0
  br i1 %168, label %180, label %169

169:                                              ; preds = %132
  %170 = load i32, ptr @g_displayLevel, align 4, !tbaa !11
  %171 = icmp sge i32 %170, 2
  br i1 %171, label %172, label %179

172:                                              ; preds = %169
  %173 = load ptr, ptr @stderr, align 8, !tbaa !5
  %174 = load i64, ptr %22, align 8, !tbaa !9
  %175 = trunc i64 %174 to i32
  %176 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %173, ptr noundef @.str.42, i32 noundef %175) #7
  %177 = load ptr, ptr @stderr, align 8, !tbaa !5
  %178 = call i32 @fflush(ptr noundef %177)
  br label %179

179:                                              ; preds = %172, %169
  br label %180

180:                                              ; preds = %179, %132
  call void @FASTCOVER_ctx_destroy(ptr noundef %14)
  %181 = load ptr, ptr %19, align 8, !tbaa !5
  call void @free(ptr noundef %181) #7
  %182 = load i64, ptr %22, align 8, !tbaa !9
  store i64 %182, ptr %7, align 8
  store i32 1, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  br label %183

183:                                              ; preds = %180, %118, %87, %75, %63
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 48, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  %184 = load i64, ptr %7, align 8
  ret i64 %184
}

; Function Attrs: nounwind uwtable
declare hidden void @FASTCOVER_convertToCoverParams(ptr noundef byval(%struct.ZDICT_fastCover_params_t) align 8, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i32 @FASTCOVER_checkParameters(ptr noundef byval(%struct.ZDICT_cover_params_t) align 8, i64 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden i64 @FASTCOVER_ctx_init(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, double noundef, i32 noundef, i64) #2

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

; Function Attrs: nounwind uwtable
declare hidden i64 @FASTCOVER_buildDictionary(ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef byval(%struct.ZDICT_cover_params_t) align 8, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @FASTCOVER_ctx_destroy(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #5 = { "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(0,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 }
attributes #8 = { nounwind allocsize(0,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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 48}
!14 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !15, i64 24, !12, i64 32, !12, i64 36, !12, i64 40, !16, i64 44}
!15 = !{!"double", !7, i64 0}
!16 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8}
!17 = !{!14, !15, i64 24}
!18 = !{!14, !12, i64 8}
!19 = !{!14, !12, i64 32}
!20 = !{i64 0, i64 4, !11, i64 4, i64 4, !11}
!21 = !{!22, !12, i64 4}
!22 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !15, i64 16, !12, i64 24, !12, i64 28, !16, i64 32}
!23 = !{!24, !10, i64 48}
!24 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !6, i64 56, !12, i64 64, !12, i64 68, !25, i64 72}
!25 = !{!"", !12, i64 0, !12, i64 4}
!26 = !{!24, !6, i64 56}
!27 = !{!24, !10, i64 32}
!28 = !{!24, !12, i64 72}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.FASTCOVER_accel_t = type { i32, i32 }
%struct.ZDICT_params_t = type { i32, i32, i32 }
%struct.ZDICT_fastCover_params_t = type { i32, i32, i32, i32, i32, double, i32, i32, i32, %struct.ZDICT_params_t }
%struct.FASTCOVER_ctx_t = type { ptr, ptr, ptr, i64, i64, i64, i64, ptr, i32, i32, %struct.FASTCOVER_accel_t }
%struct.ZDICT_cover_params_t = type { i32, i32, i32, i32, double, i32, i32, %struct.ZDICT_params_t }

@stderr = external local_unnamed_addr global ptr, align 8
@g_displayLevel = external hidden local_unnamed_addr global i32, align 4
@.str.39 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.41 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.42 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.52 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.53 = external hidden unnamed_addr constant [45 x i8], align 1
@FASTCOVER_defaultAccelParameters = external hidden local_unnamed_addr constant [11 x %struct.FASTCOVER_accel_t], align 16

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @ZSTD_isError(i64 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @COVER_warnOnSmallCorpus(i64 noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local i64 @ZDICT_finalizeDictionary(ptr noundef, i64 noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef byval(%struct.ZDICT_params_t) align 8) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local noundef i64 @ZDICT_trainFromBuffer_fastCover(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef byval(%struct.ZDICT_fastCover_params_t) align 8 %5) local_unnamed_addr #1 {
  %7 = alloca %struct.FASTCOVER_ctx_t, align 8
  %8 = alloca %struct.ZDICT_cover_params_t, align 8
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %7) #7
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %8) #7
  %9 = getelementptr inbounds i8, ptr %5, i64 48
  %10 = load i32, ptr %9, align 8, !tbaa !5
  store i32 %10, ptr @g_displayLevel, align 4, !tbaa !12
  %11 = getelementptr inbounds i8, ptr %5, i64 24
  store double 1.000000e+00, ptr %11, align 8, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %5, i64 8
  %13 = load i32, ptr %12, align 8
  %14 = icmp eq i32 %13, 0
  %15 = select i1 %14, i32 20, i32 %13
  store i32 %15, ptr %12, align 8, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %5, i64 32
  %17 = load i32, ptr %16, align 8
  %18 = tail call i32 @llvm.umax.i32(i32 %17, i32 1)
  store i32 %18, ptr %16, align 8, !tbaa !15
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %8, i8 0, i64 48, i1 false)
  call void @FASTCOVER_convertToCoverParams(ptr noundef nonnull byval(%struct.ZDICT_fastCover_params_t) align 8 %5, ptr noundef nonnull %8)
  %19 = load i32, ptr %12, align 8, !tbaa !14
  %20 = load i32, ptr %16, align 8, !tbaa !15
  %21 = call i32 @FASTCOVER_checkParameters(ptr noundef nonnull byval(%struct.ZDICT_cover_params_t) align 8 %8, i64 noundef %1, i32 noundef %19, i32 noundef %20)
  %.not = icmp eq i32 %21, 0
  br i1 %.not, label %22, label %30

22:                                               ; preds = %6
  %23 = load i32, ptr @g_displayLevel, align 4, !tbaa !12
  %24 = icmp sgt i32 %23, 0
  br i1 %24, label %25, label %109

25:                                               ; preds = %22
  %26 = load ptr, ptr @stderr, align 8, !tbaa !16
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef nonnull @.str.52) #8
  %28 = load ptr, ptr @stderr, align 8, !tbaa !16
  %29 = call i32 @fflush(ptr noundef %28)
  br label %109

30:                                               ; preds = %6
  %31 = icmp eq i32 %4, 0
  br i1 %31, label %32, label %40

32:                                               ; preds = %30
  %33 = load i32, ptr @g_displayLevel, align 4, !tbaa !12
  %34 = icmp sgt i32 %33, 0
  br i1 %34, label %35, label %109

35:                                               ; preds = %32
  %36 = load ptr, ptr @stderr, align 8, !tbaa !16
  %37 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %36, ptr noundef nonnull @.str.53) #8
  %38 = load ptr, ptr @stderr, align 8, !tbaa !16
  %39 = call i32 @fflush(ptr noundef %38)
  br label %109

40:                                               ; preds = %30
  %41 = icmp ult i64 %1, 256
  br i1 %41, label %42, label %50

42:                                               ; preds = %40
  %43 = load i32, ptr @g_displayLevel, align 4, !tbaa !12
  %44 = icmp sgt i32 %43, 0
  br i1 %44, label %45, label %109

45:                                               ; preds = %42
  %46 = load ptr, ptr @stderr, align 8, !tbaa !16
  %47 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef nonnull @.str.39, i32 noundef 256) #8
  %48 = load ptr, ptr @stderr, align 8, !tbaa !16
  %49 = call i32 @fflush(ptr noundef %48)
  br label %109

50:                                               ; preds = %40
  %51 = load i32, ptr %16, align 8, !tbaa !15
  %52 = zext i32 %51 to i64
  %53 = getelementptr inbounds [11 x %struct.FASTCOVER_accel_t], ptr @FASTCOVER_defaultAccelParameters, i64 0, i64 %52
  %.sroa.0.0.copyload = load i64, ptr %53, align 8
  %54 = getelementptr inbounds i8, ptr %8, i64 4
  %55 = load i32, ptr %54, align 4, !tbaa !18
  %56 = load double, ptr %11, align 8, !tbaa !13
  %57 = load i32, ptr %12, align 8, !tbaa !14
  %58 = call i64 @FASTCOVER_ctx_init(ptr noundef nonnull %7, ptr noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %55, double noundef %56, i32 noundef %57, i64 %.sroa.0.0.copyload)
  %59 = call i32 @ZSTD_isError(i64 noundef %58)
  %.not30 = icmp eq i32 %59, 0
  br i1 %.not30, label %.critedge, label %60

60:                                               ; preds = %50
  %61 = load i32, ptr @g_displayLevel, align 4, !tbaa !12
  %62 = icmp sgt i32 %61, 0
  br i1 %62, label %63, label %109

63:                                               ; preds = %60
  %64 = load ptr, ptr @stderr, align 8, !tbaa !16
  %65 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %64, ptr noundef nonnull @.str.46) #8
  %66 = load ptr, ptr @stderr, align 8, !tbaa !16
  %67 = call i32 @fflush(ptr noundef %66)
  br label %109

.critedge:                                        ; preds = %50
  %68 = getelementptr inbounds i8, ptr %7, i64 48
  %69 = load i64, ptr %68, align 8, !tbaa !20
  %70 = load i32, ptr @g_displayLevel, align 4, !tbaa !12
  call void @COVER_warnOnSmallCorpus(i64 noundef %1, i64 noundef %69, i32 noundef %70)
  %71 = load i32, ptr @g_displayLevel, align 4, !tbaa !12
  %72 = icmp sgt i32 %71, 1
  br i1 %72, label %73, label %78

73:                                               ; preds = %.critedge
  %74 = load ptr, ptr @stderr, align 8, !tbaa !16
  %75 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %74, ptr noundef nonnull @.str.41) #8
  %76 = load ptr, ptr @stderr, align 8, !tbaa !16
  %77 = call i32 @fflush(ptr noundef %76)
  br label %78

78:                                               ; preds = %73, %.critedge
  %79 = load i32, ptr %12, align 8, !tbaa !14
  %80 = zext nneg i32 %79 to i64
  %81 = shl nuw i64 1, %80
  %82 = call noalias ptr @calloc(i64 noundef %81, i64 noundef 2) #9
  %83 = getelementptr inbounds i8, ptr %7, i64 56
  %84 = load ptr, ptr %83, align 8, !tbaa !24
  %85 = call i64 @FASTCOVER_buildDictionary(ptr noundef nonnull %7, ptr noundef %84, ptr noundef %0, i64 noundef %1, ptr noundef nonnull byval(%struct.ZDICT_cover_params_t) align 8 %8, ptr noundef %82)
  %86 = getelementptr inbounds i8, ptr %7, i64 32
  %87 = load i64, ptr %86, align 8, !tbaa !25
  %88 = getelementptr inbounds i8, ptr %7, i64 72
  %89 = load i32, ptr %88, align 8, !tbaa !26
  %90 = zext i32 %89 to i64
  %91 = mul i64 %87, %90
  %92 = udiv i64 %91, 100
  %93 = trunc i64 %92 to i32
  %94 = getelementptr inbounds i8, ptr %0, i64 %85
  %95 = sub i64 %1, %85
  %96 = getelementptr inbounds i8, ptr %8, i64 32
  %97 = call i64 @ZDICT_finalizeDictionary(ptr noundef %0, i64 noundef %1, ptr noundef %94, i64 noundef %95, ptr noundef %2, ptr noundef %3, i32 noundef %93, ptr noundef nonnull byval(%struct.ZDICT_params_t) align 8 %96)
  %98 = call i32 @ZSTD_isError(i64 noundef %97)
  %99 = icmp eq i32 %98, 0
  %100 = load i32, ptr @g_displayLevel, align 4
  %101 = icmp sgt i32 %100, 1
  %or.cond = select i1 %99, i1 %101, i1 false
  br i1 %or.cond, label %102, label %108

102:                                              ; preds = %78
  %103 = load ptr, ptr @stderr, align 8, !tbaa !16
  %104 = trunc i64 %97 to i32
  %105 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %103, ptr noundef nonnull @.str.42, i32 noundef %104) #8
  %106 = load ptr, ptr @stderr, align 8, !tbaa !16
  %107 = call i32 @fflush(ptr noundef %106)
  br label %108

108:                                              ; preds = %102, %78
  call void @FASTCOVER_ctx_destroy(ptr noundef nonnull %7)
  call void @free(ptr noundef %82) #7
  br label %109

109:                                              ; preds = %63, %60, %42, %45, %32, %35, %22, %25, %108
  %.1 = phi i64 [ %97, %108 ], [ -42, %25 ], [ -42, %22 ], [ -72, %35 ], [ -72, %32 ], [ -70, %45 ], [ -70, %42 ], [ %58, %60 ], [ %58, %63 ]
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %7) #7
  ret i64 %.1
}

; Function Attrs: nounwind uwtable
declare hidden void @FASTCOVER_convertToCoverParams(ptr noundef byval(%struct.ZDICT_fastCover_params_t) align 8, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i32 @FASTCOVER_checkParameters(ptr noundef byval(%struct.ZDICT_cover_params_t) align 8, i64 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i64 @FASTCOVER_ctx_init(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, double noundef, i32 noundef, i64) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #5

; Function Attrs: nounwind uwtable
declare hidden i64 @FASTCOVER_buildDictionary(ptr noundef, ptr noundef, ptr noundef, i64 noundef, ptr noundef byval(%struct.ZDICT_cover_params_t) align 8, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @FASTCOVER_ctx_destroy(ptr noundef) local_unnamed_addr #1

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 #5 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) 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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind }
attributes #8 = { cold nounwind }
attributes #9 = { nounwind allocsize(0,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, !7, i64 48}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !10, i64 24, !7, i64 32, !7, i64 36, !7, i64 40, !11, i64 44}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8}
!12 = !{!7, !7, i64 0}
!13 = !{!6, !10, i64 24}
!14 = !{!6, !7, i64 8}
!15 = !{!6, !7, i64 32}
!16 = !{!17, !17, i64 0}
!17 = !{!"any pointer", !8, i64 0}
!18 = !{!19, !7, i64 4}
!19 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !7, i64 24, !7, i64 28, !11, i64 32}
!20 = !{!21, !22, i64 48}
!21 = !{!"", !17, i64 0, !17, i64 8, !17, i64 16, !22, i64 24, !22, i64 32, !22, i64 40, !22, i64 48, !17, i64 56, !7, i64 64, !7, i64 68, !23, i64 72}
!22 = !{!"long", !8, i64 0}
!23 = !{!"", !7, i64 0, !7, i64 4}
!24 = !{!21, !17, i64 56}
!25 = !{!21, !22, i64 32}
!26 = !{!21, !7, i64 72}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass