; LLVM IR from DanEngelbrecht/longtail :: lib/compressblockstore (longtail_compressblockstore)

; 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 [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [110 x i8], align 1
@__func__.Longtail_CreateCompressBlockStoreAPI = external hidden unnamed_addr constant [37 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [41 x i8], align 1

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

34:                                               ; preds = %2
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str.3, ptr noundef @__func__.Longtail_CreateCompressBlockStoreAPI, i32 noundef 641, ptr noundef %35, i32 noundef 3, ptr noundef @.str.6, ptr noundef @.str)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %63

36:                                               ; preds = %2
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %41, label %39

39:                                               ; preds = %36
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str.3, ptr noundef @__func__.Longtail_CreateCompressBlockStoreAPI, i32 noundef 642, ptr noundef %40, i32 noundef 3, ptr noundef @.str.6, ptr noundef @.str.2)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %63

41:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store i64 456, ptr %10, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  %42 = load i64, ptr %10, align 8, !tbaa !18
  %43 = call ptr @Longtail_Alloc(ptr noundef @.str.7, i64 noundef %42)
  store ptr %43, ptr %11, align 8, !tbaa !5
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = icmp ne ptr %44, null
  br i1 %45, label %48, label %46

46:                                               ; preds = %41
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str.3, ptr noundef @__func__.Longtail_CreateCompressBlockStoreAPI, i32 noundef 648, ptr noundef %47, i32 noundef 3, ptr noundef @.str.8, i32 noundef 12)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %62

48:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %49 = load ptr, ptr %11, align 8, !tbaa !5
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = call i32 @CompressBlockStore_Init(ptr noundef %49, ptr noundef %50, ptr noundef %51, ptr noundef %12)
  store i32 %52, ptr %13, align 4, !tbaa !19
  %53 = load i32, ptr %13, align 4, !tbaa !19
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %59

55:                                               ; preds = %48
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = load i32, ptr %13, align 4, !tbaa !19
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str.3, ptr noundef @__func__.Longtail_CreateCompressBlockStoreAPI, i32 noundef 659, ptr noundef %56, i32 noundef 3, ptr noundef @.str.9, i32 noundef %57)
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  call void @Longtail_Free(ptr noundef %58)
  store ptr null, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %61

59:                                               ; preds = %48
  %60 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %60, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %61

61:                                               ; preds = %59, %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  br label %62

62:                                               ; preds = %61, %46
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %63

63:                                               ; preds = %62, %39, %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 48, ptr %6) #3
  %64 = load ptr, ptr %3, align 8
  ret ptr %64
}

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

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

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

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

declare void @Longtail_Free(ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 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, !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 [20 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [110 x i8], align 1
@__func__.Longtail_CreateCompressBlockStoreAPI = external hidden unnamed_addr constant [37 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [41 x i8], align 1

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

13:                                               ; preds = %2
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.3, ptr noundef nonnull @__func__.Longtail_CreateCompressBlockStoreAPI, i32 noundef 641, ptr noundef nonnull %4, i32 noundef 3, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str) #3
  br label %25

14:                                               ; preds = %2
  %.not21 = icmp eq ptr %1, null
  br i1 %.not21, label %15, label %16

15:                                               ; preds = %14
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.3, ptr noundef nonnull @__func__.Longtail_CreateCompressBlockStoreAPI, i32 noundef 642, ptr noundef nonnull %4, i32 noundef 3, ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.2) #3
  br label %25

16:                                               ; preds = %14
  %17 = call ptr @Longtail_Alloc(ptr noundef nonnull @.str.7, i64 noundef 456) #3
  %.not22 = icmp eq ptr %17, null
  br i1 %.not22, label %18, label %19

18:                                               ; preds = %16
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.3, ptr noundef nonnull @__func__.Longtail_CreateCompressBlockStoreAPI, i32 noundef 648, ptr noundef nonnull %4, i32 noundef 3, ptr noundef nonnull @.str.8, i32 noundef 12) #3
  br label %25

19:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %20 = call i32 @CompressBlockStore_Init(ptr noundef nonnull %17, ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull %5)
  %.not23 = icmp eq i32 %20, 0
  br i1 %.not23, label %22, label %21

21:                                               ; preds = %19
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.3, ptr noundef nonnull @__func__.Longtail_CreateCompressBlockStoreAPI, i32 noundef 659, ptr noundef nonnull %4, i32 noundef 3, ptr noundef nonnull @.str.9, i32 noundef %20) #3
  call void @Longtail_Free(ptr noundef nonnull %17) #3
  br label %24

22:                                               ; preds = %19
  %23 = load ptr, ptr %5, align 8, !tbaa !17
  br label %24

24:                                               ; preds = %22, %21
  %.0 = phi ptr [ null, %21 ], [ %23, %22 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  br label %25

25:                                               ; preds = %18, %24, %15, %13
  %.2 = phi ptr [ null, %15 ], [ null, %13 ], [ %.0, %24 ], [ null, %18 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %3) #3
  ret ptr %.2
}

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

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

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

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

declare void @Longtail_Free(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress 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, !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