; LLVM IR from DanEngelbrecht/longtail :: lib/lrublockstore (longtail_lrublockstore)

; 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.Longtail_StoredBlock = type { ptr, ptr, ptr, i32 }
%struct.Longtail_BlockIndex = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.LRUStoredBlock = type { %struct.Longtail_StoredBlock, ptr, ptr, i32 }

@.str.7 = external hidden unnamed_addr constant [17 x i8], align 1

; 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
declare dso_local i32 @LRUStoredBlock_Dispose(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @CreateLRUBlock(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store ptr null, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.Longtail_StoredBlock, ptr %8, i32 0, i32 1
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds %struct.Longtail_BlockIndex, ptr %10, i32 0, i32 0
  %12 = load ptr, ptr %11, align 8, !tbaa !12
  %13 = load i64, ptr %12, align 8, !tbaa !14
  store i64 %13, ptr %6, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %14 = call ptr @Longtail_Alloc(ptr noundef @.str.7, i64 noundef 56)
  store ptr %14, ptr %7, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.LRUStoredBlock, ptr %16, i32 0, i32 1
  store ptr %15, ptr %17, align 8, !tbaa !16
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.LRUStoredBlock, ptr %19, i32 0, i32 2
  store ptr %18, ptr %20, align 8, !tbaa !18
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.LRUStoredBlock, ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds %struct.Longtail_StoredBlock, ptr %22, i32 0, i32 0
  store ptr @LRUStoredBlock_Dispose, ptr %23, align 8, !tbaa !19
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.Longtail_StoredBlock, ptr %24, i32 0, i32 3
  %26 = load i32, ptr %25, align 8, !tbaa !20
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.LRUStoredBlock, ptr %27, i32 0, i32 0
  %29 = getelementptr inbounds %struct.Longtail_StoredBlock, ptr %28, i32 0, i32 3
  store i32 %26, ptr %29, align 8, !tbaa !21
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.Longtail_StoredBlock, ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !22
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.LRUStoredBlock, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds %struct.Longtail_StoredBlock, ptr %34, i32 0, i32 2
  store ptr %32, ptr %35, align 8, !tbaa !23
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.Longtail_StoredBlock, ptr %36, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.LRUStoredBlock, ptr %39, i32 0, i32 0
  %41 = getelementptr inbounds %struct.Longtail_StoredBlock, ptr %40, i32 0, i32 1
  store ptr %38, ptr %41, align 8, !tbaa !24
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.LRUStoredBlock, ptr %42, i32 0, i32 3
  store volatile i32 1, ptr %43, align 8, !tbaa !25
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret ptr %44
}

declare ptr @Longtail_Alloc(ptr noundef, i64 noundef) #2

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 = { "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/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"Longtail_StoredBlock", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"Longtail_BlockIndex", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!17, !6, i64 32}
!17 = !{!"LRUStoredBlock", !10, i64 0, !6, i64 32, !6, i64 40, !11, i64 48}
!18 = !{!17, !6, i64 40}
!19 = !{!17, !6, i64 0}
!20 = !{!10, !11, i64 24}
!21 = !{!17, !11, i64 24}
!22 = !{!10, !6, i64 16}
!23 = !{!17, !6, i64 16}
!24 = !{!17, !6, i64 8}
!25 = !{!17, !11, i64 48}


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

@.str.7 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @LRUStoredBlock_Dispose(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @CreateLRUBlock(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %1, i64 8
  %4 = tail call ptr @Longtail_Alloc(ptr noundef nonnull @.str.7, i64 noundef 56) #2
  %5 = getelementptr inbounds i8, ptr %4, i64 32
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %4, i64 40
  store ptr %0, ptr %6, align 8, !tbaa !12
  store ptr @LRUStoredBlock_Dispose, ptr %4, align 8, !tbaa !13
  %7 = getelementptr inbounds i8, ptr %1, i64 24
  %8 = load i32, ptr %7, align 8, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %4, i64 24
  store i32 %8, ptr %9, align 8, !tbaa !15
  %10 = getelementptr inbounds i8, ptr %4, i64 8
  %11 = load <2 x ptr>, ptr %3, align 8, !tbaa !16
  store <2 x ptr> %11, ptr %10, align 8, !tbaa !16
  %12 = getelementptr inbounds i8, ptr %4, i64 48
  store volatile i32 1, ptr %12, align 8, !tbaa !17
  ret ptr %4
}

declare ptr @Longtail_Alloc(ptr noundef, i64 noundef) local_unnamed_addr #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 = { "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, !8, i64 32}
!6 = !{!"LRUStoredBlock", !7, i64 0, !8, i64 32, !8, i64 40, !11, i64 48}
!7 = !{!"Longtail_StoredBlock", !8, i64 0, !8, i64 8, !8, i64 16, !11, i64 24}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!6, !8, i64 40}
!13 = !{!6, !8, i64 0}
!14 = !{!7, !11, i64 24}
!15 = !{!6, !11, i64 24}
!16 = !{!8, !8, i64 0}
!17 = !{!6, !11, i64 48}


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