; LLVM IR from drohmer/cgp :: library/cgp/17_timer/timer_event_periodic (timer_event_periodic)

; 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.cgp::timer_event_periodic" = type { %"class.cgp::timer_basic", i8, float, float }
%"class.cgp::timer_basic" = type { float, float, i8, float }

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN3cgp20timer_event_periodic6updateEv(ptr noundef nonnull align 4 dereferenceable(28) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %5 = call noundef float @_ZN3cgp11timer_basic6updateEv(ptr noundef nonnull align 4 dereferenceable(16) %4)
  store float %5, ptr %3, align 4, !tbaa !9
  %6 = load float, ptr %3, align 4, !tbaa !9
  %7 = getelementptr inbounds %"class.cgp::timer_event_periodic", ptr %4, i32 0, i32 2
  %8 = load float, ptr %7, align 4, !tbaa !11
  %9 = fadd float %8, %6
  store float %9, ptr %7, align 4, !tbaa !11
  %10 = getelementptr inbounds %"class.cgp::timer_event_periodic", ptr %4, i32 0, i32 2
  %11 = load float, ptr %10, align 4, !tbaa !11
  %12 = getelementptr inbounds %"class.cgp::timer_event_periodic", ptr %4, i32 0, i32 3
  %13 = load float, ptr %12, align 4, !tbaa !15
  %14 = fcmp oge float %11, %13
  br i1 %14, label %15, label %30

15:                                               ; preds = %1
  %16 = getelementptr inbounds %"class.cgp::timer_event_periodic", ptr %4, i32 0, i32 3
  %17 = load float, ptr %16, align 4, !tbaa !15
  %18 = getelementptr inbounds %"class.cgp::timer_event_periodic", ptr %4, i32 0, i32 2
  %19 = load float, ptr %18, align 4, !tbaa !11
  %20 = fsub float %19, %17
  store float %20, ptr %18, align 4, !tbaa !11
  %21 = getelementptr inbounds %"class.cgp::timer_event_periodic", ptr %4, i32 0, i32 2
  %22 = load float, ptr %21, align 4, !tbaa !11
  %23 = getelementptr inbounds %"class.cgp::timer_event_periodic", ptr %4, i32 0, i32 3
  %24 = load float, ptr %23, align 4, !tbaa !15
  %25 = fcmp oge float %22, %24
  br i1 %25, label %26, label %28

26:                                               ; preds = %15
  %27 = getelementptr inbounds %"class.cgp::timer_event_periodic", ptr %4, i32 0, i32 2
  store float 0.000000e+00, ptr %27, align 4, !tbaa !11
  br label %28

28:                                               ; preds = %26, %15
  %29 = getelementptr inbounds %"class.cgp::timer_event_periodic", ptr %4, i32 0, i32 1
  store i8 1, ptr %29, align 4, !tbaa !16
  br label %32

30:                                               ; preds = %1
  %31 = getelementptr inbounds %"class.cgp::timer_event_periodic", ptr %4, i32 0, i32 1
  store i8 0, ptr %31, align 4, !tbaa !16
  br label %32

32:                                               ; preds = %30, %28
  %33 = load float, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret float %33
}

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

declare noundef float @_ZN3cgp11timer_basic6updateEv(ptr noundef nonnull align 4 dereferenceable(16)) #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 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 = { "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, !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, !10, i64 20}
!12 = !{!"_ZTSN3cgp20timer_event_periodicE", !13, i64 0, !14, i64 16, !10, i64 20, !10, i64 24}
!13 = !{!"_ZTSN3cgp11timer_basicE", !10, i64 0, !10, i64 4, !14, i64 8, !10, i64 12}
!14 = !{!"bool", !7, i64 0}
!15 = !{!12, !10, i64 24}
!16 = !{!12, !14, i64 16}


; 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 uwtable
define dso_local noundef float @_ZN3cgp20timer_event_periodic6updateEv(ptr noundef nonnull align 4 dereferenceable(28) %0) local_unnamed_addr #0 align 2 {
  %2 = tail call noundef float @_ZN3cgp11timer_basic6updateEv(ptr noundef nonnull align 4 dereferenceable(16) %0)
  %3 = getelementptr inbounds i8, ptr %0, i64 20
  %4 = load float, ptr %3, align 4, !tbaa !5
  %5 = fadd float %2, %4
  store float %5, ptr %3, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load float, ptr %6, align 4, !tbaa !12
  %8 = fcmp ult float %5, %7
  br i1 %8, label %12, label %9

9:                                                ; preds = %1
  %10 = fsub float %5, %7
  %11 = fcmp ult float %10, %7
  %storemerge = select i1 %11, float %10, float 0.000000e+00
  store float %storemerge, ptr %3, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %1, %9
  %.sink = phi i8 [ 1, %9 ], [ 0, %1 ]
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  store i8 %.sink, ptr %13, align 4
  ret float %2
}

declare noundef float @_ZN3cgp11timer_basic6updateEv(ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #1

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

!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, !8, i64 20}
!6 = !{!"_ZTSN3cgp20timer_event_periodicE", !7, i64 0, !11, i64 16, !8, i64 20, !8, i64 24}
!7 = !{!"_ZTSN3cgp11timer_basicE", !8, i64 0, !8, i64 4, !11, i64 8, !8, i64 12}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"bool", !9, i64 0}
!12 = !{!6, !8, i64 24}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass