; 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.Longtail_LogFieldFmt_Private = type { ptr, ptr, ptr }
%struct.Longtail_LogContextFmt_Private = type { ptr, ptr, i64 }

@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [104 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@__func__.Longtail_CreateShareBlockStoreAPI = external hidden unnamed_addr constant [34 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [38 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

declare void @Longtail_Free(ptr noundef) #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @Longtail_CreateShareBlockStoreAPI(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca [1 x %struct.Longtail_LogFieldFmt_Private], align 16
  %5 = alloca %struct.Longtail_LogContextFmt_Private, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %4) #3
  %12 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %4, i32 0, i32 0
  store ptr @.str.3, ptr %12, align 8, !tbaa !9
  %13 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %4, i32 0, i32 1
  store ptr @.str.4, ptr %13, align 8, !tbaa !11
  %14 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %4, i32 0, i32 2
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = ptrtoint ptr %15 to i64
  %17 = inttoptr i64 %16 to ptr
  store ptr %17, ptr %14, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 24, ptr %5) #3
  %18 = getelementptr inbounds %struct.Longtail_LogContextFmt_Private, ptr %5, i32 0, i32 0
  store ptr null, ptr %18, align 8, !tbaa !13
  %19 = getelementptr inbounds %struct.Longtail_LogContextFmt_Private, ptr %5, i32 0, i32 1
  %20 = getelementptr inbounds [1 x %struct.Longtail_LogFieldFmt_Private], ptr %4, i64 0, i64 0
  store ptr %20, ptr %19, align 8, !tbaa !16
  %21 = getelementptr inbounds %struct.Longtail_LogContextFmt_Private, ptr %5, i32 0, i32 2
  store i64 1, ptr %21, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store ptr %5, ptr %6, align 8, !tbaa !5
  %22 = 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__.Longtail_CreateShareBlockStoreAPI, i32 noundef 557, ptr noundef %22, i32 noundef 0, ptr noundef @.str.5, ptr noundef @.str.6)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store i64 288, ptr %7, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %23 = load i64, ptr %7, align 8, !tbaa !18
  %24 = call ptr @Longtail_Alloc(ptr noundef @.str, i64 noundef %23)
  store ptr %24, ptr %8, align 8, !tbaa !5
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %29, label %27

27:                                               ; preds = %1
  %28 = 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__.Longtail_CreateShareBlockStoreAPI, i32 noundef 565, ptr noundef %28, i32 noundef 3, ptr noundef @.str.2, i32 noundef 12)
  store ptr null, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %42

29:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = load ptr, ptr %3, align 8, !tbaa !5
  %32 = call i32 @ShareBlockStore_Init(ptr noundef %30, ptr noundef %31, ptr noundef %10)
  store i32 %32, ptr %11, align 4, !tbaa !19
  %33 = load i32, ptr %11, align 4, !tbaa !19
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %39

35:                                               ; preds = %29
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = load i32, ptr %11, align 4, !tbaa !19
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str.1, ptr noundef @__func__.Longtail_CreateShareBlockStoreAPI, i32 noundef 575, ptr noundef %36, i32 noundef 3, ptr noundef @.str.7, i32 noundef %37)
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  call void @Longtail_Free(ptr noundef %38)
  store ptr null, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %41

39:                                               ; preds = %29
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %40, ptr %2, align 8
  store i32 1, ptr %9, align 4
  br label %41

41:                                               ; preds = %39, %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %42

42:                                               ; preds = %41, %27
  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
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %4) #3
  %43 = load ptr, ptr %2, align 8
  ret ptr %43
}

; Function Attrs: nounwind uwtable
declare hidden i32 @ShareBlockStore_Init(ptr noundef, ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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 0}
!10 = !{!"Longtail_LogFieldFmt_Private", !6, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!10, !6, i64 8}
!12 = !{!10, !6, i64 16}
!13 = !{!14, !6, i64 0}
!14 = !{!"Longtail_LogContextFmt_Private", !6, i64 0, !6, i64 8, !15, i64 16}
!15 = !{!"long", !7, i64 0}
!16 = !{!14, !6, i64 8}
!17 = !{!14, !15, i64 16}
!18 = !{!15, !15, i64 0}
!19 = !{!20, !20, i64 0}
!20 = !{!"int", !7, i64 0}


; 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.Longtail_LogFieldFmt_Private = type { ptr, ptr, ptr }
%struct.Longtail_LogContextFmt_Private = type { ptr, ptr, i64 }

@.str = external hidden unnamed_addr constant [19 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [104 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@__func__.Longtail_CreateShareBlockStoreAPI = external hidden unnamed_addr constant [34 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [38 x i8], align 1

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

declare void @Longtail_Free(ptr noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @Longtail_CreateShareBlockStoreAPI(ptr noundef %0) local_unnamed_addr #2 {
  %2 = alloca [1 x %struct.Longtail_LogFieldFmt_Private], align 16
  %3 = alloca %struct.Longtail_LogContextFmt_Private, align 8
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %2) #3
  store ptr @.str.3, ptr %2, align 16, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %2, i64 8
  store ptr @.str.4, ptr %5, align 8, !tbaa !10
  %6 = getelementptr inbounds i8, ptr %2, i64 16
  store ptr %0, ptr %6, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #3
  store ptr null, ptr %3, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %2, ptr %7, align 8, !tbaa !15
  %8 = getelementptr inbounds i8, ptr %3, i64 16
  store i64 1, ptr %8, align 8, !tbaa !16
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.Longtail_CreateShareBlockStoreAPI, i32 noundef 557, ptr noundef nonnull %3, i32 noundef 0, ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6) #3
  %9 = call ptr @Longtail_Alloc(ptr noundef nonnull @.str, i64 noundef 288) #3
  %.not = icmp eq ptr %9, null
  br i1 %.not, label %10, label %11

10:                                               ; preds = %1
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.Longtail_CreateShareBlockStoreAPI, i32 noundef 565, ptr noundef nonnull %3, i32 noundef 3, ptr noundef nonnull @.str.2, i32 noundef 12) #3
  br label %17

11:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %12 = call i32 @ShareBlockStore_Init(ptr noundef nonnull %9, ptr noundef %0, ptr noundef nonnull %4)
  %.not13 = icmp eq i32 %12, 0
  br i1 %.not13, label %14, label %13

13:                                               ; preds = %11
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.Longtail_CreateShareBlockStoreAPI, i32 noundef 575, ptr noundef nonnull %3, i32 noundef 3, ptr noundef nonnull @.str.7, i32 noundef %12) #3
  call void @Longtail_Free(ptr noundef nonnull %9) #3
  br label %16

14:                                               ; preds = %11
  %15 = load ptr, ptr %4, align 8, !tbaa !17
  br label %16

16:                                               ; preds = %14, %13
  %.0 = phi ptr [ null, %13 ], [ %15, %14 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  br label %17

17:                                               ; preds = %16, %10
  %.1 = phi ptr [ %.0, %16 ], [ null, %10 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %2) #3
  ret ptr %.1
}

; Function Attrs: nounwind uwtable
declare hidden i32 @ShareBlockStore_Init(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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, !7, i64 0}
!6 = !{!"Longtail_LogFieldFmt_Private", !7, i64 0, !7, i64 8, !7, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 16}
!12 = !{!13, !7, i64 0}
!13 = !{!"Longtail_LogContextFmt_Private", !7, i64 0, !7, i64 8, !14, i64 16}
!14 = !{!"long", !8, i64 0}
!15 = !{!13, !7, i64 8}
!16 = !{!13, !14, i64 16}
!17 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass