; LLVM IR from shupx/swarm_sync_sim :: src/px4_rotor_sim/src/mavros_px4_quadrotor_sim/px4_modules/mc_pos_control/Takeof_abf8f277 (ZN7Takeoff10updateRampEff)

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

%class.Takeoff = type { i32, [4 x i8], %"class.systemlib::Hysteresis", float, float, float, [4 x i8] }
%"class.systemlib::Hysteresis" = type <{ i64, i64, i64, i8, i8, [6 x i8] }>

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef float @_ZN7Takeoff10updateRampEff(ptr noundef nonnull align 8 dereferenceable(52) %0, float noundef %1, float noundef %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = 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
  %8 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %9 = load float, ptr %6, align 4, !tbaa !9
  store float %9, ptr %7, align 4, !tbaa !9
  %10 = getelementptr inbounds %class.Takeoff, ptr %8, i32 0, i32 0
  %11 = load i32, ptr %10, align 8, !tbaa !11
  %12 = icmp slt i32 %11, 4
  br i1 %12, label %13, label %16

13:                                               ; preds = %3
  %14 = getelementptr inbounds %class.Takeoff, ptr %8, i32 0, i32 4
  %15 = load float, ptr %14, align 4, !tbaa !17
  store float %15, ptr %7, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %13, %3
  %17 = getelementptr inbounds %class.Takeoff, ptr %8, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !11
  %19 = icmp eq i32 %18, 4
  br i1 %19, label %20, label %50

20:                                               ; preds = %16
  %21 = getelementptr inbounds %class.Takeoff, ptr %8, i32 0, i32 3
  %22 = load float, ptr %21, align 8, !tbaa !18
  %23 = load float, ptr %5, align 4, !tbaa !9
  %24 = fcmp ogt float %22, %23
  br i1 %24, label %25, label %33

25:                                               ; preds = %20
  %26 = load float, ptr %5, align 4, !tbaa !9
  %27 = getelementptr inbounds %class.Takeoff, ptr %8, i32 0, i32 3
  %28 = load float, ptr %27, align 8, !tbaa !18
  %29 = fdiv float %26, %28
  %30 = getelementptr inbounds %class.Takeoff, ptr %8, i32 0, i32 5
  %31 = load float, ptr %30, align 8, !tbaa !19
  %32 = fadd float %31, %29
  store float %32, ptr %30, align 8, !tbaa !19
  br label %35

33:                                               ; preds = %20
  %34 = getelementptr inbounds %class.Takeoff, ptr %8, i32 0, i32 5
  store float 1.000000e+00, ptr %34, align 8, !tbaa !19
  br label %35

35:                                               ; preds = %33, %25
  %36 = getelementptr inbounds %class.Takeoff, ptr %8, i32 0, i32 5
  %37 = load float, ptr %36, align 8, !tbaa !19
  %38 = fcmp olt float %37, 1.000000e+00
  br i1 %38, label %39, label %49

39:                                               ; preds = %35
  %40 = getelementptr inbounds %class.Takeoff, ptr %8, i32 0, i32 4
  %41 = load float, ptr %40, align 4, !tbaa !17
  %42 = getelementptr inbounds %class.Takeoff, ptr %8, i32 0, i32 5
  %43 = load float, ptr %42, align 8, !tbaa !19
  %44 = load float, ptr %6, align 4, !tbaa !9
  %45 = getelementptr inbounds %class.Takeoff, ptr %8, i32 0, i32 4
  %46 = load float, ptr %45, align 4, !tbaa !17
  %47 = fsub float %44, %46
  %48 = call float @llvm.fmuladd.f32(float %43, float %47, float %41)
  store float %48, ptr %7, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %39, %35
  br label %50

50:                                               ; preds = %49, %16
  %51 = load float, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret float %51
}

; 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

attributes #0 = { mustprogress 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTS7Takeoff", !13, i64 0, !14, i64 8, !10, i64 40, !10, i64 44, !10, i64 48}
!13 = !{!"_ZTS12TakeoffState", !7, i64 0}
!14 = !{!"_ZTSN9systemlib10HysteresisE", !15, i64 0, !15, i64 8, !15, i64 16, !16, i64 24, !16, i64 25}
!15 = !{!"long", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!12, !10, i64 44}
!18 = !{!12, !10, i64 40}
!19 = !{!12, !10, i64 48}


; 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 noundef float @_ZN7Takeoff10updateRampEff(ptr nocapture noundef nonnull align 8 dereferenceable(52) %0, float noundef %1, float noundef %2) local_unnamed_addr #0 align 2 {
  %4 = load i32, ptr %0, align 8, !tbaa !5
  %5 = icmp slt i32 %4, 4
  %6 = getelementptr inbounds i8, ptr %0, i64 44
  %7 = load float, ptr %6, align 4
  %.0 = select i1 %5, float %7, float %2
  %8 = icmp eq i32 %4, 4
  br i1 %8, label %9, label %23

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  %11 = load float, ptr %10, align 8, !tbaa !14
  %12 = fcmp ogt float %11, %1
  br i1 %12, label %14, label %.thread

.thread:                                          ; preds = %9
  %13 = getelementptr inbounds i8, ptr %0, i64 48
  store float 1.000000e+00, ptr %13, align 8, !tbaa !15
  br label %23

14:                                               ; preds = %9
  %15 = fdiv float %1, %11
  %16 = getelementptr inbounds i8, ptr %0, i64 48
  %17 = load float, ptr %16, align 8, !tbaa !15
  %18 = fadd float %15, %17
  store float %18, ptr %16, align 8, !tbaa !15
  %19 = fcmp olt float %18, 1.000000e+00
  br i1 %19, label %20, label %23

20:                                               ; preds = %14
  %21 = fsub float %2, %7
  %22 = tail call float @llvm.fmuladd.f32(float %18, float %21, float %7)
  br label %23

23:                                               ; preds = %.thread, %14, %20, %3
  %.1 = phi float [ %22, %20 ], [ %.0, %14 ], [ %.0, %3 ], [ %.0, %.thread ]
  ret float %.1
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, 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 = !{!"_ZTS7Takeoff", !7, i64 0, !10, i64 8, !13, i64 40, !13, i64 44, !13, i64 48}
!7 = !{!"_ZTS12TakeoffState", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSN9systemlib10HysteresisE", !11, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !12, i64 25}
!11 = !{!"long", !8, i64 0}
!12 = !{!"bool", !8, i64 0}
!13 = !{!"float", !8, i64 0}
!14 = !{!6, !13, i64 40}
!15 = !{!6, !13, i64 48}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass