; LLVM IR from ClecioJung/digital-control :: digitalControl (pidClosedLoopResponseProject)

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

%struct.PI_D = type { [3 x float], [3 x float], [3 x float], i8, %struct.Saturator, i8, float, %struct.FirstOrderFilter, float, [8 x float] }
%struct.Saturator = type { float, float }
%struct.FirstOrderFilter = type { float, float, float, [3 x float] }

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nounwind uwtable
declare dso_local void @filterInit(ptr noundef, float noundef, float noundef, float noundef) #2

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

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

; Function Attrs: nounwind uwtable
declare hidden float @square(float noundef) #2

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

; Function Attrs: nounwind uwtable
declare dso_local void @pidDiscreet(ptr noundef, float noundef, float noundef, float noundef, float noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @pidClosedLoopResponseProject(ptr noundef %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4) #2 {
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca float, 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
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca float, align 4
  %19 = alloca float, align 4
  %20 = alloca float, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store float %1, ptr %7, align 4, !tbaa !9
  store float %2, ptr %8, align 4, !tbaa !9
  store float %3, ptr %9, align 4, !tbaa !9
  store float %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store float 1.000000e+01, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %21 = load float, ptr %7, align 4, !tbaa !9
  %22 = fdiv float %21, 1.000000e+02
  %23 = call float @logf(float noundef %22) #4
  %24 = load float, ptr %7, align 4, !tbaa !9
  %25 = fdiv float %24, 1.000000e+02
  %26 = call float @logf(float noundef %25) #4
  %27 = call float @square(float noundef %26)
  %28 = call float @square(float noundef 0x400921FB60000000)
  %29 = fadd float %27, %28
  %30 = call float @sqrtf(float noundef %29) #4
  %31 = fdiv float %23, %30
  %32 = call float @llvm.fabs.f32(float %31)
  store float %32, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %33 = load float, ptr %12, align 4, !tbaa !9
  %34 = load float, ptr %8, align 4, !tbaa !9
  %35 = fmul float %33, %34
  %36 = fpext float %35 to double
  %37 = fdiv double 4.000000e+00, %36
  %38 = fptrunc double %37 to float
  store float %38, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %39 = load float, ptr %12, align 4, !tbaa !9
  %40 = load float, ptr %13, align 4, !tbaa !9
  %41 = fmul float %39, %40
  %42 = call float @llvm.fabs.f32(float %41)
  store float %42, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %43 = load float, ptr %13, align 4, !tbaa !9
  %44 = fpext float %43 to double
  %45 = load float, ptr %12, align 4, !tbaa !9
  %46 = fpext float %45 to double
  %47 = fmul double 2.000000e+00, %46
  %48 = fdiv double %44, %47
  %49 = fptrunc double %48 to float
  store float %49, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %50 = load float, ptr %13, align 4, !tbaa !9
  %51 = call float @square(float noundef %50)
  %52 = fpext float %51 to double
  %53 = load float, ptr %12, align 4, !tbaa !9
  %54 = fpext float %53 to double
  %55 = fmul double 2.000000e+00, %54
  %56 = load float, ptr %13, align 4, !tbaa !9
  %57 = fpext float %56 to double
  %58 = load float, ptr %10, align 4, !tbaa !9
  %59 = fpext float %58 to double
  %60 = fneg double %59
  %61 = call double @llvm.fmuladd.f64(double %55, double %57, double %60)
  %62 = fdiv double %52, %61
  %63 = fptrunc double %62 to float
  store float %63, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %64 = load float, ptr %15, align 4, !tbaa !9
  %65 = load float, ptr %16, align 4, !tbaa !9
  %66 = fmul float %64, %65
  %67 = call float @sqrtf(float noundef %66) #4
  store float %67, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %68 = load float, ptr %17, align 4, !tbaa !9
  %69 = fpext float %68 to double
  %70 = fdiv double 1.000000e+00, %69
  %71 = fptrunc double %70 to float
  store float %71, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %72 = load float, ptr %13, align 4, !tbaa !9
  %73 = fpext float %72 to double
  %74 = load float, ptr %9, align 4, !tbaa !9
  %75 = fpext float %74 to double
  %76 = load float, ptr %12, align 4, !tbaa !9
  %77 = fpext float %76 to double
  %78 = fmul double 2.000000e+00, %77
  %79 = load float, ptr %17, align 4, !tbaa !9
  %80 = fpext float %79 to double
  %81 = load float, ptr %13, align 4, !tbaa !9
  %82 = fpext float %81 to double
  %83 = fneg double %82
  %84 = call double @llvm.fmuladd.f64(double %78, double %80, double %83)
  %85 = fmul double %75, %84
  %86 = fdiv double %73, %85
  %87 = fptrunc double %86 to float
  store float %87, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  %88 = load float, ptr %17, align 4, !tbaa !9
  %89 = load float, ptr %13, align 4, !tbaa !9
  %90 = call float @square(float noundef %89)
  %91 = fdiv float %88, %90
  %92 = fpext float %91 to double
  %93 = load float, ptr %19, align 4, !tbaa !9
  %94 = load float, ptr %9, align 4, !tbaa !9
  %95 = fmul float %93, %94
  %96 = load float, ptr %10, align 4, !tbaa !9
  %97 = fmul float %95, %96
  %98 = fpext float %97 to double
  %99 = fdiv double 1.000000e+00, %98
  %100 = fsub double %92, %99
  %101 = fptrunc double %100 to float
  store float %101, ptr %20, align 4, !tbaa !9
  %102 = load ptr, ptr %6, align 8, !tbaa !5
  %103 = load float, ptr %19, align 4, !tbaa !9
  %104 = load float, ptr %18, align 4, !tbaa !9
  %105 = load float, ptr %20, align 4, !tbaa !9
  call void @pidDiscreet(ptr noundef %102, float noundef %103, float noundef %104, float noundef %105, float noundef 1.000000e+01)
  %106 = load ptr, ptr %6, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.PI_D, ptr %106, i32 0, i32 5
  %108 = load i8, ptr %107, align 4, !tbaa !11, !range !16, !noundef !17
  %109 = trunc i8 %108 to i1
  br i1 %109, label %110, label %119

110:                                              ; preds = %5
  %111 = load ptr, ptr %6, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.PI_D, ptr %111, i32 0, i32 7
  %113 = load float, ptr %14, align 4, !tbaa !9
  %114 = fmul float 1.000000e+01, %113
  %115 = load float, ptr %17, align 4, !tbaa !9
  %116 = load ptr, ptr %6, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.PI_D, ptr %116, i32 0, i32 8
  %118 = load float, ptr %117, align 4, !tbaa !18
  call void @filterInit(ptr noundef %112, float noundef %114, float noundef %115, float noundef %118)
  br label %119

119:                                              ; preds = %110, %5
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { 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 = !{!"any pointer", !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, !13, i64 48}
!12 = !{!"", !7, i64 0, !7, i64 12, !7, i64 24, !13, i64 36, !14, i64 40, !13, i64 48, !10, i64 52, !15, i64 56, !10, i64 80, !7, i64 84}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"", !10, i64 0, !10, i64 4}
!15 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8, !7, i64 12}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!12, !10, i64 80}


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

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

; Function Attrs: nounwind uwtable
declare dso_local void @filterInit(ptr noundef, float noundef, float noundef, float noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
declare hidden float @square(float noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @pidDiscreet(ptr noundef, float noundef, float noundef, float noundef, float noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @pidClosedLoopResponseProject(ptr noundef %0, float noundef %1, float noundef %2, float noundef %3, float noundef %4) local_unnamed_addr #1 {
  %6 = fdiv float %1, 1.000000e+02
  %7 = tail call float @logf(float noundef %6) #3
  %8 = tail call float @logf(float noundef %6) #3
  %9 = tail call float @square(float noundef %8)
  %10 = tail call float @square(float noundef 0x400921FB60000000)
  %11 = fadd float %9, %10
  %12 = tail call float @sqrtf(float noundef %11) #3
  %13 = fdiv float %7, %12
  %14 = tail call float @llvm.fabs.f32(float %13)
  %15 = fmul float %14, %2
  %16 = fdiv float 4.000000e+00, %15
  %17 = fpext float %14 to double
  %18 = fmul double %17, 2.000000e+00
  %19 = tail call float @square(float noundef %16)
  %20 = fpext float %4 to double
  %21 = fneg double %20
  %22 = insertelement <2 x float> poison, float %16, i64 0
  %23 = insertelement <2 x float> %22, float %19, i64 1
  %24 = fpext <2 x float> %23 to <2 x double>
  %25 = extractelement <2 x double> %24, i64 0
  %26 = tail call double @llvm.fmuladd.f64(double %18, double %25, double %21)
  %27 = insertelement <2 x double> poison, double %18, i64 0
  %28 = insertelement <2 x double> %27, double %26, i64 1
  %29 = fdiv <2 x double> %24, %28
  %30 = fptrunc <2 x double> %29 to <2 x float>
  %shift = shufflevector <2 x float> %30, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %31 = fmul <2 x float> %shift, %30
  %32 = extractelement <2 x float> %31, i64 0
  %33 = tail call float @sqrtf(float noundef %32) #3
  %34 = fpext float %33 to double
  %35 = fdiv float 1.000000e+00, %33
  %36 = fpext float %3 to double
  %37 = fneg double %25
  %38 = tail call double @llvm.fmuladd.f64(double %18, double %34, double %37)
  %39 = fmul double %38, %36
  %40 = fdiv double %25, %39
  %41 = fptrunc double %40 to float
  %42 = tail call float @square(float noundef %16)
  %43 = fdiv float %33, %42
  %44 = fpext float %43 to double
  %45 = fmul float %41, %3
  %46 = fmul float %45, %4
  %47 = fpext float %46 to double
  %48 = fdiv double 1.000000e+00, %47
  %49 = fsub double %44, %48
  %50 = fptrunc double %49 to float
  tail call void @pidDiscreet(ptr noundef %0, float noundef %41, float noundef %35, float noundef %50, float noundef 1.000000e+01)
  %51 = getelementptr inbounds i8, ptr %0, i64 48
  %52 = load i8, ptr %51, align 4, !tbaa !5, !range !13, !noundef !14
  %53 = trunc nuw i8 %52 to i1
  br i1 %53, label %54, label %61

54:                                               ; preds = %5
  %55 = fmul float %14, %16
  %56 = tail call float @llvm.fabs.f32(float %55)
  %57 = getelementptr inbounds i8, ptr %0, i64 56
  %58 = fmul float %56, 1.000000e+01
  %59 = getelementptr inbounds i8, ptr %0, i64 80
  %60 = load float, ptr %59, align 4, !tbaa !15
  tail call void @filterInit(ptr noundef nonnull %57, float noundef %58, float noundef %33, float noundef %60)
  br label %61

61:                                               ; preds = %54, %5
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #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 = { 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, !9, i64 48}
!6 = !{!"", !7, i64 0, !7, i64 12, !7, i64 24, !9, i64 36, !10, i64 40, !9, i64 48, !11, i64 52, !12, i64 56, !11, i64 80, !7, i64 84}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"_Bool", !7, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 4}
!11 = !{!"float", !7, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !7, i64 12}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!6, !11, i64 80}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SLPVectorizerPass,SROAPass,TailCallElimPass,VectorCombinePass