; LLVM IR from jgaeddert/liquid-dsp :: src/modem/tests (gmskmodem_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 [91 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @gmskmodem_test_mod_demod(i32 noundef %0, i32 noundef %1, float noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca float, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store float %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %17 = load i32, ptr %4, align 4, !tbaa !5
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = load float, ptr %6, align 4, !tbaa !9
  %20 = call ptr @gmskmod_create(i32 noundef %17, i32 noundef %18, float noundef %19)
  store ptr %20, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %23 = load float, ptr %6, align 4, !tbaa !9
  %24 = call ptr @gmskdem_create(i32 noundef %21, i32 noundef %22, float noundef %23)
  store ptr %24, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = add i32 %25, %26
  store i32 %27, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %28 = load i32, ptr %9, align 4, !tbaa !5
  %29 = add i32 80, %28
  store i32 %29, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %30 = call ptr @msequence_create_default(i32 noundef 7)
  store ptr %30, ptr %11, align 8, !tbaa !11
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = zext i32 %31 to i64
  %33 = call ptr @llvm.stacksave.p0()
  store ptr %33, ptr %12, align 8
  %34 = alloca { float, float }, i64 %32, align 16
  store i64 %32, ptr %13, align 8
  %35 = load i32, ptr %10, align 4, !tbaa !5
  %36 = zext i32 %35 to i64
  %37 = alloca i32, i64 %36, align 16
  store i64 %36, ptr %14, align 8
  %38 = load i32, ptr %10, align 4, !tbaa !5
  %39 = zext i32 %38 to i64
  %40 = alloca i32, i64 %39, align 16
  store i64 %39, ptr %15, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %62, %3
  %42 = load i32, ptr %16, align 4, !tbaa !5
  %43 = load i32, ptr %10, align 4, !tbaa !5
  %44 = icmp ult i32 %42, %43
  br i1 %44, label %45, label %65

45:                                               ; preds = %41
  %46 = load ptr, ptr %11, align 8, !tbaa !11
  %47 = call i32 @msequence_generate_symbol(ptr noundef %46, i32 noundef 1)
  %48 = load i32, ptr %16, align 4, !tbaa !5
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds i32, ptr %37, i64 %49
  store i32 %47, ptr %50, align 4, !tbaa !5
  %51 = load ptr, ptr %7, align 8, !tbaa !11
  %52 = load i32, ptr %16, align 4, !tbaa !5
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds i32, ptr %37, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = call i32 @gmskmod_modulate(ptr noundef %51, i32 noundef %55, ptr noundef %34)
  %57 = load ptr, ptr %8, align 8, !tbaa !11
  %58 = load i32, ptr %16, align 4, !tbaa !5
  %59 = zext i32 %58 to i64
  %60 = getelementptr inbounds i32, ptr %40, i64 %59
  %61 = call i32 @gmskdem_demodulate(ptr noundef %57, ptr noundef %34, ptr noundef %60)
  br label %62

62:                                               ; preds = %45
  %63 = load i32, ptr %16, align 4, !tbaa !5
  %64 = add i32 %63, 1
  store i32 %64, ptr %16, align 4, !tbaa !5
  br label %41, !llvm.loop !13

65:                                               ; preds = %41
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %102, %65
  %67 = load i32, ptr %16, align 4, !tbaa !5
  %68 = load i32, ptr %10, align 4, !tbaa !5
  %69 = icmp ult i32 %67, %68
  br i1 %69, label %70, label %105

70:                                               ; preds = %66
  %71 = load i32, ptr %16, align 4, !tbaa !5
  %72 = load i32, ptr %9, align 4, !tbaa !5
  %73 = icmp uge i32 %71, %72
  br i1 %73, label %74, label %101

74:                                               ; preds = %70
  %75 = load i32, ptr %16, align 4, !tbaa !5
  %76 = load i32, ptr %9, align 4, !tbaa !5
  %77 = sub i32 %75, %76
  %78 = zext i32 %77 to i64
  %79 = getelementptr inbounds i32, ptr %37, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = load i32, ptr %16, align 4, !tbaa !5
  %82 = zext i32 %81 to i64
  %83 = getelementptr inbounds i32, ptr %40, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = icmp ne i32 %80, %84
  br i1 %85, label %86, label %99

86:                                               ; preds = %74
  %87 = load i32, ptr %16, align 4, !tbaa !5
  %88 = load i32, ptr %9, align 4, !tbaa !5
  %89 = sub i32 %87, %88
  %90 = zext i32 %89 to i64
  %91 = getelementptr inbounds i32, ptr %37, i64 %90
  %92 = load i32, ptr %91, align 4, !tbaa !5
  %93 = uitofp i32 %92 to double
  %94 = load i32, ptr %16, align 4, !tbaa !5
  %95 = zext i32 %94 to i64
  %96 = getelementptr inbounds i32, ptr %40, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = uitofp i32 %97 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 72, ptr noundef @.str.1, double noundef %93, ptr noundef @.str.2, ptr noundef @.str.3, double noundef %98)
  br label %100

99:                                               ; preds = %74
  call void (...) @liquid_autotest_passed()
  br label %100

100:                                              ; preds = %99, %86
  br label %101

101:                                              ; preds = %100, %70
  br label %102

102:                                              ; preds = %101
  %103 = load i32, ptr %16, align 4, !tbaa !5
  %104 = add i32 %103, 1
  store i32 %104, ptr %16, align 4, !tbaa !5
  br label %66, !llvm.loop !15

105:                                              ; preds = %66
  %106 = load ptr, ptr %11, align 8, !tbaa !11
  %107 = call i32 @msequence_destroy(ptr noundef %106)
  %108 = load ptr, ptr %7, align 8, !tbaa !11
  %109 = call i32 @gmskmod_destroy(ptr noundef %108)
  %110 = load ptr, ptr %8, align 8, !tbaa !11
  %111 = call i32 @gmskdem_destroy(ptr noundef %110)
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  %112 = load ptr, ptr %12, align 8
  call void @llvm.stackrestore.p0(ptr %112)
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  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 @gmskmod_create(i32 noundef, i32 noundef, float noundef) #2

declare ptr @gmskdem_create(i32 noundef, i32 noundef, float noundef) #2

declare ptr @msequence_create_default(i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

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

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

declare i32 @gmskdem_demodulate(ptr noundef, 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 @msequence_destroy(ptr noundef) #2

declare i32 @gmskmod_destroy(ptr noundef) #2

declare i32 @gmskdem_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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #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 = { 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 willreturn }
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 = !{!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 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !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"

@.str = external hidden unnamed_addr constant [91 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @gmskmodem_test_mod_demod(i32 noundef %0, i32 noundef %1, float noundef %2) local_unnamed_addr #0 {
  %4 = tail call ptr @gmskmod_create(i32 noundef %0, i32 noundef %1, float noundef %2) #2
  %5 = tail call ptr @gmskdem_create(i32 noundef %0, i32 noundef %1, float noundef %2) #2
  %6 = shl i32 %1, 1
  %7 = add i32 %6, 80
  %8 = tail call ptr @msequence_create_default(i32 noundef 7) #2
  %9 = zext i32 %0 to i64
  %10 = alloca { float, float }, i64 %9, align 16
  %11 = zext i32 %7 to i64
  %12 = alloca i32, i64 %11, align 16
  %13 = alloca i32, i64 %11, align 16
  %.not43 = icmp eq i32 %7, 0
  br i1 %.not43, label %._crit_edge, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph
  br i1 %.not43, label %._crit_edge, label %.lr.ph42.preheader

.lr.ph42.preheader:                               ; preds = %.preheader
  %14 = zext i32 %6 to i64
  br label %.lr.ph42

.lr.ph:                                           ; preds = %3, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %3 ]
  %15 = call i32 @msequence_generate_symbol(ptr noundef %8, i32 noundef 1) #2
  %16 = getelementptr inbounds i32, ptr %12, i64 %indvars.iv
  store i32 %15, ptr %16, align 4, !tbaa !5
  %17 = call i32 @gmskmod_modulate(ptr noundef %4, i32 noundef %15, ptr noundef nonnull %10) #2
  %18 = getelementptr inbounds i32, ptr %13, i64 %indvars.iv
  %19 = call i32 @gmskdem_demodulate(ptr noundef %5, ptr noundef nonnull %10, ptr noundef nonnull %18) #2
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %11
  br i1 %exitcond.not, label %.preheader, label %.lr.ph, !llvm.loop !9

.lr.ph42:                                         ; preds = %.lr.ph42.preheader, %32
  %indvars.iv46 = phi i64 [ 0, %.lr.ph42.preheader ], [ %indvars.iv.next47, %32 ]
  %.not = icmp ult i64 %indvars.iv46, %14
  br i1 %.not, label %32, label %20

20:                                               ; preds = %.lr.ph42
  %21 = trunc nuw i64 %indvars.iv46 to i32
  %22 = sub i32 %21, %6
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds i32, ptr %12, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = getelementptr inbounds i32, ptr %13, i64 %indvars.iv46
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %.not39 = icmp eq i32 %25, %27
  br i1 %.not39, label %31, label %28

28:                                               ; preds = %20
  %29 = uitofp i32 %25 to double
  %30 = uitofp i32 %27 to double
  call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 72, ptr noundef nonnull @.str.1, double noundef %29, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, double noundef %30) #2
  br label %32

31:                                               ; preds = %20
  call void (...) @liquid_autotest_passed() #2
  br label %32

32:                                               ; preds = %.lr.ph42, %31, %28
  %indvars.iv.next47 = add nuw nsw i64 %indvars.iv46, 1
  %exitcond50.not = icmp eq i64 %indvars.iv.next47, %11
  br i1 %exitcond50.not, label %._crit_edge, label %.lr.ph42, !llvm.loop !11

._crit_edge:                                      ; preds = %32, %3, %.preheader
  %33 = call i32 @msequence_destroy(ptr noundef %8) #2
  %34 = call i32 @gmskmod_destroy(ptr noundef %4) #2
  %35 = call i32 @gmskdem_destroy(ptr noundef %5) #2
  ret void
}

declare ptr @gmskmod_create(i32 noundef, i32 noundef, float noundef) local_unnamed_addr #1

declare ptr @gmskdem_create(i32 noundef, i32 noundef, float noundef) local_unnamed_addr #1

declare ptr @msequence_create_default(i32 noundef) local_unnamed_addr #1

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

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

declare i32 @gmskdem_demodulate(ptr noundef, 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 @msequence_destroy(ptr noundef) local_unnamed_addr #1

declare i32 @gmskmod_destroy(ptr noundef) local_unnamed_addr #1

declare i32 @gmskdem_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}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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