; LLVM IR from DanEngelbrecht/longtail :: test (test)

; 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 }
%struct.Longtail_AsyncPruneBlocksAPI = type { %struct.Longtail_API, ptr }
%struct.Longtail_API = type { ptr }

@.str.3 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.586 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.587 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.588 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.590 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.592 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.594 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.597 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.598 = external hidden unnamed_addr constant [18 x i8], align 1
@__func__._ZN19TestAsyncBlockStore11PruneBlocksEP22Longtail_BlockStoreAPIjPKmP28Longtail_AsyncPruneBlocksAPI = external hidden unnamed_addr constant [12 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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN19TestAsyncBlockStore11PruneBlocksEP22Longtail_BlockStoreAPIjPKmP28Longtail_AsyncPruneBlocksAPI(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #2 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca [4 x %struct.Longtail_LogFieldFmt_Private], align 16
  %10 = alloca %struct.Longtail_LogContextFmt_Private, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 96, ptr %9) #3
  %13 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %9, i32 0, i32 0
  store ptr @.str.590, ptr %13, align 8, !tbaa !11
  %14 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %9, i32 0, i32 1
  store ptr @.str.586, ptr %14, align 8, !tbaa !13
  %15 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %9, i32 0, i32 2
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = ptrtoint ptr %16 to i64
  %18 = inttoptr i64 %17 to ptr
  store ptr %18, ptr %15, align 8, !tbaa !14
  %19 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %9, i64 1
  %20 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %19, i32 0, i32 0
  store ptr @.str.597, ptr %20, align 8, !tbaa !11
  %21 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %19, i32 0, i32 1
  store ptr @.str.594, ptr %21, align 8, !tbaa !13
  %22 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %19, i32 0, i32 2
  %23 = load i32, ptr %6, align 4, !tbaa !9
  %24 = zext i32 %23 to i64
  %25 = inttoptr i64 %24 to ptr
  store ptr %25, ptr %22, align 8, !tbaa !14
  %26 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %9, i64 2
  %27 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %26, i32 0, i32 0
  store ptr @.str.598, ptr %27, align 8, !tbaa !11
  %28 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %26, i32 0, i32 1
  store ptr @.str.586, ptr %28, align 8, !tbaa !13
  %29 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %26, i32 0, i32 2
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = ptrtoint ptr %30 to i64
  %32 = inttoptr i64 %31 to ptr
  store ptr %32, ptr %29, align 8, !tbaa !14
  %33 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %9, i64 3
  %34 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %33, i32 0, i32 0
  store ptr @.str.592, ptr %34, align 8, !tbaa !11
  %35 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %33, i32 0, i32 1
  store ptr @.str.586, ptr %35, align 8, !tbaa !13
  %36 = getelementptr inbounds %struct.Longtail_LogFieldFmt_Private, ptr %33, i32 0, i32 2
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = ptrtoint ptr %37 to i64
  %39 = inttoptr i64 %38 to ptr
  store ptr %39, ptr %36, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #3
  %40 = getelementptr inbounds %struct.Longtail_LogContextFmt_Private, ptr %10, i32 0, i32 0
  store ptr null, ptr %40, align 8, !tbaa !15
  %41 = getelementptr inbounds %struct.Longtail_LogContextFmt_Private, ptr %10, i32 0, i32 1
  %42 = getelementptr inbounds [4 x %struct.Longtail_LogFieldFmt_Private], ptr %9, i64 0, i64 0
  store ptr %42, ptr %41, align 8, !tbaa !18
  %43 = getelementptr inbounds %struct.Longtail_LogContextFmt_Private, ptr %10, i32 0, i32 2
  store i64 4, ptr %43, align 8, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  store ptr %10, ptr %11, align 8, !tbaa !5
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str.3, ptr noundef @__func__._ZN19TestAsyncBlockStore11PruneBlocksEP22Longtail_BlockStoreAPIjPKmP28Longtail_AsyncPruneBlocksAPI, i32 noundef 4113, ptr noundef %44, i32 noundef 0, ptr noundef @.str.587, ptr noundef @.str.588)
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %45, ptr %12, align 8, !tbaa !5
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.Longtail_AsyncPruneBlocksAPI, ptr %46, i32 0, i32 1
  %48 = load ptr, ptr %47, align 8, !tbaa !20
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  call void %48(ptr noundef %49, i32 noundef 0, i32 noundef 0)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 96, ptr %9) #3
  ret i32 0
}

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 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS28Longtail_LogFieldFmt_Private", !6, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!12, !6, i64 8}
!14 = !{!12, !6, i64 16}
!15 = !{!16, !6, i64 0}
!16 = !{!"_ZTS30Longtail_LogContextFmt_Private", !6, i64 0, !6, i64 8, !17, i64 16}
!17 = !{!"long", !7, i64 0}
!18 = !{!16, !6, i64 8}
!19 = !{!16, !17, i64 16}
!20 = !{!21, !6, i64 8}
!21 = !{!"_ZTS28Longtail_AsyncPruneBlocksAPI", !22, i64 0, !6, i64 8}
!22 = !{!"_ZTS12Longtail_API", !6, 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.3 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.586 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.587 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.588 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.590 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.592 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.594 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.597 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.598 = external hidden unnamed_addr constant [18 x i8], align 1
@__func__._ZN19TestAsyncBlockStore11PruneBlocksEP22Longtail_BlockStoreAPIjPKmP28Longtail_AsyncPruneBlocksAPI = external hidden unnamed_addr constant [12 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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN19TestAsyncBlockStore11PruneBlocksEP22Longtail_BlockStoreAPIjPKmP28Longtail_AsyncPruneBlocksAPI(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #2 align 2 {
  %5 = alloca [4 x %struct.Longtail_LogFieldFmt_Private], align 16
  %6 = alloca %struct.Longtail_LogContextFmt_Private, align 8
  call void @llvm.lifetime.start.p0(i64 96, ptr nonnull %5) #3
  store ptr @.str.590, ptr %5, align 16, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr @.str.586, ptr %7, align 8, !tbaa !10
  %8 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr %0, ptr %8, align 16, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %5, i64 24
  store ptr @.str.597, ptr %9, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %5, i64 32
  store ptr @.str.594, ptr %10, align 16, !tbaa !10
  %11 = getelementptr inbounds i8, ptr %5, i64 40
  %12 = zext i32 %1 to i64
  %13 = inttoptr i64 %12 to ptr
  store ptr %13, ptr %11, align 8, !tbaa !11
  %14 = getelementptr inbounds i8, ptr %5, i64 48
  store ptr @.str.598, ptr %14, align 16, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %5, i64 56
  store ptr @.str.586, ptr %15, align 8, !tbaa !10
  %16 = getelementptr inbounds i8, ptr %5, i64 64
  store ptr %2, ptr %16, align 16, !tbaa !11
  %17 = getelementptr inbounds i8, ptr %5, i64 72
  store ptr @.str.592, ptr %17, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %5, i64 80
  store ptr @.str.586, ptr %18, align 16, !tbaa !10
  %19 = getelementptr inbounds i8, ptr %5, i64 88
  store ptr %3, ptr %19, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #3
  store ptr null, ptr %6, align 8, !tbaa !12
  %20 = getelementptr inbounds i8, ptr %6, i64 8
  store ptr %5, ptr %20, align 8, !tbaa !15
  %21 = getelementptr inbounds i8, ptr %6, i64 16
  store i64 4, ptr %21, align 8, !tbaa !16
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str.3, ptr noundef nonnull @__func__._ZN19TestAsyncBlockStore11PruneBlocksEP22Longtail_BlockStoreAPIjPKmP28Longtail_AsyncPruneBlocksAPI, i32 noundef 4113, ptr noundef nonnull %6, i32 noundef 0, ptr noundef nonnull @.str.587, ptr noundef nonnull @.str.588)
  %22 = getelementptr inbounds i8, ptr %3, i64 8
  %23 = load ptr, ptr %22, align 8, !tbaa !17
  call void %23(ptr noundef %3, i32 noundef 0, i32 noundef 0)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %5) #3
  ret i32 0
}

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 = { mustprogress 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 = !{!"_ZTS28Longtail_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++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 16}
!12 = !{!13, !7, i64 0}
!13 = !{!"_ZTS30Longtail_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 = !{!18, !7, i64 8}
!18 = !{!"_ZTS28Longtail_AsyncPruneBlocksAPI", !19, i64 0, !7, i64 8}
!19 = !{!"_ZTS12Longtail_API", !7, i64 0}


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