; LLVM IR from DanEngelbrecht/longtail :: lib/lz4/ext (lz4)

; 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.LZ4_stream_t_internal = type { [4096 x i32], ptr, ptr, i32, i32, i32 }

; Function Attrs: nounwind uwtable
declare dso_local i32 @LZ4_compressBound(i32 noundef) #0

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @LZ4_compress_generic(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 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 @LZ4_compress_fast_extState_fastReset(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #0 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store i32 %3, ptr %11, align 4, !tbaa !9
  store i32 %4, ptr %12, align 4, !tbaa !9
  store i32 %5, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %20, ptr %14, align 8, !tbaa !5
  %21 = load i32, ptr %13, align 4, !tbaa !9
  %22 = icmp slt i32 %21, 1
  br i1 %22, label %23, label %24

23:                                               ; preds = %6
  store i32 1, ptr %13, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %23, %6
  %25 = load i32, ptr %13, align 4, !tbaa !9
  %26 = icmp sgt i32 %25, 65537
  br i1 %26, label %27, label %28

27:                                               ; preds = %24
  store i32 65537, ptr %13, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %27, %24
  %29 = load i32, ptr %12, align 4, !tbaa !9
  %30 = load i32, ptr %11, align 4, !tbaa !9
  %31 = call i32 @LZ4_compressBound(i32 noundef %30)
  %32 = icmp sge i32 %29, %31
  br i1 %32, label %33, label %67

33:                                               ; preds = %28
  %34 = load i32, ptr %11, align 4, !tbaa !9
  %35 = icmp slt i32 %34, 65547
  br i1 %35, label %36, label %58

36:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store i32 3, ptr %15, align 4, !tbaa !9
  %37 = load ptr, ptr %14, align 8, !tbaa !5
  %38 = load i32, ptr %11, align 4, !tbaa !9
  call void @LZ4_prepareTable(ptr noundef %37, i32 noundef %38, i32 noundef 3)
  %39 = load ptr, ptr %14, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.LZ4_stream_t_internal, ptr %39, i32 0, i32 3
  %41 = load i32, ptr %40, align 8, !tbaa !11
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %50

43:                                               ; preds = %36
  %44 = load ptr, ptr %14, align 8, !tbaa !5
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = load i32, ptr %11, align 4, !tbaa !9
  %48 = load i32, ptr %13, align 4, !tbaa !9
  %49 = call i32 @LZ4_compress_generic(ptr noundef %44, ptr noundef %45, ptr noundef %46, i32 noundef %47, ptr noundef null, i32 noundef 0, i32 noundef 0, i32 noundef 3, i32 noundef 0, i32 noundef 1, i32 noundef %48)
  store i32 %49, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %57

50:                                               ; preds = %36
  %51 = load ptr, ptr %14, align 8, !tbaa !5
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = load ptr, ptr %10, align 8, !tbaa !5
  %54 = load i32, ptr %11, align 4, !tbaa !9
  %55 = load i32, ptr %13, align 4, !tbaa !9
  %56 = call i32 @LZ4_compress_generic(ptr noundef %51, ptr noundef %52, ptr noundef %53, i32 noundef %54, ptr noundef null, i32 noundef 0, i32 noundef 0, i32 noundef 3, i32 noundef 0, i32 noundef 0, i32 noundef %55)
  store i32 %56, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %57

57:                                               ; preds = %50, %43
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %104

58:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  store i32 2, ptr %17, align 4, !tbaa !9
  %59 = load ptr, ptr %14, align 8, !tbaa !5
  %60 = load i32, ptr %11, align 4, !tbaa !9
  call void @LZ4_prepareTable(ptr noundef %59, i32 noundef %60, i32 noundef 2)
  %61 = load ptr, ptr %14, align 8, !tbaa !5
  %62 = load ptr, ptr %9, align 8, !tbaa !5
  %63 = load ptr, ptr %10, align 8, !tbaa !5
  %64 = load i32, ptr %11, align 4, !tbaa !9
  %65 = load i32, ptr %13, align 4, !tbaa !9
  %66 = call i32 @LZ4_compress_generic(ptr noundef %61, ptr noundef %62, ptr noundef %63, i32 noundef %64, ptr noundef null, i32 noundef 0, i32 noundef 0, i32 noundef 2, i32 noundef 0, i32 noundef 0, i32 noundef %65)
  store i32 %66, ptr %7, align 4
  store i32 1, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %104

67:                                               ; preds = %28
  %68 = load i32, ptr %11, align 4, !tbaa !9
  %69 = icmp slt i32 %68, 65547
  br i1 %69, label %70, label %94

70:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  store i32 3, ptr %18, align 4, !tbaa !9
  %71 = load ptr, ptr %14, align 8, !tbaa !5
  %72 = load i32, ptr %11, align 4, !tbaa !9
  call void @LZ4_prepareTable(ptr noundef %71, i32 noundef %72, i32 noundef 3)
  %73 = load ptr, ptr %14, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.LZ4_stream_t_internal, ptr %73, i32 0, i32 3
  %75 = load i32, ptr %74, align 8, !tbaa !11
  %76 = icmp ne i32 %75, 0
  br i1 %76, label %77, label %85

77:                                               ; preds = %70
  %78 = load ptr, ptr %14, align 8, !tbaa !5
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  %80 = load ptr, ptr %10, align 8, !tbaa !5
  %81 = load i32, ptr %11, align 4, !tbaa !9
  %82 = load i32, ptr %12, align 4, !tbaa !9
  %83 = load i32, ptr %13, align 4, !tbaa !9
  %84 = call i32 @LZ4_compress_generic(ptr noundef %78, ptr noundef %79, ptr noundef %80, i32 noundef %81, ptr noundef null, i32 noundef %82, i32 noundef 1, i32 noundef 3, i32 noundef 0, i32 noundef 1, i32 noundef %83)
  store i32 %84, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %93

85:                                               ; preds = %70
  %86 = load ptr, ptr %14, align 8, !tbaa !5
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  %88 = load ptr, ptr %10, align 8, !tbaa !5
  %89 = load i32, ptr %11, align 4, !tbaa !9
  %90 = load i32, ptr %12, align 4, !tbaa !9
  %91 = load i32, ptr %13, align 4, !tbaa !9
  %92 = call i32 @LZ4_compress_generic(ptr noundef %86, ptr noundef %87, ptr noundef %88, i32 noundef %89, ptr noundef null, i32 noundef %90, i32 noundef 1, i32 noundef 3, i32 noundef 0, i32 noundef 0, i32 noundef %91)
  store i32 %92, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %93

93:                                               ; preds = %85, %77
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  br label %104

94:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  store i32 2, ptr %19, align 4, !tbaa !9
  %95 = load ptr, ptr %14, align 8, !tbaa !5
  %96 = load i32, ptr %11, align 4, !tbaa !9
  call void @LZ4_prepareTable(ptr noundef %95, i32 noundef %96, i32 noundef 2)
  %97 = load ptr, ptr %14, align 8, !tbaa !5
  %98 = load ptr, ptr %9, align 8, !tbaa !5
  %99 = load ptr, ptr %10, align 8, !tbaa !5
  %100 = load i32, ptr %11, align 4, !tbaa !9
  %101 = load i32, ptr %12, align 4, !tbaa !9
  %102 = load i32, ptr %13, align 4, !tbaa !9
  %103 = call i32 @LZ4_compress_generic(ptr noundef %97, ptr noundef %98, ptr noundef %99, i32 noundef %100, ptr noundef null, i32 noundef %101, i32 noundef 1, i32 noundef 2, i32 noundef 0, i32 noundef 0, i32 noundef %102)
  store i32 %103, ptr %7, align 4
  store i32 1, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  br label %104

104:                                              ; preds = %94, %93, %58, %57
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %105 = load i32, ptr %7, align 4
  ret i32 %105
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @LZ4_prepareTable(ptr noundef, i32 noundef, i32 noundef) #2

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 = { alwaysinline 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 16400}
!12 = !{!"LZ4_stream_t_internal", !7, i64 0, !6, i64 16384, !6, i64 16392, !10, i64 16400, !10, i64 16404, !10, i64 16408}


; 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"

; Function Attrs: nounwind uwtable
declare dso_local i32 @LZ4_compressBound(i32 noundef) local_unnamed_addr #0

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @LZ4_compress_generic(ptr noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @LZ4_compress_fast_extState_fastReset(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  %spec.store.select = tail call i32 @llvm.smax.i32(i32 %5, i32 1)
  %spec.store.select1 = tail call i32 @llvm.umin.i32(i32 %spec.store.select, i32 65537)
  %7 = tail call i32 @LZ4_compressBound(i32 noundef %3)
  %.not = icmp sgt i32 %7, %4
  %8 = icmp slt i32 %3, 65547
  br i1 %.not, label %19, label %9

9:                                                ; preds = %6
  br i1 %8, label %10, label %17

10:                                               ; preds = %9
  tail call void @LZ4_prepareTable(ptr noundef %0, i32 noundef %3, i32 noundef 3)
  %11 = getelementptr inbounds i8, ptr %0, i64 16400
  %12 = load i32, ptr %11, align 8, !tbaa !5
  %.not56 = icmp eq i32 %12, 0
  br i1 %.not56, label %15, label %13

13:                                               ; preds = %10
  %14 = tail call i32 @LZ4_compress_generic(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef null, i32 noundef 0, i32 noundef 0, i32 noundef 3, i32 noundef 0, i32 noundef 1, i32 noundef %spec.store.select1)
  br label %29

15:                                               ; preds = %10
  %16 = tail call i32 @LZ4_compress_generic(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef null, i32 noundef 0, i32 noundef 0, i32 noundef 3, i32 noundef 0, i32 noundef 0, i32 noundef %spec.store.select1)
  br label %29

17:                                               ; preds = %9
  tail call void @LZ4_prepareTable(ptr noundef %0, i32 noundef %3, i32 noundef 2)
  %18 = tail call i32 @LZ4_compress_generic(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef null, i32 noundef 0, i32 noundef 0, i32 noundef 2, i32 noundef 0, i32 noundef 0, i32 noundef %spec.store.select1)
  br label %29

19:                                               ; preds = %6
  br i1 %8, label %20, label %27

20:                                               ; preds = %19
  tail call void @LZ4_prepareTable(ptr noundef %0, i32 noundef %3, i32 noundef 3)
  %21 = getelementptr inbounds i8, ptr %0, i64 16400
  %22 = load i32, ptr %21, align 8, !tbaa !5
  %.not55 = icmp eq i32 %22, 0
  br i1 %.not55, label %25, label %23

23:                                               ; preds = %20
  %24 = tail call i32 @LZ4_compress_generic(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef null, i32 noundef %4, i32 noundef 1, i32 noundef 3, i32 noundef 0, i32 noundef 1, i32 noundef %spec.store.select1)
  br label %29

25:                                               ; preds = %20
  %26 = tail call i32 @LZ4_compress_generic(ptr noundef nonnull %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef null, i32 noundef %4, i32 noundef 1, i32 noundef 3, i32 noundef 0, i32 noundef 0, i32 noundef %spec.store.select1)
  br label %29

27:                                               ; preds = %19
  tail call void @LZ4_prepareTable(ptr noundef %0, i32 noundef %3, i32 noundef 2)
  %28 = tail call i32 @LZ4_compress_generic(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef null, i32 noundef %4, i32 noundef 1, i32 noundef 2, i32 noundef 0, i32 noundef 0, i32 noundef %spec.store.select1)
  br label %29

29:                                               ; preds = %23, %25, %13, %15, %27, %17
  %.2 = phi i32 [ %18, %17 ], [ %28, %27 ], [ %14, %13 ], [ %16, %15 ], [ %24, %23 ], [ %26, %25 ]
  ret i32 %.2
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @LZ4_prepareTable(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umin.i32(i32, i32) #2

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 = { alwaysinline 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !10, i64 16400}
!6 = !{!"LZ4_stream_t_internal", !7, i64 0, !9, i64 16384, !9, i64 16392, !10, i64 16400, !10, i64 16404, !10, i64 16408}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"any pointer", !7, i64 0}
!10 = !{!"int", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass