; LLVM IR from ubaldot/defrecs :: stm32f4x/ADC_Readings/Drivers/CMSIS/DSP/Examples/ARM/arm_dotproduct_example (main)

; 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"

@srcA_buf_f32 = external dso_local global [32 x float], align 16
@srcB_buf_f32 = external dso_local global [32 x float], align 16
@refDotProdOut = external dso_local global float, align 4
@multOutput = external dso_local global [32 x float], align 16
@testOutput = external dso_local global float, align 4
@status = external dso_local global i32, align 4

; 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
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @arm_mult_f32(ptr noundef @srcA_buf_f32, ptr noundef @srcB_buf_f32, ptr noundef @multOutput, i32 noundef 32)
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %4

4:                                                ; preds = %11, %0
  %5 = load i32, ptr %2, align 4, !tbaa !5
  %6 = icmp ult i32 %5, 32
  br i1 %6, label %7, label %14

7:                                                ; preds = %4
  %8 = load i32, ptr %2, align 4, !tbaa !5
  %9 = zext i32 %8 to i64
  %10 = getelementptr inbounds [32 x float], ptr @multOutput, i64 0, i64 %9
  call void @arm_add_f32(ptr noundef @testOutput, ptr noundef %10, ptr noundef @testOutput, i32 noundef 1)
  br label %11

11:                                               ; preds = %7
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = add i32 %12, 1
  store i32 %13, ptr %2, align 4, !tbaa !5
  br label %4, !llvm.loop !9

14:                                               ; preds = %4
  %15 = load float, ptr @refDotProdOut, align 4, !tbaa !11
  %16 = load float, ptr @testOutput, align 4, !tbaa !11
  %17 = fsub float %15, %16
  %18 = call float @llvm.fabs.f32(float %17)
  store float %18, ptr %3, align 4, !tbaa !11
  %19 = load float, ptr %3, align 4, !tbaa !11
  %20 = fcmp ogt float %19, 0x3EB0C6F7A0000000
  %21 = zext i1 %20 to i64
  %22 = select i1 %20, i32 -6, i32 0
  store i32 %22, ptr @status, align 4, !tbaa !5
  %23 = load i32, ptr @status, align 4, !tbaa !5
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %28

25:                                               ; preds = %14
  br label %26

26:                                               ; preds = %27, %25
  br label %27

27:                                               ; preds = %26
  br label %26

28:                                               ; preds = %14
  br label %29

29:                                               ; preds = %30, %28
  br label %30

30:                                               ; preds = %29
  br label %29
}

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

declare void @arm_mult_f32(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #2

declare void @arm_add_f32(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #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 speculatable willreturn memory(none) }
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"}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}


; 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"

@srcA_buf_f32 = external dso_local global [32 x float], align 16
@srcB_buf_f32 = external dso_local global [32 x float], align 16
@refDotProdOut = external dso_local local_unnamed_addr global float, align 4
@multOutput = external dso_local global [32 x float], align 16
@testOutput = external dso_local global float, align 4
@status = external dso_local local_unnamed_addr global i32, align 4

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  tail call void @arm_mult_f32(ptr noundef nonnull @srcA_buf_f32, ptr noundef nonnull @srcB_buf_f32, ptr noundef nonnull @multOutput, i32 noundef 32) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull @multOutput, ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 4), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 8), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 12), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 16), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 20), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 24), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 28), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 32), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 36), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 40), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 44), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 48), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 52), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 56), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 60), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 64), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 68), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 72), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 76), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 80), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 84), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 88), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 92), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 96), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 100), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 104), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 108), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 112), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 116), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 120), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  tail call void @arm_add_f32(ptr noundef nonnull @testOutput, ptr noundef nonnull getelementptr inbounds (i8, ptr @multOutput, i64 124), ptr noundef nonnull @testOutput, i32 noundef 1) #3
  %1 = load float, ptr @refDotProdOut, align 4, !tbaa !5
  %2 = load float, ptr @testOutput, align 4, !tbaa !5
  %3 = fsub float %1, %2
  %4 = tail call float @llvm.fabs.f32(float %3)
  %5 = fcmp ogt float %4, 0x3EB0C6F7A0000000
  %6 = select i1 %5, i32 -6, i32 0
  store i32 %6, ptr @status, align 4, !tbaa !9
  br i1 %5, label %.preheader, label %.preheader3

.preheader:                                       ; preds = %0, %.preheader
  br label %.preheader

.preheader3:                                      ; preds = %0, %.preheader3
  br label %.preheader3
}

declare void @arm_mult_f32(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @arm_add_f32(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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

attributes #0 = { noreturn 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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


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