; LLVM IR from kala13x/libxutils :: src/sys (xtime)

; 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.XTime = type { i16, i8, i8, i8, i8, i8, i8 }
%struct.tm = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i64, ptr }

; Function Attrs: nounwind uwtable
define dso_local void @XTime_ToTm(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.XTime, ptr %5, i32 0, i32 0
  %7 = load i16, ptr %6, align 2, !tbaa !9
  %8 = zext i16 %7 to i32
  %9 = sub nsw i32 %8, 1900
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.tm, ptr %10, i32 0, i32 5
  store i32 %9, ptr %11, align 4, !tbaa !12
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.XTime, ptr %12, i32 0, i32 1
  %14 = load i8, ptr %13, align 2, !tbaa !16
  %15 = zext i8 %14 to i32
  %16 = sub nsw i32 %15, 1
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.tm, ptr %17, i32 0, i32 4
  store i32 %16, ptr %18, align 8, !tbaa !17
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.XTime, ptr %19, i32 0, i32 2
  %21 = load i8, ptr %20, align 1, !tbaa !18
  %22 = zext i8 %21 to i32
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.tm, ptr %23, i32 0, i32 3
  store i32 %22, ptr %24, align 4, !tbaa !19
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.XTime, ptr %25, i32 0, i32 3
  %27 = load i8, ptr %26, align 2, !tbaa !20
  %28 = zext i8 %27 to i32
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.tm, ptr %29, i32 0, i32 2
  store i32 %28, ptr %30, align 8, !tbaa !21
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.XTime, ptr %31, i32 0, i32 4
  %33 = load i8, ptr %32, align 1, !tbaa !22
  %34 = zext i8 %33 to i32
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.tm, ptr %35, i32 0, i32 1
  store i32 %34, ptr %36, align 4, !tbaa !23
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.XTime, ptr %37, i32 0, i32 5
  %39 = load i8, ptr %38, align 2, !tbaa !24
  %40 = zext i8 %39 to i32
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.tm, ptr %41, i32 0, i32 0
  store i32 %40, ptr %42, align 8, !tbaa !25
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.tm, ptr %43, i32 0, i32 8
  store i32 -1, ptr %44, align 8, !tbaa !26
  ret void
}

attributes #0 = { 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" }

!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/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"XTime", !11, i64 0, !7, i64 2, !7, i64 3, !7, i64 4, !7, i64 5, !7, i64 6, !7, i64 7}
!11 = !{!"short", !7, i64 0}
!12 = !{!13, !14, i64 20}
!13 = !{!"tm", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20, !14, i64 24, !14, i64 28, !14, i64 32, !15, i64 40, !6, i64 48}
!14 = !{!"int", !7, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!10, !7, i64 2}
!17 = !{!13, !14, i64 16}
!18 = !{!10, !7, i64 3}
!19 = !{!13, !14, i64 12}
!20 = !{!10, !7, i64 4}
!21 = !{!13, !14, i64 8}
!22 = !{!10, !7, i64 5}
!23 = !{!13, !14, i64 4}
!24 = !{!10, !7, i64 6}
!25 = !{!13, !14, i64 0}
!26 = !{!13, !14, 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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @XTime_ToTm(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 {
  %3 = load i16, ptr %0, align 2, !tbaa !5
  %4 = zext i16 %3 to i32
  %5 = add nsw i32 %4, -1900
  %6 = getelementptr inbounds i8, ptr %1, i64 20
  store i32 %5, ptr %6, align 4, !tbaa !10
  %7 = getelementptr inbounds i8, ptr %0, i64 2
  %8 = load i8, ptr %7, align 2, !tbaa !15
  %9 = zext i8 %8 to i32
  %10 = add nsw i32 %9, -1
  %11 = getelementptr inbounds i8, ptr %1, i64 16
  store i32 %10, ptr %11, align 8, !tbaa !16
  %12 = getelementptr inbounds i8, ptr %0, i64 3
  %13 = load <4 x i8>, ptr %12, align 1, !tbaa !17
  %14 = zext <4 x i8> %13 to <4 x i32>
  %15 = shufflevector <4 x i32> %14, <4 x i32> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
  store <4 x i32> %15, ptr %1, align 8, !tbaa !18
  %16 = getelementptr inbounds i8, ptr %1, i64 32
  store i32 -1, ptr %16, align 8, !tbaa !19
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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, !7, i64 0}
!6 = !{!"XTime", !7, i64 0, !8, i64 2, !8, i64 3, !8, i64 4, !8, i64 5, !8, i64 6, !8, i64 7}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !12, i64 20}
!11 = !{!"tm", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !13, i64 40, !14, i64 48}
!12 = !{!"int", !8, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!6, !8, i64 2}
!16 = !{!11, !12, i64 16}
!17 = !{!8, !8, i64 0}
!18 = !{!12, !12, i64 0}
!19 = !{!11, !12, i64 32}


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