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

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

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

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

9:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  %10 = call noundef double @_ZNK4Ubpa5Timer10GetCurTimeEv(ptr noundef nonnull align 8 dereferenceable(112) %6)
  store double %10, ptr %4, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %11 = load double, ptr %4, align 8, !tbaa !19
  %12 = getelementptr inbounds %"class.Ubpa::Timer", ptr %6, i32 0, i32 3
  %13 = load double, ptr %12, align 8, !tbaa !20
  %14 = fsub double %11, %13
  store double %14, ptr %5, align 8, !tbaa !19
  %15 = load double, ptr %5, align 8, !tbaa !19
  %16 = getelementptr inbounds %"class.Ubpa::Timer", ptr %6, i32 0, i32 4
  %17 = load double, ptr %16, align 8, !tbaa !21
  %18 = fadd double %17, %15
  store double %18, ptr %16, align 8, !tbaa !21
  %19 = load double, ptr %5, align 8, !tbaa !19
  %20 = getelementptr inbounds %"class.Ubpa::Timer", ptr %6, i32 0, i32 1
  %21 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIdSaIdEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %20) #3
  %22 = load double, ptr %21, align 8, !tbaa !19
  %23 = fadd double %22, %19
  store double %23, ptr %21, align 8, !tbaa !19
  %24 = getelementptr inbounds %"class.Ubpa::Timer", ptr %6, i32 0, i32 0
  store i32 2, ptr %24, align 8, !tbaa !9
  store i1 true, ptr %2, align 1
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %26

25:                                               ; preds = %1
  store i1 false, ptr %2, align 1
  br label %26

26:                                               ; preds = %25, %9
  %27 = load i1, ptr %2, align 1
  ret i1 %27
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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" }
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}


; 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 nounwind uwtable
declare dso_local noundef double @_ZNK4Ubpa5Timer10GetCurTimeEv(ptr noundef nonnull align 8 dereferenceable(112)) local_unnamed_addr #0 align 2

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

3:                                                ; preds = %1
  %4 = tail call noundef double @_ZNK4Ubpa5Timer10GetCurTimeEv(ptr noundef nonnull align 8 dereferenceable(112) %0)
  %5 = getelementptr inbounds i8, ptr %0, i64 96
  %6 = load double, ptr %5, align 8, !tbaa !18
  %7 = fsub double %4, %6
  %8 = getelementptr inbounds i8, ptr %0, i64 104
  %9 = load double, ptr %8, align 8, !tbaa !19
  %10 = fadd double %9, %7
  store double %10, ptr %8, align 8, !tbaa !19
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIdSaIdEE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %11) #1
  %13 = load double, ptr %12, align 8, !tbaa !20
  %14 = fadd double %7, %13
  store double %14, ptr %12, align 8, !tbaa !20
  store i32 2, ptr %0, align 8, !tbaa !5
  br label %15

15:                                               ; preds = %1, %3
  ret i1 %cond
}

; 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 #0 align 2

attributes #0 = { 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 #1 = { 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}


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