; LLVM IR from lfarcaro/ARINC653_ARMV7A_Z7000 :: ARINC653_ARMV7A_Z7000.sw/MEASURE/src/Algorithms (algorithm_lms1)

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

@algorithm_lms1_mu = external dso_local global float, align 4
@ALGORITHM_LMS1_EXECUTE.d = external hidden global [201 x float], align 16
@ALGORITHM_LMS1_EXECUTE.b = external hidden global [21 x float], align 16

; Function Attrs: nounwind uwtable
declare dso_local float @algorithm_lms1(float noundef, float noundef, ptr noundef, i32 noundef, float noundef, float noundef) #0

; 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

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

; Function Attrs: nounwind uwtable
define dso_local void @ALGORITHM_LMS1_EXECUTE() #0 {
  %1 = alloca float, align 4
  %2 = alloca float, align 4
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %6 = call float @algorithm_lms1_sqrt(float noundef 2.000000e+00)
  store float %6, ptr %1, align 4, !tbaa !5
  %7 = call float @algorithm_lms1_sqrt(float noundef 1.200000e+01)
  %8 = fpext float %7 to double
  %9 = fmul double 2.000000e-01, %8
  %10 = fptrunc double %9 to float
  store float %10, ptr %2, align 4, !tbaa !5
  store float 0x3FD41B2F80000000, ptr %3, align 4, !tbaa !5
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %28, %0
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = icmp slt i32 %12, 201
  br i1 %13, label %14, label %31

14:                                               ; preds = %11
  %15 = load float, ptr %1, align 4, !tbaa !5
  %16 = load float, ptr %3, align 4, !tbaa !5
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = sitofp i32 %17 to float
  %19 = fmul float %16, %18
  %20 = call float @algorithm_lms1_sin(float noundef %19)
  %21 = load float, ptr %2, align 4, !tbaa !5
  %22 = call float @algorithm_lms1_gaussian()
  %23 = fmul float %21, %22
  %24 = call float @llvm.fmuladd.f32(float %15, float %20, float %23)
  %25 = load i32, ptr %5, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [201 x float], ptr @ALGORITHM_LMS1_EXECUTE.d, i64 0, i64 %26
  store float %24, ptr %27, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %14
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %5, align 4, !tbaa !9
  br label %11, !llvm.loop !11

31:                                               ; preds = %11
  %32 = load float, ptr @algorithm_lms1_mu, align 4, !tbaa !5
  %33 = fpext float %32 to double
  %34 = fmul double 2.000000e+00, %33
  %35 = fdiv double %34, 2.100000e+01
  %36 = fptrunc double %35 to float
  store float %36, ptr @algorithm_lms1_mu, align 4, !tbaa !5
  store float 0.000000e+00, ptr %4, align 4, !tbaa !5
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %52, %31
  %38 = load i32, ptr %5, align 4, !tbaa !9
  %39 = icmp slt i32 %38, 201
  br i1 %39, label %40, label %55

40:                                               ; preds = %37
  %41 = load float, ptr %4, align 4, !tbaa !5
  %42 = load i32, ptr %5, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [201 x float], ptr @ALGORITHM_LMS1_EXECUTE.d, i64 0, i64 %43
  %45 = load float, ptr %44, align 4, !tbaa !5
  %46 = load float, ptr @algorithm_lms1_mu, align 4, !tbaa !5
  %47 = call float @algorithm_lms1(float noundef %41, float noundef %45, ptr noundef @ALGORITHM_LMS1_EXECUTE.b, i32 noundef 20, float noundef %46, float noundef 0x3F847AE140000000)
  %48 = load i32, ptr %5, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [201 x float], ptr @ALGORITHM_LMS1_EXECUTE.d, i64 0, i64 %49
  %51 = load float, ptr %50, align 4, !tbaa !5
  store float %51, ptr %4, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %40
  %53 = load i32, ptr %5, align 4, !tbaa !9
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %5, align 4, !tbaa !9
  br label %37, !llvm.loop !13

55:                                               ; preds = %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden float @algorithm_lms1_sqrt(float noundef) #0

; Function Attrs: nounwind uwtable
declare hidden float @algorithm_lms1_sin(float noundef) #0

; Function Attrs: nounwind uwtable
declare hidden float @algorithm_lms1_gaussian() #0

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 = { 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}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

@algorithm_lms1_mu = external dso_local local_unnamed_addr global float, align 4
@ALGORITHM_LMS1_EXECUTE.d = external hidden local_unnamed_addr global [201 x float], align 16
@ALGORITHM_LMS1_EXECUTE.b = external hidden global [21 x float], align 16

; Function Attrs: nounwind uwtable
declare dso_local float @algorithm_lms1(float noundef, float noundef, ptr noundef, i32 noundef, float noundef, float noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @ALGORITHM_LMS1_EXECUTE() local_unnamed_addr #0 {
  %1 = tail call float @algorithm_lms1_sqrt(float noundef 2.000000e+00)
  %2 = tail call float @algorithm_lms1_sqrt(float noundef 1.200000e+01)
  %3 = fpext float %2 to double
  %4 = fmul double %3, 2.000000e-01
  %5 = fptrunc double %4 to float
  br label %6

6:                                                ; preds = %0, %6
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %6 ]
  %7 = trunc nuw nsw i64 %indvars.iv to i32
  %8 = uitofp nneg i32 %7 to float
  %9 = fmul float %8, 0x3FD41B2F80000000
  %10 = tail call float @algorithm_lms1_sin(float noundef %9)
  %11 = tail call float @algorithm_lms1_gaussian()
  %12 = fmul float %11, %5
  %13 = tail call float @llvm.fmuladd.f32(float %1, float %10, float %12)
  %14 = getelementptr inbounds [201 x float], ptr @ALGORITHM_LMS1_EXECUTE.d, i64 0, i64 %indvars.iv
  store float %13, ptr %14, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 201
  br i1 %exitcond.not, label %15, label %6, !llvm.loop !9

15:                                               ; preds = %6
  %16 = load float, ptr @algorithm_lms1_mu, align 4, !tbaa !5
  %17 = fpext float %16 to double
  %18 = fmul double %17, 2.000000e+00
  %19 = fdiv double %18, 2.100000e+01
  %20 = fptrunc double %19 to float
  store float %20, ptr @algorithm_lms1_mu, align 4, !tbaa !5
  br label %21

21:                                               ; preds = %15, %21
  %indvars.iv16 = phi i64 [ 0, %15 ], [ %indvars.iv.next17, %21 ]
  %.01113 = phi float [ 0.000000e+00, %15 ], [ %26, %21 ]
  %22 = getelementptr inbounds [201 x float], ptr @ALGORITHM_LMS1_EXECUTE.d, i64 0, i64 %indvars.iv16
  %23 = load float, ptr %22, align 4, !tbaa !5
  %24 = load float, ptr @algorithm_lms1_mu, align 4, !tbaa !5
  %25 = tail call float @algorithm_lms1(float noundef %.01113, float noundef %23, ptr noundef nonnull @ALGORITHM_LMS1_EXECUTE.b, i32 noundef 20, float noundef %24, float noundef 0x3F847AE140000000)
  %26 = load float, ptr %22, align 4, !tbaa !5
  %indvars.iv.next17 = add nuw nsw i64 %indvars.iv16, 1
  %exitcond19.not = icmp eq i64 %indvars.iv.next17, 201
  br i1 %exitcond19.not, label %27, label %21, !llvm.loop !11

27:                                               ; preds = %21
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden float @algorithm_lms1_sqrt(float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden float @algorithm_lms1_sin(float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden float @algorithm_lms1_gaussian() local_unnamed_addr #0

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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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