; LLVM IR from BlueBrain/CoreNeuron :: coreneuron/utils/utils.ll (ZN10coreneuron9nrn_wtimeEv)

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

%"struct.coreneuron::corenrn_parameters" = type { %"struct.coreneuron::corenrn_parameters_data", %"class.std::unique_ptr" }
%"struct.coreneuron::corenrn_parameters_data" = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, double, double, double, double, double, double, double, double, %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.1" }
%"struct.std::_Head_base.1" = type { ptr }
%"struct.coreneuron::mpi_function.3" = type { %"struct.coreneuron::mpi_function_base" }
%"struct.coreneuron::mpi_function_base" = type { ptr, ptr }
%struct.timeval = type { i64, i64 }

@_ZN10coreneuron13corenrn_paramE = external global %"struct.coreneuron::corenrn_parameters", align 8
@_ZN10coreneuron12nrnmpi_wtimeE = external global %"struct.coreneuron::mpi_function.3", align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN10coreneuron9nrn_wtimeEv() #0 {
  %1 = alloca double, align 8
  %2 = alloca %struct.timeval, align 8
  %3 = load i8, ptr getelementptr inbounds (%"struct.coreneuron::corenrn_parameters_data", ptr @_ZN10coreneuron13corenrn_paramE, i32 0, i32 10), align 8, !tbaa !5, !range !17, !noundef !18
  %4 = trunc i8 %3 to i1
  br i1 %4, label %5, label %7

5:                                                ; preds = %0
  %6 = call noundef double @_ZNK10coreneuron12mpi_functionISt17integral_constantIPFdvEXadL_Z17nrnmpi_wtime_implEEEEclIJEEEDaDpOT_(ptr noundef nonnull align 8 dereferenceable(16) @_ZN10coreneuron12nrnmpi_wtimeE)
  store double %6, ptr %1, align 8
  br label %17

7:                                                ; preds = %0
  call void @llvm.lifetime.start.p0(i64 16, ptr %2) #3
  %8 = call i32 @gettimeofday(ptr noundef %2, ptr noundef null) #3
  %9 = getelementptr inbounds %struct.timeval, ptr %2, i32 0, i32 0
  %10 = load i64, ptr %9, align 8, !tbaa !19
  %11 = sitofp i64 %10 to double
  %12 = getelementptr inbounds %struct.timeval, ptr %2, i32 0, i32 1
  %13 = load i64, ptr %12, align 8, !tbaa !21
  %14 = sitofp i64 %13 to double
  %15 = fdiv double %14, 1.000000e+06
  %16 = fadd double %11, %15
  store double %16, ptr %1, align 8
  call void @llvm.lifetime.end.p0(i64 16, ptr %2) #3
  br label %17

17:                                               ; preds = %7, %5
  %18 = load double, ptr %1, align 8
  ret double %18
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZNK10coreneuron12mpi_functionISt17integral_constantIPFdvEXadL_Z17nrnmpi_wtime_implEEEEclIJEEEDaDpOT_(ptr noundef nonnull align 8 dereferenceable(16)) #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: nounwind
declare i32 @gettimeofday(ptr noundef, ptr noundef) #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 = { nounwind "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, !10, i64 40}
!6 = !{!"_ZTSN10coreneuron23corenrn_parameters_dataE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !10, i64 40, !10, i64 41, !10, i64 42, !10, i64 43, !10, i64 44, !10, i64 45, !10, i64 46, !10, i64 47, !10, i64 48, !11, i64 52, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !13, i64 120, !13, i64 152, !13, i64 184, !13, i64 216, !13, i64 248, !13, i64 280, !13, i64 312, !13, i64 344, !13, i64 376}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTSN10coreneuron23corenrn_parameters_data13verbose_levelE", !8, i64 0}
!12 = !{!"double", !8, i64 0}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !14, i64 0, !16, i64 8, !8, i64 16}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !15, i64 0}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!"long", !8, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!20, !16, i64 0}
!20 = !{!"_ZTS7timeval", !16, i64 0, !16, i64 8}
!21 = !{!20, !16, i64 8}


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

%"struct.coreneuron::corenrn_parameters" = type { %"struct.coreneuron::corenrn_parameters_data", %"class.std::unique_ptr" }
%"struct.coreneuron::corenrn_parameters_data" = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i8, i8, i8, i8, i8, i8, i8, i8, i8, i32, double, double, double, double, double, double, double, double, %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.1" }
%"struct.std::_Head_base.1" = type { ptr }
%"struct.coreneuron::mpi_function.3" = type { %"struct.coreneuron::mpi_function_base" }
%"struct.coreneuron::mpi_function_base" = type { ptr, ptr }
%struct.timeval = type { i64, i64 }

@_ZN10coreneuron13corenrn_paramE = external local_unnamed_addr global %"struct.coreneuron::corenrn_parameters", align 8
@_ZN10coreneuron12nrnmpi_wtimeE = external global %"struct.coreneuron::mpi_function.3", align 8

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN10coreneuron9nrn_wtimeEv() local_unnamed_addr #0 {
  %1 = alloca %struct.timeval, align 8
  %2 = load i8, ptr getelementptr inbounds (i8, ptr @_ZN10coreneuron13corenrn_paramE, i64 40), align 8, !tbaa !5, !range !17, !noundef !18
  %3 = trunc nuw i8 %2 to i1
  br i1 %3, label %4, label %6

4:                                                ; preds = %0
  %5 = tail call noundef double @_ZNK10coreneuron12mpi_functionISt17integral_constantIPFdvEXadL_Z17nrnmpi_wtime_implEEEEclIJEEEDaDpOT_(ptr noundef nonnull align 8 dereferenceable(16) @_ZN10coreneuron12nrnmpi_wtimeE)
  br label %15

6:                                                ; preds = %0
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %1) #3
  %7 = call i32 @gettimeofday(ptr noundef nonnull %1, ptr noundef null) #3
  %8 = load i64, ptr %1, align 8, !tbaa !19
  %9 = sitofp i64 %8 to double
  %10 = getelementptr inbounds i8, ptr %1, i64 8
  %11 = load i64, ptr %10, align 8, !tbaa !21
  %12 = sitofp i64 %11 to double
  %13 = fdiv double %12, 1.000000e+06
  %14 = fadd double %13, %9
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %1) #3
  br label %15

15:                                               ; preds = %6, %4
  %.0 = phi double [ %5, %4 ], [ %14, %6 ]
  ret double %.0
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef double @_ZNK10coreneuron12mpi_functionISt17integral_constantIPFdvEXadL_Z17nrnmpi_wtime_implEEEEclIJEEEDaDpOT_(ptr noundef nonnull align 8 dereferenceable(16)) 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: nofree nounwind
declare noundef i32 @gettimeofday(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "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, !10, i64 40}
!6 = !{!"_ZTSN10coreneuron23corenrn_parameters_dataE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !10, i64 40, !10, i64 41, !10, i64 42, !10, i64 43, !10, i64 44, !10, i64 45, !10, i64 46, !10, i64 47, !10, i64 48, !11, i64 52, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !12, i64 112, !13, i64 120, !13, i64 152, !13, i64 184, !13, i64 216, !13, i64 248, !13, i64 280, !13, i64 312, !13, i64 344, !13, i64 376}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTSN10coreneuron23corenrn_parameters_data13verbose_levelE", !8, i64 0}
!12 = !{!"double", !8, i64 0}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !14, i64 0, !16, i64 8, !8, i64 16}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !15, i64 0}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!"long", !8, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!20, !16, i64 0}
!20 = !{!"_ZTS7timeval", !16, i64 0, !16, i64 8}
!21 = !{!20, !16, i64 8}


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