; LLVM IR from DanEngelbrecht/longtail :: lib/shareblockstore (longtail_shareblockstore)

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

@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [104 x i8], align 1
@__func__.SharedStoredBlock_CreateBlock = external hidden unnamed_addr constant [30 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [32 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @SharedStoredBlock_CreateBlock(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store ptr null, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 56, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %10 = load i64, ptr %7, align 8, !tbaa !9
  %11 = call ptr @Longtail_Alloc(ptr noundef @.str, i64 noundef %10)
  store ptr %11, ptr %8, align 8, !tbaa !5
  %12 = load ptr, ptr %8, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %16, label %14

14:                                               ; preds = %2
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str.1, ptr noundef @__func__.SharedStoredBlock_CreateBlock, i32 noundef 121, ptr noundef %15, i32 noundef 3, ptr noundef @.str.2, i32 noundef 12)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %47

16:                                               ; preds = %2
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.SharedStoredBlock, ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds %struct.Longtail_StoredBlock, ptr %18, i32 0, i32 0
  store ptr @SharedStoredBlock_Dispose, ptr %19, align 8, !tbaa !11
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.Longtail_StoredBlock, ptr %20, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.SharedStoredBlock, ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds %struct.Longtail_StoredBlock, ptr %24, i32 0, i32 1
  store ptr %22, ptr %25, align 8, !tbaa !16
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.Longtail_StoredBlock, ptr %26, i32 0, i32 2
  %28 = load ptr, ptr %27, align 8, !tbaa !17
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.SharedStoredBlock, ptr %29, i32 0, i32 0
  %31 = getelementptr inbounds %struct.Longtail_StoredBlock, ptr %30, i32 0, i32 2
  store ptr %28, ptr %31, align 8, !tbaa !18
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.Longtail_StoredBlock, ptr %32, i32 0, i32 3
  %34 = load i32, ptr %33, align 8, !tbaa !19
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.SharedStoredBlock, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds %struct.Longtail_StoredBlock, ptr %36, i32 0, i32 3
  store i32 %34, ptr %37, align 8, !tbaa !20
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.SharedStoredBlock, ptr %39, i32 0, i32 1
  store ptr %38, ptr %40, align 8, !tbaa !21
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.SharedStoredBlock, ptr %42, i32 0, i32 2
  store ptr %41, ptr %43, align 8, !tbaa !22
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.SharedStoredBlock, ptr %44, i32 0, i32 3
  store volatile i32 0, ptr %45, align 8, !tbaa !23
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %46, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %47

47:                                               ; preds = %16, %14
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %48 = load ptr, ptr %3, align 8
  ret ptr %48
}

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

declare void @Longtail_CallLogger(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #2

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 nosync nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"SharedStoredBlock", !13, i64 0, !6, i64 32, !6, i64 40, !14, i64 48}
!13 = !{!"Longtail_StoredBlock", !6, i64 0, !6, i64 8, !6, i64 16, !14, i64 24}
!14 = !{!"int", !7, i64 0}
!15 = !{!13, !6, i64 8}
!16 = !{!12, !6, i64 8}
!17 = !{!13, !6, i64 16}
!18 = !{!12, !6, i64 16}
!19 = !{!13, !14, i64 24}
!20 = !{!12, !14, i64 24}
!21 = !{!12, !6, i64 32}
!22 = !{!12, !6, i64 40}
!23 = !{!12, !14, 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 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [104 x i8], align 1
@__func__.SharedStoredBlock_CreateBlock = external hidden unnamed_addr constant [30 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [32 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @SharedStoredBlock_CreateBlock(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call ptr @Longtail_Alloc(ptr noundef nonnull @.str, i64 noundef 56) #2
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %4, label %5

4:                                                ; preds = %2
  tail call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.SharedStoredBlock_CreateBlock, i32 noundef 121, ptr noundef null, i32 noundef 3, ptr noundef nonnull @.str.2, i32 noundef 12) #2
  br label %15

5:                                                ; preds = %2
  store ptr @SharedStoredBlock_Dispose, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = getelementptr inbounds i8, ptr %3, i64 8
  %8 = load <2 x ptr>, ptr %6, align 8, !tbaa !12
  store <2 x ptr> %8, ptr %7, align 8, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %1, i64 24
  %10 = load i32, ptr %9, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %3, i64 24
  store i32 %10, ptr %11, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %3, i64 32
  store ptr %1, ptr %12, align 8, !tbaa !15
  %13 = getelementptr inbounds i8, ptr %3, i64 40
  store ptr %0, ptr %13, align 8, !tbaa !16
  %14 = getelementptr inbounds i8, ptr %3, i64 48
  store volatile i32 0, ptr %14, align 8, !tbaa !17
  br label %15

15:                                               ; preds = %5, %4
  ret ptr %3
}

declare ptr @Longtail_Alloc(ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @Longtail_CallLogger(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr 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 0}
!6 = !{!"SharedStoredBlock", !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 = !{!8, !8, i64 0}
!13 = !{!7, !11, i64 24}
!14 = !{!6, !11, i64 24}
!15 = !{!6, !8, i64 32}
!16 = !{!6, !8, i64 40}
!17 = !{!6, !11, i64 48}


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