; LLVM IR from DanEngelbrecht/longtail :: lib/hpcdcchunker (longtail_hpcdcchunker)

; 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_HPCDCChunkerAPI = type { %struct.Longtail_ChunkerAPI, ptr, [232 x ptr], i32 }
%struct.Longtail_ChunkerAPI = type { %struct.Longtail_API, ptr, ptr, ptr, ptr, ptr }
%struct.Longtail_API = type { ptr }

@.str = external hidden unnamed_addr constant [98 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 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 [12 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [8 x i8], align 1
@__func__.HPCDCChunker_DisposeChunker = external hidden unnamed_addr constant [28 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_CallLogger(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, 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 void @Longtail_LockSpinLock(ptr noundef) #1

declare void @Longtail_Free(ptr noundef) #1

declare void @Longtail_UnlockSpinLock(ptr noundef) #1

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

31:                                               ; preds = %2
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str, ptr noundef @__func__.HPCDCChunker_DisposeChunker, i32 noundef 434, ptr noundef %32, i32 noundef 3, ptr noundef @.str.8, ptr noundef @.str.6)
  store i32 22, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %69

33:                                               ; preds = %2
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %38, label %36

36:                                               ; preds = %33
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str, ptr noundef @__func__.HPCDCChunker_DisposeChunker, i32 noundef 435, ptr noundef %37, i32 noundef 3, ptr noundef @.str.8, ptr noundef @.str.14)
  store i32 22, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %69

38:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %39, ptr %10, align 8, !tbaa !5
  %40 = load ptr, ptr %10, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.Longtail_HPCDCChunkerAPI, ptr %40, i32 0, i32 1
  %42 = load ptr, ptr %41, align 8, !tbaa !18
  call void @Longtail_LockSpinLock(ptr noundef %42)
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.Longtail_HPCDCChunkerAPI, ptr %43, i32 0, i32 3
  %45 = load i32, ptr %44, align 8, !tbaa !23
  %46 = icmp eq i32 %45, 232
  br i1 %46, label %47, label %52

47:                                               ; preds = %38
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Longtail_HPCDCChunkerAPI, ptr %48, i32 0, i32 1
  %50 = load ptr, ptr %49, align 8, !tbaa !18
  call void @Longtail_UnlockSpinLock(ptr noundef %50)
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  call void @Longtail_Free(ptr noundef %51)
  br label %68

52:                                               ; preds = %38
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.Longtail_HPCDCChunkerAPI, ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.Longtail_HPCDCChunkerAPI, ptr %56, i32 0, i32 3
  %58 = load i32, ptr %57, align 8, !tbaa !23
  %59 = zext i32 %58 to i64
  %60 = getelementptr inbounds [232 x ptr], ptr %55, i64 0, i64 %59
  store ptr %53, ptr %60, align 8, !tbaa !5
  %61 = load ptr, ptr %10, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.Longtail_HPCDCChunkerAPI, ptr %61, i32 0, i32 3
  %63 = load i32, ptr %62, align 8, !tbaa !23
  %64 = add i32 %63, 1
  store i32 %64, ptr %62, align 8, !tbaa !23
  %65 = load ptr, ptr %10, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.Longtail_HPCDCChunkerAPI, ptr %65, i32 0, i32 1
  %67 = load ptr, ptr %66, align 8, !tbaa !18
  call void @Longtail_UnlockSpinLock(ptr noundef %67)
  br label %68

68:                                               ; preds = %52, %47
  store i32 0, ptr %3, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %69

69:                                               ; preds = %68, %36, %31
  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
  %70 = load i32, ptr %3, align 4
  ret i32 %70
}

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 = !{!19, !6, i64 48}
!19 = !{!"Longtail_HPCDCChunkerAPI", !20, i64 0, !6, i64 48, !7, i64 56, !22, i64 1912}
!20 = !{!"Longtail_ChunkerAPI", !21, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!21 = !{!"Longtail_API", !6, i64 0}
!22 = !{!"int", !7, i64 0}
!23 = !{!19, !22, i64 1912}


; 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 [98 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 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 [12 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [8 x i8], align 1
@__func__.HPCDCChunker_DisposeChunker = external hidden unnamed_addr constant [28 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_CallLogger(ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, 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 void @Longtail_LockSpinLock(ptr noundef) local_unnamed_addr #1

declare void @Longtail_Free(ptr noundef) local_unnamed_addr #1

declare void @Longtail_UnlockSpinLock(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 23) i32 @HPCDCChunker_DisposeChunker(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca [2 x %struct.Longtail_LogFieldFmt_Private], align 16
  %4 = alloca %struct.Longtail_LogContextFmt_Private, align 8
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %3) #3
  store ptr @.str.6, ptr %3, align 16, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr @.str.3, ptr %5, align 8, !tbaa !10
  %6 = getelementptr inbounds i8, ptr %3, i64 16
  store ptr %0, ptr %6, align 16, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %3, i64 24
  store ptr @.str.14, ptr %7, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %3, i64 32
  store ptr @.str.3, ptr %8, align 16, !tbaa !10
  %9 = getelementptr inbounds i8, ptr %3, i64 40
  store ptr %1, ptr %9, 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
  %10 = getelementptr inbounds i8, ptr %4, i64 8
  store ptr %3, ptr %10, align 8, !tbaa !15
  %11 = getelementptr inbounds i8, ptr %4, i64 16
  store i64 2, ptr %11, align 8, !tbaa !16
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str, ptr noundef nonnull @__func__.HPCDCChunker_DisposeChunker, i32 noundef 432, 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 %12, label %13

12:                                               ; preds = %2
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str, ptr noundef nonnull @__func__.HPCDCChunker_DisposeChunker, i32 noundef 434, ptr noundef nonnull %4, i32 noundef 3, ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.6) #3
  br label %29

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

14:                                               ; preds = %13
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str, ptr noundef nonnull @__func__.HPCDCChunker_DisposeChunker, i32 noundef 435, ptr noundef nonnull %4, i32 noundef 3, ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.14) #3
  br label %29

15:                                               ; preds = %13
  %16 = getelementptr inbounds i8, ptr %0, i64 48
  %17 = load ptr, ptr %16, align 8, !tbaa !17
  call void @Longtail_LockSpinLock(ptr noundef %17) #3
  %18 = getelementptr inbounds i8, ptr %0, i64 1912
  %19 = load i32, ptr %18, align 8, !tbaa !22
  %20 = icmp eq i32 %19, 232
  br i1 %20, label %21, label %23

21:                                               ; preds = %15
  %22 = load ptr, ptr %16, align 8, !tbaa !17
  call void @Longtail_UnlockSpinLock(ptr noundef %22) #3
  call void @Longtail_Free(ptr noundef nonnull %1) #3
  br label %29

23:                                               ; preds = %15
  %24 = getelementptr inbounds i8, ptr %0, i64 56
  %25 = zext i32 %19 to i64
  %26 = getelementptr inbounds [232 x ptr], ptr %24, i64 0, i64 %25
  store ptr %1, ptr %26, align 8, !tbaa !23
  %27 = add i32 %19, 1
  store i32 %27, ptr %18, align 8, !tbaa !22
  %28 = load ptr, ptr %16, align 8, !tbaa !17
  call void @Longtail_UnlockSpinLock(ptr noundef %28) #3
  br label %29

29:                                               ; preds = %21, %23, %14, %12
  %.0 = phi i32 [ 22, %14 ], [ 22, %12 ], [ 0, %23 ], [ 0, %21 ]
  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 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 = { 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 = !{!18, !7, i64 48}
!18 = !{!"Longtail_HPCDCChunkerAPI", !19, i64 0, !7, i64 48, !8, i64 56, !21, i64 1912}
!19 = !{!"Longtail_ChunkerAPI", !20, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}
!20 = !{!"Longtail_API", !7, i64 0}
!21 = !{!"int", !8, i64 0}
!22 = !{!18, !21, i64 1912}
!23 = !{!7, !7, i64 0}


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