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

; 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local i64 @XTime_Serialize(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.XTime, ptr %4, i32 0, i32 0
  %6 = load i16, ptr %5, align 2, !tbaa !9
  %7 = zext i16 %6 to i64
  store i64 %7, ptr %3, align 8, !tbaa !12
  %8 = load i64, ptr %3, align 8, !tbaa !12
  %9 = shl i64 %8, 8
  store i64 %9, ptr %3, align 8, !tbaa !12
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.XTime, ptr %10, i32 0, i32 1
  %12 = load i8, ptr %11, align 2, !tbaa !14
  %13 = zext i8 %12 to i64
  %14 = load i64, ptr %3, align 8, !tbaa !12
  %15 = add i64 %14, %13
  store i64 %15, ptr %3, align 8, !tbaa !12
  %16 = load i64, ptr %3, align 8, !tbaa !12
  %17 = shl i64 %16, 8
  store i64 %17, ptr %3, align 8, !tbaa !12
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.XTime, ptr %18, i32 0, i32 2
  %20 = load i8, ptr %19, align 1, !tbaa !15
  %21 = zext i8 %20 to i64
  %22 = load i64, ptr %3, align 8, !tbaa !12
  %23 = add i64 %22, %21
  store i64 %23, ptr %3, align 8, !tbaa !12
  %24 = load i64, ptr %3, align 8, !tbaa !12
  %25 = shl i64 %24, 8
  store i64 %25, ptr %3, align 8, !tbaa !12
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.XTime, ptr %26, i32 0, i32 3
  %28 = load i8, ptr %27, align 2, !tbaa !16
  %29 = zext i8 %28 to i64
  %30 = load i64, ptr %3, align 8, !tbaa !12
  %31 = add i64 %30, %29
  store i64 %31, ptr %3, align 8, !tbaa !12
  %32 = load i64, ptr %3, align 8, !tbaa !12
  %33 = shl i64 %32, 8
  store i64 %33, ptr %3, align 8, !tbaa !12
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.XTime, ptr %34, i32 0, i32 4
  %36 = load i8, ptr %35, align 1, !tbaa !17
  %37 = zext i8 %36 to i64
  %38 = load i64, ptr %3, align 8, !tbaa !12
  %39 = add i64 %38, %37
  store i64 %39, ptr %3, align 8, !tbaa !12
  %40 = load i64, ptr %3, align 8, !tbaa !12
  %41 = shl i64 %40, 8
  store i64 %41, ptr %3, align 8, !tbaa !12
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.XTime, ptr %42, i32 0, i32 5
  %44 = load i8, ptr %43, align 2, !tbaa !18
  %45 = zext i8 %44 to i64
  %46 = load i64, ptr %3, align 8, !tbaa !12
  %47 = add i64 %46, %45
  store i64 %47, ptr %3, align 8, !tbaa !12
  %48 = load i64, ptr %3, align 8, !tbaa !12
  %49 = shl i64 %48, 8
  store i64 %49, ptr %3, align 8, !tbaa !12
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.XTime, ptr %50, i32 0, i32 6
  %52 = load i8, ptr %51, align 1, !tbaa !19
  %53 = zext i8 %52 to i64
  %54 = load i64, ptr %3, align 8, !tbaa !12
  %55 = add i64 %54, %53
  store i64 %55, ptr %3, align 8, !tbaa !12
  %56 = load i64, ptr %3, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret i64 %56
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"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, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!10, !7, i64 2}
!15 = !{!10, !7, i64 3}
!16 = !{!10, !7, i64 4}
!17 = !{!10, !7, i64 5}
!18 = !{!10, !7, i64 6}
!19 = !{!10, !7, i64 7}


; 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: read) uwtable
define dso_local i64 @XTime_Serialize(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load i16, ptr %0, align 2, !tbaa !5
  %3 = zext i16 %2 to i64
  %4 = getelementptr inbounds i8, ptr %0, i64 2
  %5 = load i8, ptr %4, align 2, !tbaa !10
  %6 = zext i8 %5 to i64
  %7 = shl nuw nsw i64 %3, 16
  %8 = shl nuw nsw i64 %6, 8
  %9 = or disjoint i64 %8, %7
  %10 = getelementptr inbounds i8, ptr %0, i64 3
  %11 = load i8, ptr %10, align 1, !tbaa !11
  %12 = zext i8 %11 to i64
  %13 = or disjoint i64 %9, %12
  %14 = getelementptr inbounds i8, ptr %0, i64 4
  %15 = load i8, ptr %14, align 2, !tbaa !12
  %16 = zext i8 %15 to i64
  %17 = getelementptr inbounds i8, ptr %0, i64 5
  %18 = load i8, ptr %17, align 1, !tbaa !13
  %19 = zext i8 %18 to i64
  %20 = getelementptr inbounds i8, ptr %0, i64 6
  %21 = load i8, ptr %20, align 2, !tbaa !14
  %22 = zext i8 %21 to i64
  %23 = shl nuw i64 %13, 32
  %24 = shl nuw nsw i64 %16, 24
  %25 = shl nuw nsw i64 %19, 16
  %26 = or disjoint i64 %24, %25
  %27 = or disjoint i64 %23, %26
  %28 = shl nuw nsw i64 %22, 8
  %29 = getelementptr inbounds i8, ptr %0, i64 7
  %30 = load i8, ptr %29, align 1, !tbaa !15
  %31 = zext i8 %30 to i64
  %32 = or disjoint i64 %28, %31
  %33 = or disjoint i64 %32, %27
  ret i64 %33
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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 = !{!6, !8, i64 2}
!11 = !{!6, !8, i64 3}
!12 = !{!6, !8, i64 4}
!13 = !{!6, !8, i64 5}
!14 = !{!6, !8, i64 6}
!15 = !{!6, !8, i64 7}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass