; LLVM IR from parallella/pal :: tests/dsp (check_p_acorr_f32)

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

@out_size = external dso_local global i32, align 4
@out = external dso_local global [120 x float], align 16
@test_out = external dso_local global [120 x float], align 16
@.str = external hidden unnamed_addr constant [78 x i8], align 1
@__func__.tc_against_gold_v = external hidden unnamed_addr constant [18 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [69 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @check_data(float noundef, float noundef, float noundef) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @tc_against_gold_v(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %8

8:                                                ; preds = %44, %2
  %9 = load i64, ptr %6, align 8, !tbaa !9
  %10 = load i32, ptr @out_size, align 4, !tbaa !11
  %11 = sext i32 %10 to i64
  %12 = icmp ult i64 %9, %11
  br i1 %12, label %13, label %47

13:                                               ; preds = %8
  br label %14

14:                                               ; preds = %13
  %15 = load i64, ptr %6, align 8, !tbaa !9
  %16 = getelementptr inbounds [120 x float], ptr @test_out, i64 0, i64 %15
  %17 = load float, ptr %16, align 4, !tbaa !13
  %18 = load i64, ptr %6, align 8, !tbaa !9
  %19 = getelementptr inbounds [120 x float], ptr @out, i64 0, i64 %18
  %20 = load float, ptr %19, align 4, !tbaa !13
  %21 = call i32 @check_data(float noundef %17, float noundef %20, float noundef 0x3F1A36E2E0000000)
  %22 = icmp eq i32 %21, 1
  br i1 %22, label %41, label %23

23:                                               ; preds = %14
  %24 = load i64, ptr %6, align 8, !tbaa !9
  %25 = load i64, ptr %6, align 8, !tbaa !9
  %26 = getelementptr inbounds [120 x float], ptr @out, i64 0, i64 %25
  %27 = load float, ptr %26, align 4, !tbaa !13
  %28 = fpext float %27 to double
  %29 = load i64, ptr %6, align 8, !tbaa !9
  %30 = getelementptr inbounds [120 x float], ptr @test_out, i64 0, i64 %29
  %31 = load float, ptr %30, align 4, !tbaa !13
  %32 = fpext float %31 to double
  %33 = load i64, ptr %6, align 8, !tbaa !9
  %34 = getelementptr inbounds [120 x float], ptr @test_out, i64 0, i64 %33
  %35 = load float, ptr %34, align 4, !tbaa !13
  %36 = load i64, ptr %6, align 8, !tbaa !9
  %37 = getelementptr inbounds [120 x float], ptr @out, i64 0, i64 %36
  %38 = load float, ptr %37, align 4, !tbaa !13
  %39 = fdiv float %35, %38
  %40 = fpext float %39 to double
  call void (ptr, ptr, i32, ptr, ptr, ...) @__ut_assert_msg(ptr noundef @.str, ptr noundef @__func__.tc_against_gold_v, i32 noundef 60, ptr noundef @.str.1, ptr noundef @.str.2, i64 noundef %24, double noundef %28, double noundef %32, double noundef %40)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %48

41:                                               ; preds = %14
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  %45 = load i64, ptr %6, align 8, !tbaa !9
  %46 = add i64 %45, 1
  store i64 %46, ptr %6, align 8, !tbaa !9
  br label %8, !llvm.loop !15

47:                                               ; preds = %8
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %48

48:                                               ; preds = %47, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %49 = load i32, ptr %3, align 4
  ret i32 %49
}

declare void @__ut_assert_msg(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) #2

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 = { 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}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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"

@out_size = external dso_local local_unnamed_addr global i32, align 4
@out = external dso_local local_unnamed_addr global [120 x float], align 16
@test_out = external dso_local local_unnamed_addr global [120 x float], align 16
@.str = external hidden unnamed_addr constant [78 x i8], align 1
@__func__.tc_against_gold_v = external hidden unnamed_addr constant [18 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [69 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @check_data(float noundef, float noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @tc_against_gold_v(ptr nocapture noundef readnone %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = load i32, ptr @out_size, align 4, !tbaa !5
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %2, %19
  %.014 = phi i64 [ %20, %19 ], [ 0, %2 ]
  %4 = getelementptr inbounds [120 x float], ptr @test_out, i64 0, i64 %.014
  %5 = load float, ptr %4, align 4, !tbaa !9
  %6 = getelementptr inbounds [120 x float], ptr @out, i64 0, i64 %.014
  %7 = load float, ptr %6, align 4, !tbaa !9
  %8 = tail call i32 @check_data(float noundef %5, float noundef %7, float noundef 0x3F1A36E2E0000000)
  %9 = icmp eq i32 %8, 1
  br i1 %9, label %19, label %10

10:                                               ; preds = %.lr.ph
  %11 = getelementptr inbounds [120 x float], ptr @test_out, i64 0, i64 %.014
  %12 = getelementptr inbounds [120 x float], ptr @out, i64 0, i64 %.014
  %13 = load float, ptr %12, align 4, !tbaa !9
  %14 = fpext float %13 to double
  %15 = load float, ptr %11, align 4, !tbaa !9
  %16 = fpext float %15 to double
  %17 = fdiv float %15, %13
  %18 = fpext float %17 to double
  tail call void (ptr, ptr, i32, ptr, ptr, ...) @__ut_assert_msg(ptr noundef nonnull @.str, ptr noundef nonnull @__func__.tc_against_gold_v, i32 noundef 60, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i64 noundef %.014, double noundef %14, double noundef %16, double noundef %18) #2
  br label %.loopexit

19:                                               ; preds = %.lr.ph
  %20 = add nuw i64 %.014, 1
  %21 = load i32, ptr @out_size, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = icmp ult i64 %20, %22
  br i1 %23, label %.lr.ph, label %.loopexit, !llvm.loop !11

.loopexit:                                        ; preds = %19, %2, %10
  %.010 = phi i32 [ 1, %10 ], [ 0, %2 ], [ 0, %19 ]
  ret i32 %.010
}

declare void @__ut_assert_msg(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #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 = { "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 = { 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 = !{!"int", !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"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass