; LLVM IR from tsotchke/quantum_rng :: tests/statistical (statistical_tests)

; 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.statistical_results = type { double, double, double, double, [4 x double], double, double }

; Function Attrs: nounwind uwtable
define dso_local void @run_statistical_suite(ptr dead_on_unwind noalias writable sret(%struct.statistical_results) align 8 %0, ptr noundef %1, i64 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca double, align 8
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  %17 = alloca i64, align 8
  %18 = alloca i32, align 4
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  %21 = alloca i64, align 8
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  %24 = alloca i32, align 4
  %25 = alloca i64, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  store i64 %2, ptr %5, align 8, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 8 %0, i8 0, i64 80, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %26 = load i64, ptr %5, align 8, !tbaa !9
  %27 = mul i64 %26, 8
  %28 = call noalias ptr @malloc(i64 noundef %27) #8
  store ptr %28, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %29

29:                                               ; preds = %40, %3
  %30 = load i64, ptr %7, align 8, !tbaa !9
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = icmp ult i64 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %43

34:                                               ; preds = %29
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = call i64 @qrng_uint64(ptr noundef %35)
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = load i64, ptr %7, align 8, !tbaa !9
  %39 = getelementptr inbounds i64, ptr %37, i64 %38
  store i64 %36, ptr %39, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %34
  %41 = load i64, ptr %7, align 8, !tbaa !9
  %42 = add i64 %41, 1
  store i64 %42, ptr %7, align 8, !tbaa !9
  br label %29, !llvm.loop !11

43:                                               ; preds = %33
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = load i64, ptr %5, align 8, !tbaa !9
  %46 = call double @calculate_entropy(ptr noundef %44, i64 noundef %45)
  %47 = getelementptr inbounds %struct.statistical_results, ptr %0, i32 0, i32 0
  store double %46, ptr %47, align 8, !tbaa !13
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = load i64, ptr %5, align 8, !tbaa !9
  %50 = call double @chi_square_test(ptr noundef %48, i64 noundef %49)
  %51 = getelementptr inbounds %struct.statistical_results, ptr %0, i32 0, i32 1
  store double %50, ptr %51, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 0, ptr %8, align 4, !tbaa !17
  br label %52

52:                                               ; preds = %64, %43
  %53 = load i32, ptr %8, align 4, !tbaa !17
  %54 = icmp slt i32 %53, 4
  br i1 %54, label %56, label %55

55:                                               ; preds = %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %67

56:                                               ; preds = %52
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load i64, ptr %5, align 8, !tbaa !9
  %59 = call double @pattern_analysis(ptr noundef %57, i64 noundef %58)
  %60 = getelementptr inbounds %struct.statistical_results, ptr %0, i32 0, i32 4
  %61 = load i32, ptr %8, align 4, !tbaa !17
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [4 x double], ptr %60, i64 0, i64 %62
  store double %59, ptr %63, align 8, !tbaa !19
  br label %64

64:                                               ; preds = %56
  %65 = load i32, ptr %8, align 4, !tbaa !17
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %8, align 4, !tbaa !17
  br label %52, !llvm.loop !20

67:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  store i64 0, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #7
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %68

68:                                               ; preds = %83, %67
  %69 = load i64, ptr %10, align 8, !tbaa !9
  %70 = load i64, ptr %5, align 8, !tbaa !9
  %71 = icmp ult i64 %69, %70
  br i1 %71, label %73, label %72

72:                                               ; preds = %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #7
  br label %86

73:                                               ; preds = %68
  %74 = load ptr, ptr %6, align 8, !tbaa !5
  %75 = load i64, ptr %10, align 8, !tbaa !9
  %76 = getelementptr inbounds i64, ptr %74, i64 %75
  %77 = load i64, ptr %76, align 8, !tbaa !9
  %78 = call i64 @llvm.ctpop.i64(i64 %77)
  %79 = trunc i64 %78 to i32
  %80 = sext i32 %79 to i64
  %81 = load i64, ptr %9, align 8, !tbaa !9
  %82 = add i64 %81, %80
  store i64 %82, ptr %9, align 8, !tbaa !9
  br label %83

83:                                               ; preds = %73
  %84 = load i64, ptr %10, align 8, !tbaa !9
  %85 = add i64 %84, 1
  store i64 %85, ptr %10, align 8, !tbaa !9
  br label %68, !llvm.loop !21

86:                                               ; preds = %72
  %87 = load i64, ptr %9, align 8, !tbaa !9
  %88 = uitofp i64 %87 to double
  %89 = load i64, ptr %5, align 8, !tbaa !9
  %90 = mul i64 %89, 64
  %91 = uitofp i64 %90 to double
  %92 = fdiv double %88, %91
  %93 = getelementptr inbounds %struct.statistical_results, ptr %0, i32 0, i32 2
  store double %92, ptr %93, align 8, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  store double 0.000000e+00, ptr %11, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #7
  store i64 1, ptr %12, align 8, !tbaa !9
  br label %94

94:                                               ; preds = %116, %86
  %95 = load i64, ptr %12, align 8, !tbaa !9
  %96 = load i64, ptr %5, align 8, !tbaa !9
  %97 = icmp ult i64 %95, %96
  br i1 %97, label %99, label %98

98:                                               ; preds = %94
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #7
  br label %119

99:                                               ; preds = %94
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  %101 = load i64, ptr %12, align 8, !tbaa !9
  %102 = getelementptr inbounds i64, ptr %100, i64 %101
  %103 = load i64, ptr %102, align 8, !tbaa !9
  %104 = load ptr, ptr %6, align 8, !tbaa !5
  %105 = load i64, ptr %12, align 8, !tbaa !9
  %106 = sub i64 %105, 1
  %107 = getelementptr inbounds i64, ptr %104, i64 %106
  %108 = load i64, ptr %107, align 8, !tbaa !9
  %109 = and i64 %103, %108
  %110 = uitofp i64 %109 to double
  %111 = load i64, ptr %5, align 8, !tbaa !9
  %112 = uitofp i64 %111 to double
  %113 = fdiv double %110, %112
  %114 = load double, ptr %11, align 8, !tbaa !19
  %115 = fadd double %114, %113
  store double %115, ptr %11, align 8, !tbaa !19
  br label %116

116:                                              ; preds = %99
  %117 = load i64, ptr %12, align 8, !tbaa !9
  %118 = add i64 %117, 1
  store i64 %118, ptr %12, align 8, !tbaa !9
  br label %94, !llvm.loop !23

119:                                              ; preds = %98
  %120 = load double, ptr %11, align 8, !tbaa !19
  %121 = fdiv double %120, 0x43F0000000000000
  %122 = getelementptr inbounds %struct.statistical_results, ptr %0, i32 0, i32 3
  store double %121, ptr %122, align 8, !tbaa !24
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %123 = load i64, ptr %5, align 8, !tbaa !9
  %124 = mul i64 %123, 8
  %125 = call noalias ptr @malloc(i64 noundef %124) #8
  store ptr %125, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  store i64 0, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  store i64 0, ptr %15, align 8, !tbaa !9
  br label %126

126:                                              ; preds = %169, %119
  %127 = load i64, ptr %15, align 8, !tbaa !9
  %128 = load i64, ptr %5, align 8, !tbaa !9
  %129 = icmp ult i64 %127, %128
  br i1 %129, label %131, label %130

130:                                              ; preds = %126
  store i32 14, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  br label %172

131:                                              ; preds = %126
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %132 = load ptr, ptr %6, align 8, !tbaa !5
  %133 = load i64, ptr %15, align 8, !tbaa !9
  %134 = getelementptr inbounds i64, ptr %132, i64 %133
  %135 = load i64, ptr %134, align 8, !tbaa !9
  %136 = and i64 %135, 65535
  store i64 %136, ptr %17, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  store i32 0, ptr %18, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  store i64 0, ptr %19, align 8, !tbaa !9
  br label %137

137:                                              ; preds = %151, %131
  %138 = load i64, ptr %19, align 8, !tbaa !9
  %139 = load i64, ptr %14, align 8, !tbaa !9
  %140 = icmp ult i64 %138, %139
  br i1 %140, label %142, label %141

141:                                              ; preds = %137
  store i32 17, ptr %16, align 4
  br label %154

142:                                              ; preds = %137
  %143 = load ptr, ptr %13, align 8, !tbaa !5
  %144 = load i64, ptr %19, align 8, !tbaa !9
  %145 = getelementptr inbounds i64, ptr %143, i64 %144
  %146 = load i64, ptr %145, align 8, !tbaa !9
  %147 = load i64, ptr %17, align 8, !tbaa !9
  %148 = icmp eq i64 %146, %147
  br i1 %148, label %149, label %150

149:                                              ; preds = %142
  store i32 1, ptr %18, align 4, !tbaa !17
  store i32 17, ptr %16, align 4
  br label %154

150:                                              ; preds = %142
  br label %151

151:                                              ; preds = %150
  %152 = load i64, ptr %19, align 8, !tbaa !9
  %153 = add i64 %152, 1
  store i64 %153, ptr %19, align 8, !tbaa !9
  br label %137, !llvm.loop !25

154:                                              ; preds = %149, %141
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  br label %155

155:                                              ; preds = %154
  %156 = load i32, ptr %18, align 4, !tbaa !17
  %157 = icmp ne i32 %156, 0
  br i1 %157, label %168, label %158

158:                                              ; preds = %155
  %159 = load i64, ptr %14, align 8, !tbaa !9
  %160 = load i64, ptr %5, align 8, !tbaa !9
  %161 = icmp ult i64 %159, %160
  br i1 %161, label %162, label %168

162:                                              ; preds = %158
  %163 = load i64, ptr %17, align 8, !tbaa !9
  %164 = load ptr, ptr %13, align 8, !tbaa !5
  %165 = load i64, ptr %14, align 8, !tbaa !9
  %166 = add i64 %165, 1
  store i64 %166, ptr %14, align 8, !tbaa !9
  %167 = getelementptr inbounds i64, ptr %164, i64 %165
  store i64 %163, ptr %167, align 8, !tbaa !9
  br label %168

168:                                              ; preds = %162, %158, %155
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  br label %169

169:                                              ; preds = %168
  %170 = load i64, ptr %15, align 8, !tbaa !9
  %171 = add i64 %170, 1
  store i64 %171, ptr %15, align 8, !tbaa !9
  br label %126, !llvm.loop !26

172:                                              ; preds = %130
  %173 = load i64, ptr %14, align 8, !tbaa !9
  %174 = uitofp i64 %173 to double
  %175 = load i64, ptr %5, align 8, !tbaa !9
  %176 = uitofp i64 %175 to double
  %177 = fdiv double %174, %176
  %178 = getelementptr inbounds %struct.statistical_results, ptr %0, i32 0, i32 5
  store double %177, ptr %178, align 8, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #7
  store i64 0, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #7
  store i64 0, ptr %21, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #7
  %179 = load ptr, ptr %6, align 8, !tbaa !5
  %180 = getelementptr inbounds i64, ptr %179, i64 0
  %181 = load i64, ptr %180, align 8, !tbaa !9
  %182 = and i64 %181, 1
  store i64 %182, ptr %22, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #7
  store i64 0, ptr %23, align 8, !tbaa !9
  br label %183

183:                                              ; preds = %221, %172
  %184 = load i64, ptr %23, align 8, !tbaa !9
  %185 = load i64, ptr %5, align 8, !tbaa !9
  %186 = icmp ult i64 %184, %185
  br i1 %186, label %188, label %187

187:                                              ; preds = %183
  store i32 20, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #7
  br label %224

188:                                              ; preds = %183
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #7
  store i32 0, ptr %24, align 4, !tbaa !17
  br label %189

189:                                              ; preds = %217, %188
  %190 = load i32, ptr %24, align 4, !tbaa !17
  %191 = icmp slt i32 %190, 64
  br i1 %191, label %193, label %192

192:                                              ; preds = %189
  store i32 23, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #7
  br label %220

193:                                              ; preds = %189
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #7
  %194 = load ptr, ptr %6, align 8, !tbaa !5
  %195 = load i64, ptr %23, align 8, !tbaa !9
  %196 = getelementptr inbounds i64, ptr %194, i64 %195
  %197 = load i64, ptr %196, align 8, !tbaa !9
  %198 = load i32, ptr %24, align 4, !tbaa !17
  %199 = zext i32 %198 to i64
  %200 = lshr i64 %197, %199
  %201 = and i64 %200, 1
  store i64 %201, ptr %25, align 8, !tbaa !9
  %202 = load i64, ptr %25, align 8, !tbaa !9
  %203 = load i64, ptr %22, align 8, !tbaa !9
  %204 = icmp eq i64 %202, %203
  br i1 %204, label %205, label %214

205:                                              ; preds = %193
  %206 = load i64, ptr %20, align 8, !tbaa !9
  %207 = add i64 %206, 1
  store i64 %207, ptr %20, align 8, !tbaa !9
  %208 = load i64, ptr %20, align 8, !tbaa !9
  %209 = load i64, ptr %21, align 8, !tbaa !9
  %210 = icmp ugt i64 %208, %209
  br i1 %210, label %211, label %213

211:                                              ; preds = %205
  %212 = load i64, ptr %20, align 8, !tbaa !9
  store i64 %212, ptr %21, align 8, !tbaa !9
  br label %213

213:                                              ; preds = %211, %205
  br label %216

214:                                              ; preds = %193
  store i64 1, ptr %20, align 8, !tbaa !9
  %215 = load i64, ptr %25, align 8, !tbaa !9
  store i64 %215, ptr %22, align 8, !tbaa !9
  br label %216

216:                                              ; preds = %214, %213
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #7
  br label %217

217:                                              ; preds = %216
  %218 = load i32, ptr %24, align 4, !tbaa !17
  %219 = add nsw i32 %218, 1
  store i32 %219, ptr %24, align 4, !tbaa !17
  br label %189, !llvm.loop !28

220:                                              ; preds = %192
  br label %221

221:                                              ; preds = %220
  %222 = load i64, ptr %23, align 8, !tbaa !9
  %223 = add i64 %222, 1
  store i64 %223, ptr %23, align 8, !tbaa !9
  br label %183, !llvm.loop !29

224:                                              ; preds = %187
  %225 = load i64, ptr %21, align 8, !tbaa !9
  %226 = uitofp i64 %225 to double
  %227 = getelementptr inbounds %struct.statistical_results, ptr %0, i32 0, i32 6
  store double %226, ptr %227, align 8, !tbaa !30
  %228 = load ptr, ptr %13, align 8, !tbaa !5
  call void @free(ptr noundef %228) #7
  %229 = load ptr, ptr %6, align 8, !tbaa !5
  call void @free(ptr noundef %229) #7
  store i32 1, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  ret void
}

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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

declare i64 @qrng_uint64(ptr noundef) #4

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

; Function Attrs: nounwind uwtable
declare dso_local double @calculate_entropy(ptr noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local double @chi_square_test(ptr noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local double @pattern_analysis(ptr noundef, i64 noundef) #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.ctpop.i64(i64) #5

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

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 nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }

!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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !15, i64 0}
!14 = !{!"", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24, !7, i64 32, !15, i64 64, !15, i64 72}
!15 = !{!"double", !7, i64 0}
!16 = !{!14, !15, i64 8}
!17 = !{!18, !18, i64 0}
!18 = !{!"int", !7, i64 0}
!19 = !{!15, !15, i64 0}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}
!22 = !{!14, !15, i64 16}
!23 = distinct !{!23, !12}
!24 = !{!14, !15, i64 24}
!25 = distinct !{!25, !12}
!26 = distinct !{!26, !12}
!27 = !{!14, !15, i64 64}
!28 = distinct !{!28, !12}
!29 = distinct !{!29, !12}
!30 = !{!14, !15, 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.statistical_results = type { double, double, double, double, [4 x double], double, double }

; Function Attrs: nounwind uwtable
define dso_local void @run_statistical_suite(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.statistical_results) align 8 %0, ptr noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(80) %4, i8 0, i64 64, i1 false)
  %5 = shl i64 %2, 3
  %6 = tail call noalias ptr @malloc(i64 noundef %5) #7
  %.not128 = icmp eq i64 %2, 0
  br i1 %.not128, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %3
  %7 = tail call double @calculate_entropy(ptr noundef %6, i64 noundef %2)
  store double %7, ptr %0, align 8, !tbaa !5
  %8 = tail call double @chi_square_test(ptr noundef %6, i64 noundef %2)
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  store double %8, ptr %9, align 8, !tbaa !10
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  %11 = tail call double @pattern_analysis(ptr noundef %6, i64 noundef %2)
  store double %11, ptr %10, align 8, !tbaa !11
  %12 = tail call double @pattern_analysis(ptr noundef %6, i64 noundef %2)
  %13 = getelementptr inbounds i8, ptr %0, i64 40
  store double %12, ptr %13, align 8, !tbaa !11
  %14 = tail call double @pattern_analysis(ptr noundef %6, i64 noundef %2)
  %15 = getelementptr inbounds i8, ptr %0, i64 48
  store double %14, ptr %15, align 8, !tbaa !11
  %16 = tail call double @pattern_analysis(ptr noundef %6, i64 noundef %2)
  %17 = getelementptr inbounds i8, ptr %0, i64 56
  store double %16, ptr %17, align 8, !tbaa !11
  br i1 %.not128, label %._crit_edge116.thread, label %.lr.ph100.preheader

.lr.ph100.preheader:                              ; preds = %._crit_edge
  %min.iters.check = icmp ult i64 %2, 4
  br i1 %min.iters.check, label %.lr.ph100.preheader153, label %vector.ph

.lr.ph100.preheader153:                           ; preds = %middle.block, %.lr.ph100.preheader
  %.08799.ph = phi i64 [ 0, %.lr.ph100.preheader ], [ %25, %middle.block ]
  %.09098.ph = phi i64 [ 0, %.lr.ph100.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph100

vector.ph:                                        ; preds = %.lr.ph100.preheader
  %n.vec = and i64 %2, -4
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %22, %vector.body ]
  %vec.phi150 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %23, %vector.body ]
  %18 = getelementptr inbounds i64, ptr %6, i64 %index
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  %wide.load = load <2 x i64>, ptr %18, align 8, !tbaa !12
  %wide.load151 = load <2 x i64>, ptr %19, align 8, !tbaa !12
  %20 = tail call range(i64 0, 65) <2 x i64> @llvm.ctpop.v2i64(<2 x i64> %wide.load)
  %21 = tail call range(i64 0, 65) <2 x i64> @llvm.ctpop.v2i64(<2 x i64> %wide.load151)
  %22 = add <2 x i64> %20, %vec.phi
  %23 = add <2 x i64> %21, %vec.phi150
  %index.next = add nuw i64 %index, 4
  %24 = icmp eq i64 %index.next, %n.vec
  br i1 %24, label %middle.block, label %vector.body, !llvm.loop !14

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %23, %22
  %25 = tail call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  %cmp.n = icmp eq i64 %n.vec, %2
  br i1 %cmp.n, label %._crit_edge101, label %.lr.ph100.preheader153

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.096 = phi i64 [ %28, %.lr.ph ], [ 0, %3 ]
  %26 = tail call i64 @qrng_uint64(ptr noundef %1) #8
  %27 = getelementptr inbounds i64, ptr %6, i64 %.096
  store i64 %26, ptr %27, align 8, !tbaa !12
  %28 = add nuw i64 %.096, 1
  %exitcond.not = icmp eq i64 %28, %2
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !18

._crit_edge101:                                   ; preds = %.lr.ph100, %middle.block
  %.lcssa149 = phi i64 [ %25, %middle.block ], [ %40, %.lr.ph100 ]
  %29 = uitofp i64 %.lcssa149 to double
  %30 = shl i64 %2, 6
  %31 = uitofp i64 %30 to double
  %32 = fdiv double %29, %31
  %33 = getelementptr inbounds i8, ptr %0, i64 16
  store double %32, ptr %33, align 8, !tbaa !19
  %.not = icmp eq i64 %2, 1
  br i1 %.not, label %.lr.ph115.preheader, label %.lr.ph105

.lr.ph105:                                        ; preds = %._crit_edge101
  %34 = uitofp i64 %2 to double
  %35 = add i64 %2, -1
  %xtraiter = and i64 %35, 1
  %36 = icmp eq i64 %2, 2
  br i1 %36, label %._crit_edge106.loopexit.unr-lcssa, label %.lr.ph105.new

.lr.ph105.new:                                    ; preds = %.lr.ph105
  %unroll_iter = and i64 %35, -2
  %invariant.gep = getelementptr i8, ptr %6, i64 8
  br label %58

.lr.ph100:                                        ; preds = %.lr.ph100.preheader153, %.lr.ph100
  %.08799 = phi i64 [ %40, %.lr.ph100 ], [ %.08799.ph, %.lr.ph100.preheader153 ]
  %.09098 = phi i64 [ %41, %.lr.ph100 ], [ %.09098.ph, %.lr.ph100.preheader153 ]
  %37 = getelementptr inbounds i64, ptr %6, i64 %.09098
  %38 = load i64, ptr %37, align 8, !tbaa !12
  %39 = tail call range(i64 0, 65) i64 @llvm.ctpop.i64(i64 %38)
  %40 = add i64 %39, %.08799
  %41 = add nuw i64 %.09098, 1
  %exitcond136.not = icmp eq i64 %41, %2
  br i1 %exitcond136.not, label %._crit_edge101, label %.lr.ph100, !llvm.loop !20

._crit_edge106.loopexit.unr-lcssa:                ; preds = %58, %.lr.ph105
  %.lcssa152.ph = phi double [ poison, %.lr.ph105 ], [ %71, %58 ]
  %.088103.unr = phi i64 [ 1, %.lr.ph105 ], [ %72, %58 ]
  %.089102.unr = phi double [ 0.000000e+00, %.lr.ph105 ], [ %71, %58 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge106.loopexit, label %._crit_edge106.loopexit.epilog-lcssa

._crit_edge106.loopexit.epilog-lcssa:             ; preds = %._crit_edge106.loopexit.unr-lcssa
  %42 = getelementptr inbounds i64, ptr %6, i64 %.088103.unr
  %43 = load i64, ptr %42, align 8, !tbaa !12
  %44 = getelementptr i8, ptr %42, i64 -8
  %45 = load i64, ptr %44, align 8, !tbaa !12
  %46 = and i64 %45, %43
  %47 = uitofp i64 %46 to double
  %48 = fdiv double %47, %34
  %49 = fadd double %.089102.unr, %48
  br label %._crit_edge106.loopexit

._crit_edge106.loopexit:                          ; preds = %._crit_edge106.loopexit.unr-lcssa, %._crit_edge106.loopexit.epilog-lcssa
  %.lcssa152 = phi double [ %.lcssa152.ph, %._crit_edge106.loopexit.unr-lcssa ], [ %49, %._crit_edge106.loopexit.epilog-lcssa ]
  %50 = fmul double %.lcssa152, 0x3BF0000000000000
  br label %.lr.ph115.preheader

._crit_edge116.thread:                            ; preds = %._crit_edge
  %51 = getelementptr inbounds i8, ptr %0, i64 16
  store <2 x double> <double 0x7FF8000000000000, double 0.000000e+00>, ptr %51, align 8, !tbaa !11
  %52 = tail call noalias ptr @malloc(i64 noundef %5) #7
  %53 = uitofp nneg i64 %2 to double
  %54 = fdiv double 0.000000e+00, %53
  %55 = getelementptr inbounds i8, ptr %0, i64 64
  store double %54, ptr %55, align 8, !tbaa !21
  br label %._crit_edge126

.lr.ph115.preheader:                              ; preds = %._crit_edge106.loopexit, %._crit_edge101
  %.089.lcssa.ph = phi double [ %50, %._crit_edge106.loopexit ], [ 0.000000e+00, %._crit_edge101 ]
  %56 = getelementptr inbounds i8, ptr %0, i64 24
  store double %.089.lcssa.ph, ptr %56, align 8, !tbaa !22
  %57 = tail call noalias ptr @malloc(i64 noundef %5) #7
  br label %.lr.ph115

58:                                               ; preds = %58, %.lr.ph105.new
  %.088103 = phi i64 [ 1, %.lr.ph105.new ], [ %72, %58 ]
  %.089102 = phi double [ 0.000000e+00, %.lr.ph105.new ], [ %71, %58 ]
  %niter = phi i64 [ 0, %.lr.ph105.new ], [ %niter.next.1, %58 ]
  %59 = getelementptr inbounds i64, ptr %6, i64 %.088103
  %60 = load i64, ptr %59, align 8, !tbaa !12
  %61 = getelementptr i8, ptr %59, i64 -8
  %62 = load i64, ptr %61, align 8, !tbaa !12
  %63 = and i64 %62, %60
  %64 = uitofp i64 %63 to double
  %65 = fdiv double %64, %34
  %66 = fadd double %.089102, %65
  %gep = getelementptr i64, ptr %invariant.gep, i64 %.088103
  %67 = load i64, ptr %gep, align 8, !tbaa !12
  %68 = and i64 %60, %67
  %69 = uitofp i64 %68 to double
  %70 = fdiv double %69, %34
  %71 = fadd double %66, %70
  %72 = add nuw i64 %.088103, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge106.loopexit.unr-lcssa, label %58, !llvm.loop !23

.preheader.preheader:                             ; preds = %.loopexit
  %73 = uitofp i64 %.186 to double
  %74 = uitofp i64 %2 to double
  %75 = fdiv double %73, %74
  %76 = getelementptr inbounds i8, ptr %0, i64 64
  store double %75, ptr %76, align 8, !tbaa !21
  %77 = load i64, ptr %6, align 8, !tbaa !12
  %78 = and i64 %77, 1
  br label %.preheader

.lr.ph115:                                        ; preds = %.lr.ph115.preheader, %.loopexit
  %.084113 = phi i64 [ %90, %.loopexit ], [ 0, %.lr.ph115.preheader ]
  %.085112 = phi i64 [ %.186, %.loopexit ], [ 0, %.lr.ph115.preheader ]
  %79 = getelementptr inbounds i64, ptr %6, i64 %.084113
  %80 = load i64, ptr %79, align 8, !tbaa !12
  %81 = and i64 %80, 65535
  %.not108.not = icmp eq i64 %.085112, 0
  br i1 %.not108.not, label %.critedge, label %.lr.ph111

82:                                               ; preds = %.lr.ph111
  %83 = add nuw i64 %.081109, 1
  %exitcond138.not = icmp eq i64 %83, %.085112
  br i1 %exitcond138.not, label %.critedge, label %.lr.ph111, !llvm.loop !24

.lr.ph111:                                        ; preds = %.lr.ph115, %82
  %.081109 = phi i64 [ %83, %82 ], [ 0, %.lr.ph115 ]
  %84 = getelementptr inbounds i64, ptr %57, i64 %.081109
  %85 = load i64, ptr %84, align 8, !tbaa !12
  %86 = icmp eq i64 %85, %81
  br i1 %86, label %.loopexit, label %82

.critedge:                                        ; preds = %82, %.lr.ph115
  %.old = icmp ult i64 %.085112, %2
  br i1 %.old, label %87, label %.loopexit

87:                                               ; preds = %.critedge
  %88 = add nuw i64 %.085112, 1
  %89 = getelementptr inbounds i64, ptr %57, i64 %.085112
  store i64 %81, ptr %89, align 8, !tbaa !12
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph111, %87, %.critedge
  %.186 = phi i64 [ %88, %87 ], [ %.085112, %.critedge ], [ %.085112, %.lr.ph111 ]
  %90 = add nuw i64 %.084113, 1
  %exitcond139.not = icmp eq i64 %90, %2
  br i1 %exitcond139.not, label %.preheader.preheader, label %.lr.ph115, !llvm.loop !25

.preheader:                                       ; preds = %.preheader.preheader, %96
  %.073125 = phi i64 [ %97, %96 ], [ 0, %.preheader.preheader ]
  %.074124 = phi i64 [ %105, %96 ], [ %78, %.preheader.preheader ]
  %.075123 = phi i64 [ %.277.1, %96 ], [ 0, %.preheader.preheader ]
  %.078122 = phi i64 [ %.280.1, %96 ], [ 0, %.preheader.preheader ]
  %91 = getelementptr inbounds i64, ptr %6, i64 %.073125
  %92 = load i64, ptr %91, align 8, !tbaa !12
  br label %98

._crit_edge126.loopexit:                          ; preds = %96
  %93 = uitofp i64 %.277.1 to double
  br label %._crit_edge126

._crit_edge126:                                   ; preds = %._crit_edge116.thread, %._crit_edge126.loopexit
  %94 = phi ptr [ %57, %._crit_edge126.loopexit ], [ %52, %._crit_edge116.thread ]
  %.075.lcssa = phi double [ %93, %._crit_edge126.loopexit ], [ 0.000000e+00, %._crit_edge116.thread ]
  %95 = getelementptr inbounds i8, ptr %0, i64 72
  store double %.075.lcssa, ptr %95, align 8, !tbaa !26
  tail call void @free(ptr noundef %94) #8
  tail call void @free(ptr noundef %6) #8
  ret void

96:                                               ; preds = %98
  %97 = add nuw i64 %.073125, 1
  %exitcond142.not = icmp eq i64 %97, %2
  br i1 %exitcond142.not, label %._crit_edge126.loopexit, label %.preheader, !llvm.loop !27

98:                                               ; preds = %98, %.preheader
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next.1, %98 ]
  %.1120 = phi i64 [ %.074124, %.preheader ], [ %105, %98 ]
  %.176119 = phi i64 [ %.075123, %.preheader ], [ %.277.1, %98 ]
  %.179118 = phi i64 [ %.078122, %.preheader ], [ %.280.1, %98 ]
  %99 = lshr i64 %92, %indvars.iv
  %100 = and i64 %99, 1
  %101 = icmp eq i64 %100, %.1120
  %102 = add i64 %.179118, 1
  %spec.select = tail call i64 @llvm.umax.i64(i64 %102, i64 %.176119)
  %103 = add i64 %.179118, 2
  %.277 = select i1 %101, i64 %spec.select, i64 %.176119
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %104 = lshr i64 %92, %indvars.iv.next
  %105 = and i64 %104, 1
  %106 = icmp eq i64 %105, %100
  %107 = select i1 %101, i64 %103, i64 2
  %spec.select.1 = tail call i64 @llvm.umax.i64(i64 %107, i64 %.277)
  %.280.1 = select i1 %106, i64 %107, i64 1
  %.277.1 = select i1 %106, i64 %spec.select.1, i64 %.277
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %exitcond141.not.1 = icmp eq i64 %indvars.iv.next.1, 64
  br i1 %exitcond141.not.1, label %96, label %98, !llvm.loop !28
}

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

declare i64 @qrng_uint64(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local double @calculate_entropy(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local double @chi_square_test(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local double @pattern_analysis(ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.ctpop.i64(i64) #4

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x i64> @llvm.ctpop.v2i64(<2 x i64>) #6

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #6

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 nounwind willreturn memory(argmem: write) }
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 = { "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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind allocsize(0) }
attributes #8 = { 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !8, i64 32, !7, i64 64, !7, i64 72}
!7 = !{!"double", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = distinct !{!14, !15, !16, !17}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!"llvm.loop.isvectorized", i32 1}
!17 = !{!"llvm.loop.unroll.runtime.disable"}
!18 = distinct !{!18, !15}
!19 = !{!6, !7, i64 16}
!20 = distinct !{!20, !15, !17, !16}
!21 = !{!6, !7, i64 64}
!22 = !{!6, !7, i64 24}
!23 = distinct !{!23, !15}
!24 = distinct !{!24, !15}
!25 = distinct !{!25, !15}
!26 = !{!6, !7, i64 72}
!27 = distinct !{!27, !15}
!28 = distinct !{!28, !15}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass