; LLVM IR from jgaeddert/liquid-dsp :: sandbox (vectorcf_test)

; 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 [33 x i8], align 1
@.str.1 = 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 ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca { float, float }, align 4
  %7 = alloca { float, float }, align 4
  %8 = alloca float, align 4
  %9 = alloca { float, float }, align 4
  %10 = 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
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = zext i32 %11 to i64
  %13 = call ptr @llvm.stacksave.p0()
  store ptr %13, ptr %4, align 8
  %14 = alloca { float, float }, i64 %12, align 16
  store i64 %12, ptr %5, align 8
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %37, %0
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = icmp ult i32 %16, %17
  br i1 %18, label %19, label %40

19:                                               ; preds = %15
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = uitofp i32 %20 to float
  %22 = fmul float 0.000000e+00, %21
  %23 = fmul float 1.000000e+00, %21
  %24 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 0
  %25 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 1
  store float %22, ptr %24, align 4
  store float %23, ptr %25, align 4
  %26 = load <2 x float>, ptr %6, align 4
  %27 = call <2 x float> @cexpf(<2 x float> noundef %26) #5
  store <2 x float> %27, ptr %7, align 4
  %28 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %29 = load float, ptr %28, align 4
  %30 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  %31 = load float, ptr %30, align 4
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = zext i32 %32 to i64
  %34 = getelementptr inbounds { float, float }, ptr %14, i64 %33
  %35 = getelementptr inbounds { float, float }, ptr %34, i32 0, i32 0
  %36 = getelementptr inbounds { float, float }, ptr %34, i32 0, i32 1
  store float %29, ptr %35, align 8
  store float %31, ptr %36, align 4
  br label %37

37:                                               ; preds = %19
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = add i32 %38, 1
  store i32 %39, ptr %3, align 4, !tbaa !5
  br label %15, !llvm.loop !9

40:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store float 0.000000e+00, ptr %8, align 4, !tbaa !11
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %81, %40
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = load i32, ptr %2, align 4, !tbaa !5
  %44 = icmp ult i32 %42, %43
  br i1 %44, label %45, label %84

45:                                               ; preds = %41
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds { float, float }, ptr %14, i64 %47
  %49 = getelementptr inbounds { float, float }, ptr %48, i32 0, i32 0
  %50 = load float, ptr %49, align 8
  %51 = getelementptr inbounds { float, float }, ptr %48, i32 0, i32 1
  %52 = load float, ptr %51, align 4
  %53 = load i32, ptr %3, align 4, !tbaa !5
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds { float, float }, ptr %14, i64 %54
  %56 = getelementptr inbounds { float, float }, ptr %55, i32 0, i32 0
  %57 = load float, ptr %56, align 8
  %58 = getelementptr inbounds { float, float }, ptr %55, i32 0, i32 1
  %59 = load float, ptr %58, align 4
  %60 = fneg float %59
  %61 = fmul float %50, %57
  %62 = fmul float %52, %60
  %63 = fmul float %50, %60
  %64 = fmul float %52, %57
  %65 = fsub float %61, %62
  %66 = fadd float %63, %64
  %67 = fcmp uno float %65, %65
  br i1 %67, label %68, label %76, !prof !13

68:                                               ; preds = %45
  %69 = fcmp uno float %66, %66
  br i1 %69, label %70, label %76, !prof !13

70:                                               ; preds = %68
  %71 = call <2 x float> @__mulsc3(float noundef %50, float noundef %52, float noundef %57, float noundef %60) #5
  store <2 x float> %71, ptr %9, align 4
  %72 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %73 = load float, ptr %72, align 4
  %74 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  %75 = load float, ptr %74, align 4
  br label %76

76:                                               ; preds = %70, %68, %45
  %77 = phi float [ %65, %45 ], [ %65, %68 ], [ %73, %70 ]
  %78 = phi float [ %66, %45 ], [ %66, %68 ], [ %75, %70 ]
  %79 = load float, ptr %8, align 4, !tbaa !11
  %80 = fadd float %79, %77
  store float %80, ptr %8, align 4, !tbaa !11
  br label %81

81:                                               ; preds = %76
  %82 = load i32, ptr %3, align 4, !tbaa !5
  %83 = add i32 %82, 1
  store i32 %83, ptr %3, align 4, !tbaa !5
  br label %41, !llvm.loop !14

84:                                               ; preds = %41
  %85 = load float, ptr %8, align 4, !tbaa !11
  %86 = call float @sqrtf(float noundef %85) #5
  store float %86, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %87 = load i32, ptr %2, align 4, !tbaa !5
  %88 = call float @liquid_vectorcf_norm(ptr noundef %14, i32 noundef %87)
  store float %88, ptr %10, align 4, !tbaa !11
  %89 = load float, ptr %10, align 4, !tbaa !11
  %90 = fpext float %89 to double
  %91 = load float, ptr %8, align 4, !tbaa !11
  %92 = fpext float %91 to double
  %93 = call i32 (ptr, ...) @printf(ptr noundef @.str, double noundef %90, double noundef %92)
  %94 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %95 = load ptr, ptr %4, align 8
  call void @llvm.stackrestore.p0(ptr %95)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  %96 = load i32, ptr %1, align 4
  ret i32 %96
}

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

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

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

declare <2 x float> @__mulsc3(float, float, float, float)

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

declare float @liquid_vectorcf_norm(ptr noundef, i32 noundef) #4

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

; 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) #2

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 = { nocallback nofree nosync nounwind willreturn }
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 = { "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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"branch_weights", i32 1, i32 1048575}
!14 = distinct !{!14, !10}


; 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 [33 x i8], align 1
@.str.1 = 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 = alloca [64 x { float, float }], align 16
  br label %2

2:                                                ; preds = %0, %2
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %2 ]
  %3 = trunc nuw nsw i64 %indvars.iv to i32
  %4 = uitofp nneg i32 %3 to float
  %.sroa.05.4.vec.insert = insertelement <2 x float> <float 0.000000e+00, float poison>, float %4, i64 1
  %5 = tail call <2 x float> @cexpf(<2 x float> noundef %.sroa.05.4.vec.insert) #5
  %6 = getelementptr inbounds { float, float }, ptr %1, i64 %indvars.iv
  store <2 x float> %5, ptr %6, align 8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 64
  br i1 %exitcond.not, label %.preheader, label %2, !llvm.loop !5

.preheader:                                       ; preds = %2, %22
  %indvars.iv25 = phi i64 [ %indvars.iv.next26, %22 ], [ 0, %2 ]
  %.02022 = phi float [ %24, %22 ], [ 0.000000e+00, %2 ]
  %7 = getelementptr inbounds { float, float }, ptr %1, i64 %indvars.iv25
  %8 = load <2 x float>, ptr %7, align 8
  %9 = extractelement <2 x float> %8, i64 1
  %10 = fneg float %9
  %11 = fmul <2 x float> %8, %8
  %shift = shufflevector <2 x float> %11, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %12 = fadd <2 x float> %11, %shift
  %13 = extractelement <2 x float> %12, i64 0
  %14 = fcmp uno float %13, 0.000000e+00
  br i1 %14, label %15, label %22, !prof !7

15:                                               ; preds = %.preheader
  %16 = extractelement <2 x float> %8, i64 0
  %17 = fmul float %16, %9
  %18 = fsub float %17, %17
  %19 = fcmp uno float %18, 0.000000e+00
  br i1 %19, label %20, label %22, !prof !7

20:                                               ; preds = %15
  %21 = tail call <2 x float> @__mulsc3(float noundef %16, float noundef %9, float noundef %16, float noundef %10) #5
  %.sroa.0.0.vec.extract = extractelement <2 x float> %21, i64 0
  br label %22

22:                                               ; preds = %20, %15, %.preheader
  %23 = phi float [ %13, %.preheader ], [ %13, %15 ], [ %.sroa.0.0.vec.extract, %20 ]
  %24 = fadd float %.02022, %23
  %indvars.iv.next26 = add nuw nsw i64 %indvars.iv25, 1
  %exitcond28.not = icmp eq i64 %indvars.iv.next26, 64
  br i1 %exitcond28.not, label %25, label %.preheader, !llvm.loop !8

25:                                               ; preds = %22
  %26 = tail call float @sqrtf(float noundef %24) #5
  %27 = call float @liquid_vectorcf_norm(ptr noundef nonnull %1, i32 noundef 64) #5
  %28 = fpext float %27 to double
  %29 = fpext float %26 to double
  %30 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, double noundef %28, double noundef %29)
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  ret i32 0
}

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

declare <2 x float> @__mulsc3(float, float, float, float) local_unnamed_addr

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

declare float @liquid_vectorcf_norm(ptr noundef, i32 noundef) local_unnamed_addr #3

; 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 = { 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 #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 = { "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 = !{!"branch_weights", i32 1, i32 1048575}
!8 = distinct !{!8, !6}


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