; LLVM IR from Nonoum/ECL :: tests (tests)

; 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_ZeroEaterComprssorState = type { ptr, 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: mustprogress uwtable
define dso_local i32 @ECL_ZeroEater_Compress(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %struct.ECL_ZeroEaterComprssorState, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 32, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds i8, ptr %17, i64 %19
  store ptr %20, ptr %15, align 8, !tbaa !5
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %24, label %23

23:                                               ; preds = %4
  store i32 0, ptr %5, align 4
  store i32 1, ptr %16, align 4
  br label %127

24:                                               ; preds = %4
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %28, label %27

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

28:                                               ; preds = %27, %24
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ECL_ZeroEaterComprssorState, ptr %10, i32 0, i32 0
  store ptr %29, ptr %30, align 8, !tbaa !11
  %31 = getelementptr inbounds %struct.ECL_ZeroEaterComprssorState, ptr %10, i32 0, i32 3
  store i32 0, ptr %31, align 8, !tbaa !13
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ECL_ZeroEaterComprssorState, ptr %10, i32 0, i32 1
  store ptr %32, ptr %33, align 8, !tbaa !14
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %41

36:                                               ; preds = %28
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = load i32, ptr %9, align 4, !tbaa !9
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds i8, ptr %37, i64 %39
  br label %43

41:                                               ; preds = %28
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %41, %36
  %44 = phi ptr [ %40, %36 ], [ %42, %41 ]
  %45 = getelementptr inbounds %struct.ECL_ZeroEaterComprssorState, ptr %10, i32 0, i32 2
  store ptr %44, ptr %45, align 8, !tbaa !15
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %46, ptr %13, align 8, !tbaa !5
  br label %47

47:                                               ; preds = %123, %113, %43
  %48 = getelementptr inbounds %struct.ECL_ZeroEaterComprssorState, ptr %10, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !11
  %50 = load ptr, ptr %15, align 8, !tbaa !5
  %51 = icmp ult ptr %49, %50
  br i1 %51, label %52, label %124

52:                                               ; preds = %47
  %53 = load ptr, ptr %13, align 8, !tbaa !5
  store ptr %53, ptr %14, align 8, !tbaa !5
  br label %54

54:                                               ; preds = %65, %52
  %55 = load ptr, ptr %14, align 8, !tbaa !5
  %56 = load ptr, ptr %15, align 8, !tbaa !5
  %57 = icmp ult ptr %55, %56
  br i1 %57, label %58, label %62

58:                                               ; preds = %54
  %59 = load ptr, ptr %14, align 8, !tbaa !5
  %60 = load i8, ptr %59, align 1, !tbaa !16
  %61 = icmp ne i8 %60, 0
  br label %62

62:                                               ; preds = %58, %54
  %63 = phi i1 [ false, %54 ], [ %61, %58 ]
  br i1 %63, label %64, label %68

64:                                               ; preds = %62
  br label %65

65:                                               ; preds = %64
  %66 = load ptr, ptr %14, align 8, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %66, i32 1
  store ptr %67, ptr %14, align 8, !tbaa !5
  br label %54, !llvm.loop !17

68:                                               ; preds = %62
  %69 = load ptr, ptr %14, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.ECL_ZeroEaterComprssorState, ptr %10, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !11
  %72 = ptrtoint ptr %69 to i64
  %73 = ptrtoint ptr %71 to i64
  %74 = sub i64 %72, %73
  %75 = trunc i64 %74 to i32
  store i32 %75, ptr %11, align 4, !tbaa !9
  %76 = load ptr, ptr %14, align 8, !tbaa !5
  %77 = load ptr, ptr %15, align 8, !tbaa !5
  %78 = icmp eq ptr %76, %77
  br i1 %78, label %79, label %81

79:                                               ; preds = %68
  %80 = load i32, ptr %11, align 4, !tbaa !9
  call void @_ZL22ECL_ZeroEater_DumpSeq1P27ECL_ZeroEaterComprssorStatej(ptr noundef %10, i32 noundef %80)
  br label %124

81:                                               ; preds = %68
  %82 = load ptr, ptr %14, align 8, !tbaa !5
  store ptr %82, ptr %13, align 8, !tbaa !5
  br label %83

83:                                               ; preds = %95, %81
  %84 = load ptr, ptr %13, align 8, !tbaa !5
  %85 = load ptr, ptr %15, align 8, !tbaa !5
  %86 = icmp ult ptr %84, %85
  br i1 %86, label %87, label %92

87:                                               ; preds = %83
  %88 = load ptr, ptr %13, align 8, !tbaa !5
  %89 = load i8, ptr %88, align 1, !tbaa !16
  %90 = icmp ne i8 %89, 0
  %91 = xor i1 %90, true
  br label %92

92:                                               ; preds = %87, %83
  %93 = phi i1 [ false, %83 ], [ %91, %87 ]
  br i1 %93, label %94, label %98

94:                                               ; preds = %92
  br label %95

95:                                               ; preds = %94
  %96 = load ptr, ptr %13, align 8, !tbaa !5
  %97 = getelementptr inbounds i8, ptr %96, i32 1
  store ptr %97, ptr %13, align 8, !tbaa !5
  br label %83, !llvm.loop !19

98:                                               ; preds = %92
  %99 = load ptr, ptr %13, align 8, !tbaa !5
  %100 = load ptr, ptr %14, align 8, !tbaa !5
  %101 = ptrtoint ptr %99 to i64
  %102 = ptrtoint ptr %100 to i64
  %103 = sub i64 %101, %102
  %104 = trunc i64 %103 to i32
  store i32 %104, ptr %12, align 4, !tbaa !9
  %105 = load i32, ptr %11, align 4, !tbaa !9
  %106 = icmp ne i32 %105, 0
  br i1 %106, label %107, label %119

107:                                              ; preds = %98
  %108 = load i32, ptr %12, align 4, !tbaa !9
  %109 = icmp eq i32 %108, 1
  br i1 %109, label %110, label %114

110:                                              ; preds = %107
  %111 = load i32, ptr %11, align 4, !tbaa !9
  %112 = icmp ugt i32 %111, 8
  br i1 %112, label %113, label %114

113:                                              ; preds = %110
  br label %47, !llvm.loop !20

114:                                              ; preds = %110, %107
  %115 = load i32, ptr %11, align 4, !tbaa !9
  %116 = load i32, ptr %12, align 4, !tbaa !9
  call void @_ZL25ECL_ZeroEater_DumpGenericP27ECL_ZeroEaterComprssorStatejj(ptr noundef %10, i32 noundef %115, i32 noundef %116)
  %117 = load ptr, ptr %13, align 8, !tbaa !5
  %118 = getelementptr inbounds %struct.ECL_ZeroEaterComprssorState, ptr %10, i32 0, i32 0
  store ptr %117, ptr %118, align 8, !tbaa !11
  br label %123

119:                                              ; preds = %98
  %120 = load i32, ptr %12, align 4, !tbaa !9
  call void @_ZL22ECL_ZeroEater_DumpSeq2P27ECL_ZeroEaterComprssorStatej(ptr noundef %10, i32 noundef %120)
  %121 = load ptr, ptr %13, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.ECL_ZeroEaterComprssorState, ptr %10, i32 0, i32 0
  store ptr %121, ptr %122, align 8, !tbaa !11
  br label %123

123:                                              ; preds = %119, %114
  br label %47, !llvm.loop !20

124:                                              ; preds = %79, %47
  %125 = getelementptr inbounds %struct.ECL_ZeroEaterComprssorState, ptr %10, i32 0, i32 3
  %126 = load i32, ptr %125, align 8, !tbaa !13
  store i32 %126, ptr %5, align 4
  store i32 1, ptr %16, align 4
  br label %127

127:                                              ; preds = %124, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #3
  %128 = load i32, ptr %5, align 4
  ret i32 %128
}

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL25ECL_ZeroEater_DumpGenericP27ECL_ZeroEaterComprssorStatejj(ptr noundef, i32 noundef, i32 noundef) #1

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS27ECL_ZeroEaterComprssorState", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24}
!13 = !{!12, !10, i64 24}
!14 = !{!12, !6, i64 8}
!15 = !{!12, !6, i64 16}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = distinct !{!20, !18}


; 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_ZeroEaterComprssorState = type { ptr, 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: mustprogress uwtable
define dso_local i32 @ECL_ZeroEater_Compress(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = alloca %struct.ECL_ZeroEaterComprssorState, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #3
  %6 = zext i32 %1 to i64
  %7 = getelementptr inbounds i8, ptr %0, i64 %6
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %44, label %8

8:                                                ; preds = %4
  %.not45 = icmp eq ptr %2, null
  %9 = zext i32 %3 to i64
  store ptr %0, ptr %5, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %5, i64 24
  store i32 0, ptr %10, align 8, !tbaa !11
  %11 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr %2, ptr %11, align 8, !tbaa !12
  %12 = select i1 %.not45, i64 0, i64 %9
  %13 = getelementptr inbounds i8, ptr %2, i64 %12
  %14 = select i1 %.not45, ptr null, ptr %13
  %15 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr %14, ptr %15, align 8, !tbaa !13
  %.not60 = icmp eq i32 %1, 0
  br i1 %.not60, label %.loopexit, label %.preheader49

.preheader49:                                     ; preds = %8, %.backedge
  %16 = phi ptr [ %41, %.backedge ], [ %0, %8 ]
  %.04058 = phi ptr [ %.1.lcssa, %.backedge ], [ %0, %8 ]
  %17 = icmp ult ptr %.04058, %7
  br i1 %17, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %.preheader49, %19
  %.03950 = phi ptr [ %20, %19 ], [ %.04058, %.preheader49 ]
  %18 = load i8, ptr %.03950, align 1, !tbaa !14
  %.not46 = icmp eq i8 %18, 0
  br i1 %.not46, label %.critedge, label %19

19:                                               ; preds = %.lr.ph
  %20 = getelementptr inbounds i8, ptr %.03950, i64 1
  %21 = icmp ult ptr %20, %7
  br i1 %21, label %.lr.ph, label %.critedge, !llvm.loop !15

.critedge:                                        ; preds = %.lr.ph, %19, %.preheader49
  %.039.lcssa = phi ptr [ %.04058, %.preheader49 ], [ %20, %19 ], [ %.03950, %.lr.ph ]
  %22 = ptrtoint ptr %.039.lcssa to i64
  %23 = ptrtoint ptr %16 to i64
  %24 = sub i64 %22, %23
  %25 = trunc i64 %24 to i32
  %26 = icmp eq ptr %.039.lcssa, %7
  br i1 %26, label %28, label %.preheader

.preheader:                                       ; preds = %.critedge
  %27 = icmp ult ptr %.039.lcssa, %7
  br i1 %27, label %.lr.ph54, label %.critedge2

28:                                               ; preds = %.critedge
  call void @_ZL22ECL_ZeroEater_DumpSeq1P27ECL_ZeroEaterComprssorStatej(ptr noundef nonnull %5, i32 noundef %25)
  br label %.loopexit

.lr.ph54:                                         ; preds = %.preheader, %30
  %.153 = phi ptr [ %31, %30 ], [ %.039.lcssa, %.preheader ]
  %29 = load i8, ptr %.153, align 1, !tbaa !14
  %.not47 = icmp eq i8 %29, 0
  br i1 %.not47, label %30, label %.critedge2.loopexit

30:                                               ; preds = %.lr.ph54
  %31 = getelementptr inbounds i8, ptr %.153, i64 1
  %32 = icmp ult ptr %31, %7
  br i1 %32, label %.lr.ph54, label %.critedge2.loopexit, !llvm.loop !17

.critedge2.loopexit:                              ; preds = %30, %.lr.ph54
  %.1.lcssa.ph = phi ptr [ %.153, %.lr.ph54 ], [ %31, %30 ]
  %.pre = ptrtoint ptr %.1.lcssa.ph to i64
  br label %.critedge2

.critedge2:                                       ; preds = %.critedge2.loopexit, %.preheader
  %.pre-phi = phi i64 [ %.pre, %.critedge2.loopexit ], [ %22, %.preheader ]
  %.1.lcssa = phi ptr [ %.1.lcssa.ph, %.critedge2.loopexit ], [ %.039.lcssa, %.preheader ]
  %33 = sub i64 %.pre-phi, %22
  %34 = trunc i64 %33 to i32
  %.not48 = icmp eq i32 %25, 0
  br i1 %.not48, label %39, label %35

35:                                               ; preds = %.critedge2
  %36 = icmp eq i32 %34, 1
  %37 = icmp ugt i32 %25, 8
  %or.cond = and i1 %37, %36
  br i1 %or.cond, label %.backedge, label %38

38:                                               ; preds = %35
  call void @_ZL25ECL_ZeroEater_DumpGenericP27ECL_ZeroEaterComprssorStatejj(ptr noundef nonnull %5, i32 noundef %25, i32 noundef %34)
  br label %40

39:                                               ; preds = %.critedge2
  call void @_ZL22ECL_ZeroEater_DumpSeq2P27ECL_ZeroEaterComprssorStatej(ptr noundef nonnull %5, i32 noundef %34)
  br label %40

40:                                               ; preds = %39, %38
  store ptr %.1.lcssa, ptr %5, align 8, !tbaa !5
  br label %.backedge

.backedge:                                        ; preds = %40, %35
  %41 = phi ptr [ %.1.lcssa, %40 ], [ %16, %35 ]
  %42 = icmp ult ptr %41, %7
  br i1 %42, label %.preheader49, label %.loopexit, !llvm.loop !18

.loopexit:                                        ; preds = %.backedge, %8, %28
  %43 = load i32, ptr %10, align 8, !tbaa !11
  br label %44

44:                                               ; preds = %4, %.loopexit
  %.0 = phi i32 [ %43, %.loopexit ], [ 0, %4 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #3
  ret i32 %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL22ECL_ZeroEater_DumpSeq1P27ECL_ZeroEaterComprssorStatej(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL25ECL_ZeroEater_DumpGenericP27ECL_ZeroEaterComprssorStatejj(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL22ECL_ZeroEater_DumpSeq2P27ECL_ZeroEaterComprssorStatej(ptr noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { mustprogress 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 = !{!"_ZTS27ECL_ZeroEaterComprssorState", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!6, !7, i64 8}
!13 = !{!6, !7, i64 16}
!14 = !{!8, !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass