; LLVM IR from atlantis13579/Riemann :: Test/Test_Vehicle.ll (Z7TestPIDv)

; 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.PID_Controller = type { %struct.PID_Calibration, float, float }
%struct.PID_Calibration = type { float, float, float, float, float, float, float }

@.str = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z7TestPIDv() #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca %class.PID_Controller, align 4
  %2 = alloca float, align 4
  %3 = alloca float, align 4
  %4 = alloca i32, align 4
  %5 = alloca float, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  call void @llvm.lifetime.start.p0(i64 36, ptr %1) #4
  call void @_ZN14PID_ControllerC2Efffffff(ptr noundef nonnull align 4 dereferenceable(36) %1, float noundef 5.000000e-01, float noundef 0x3FB47AE140000000, float noundef 0x3FB99999A0000000, float noundef -1.000000e+01, float noundef 1.000000e+01, float noundef -1.000000e+00, float noundef 1.000000e+00)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store float 0.000000e+00, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store float 1.000000e+00, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %21, %0
  %10 = load i32, ptr %4, align 4, !tbaa !9
  %11 = icmp slt i32 %10, 100
  br i1 %11, label %13, label %12

12:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %28

13:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %14 = load float, ptr %2, align 4, !tbaa !5
  %15 = load float, ptr %3, align 4, !tbaa !5
  %16 = invoke noundef float @_ZN14PID_Controller7ComputeEfff(ptr noundef nonnull align 4 dereferenceable(36) %1, float noundef 0x3FA0E56040000000, float noundef %14, float noundef %15)
          to label %17 unwind label %24

17:                                               ; preds = %13
  store float %16, ptr %5, align 4, !tbaa !5
  %18 = load float, ptr %2, align 4, !tbaa !5
  %19 = load float, ptr %5, align 4, !tbaa !5
  %20 = fadd float %18, %19
  store float %20, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %21

21:                                               ; preds = %17
  %22 = load i32, ptr %4, align 4, !tbaa !9
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %4, align 4, !tbaa !9
  br label %9, !llvm.loop !11

24:                                               ; preds = %13
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %6, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  call void @_ZN14PID_ControllerD2Ev(ptr noundef nonnull align 4 dereferenceable(36) %1) #4
  call void @llvm.lifetime.end.p0(i64 36, ptr %1) #4
  br label %29

28:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  call void @_ZN14PID_ControllerD2Ev(ptr noundef nonnull align 4 dereferenceable(36) %1) #4
  call void @llvm.lifetime.end.p0(i64 36, ptr %1) #4
  ret void

29:                                               ; preds = %24
  %30 = load ptr, ptr %6, align 8
  %31 = load i32, ptr %7, align 4
  %32 = insertvalue { ptr, i32 } poison, ptr %30, 0
  %33 = insertvalue { ptr, i32 } %32, i32 %31, 1
  resume { ptr, i32 } %33
}

declare i32 @printf(ptr noundef, ...) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14PID_ControllerC2Efffffff(ptr noundef nonnull align 4 dereferenceable(36), float noundef, float noundef, float noundef, float noundef, float noundef, float noundef, float noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZN14PID_Controller7ComputeEfff(ptr noundef nonnull align 4 dereferenceable(36), float noundef, float noundef, float noundef) #0 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN14PID_ControllerD2Ev(ptr noundef nonnull align 4 dereferenceable(36)) unnamed_addr #3 align 2

attributes #0 = { mustprogress 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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

%class.PID_Controller = type { %struct.PID_Calibration, float, float }
%struct.PID_Calibration = type { float, float, float, float, float, float, float }

@.str = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_Z7TestPIDv() local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %1 = alloca %class.PID_Controller, align 4
  %2 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %1) #4
  call void @_ZN14PID_ControllerC2Efffffff(ptr noundef nonnull align 4 dereferenceable(36) %1, float noundef 5.000000e-01, float noundef 0x3FB47AE140000000, float noundef 0x3FB99999A0000000, float noundef -1.000000e+01, float noundef 1.000000e+01, float noundef -1.000000e+00, float noundef 1.000000e+00)
  br label %4

3:                                                ; preds = %6
  call void @_ZN14PID_ControllerD2Ev(ptr noundef nonnull align 4 dereferenceable(36) %1) #4
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %1) #4
  ret void

4:                                                ; preds = %0, %6
  %.09 = phi float [ 0.000000e+00, %0 ], [ %7, %6 ]
  %.078 = phi i32 [ 0, %0 ], [ %8, %6 ]
  %5 = invoke noundef float @_ZN14PID_Controller7ComputeEfff(ptr noundef nonnull align 4 dereferenceable(36) %1, float noundef 0x3FA0E56040000000, float noundef %.09, float noundef 1.000000e+00)
          to label %6 unwind label %9

6:                                                ; preds = %4
  %7 = fadd float %.09, %5
  %8 = add nuw nsw i32 %.078, 1
  %exitcond.not = icmp eq i32 %8, 100
  br i1 %exitcond.not, label %3, label %4, !llvm.loop !5

9:                                                ; preds = %4
  %10 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN14PID_ControllerD2Ev(ptr noundef nonnull align 4 dereferenceable(36) %1) #4
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %1) #4
  resume { ptr, i32 } %10
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN14PID_ControllerC2Efffffff(ptr noundef nonnull align 4 dereferenceable(36), float noundef, float noundef, float noundef, float noundef, float noundef, float noundef, float noundef) unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZN14PID_Controller7ComputeEfff(ptr noundef nonnull align 4 dereferenceable(36), float noundef, float noundef, float noundef) local_unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN14PID_ControllerD2Ev(ptr noundef nonnull align 4 dereferenceable(36)) unnamed_addr #3 align 2

attributes #0 = { mustprogress 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 = { nofree 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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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