; LLVM IR from drohmer/cgp :: library/cgp/17_timer/timer_basic/timer_basic.ll (ZN3cgp11timer_basic6updateEv)

; 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_basic" = type { float, float, i8, float }

declare double @glfwGetTime() #0

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN3cgp11timer_basic6updateEv(ptr noundef nonnull align 4 dereferenceable(16) %0) #1 align 2 {
  %2 = alloca float, align 4
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  %7 = getelementptr inbounds %"class.cgp::timer_basic", ptr %6, i32 0, i32 2
  %8 = load i8, ptr %7, align 4, !tbaa !9, !range !13, !noundef !14
  %9 = trunc i8 %8 to i1
  br i1 %9, label %11, label %10

10:                                               ; preds = %1
  store float 0.000000e+00, ptr %2, align 4
  br label %28

11:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %12 = call double @glfwGetTime()
  %13 = fptrunc double %12 to float
  store float %13, ptr %4, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %14 = getelementptr inbounds %"class.cgp::timer_basic", ptr %6, i32 0, i32 1
  %15 = load float, ptr %14, align 4, !tbaa !16
  %16 = load float, ptr %4, align 4, !tbaa !15
  %17 = getelementptr inbounds %"class.cgp::timer_basic", ptr %6, i32 0, i32 3
  %18 = load float, ptr %17, align 4, !tbaa !17
  %19 = fsub float %16, %18
  %20 = fmul float %15, %19
  store float %20, ptr %5, align 4, !tbaa !15
  %21 = load float, ptr %4, align 4, !tbaa !15
  %22 = getelementptr inbounds %"class.cgp::timer_basic", ptr %6, i32 0, i32 3
  store float %21, ptr %22, align 4, !tbaa !17
  %23 = load float, ptr %5, align 4, !tbaa !15
  %24 = getelementptr inbounds %"class.cgp::timer_basic", ptr %6, i32 0, i32 0
  %25 = load float, ptr %24, align 4, !tbaa !18
  %26 = fadd float %25, %23
  store float %26, ptr %24, align 4, !tbaa !18
  %27 = load float, ptr %5, align 4, !tbaa !15
  store float %27, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %28

28:                                               ; preds = %11, %10
  %29 = load float, ptr %2, align 4
  ret float %29
}

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

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

attributes #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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !12, i64 8}
!10 = !{!"_ZTSN3cgp11timer_basicE", !11, i64 0, !11, i64 4, !12, i64 8, !11, i64 12}
!11 = !{!"float", !7, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!11, !11, i64 0}
!16 = !{!10, !11, i64 4}
!17 = !{!10, !11, i64 12}
!18 = !{!10, !11, i64 0}


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

declare double @glfwGetTime() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN3cgp11timer_basic6updateEv(ptr nocapture noundef nonnull align 4 dereferenceable(16) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = load i8, ptr %2, align 4, !tbaa !5, !range !11, !noundef !12
  %4 = trunc nuw i8 %3 to i1
  br i1 %4, label %5, label %16

5:                                                ; preds = %1
  %6 = tail call double @glfwGetTime()
  %7 = fptrunc double %6 to float
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  %9 = load float, ptr %8, align 4, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  %11 = load float, ptr %10, align 4, !tbaa !14
  %12 = fsub float %7, %11
  %13 = fmul float %9, %12
  store float %7, ptr %10, align 4, !tbaa !14
  %14 = load float, ptr %0, align 4, !tbaa !15
  %15 = fadd float %14, %13
  store float %15, ptr %0, align 4, !tbaa !15
  br label %16

16:                                               ; preds = %1, %5
  %.0 = phi float [ %13, %5 ], [ 0.000000e+00, %1 ]
  ret float %.0
}

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

!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, !10, i64 8}
!6 = !{!"_ZTSN3cgp11timer_basicE", !7, i64 0, !7, i64 4, !10, i64 8, !7, i64 12}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!6, !7, i64 4}
!14 = !{!6, !7, i64 12}
!15 = !{!6, !7, i64 0}


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