; LLVM IR from Samson-Mano/EM_Propogation_simulation :: EM_Propogation_simulation/src/ImGui (implot)

; 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.ImPlotDateTimeSpec = type <{ i32, i32, i8, i8, [2 x i8] }>

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; 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
declare dso_local noundef i32 @_ZN6ImPlot10FormatTimeERK10ImPlotTimePciib(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef, i32 noundef, i32 noundef, i1 noundef zeroext) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6ImPlot10FormatDateERK10ImPlotTimePciib(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef, i32 noundef, i32 noundef, i1 noundef zeroext) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6ImPlot14FormatDateTimeERK10ImPlotTimePci18ImPlotDateTimeSpec(ptr noundef nonnull align 8 dereferenceable(12) %0, ptr noundef %1, i32 noundef %2, i64 %3, i32 %4) #2 {
  %6 = alloca %struct.ImPlotDateTimeSpec, align 4
  %7 = alloca { i64, i32 }, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 0
  store i64 %3, ptr %12, align 4
  %13 = getelementptr inbounds { i64, i32 }, ptr %7, i32 0, i32 1
  store i32 %4, ptr %13, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %7, i64 12, i1 false)
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store i32 %2, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 0, ptr %11, align 4, !tbaa !9
  %14 = getelementptr inbounds %struct.ImPlotDateTimeSpec, ptr %6, i32 0, i32 0
  %15 = load i32, ptr %14, align 4, !tbaa !11
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %29

17:                                               ; preds = %5
  %18 = load ptr, ptr %8, align 8, !tbaa !5
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = load i32, ptr %10, align 4, !tbaa !9
  %21 = getelementptr inbounds %struct.ImPlotDateTimeSpec, ptr %6, i32 0, i32 0
  %22 = load i32, ptr %21, align 4, !tbaa !11
  %23 = getelementptr inbounds %struct.ImPlotDateTimeSpec, ptr %6, i32 0, i32 2
  %24 = load i8, ptr %23, align 4, !tbaa !14, !range !15, !noundef !16
  %25 = trunc i8 %24 to i1
  %26 = call noundef i32 @_ZN6ImPlot10FormatDateERK10ImPlotTimePciib(ptr noundef nonnull align 8 dereferenceable(12) %18, ptr noundef %19, i32 noundef %20, i32 noundef %22, i1 noundef zeroext %25)
  %27 = load i32, ptr %11, align 4, !tbaa !9
  %28 = add nsw i32 %27, %26
  store i32 %28, ptr %11, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %17, %5
  %30 = getelementptr inbounds %struct.ImPlotDateTimeSpec, ptr %6, i32 0, i32 1
  %31 = load i32, ptr %30, align 4, !tbaa !17
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %60

33:                                               ; preds = %29
  %34 = getelementptr inbounds %struct.ImPlotDateTimeSpec, ptr %6, i32 0, i32 0
  %35 = load i32, ptr %34, align 4, !tbaa !11
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %43

37:                                               ; preds = %33
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = load i32, ptr %11, align 4, !tbaa !9
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %11, align 4, !tbaa !9
  %41 = sext i32 %39 to i64
  %42 = getelementptr inbounds i8, ptr %38, i64 %41
  store i8 32, ptr %42, align 1, !tbaa !18
  br label %43

43:                                               ; preds = %37, %33
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = load i32, ptr %11, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds i8, ptr %45, i64 %47
  %49 = load i32, ptr %10, align 4, !tbaa !9
  %50 = load i32, ptr %11, align 4, !tbaa !9
  %51 = sub nsw i32 %49, %50
  %52 = getelementptr inbounds %struct.ImPlotDateTimeSpec, ptr %6, i32 0, i32 1
  %53 = load i32, ptr %52, align 4, !tbaa !17
  %54 = getelementptr inbounds %struct.ImPlotDateTimeSpec, ptr %6, i32 0, i32 3
  %55 = load i8, ptr %54, align 1, !tbaa !19, !range !15, !noundef !16
  %56 = trunc i8 %55 to i1
  %57 = call noundef i32 @_ZN6ImPlot10FormatTimeERK10ImPlotTimePciib(ptr noundef nonnull align 8 dereferenceable(12) %44, ptr noundef %48, i32 noundef %51, i32 noundef %53, i1 noundef zeroext %56)
  %58 = load i32, ptr %11, align 4, !tbaa !9
  %59 = add nsw i32 %58, %57
  store i32 %59, ptr %11, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %43, %29
  %61 = load i32, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  ret i32 %61
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTS18ImPlotDateTimeSpec", !10, i64 0, !10, i64 4, !13, i64 8, !13, i64 9}
!13 = !{!"bool", !7, i64 0}
!14 = !{!12, !13, i64 8}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!12, !10, i64 4}
!18 = !{!7, !7, i64 0}
!19 = !{!12, !13, i64 9}


; 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 noundef i32 @_ZN6ImPlot10FormatTimeERK10ImPlotTimePciib(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef, i32 noundef, i32 noundef, i1 noundef zeroext) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN6ImPlot10FormatDateERK10ImPlotTimePciib(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef, i32 noundef, i32 noundef, i1 noundef zeroext) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN6ImPlot14FormatDateTimeERK10ImPlotTimePci18ImPlotDateTimeSpec(ptr noundef nonnull align 8 dereferenceable(12) %0, ptr noundef %1, i32 noundef %2, i64 %3, i32 %4) local_unnamed_addr #0 {
  %.sroa.012.0.extract.trunc = trunc i64 %3 to i32
  %.sroa.4.0.extract.shift = lshr i64 %3, 32
  %.sroa.4.0.extract.trunc = trunc nuw i64 %.sroa.4.0.extract.shift to i32
  %.not = icmp eq i32 %.sroa.012.0.extract.trunc, 0
  br i1 %.not, label %6, label %.thread

6:                                                ; preds = %5
  %.not16 = icmp ult i64 %3, 4294967296
  br i1 %.not16, label %21, label %13

.thread:                                          ; preds = %5
  %7 = trunc i32 %4 to i1
  %8 = tail call noundef i32 @_ZN6ImPlot10FormatDateERK10ImPlotTimePciib(ptr noundef nonnull align 8 dereferenceable(12) %0, ptr noundef %1, i32 noundef %2, i32 noundef %.sroa.012.0.extract.trunc, i1 noundef zeroext %7)
  %.not1618 = icmp ult i64 %3, 4294967296
  br i1 %.not1618, label %21, label %9

9:                                                ; preds = %.thread
  %10 = add nsw i32 %8, 1
  %11 = sext i32 %8 to i64
  %12 = getelementptr inbounds i8, ptr %1, i64 %11
  store i8 32, ptr %12, align 1, !tbaa !5
  br label %13

13:                                               ; preds = %6, %9
  %.1 = phi i32 [ %10, %9 ], [ 0, %6 ]
  %14 = sext i32 %.1 to i64
  %15 = getelementptr inbounds i8, ptr %1, i64 %14
  %16 = sub nsw i32 %2, %.1
  %17 = and i32 %4, 256
  %18 = icmp ne i32 %17, 0
  %19 = tail call noundef i32 @_ZN6ImPlot10FormatTimeERK10ImPlotTimePciib(ptr noundef nonnull align 8 dereferenceable(12) %0, ptr noundef %15, i32 noundef %16, i32 noundef %.sroa.4.0.extract.trunc, i1 noundef zeroext %18)
  %20 = add nsw i32 %19, %.1
  br label %21

21:                                               ; preds = %.thread, %13, %6
  %.2 = phi i32 [ %20, %13 ], [ 0, %6 ], [ %8, %.thread ]
  ret i32 %.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" }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


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