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

; 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
define dso_local void @_ZN2vl19ConvertTMToDateTimeEP2tml(ptr dead_on_unwind noalias writable sret(%"struct.vl::DateTime") align 8 %0, ptr noundef %1, i64 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  store i64 %2, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = call i64 @mktime(ptr noundef %7) #3
  store i64 %8, ptr %6, align 8, !tbaa !9
  call void @_ZN2vl8DateTimeC1Ev(ptr noundef nonnull align 8 dereferenceable(80) %0)
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.tm, ptr %9, i32 0, i32 5
  %11 = load i32, ptr %10, align 4, !tbaa !11
  %12 = add nsw i32 %11, 1900
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds %"struct.vl::DateTime", ptr %0, i32 0, i32 0
  store i64 %13, ptr %14, align 8, !tbaa !14
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.tm, ptr %15, i32 0, i32 4
  %17 = load i32, ptr %16, align 8, !tbaa !16
  %18 = add nsw i32 %17, 1
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds %"struct.vl::DateTime", ptr %0, i32 0, i32 1
  store i64 %19, ptr %20, align 8, !tbaa !17
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.tm, ptr %21, i32 0, i32 3
  %23 = load i32, ptr %22, align 4, !tbaa !18
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds %"struct.vl::DateTime", ptr %0, i32 0, i32 3
  store i64 %24, ptr %25, align 8, !tbaa !19
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.tm, ptr %26, i32 0, i32 6
  %28 = load i32, ptr %27, align 8, !tbaa !20
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds %"struct.vl::DateTime", ptr %0, i32 0, i32 2
  store i64 %29, ptr %30, align 8, !tbaa !21
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.tm, ptr %31, i32 0, i32 2
  %33 = load i32, ptr %32, align 8, !tbaa !22
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds %"struct.vl::DateTime", ptr %0, i32 0, i32 4
  store i64 %34, ptr %35, align 8, !tbaa !23
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.tm, ptr %36, i32 0, i32 1
  %38 = load i32, ptr %37, align 4, !tbaa !24
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds %"struct.vl::DateTime", ptr %0, i32 0, i32 5
  store i64 %39, ptr %40, align 8, !tbaa !25
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.tm, ptr %41, i32 0, i32 0
  %43 = load i32, ptr %42, align 8, !tbaa !26
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds %"struct.vl::DateTime", ptr %0, i32 0, i32 6
  store i64 %44, ptr %45, align 8, !tbaa !27
  %46 = load i64, ptr %5, align 8, !tbaa !9
  %47 = getelementptr inbounds %"struct.vl::DateTime", ptr %0, i32 0, i32 7
  store i64 %46, ptr %47, align 8, !tbaa !28
  %48 = load i64, ptr %6, align 8, !tbaa !9
  %49 = mul i64 %48, 1000
  %50 = load i64, ptr %5, align 8, !tbaa !9
  %51 = add i64 %49, %50
  %52 = getelementptr inbounds %"struct.vl::DateTime", ptr %0, i32 0, i32 9
  store i64 %51, ptr %52, align 8, !tbaa !29
  %53 = load i64, ptr %6, align 8, !tbaa !9
  %54 = mul i64 %53, 1000
  %55 = load i64, ptr %5, align 8, !tbaa !9
  %56 = add i64 %54, %55
  %57 = getelementptr inbounds %"struct.vl::DateTime", ptr %0, i32 0, i32 8
  store i64 %56, ptr %57, align 8, !tbaa !30
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  ret void
}

; 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 i64 @mktime(ptr noundef) #2

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

declare void @_ZN2vl8DateTimeC1Ev(ptr)

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, !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 = !{!"long", !7, i64 0}
!11 = !{!12, !13, i64 20}
!12 = !{!"_ZTS2tm", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !10, i64 40, !6, i64 48}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !10, i64 0}
!15 = !{!"_ZTSN2vl8DateTimeE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72}
!16 = !{!12, !13, i64 16}
!17 = !{!15, !10, i64 8}
!18 = !{!12, !13, i64 12}
!19 = !{!15, !10, i64 24}
!20 = !{!12, !13, i64 24}
!21 = !{!15, !10, i64 16}
!22 = !{!12, !13, i64 8}
!23 = !{!15, !10, i64 32}
!24 = !{!12, !13, i64 4}
!25 = !{!15, !10, i64 40}
!26 = !{!12, !13, i64 0}
!27 = !{!15, !10, i64 48}
!28 = !{!15, !10, i64 56}
!29 = !{!15, !10, i64 72}
!30 = !{!15, !10, i64 64}


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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2vl19ConvertTMToDateTimeEP2tml(ptr dead_on_unwind noalias writable sret(%"struct.vl::DateTime") align 8 %0, ptr nocapture noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = tail call i64 @mktime(ptr noundef %1) #2
  tail call void @_ZN2vl8DateTimeC1Ev(ptr noundef nonnull align 8 dereferenceable(80) %0)
  %5 = getelementptr inbounds i8, ptr %1, i64 16
  %6 = load <2 x i32>, ptr %5, align 8, !tbaa !5
  %7 = add nsw <2 x i32> %6, <i32 1, i32 1900>
  %8 = sext <2 x i32> %7 to <2 x i64>
  %9 = shufflevector <2 x i64> %8, <2 x i64> poison, <2 x i32> <i32 1, i32 0>
  store <2 x i64> %9, ptr %0, align 8, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %1, i64 12
  %11 = load i32, ptr %10, align 4, !tbaa !11
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  store i64 %12, ptr %13, align 8, !tbaa !14
  %14 = getelementptr inbounds i8, ptr %1, i64 24
  %15 = load i32, ptr %14, align 8, !tbaa !16
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %16, ptr %17, align 8, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %1, i64 8
  %19 = load i32, ptr %18, align 8, !tbaa !18
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 %20, ptr %21, align 8, !tbaa !19
  %22 = getelementptr inbounds i8, ptr %1, i64 4
  %23 = load i32, ptr %22, align 4, !tbaa !20
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i8, ptr %0, i64 40
  store i64 %24, ptr %25, align 8, !tbaa !21
  %26 = load i32, ptr %1, align 8, !tbaa !22
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i8, ptr %0, i64 48
  store i64 %27, ptr %28, align 8, !tbaa !23
  %29 = getelementptr inbounds i8, ptr %0, i64 56
  store i64 %2, ptr %29, align 8, !tbaa !24
  %30 = mul i64 %4, 1000
  %31 = add i64 %30, %2
  %32 = getelementptr inbounds i8, ptr %0, i64 72
  store i64 %31, ptr %32, align 8, !tbaa !25
  %33 = getelementptr inbounds i8, ptr %0, i64 64
  store i64 %31, ptr %33, align 8, !tbaa !26
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn
declare noundef i64 @mktime(ptr nocapture noundef) local_unnamed_addr #1

declare void @_ZN2vl8DateTimeC1Ev(ptr) local_unnamed_addr

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 nofree nounwind willreturn "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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 12}
!12 = !{!"_ZTS2tm", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20, !6, i64 24, !6, i64 28, !6, i64 32, !10, i64 40, !13, i64 48}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!15, !10, i64 24}
!15 = !{!"_ZTSN2vl8DateTimeE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72}
!16 = !{!12, !6, i64 24}
!17 = !{!15, !10, i64 16}
!18 = !{!12, !6, i64 8}
!19 = !{!15, !10, i64 32}
!20 = !{!12, !6, i64 4}
!21 = !{!15, !10, i64 40}
!22 = !{!12, !6, i64 0}
!23 = !{!15, !10, i64 48}
!24 = !{!15, !10, i64 56}
!25 = !{!15, !10, i64 72}
!26 = !{!15, !10, i64 64}


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