; LLVM IR from DanEngelbrecht/longtail :: lib/cacheblockstore (longtail_cacheblockstore)

; 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 [16 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 [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [19 x i8], align 1
@__func__.Longtail_CreateCacheBlockStoreAPI = external hidden unnamed_addr constant [34 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [43 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_CreateCacheBlockStoreAPI(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca [3 x %struct.Longtail_LogFieldFmt_Private], align 16
  %9 = alloca %struct.Longtail_LogContextFmt_Private, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 72, ptr %8) #3
  %16 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %8, i32 0, i32 0
  store ptr @.str.3, ptr %16, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %8, i32 0, i32 1
  store ptr @.str.4, ptr %17, align 8, !tbaa !11
  %18 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %8, i32 0, i32 2
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = ptrtoint ptr %19 to i64
  %21 = inttoptr i64 %20 to ptr
  store ptr %21, ptr %18, align 8, !tbaa !12
  %22 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %8, i64 1
  %23 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %22, i32 0, i32 0
  store ptr @.str.5, ptr %23, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %22, i32 0, i32 1
  store ptr @.str.4, ptr %24, align 8, !tbaa !11
  %25 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %22, i32 0, i32 2
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = ptrtoint ptr %26 to i64
  %28 = inttoptr i64 %27 to ptr
  store ptr %28, ptr %25, align 8, !tbaa !12
  %29 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %8, i64 2
  %30 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %29, i32 0, i32 0
  store ptr @.str.6, ptr %30, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %29, i32 0, i32 1
  store ptr @.str.4, ptr %31, align 8, !tbaa !11
  %32 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %29, i32 0, i32 2
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = ptrtoint ptr %33 to i64
  %35 = inttoptr i64 %34 to ptr
  store ptr %35, ptr %32, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #3
  %36 = getelementptr inbounds %struct.Longtail_LogContextFmt_Private, ptr %9, i32 0, i32 0
  store ptr null, ptr %36, align 8, !tbaa !13
  %37 = getelementptr inbounds %struct.Longtail_LogContextFmt_Private, ptr %9, i32 0, i32 1
  %38 = getelementptr inbounds [3 x %struct.Longtail_LogFieldFmt_Private], ptr %8, i64 0, i64 0
  store ptr %38, ptr %37, align 8, !tbaa !16
  %39 = getelementptr inbounds %struct.Longtail_LogContextFmt_Private, ptr %9, i32 0, i32 2
  store i64 3, ptr %39, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store ptr %9, ptr %10, align 8, !tbaa !5
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str.1, ptr noundef @__func__.Longtail_CreateCacheBlockStoreAPI, i32 noundef 981, ptr noundef %40, i32 noundef 0, ptr noundef @.str.7, ptr noundef @.str.8)
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = icmp ne ptr %41, null
  br i1 %42, label %45, label %43

43:                                               ; preds = %3
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str.1, ptr noundef @__func__.Longtail_CreateCacheBlockStoreAPI, i32 noundef 983, ptr noundef %44, i32 noundef 3, ptr noundef @.str.9, ptr noundef @.str.5)
  store ptr null, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %71

45:                                               ; preds = %3
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = icmp ne ptr %46, null
  br i1 %47, label %50, label %48

48:                                               ; preds = %45
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str.1, ptr noundef @__func__.Longtail_CreateCacheBlockStoreAPI, i32 noundef 984, ptr noundef %49, i32 noundef 3, ptr noundef @.str.9, ptr noundef @.str.6)
  store ptr null, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %71

50:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  store i64 280, ptr %12, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %51 = load i64, ptr %12, align 8, !tbaa !18
  %52 = call ptr @Longtail_Alloc(ptr noundef @.str, i64 noundef %51)
  store ptr %52, ptr %13, align 8, !tbaa !5
  %53 = load ptr, ptr %13, align 8, !tbaa !5
  %54 = icmp ne ptr %53, null
  br i1 %54, label %57, label %55

55:                                               ; preds = %50
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str.1, ptr noundef @__func__.Longtail_CreateCacheBlockStoreAPI, i32 noundef 990, ptr noundef %56, i32 noundef 3, ptr noundef @.str.2, i32 noundef 12)
  store ptr null, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %70

57:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %58 = load ptr, ptr %13, align 8, !tbaa !5
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = load ptr, ptr %7, align 8, !tbaa !5
  %62 = call i32 @CacheBlockStore_Init(ptr noundef %58, ptr noundef %59, ptr noundef %60, ptr noundef %61, ptr noundef %14)
  store i32 %62, ptr %15, align 4, !tbaa !19
  %63 = load i32, ptr %15, align 4, !tbaa !19
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %67

65:                                               ; preds = %57
  %66 = load ptr, ptr %13, align 8, !tbaa !5
  call void @Longtail_Free(ptr noundef %66)
  store ptr null, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %69

67:                                               ; preds = %57
  %68 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %68, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %69

69:                                               ; preds = %67, %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  br label %70

70:                                               ; preds = %69, %55
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %71

71:                                               ; preds = %70, %48, %43
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 72, ptr %8) #3
  %72 = load ptr, ptr %4, align 8
  ret ptr %72
}

; Function Attrs: nounwind uwtable
declare hidden i32 @CacheBlockStore_Init(ptr noundef, ptr noundef, 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 [16 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 [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [19 x i8], align 1
@__func__.Longtail_CreateCacheBlockStoreAPI = external hidden unnamed_addr constant [34 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [43 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_CreateCacheBlockStoreAPI(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = alloca [3 x %struct.Longtail_LogFieldFmt_Private], align 16
  %5 = alloca %struct.Longtail_LogContextFmt_Private, align 8
  %6 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %4) #3
  store ptr @.str.3, ptr %4, align 16, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr @.str.4, ptr %7, align 8, !tbaa !10
  %8 = getelementptr inbounds i8, ptr %4, i64 16
  store ptr %0, ptr %8, align 16, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %4, i64 24
  store ptr @.str.5, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %4, i64 32
  store ptr @.str.4, ptr %10, align 16, !tbaa !10
  %11 = getelementptr inbounds i8, ptr %4, i64 40
  store ptr %1, ptr %11, align 8, !tbaa !11
  %12 = getelementptr inbounds i8, ptr %4, i64 48
  store ptr @.str.6, ptr %12, align 16, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %4, i64 56
  store ptr @.str.4, ptr %13, align 8, !tbaa !10
  %14 = getelementptr inbounds i8, ptr %4, i64 64
  store ptr %2, ptr %14, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #3
  store ptr null, ptr %5, align 8, !tbaa !12
  %15 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %4, ptr %15, align 8, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %5, i64 16
  store i64 3, ptr %16, align 8, !tbaa !16
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.Longtail_CreateCacheBlockStoreAPI, i32 noundef 981, ptr noundef nonnull %5, i32 noundef 0, ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.8) #3
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %17, label %18

17:                                               ; preds = %3
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.Longtail_CreateCacheBlockStoreAPI, i32 noundef 983, ptr noundef nonnull %5, i32 noundef 3, ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.5) #3
  br label %29

18:                                               ; preds = %3
  %.not20 = icmp eq ptr %2, null
  br i1 %.not20, label %19, label %20

19:                                               ; preds = %18
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.Longtail_CreateCacheBlockStoreAPI, i32 noundef 984, ptr noundef nonnull %5, i32 noundef 3, ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.6) #3
  br label %29

20:                                               ; preds = %18
  %21 = call ptr @Longtail_Alloc(ptr noundef nonnull @.str, i64 noundef 280) #3
  %.not21 = icmp eq ptr %21, null
  br i1 %.not21, label %22, label %23

22:                                               ; preds = %20
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.1, ptr noundef nonnull @__func__.Longtail_CreateCacheBlockStoreAPI, i32 noundef 990, ptr noundef nonnull %5, i32 noundef 3, ptr noundef nonnull @.str.2, i32 noundef 12) #3
  br label %29

23:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  %24 = call i32 @CacheBlockStore_Init(ptr noundef nonnull %21, ptr noundef %0, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %6)
  %.not22 = icmp eq i32 %24, 0
  br i1 %.not22, label %26, label %25

25:                                               ; preds = %23
  call void @Longtail_Free(ptr noundef nonnull %21) #3
  br label %28

26:                                               ; preds = %23
  %27 = load ptr, ptr %6, align 8, !tbaa !17
  br label %28

28:                                               ; preds = %26, %25
  %.0 = phi ptr [ null, %25 ], [ %27, %26 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  br label %29

29:                                               ; preds = %22, %28, %19, %17
  %.2 = phi ptr [ null, %19 ], [ null, %17 ], [ %.0, %28 ], [ null, %22 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %4) #3
  ret ptr %.2
}

; Function Attrs: nounwind uwtable
declare hidden i32 @CacheBlockStore_Init(ptr noundef, ptr noundef, 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,SimplifyCFGPass