; LLVM IR from jgaeddert/liquid-dsp :: examples (asgramcf_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 ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca float, align 4
  %16 = alloca { float, float }, align 4
  %17 = alloca { float, 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
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = call ptr @asgramcf_create(i32 noundef %18)
  store ptr %19, ptr %6, align 8, !tbaa !11
  %20 = load ptr, ptr %6, align 8, !tbaa !11
  %21 = load float, ptr %5, align 4, !tbaa !9
  %22 = fadd float %21, 1.500000e+01
  %23 = call i32 @asgramcf_set_scale(ptr noundef %20, float noundef %22, 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
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = zext i32 %24 to i64
  %26 = call ptr @llvm.stacksave.p0()
  store ptr %26, ptr %13, align 8
  %27 = alloca { float, float }, i64 %25, align 16
  store i64 %25, ptr %14, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %28 = load float, ptr %5, align 4, !tbaa !9
  %29 = fdiv float %28, 2.000000e+01
  %30 = call float @powf(float noundef 1.000000e+01, float noundef %29) #5
  store float %30, ptr %15, align 4, !tbaa !9
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %112, %0
  %32 = load i32, ptr %8, align 4, !tbaa !5
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = icmp ult i32 %32, %33
  br i1 %34, label %35, label %115

35:                                               ; preds = %31
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %100, %35
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = icmp ult i32 %37, %38
  br i1 %39, label %40, label %103

40:                                               ; preds = %36
  %41 = load float, ptr %9, align 4, !tbaa !9
  %42 = fmul float 0.000000e+00, %41
  %43 = fmul float 1.000000e+00, %41
  %44 = getelementptr inbounds { float, float }, ptr %16, i32 0, i32 0
  %45 = getelementptr inbounds { float, float }, ptr %16, i32 0, i32 1
  store float %42, ptr %44, align 4
  store float %43, ptr %45, align 4
  %46 = load <2 x float>, ptr %16, align 4
  %47 = call <2 x float> @cexpf(<2 x float> noundef %46) #5
  store <2 x float> %47, ptr %17, align 4
  %48 = getelementptr inbounds { float, float }, ptr %17, i32 0, i32 0
  %49 = load float, ptr %48, align 4
  %50 = getelementptr inbounds { float, float }, ptr %17, i32 0, i32 1
  %51 = load float, ptr %50, align 4
  %52 = load i32, ptr %7, align 4, !tbaa !5
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds { float, float }, ptr %27, i64 %53
  %55 = getelementptr inbounds { float, float }, ptr %54, i32 0, i32 0
  %56 = getelementptr inbounds { float, float }, ptr %54, i32 0, i32 1
  store float %49, ptr %55, align 8
  store float %51, ptr %56, align 4
  %57 = load float, ptr %15, align 4, !tbaa !9
  %58 = call float (...) @randnf()
  %59 = call float (...) @randnf()
  %60 = fmul float 0.000000e+00, %59
  %61 = fmul float 1.000000e+00, %59
  %62 = fadd float %58, %60
  %63 = fmul float %57, %62
  %64 = fmul float %57, %61
  %65 = fpext float %63 to double
  %66 = fpext float %64 to double
  %67 = fmul double %65, 0x3FE6A09E667F3BCD
  %68 = fmul double %66, 0x3FE6A09E667F3BCD
  %69 = load i32, ptr %7, align 4, !tbaa !5
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds { float, float }, ptr %27, i64 %70
  %72 = getelementptr inbounds { float, float }, ptr %71, i32 0, i32 0
  %73 = load float, ptr %72, align 8
  %74 = getelementptr inbounds { float, float }, ptr %71, i32 0, i32 1
  %75 = load float, ptr %74, align 4
  %76 = fpext float %73 to double
  %77 = fpext float %75 to double
  %78 = fadd double %76, %67
  %79 = fadd double %77, %68
  %80 = fptrunc double %78 to float
  %81 = fptrunc double %79 to float
  %82 = getelementptr inbounds { float, float }, ptr %71, i32 0, i32 0
  %83 = getelementptr inbounds { float, float }, ptr %71, i32 0, i32 1
  store float %80, ptr %82, align 8
  store float %81, ptr %83, align 4
  %84 = load float, ptr %10, align 4, !tbaa !9
  %85 = load float, ptr %9, align 4, !tbaa !9
  %86 = fadd float %85, %84
  store float %86, ptr %9, align 4, !tbaa !9
  %87 = load float, ptr %11, align 4, !tbaa !9
  %88 = call float @sinf(float noundef %87) #5
  %89 = fpext float %88 to double
  %90 = fmul double 0x40069E955B62F741, %89
  %91 = load i32, ptr %8, align 4, !tbaa !5
  %92 = load i32, ptr %3, align 4, !tbaa !5
  %93 = call float @liquid_hamming(i32 noundef %91, i32 noundef %92)
  %94 = fpext float %93 to double
  %95 = fmul double %90, %94
  %96 = fptrunc double %95 to float
  store float %96, ptr %10, align 4, !tbaa !9
  %97 = load float, ptr %12, align 4, !tbaa !9
  %98 = load float, ptr %11, align 4, !tbaa !9
  %99 = fadd float %98, %97
  store float %99, ptr %11, align 4, !tbaa !9
  br label %100

100:                                              ; preds = %40
  %101 = load i32, ptr %7, align 4, !tbaa !5
  %102 = add i32 %101, 1
  store i32 %102, ptr %7, align 4, !tbaa !5
  br label %36, !llvm.loop !13

103:                                              ; preds = %36
  %104 = load ptr, ptr %6, align 8, !tbaa !11
  %105 = load i32, ptr %2, align 4, !tbaa !5
  %106 = call i32 @asgramcf_write(ptr noundef %104, ptr noundef %27, i32 noundef %105)
  %107 = load ptr, ptr %6, align 8, !tbaa !11
  %108 = call i32 @asgramcf_print(ptr noundef %107)
  %109 = load i32, ptr %4, align 4, !tbaa !5
  %110 = mul i32 %109, 1000
  %111 = call i32 @usleep(i32 noundef %110)
  br label %112

112:                                              ; preds = %103
  %113 = load i32, ptr %8, align 4, !tbaa !5
  %114 = add i32 %113, 1
  store i32 %114, ptr %8, align 4, !tbaa !5
  br label %31, !llvm.loop !15

115:                                              ; preds = %31
  %116 = load ptr, ptr %6, align 8, !tbaa !11
  %117 = call i32 @asgramcf_destroy(ptr noundef %116)
  %118 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  %119 = load ptr, ptr %13, align 8
  call void @llvm.stackrestore.p0(ptr %119)
  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
  %120 = load i32, ptr %1, align 4
  ret i32 %120
}

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

declare ptr @asgramcf_create(i32 noundef) #2

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

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

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

; Function Attrs: nounwind
declare <2 x float> @cexpf(<2 x float> noundef) #4

declare float @randnf(...) #2

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

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

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

declare i32 @asgramcf_print(ptr noundef) #2

declare i32 @usleep(i32 noundef) #2

declare i32 @asgramcf_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"="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 = { 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 [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call ptr @asgramcf_create(i32 noundef 64) #5
  %2 = tail call i32 @asgramcf_set_scale(ptr noundef %1, float noundef -2.500000e+01, float noundef 5.000000e+00) #5
  %3 = alloca [64 x { float, float }], align 16
  br label %.preheader

.preheader:                                       ; preds = %0, %30
  %.03043 = phi i32 [ 0, %0 ], [ %34, %30 ]
  %.03142 = phi float [ 0.000000e+00, %0 ], [ %21, %30 ]
  %.03241 = phi float [ 0.000000e+00, %0 ], [ %28, %30 ]
  %.03440 = phi float [ 0.000000e+00, %0 ], [ %29, %30 ]
  br label %4

4:                                                ; preds = %.preheader, %4
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next, %4 ]
  %.138 = phi float [ %.03142, %.preheader ], [ %21, %4 ]
  %.13337 = phi float [ %.03241, %.preheader ], [ %28, %4 ]
  %.13536 = phi float [ %.03440, %.preheader ], [ %29, %4 ]
  %5 = fmul float %.138, 0.000000e+00
  %.sroa.01.0.vec.insert = insertelement <2 x float> poison, float %5, i64 0
  %.sroa.01.4.vec.insert = insertelement <2 x float> %.sroa.01.0.vec.insert, float %.138, i64 1
  %6 = call <2 x float> @cexpf(<2 x float> noundef %.sroa.01.4.vec.insert) #5
  %7 = getelementptr inbounds { float, float }, ptr %3, i64 %indvars.iv
  store <2 x float> %6, ptr %7, align 8
  %8 = call float (...) @randnf() #5
  %9 = call float (...) @randnf() #5
  %10 = fmul float %9, 0.000000e+00
  %11 = fadd float %8, %10
  %12 = insertelement <2 x float> poison, float %11, i64 0
  %13 = insertelement <2 x float> %12, float %9, i64 1
  %14 = fmul <2 x float> %13, <float 0x3F847AE140000000, float 0x3F847AE140000000>
  %15 = fpext <2 x float> %14 to <2 x double>
  %16 = fmul <2 x double> %15, <double 0x3FE6A09E667F3BCD, double 0x3FE6A09E667F3BCD>
  %17 = load <2 x float>, ptr %7, align 8
  %18 = fpext <2 x float> %17 to <2 x double>
  %19 = fadd <2 x double> %16, %18
  %20 = fptrunc <2 x double> %19 to <2 x float>
  store <2 x float> %20, ptr %7, align 8
  %21 = fadd float %.13337, %.138
  %22 = call float @sinf(float noundef %.13536) #5
  %23 = fpext float %22 to double
  %24 = fmul double %23, 0x40069E955B62F741
  %25 = call float @liquid_hamming(i32 noundef %.03043, i32 noundef 200) #5
  %26 = fpext float %25 to double
  %27 = fmul double %24, %26
  %28 = fptrunc double %27 to float
  %29 = fadd float %.13536, 0x3F689374C0000000
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 64
  br i1 %exitcond.not, label %30, label %4, !llvm.loop !5

30:                                               ; preds = %4
  %31 = call i32 @asgramcf_write(ptr noundef %1, ptr noundef nonnull %3, i32 noundef 64) #5
  %32 = call i32 @asgramcf_print(ptr noundef %1) #5
  %33 = call i32 @usleep(i32 noundef 25000) #5
  %34 = add nuw nsw i32 %.03043, 1
  %exitcond47.not = icmp eq i32 %34, 200
  br i1 %exitcond47.not, label %35, label %.preheader, !llvm.loop !7

35:                                               ; preds = %30
  %36 = call i32 @asgramcf_destroy(ptr noundef %1) #5
  %37 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  ret i32 0
}

declare ptr @asgramcf_create(i32 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind
declare <2 x float> @cexpf(<2 x float> noundef) local_unnamed_addr #2

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

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

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

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

declare i32 @asgramcf_print(ptr noundef) local_unnamed_addr #1

declare i32 @usleep(i32 noundef) local_unnamed_addr #1

declare i32 @asgramcf_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"="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 = { "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 "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 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 #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,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass