; LLVM IR from vczh/herodb :: Kernel/Source/Vlpp.ll (ZN2vl8DateTime12FromDateTimeElllllll)

; 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.vl::DateTime" = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 }
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2vl19ConvertTMToDateTimeEP2tml(ptr dead_on_unwind noalias writable sret(%"struct.vl::DateTime") align 8, ptr noundef, i64 noundef) #0

; 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 uwtable
define dso_local void @_ZN2vl8DateTime12FromDateTimeElllllll(ptr dead_on_unwind noalias writable sret(%"struct.vl::DateTime") align 8 %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4, i64 noundef %5, i64 noundef %6, i64 noundef %7) #0 align 2 {
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca %struct.tm, align 8
  store i64 %1, ptr %9, align 8, !tbaa !5
  store i64 %2, ptr %10, align 8, !tbaa !5
  store i64 %3, ptr %11, align 8, !tbaa !5
  store i64 %4, ptr %12, align 8, !tbaa !5
  store i64 %5, ptr %13, align 8, !tbaa !5
  store i64 %6, ptr %14, align 8, !tbaa !5
  store i64 %7, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 56, ptr %16) #3
  call void @llvm.memset.p0.i64(ptr align 8 %16, i8 0, i64 56, i1 false)
  %17 = load i64, ptr %9, align 8, !tbaa !5
  %18 = sub nsw i64 %17, 1900
  %19 = trunc i64 %18 to i32
  %20 = getelementptr inbounds %struct.tm, ptr %16, i32 0, i32 5
  store i32 %19, ptr %20, align 4, !tbaa !9
  %21 = load i64, ptr %10, align 8, !tbaa !5
  %22 = sub nsw i64 %21, 1
  %23 = trunc i64 %22 to i32
  %24 = getelementptr inbounds %struct.tm, ptr %16, i32 0, i32 4
  store i32 %23, ptr %24, align 8, !tbaa !13
  %25 = load i64, ptr %11, align 8, !tbaa !5
  %26 = trunc i64 %25 to i32
  %27 = getelementptr inbounds %struct.tm, ptr %16, i32 0, i32 3
  store i32 %26, ptr %27, align 4, !tbaa !14
  %28 = load i64, ptr %12, align 8, !tbaa !5
  %29 = trunc i64 %28 to i32
  %30 = getelementptr inbounds %struct.tm, ptr %16, i32 0, i32 2
  store i32 %29, ptr %30, align 8, !tbaa !15
  %31 = load i64, ptr %13, align 8, !tbaa !5
  %32 = trunc i64 %31 to i32
  %33 = getelementptr inbounds %struct.tm, ptr %16, i32 0, i32 1
  store i32 %32, ptr %33, align 4, !tbaa !16
  %34 = load i64, ptr %14, align 8, !tbaa !5
  %35 = trunc i64 %34 to i32
  %36 = getelementptr inbounds %struct.tm, ptr %16, i32 0, i32 0
  store i32 %35, ptr %36, align 8, !tbaa !17
  %37 = getelementptr inbounds %struct.tm, ptr %16, i32 0, i32 8
  store i32 -1, ptr %37, align 8, !tbaa !18
  %38 = load i64, ptr %15, align 8, !tbaa !5
  call void @_ZN2vl19ConvertTMToDateTimeEP2tml(ptr dead_on_unwind writable sret(%"struct.vl::DateTime") align 8 %0, ptr noundef %16, i64 noundef %38)
  call void @llvm.lifetime.end.p0(i64 56, ptr %16) #3
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 20}
!10 = !{!"_ZTS2tm", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !6, i64 40, !12, i64 48}
!11 = !{!"int", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!10, !11, i64 16}
!14 = !{!10, !11, i64 12}
!15 = !{!10, !11, i64 8}
!16 = !{!10, !11, i64 4}
!17 = !{!10, !11, i64 0}
!18 = !{!10, !11, i64 32}


; 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.vl::DateTime" = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 }
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2vl19ConvertTMToDateTimeEP2tml(ptr dead_on_unwind noalias writable sret(%"struct.vl::DateTime") align 8, ptr noundef, i64 noundef) local_unnamed_addr #0

; 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 uwtable
define dso_local void @_ZN2vl8DateTime12FromDateTimeElllllll(ptr dead_on_unwind noalias writable sret(%"struct.vl::DateTime") align 8 %0, i64 noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4, i64 noundef %5, i64 noundef %6, i64 noundef %7) local_unnamed_addr #0 align 2 {
  %9 = alloca %struct.tm, align 8
  call void @llvm.lifetime.start.p0(i64 56, ptr nonnull %9) #3
  %10 = getelementptr inbounds i8, ptr %9, i64 24
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(56) %10, i8 0, i64 32, i1 false)
  %11 = trunc i64 %1 to i32
  %12 = add i32 %11, -1900
  %13 = getelementptr inbounds i8, ptr %9, i64 20
  store i32 %12, ptr %13, align 4, !tbaa !5
  %14 = trunc i64 %2 to i32
  %15 = add i32 %14, -1
  %16 = getelementptr inbounds i8, ptr %9, i64 16
  store i32 %15, ptr %16, align 8, !tbaa !12
  %17 = trunc i64 %3 to i32
  %18 = getelementptr inbounds i8, ptr %9, i64 12
  store i32 %17, ptr %18, align 4, !tbaa !13
  %19 = trunc i64 %4 to i32
  %20 = getelementptr inbounds i8, ptr %9, i64 8
  store i32 %19, ptr %20, align 8, !tbaa !14
  %21 = trunc i64 %5 to i32
  %22 = getelementptr inbounds i8, ptr %9, i64 4
  store i32 %21, ptr %22, align 4, !tbaa !15
  %23 = trunc i64 %6 to i32
  store i32 %23, ptr %9, align 8, !tbaa !16
  %24 = getelementptr inbounds i8, ptr %9, i64 32
  store i32 -1, ptr %24, align 8, !tbaa !17
  call void @_ZN2vl19ConvertTMToDateTimeEP2tml(ptr dead_on_unwind writable sret(%"struct.vl::DateTime") align 8 %0, ptr noundef nonnull %9, i64 noundef %7)
  call void @llvm.lifetime.end.p0(i64 56, ptr nonnull %9) #3
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 nocallback nofree nounwind willreturn memory(argmem: write) }
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 20}
!6 = !{!"_ZTS2tm", !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, !10, i64 40, !11, i64 48}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !7, i64 16}
!13 = !{!6, !7, i64 12}
!14 = !{!6, !7, i64 8}
!15 = !{!6, !7, i64 4}
!16 = !{!6, !7, i64 0}
!17 = !{!6, !7, i64 32}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass