; LLVM IR from jgaeddert/liquid-dsp :: examples (asgramf_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 [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 float, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 64, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 200, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 25, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store float -4.000000e+01, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = call ptr @asgramf_create(i32 noundef %15)
  store ptr %16, ptr %6, align 8, !tbaa !11
  %17 = load ptr, ptr %6, align 8, !tbaa !11
  %18 = load float, ptr %5, align 4, !tbaa !9
  %19 = fadd float %18, 1.500000e+01
  %20 = call i32 @asgramf_set_scale(ptr noundef %17, float noundef %19, float noundef 5.000000e+00)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store float 0.000000e+00, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store float 0.000000e+00, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store float 0.000000e+00, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store float 0x3F689374C0000000, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %21 = load float, ptr %5, align 4, !tbaa !9
  %22 = fdiv float %21, 2.000000e+01
  %23 = call float @powf(float noundef 1.000000e+01, float noundef %22) #5
  store float %23, ptr %13, align 4, !tbaa !9
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %24

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

28:                                               ; preds = %24
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %58, %28
  %30 = load i32, ptr %7, align 4, !tbaa !5
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = icmp ult i32 %30, %31
  br i1 %32, label %33, label %61

33:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %34 = load float, ptr %9, align 4, !tbaa !9
  %35 = call float @cosf(float noundef %34) #5
  %36 = load float, ptr %13, align 4, !tbaa !9
  %37 = call float (...) @randnf()
  %38 = call float @llvm.fmuladd.f32(float %36, float %37, float %35)
  store float %38, ptr %14, align 4, !tbaa !9
  %39 = load ptr, ptr %6, align 8, !tbaa !11
  %40 = load float, ptr %14, align 4, !tbaa !9
  %41 = call i32 @asgramf_push(ptr noundef %39, float noundef %40)
  %42 = load float, ptr %10, align 4, !tbaa !9
  %43 = load float, ptr %9, align 4, !tbaa !9
  %44 = fadd float %43, %42
  store float %44, ptr %9, align 4, !tbaa !9
  %45 = load float, ptr %11, align 4, !tbaa !9
  %46 = call float @sinf(float noundef %45) #5
  %47 = fpext float %46 to double
  %48 = fmul double 0x3FF41B2F7BA3BCBE, %47
  %49 = load i32, ptr %8, align 4, !tbaa !5
  %50 = load i32, ptr %3, align 4, !tbaa !5
  %51 = call float @liquid_hamming(i32 noundef %49, i32 noundef %50)
  %52 = fpext float %51 to double
  %53 = call double @llvm.fmuladd.f64(double %48, double %52, double 0x3FF921FB54442D18)
  %54 = fptrunc double %53 to float
  store float %54, ptr %10, align 4, !tbaa !9
  %55 = load float, ptr %12, align 4, !tbaa !9
  %56 = load float, ptr %11, align 4, !tbaa !9
  %57 = fadd float %56, %55
  store float %57, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %58

58:                                               ; preds = %33
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = add i32 %59, 1
  store i32 %60, ptr %7, align 4, !tbaa !5
  br label %29, !llvm.loop !13

61:                                               ; preds = %29
  %62 = load ptr, ptr %6, align 8, !tbaa !11
  %63 = call i32 @asgramf_print(ptr noundef %62)
  %64 = load i32, ptr %4, align 4, !tbaa !5
  %65 = mul i32 %64, 1000
  %66 = call i32 @usleep(i32 noundef %65)
  br label %67

67:                                               ; preds = %61
  %68 = load i32, ptr %8, align 4, !tbaa !5
  %69 = add i32 %68, 1
  store i32 %69, ptr %8, align 4, !tbaa !5
  br label %24, !llvm.loop !15

70:                                               ; preds = %24
  %71 = load ptr, ptr %6, align 8, !tbaa !11
  %72 = call i32 @asgramf_destroy(ptr noundef %71)
  %73 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, 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
  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 @asgramf_create(i32 noundef) #2

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

; Function Attrs: nounwind
declare float @powf(float noundef, float noundef) #3

; Function Attrs: nounwind
declare float @cosf(float noundef) #3

declare float @randnf(...) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #4

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

; Function Attrs: nounwind
declare float @sinf(float noundef) #3

declare float @liquid_hamming(i32 noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #4

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

declare i32 @asgramf_print(ptr noundef) #2

declare i32 @usleep(i32 noundef) #2

declare i32 @asgramf_destroy(ptr noundef) #2

declare i32 @printf(ptr noundef, ...) #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 = { 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 "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call ptr @asgramf_create(i32 noundef 64) #5
  %2 = tail call i32 @asgramf_set_scale(ptr noundef %1, float noundef -2.500000e+01, float noundef 5.000000e+00) #5
  br label %.preheader

.preheader:                                       ; preds = %0, %18
  %.02336 = phi i32 [ 0, %0 ], [ %21, %18 ]
  %.02435 = phi float [ 0.000000e+00, %0 ], [ %8, %18 ]
  %.02534 = phi float [ 0.000000e+00, %0 ], [ %16, %18 ]
  %.02733 = phi float [ 0.000000e+00, %0 ], [ %15, %18 ]
  br label %3

3:                                                ; preds = %.preheader, %3
  %.032 = phi i32 [ 0, %.preheader ], [ %17, %3 ]
  %.131 = phi float [ %.02435, %.preheader ], [ %8, %3 ]
  %.12630 = phi float [ %.02534, %.preheader ], [ %16, %3 ]
  %.12829 = phi float [ %.02733, %.preheader ], [ %15, %3 ]
  %4 = tail call float @cosf(float noundef %.131) #5
  %5 = tail call float (...) @randnf() #5
  %6 = tail call float @llvm.fmuladd.f32(float %5, float 0x3F847AE140000000, float %4)
  %7 = tail call i32 @asgramf_push(ptr noundef %1, float noundef %6) #5
  %8 = fadd float %.12829, %.131
  %9 = tail call float @sinf(float noundef %.12630) #5
  %10 = fpext float %9 to double
  %11 = fmul double %10, 0x3FF41B2F7BA3BCBE
  %12 = tail call float @liquid_hamming(i32 noundef %.02336, i32 noundef 200) #5
  %13 = fpext float %12 to double
  %14 = tail call double @llvm.fmuladd.f64(double %11, double %13, double 0x3FF921FB54442D18)
  %15 = fptrunc double %14 to float
  %16 = fadd float %.12630, 0x3F689374C0000000
  %17 = add nuw nsw i32 %.032, 1
  %exitcond.not = icmp eq i32 %17, 64
  br i1 %exitcond.not, label %18, label %3, !llvm.loop !5

18:                                               ; preds = %3
  %19 = tail call i32 @asgramf_print(ptr noundef %1) #5
  %20 = tail call i32 @usleep(i32 noundef 25000) #5
  %21 = add nuw nsw i32 %.02336, 1
  %exitcond39.not = icmp eq i32 %21, 200
  br i1 %exitcond39.not, label %22, label %.preheader, !llvm.loop !7

22:                                               ; preds = %18
  %23 = tail call i32 @asgramf_destroy(ptr noundef %1) #5
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  ret i32 0
}

declare ptr @asgramf_create(i32 noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @cosf(float noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sinf(float noundef) local_unnamed_addr #2

declare float @liquid_hamming(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

declare i32 @asgramf_print(ptr noundef) local_unnamed_addr #1

declare i32 @usleep(i32 noundef) local_unnamed_addr #1

declare i32 @asgramf_destroy(ptr noundef) local_unnamed_addr #1

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

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 = { mustprogress nofree nounwind willreturn memory(write) "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


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