; LLVM IR from jgaeddert/liquid-dsp :: src/random/tests (random_autotest)

; 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"

@.str = external hidden unnamed_addr constant [89 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @autotest_randf() #0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #5
  store i64 250000, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store float 0.000000e+00, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store float 0.000000e+00, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store float 0x3FC3333340000000, ptr %6, align 4, !tbaa !9
  store i64 0, ptr %2, align 8, !tbaa !5
  br label %7

7:                                                ; preds = %20, %0
  %8 = load i64, ptr %2, align 8, !tbaa !5
  %9 = load i64, ptr %1, align 8, !tbaa !5
  %10 = icmp ult i64 %8, %9
  br i1 %10, label %11, label %23

11:                                               ; preds = %7
  %12 = call float (...) @randf()
  store float %12, ptr %3, align 4, !tbaa !9
  %13 = load float, ptr %3, align 4, !tbaa !9
  %14 = load float, ptr %4, align 4, !tbaa !9
  %15 = fadd float %14, %13
  store float %15, ptr %4, align 4, !tbaa !9
  %16 = load float, ptr %3, align 4, !tbaa !9
  %17 = load float, ptr %3, align 4, !tbaa !9
  %18 = load float, ptr %5, align 4, !tbaa !9
  %19 = call float @llvm.fmuladd.f32(float %16, float %17, float %18)
  store float %19, ptr %5, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %11
  %21 = load i64, ptr %2, align 8, !tbaa !5
  %22 = add i64 %21, 1
  store i64 %22, ptr %2, align 8, !tbaa !5
  br label %7, !llvm.loop !11

23:                                               ; preds = %7
  %24 = load i64, ptr %1, align 8, !tbaa !5
  %25 = uitofp i64 %24 to float
  %26 = load float, ptr %4, align 4, !tbaa !9
  %27 = fdiv float %26, %25
  store float %27, ptr %4, align 4, !tbaa !9
  %28 = load float, ptr %5, align 4, !tbaa !9
  %29 = load i64, ptr %1, align 8, !tbaa !5
  %30 = uitofp i64 %29 to float
  %31 = fdiv float %28, %30
  %32 = load float, ptr %4, align 4, !tbaa !9
  %33 = load float, ptr %4, align 4, !tbaa !9
  %34 = fneg float %32
  %35 = call float @llvm.fmuladd.f32(float %34, float %33, float %31)
  store float %35, ptr %5, align 4, !tbaa !9
  %36 = load float, ptr %4, align 4, !tbaa !9
  %37 = fsub float %36, 5.000000e-01
  %38 = fpext float %37 to double
  %39 = load float, ptr %4, align 4, !tbaa !9
  %40 = fsub float %39, 5.000000e-01
  %41 = fpext float %40 to double
  %42 = load float, ptr %4, align 4, !tbaa !9
  %43 = fsub float %42, 5.000000e-01
  %44 = fpext float %43 to double
  %45 = load float, ptr %4, align 4, !tbaa !9
  %46 = fsub float %45, 5.000000e-01
  %47 = fpext float %46 to double
  %48 = call double @llvm.fmuladd.f64(double %38, double %41, double 0.000000e+00)
  %49 = call double @sqrt(double noundef %48) #5
  %50 = load float, ptr %6, align 4, !tbaa !9
  %51 = fpext float %50 to double
  %52 = fcmp ogt double %49, %51
  br i1 %52, label %63, label %53

53:                                               ; preds = %23
  %54 = load float, ptr %4, align 4, !tbaa !9
  %55 = call i1 @llvm.is.fpclass.f32(float %54, i32 3)
  br i1 %55, label %63, label %56

56:                                               ; preds = %53
  %57 = load float, ptr %4, align 4, !tbaa !9
  %58 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %58, label %63, label %59

59:                                               ; preds = %56
  %60 = call i1 @llvm.is.fpclass.f32(float 5.000000e-01, i32 3)
  br i1 %60, label %63, label %61

61:                                               ; preds = %59
  %62 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %62, label %63, label %80

63:                                               ; preds = %61, %59, %56, %53, %23
  %64 = load float, ptr %4, align 4, !tbaa !9
  %65 = fsub float %64, 5.000000e-01
  %66 = fpext float %65 to double
  %67 = load float, ptr %4, align 4, !tbaa !9
  %68 = fsub float %67, 5.000000e-01
  %69 = fpext float %68 to double
  %70 = load float, ptr %4, align 4, !tbaa !9
  %71 = fsub float %70, 5.000000e-01
  %72 = fpext float %71 to double
  %73 = load float, ptr %4, align 4, !tbaa !9
  %74 = fsub float %73, 5.000000e-01
  %75 = fpext float %74 to double
  %76 = call double @llvm.fmuladd.f64(double %66, double %69, double 0.000000e+00)
  %77 = call double @sqrt(double noundef %76) #5
  %78 = load float, ptr %6, align 4, !tbaa !9
  %79 = fpext float %78 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 46, ptr noundef @.str.1, double noundef %77, ptr noundef @.str.2, ptr noundef @.str.3, double noundef %79)
  br label %81

80:                                               ; preds = %61
  call void (...) @liquid_autotest_passed()
  br label %81

81:                                               ; preds = %80, %63
  %82 = load float, ptr %5, align 4, !tbaa !9
  %83 = fsub float %82, 0x3FB5555560000000
  %84 = fpext float %83 to double
  %85 = load float, ptr %5, align 4, !tbaa !9
  %86 = fsub float %85, 0x3FB5555560000000
  %87 = fpext float %86 to double
  %88 = load float, ptr %5, align 4, !tbaa !9
  %89 = fsub float %88, 0x3FB5555560000000
  %90 = fpext float %89 to double
  %91 = load float, ptr %5, align 4, !tbaa !9
  %92 = fsub float %91, 0x3FB5555560000000
  %93 = fpext float %92 to double
  %94 = call double @llvm.fmuladd.f64(double %84, double %87, double 0.000000e+00)
  %95 = call double @sqrt(double noundef %94) #5
  %96 = load float, ptr %6, align 4, !tbaa !9
  %97 = fpext float %96 to double
  %98 = fcmp ogt double %95, %97
  br i1 %98, label %109, label %99

99:                                               ; preds = %81
  %100 = load float, ptr %5, align 4, !tbaa !9
  %101 = call i1 @llvm.is.fpclass.f32(float %100, i32 3)
  br i1 %101, label %109, label %102

102:                                              ; preds = %99
  %103 = load float, ptr %5, align 4, !tbaa !9
  %104 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %104, label %109, label %105

105:                                              ; preds = %102
  %106 = call i1 @llvm.is.fpclass.f32(float 0x3FB5555560000000, i32 3)
  br i1 %106, label %109, label %107

107:                                              ; preds = %105
  %108 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %108, label %109, label %126

109:                                              ; preds = %107, %105, %102, %99, %81
  %110 = load float, ptr %5, align 4, !tbaa !9
  %111 = fsub float %110, 0x3FB5555560000000
  %112 = fpext float %111 to double
  %113 = load float, ptr %5, align 4, !tbaa !9
  %114 = fsub float %113, 0x3FB5555560000000
  %115 = fpext float %114 to double
  %116 = load float, ptr %5, align 4, !tbaa !9
  %117 = fsub float %116, 0x3FB5555560000000
  %118 = fpext float %117 to double
  %119 = load float, ptr %5, align 4, !tbaa !9
  %120 = fsub float %119, 0x3FB5555560000000
  %121 = fpext float %120 to double
  %122 = call double @llvm.fmuladd.f64(double %112, double %115, double 0.000000e+00)
  %123 = call double @sqrt(double noundef %122) #5
  %124 = load float, ptr %6, align 4, !tbaa !9
  %125 = fpext float %124 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 47, ptr noundef @.str.4, double noundef %123, ptr noundef @.str.2, ptr noundef @.str.3, double noundef %125)
  br label %127

126:                                              ; preds = %107
  call void (...) @liquid_autotest_passed()
  br label %127

127:                                              ; preds = %126, %109
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #5
  ret void
}

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

declare float @randf(...) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

; Function Attrs: nounwind
declare double @sqrt(double noundef) #4

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i1 @llvm.is.fpclass.f32(float, i32 immarg) #3

declare void @liquid_autotest_failed_expr(ptr noundef, i32 noundef, ptr noundef, double noundef, ptr noundef, ptr noundef, double noundef) #2

declare void @liquid_autotest_passed(...) #2

; 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 = { "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 nosync nounwind speculatable willreturn memory(none) }
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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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"

@.str = external hidden unnamed_addr constant [89 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @autotest_randf() local_unnamed_addr #0 {
  br label %1

1:                                                ; preds = %0, %1
  %.045 = phi i64 [ 0, %0 ], [ %5, %1 ]
  %.03744 = phi float [ 0.000000e+00, %0 ], [ %4, %1 ]
  %.03843 = phi float [ 0.000000e+00, %0 ], [ %3, %1 ]
  %2 = tail call float (...) @randf() #4
  %3 = fadd float %.03843, %2
  %4 = tail call float @llvm.fmuladd.f32(float %2, float %2, float %.03744)
  %5 = add nuw nsw i64 %.045, 1
  %exitcond.not = icmp eq i64 %5, 250000
  br i1 %exitcond.not, label %6, label %1, !llvm.loop !5

6:                                                ; preds = %1
  %7 = fdiv float %3, 2.500000e+05
  %8 = fdiv float %4, 2.500000e+05
  %9 = fneg float %7
  %10 = tail call float @llvm.fmuladd.f32(float %9, float %7, float %8)
  %11 = fadd float %7, -5.000000e-01
  %12 = fpext float %11 to double
  %13 = tail call double @llvm.fmuladd.f64(double %12, double %12, double 0.000000e+00)
  %sqrt = tail call double @llvm.sqrt.f64(double %13)
  %14 = fcmp ogt double %sqrt, 0x3FC3333340000000
  %15 = fcmp uno float %7, 0.000000e+00
  %or.cond = select i1 %14, i1 true, i1 %15
  br i1 %or.cond, label %16, label %17

16:                                               ; preds = %6
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 46, ptr noundef nonnull @.str.1, double noundef %sqrt, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, double noundef 0x3FC3333340000000) #4
  br label %18

17:                                               ; preds = %6
  tail call void (...) @liquid_autotest_passed() #4
  br label %18

18:                                               ; preds = %17, %16
  %19 = fadd float %10, 0xBFB5555560000000
  %20 = fpext float %19 to double
  %21 = tail call double @llvm.fmuladd.f64(double %20, double %20, double 0.000000e+00)
  %sqrt41 = tail call double @llvm.sqrt.f64(double %21)
  %22 = fcmp ogt double %sqrt41, 0x3FC3333340000000
  %23 = fcmp uno float %10, 0.000000e+00
  %or.cond39 = select i1 %22, i1 true, i1 %23
  br i1 %or.cond39, label %24, label %25

24:                                               ; preds = %18
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 47, ptr noundef nonnull @.str.4, double noundef %sqrt41, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, double noundef 0x3FC3333340000000) #4
  br label %26

25:                                               ; preds = %18
  tail call void (...) @liquid_autotest_passed() #4
  br label %26

26:                                               ; preds = %25, %24
  ret void
}

declare float @randf(...) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

declare void @liquid_autotest_failed_expr(ptr noundef, i32 noundef, ptr noundef, double noundef, ptr noundef, ptr noundef, double noundef) local_unnamed_addr #1

declare void @liquid_autotest_passed(...) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.sqrt.f64(double) #3

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 = { "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 nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass