; LLVM IR from jgaeddert/liquid-dsp :: examples (spwaterfallcf_example)

; 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 [44 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %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
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1800, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 1000, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 2000000, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = call ptr @spwaterfallcf_create_default(i32 noundef %13, i32 noundef %14)
  store ptr %15, ptr %5, align 8, !tbaa !9
  %16 = load ptr, ptr %5, align 8, !tbaa !9
  %17 = call i32 @spwaterfallcf_print(ptr noundef %16)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %18 = call ptr @msourcecf_create_default()
  store ptr %18, ptr %6, align 8, !tbaa !9
  %19 = load ptr, ptr %6, align 8, !tbaa !9
  %20 = call i32 @msourcecf_add_noise(ptr noundef %19, float noundef 0.000000e+00, float noundef 1.000000e+00, float noundef -4.000000e+01)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %21 = load ptr, ptr %6, align 8, !tbaa !9
  %22 = call i32 @msourcecf_add_noise(ptr noundef %21, float noundef 0x3FD99999A0000000, float noundef 0x3FB99999A0000000, float noundef -2.000000e+01)
  store i32 %22, ptr %7, align 4, !tbaa !5
  %23 = load ptr, ptr %6, align 8, !tbaa !9
  %24 = call i32 @msourcecf_add_tone(ptr noundef %23, float noundef 0xBFD99999A0000000, float noundef 0.000000e+00, float noundef 0.000000e+00)
  %25 = load ptr, ptr %6, align 8, !tbaa !9
  %26 = call i32 @msourcecf_add_fsk(ptr noundef %25, float noundef 0xBFD6666660000000, float noundef 0x3F9EB851E0000000, float noundef -3.000000e+01, i32 noundef 2, i32 noundef 500)
  %27 = load ptr, ptr %6, align 8, !tbaa !9
  %28 = call i32 @msourcecf_add_chirp(ptr noundef %27, float noundef 0x3FC5C28F60000000, float noundef 0x3FB99999A0000000, float noundef -5.000000e+01, float noundef 2.500000e+05, i32 noundef 0, i32 noundef 0)
  %29 = load ptr, ptr %6, align 8, !tbaa !9
  %30 = call i32 @msourcecf_add_modem(ptr noundef %29, float noundef 0xBFB99999A0000000, float noundef 0x3FC3333340000000, float noundef -1.000000e+01, i32 noundef 40, i32 noundef 12, float noundef 2.500000e-01)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 64, ptr %8, align 4, !tbaa !5
  %31 = load i32, ptr %8, align 4, !tbaa !5
  %32 = zext i32 %31 to i64
  %33 = call ptr @llvm.stacksave.p0()
  store ptr %33, ptr %9, align 8
  %34 = alloca { float, float }, i64 %32, align 16
  store i64 %32, ptr %10, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 1, ptr %12, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %69, %0
  %36 = load i32, ptr %11, align 4, !tbaa !5
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = icmp ult i32 %36, %37
  br i1 %38, label %39, label %70

39:                                               ; preds = %35
  %40 = load ptr, ptr %6, align 8, !tbaa !9
  %41 = load i32, ptr %8, align 4, !tbaa !5
  %42 = call i32 @msourcecf_write_samples(ptr noundef %40, ptr noundef %34, i32 noundef %41)
  %43 = load ptr, ptr %5, align 8, !tbaa !9
  %44 = load i32, ptr %8, align 4, !tbaa !5
  %45 = call i32 @spwaterfallcf_write(ptr noundef %43, ptr noundef %34, i32 noundef %44)
  %46 = load i32, ptr %8, align 4, !tbaa !5
  %47 = load i32, ptr %11, align 4, !tbaa !5
  %48 = add i32 %47, %46
  store i32 %48, ptr %11, align 4, !tbaa !5
  %49 = load i32, ptr %12, align 4, !tbaa !5
  %50 = icmp eq i32 %49, 0
  br i1 %50, label %51, label %58

51:                                               ; preds = %39
  %52 = call float (...) @randf()
  %53 = fcmp olt float %52, 0x3F50624DE0000000
  br i1 %53, label %54, label %58

54:                                               ; preds = %51
  store i32 1, ptr %12, align 4, !tbaa !5
  %55 = load ptr, ptr %6, align 8, !tbaa !9
  %56 = load i32, ptr %7, align 4, !tbaa !5
  %57 = call i32 @msourcecf_enable(ptr noundef %55, i32 noundef %56)
  br label %69

58:                                               ; preds = %51, %39
  %59 = load i32, ptr %12, align 4, !tbaa !5
  %60 = icmp eq i32 %59, 1
  br i1 %60, label %61, label %68

61:                                               ; preds = %58
  %62 = call float (...) @randf()
  %63 = fcmp olt float %62, 0x3F689374C0000000
  br i1 %63, label %64, label %68

64:                                               ; preds = %61
  store i32 0, ptr %12, align 4, !tbaa !5
  %65 = load ptr, ptr %6, align 8, !tbaa !9
  %66 = load i32, ptr %7, align 4, !tbaa !5
  %67 = call i32 @msourcecf_disable(ptr noundef %65, i32 noundef %66)
  br label %68

68:                                               ; preds = %64, %61, %58
  br label %69

69:                                               ; preds = %68, %54
  br label %35, !llvm.loop !11

70:                                               ; preds = %35
  %71 = load ptr, ptr %5, align 8, !tbaa !9
  %72 = call i32 @spwaterfallcf_set_rate(ptr noundef %71, float noundef 1.000000e+08)
  %73 = load ptr, ptr %5, align 8, !tbaa !9
  %74 = call i32 @spwaterfallcf_set_freq(ptr noundef %73, float noundef 7.500000e+08)
  %75 = load ptr, ptr %5, align 8, !tbaa !9
  %76 = call i32 @spwaterfallcf_set_dims(ptr noundef %75, i32 noundef 1200, i32 noundef 800)
  %77 = load ptr, ptr %5, align 8, !tbaa !9
  %78 = call i32 @spwaterfallcf_set_commands(ptr noundef %77, ptr noundef @.str)
  %79 = load ptr, ptr %5, align 8, !tbaa !9
  %80 = call i32 @spwaterfallcf_export(ptr noundef %79, ptr noundef @.str.1)
  %81 = load ptr, ptr %6, align 8, !tbaa !9
  %82 = call i32 @msourcecf_destroy(ptr noundef %81)
  %83 = load ptr, ptr %5, align 8, !tbaa !9
  %84 = call i32 @spwaterfallcf_destroy(ptr noundef %83)
  %85 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  %86 = load ptr, ptr %9, align 8
  call void @llvm.stackrestore.p0(ptr %86)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  %87 = load i32, ptr %1, align 4
  ret i32 %87
}

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

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

declare i32 @spwaterfallcf_print(ptr noundef) #2

declare ptr @msourcecf_create_default() #2

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

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

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

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

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

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

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

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

declare float @randf(...) #2

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

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

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

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

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

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

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

declare i32 @msourcecf_destroy(ptr noundef) #2

declare i32 @spwaterfallcf_destroy(ptr noundef) #2

declare i32 @printf(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 = !{!"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 [44 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call ptr @spwaterfallcf_create_default(i32 noundef 1800, i32 noundef 1000) #3
  %2 = tail call i32 @spwaterfallcf_print(ptr noundef %1) #3
  %3 = tail call ptr @msourcecf_create_default() #3
  %4 = tail call i32 @msourcecf_add_noise(ptr noundef %3, float noundef 0.000000e+00, float noundef 1.000000e+00, float noundef -4.000000e+01) #3
  %5 = tail call i32 @msourcecf_add_noise(ptr noundef %3, float noundef 0x3FD99999A0000000, float noundef 0x3FB99999A0000000, float noundef -2.000000e+01) #3
  %6 = tail call i32 @msourcecf_add_tone(ptr noundef %3, float noundef 0xBFD99999A0000000, float noundef 0.000000e+00, float noundef 0.000000e+00) #3
  %7 = tail call i32 @msourcecf_add_fsk(ptr noundef %3, float noundef 0xBFD6666660000000, float noundef 0x3F9EB851E0000000, float noundef -3.000000e+01, i32 noundef 2, i32 noundef 500) #3
  %8 = tail call i32 @msourcecf_add_chirp(ptr noundef %3, float noundef 0x3FC5C28F60000000, float noundef 0x3FB99999A0000000, float noundef -5.000000e+01, float noundef 2.500000e+05, i32 noundef 0, i32 noundef 0) #3
  %9 = tail call i32 @msourcecf_add_modem(ptr noundef %3, float noundef 0xBFB99999A0000000, float noundef 0x3FC3333340000000, float noundef -1.000000e+01, i32 noundef 40, i32 noundef 12, float noundef 2.500000e-01) #3
  %10 = alloca [64 x { float, float }], align 16
  br label %11

11:                                               ; preds = %0, %24
  %.034 = phi i32 [ 1, %0 ], [ %.1, %24 ]
  %.03233 = phi i32 [ 0, %0 ], [ %14, %24 ]
  %12 = call i32 @msourcecf_write_samples(ptr noundef %3, ptr noundef nonnull %10, i32 noundef 64) #3
  %13 = call i32 @spwaterfallcf_write(ptr noundef %1, ptr noundef nonnull %10, i32 noundef 64) #3
  %14 = add nuw nsw i32 %.03233, 64
  %switch = icmp eq i32 %.034, 0
  %15 = call float (...) @randf() #3
  br i1 %switch, label %16, label %20

16:                                               ; preds = %11
  %17 = fcmp olt float %15, 0x3F50624DE0000000
  br i1 %17, label %18, label %24

18:                                               ; preds = %16
  %19 = call i32 @msourcecf_enable(ptr noundef %3, i32 noundef %5) #3
  br label %24

20:                                               ; preds = %11
  %21 = fcmp olt float %15, 0x3F689374C0000000
  br i1 %21, label %22, label %24

22:                                               ; preds = %20
  %23 = call i32 @msourcecf_disable(ptr noundef %3, i32 noundef %5) #3
  br label %24

24:                                               ; preds = %16, %20, %22, %18
  %.1 = phi i32 [ 1, %18 ], [ 0, %22 ], [ 1, %20 ], [ 0, %16 ]
  %25 = icmp ult i32 %.03233, 1999936
  br i1 %25, label %11, label %26, !llvm.loop !5

26:                                               ; preds = %24
  %27 = call i32 @spwaterfallcf_set_rate(ptr noundef %1, float noundef 1.000000e+08) #3
  %28 = call i32 @spwaterfallcf_set_freq(ptr noundef %1, float noundef 7.500000e+08) #3
  %29 = call i32 @spwaterfallcf_set_dims(ptr noundef %1, i32 noundef 1200, i32 noundef 800) #3
  %30 = call i32 @spwaterfallcf_set_commands(ptr noundef %1, ptr noundef nonnull @.str) #3
  %31 = call i32 @spwaterfallcf_export(ptr noundef %1, ptr noundef nonnull @.str.1) #3
  %32 = call i32 @msourcecf_destroy(ptr noundef %3) #3
  %33 = call i32 @spwaterfallcf_destroy(ptr noundef %1) #3
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  ret i32 0
}

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

declare i32 @spwaterfallcf_print(ptr noundef) local_unnamed_addr #1

declare ptr @msourcecf_create_default() local_unnamed_addr #1

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

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

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

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

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

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

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

declare float @randf(...) local_unnamed_addr #1

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

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

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

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

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

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

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

declare i32 @msourcecf_destroy(ptr noundef) local_unnamed_addr #1

declare i32 @spwaterfallcf_destroy(ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 = { "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 = { nofree nounwind "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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass