; LLVM IR from travisdowns/uarch-bench :: page-info (extract_info)

; 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.page_info = type { i64, i8, i8, i8, i8, i8, i8, i64 }

; Function Attrs: nounwind uwtable
define dso_local void @extract_info(ptr dead_on_unwind noalias writable sret(%struct.page_info) align 8 %0, i64 noundef %1) #0 {
  %3 = alloca i64, align 8
  store i64 %1, ptr %3, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %0, i8 0, i64 24, i1 false)
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = and i64 %4, 36028797018963967
  %6 = getelementptr inbounds %struct.page_info, ptr %0, i32 0, i32 0
  store i64 %5, ptr %6, align 8, !tbaa !9
  %7 = load i64, ptr %3, align 8, !tbaa !5
  %8 = and i64 %7, 36028797018963968
  %9 = icmp ne i64 %8, 0
  %10 = getelementptr inbounds %struct.page_info, ptr %0, i32 0, i32 1
  %11 = zext i1 %9 to i8
  store i8 %11, ptr %10, align 8, !tbaa !12
  %12 = load i64, ptr %3, align 8, !tbaa !5
  %13 = and i64 %12, 72057594037927936
  %14 = icmp ne i64 %13, 0
  %15 = getelementptr inbounds %struct.page_info, ptr %0, i32 0, i32 2
  %16 = zext i1 %14 to i8
  store i8 %16, ptr %15, align 1, !tbaa !13
  %17 = load i64, ptr %3, align 8, !tbaa !5
  %18 = and i64 %17, 2305843009213693952
  %19 = icmp ne i64 %18, 0
  %20 = getelementptr inbounds %struct.page_info, ptr %0, i32 0, i32 3
  %21 = zext i1 %19 to i8
  store i8 %21, ptr %20, align 2, !tbaa !14
  %22 = load i64, ptr %3, align 8, !tbaa !5
  %23 = and i64 %22, 4611686018427387904
  %24 = icmp ne i64 %23, 0
  %25 = getelementptr inbounds %struct.page_info, ptr %0, i32 0, i32 4
  %26 = zext i1 %24 to i8
  store i8 %26, ptr %25, align 1, !tbaa !15
  %27 = load i64, ptr %3, align 8, !tbaa !5
  %28 = and i64 %27, -9223372036854775808
  %29 = icmp ne i64 %28, 0
  %30 = getelementptr inbounds %struct.page_info, ptr %0, i32 0, i32 5
  %31 = zext i1 %29 to i8
  store i8 %31, ptr %30, align 4, !tbaa !16
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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" }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"", !6, i64 0, !11, i64 8, !11, i64 9, !11, i64 10, !11, i64 11, !11, i64 12, !11, i64 13, !6, i64 16}
!11 = !{!"_Bool", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!10, !11, i64 9}
!14 = !{!10, !11, i64 10}
!15 = !{!10, !11, i64 11}
!16 = !{!10, !11, i64 12}


; 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.page_info = type { i64, i8, i8, i8, i8, i8, i8, i64 }

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local void @extract_info(ptr dead_on_unwind noalias nocapture writable writeonly sret(%struct.page_info) align 8 %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %3, i8 0, i64 16, i1 false)
  %4 = and i64 %1, 36028797018963967
  store i64 %4, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = lshr i64 %1, 55
  %7 = trunc i64 %6 to i8
  %8 = and i8 %7, 1
  store i8 %8, ptr %5, align 8, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %0, i64 9
  %10 = lshr i64 %1, 56
  %11 = trunc nuw i64 %10 to i8
  %12 = and i8 %11, 1
  store i8 %12, ptr %9, align 1, !tbaa !12
  %13 = getelementptr inbounds i8, ptr %0, i64 10
  %14 = lshr i64 %1, 61
  %15 = trunc nuw nsw i64 %14 to i8
  %16 = and i8 %15, 1
  store i8 %16, ptr %13, align 2, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %0, i64 11
  %18 = lshr i64 %1, 62
  %19 = trunc nuw nsw i64 %18 to i8
  %20 = and i8 %19, 1
  store i8 %20, ptr %17, align 1, !tbaa !14
  %21 = getelementptr inbounds i8, ptr %0, i64 12
  %.lobit = lshr i64 %1, 63
  %22 = trunc nuw nsw i64 %.lobit to i8
  store i8 %22, ptr %21, align 4, !tbaa !15
  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) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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 nounwind willreturn memory(argmem: write) }

!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 = !{!"", !7, i64 0, !10, i64 8, !10, i64 9, !10, i64 10, !10, i64 11, !10, i64 12, !10, i64 13, !7, i64 16}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Bool", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!6, !10, i64 9}
!13 = !{!6, !10, i64 10}
!14 = !{!6, !10, i64 11}
!15 = !{!6, !10, i64 12}


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