; LLVM IR from Nonoum/ECL :: ECL_NanoLZ (ECL_NanoLZ_Compress_auto_ex)

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

; 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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @ECL_NanoLZ_ValidateU16size(i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ECL_NanoLZ_Compress_mid2(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ECL_NanoLZ_Compress_mid2min(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @ECL_NanoLZ_FastParams_Alloc1(ptr noundef, i8 noundef zeroext) #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @ECL_NanoLZ_FastParams_Alloc2(ptr noundef, i8 noundef zeroext) #1

; Function Attrs: nounwind uwtable
declare dso_local void @ECL_NanoLZ_FastParams_Destroy(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ECL_NanoLZ_Compress_fast1(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ECL_NanoLZ_Compress_fast2(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @ECL_NanoLZ_Compress_auto_ex(i32 noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef %6, ptr noundef %7) #1 {
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca [513 x i8], align 16
  %19 = alloca [513 x i8], align 16
  %20 = alloca [113 x i8], align 16
  %21 = alloca %struct.ECL_NanoLZ_FastParams, align 8
  %22 = alloca %struct.ECL_NanoLZ_FastParams, align 8
  store i32 %0, ptr %9, align 4, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !9
  store i32 %2, ptr %11, align 4, !tbaa !5
  store ptr %3, ptr %12, align 8, !tbaa !9
  store i32 %4, ptr %13, align 4, !tbaa !5
  store i32 %5, ptr %14, align 4, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !9
  store ptr %7, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  store i32 0, ptr %17, align 4, !tbaa !5
  %23 = load i32, ptr %14, align 4, !tbaa !5
  %24 = icmp ult i32 %23, 2
  br i1 %24, label %25, label %36

25:                                               ; preds = %8
  %26 = load i32, ptr %11, align 4, !tbaa !5
  %27 = call zeroext i1 @ECL_NanoLZ_ValidateU16size(i32 noundef %26)
  br i1 %27, label %28, label %36

28:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 513, ptr %18) #4
  %29 = load i32, ptr %9, align 4, !tbaa !5
  %30 = load ptr, ptr %10, align 8, !tbaa !9
  %31 = load i32, ptr %11, align 4, !tbaa !5
  %32 = load ptr, ptr %12, align 8, !tbaa !9
  %33 = load i32, ptr %13, align 4, !tbaa !5
  %34 = getelementptr inbounds [513 x i8], ptr %18, i64 0, i64 0
  %35 = call i32 @ECL_NanoLZ_Compress_mid2min(i32 noundef %29, ptr noundef %30, i32 noundef %31, ptr noundef %32, i32 noundef %33, ptr noundef %34)
  store i32 %35, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 513, ptr %18) #4
  br label %116

36:                                               ; preds = %25, %8
  %37 = load i32, ptr %11, align 4, !tbaa !5
  %38 = icmp ult i32 %37, 70
  br i1 %38, label %39, label %59

39:                                               ; preds = %36
  call void @llvm.lifetime.start.p0(i64 513, ptr %19) #4
  call void @llvm.lifetime.start.p0(i64 113, ptr %20) #4
  %40 = load i32, ptr %9, align 4, !tbaa !5
  %41 = load ptr, ptr %10, align 8, !tbaa !9
  %42 = load i32, ptr %11, align 4, !tbaa !5
  %43 = getelementptr inbounds [113 x i8], ptr %20, i64 0, i64 0
  %44 = load i32, ptr %14, align 4, !tbaa !5
  %45 = getelementptr inbounds [513 x i8], ptr %19, i64 0, i64 0
  %46 = call i32 @ECL_NanoLZ_Compress_mid2(i32 noundef %40, ptr noundef %41, i32 noundef %42, ptr noundef %43, i32 noundef 113, i32 noundef %44, ptr noundef %45)
  store i32 %46, ptr %17, align 4, !tbaa !5
  %47 = load i32, ptr %17, align 4, !tbaa !5
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %58

49:                                               ; preds = %39
  %50 = load i32, ptr %17, align 4, !tbaa !5
  %51 = load i32, ptr %13, align 4, !tbaa !5
  %52 = icmp ule i32 %50, %51
  br i1 %52, label %53, label %58

53:                                               ; preds = %49
  %54 = load ptr, ptr %12, align 8, !tbaa !9
  %55 = getelementptr inbounds [113 x i8], ptr %20, i64 0, i64 0
  %56 = load i32, ptr %17, align 4, !tbaa !5
  %57 = zext i32 %56 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %54, ptr align 16 %55, i64 %57, i1 false)
  br label %58

58:                                               ; preds = %53, %49, %39
  call void @llvm.lifetime.end.p0(i64 113, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 513, ptr %19) #4
  br label %115

59:                                               ; preds = %36
  %60 = load i32, ptr %11, align 4, !tbaa !5
  %61 = icmp ult i32 %60, 1500
  br i1 %61, label %62, label %88

62:                                               ; preds = %59
  %63 = load ptr, ptr %15, align 8, !tbaa !9
  %64 = icmp ne ptr %63, null
  br i1 %64, label %65, label %74

65:                                               ; preds = %62
  %66 = load i32, ptr %9, align 4, !tbaa !5
  %67 = load ptr, ptr %10, align 8, !tbaa !9
  %68 = load i32, ptr %11, align 4, !tbaa !5
  %69 = load ptr, ptr %12, align 8, !tbaa !9
  %70 = load i32, ptr %13, align 4, !tbaa !5
  %71 = load i32, ptr %14, align 4, !tbaa !5
  %72 = load ptr, ptr %15, align 8, !tbaa !9
  %73 = call i32 @ECL_NanoLZ_Compress_fast1(i32 noundef %66, ptr noundef %67, i32 noundef %68, ptr noundef %69, i32 noundef %70, i32 noundef %71, ptr noundef %72)
  store i32 %73, ptr %17, align 4, !tbaa !5
  br label %87

74:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 24, ptr %21) #4
  %75 = load i32, ptr %11, align 4, !tbaa !5
  %76 = call zeroext i8 @ECL_LogRoundUp(i32 noundef %75)
  %77 = call zeroext i1 @ECL_NanoLZ_FastParams_Alloc1(ptr noundef %21, i8 noundef zeroext %76)
  br i1 %77, label %78, label %86

78:                                               ; preds = %74
  %79 = load i32, ptr %9, align 4, !tbaa !5
  %80 = load ptr, ptr %10, align 8, !tbaa !9
  %81 = load i32, ptr %11, align 4, !tbaa !5
  %82 = load ptr, ptr %12, align 8, !tbaa !9
  %83 = load i32, ptr %13, align 4, !tbaa !5
  %84 = load i32, ptr %14, align 4, !tbaa !5
  %85 = call i32 @ECL_NanoLZ_Compress_fast1(i32 noundef %79, ptr noundef %80, i32 noundef %81, ptr noundef %82, i32 noundef %83, i32 noundef %84, ptr noundef %21)
  store i32 %85, ptr %17, align 4, !tbaa !5
  call void @ECL_NanoLZ_FastParams_Destroy(ptr noundef %21)
  br label %86

86:                                               ; preds = %78, %74
  call void @llvm.lifetime.end.p0(i64 24, ptr %21) #4
  br label %87

87:                                               ; preds = %86, %65
  br label %114

88:                                               ; preds = %59
  %89 = load ptr, ptr %16, align 8, !tbaa !9
  %90 = icmp ne ptr %89, null
  br i1 %90, label %91, label %100

91:                                               ; preds = %88
  %92 = load i32, ptr %9, align 4, !tbaa !5
  %93 = load ptr, ptr %10, align 8, !tbaa !9
  %94 = load i32, ptr %11, align 4, !tbaa !5
  %95 = load ptr, ptr %12, align 8, !tbaa !9
  %96 = load i32, ptr %13, align 4, !tbaa !5
  %97 = load i32, ptr %14, align 4, !tbaa !5
  %98 = load ptr, ptr %16, align 8, !tbaa !9
  %99 = call i32 @ECL_NanoLZ_Compress_fast2(i32 noundef %92, ptr noundef %93, i32 noundef %94, ptr noundef %95, i32 noundef %96, i32 noundef %97, ptr noundef %98)
  store i32 %99, ptr %17, align 4, !tbaa !5
  br label %113

100:                                              ; preds = %88
  call void @llvm.lifetime.start.p0(i64 24, ptr %22) #4
  %101 = load i32, ptr %11, align 4, !tbaa !5
  %102 = call zeroext i8 @ECL_LogRoundUp(i32 noundef %101)
  %103 = call zeroext i1 @ECL_NanoLZ_FastParams_Alloc2(ptr noundef %22, i8 noundef zeroext %102)
  br i1 %103, label %104, label %112

104:                                              ; preds = %100
  %105 = load i32, ptr %9, align 4, !tbaa !5
  %106 = load ptr, ptr %10, align 8, !tbaa !9
  %107 = load i32, ptr %11, align 4, !tbaa !5
  %108 = load ptr, ptr %12, align 8, !tbaa !9
  %109 = load i32, ptr %13, align 4, !tbaa !5
  %110 = load i32, ptr %14, align 4, !tbaa !5
  %111 = call i32 @ECL_NanoLZ_Compress_fast2(i32 noundef %105, ptr noundef %106, i32 noundef %107, ptr noundef %108, i32 noundef %109, i32 noundef %110, ptr noundef %22)
  store i32 %111, ptr %17, align 4, !tbaa !5
  call void @ECL_NanoLZ_FastParams_Destroy(ptr noundef %22)
  br label %112

112:                                              ; preds = %104, %100
  call void @llvm.lifetime.end.p0(i64 24, ptr %22) #4
  br label %113

113:                                              ; preds = %112, %91
  br label %114

114:                                              ; preds = %113, %87
  br label %115

115:                                              ; preds = %114, %58
  br label %116

116:                                              ; preds = %115, %28
  %117 = load i32, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  ret i32 %117
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare zeroext i8 @ECL_LogRoundUp(i32 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 #4 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !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.ECL_NanoLZ_FastParams = type { ptr, ptr, i32 }

; 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

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @ECL_NanoLZ_ValidateU16size(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ECL_NanoLZ_Compress_mid2(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ECL_NanoLZ_Compress_mid2min(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @ECL_NanoLZ_FastParams_Alloc1(ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @ECL_NanoLZ_FastParams_Alloc2(ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @ECL_NanoLZ_FastParams_Destroy(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ECL_NanoLZ_Compress_fast1(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @ECL_NanoLZ_Compress_fast2(i32 noundef, ptr noundef, i32 noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @ECL_NanoLZ_Compress_auto_ex(i32 noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef %6, ptr noundef %7) local_unnamed_addr #1 {
  %9 = alloca [513 x i8], align 16
  %10 = alloca [513 x i8], align 16
  %11 = alloca [113 x i8], align 16
  %12 = alloca %struct.ECL_NanoLZ_FastParams, align 8
  %13 = alloca %struct.ECL_NanoLZ_FastParams, align 8
  %14 = icmp ult i32 %5, 2
  br i1 %14, label %15, label %19

15:                                               ; preds = %8
  %16 = tail call zeroext i1 @ECL_NanoLZ_ValidateU16size(i32 noundef %2)
  br i1 %16, label %17, label %19

17:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 513, ptr nonnull %9) #4
  %18 = call i32 @ECL_NanoLZ_Compress_mid2min(i32 noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4, ptr noundef nonnull %9)
  call void @llvm.lifetime.end.p0(i64 513, ptr nonnull %9) #4
  br label %47

19:                                               ; preds = %15, %8
  %20 = icmp ult i32 %2, 70
  br i1 %20, label %21, label %27

21:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 513, ptr nonnull %10) #4
  call void @llvm.lifetime.start.p0(i64 113, ptr nonnull %11) #4
  %22 = call i32 @ECL_NanoLZ_Compress_mid2(i32 noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef nonnull %11, i32 noundef 113, i32 noundef %5, ptr noundef nonnull %10)
  %23 = add i32 %22, -1
  %or.cond.not = icmp ult i32 %23, %4
  br i1 %or.cond.not, label %24, label %26

24:                                               ; preds = %21
  %25 = zext i32 %22 to i64
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %3, ptr nonnull align 16 %11, i64 %25, i1 false)
  br label %26

26:                                               ; preds = %24, %21
  call void @llvm.lifetime.end.p0(i64 113, ptr nonnull %11) #4
  call void @llvm.lifetime.end.p0(i64 513, ptr nonnull %10) #4
  br label %47

27:                                               ; preds = %19
  %28 = icmp ult i32 %2, 1500
  br i1 %28, label %29, label %38

29:                                               ; preds = %27
  %.not53 = icmp eq ptr %6, null
  br i1 %.not53, label %32, label %30

30:                                               ; preds = %29
  %31 = tail call i32 @ECL_NanoLZ_Compress_fast1(i32 noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef nonnull %6)
  br label %47

32:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %12) #4
  %33 = tail call zeroext i8 @ECL_LogRoundUp(i32 noundef %2) #4
  %34 = call zeroext i1 @ECL_NanoLZ_FastParams_Alloc1(ptr noundef nonnull %12, i8 noundef zeroext %33)
  br i1 %34, label %35, label %37

35:                                               ; preds = %32
  %36 = call i32 @ECL_NanoLZ_Compress_fast1(i32 noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef nonnull %12)
  call void @ECL_NanoLZ_FastParams_Destroy(ptr noundef nonnull %12)
  br label %37

37:                                               ; preds = %35, %32
  %.0 = phi i32 [ %36, %35 ], [ 0, %32 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %12) #4
  br label %47

38:                                               ; preds = %27
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %41, label %39

39:                                               ; preds = %38
  %40 = tail call i32 @ECL_NanoLZ_Compress_fast2(i32 noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef nonnull %7)
  br label %47

41:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %13) #4
  %42 = tail call zeroext i8 @ECL_LogRoundUp(i32 noundef %2) #4
  %43 = call zeroext i1 @ECL_NanoLZ_FastParams_Alloc2(ptr noundef nonnull %13, i8 noundef zeroext %42)
  br i1 %43, label %44, label %46

44:                                               ; preds = %41
  %45 = call i32 @ECL_NanoLZ_Compress_fast2(i32 noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, i32 noundef %4, i32 noundef %5, ptr noundef nonnull %13)
  call void @ECL_NanoLZ_FastParams_Destroy(ptr noundef nonnull %13)
  br label %46

46:                                               ; preds = %44, %41
  %.1 = phi i32 [ %45, %44 ], [ 0, %41 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %13) #4
  br label %47

47:                                               ; preds = %26, %39, %46, %30, %37, %17
  %.2 = phi i32 [ %18, %17 ], [ %22, %26 ], [ %31, %30 ], [ %.0, %37 ], [ %40, %39 ], [ %.1, %46 ]
  ret i32 %.2
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

declare zeroext i8 @ECL_LogRoundUp(i32 noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 #4 = { 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)"}


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