; LLVM IR from jgaeddert/liquid-dsp :: src/sequence/tests (complementary_codes_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"

@liquid_autotest_verbose = external global i32, align 4
@.str = external hidden unnamed_addr constant [104 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @complementary_codes_test(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = call ptr @bsequence_create(i32 noundef %10)
  store ptr %11, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = call ptr @bsequence_create(i32 noundef %12)
  store ptr %13, ptr %4, align 8, !tbaa !9
  %14 = load ptr, ptr %3, align 8, !tbaa !9
  %15 = load ptr, ptr %4, align 8, !tbaa !9
  %16 = call i32 @bsequence_create_ccodes(ptr noundef %14, ptr noundef %15)
  %17 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %24

19:                                               ; preds = %1
  %20 = load ptr, ptr %3, align 8, !tbaa !9
  %21 = call i32 @bsequence_print(ptr noundef %20)
  %22 = load ptr, ptr %4, align 8, !tbaa !9
  %23 = call i32 @bsequence_print(ptr noundef %22)
  br label %24

24:                                               ; preds = %19, %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = call ptr @bsequence_create(i32 noundef %25)
  store ptr %26, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = call ptr @bsequence_create(i32 noundef %27)
  store ptr %28, ptr %6, align 8, !tbaa !9
  %29 = load ptr, ptr %5, align 8, !tbaa !9
  %30 = load ptr, ptr %6, align 8, !tbaa !9
  %31 = call i32 @bsequence_create_ccodes(ptr noundef %29, ptr noundef %30)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %85, %24
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = icmp ult i32 %33, %34
  br i1 %35, label %36, label %88

36:                                               ; preds = %32
  %37 = load ptr, ptr %3, align 8, !tbaa !9
  %38 = load ptr, ptr %5, align 8, !tbaa !9
  %39 = call i32 @bsequence_correlate(ptr noundef %37, ptr noundef %38)
  %40 = mul nsw i32 2, %39
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sub i32 %40, %41
  store i32 %42, ptr %8, align 4, !tbaa !5
  %43 = load ptr, ptr %4, align 8, !tbaa !9
  %44 = load ptr, ptr %6, align 8, !tbaa !9
  %45 = call i32 @bsequence_correlate(ptr noundef %43, ptr noundef %44)
  %46 = mul nsw i32 2, %45
  %47 = load i32, ptr %2, align 4, !tbaa !5
  %48 = sub i32 %46, %47
  store i32 %48, ptr %9, align 4, !tbaa !5
  %49 = load i32, ptr %7, align 4, !tbaa !5
  %50 = icmp eq i32 %49, 0
  br i1 %50, label %51, label %68

51:                                               ; preds = %36
  %52 = load i32, ptr %8, align 4, !tbaa !5
  %53 = load i32, ptr %9, align 4, !tbaa !5
  %54 = add nsw i32 %52, %53
  %55 = load i32, ptr %2, align 4, !tbaa !5
  %56 = mul i32 2, %55
  %57 = icmp ne i32 %54, %56
  br i1 %57, label %58, label %66

58:                                               ; preds = %51
  %59 = load i32, ptr %8, align 4, !tbaa !5
  %60 = load i32, ptr %9, align 4, !tbaa !5
  %61 = add nsw i32 %59, %60
  %62 = sitofp i32 %61 to double
  %63 = load i32, ptr %2, align 4, !tbaa !5
  %64 = mul i32 2, %63
  %65 = uitofp i32 %64 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 55, ptr noundef @.str.1, double noundef %62, ptr noundef @.str.2, ptr noundef @.str.3, double noundef %65)
  br label %67

66:                                               ; preds = %51
  call void (...) @liquid_autotest_passed()
  br label %67

67:                                               ; preds = %66, %58
  br label %80

68:                                               ; preds = %36
  %69 = load i32, ptr %8, align 4, !tbaa !5
  %70 = load i32, ptr %9, align 4, !tbaa !5
  %71 = add nsw i32 %69, %70
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %73, label %78

73:                                               ; preds = %68
  %74 = load i32, ptr %8, align 4, !tbaa !5
  %75 = load i32, ptr %9, align 4, !tbaa !5
  %76 = add nsw i32 %74, %75
  %77 = sitofp i32 %76 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 56, ptr noundef @.str.1, double noundef %77, ptr noundef @.str.2, ptr noundef @.str.4, double noundef 0.000000e+00)
  br label %79

78:                                               ; preds = %68
  call void (...) @liquid_autotest_passed()
  br label %79

79:                                               ; preds = %78, %73
  br label %80

80:                                               ; preds = %79, %67
  %81 = load ptr, ptr %5, align 8, !tbaa !9
  %82 = call i32 @bsequence_circshift(ptr noundef %81)
  %83 = load ptr, ptr %6, align 8, !tbaa !9
  %84 = call i32 @bsequence_circshift(ptr noundef %83)
  br label %85

85:                                               ; preds = %80
  %86 = load i32, ptr %7, align 4, !tbaa !5
  %87 = add i32 %86, 1
  store i32 %87, ptr %7, align 4, !tbaa !5
  br label %32, !llvm.loop !11

88:                                               ; preds = %32
  %89 = load ptr, ptr %3, align 8, !tbaa !9
  %90 = call i32 @bsequence_destroy(ptr noundef %89)
  %91 = load ptr, ptr %4, align 8, !tbaa !9
  %92 = call i32 @bsequence_destroy(ptr noundef %91)
  %93 = load ptr, ptr %5, align 8, !tbaa !9
  %94 = call i32 @bsequence_destroy(ptr noundef %93)
  %95 = load ptr, ptr %6, align 8, !tbaa !9
  %96 = call i32 @bsequence_destroy(ptr noundef %95)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  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 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  ret void
}

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

declare ptr @bsequence_create(i32 noundef) #2

declare i32 @bsequence_create_ccodes(ptr noundef, ptr noundef) #2

declare i32 @bsequence_print(ptr noundef) #2

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

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

declare i32 @bsequence_circshift(ptr noundef) #2

declare i32 @bsequence_destroy(ptr noundef) #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 = { 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"

@liquid_autotest_verbose = external local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [104 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @complementary_codes_test(i32 noundef %0) local_unnamed_addr #0 {
  %2 = tail call ptr @bsequence_create(i32 noundef %0) #2
  %3 = tail call ptr @bsequence_create(i32 noundef %0) #2
  %4 = tail call i32 @bsequence_create_ccodes(ptr noundef %2, ptr noundef %3) #2
  %5 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %9, label %6

6:                                                ; preds = %1
  %7 = tail call i32 @bsequence_print(ptr noundef %2) #2
  %8 = tail call i32 @bsequence_print(ptr noundef %3) #2
  br label %9

9:                                                ; preds = %6, %1
  %10 = tail call ptr @bsequence_create(i32 noundef %0) #2
  %11 = tail call ptr @bsequence_create(i32 noundef %0) #2
  %12 = tail call i32 @bsequence_create_ccodes(ptr noundef %10, ptr noundef %11) #2
  %.not42 = icmp eq i32 %0, 0
  br i1 %.not42, label %._crit_edge, label %13

13:                                               ; preds = %9
  %14 = shl i32 %0, 1
  %15 = tail call i32 @bsequence_correlate(ptr noundef %2, ptr noundef %10) #2
  %16 = tail call i32 @bsequence_correlate(ptr noundef %3, ptr noundef %11) #2
  %17 = shl nsw i32 %16, 1
  %18 = sub i32 %17, %0
  %19 = shl nsw i32 %15, 1
  %20 = sub i32 %19, %0
  %21 = add nsw i32 %18, %20
  %.not40.peel = icmp eq i32 %21, %14
  br i1 %.not40.peel, label %25, label %22

22:                                               ; preds = %13
  %23 = uitofp i32 %14 to double
  %24 = sitofp i32 %21 to double
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 55, ptr noundef nonnull @.str.1, double noundef %24, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, double noundef %23) #2
  br label %26

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

26:                                               ; preds = %25, %22
  %27 = tail call i32 @bsequence_circshift(ptr noundef %10) #2
  %28 = tail call i32 @bsequence_circshift(ptr noundef %11) #2
  %exitcond.peel.not = icmp eq i32 %0, 1
  br i1 %exitcond.peel.not, label %._crit_edge, label %.peel.next

.peel.next:                                       ; preds = %26, %39
  %.041 = phi i32 [ %42, %39 ], [ 1, %26 ]
  %29 = tail call i32 @bsequence_correlate(ptr noundef %2, ptr noundef %10) #2
  %30 = tail call i32 @bsequence_correlate(ptr noundef %3, ptr noundef %11) #2
  %31 = shl nsw i32 %30, 1
  %32 = sub i32 %31, %0
  %33 = shl nsw i32 %29, 1
  %34 = sub i32 %33, %0
  %35 = add nsw i32 %32, %34
  %.not39 = icmp eq i32 %35, 0
  br i1 %.not39, label %38, label %36

36:                                               ; preds = %.peel.next
  %37 = sitofp i32 %35 to double
  tail call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 56, ptr noundef nonnull @.str.1, double noundef %37, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.4, double noundef 0.000000e+00) #2
  br label %39

38:                                               ; preds = %.peel.next
  tail call void (...) @liquid_autotest_passed() #2
  br label %39

39:                                               ; preds = %36, %38
  %40 = tail call i32 @bsequence_circshift(ptr noundef %10) #2
  %41 = tail call i32 @bsequence_circshift(ptr noundef %11) #2
  %42 = add nuw i32 %.041, 1
  %exitcond.not = icmp eq i32 %42, %0
  br i1 %exitcond.not, label %._crit_edge, label %.peel.next, !llvm.loop !9

._crit_edge:                                      ; preds = %39, %26, %9
  %43 = tail call i32 @bsequence_destroy(ptr noundef %2) #2
  %44 = tail call i32 @bsequence_destroy(ptr noundef %3) #2
  %45 = tail call i32 @bsequence_destroy(ptr noundef %10) #2
  %46 = tail call i32 @bsequence_destroy(ptr noundef %11) #2
  ret void
}

declare ptr @bsequence_create(i32 noundef) local_unnamed_addr #1

declare i32 @bsequence_create_ccodes(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @bsequence_print(ptr noundef) local_unnamed_addr #1

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

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

declare i32 @bsequence_circshift(ptr noundef) local_unnamed_addr #1

declare i32 @bsequence_destroy(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 = distinct !{!9, !10, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.peeled.count", i32 1}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass