; LLVM IR from jgaeddert/liquid-dsp :: src/sequence/tests (msequence_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 [94 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [3 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

declare ptr @msequence_create_default(i32 noundef) #1

declare ptr @bsequence_create(i32 noundef) #1

declare i32 @msequence_get_length(ptr noundef) #1

declare i32 @bsequence_init_msequence(ptr noundef, ptr noundef) #1

declare i32 @bsequence_get_length(ptr noundef) #1

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

declare void @liquid_autotest_passed(...) #1

declare i32 @bsequence_destroy(ptr noundef) #1

declare i32 @msequence_destroy(ptr noundef) #1

; 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 void @msequence_test_autocorrelation(i32 noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = call ptr @msequence_create_default(i32 noundef %9)
  store ptr %10, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %11 = load ptr, ptr %3, align 8, !tbaa !9
  %12 = call i32 @msequence_get_length(ptr noundef %11)
  store i32 %12, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = call ptr @bsequence_create(i32 noundef %13)
  store ptr %14, ptr %5, align 8, !tbaa !9
  %15 = load ptr, ptr %5, align 8, !tbaa !9
  %16 = load ptr, ptr %3, align 8, !tbaa !9
  %17 = call i32 @bsequence_init_msequence(ptr noundef %15, ptr noundef %16)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = call ptr @bsequence_create(i32 noundef %18)
  store ptr %19, ptr %6, align 8, !tbaa !9
  %20 = load ptr, ptr %6, align 8, !tbaa !9
  %21 = load ptr, ptr %3, align 8, !tbaa !9
  %22 = call i32 @bsequence_init_msequence(ptr noundef %20, ptr noundef %21)
  %23 = load ptr, ptr %5, align 8, !tbaa !9
  %24 = call i32 @bsequence_get_length(ptr noundef %23)
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = icmp ne i32 %24, %25
  br i1 %26, label %27, label %33

27:                                               ; preds = %1
  %28 = load ptr, ptr %5, align 8, !tbaa !9
  %29 = call i32 @bsequence_get_length(ptr noundef %28)
  %30 = uitofp i32 %29 to double
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = uitofp i32 %31 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 61, ptr noundef @.str.4, double noundef %30, ptr noundef @.str.2, ptr noundef @.str.5, double noundef %32)
  br label %34

33:                                               ; preds = %1
  call void (...) @liquid_autotest_passed()
  br label %34

34:                                               ; preds = %33, %27
  %35 = load ptr, ptr %6, align 8, !tbaa !9
  %36 = call i32 @bsequence_get_length(ptr noundef %35)
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = icmp ne i32 %36, %37
  br i1 %38, label %39, label %45

39:                                               ; preds = %34
  %40 = load ptr, ptr %6, align 8, !tbaa !9
  %41 = call i32 @bsequence_get_length(ptr noundef %40)
  %42 = uitofp i32 %41 to double
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = uitofp i32 %43 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 62, ptr noundef @.str.6, double noundef %42, ptr noundef @.str.2, ptr noundef @.str.5, double noundef %44)
  br label %46

45:                                               ; preds = %34
  call void (...) @liquid_autotest_passed()
  br label %46

46:                                               ; preds = %45, %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %47 = load ptr, ptr %5, align 8, !tbaa !9
  %48 = load ptr, ptr %6, align 8, !tbaa !9
  %49 = call i32 @bsequence_correlate(ptr noundef %47, ptr noundef %48)
  store i32 %49, ptr %7, align 4, !tbaa !5
  %50 = load i32, ptr %7, align 4, !tbaa !5
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = icmp ne i32 %50, %51
  br i1 %52, label %53, label %58

53:                                               ; preds = %46
  %54 = load i32, ptr %7, align 4, !tbaa !5
  %55 = sitofp i32 %54 to double
  %56 = load i32, ptr %4, align 4, !tbaa !5
  %57 = uitofp i32 %56 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 67, ptr noundef @.str.7, double noundef %55, ptr noundef @.str.2, ptr noundef @.str.5, double noundef %57)
  br label %59

58:                                               ; preds = %46
  call void (...) @liquid_autotest_passed()
  br label %59

59:                                               ; preds = %58, %53
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %83, %59
  %61 = load i32, ptr %8, align 4, !tbaa !5
  %62 = load i32, ptr %4, align 4, !tbaa !5
  %63 = sub i32 %62, 1
  %64 = icmp ult i32 %61, %63
  br i1 %64, label %65, label %86

65:                                               ; preds = %60
  %66 = load ptr, ptr %6, align 8, !tbaa !9
  %67 = load ptr, ptr %3, align 8, !tbaa !9
  %68 = call i32 @msequence_advance(ptr noundef %67)
  %69 = call i32 @bsequence_push(ptr noundef %66, i32 noundef %68)
  %70 = load ptr, ptr %5, align 8, !tbaa !9
  %71 = load ptr, ptr %6, align 8, !tbaa !9
  %72 = call i32 @bsequence_correlate(ptr noundef %70, ptr noundef %71)
  %73 = mul nsw i32 2, %72
  %74 = load i32, ptr %4, align 4, !tbaa !5
  %75 = sub i32 %73, %74
  store i32 %75, ptr %7, align 4, !tbaa !5
  %76 = load i32, ptr %7, align 4, !tbaa !5
  %77 = icmp ne i32 %76, -1
  br i1 %77, label %78, label %81

78:                                               ; preds = %65
  %79 = load i32, ptr %7, align 4, !tbaa !5
  %80 = sitofp i32 %79 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 74, ptr noundef @.str.7, double noundef %80, ptr noundef @.str.2, ptr noundef @.str.8, double noundef -1.000000e+00)
  br label %82

81:                                               ; preds = %65
  call void (...) @liquid_autotest_passed()
  br label %82

82:                                               ; preds = %81, %78
  br label %83

83:                                               ; preds = %82
  %84 = load i32, ptr %8, align 4, !tbaa !5
  %85 = add i32 %84, 1
  store i32 %85, ptr %8, align 4, !tbaa !5
  br label %60, !llvm.loop !11

86:                                               ; preds = %60
  %87 = load ptr, ptr %5, align 8, !tbaa !9
  %88 = call i32 @bsequence_destroy(ptr noundef %87)
  %89 = load ptr, ptr %6, align 8, !tbaa !9
  %90 = call i32 @bsequence_destroy(ptr noundef %89)
  %91 = load ptr, ptr %3, align 8, !tbaa !9
  %92 = call i32 @msequence_destroy(ptr noundef %91)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

declare i32 @bsequence_correlate(ptr noundef, ptr noundef) #1

declare i32 @bsequence_push(ptr noundef, i32 noundef) #1

declare i32 @msequence_advance(ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { 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 = !{!"any pointer", !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 [94 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [3 x i8], align 1

declare ptr @msequence_create_default(i32 noundef) local_unnamed_addr #0

declare ptr @bsequence_create(i32 noundef) local_unnamed_addr #0

declare i32 @msequence_get_length(ptr noundef) local_unnamed_addr #0

declare i32 @bsequence_init_msequence(ptr noundef, ptr noundef) local_unnamed_addr #0

declare i32 @bsequence_get_length(ptr noundef) local_unnamed_addr #0

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

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

declare i32 @bsequence_destroy(ptr noundef) local_unnamed_addr #0

declare i32 @msequence_destroy(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @msequence_test_autocorrelation(i32 noundef %0) local_unnamed_addr #1 {
  %2 = tail call ptr @msequence_create_default(i32 noundef %0) #2
  %3 = tail call i32 @msequence_get_length(ptr noundef %2) #2
  %4 = tail call ptr @bsequence_create(i32 noundef %3) #2
  %5 = tail call i32 @bsequence_init_msequence(ptr noundef %4, ptr noundef %2) #2
  %6 = tail call ptr @bsequence_create(i32 noundef %3) #2
  %7 = tail call i32 @bsequence_init_msequence(ptr noundef %6, ptr noundef %2) #2
  %8 = tail call i32 @bsequence_get_length(ptr noundef %4) #2
  %.not = icmp eq i32 %8, %3
  br i1 %.not, label %13, label %9

9:                                                ; preds = %1
  %10 = tail call i32 @bsequence_get_length(ptr noundef %4) #2
  %11 = uitofp i32 %10 to double
  %12 = uitofp i32 %3 to double
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 61, ptr noundef nonnull @.str.4, double noundef %11, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.5, double noundef %12) #2
  br label %14

13:                                               ; preds = %1
  tail call void (...) @liquid_autotest_passed() #2
  br label %14

14:                                               ; preds = %13, %9
  %15 = tail call i32 @bsequence_get_length(ptr noundef %6) #2
  %.not37 = icmp eq i32 %15, %3
  br i1 %.not37, label %20, label %16

16:                                               ; preds = %14
  %17 = tail call i32 @bsequence_get_length(ptr noundef %6) #2
  %18 = uitofp i32 %17 to double
  %19 = uitofp i32 %3 to double
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 62, ptr noundef nonnull @.str.6, double noundef %18, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.5, double noundef %19) #2
  br label %21

20:                                               ; preds = %14
  tail call void (...) @liquid_autotest_passed() #2
  br label %21

21:                                               ; preds = %20, %16
  %22 = tail call i32 @bsequence_correlate(ptr noundef %4, ptr noundef %6) #2
  %.not38 = icmp eq i32 %22, %3
  br i1 %.not38, label %26, label %23

23:                                               ; preds = %21
  %24 = sitofp i32 %22 to double
  %25 = uitofp i32 %3 to double
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 67, ptr noundef nonnull @.str.7, double noundef %24, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.5, double noundef %25) #2
  br label %27

26:                                               ; preds = %21
  tail call void (...) @liquid_autotest_passed() #2
  br label %27

27:                                               ; preds = %26, %23
  %28 = add i32 %3, -1
  %.not41 = icmp eq i32 %28, 0
  br i1 %.not41, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %27, %37
  %.040 = phi i32 [ %38, %37 ], [ 0, %27 ]
  %29 = tail call i32 @msequence_advance(ptr noundef %2) #2
  %30 = tail call i32 @bsequence_push(ptr noundef %6, i32 noundef %29) #2
  %31 = tail call i32 @bsequence_correlate(ptr noundef %4, ptr noundef %6) #2
  %32 = shl nsw i32 %31, 1
  %33 = sub i32 %32, %3
  %.not39 = icmp eq i32 %33, -1
  br i1 %.not39, label %36, label %34

34:                                               ; preds = %.lr.ph
  %35 = sitofp i32 %33 to double
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 74, ptr noundef nonnull @.str.7, double noundef %35, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.8, double noundef -1.000000e+00) #2
  br label %37

36:                                               ; preds = %.lr.ph
  tail call void (...) @liquid_autotest_passed() #2
  br label %37

37:                                               ; preds = %34, %36
  %38 = add nuw i32 %.040, 1
  %exitcond.not = icmp eq i32 %38, %28
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5

._crit_edge:                                      ; preds = %37, %27
  %39 = tail call i32 @bsequence_destroy(ptr noundef %4) #2
  %40 = tail call i32 @bsequence_destroy(ptr noundef %6) #2
  %41 = tail call i32 @msequence_destroy(ptr noundef %2) #2
  ret void
}

declare i32 @bsequence_correlate(ptr noundef, ptr noundef) local_unnamed_addr #0

declare i32 @bsequence_push(ptr noundef, i32 noundef) local_unnamed_addr #0

declare i32 @msequence_advance(ptr noundef) local_unnamed_addr #0

attributes #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 = { 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 = { 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: CorrelatedValuePropagationPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass