; 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_Chunker_ChunkRange = type { ptr, i64, i32 }

@.str = external hidden unnamed_addr constant [98 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
@__func__.HPCDCChunker_NextChunk = external hidden unnamed_addr constant [23 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @Longtail_HPCDCNextChunk(ptr dead_on_unwind noalias writable sret(%struct.Longtail_Chunker_ChunkRange) align 8, ptr noundef, ptr noundef, ptr noundef) #0

; 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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @HPCDCChunker_NextChunk(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca %struct.Longtail_Chunker_ChunkRange, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  store ptr null, ptr %12, align 8, !tbaa !5
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %21, label %19

19:                                               ; preds = %5
  %20 = load ptr, ptr %12, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str, ptr noundef @__func__.HPCDCChunker_NextChunk, i32 noundef 409, ptr noundef %20, i32 noundef 3, ptr noundef @.str.8, ptr noundef @.str.6)
  store i32 22, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %60

21:                                               ; preds = %5
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %26, label %24

24:                                               ; preds = %21
  %25 = load ptr, ptr %12, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str, ptr noundef @__func__.HPCDCChunker_NextChunk, i32 noundef 410, ptr noundef %25, i32 noundef 3, ptr noundef @.str.8, ptr noundef @.str.14)
  store i32 22, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %60

26:                                               ; preds = %21
  %27 = load ptr, ptr %10, align 8, !tbaa !5
  %28 = icmp ne ptr %27, null
  br i1 %28, label %31, label %29

29:                                               ; preds = %26
  %30 = load ptr, ptr %12, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str, ptr noundef @__func__.HPCDCChunker_NextChunk, i32 noundef 411, ptr noundef %30, i32 noundef 3, ptr noundef @.str.8, ptr noundef @.str.15)
  store i32 22, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %60

31:                                               ; preds = %26
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = icmp ne ptr %32, null
  br i1 %33, label %36, label %34

34:                                               ; preds = %31
  %35 = load ptr, ptr %12, align 8, !tbaa !5
  call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef @.str, ptr noundef @__func__.HPCDCChunker_NextChunk, i32 noundef 412, ptr noundef %35, i32 noundef 3, ptr noundef @.str.8, ptr noundef @.str.16)
  store i32 22, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %60

36:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %37, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %38, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %16) #3
  %39 = load ptr, ptr %15, align 8, !tbaa !5
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  call void @Longtail_HPCDCNextChunk(ptr dead_on_unwind writable sret(%struct.Longtail_Chunker_ChunkRange) align 8 %16, ptr noundef %39, ptr noundef %40, ptr noundef %41)
  %42 = getelementptr inbounds %struct.Longtail_Chunker_ChunkRange, ptr %16, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !9
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.Longtail_Chunker_ChunkRange, ptr %44, i32 0, i32 0
  store ptr %43, ptr %45, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct.Longtail_Chunker_ChunkRange, ptr %16, i32 0, i32 2
  %47 = load i32, ptr %46, align 8, !tbaa !13
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.Longtail_Chunker_ChunkRange, ptr %48, i32 0, i32 2
  store i32 %47, ptr %49, align 8, !tbaa !13
  %50 = getelementptr inbounds %struct.Longtail_Chunker_ChunkRange, ptr %16, i32 0, i32 1
  %51 = load i64, ptr %50, align 8, !tbaa !14
  %52 = load ptr, ptr %11, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.Longtail_Chunker_ChunkRange, ptr %52, i32 0, i32 1
  store i64 %51, ptr %53, align 8, !tbaa !14
  %54 = getelementptr inbounds %struct.Longtail_Chunker_ChunkRange, ptr %16, i32 0, i32 2
  %55 = load i32, ptr %54, align 8, !tbaa !13
  %56 = icmp eq i32 %55, 0
  br i1 %56, label %57, label %58

57:                                               ; preds = %36
  store i32 29, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %59

58:                                               ; preds = %36
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %59

59:                                               ; preds = %58, %57
  call void @llvm.lifetime.end.p0(i64 24, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  br label %60

60:                                               ; preds = %59, %34, %29, %24, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %61 = load i32, ptr %6, align 4
  ret i32 %61
}

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_Chunker_ChunkRange", !6, i64 0, !11, i64 8, !12, i64 16}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 16}
!14 = !{!10, !11, i64 8}


; 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_Chunker_ChunkRange = type { ptr, i64, i32 }

@.str = external hidden unnamed_addr constant [98 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
@__func__.HPCDCChunker_NextChunk = external hidden unnamed_addr constant [23 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [16 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @Longtail_HPCDCNextChunk(ptr dead_on_unwind noalias writable sret(%struct.Longtail_Chunker_ChunkRange) align 8, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; 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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 30) i32 @HPCDCChunker_NextChunk(ptr noundef readnone %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef writeonly %4) local_unnamed_addr #0 {
  %6 = alloca %struct.Longtail_Chunker_ChunkRange, align 8
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %7, label %8

7:                                                ; preds = %5
  tail call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str, ptr noundef nonnull @__func__.HPCDCChunker_NextChunk, i32 noundef 409, ptr noundef null, i32 noundef 3, ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.6) #3
  br label %23

8:                                                ; preds = %5
  %.not19 = icmp eq ptr %1, null
  br i1 %.not19, label %9, label %10

9:                                                ; preds = %8
  tail call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str, ptr noundef nonnull @__func__.HPCDCChunker_NextChunk, i32 noundef 410, ptr noundef null, i32 noundef 3, ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.14) #3
  br label %23

10:                                               ; preds = %8
  %.not20 = icmp eq ptr %3, null
  br i1 %.not20, label %11, label %12

11:                                               ; preds = %10
  tail call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str, ptr noundef nonnull @__func__.HPCDCChunker_NextChunk, i32 noundef 411, ptr noundef null, i32 noundef 3, ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.15) #3
  br label %23

12:                                               ; preds = %10
  %.not21 = icmp eq ptr %4, null
  br i1 %.not21, label %13, label %14

13:                                               ; preds = %12
  tail call void (ptr, ptr, i32, ptr, i32, ptr, ...) @Longtail_CallLogger(ptr noundef nonnull @.str, ptr noundef nonnull @__func__.HPCDCChunker_NextChunk, i32 noundef 412, ptr noundef null, i32 noundef 3, ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.16) #3
  br label %23

14:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #3
  call void @Longtail_HPCDCNextChunk(ptr dead_on_unwind nonnull writable sret(%struct.Longtail_Chunker_ChunkRange) align 8 %6, ptr noundef nonnull %1, ptr noundef %2, ptr noundef nonnull %3)
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %15, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %6, i64 16
  %17 = load i32, ptr %16, align 8, !tbaa !12
  %18 = getelementptr inbounds i8, ptr %4, i64 16
  store i32 %17, ptr %18, align 8, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %6, i64 8
  %20 = load i64, ptr %19, align 8, !tbaa !13
  %21 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %20, ptr %21, align 8, !tbaa !13
  %22 = icmp eq i32 %17, 0
  %. = select i1 %22, i32 29, i32 0
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #3
  br label %23

23:                                               ; preds = %14, %13, %11, %9, %7
  %.1 = phi i32 [ %., %14 ], [ 22, %13 ], [ 22, %11 ], [ 22, %9 ], [ 22, %7 ]
  ret i32 %.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_Chunker_ChunkRange", !7, i64 0, !10, i64 8, !11, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!6, !11, i64 16}
!13 = !{!6, !10, i64 8}


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