; LLVM IR from parallella/pal :: tests/dsp (check_p_xcorr_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"

@CANARY = external dso_local global float, align 4
@test_out1 = external dso_local global [260 x float], align 16
@test_out2 = external dso_local global [186 x float], align 16
@.str = external hidden unnamed_addr constant [78 x i8], align 1
@__func__.tc_overflow_v = external hidden unnamed_addr constant [14 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [82 x i8], align 1

; 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: nounwind uwtable
define dso_local i32 @tc_overflow_v(ptr noundef %0, ptr noundef %1) #1 {
  %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
  %8 = alloca i64, align 8
  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 259, ptr %6, align 8, !tbaa !9
  br label %9

9:                                                ; preds = %26, %2
  %10 = load i64, ptr %6, align 8, !tbaa !9
  %11 = icmp uge i64 %10, 130
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  store i32 2, ptr %7, align 4
  br label %29

13:                                               ; preds = %9
  br label %14

14:                                               ; preds = %13
  %15 = load i64, ptr %6, align 8, !tbaa !9
  %16 = getelementptr inbounds [260 x float], ptr @test_out1, i64 0, i64 %15
  %17 = load float, ptr %16, align 4, !tbaa !11
  %18 = load float, ptr @CANARY, align 4, !tbaa !11
  %19 = fcmp oeq float %17, %18
  br i1 %19, label %23, label %20

20:                                               ; preds = %14
  %21 = load i64, ptr %6, align 8, !tbaa !9
  %22 = trunc i64 %21 to i32
  call void (ptr, ptr, i32, ptr, ptr, ...) @__ut_assert_msg(ptr noundef @.str, ptr noundef @__func__.tc_overflow_v, i32 noundef 87, ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef %22)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %29

23:                                               ; preds = %14
  br label %24

24:                                               ; preds = %23
  br label %25

25:                                               ; preds = %24
  br label %26

26:                                               ; preds = %25
  %27 = load i64, ptr %6, align 8, !tbaa !9
  %28 = add i64 %27, -1
  store i64 %28, ptr %6, align 8, !tbaa !9
  br label %9, !llvm.loop !13

29:                                               ; preds = %20, %12
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %30 = load i32, ptr %7, align 4
  switch i32 %30, label %57 [
    i32 2, label %31
    i32 1, label %55
  ]

31:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  store i64 185, ptr %8, align 8, !tbaa !9
  br label %32

32:                                               ; preds = %49, %31
  %33 = load i64, ptr %8, align 8, !tbaa !9
  %34 = icmp uge i64 %33, 93
  br i1 %34, label %36, label %35

35:                                               ; preds = %32
  store i32 7, ptr %7, align 4
  br label %52

36:                                               ; preds = %32
  br label %37

37:                                               ; preds = %36
  %38 = load i64, ptr %8, align 8, !tbaa !9
  %39 = getelementptr inbounds [186 x float], ptr @test_out2, i64 0, i64 %38
  %40 = load float, ptr %39, align 4, !tbaa !11
  %41 = load float, ptr @CANARY, align 4, !tbaa !11
  %42 = fcmp oeq float %40, %41
  br i1 %42, label %46, label %43

43:                                               ; preds = %37
  %44 = load i64, ptr %8, align 8, !tbaa !9
  %45 = trunc i64 %44 to i32
  call void (ptr, ptr, i32, ptr, ptr, ...) @__ut_assert_msg(ptr noundef @.str, ptr noundef @__func__.tc_overflow_v, i32 noundef 93, ptr noundef @.str.3, ptr noundef @.str.4, i32 noundef %45)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %52

46:                                               ; preds = %37
  br label %47

47:                                               ; preds = %46
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  %50 = load i64, ptr %8, align 8, !tbaa !9
  %51 = add i64 %50, -1
  store i64 %51, ptr %8, align 8, !tbaa !9
  br label %32, !llvm.loop !15

52:                                               ; preds = %43, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %53 = load i32, ptr %7, align 4
  switch i32 %53, label %57 [
    i32 7, label %54
    i32 1, label %55
  ]

54:                                               ; preds = %52
  store i32 0, ptr %3, align 4
  br label %55

55:                                               ; preds = %54, %52, %29
  %56 = load i32, ptr %3, align 4
  ret i32 %56

57:                                               ; preds = %52, %29
  unreachable
}

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

attributes #0 = { 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 = { "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 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

@CANARY = external dso_local local_unnamed_addr global float, align 4
@test_out1 = external dso_local local_unnamed_addr global [260 x float], align 16
@test_out2 = external dso_local local_unnamed_addr global [186 x float], align 16
@.str = external hidden unnamed_addr constant [78 x i8], align 1
@__func__.tc_overflow_v = external hidden unnamed_addr constant [14 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [82 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @tc_overflow_v(ptr nocapture noundef readnone %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = load float, ptr @CANARY, align 4, !tbaa !5
  br label %4

4:                                                ; preds = %29, %2
  %.01223 = phi i64 [ 259, %2 ], [ %30, %29 ]
  %5 = getelementptr inbounds [260 x float], ptr @test_out1, i64 0, i64 %.01223
  %6 = load float, ptr %5, align 4, !tbaa !5
  %7 = fcmp oeq float %6, %3
  br i1 %7, label %9, label %.thread

.thread:                                          ; preds = %24, %19, %14, %9, %4
  %.01223.lcssa = phi i64 [ %.01223, %4 ], [ %10, %9 ], [ %15, %14 ], [ %20, %19 ], [ %25, %24 ]
  %8 = trunc i64 %.01223.lcssa to i32
  tail call void (ptr, ptr, i32, ptr, ptr, ...) @__ut_assert_msg(ptr noundef nonnull @.str, ptr noundef nonnull @__func__.tc_overflow_v, i32 noundef 87, ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef %8) #2
  br label %49

9:                                                ; preds = %4
  %10 = add nsw i64 %.01223, -1
  %11 = getelementptr inbounds [260 x float], ptr @test_out1, i64 0, i64 %10
  %12 = load float, ptr %11, align 4, !tbaa !5
  %13 = fcmp oeq float %12, %3
  br i1 %13, label %14, label %.thread

14:                                               ; preds = %9
  %15 = add nsw i64 %.01223, -2
  %16 = getelementptr inbounds [260 x float], ptr @test_out1, i64 0, i64 %15
  %17 = load float, ptr %16, align 4, !tbaa !5
  %18 = fcmp oeq float %17, %3
  br i1 %18, label %19, label %.thread

19:                                               ; preds = %14
  %20 = add nsw i64 %.01223, -3
  %21 = getelementptr inbounds [260 x float], ptr @test_out1, i64 0, i64 %20
  %22 = load float, ptr %21, align 4, !tbaa !5
  %23 = fcmp oeq float %22, %3
  br i1 %23, label %24, label %.thread

24:                                               ; preds = %19
  %25 = add nsw i64 %.01223, -4
  %26 = getelementptr inbounds [260 x float], ptr @test_out1, i64 0, i64 %25
  %27 = load float, ptr %26, align 4, !tbaa !5
  %28 = fcmp oeq float %27, %3
  br i1 %28, label %29, label %.thread

29:                                               ; preds = %24
  %30 = add nsw i64 %.01223, -5
  %31 = icmp ugt i64 %30, 129
  br i1 %31, label %4, label %.preheader, !llvm.loop !9

.preheader:                                       ; preds = %29, %45
  %.024 = phi i64 [ %46, %45 ], [ 185, %29 ]
  %32 = getelementptr inbounds [186 x float], ptr @test_out2, i64 0, i64 %.024
  %33 = load float, ptr %32, align 4, !tbaa !5
  %34 = fcmp une float %33, %3
  br i1 %34, label %35, label %.preheader.1

35:                                               ; preds = %.preheader.2, %.preheader.1, %.preheader
  %.024.lcssa = phi i64 [ %.024, %.preheader ], [ %37, %.preheader.1 ], [ %41, %.preheader.2 ]
  %.lcssa = phi i1 [ %34, %.preheader ], [ %40, %.preheader.1 ], [ %44, %.preheader.2 ]
  %36 = trunc i64 %.024.lcssa to i32
  tail call void (ptr, ptr, i32, ptr, ptr, ...) @__ut_assert_msg(ptr noundef nonnull @.str, ptr noundef nonnull @__func__.tc_overflow_v, i32 noundef 93, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, i32 noundef %36) #2
  br label %.loopexit

.preheader.1:                                     ; preds = %.preheader
  %37 = add nsw i64 %.024, -1
  %38 = getelementptr inbounds [186 x float], ptr @test_out2, i64 0, i64 %37
  %39 = load float, ptr %38, align 4, !tbaa !5
  %40 = fcmp une float %39, %3
  br i1 %40, label %35, label %.preheader.2

.preheader.2:                                     ; preds = %.preheader.1
  %41 = add nsw i64 %.024, -2
  %42 = getelementptr inbounds [186 x float], ptr @test_out2, i64 0, i64 %41
  %43 = load float, ptr %42, align 4, !tbaa !5
  %44 = fcmp une float %43, %3
  br i1 %44, label %35, label %45

45:                                               ; preds = %.preheader.2
  %46 = add nsw i64 %.024, -3
  %47 = icmp ugt i64 %46, 92
  br i1 %47, label %.preheader, label %.loopexit, !llvm.loop !11

.loopexit:                                        ; preds = %45, %35
  %48 = phi i1 [ %.lcssa, %35 ], [ %44, %45 ]
  %spec.select = zext i1 %48 to i32
  br label %49

49:                                               ; preds = %.thread, %.loopexit
  %.2 = phi i32 [ %spec.select, %.loopexit ], [ 1, %.thread ]
  ret i32 %.2
}

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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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