; LLVM IR from Ubpa/USTC_CG :: Homeworks/4_MinSurfMeshPara/project/src/Basic/Timer.ll (ZN4Ubpa5Timer3LogEv)

; 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.Ubpa::Timer" = type { i32, %"class.std::deque", i64, double, double }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<double, std::allocator<double>>::_Deque_impl" }
%"struct.std::_Deque_base<double, std::allocator<double>>::_Deque_impl" = type { %"struct.std::_Deque_base<double, std::allocator<double>>::_Deque_impl_data" }
%"struct.std::_Deque_base<double, std::allocator<double>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt5dequeIdSaIdEE10push_frontEOd(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK4Ubpa5Timer10GetCurTimeEv(ptr noundef nonnull align 8 dereferenceable(112)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIdSaIdEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN4Ubpa5Timer3LogEv(ptr noundef nonnull align 8 dereferenceable(112) %0) #0 align 2 {
  %2 = alloca double, align 8
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8
  %8 = getelementptr inbounds %"class.Ubpa::Timer", ptr %7, i32 0, i32 0
  %9 = load i32, ptr %8, align 8, !tbaa !9
  switch i32 %9, label %37 [
    i32 1, label %10
  ]

10:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %11 = call noundef double @_ZNK4Ubpa5Timer10GetCurTimeEv(ptr noundef nonnull align 8 dereferenceable(112) %7)
  store double %11, ptr %4, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %12 = load double, ptr %4, align 8, !tbaa !19
  %13 = getelementptr inbounds %"class.Ubpa::Timer", ptr %7, i32 0, i32 3
  %14 = load double, ptr %13, align 8, !tbaa !20
  %15 = fsub double %12, %14
  store double %15, ptr %5, align 8, !tbaa !19
  %16 = load double, ptr %5, align 8, !tbaa !19
  %17 = getelementptr inbounds %"class.Ubpa::Timer", ptr %7, i32 0, i32 4
  %18 = load double, ptr %17, align 8, !tbaa !21
  %19 = fadd double %18, %16
  store double %19, ptr %17, align 8, !tbaa !21
  %20 = load double, ptr %5, align 8, !tbaa !19
  %21 = getelementptr inbounds %"class.Ubpa::Timer", ptr %7, i32 0, i32 1
  %22 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIdSaIdEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %21) #3
  %23 = load double, ptr %22, align 8, !tbaa !19
  %24 = fadd double %23, %20
  store double %24, ptr %22, align 8, !tbaa !19
  %25 = getelementptr inbounds %"class.Ubpa::Timer", ptr %7, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store double 0.000000e+00, ptr %6, align 8, !tbaa !19
  call void @_ZNSt5dequeIdSaIdEE10push_frontEOd(ptr noundef nonnull align 8 dereferenceable(80) %25, ptr noundef nonnull align 8 dereferenceable(8) %6)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %26 = getelementptr inbounds %"class.Ubpa::Timer", ptr %7, i32 0, i32 1
  %27 = call noundef i64 @_ZNKSt5dequeIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) %26) #3
  %28 = getelementptr inbounds %"class.Ubpa::Timer", ptr %7, i32 0, i32 2
  %29 = load i64, ptr %28, align 8, !tbaa !22
  %30 = icmp ugt i64 %27, %29
  br i1 %30, label %31, label %33

31:                                               ; preds = %10
  %32 = getelementptr inbounds %"class.Ubpa::Timer", ptr %7, i32 0, i32 1
  call void @_ZNSt5dequeIdSaIdEE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(80) %32) #3
  br label %33

33:                                               ; preds = %31, %10
  %34 = load double, ptr %4, align 8, !tbaa !19
  %35 = getelementptr inbounds %"class.Ubpa::Timer", ptr %7, i32 0, i32 3
  store double %34, ptr %35, align 8, !tbaa !20
  %36 = load double, ptr %5, align 8, !tbaa !19
  store double %36, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %38

37:                                               ; preds = %1
  store double -1.000000e+00, ptr %2, align 8
  br label %38

38:                                               ; preds = %37, %33
  %39 = load double, ptr %2, align 8
  ret double %39
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt5dequeIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5dequeIdSaIdEE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(80)) #2 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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, !11, i64 0}
!10 = !{!"_ZTSN4Ubpa5TimerE", !11, i64 0, !12, i64 8, !16, i64 88, !18, i64 96, !18, i64 104}
!11 = !{!"_ZTSN4Ubpa5Timer10ENUM_STATEE", !7, i64 0}
!12 = !{!"_ZTSSt5dequeIdSaIdEE", !13, i64 0}
!13 = !{!"_ZTSSt11_Deque_baseIdSaIdEE", !14, i64 0}
!14 = !{!"_ZTSNSt11_Deque_baseIdSaIdEE11_Deque_implE", !15, i64 0}
!15 = !{!"_ZTSNSt11_Deque_baseIdSaIdEE16_Deque_impl_dataE", !6, i64 0, !16, i64 8, !17, i64 16, !17, i64 48}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTSSt15_Deque_iteratorIdRdPdE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!18 = !{!"double", !7, i64 0}
!19 = !{!18, !18, i64 0}
!20 = !{!10, !18, i64 96}
!21 = !{!10, !18, i64 104}
!22 = !{!10, !16, i64 88}


; 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
declare dso_local void @_ZNSt5dequeIdSaIdEE10push_frontEOd(ptr noundef nonnull align 8 dereferenceable(80), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef double @_ZNK4Ubpa5Timer10GetCurTimeEv(ptr noundef nonnull align 8 dereferenceable(112)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIdSaIdEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN4Ubpa5Timer3LogEv(ptr noundef nonnull align 8 dereferenceable(112) %0) local_unnamed_addr #0 align 2 {
  %2 = alloca double, align 8
  %3 = load i32, ptr %0, align 8, !tbaa !5
  %cond = icmp eq i32 %3, 1
  br i1 %cond, label %4, label %22

4:                                                ; preds = %1
  %5 = tail call noundef double @_ZNK4Ubpa5Timer10GetCurTimeEv(ptr noundef nonnull align 8 dereferenceable(112) %0)
  %6 = getelementptr inbounds i8, ptr %0, i64 96
  %7 = load double, ptr %6, align 8, !tbaa !18
  %8 = fsub double %5, %7
  %9 = getelementptr inbounds i8, ptr %0, i64 104
  %10 = load double, ptr %9, align 8, !tbaa !19
  %11 = fadd double %10, %8
  store double %11, ptr %9, align 8, !tbaa !19
  %12 = getelementptr inbounds i8, ptr %0, i64 8
  %13 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIdSaIdEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %12) #3
  %14 = load double, ptr %13, align 8, !tbaa !20
  %15 = fadd double %8, %14
  store double %15, ptr %13, align 8, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  store double 0.000000e+00, ptr %2, align 8, !tbaa !20
  call void @_ZNSt5dequeIdSaIdEE10push_frontEOd(ptr noundef nonnull align 8 dereferenceable(80) %12, ptr noundef nonnull align 8 dereferenceable(8) %2)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  %16 = call noundef i64 @_ZNKSt5dequeIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) %12) #3
  %17 = getelementptr inbounds i8, ptr %0, i64 88
  %18 = load i64, ptr %17, align 8, !tbaa !21
  %19 = icmp ugt i64 %16, %18
  br i1 %19, label %20, label %21

20:                                               ; preds = %4
  call void @_ZNSt5dequeIdSaIdEE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(80) %12) #3
  br label %21

21:                                               ; preds = %20, %4
  store double %5, ptr %6, align 8, !tbaa !18
  br label %22

22:                                               ; preds = %1, %21
  %.0 = phi double [ %8, %21 ], [ -1.000000e+00, %1 ]
  ret double %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt5dequeIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5dequeIdSaIdEE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #2 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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, !7, i64 0}
!6 = !{!"_ZTSN4Ubpa5TimerE", !7, i64 0, !10, i64 8, !15, i64 88, !17, i64 96, !17, i64 104}
!7 = !{!"_ZTSN4Ubpa5Timer10ENUM_STATEE", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt5dequeIdSaIdEE", !11, i64 0}
!11 = !{!"_ZTSSt11_Deque_baseIdSaIdEE", !12, i64 0}
!12 = !{!"_ZTSNSt11_Deque_baseIdSaIdEE11_Deque_implE", !13, i64 0}
!13 = !{!"_ZTSNSt11_Deque_baseIdSaIdEE16_Deque_impl_dataE", !14, i64 0, !15, i64 8, !16, i64 16, !16, i64 48}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"long", !8, i64 0}
!16 = !{!"_ZTSSt15_Deque_iteratorIdRdPdE", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!17 = !{!"double", !8, i64 0}
!18 = !{!6, !17, i64 96}
!19 = !{!6, !17, i64 104}
!20 = !{!17, !17, i64 0}
!21 = !{!6, !15, i64 88}


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