; LLVM IR from jgaeddert/liquid-dsp :: examples (nco_crcf_tone_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 [24 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [24 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 float, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store float 0x3F2FB33780000000, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 2400, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = call ptr @nco_crcf_create(i32 noundef %10)
  store ptr %11, ptr %5, align 8, !tbaa !11
  %12 = load ptr, ptr %5, align 8, !tbaa !11
  %13 = load float, ptr %3, align 4, !tbaa !9
  %14 = fpext float %13 to double
  %15 = fmul double 0x401921FB54442D18, %14
  %16 = fptrunc double %15 to float
  %17 = call i32 @nco_crcf_set_frequency(ptr noundef %12, float noundef %16)
  %18 = load ptr, ptr %5, align 8, !tbaa !11
  %19 = call i32 @nco_crcf_print(ptr noundef %18)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = zext i32 %20 to i64
  %22 = call ptr @llvm.stacksave.p0()
  store ptr %22, ptr %7, align 8
  %23 = alloca { float, float }, i64 %21, align 16
  store i64 %21, ptr %8, align 8
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %36, %0
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = icmp ult i32 %25, %26
  br i1 %27, label %28, label %39

28:                                               ; preds = %24
  %29 = load ptr, ptr %5, align 8, !tbaa !11
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds { float, float }, ptr %23, i64 %31
  %33 = call i32 @nco_crcf_cexpf(ptr noundef %29, ptr noundef %32)
  %34 = load ptr, ptr %5, align 8, !tbaa !11
  %35 = call i32 @nco_crcf_step(ptr noundef %34)
  br label %36

36:                                               ; preds = %28
  %37 = load i32, ptr %6, align 4, !tbaa !5
  %38 = add i32 %37, 1
  store i32 %38, ptr %6, align 4, !tbaa !5
  br label %24, !llvm.loop !13

39:                                               ; preds = %24
  %40 = load ptr, ptr %5, align 8, !tbaa !11
  %41 = call i32 @nco_crcf_destroy(ptr noundef %40)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %42 = call noalias ptr @fopen(ptr noundef @.str, ptr noundef @.str.1)
  store ptr %42, ptr %9, align 8, !tbaa !11
  %43 = load ptr, ptr %9, align 8, !tbaa !11
  %44 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %43, ptr noundef @.str.2, ptr noundef @.str) #5
  %45 = load ptr, ptr %9, align 8, !tbaa !11
  %46 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %45, ptr noundef @.str.3) #5
  %47 = load ptr, ptr %9, align 8, !tbaa !11
  %48 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %47, ptr noundef @.str.4) #5
  %49 = load ptr, ptr %9, align 8, !tbaa !11
  %50 = load i32, ptr %4, align 4, !tbaa !5
  %51 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef @.str.5, i32 noundef %50) #5
  %52 = load ptr, ptr %9, align 8, !tbaa !11
  %53 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %52, ptr noundef @.str.6) #5
  %54 = load ptr, ptr %9, align 8, !tbaa !11
  %55 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %54, ptr noundef @.str.7) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %56

56:                                               ; preds = %81, %39
  %57 = load i32, ptr %6, align 4, !tbaa !5
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = icmp ult i32 %57, %58
  br i1 %59, label %60, label %84

60:                                               ; preds = %56
  %61 = load ptr, ptr %9, align 8, !tbaa !11
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = add i32 %62, 1
  %64 = load i32, ptr %6, align 4, !tbaa !5
  %65 = zext i32 %64 to i64
  %66 = getelementptr inbounds { float, float }, ptr %23, i64 %65
  %67 = getelementptr inbounds { float, float }, ptr %66, i32 0, i32 0
  %68 = load float, ptr %67, align 8
  %69 = getelementptr inbounds { float, float }, ptr %66, i32 0, i32 1
  %70 = load float, ptr %69, align 4
  %71 = fpext float %68 to double
  %72 = load i32, ptr %6, align 4, !tbaa !5
  %73 = zext i32 %72 to i64
  %74 = getelementptr inbounds { float, float }, ptr %23, i64 %73
  %75 = getelementptr inbounds { float, float }, ptr %74, i32 0, i32 0
  %76 = load float, ptr %75, align 8
  %77 = getelementptr inbounds { float, float }, ptr %74, i32 0, i32 1
  %78 = load float, ptr %77, align 4
  %79 = fpext float %78 to double
  %80 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %61, ptr noundef @.str.8, i32 noundef %63, double noundef %71, double noundef %79) #5
  br label %81

81:                                               ; preds = %60
  %82 = load i32, ptr %6, align 4, !tbaa !5
  %83 = add i32 %82, 1
  store i32 %83, ptr %6, align 4, !tbaa !5
  br label %56, !llvm.loop !15

84:                                               ; preds = %56
  %85 = load ptr, ptr %9, align 8, !tbaa !11
  %86 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %85, ptr noundef @.str.9) #5
  %87 = load ptr, ptr %9, align 8, !tbaa !11
  %88 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %87, ptr noundef @.str.10) #5
  %89 = load ptr, ptr %9, align 8, !tbaa !11
  %90 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %89, ptr noundef @.str.11) #5
  %91 = load ptr, ptr %9, align 8, !tbaa !11
  %92 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %91, ptr noundef @.str.12) #5
  %93 = load ptr, ptr %9, align 8, !tbaa !11
  %94 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %93, ptr noundef @.str.13) #5
  %95 = load ptr, ptr %9, align 8, !tbaa !11
  %96 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %95, ptr noundef @.str.14) #5
  %97 = load ptr, ptr %9, align 8, !tbaa !11
  %98 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %97, ptr noundef @.str.15) #5
  %99 = load ptr, ptr %9, align 8, !tbaa !11
  %100 = call i32 @fclose(ptr noundef %99)
  %101 = call i32 (ptr, ...) @printf(ptr noundef @.str.16, ptr noundef @.str)
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  %102 = load ptr, ptr %7, align 8
  call void @llvm.stackrestore.p0(ptr %102)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  %103 = load i32, ptr %1, align 4
  ret i32 %103
}

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

declare ptr @nco_crcf_create(i32 noundef) #2

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

declare i32 @nco_crcf_print(ptr noundef) #2

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

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

declare i32 @nco_crcf_step(ptr noundef) #2

declare i32 @nco_crcf_destroy(ptr noundef) #2

declare noalias ptr @fopen(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #4

declare i32 @fclose(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 "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 #5 = { 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 [24 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call ptr @nco_crcf_create(i32 noundef 0) #3
  %2 = tail call i32 @nco_crcf_set_frequency(ptr noundef %1, float noundef 0x3F58E5AD20000000) #3
  %3 = tail call i32 @nco_crcf_print(ptr noundef %1) #3
  %4 = alloca [2400 x { float, float }], align 16
  br label %5

5:                                                ; preds = %0, %5
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %5 ]
  %6 = getelementptr inbounds { float, float }, ptr %4, i64 %indvars.iv
  %7 = call i32 @nco_crcf_cexpf(ptr noundef %1, ptr noundef nonnull %6) #3
  %8 = call i32 @nco_crcf_step(ptr noundef %1) #3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 2400
  br i1 %exitcond.not, label %9, label %5, !llvm.loop !5

9:                                                ; preds = %5
  %10 = call i32 @nco_crcf_destroy(ptr noundef %1) #3
  %11 = call noalias ptr @fopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1)
  %12 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str) #3
  %13 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.3) #3
  %14 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.4) #3
  %15 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.5, i32 noundef 2400) #3
  %16 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.6) #3
  %17 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.7) #3
  br label %18

18:                                               ; preds = %9, %18
  %indvars.iv38 = phi i64 [ 0, %9 ], [ %indvars.iv.next39, %18 ]
  %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
  %19 = getelementptr inbounds { float, float }, ptr %4, i64 %indvars.iv38
  %20 = load float, ptr %19, align 8
  %21 = getelementptr inbounds i8, ptr %19, i64 4
  %22 = fpext float %20 to double
  %23 = load float, ptr %21, align 4
  %24 = fpext float %23 to double
  %25 = trunc nuw nsw i64 %indvars.iv.next39 to i32
  %26 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.8, i32 noundef %25, double noundef %22, double noundef %24) #3
  %exitcond41.not = icmp eq i64 %indvars.iv.next39, 2400
  br i1 %exitcond41.not, label %27, label %18, !llvm.loop !7

27:                                               ; preds = %18
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.9) #3
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.10) #3
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.11) #3
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.12) #3
  %32 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.13) #3
  %33 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.14) #3
  %34 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.15) #3
  %35 = call i32 @fclose(ptr noundef %11)
  %36 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16, ptr noundef nonnull @.str)
  ret i32 0
}

declare ptr @nco_crcf_create(i32 noundef) local_unnamed_addr #1

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

declare i32 @nco_crcf_print(ptr noundef) local_unnamed_addr #1

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

declare i32 @nco_crcf_step(ptr noundef) local_unnamed_addr #1

declare i32 @nco_crcf_destroy(ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #2

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

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #2

; 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"}
!7 = distinct !{!7, !6}


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