; LLVM IR from jgaeddert/liquid-dsp :: examples (platformio_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 [25 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [27 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 ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca { float, float }, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca { float, float }, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 27, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = call ptr @modemcf_create(i32 noundef %13)
  store ptr %14, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = call ptr @modemcf_create(i32 noundef %15)
  store ptr %16, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %17 = load ptr, ptr %3, align 8, !tbaa !9
  %18 = call i32 @modemcf_get_bps(ptr noundef %17)
  store i32 %18, ptr %5, align 4, !tbaa !5
  %19 = load ptr, ptr %3, align 8, !tbaa !9
  %20 = call i32 @modemcf_print(ptr noundef %19)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = shl i32 1, %21
  store i32 %22, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %64, %0
  %24 = load i32, ptr %6, align 4, !tbaa !5
  %25 = load i32, ptr %8, align 4, !tbaa !5
  %26 = icmp ult i32 %24, %25
  br i1 %26, label %27, label %67

27:                                               ; preds = %23
  %28 = load ptr, ptr %3, align 8, !tbaa !9
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = call i32 @modemcf_modulate(ptr noundef %28, i32 noundef %29, ptr noundef %9)
  %31 = load ptr, ptr %4, align 8, !tbaa !9
  %32 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %33 = load float, ptr %32, align 4
  %34 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  %35 = load float, ptr %34, align 4
  %36 = getelementptr inbounds { float, float }, ptr %12, i32 0, i32 0
  %37 = getelementptr inbounds { float, float }, ptr %12, i32 0, i32 1
  store float %33, ptr %36, align 4
  store float %35, ptr %37, align 4
  %38 = load <2 x float>, ptr %12, align 4
  %39 = call i32 @modemcf_demodulate(ptr noundef %31, <2 x float> noundef %38, ptr noundef %7)
  %40 = load i32, ptr %6, align 4, !tbaa !5
  %41 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %42 = load float, ptr %41, align 4
  %43 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  %44 = load float, ptr %43, align 4
  %45 = fpext float %42 to double
  %46 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %47 = load float, ptr %46, align 4
  %48 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  %49 = load float, ptr %48, align 4
  %50 = fpext float %49 to double
  %51 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %40, double noundef %45, double noundef %50)
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = icmp eq i32 %52, %53
  %55 = zext i1 %54 to i64
  %56 = select i1 %54, i32 0, i32 1
  %57 = load i32, ptr %10, align 4, !tbaa !5
  %58 = add i32 %57, %56
  store i32 %58, ptr %10, align 4, !tbaa !5
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = load i32, ptr %7, align 4, !tbaa !5
  %61 = call i32 @count_bit_errors(i32 noundef %59, i32 noundef %60)
  %62 = load i32, ptr %11, align 4, !tbaa !5
  %63 = add i32 %62, %61
  store i32 %63, ptr %11, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %27
  %65 = load i32, ptr %6, align 4, !tbaa !5
  %66 = add i32 %65, 1
  store i32 %66, ptr %6, align 4, !tbaa !5
  br label %23, !llvm.loop !11

67:                                               ; preds = %23
  %68 = load i32, ptr %10, align 4, !tbaa !5
  %69 = load i32, ptr %8, align 4, !tbaa !5
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %68, i32 noundef %69)
  %71 = load i32, ptr %11, align 4, !tbaa !5
  %72 = load i32, ptr %8, align 4, !tbaa !5
  %73 = load i32, ptr %5, align 4, !tbaa !5
  %74 = mul i32 %72, %73
  %75 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %71, i32 noundef %74)
  %76 = load ptr, ptr %3, align 8, !tbaa !9
  %77 = call i32 @modemcf_destroy(ptr noundef %76)
  %78 = load ptr, ptr %4, align 8, !tbaa !9
  %79 = call i32 @modemcf_destroy(ptr noundef %78)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, 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 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, 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
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  ret i32 0
}

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

declare ptr @modemcf_create(i32 noundef) #2

declare i32 @modemcf_get_bps(ptr noundef) #2

declare i32 @modemcf_print(ptr noundef) #2

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

declare i32 @modemcf_demodulate(ptr noundef, <2 x float> noundef, ptr noundef) #2

declare i32 @printf(ptr noundef, ...) #2

declare i32 @count_bit_errors(i32 noundef, i32 noundef) #2

declare i32 @modemcf_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"="64" "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"

@.str = external hidden unnamed_addr constant [25 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca { float, float }, align 8
  %3 = tail call ptr @modemcf_create(i32 noundef 27) #4
  %4 = tail call ptr @modemcf_create(i32 noundef 27) #4
  %5 = tail call i32 @modemcf_get_bps(ptr noundef %3) #4
  %6 = tail call i32 @modemcf_print(ptr noundef %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %7 = shl nuw i32 1, %5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %8 = getelementptr inbounds i8, ptr %2, i64 4
  br label %9

9:                                                ; preds = %0, %9
  %.028 = phi i32 [ 0, %0 ], [ %23, %9 ]
  %.02327 = phi i32 [ 0, %0 ], [ %21, %9 ]
  %.02426 = phi i32 [ 0, %0 ], [ %24, %9 ]
  %10 = call i32 @modemcf_modulate(ptr noundef %3, i32 noundef %.02426, ptr noundef nonnull %2) #4
  %11 = load <2 x float>, ptr %2, align 8
  %12 = call i32 @modemcf_demodulate(ptr noundef %4, <2 x float> noundef %11, ptr noundef nonnull %1) #4
  %13 = load float, ptr %2, align 8
  %14 = fpext float %13 to double
  %15 = load float, ptr %8, align 4
  %16 = fpext float %15 to double
  %17 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %.02426, double noundef %14, double noundef %16)
  %18 = load i32, ptr %1, align 4, !tbaa !5
  %19 = icmp ne i32 %.02426, %18
  %20 = zext i1 %19 to i32
  %21 = add i32 %.02327, %20
  %22 = call i32 @count_bit_errors(i32 noundef %.02426, i32 noundef %18) #4
  %23 = add i32 %22, %.028
  %24 = add nuw i32 %.02426, 1
  %exitcond.not = icmp eq i32 %24, %7
  br i1 %exitcond.not, label %25, label %9, !llvm.loop !9

25:                                               ; preds = %9
  %26 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %21, i32 noundef %7)
  %27 = shl i32 %5, %5
  %28 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %23, i32 noundef %27)
  %29 = call i32 @modemcf_destroy(ptr noundef %3) #4
  %30 = call i32 @modemcf_destroy(ptr noundef %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret i32 0
}

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

declare ptr @modemcf_create(i32 noundef) local_unnamed_addr #2

declare i32 @modemcf_get_bps(ptr noundef) local_unnamed_addr #2

declare i32 @modemcf_print(ptr noundef) local_unnamed_addr #2

declare i32 @modemcf_modulate(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

declare i32 @modemcf_demodulate(ptr noundef, <2 x float> noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

declare i32 @count_bit_errors(i32 noundef, i32 noundef) local_unnamed_addr #2

declare i32 @modemcf_destroy(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress 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"="64" "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 = { mustprogress 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 = { 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 #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass