; LLVM IR from idmillington/cyclone-physics :: src/demos/timing.ll (ZN10TimingData4initEv)

; 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.TimingData = type <{ i32, i32, i32, [4 x i8], i64, i64, i8, [7 x i8], double, float, [4 x i8] }>

@_ZL10timingData = external hidden global ptr, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z10systemTimev() #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN10TimingData8getClockEv() #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z8initTimev() #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10TimingData4initEv() #1 align 2 personality ptr @__gxx_personality_v0 {
  %1 = alloca ptr, align 8
  %2 = alloca i32, align 4
  call void @_Z8initTimev()
  %3 = load ptr, ptr @_ZL10timingData, align 8, !tbaa !5
  %4 = icmp ne ptr %3, null
  br i1 %4, label %12, label %5

5:                                                ; preds = %0
  %6 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 56) #4
  invoke void @_ZN10TimingDataC2Ev(ptr noundef nonnull align 8 dereferenceable(52) %6)
          to label %7 unwind label %8

7:                                                ; preds = %5
  store ptr %6, ptr @_ZL10timingData, align 8, !tbaa !5
  br label %12

8:                                                ; preds = %5
  %9 = landingpad { ptr, i32 }
          cleanup
  %10 = extractvalue { ptr, i32 } %9, 0
  store ptr %10, ptr %1, align 8
  %11 = extractvalue { ptr, i32 } %9, 1
  store i32 %11, ptr %2, align 4
  call void @_ZdlPvm(ptr noundef %6, i64 noundef 56) #5
  br label %31

12:                                               ; preds = %7, %0
  %13 = load ptr, ptr @_ZL10timingData, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.TimingData, ptr %13, i32 0, i32 0
  store i32 0, ptr %14, align 8, !tbaa !9
  %15 = call noundef i32 @_Z10systemTimev()
  %16 = load ptr, ptr @_ZL10timingData, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.TimingData, ptr %16, i32 0, i32 1
  store i32 %15, ptr %17, align 4, !tbaa !16
  %18 = load ptr, ptr @_ZL10timingData, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.TimingData, ptr %18, i32 0, i32 2
  store i32 0, ptr %19, align 8, !tbaa !17
  %20 = call noundef i64 @_ZN10TimingData8getClockEv()
  %21 = load ptr, ptr @_ZL10timingData, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.TimingData, ptr %21, i32 0, i32 4
  store i64 %20, ptr %22, align 8, !tbaa !18
  %23 = load ptr, ptr @_ZL10timingData, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.TimingData, ptr %23, i32 0, i32 5
  store i64 0, ptr %24, align 8, !tbaa !19
  %25 = load ptr, ptr @_ZL10timingData, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.TimingData, ptr %25, i32 0, i32 6
  store i8 0, ptr %26, align 8, !tbaa !20
  %27 = load ptr, ptr @_ZL10timingData, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.TimingData, ptr %27, i32 0, i32 8
  store double 0.000000e+00, ptr %28, align 8, !tbaa !21
  %29 = load ptr, ptr @_ZL10timingData, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.TimingData, ptr %29, i32 0, i32 9
  store float 0.000000e+00, ptr %30, align 8, !tbaa !22
  ret void

31:                                               ; preds = %8
  %32 = load ptr, ptr %1, align 8
  %33 = load i32, ptr %2, align 4
  %34 = insertvalue { ptr, i32 } poison, ptr %32, 0
  %35 = insertvalue { ptr, i32 } %34, i32 %33, 1
  resume { ptr, i32 } %35
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10TimingDataC2Ev(ptr noundef nonnull align 8 dereferenceable(52)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #3

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 = { 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 = { nobuiltin allocsize(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 = { nobuiltin 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 #4 = { builtin allocsize(0) }
attributes #5 = { builtin 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 = !{!"_ZTS10TimingData", !11, i64 0, !11, i64 4, !11, i64 8, !12, i64 16, !12, i64 24, !13, i64 32, !14, i64 40, !15, i64 48}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = !{!10, !11, i64 4}
!17 = !{!10, !11, i64 8}
!18 = !{!10, !12, i64 16}
!19 = !{!10, !12, i64 24}
!20 = !{!10, !13, i64 32}
!21 = !{!10, !14, i64 40}
!22 = !{!10, !15, i64 48}


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

@_ZL10timingData = external hidden local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z10systemTimev() local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN10TimingData8getClockEv() local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z8initTimev() local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10TimingData4initEv() local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_Z8initTimev()
  %1 = load ptr, ptr @_ZL10timingData, align 8, !tbaa !5
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %2, label %4

2:                                                ; preds = %0
  %3 = tail call noalias noundef nonnull dereferenceable(56) ptr @_Znwm(i64 noundef 56) #3
  tail call void @_ZN10TimingDataC2Ev(ptr noundef nonnull align 8 dereferenceable(52) %3)
  store ptr %3, ptr @_ZL10timingData, align 8, !tbaa !5
  br label %4

4:                                                ; preds = %2, %0
  %5 = phi ptr [ %3, %2 ], [ %1, %0 ]
  store i32 0, ptr %5, align 8, !tbaa !9
  %6 = tail call noundef i32 @_Z10systemTimev()
  %7 = load ptr, ptr @_ZL10timingData, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %7, i64 4
  store i32 %6, ptr %8, align 4, !tbaa !16
  %9 = getelementptr inbounds i8, ptr %7, i64 8
  store i32 0, ptr %9, align 8, !tbaa !17
  %10 = tail call noundef i64 @_ZN10TimingData8getClockEv()
  %11 = load ptr, ptr @_ZL10timingData, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 16
  store i64 %10, ptr %12, align 8, !tbaa !18
  %13 = getelementptr inbounds i8, ptr %11, i64 24
  store i64 0, ptr %13, align 8, !tbaa !19
  %14 = getelementptr inbounds i8, ptr %11, i64 32
  store i8 0, ptr %14, align 8, !tbaa !20
  %15 = getelementptr inbounds i8, ptr %11, i64 40
  store double 0.000000e+00, ptr %15, align 8, !tbaa !21
  %16 = getelementptr inbounds i8, ptr %11, i64 48
  store float 0.000000e+00, ptr %16, align 8, !tbaa !22
  ret void
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN10TimingDataC2Ev(ptr noundef nonnull align 8 dereferenceable(52)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

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 = { 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 = { nobuiltin allocsize(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 = { builtin allocsize(0) }

!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 = !{!"_ZTS10TimingData", !11, i64 0, !11, i64 4, !11, i64 8, !12, i64 16, !12, i64 24, !13, i64 32, !14, i64 40, !15, i64 48}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = !{!10, !11, i64 4}
!17 = !{!10, !11, i64 8}
!18 = !{!10, !12, i64 16}
!19 = !{!10, !12, i64 24}
!20 = !{!10, !13, i64 32}
!21 = !{!10, !14, i64 40}
!22 = !{!10, !15, i64 48}


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