; LLVM IR from goldest-star/seawave-animation :: src/vcl/interaction/time_slider/time_slider.ll (ZN3vcl11time_slider6updateEv)

; 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.vcl::time_slider" = type { float, float, float, i8, float, i8, i8, float }

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

declare double @glfwGetTime() #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) #0

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

11:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %12 = call double @glfwGetTime()
  %13 = fptrunc double %12 to float
  store float %13, ptr %3, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %14 = load float, ptr %3, align 4, !tbaa !15
  %15 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 7
  %16 = load float, ptr %15, align 4, !tbaa !16
  %17 = fsub float %14, %16
  store float %17, ptr %4, align 4, !tbaa !15
  %18 = load float, ptr %3, align 4, !tbaa !15
  %19 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 7
  store float %18, ptr %19, align 4, !tbaa !16
  %20 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 3
  %21 = load i8, ptr %20, align 4, !tbaa !17, !range !13, !noundef !14
  %22 = trunc i8 %21 to i1
  br i1 %22, label %45, label %23

23:                                               ; preds = %11
  %24 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 4
  %25 = load float, ptr %24, align 4, !tbaa !18
  %26 = load float, ptr %4, align 4, !tbaa !15
  %27 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 2
  %28 = load float, ptr %27, align 4, !tbaa !19
  %29 = call float @llvm.fmuladd.f32(float %25, float %26, float %28)
  store float %29, ptr %27, align 4, !tbaa !19
  %30 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 2
  %31 = load float, ptr %30, align 4, !tbaa !19
  %32 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 1
  %33 = load float, ptr %32, align 4, !tbaa !20
  %34 = fcmp ogt float %31, %33
  br i1 %34, label %35, label %44

35:                                               ; preds = %23
  %36 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 1
  %37 = load float, ptr %36, align 4, !tbaa !20
  %38 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 0
  %39 = load float, ptr %38, align 4, !tbaa !21
  %40 = fsub float %37, %39
  %41 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 2
  %42 = load float, ptr %41, align 4, !tbaa !19
  %43 = fsub float %42, %40
  store float %43, ptr %41, align 4, !tbaa !19
  br label %44

44:                                               ; preds = %35, %23
  br label %87

45:                                               ; preds = %11
  %46 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 6
  %47 = load i8, ptr %46, align 1, !tbaa !22, !range !13, !noundef !14
  %48 = trunc i8 %47 to i1
  br i1 %48, label %56, label %49

49:                                               ; preds = %45
  %50 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 4
  %51 = load float, ptr %50, align 4, !tbaa !18
  %52 = load float, ptr %4, align 4, !tbaa !15
  %53 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 2
  %54 = load float, ptr %53, align 4, !tbaa !19
  %55 = call float @llvm.fmuladd.f32(float %51, float %52, float %54)
  store float %55, ptr %53, align 4, !tbaa !19
  br label %64

56:                                               ; preds = %45
  %57 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 4
  %58 = load float, ptr %57, align 4, !tbaa !18
  %59 = load float, ptr %4, align 4, !tbaa !15
  %60 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 2
  %61 = load float, ptr %60, align 4, !tbaa !19
  %62 = fneg float %58
  %63 = call float @llvm.fmuladd.f32(float %62, float %59, float %61)
  store float %63, ptr %60, align 4, !tbaa !19
  br label %64

64:                                               ; preds = %56, %49
  %65 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 2
  %66 = load float, ptr %65, align 4, !tbaa !19
  %67 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 1
  %68 = load float, ptr %67, align 4, !tbaa !20
  %69 = fcmp oge float %66, %68
  br i1 %69, label %70, label %75

70:                                               ; preds = %64
  %71 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 1
  %72 = load float, ptr %71, align 4, !tbaa !20
  %73 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 2
  store float %72, ptr %73, align 4, !tbaa !19
  %74 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 6
  store i8 1, ptr %74, align 1, !tbaa !22
  br label %75

75:                                               ; preds = %70, %64
  %76 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 2
  %77 = load float, ptr %76, align 4, !tbaa !19
  %78 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 0
  %79 = load float, ptr %78, align 4, !tbaa !21
  %80 = fcmp ole float %77, %79
  br i1 %80, label %81, label %86

81:                                               ; preds = %75
  %82 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 0
  %83 = load float, ptr %82, align 4, !tbaa !21
  %84 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 2
  store float %83, ptr %84, align 4, !tbaa !19
  %85 = getelementptr inbounds %"class.vcl::time_slider", ptr %5, i32 0, i32 6
  store i8 0, ptr %85, align 1, !tbaa !22
  br label %86

86:                                               ; preds = %81, %75
  br label %87

87:                                               ; preds = %86, %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %88

88:                                               ; preds = %87, %1
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 speculatable willreturn memory(none) }
attributes #3 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !12, i64 20}
!10 = !{!"_ZTSN3vcl11time_sliderE", !11, i64 0, !11, i64 4, !11, i64 8, !12, i64 12, !11, i64 16, !12, i64 20, !12, i64 21, !11, i64 24}
!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 24}
!17 = !{!10, !12, i64 12}
!18 = !{!10, !11, i64 16}
!19 = !{!10, !11, i64 8}
!20 = !{!10, !11, i64 4}
!21 = !{!10, !11, i64 0}
!22 = !{!10, !12, i64 21}


; 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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3vcl11time_slider6updateEv(ptr nocapture noundef nonnull align 4 dereferenceable(28) %0) local_unnamed_addr #2 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 20
  %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 %47

5:                                                ; preds = %1
  %6 = tail call double @glfwGetTime()
  %7 = fptrunc double %6 to float
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load float, ptr %8, align 4, !tbaa !13
  %10 = fsub float %7, %9
  store float %7, ptr %8, align 4, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %0, i64 12
  %12 = load i8, ptr %11, align 4, !tbaa !14, !range !11, !noundef !12
  %13 = trunc nuw i8 %12 to i1
  br i1 %13, label %27, label %14

14:                                               ; preds = %5
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %16 = load float, ptr %15, align 4, !tbaa !15
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = load float, ptr %17, align 4, !tbaa !16
  %19 = tail call float @llvm.fmuladd.f32(float %16, float %10, float %18)
  store float %19, ptr %17, align 4, !tbaa !16
  %20 = getelementptr inbounds i8, ptr %0, i64 4
  %21 = load float, ptr %20, align 4, !tbaa !17
  %22 = fcmp ogt float %19, %21
  br i1 %22, label %23, label %47

23:                                               ; preds = %14
  %24 = load float, ptr %0, align 4, !tbaa !18
  %25 = fsub float %21, %24
  %26 = fsub float %19, %25
  store float %26, ptr %17, align 4, !tbaa !16
  br label %47

27:                                               ; preds = %5
  %28 = getelementptr inbounds i8, ptr %0, i64 21
  %29 = load i8, ptr %28, align 1, !tbaa !19, !range !11, !noundef !12
  %30 = trunc nuw i8 %29 to i1
  %31 = getelementptr inbounds i8, ptr %0, i64 16
  %32 = load float, ptr %31, align 4, !tbaa !15
  %33 = getelementptr inbounds i8, ptr %0, i64 8
  %34 = load float, ptr %33, align 4, !tbaa !16
  %35 = fneg float %32
  %.sink9 = select i1 %30, float %35, float %32
  %36 = tail call float @llvm.fmuladd.f32(float %.sink9, float %10, float %34)
  store float %36, ptr %33, align 4, !tbaa !16
  %37 = getelementptr inbounds i8, ptr %0, i64 8
  %38 = getelementptr inbounds i8, ptr %0, i64 4
  %39 = load float, ptr %38, align 4, !tbaa !17
  %40 = fcmp ult float %36, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %27
  store float %39, ptr %37, align 4, !tbaa !16
  store i8 1, ptr %28, align 1, !tbaa !19
  br label %42

42:                                               ; preds = %41, %27
  %43 = phi float [ %39, %41 ], [ %36, %27 ]
  %44 = load float, ptr %0, align 4, !tbaa !18
  %45 = fcmp ugt float %43, %44
  br i1 %45, label %47, label %46

46:                                               ; preds = %42
  store float %44, ptr %37, align 4, !tbaa !16
  store i8 0, ptr %28, align 1, !tbaa !19
  br label %47

47:                                               ; preds = %23, %14, %46, %42, %1
  ret void
}

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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 20}
!6 = !{!"_ZTSN3vcl11time_sliderE", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 12, !7, i64 16, !10, i64 20, !10, i64 21, !7, i64 24}
!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 24}
!14 = !{!6, !10, i64 12}
!15 = !{!6, !7, i64 16}
!16 = !{!6, !7, i64 8}
!17 = !{!6, !7, i64 4}
!18 = !{!6, !7, i64 0}
!19 = !{!6, !10, i64 21}


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