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

; 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.RampGenerator = type { float, i32, float, float, float, float, float }

; Function Attrs: nounwind uwtable
define dso_local void @rampSet(ptr noundef %0, float noundef %1, float noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store float %2, ptr %6, align 4, !tbaa !9
  %7 = load float, ptr %5, align 4, !tbaa !9
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.RampGenerator, ptr %8, i32 0, i32 0
  store float %7, ptr %9, align 4, !tbaa !11
  %10 = load float, ptr %6, align 4, !tbaa !9
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.RampGenerator, ptr %11, i32 0, i32 2
  store float %10, ptr %12, align 4, !tbaa !14
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.RampGenerator, ptr %13, i32 0, i32 4
  %15 = load float, ptr %14, align 4, !tbaa !15
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.RampGenerator, ptr %16, i32 0, i32 3
  store float %15, ptr %17, align 4, !tbaa !16
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.RampGenerator, ptr %18, i32 0, i32 0
  %20 = load float, ptr %19, align 4, !tbaa !11
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.RampGenerator, ptr %21, i32 0, i32 6
  %23 = load float, ptr %22, align 4, !tbaa !17
  %24 = fdiv float %20, %23
  %25 = call float @llvm.round.f32(float %24)
  %26 = fptoui float %25 to i32
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.RampGenerator, ptr %27, i32 0, i32 1
  store i32 %26, ptr %28, align 4, !tbaa !18
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.RampGenerator, ptr %29, i32 0, i32 6
  %31 = load float, ptr %30, align 4, !tbaa !17
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.RampGenerator, ptr %32, i32 0, i32 0
  %34 = load float, ptr %33, align 4, !tbaa !11
  %35 = fdiv float %31, %34
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.RampGenerator, ptr %36, i32 0, i32 2
  %38 = load float, ptr %37, align 4, !tbaa !14
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.RampGenerator, ptr %39, i32 0, i32 3
  %41 = load float, ptr %40, align 4, !tbaa !16
  %42 = fsub float %38, %41
  %43 = fmul float %35, %42
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.RampGenerator, ptr %44, i32 0, i32 5
  store float %43, ptr %45, align 4, !tbaa !19
  ret void
}

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

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 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 = !{!"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, !10, i64 0}
!12 = !{!"", !10, i64 0, !13, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !10, i64 8}
!15 = !{!12, !10, i64 16}
!16 = !{!12, !10, i64 12}
!17 = !{!12, !10, i64 24}
!18 = !{!12, !13, i64 4}
!19 = !{!12, !10, i64 20}


; 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 nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @rampSet(ptr nocapture noundef %0, float noundef %1, float noundef %2) local_unnamed_addr #0 {
  store float %1, ptr %0, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  store float %2, ptr %4, align 4, !tbaa !11
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load float, ptr %5, align 4, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %0, i64 12
  store float %6, ptr %7, align 4, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load float, ptr %8, align 4, !tbaa !14
  %10 = fdiv float %1, %9
  %11 = tail call float @llvm.round.f32(float %10)
  %12 = fptoui float %11 to i32
  %13 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %12, ptr %13, align 4, !tbaa !15
  %14 = fdiv float %9, %1
  %15 = fsub float %2, %6
  %16 = fmul float %15, %14
  %17 = getelementptr inbounds i8, ptr %0, i64 20
  store float %16, ptr %17, align 4, !tbaa !16
  ret void
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !10, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 8}
!12 = !{!6, !7, i64 16}
!13 = !{!6, !7, i64 12}
!14 = !{!6, !7, i64 24}
!15 = !{!6, !10, i64 4}
!16 = !{!6, !7, i64 20}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass