; LLVM IR from jspd-group/pegit :: src/mz.ll_ (compress__)

; 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.z_stream_s = type { ptr, i32, i64, ptr, i32, i64, ptr, ptr, ptr, ptr, ptr, i32, i64, i64 }
%struct.strbuf = type { i64, i64, ptr }

@.str.9 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [59 x i8], align 1
@__PRETTY_FUNCTION__.__compress__ = external hidden unnamed_addr constant [56 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @z_stream_init(ptr noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local i32 @__compress__(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %struct.z_stream_s, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca [16384 x i8], align 16
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 112, ptr %7) #4
  call void @z_stream_init(ptr noundef %7)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %12 = call i32 @deflateInit_(ptr noundef %7, i32 noundef -1, ptr noundef @.str.9, i32 noundef 112)
  store i32 %12, ptr %8, align 4, !tbaa !9
  %13 = load i32, ptr %8, align 4, !tbaa !9
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %17

15:                                               ; preds = %3
  %16 = load i32, ptr %8, align 4, !tbaa !9
  call void @zerr(i32 noundef %16)
  br label %17

17:                                               ; preds = %15, %3
  call void @llvm.lifetime.start.p0(i64 16384, ptr %11) #4
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.strbuf, ptr %18, i32 0, i32 1
  %20 = load i64, ptr %19, align 8, !tbaa !11
  %21 = trunc i64 %20 to i32
  %22 = getelementptr inbounds %struct.z_stream_s, ptr %7, i32 0, i32 1
  store i32 %21, ptr %22, align 8, !tbaa !14
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.strbuf, ptr %23, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !16
  %26 = getelementptr inbounds %struct.z_stream_s, ptr %7, i32 0, i32 0
  store ptr %25, ptr %26, align 8, !tbaa !17
  br label %27

27:                                               ; preds = %57, %17
  %28 = getelementptr inbounds %struct.z_stream_s, ptr %7, i32 0, i32 1
  %29 = load i32, ptr %28, align 8, !tbaa !14
  %30 = icmp ult i32 %29, 16384
  %31 = zext i1 %30 to i64
  %32 = select i1 %30, i32 4, i32 0
  store i32 %32, ptr %9, align 4, !tbaa !9
  br label %33

33:                                               ; preds = %46, %27
  %34 = getelementptr inbounds %struct.z_stream_s, ptr %7, i32 0, i32 4
  store i32 16384, ptr %34, align 8, !tbaa !18
  %35 = getelementptr inbounds [16384 x i8], ptr %11, i64 0, i64 0
  %36 = getelementptr inbounds %struct.z_stream_s, ptr %7, i32 0, i32 3
  store ptr %35, ptr %36, align 8, !tbaa !19
  %37 = load i32, ptr %9, align 4, !tbaa !9
  %38 = call i32 @deflate(ptr noundef %7, i32 noundef %37)
  store i32 %38, ptr %8, align 4, !tbaa !9
  %39 = getelementptr inbounds %struct.z_stream_s, ptr %7, i32 0, i32 4
  %40 = load i32, ptr %39, align 8, !tbaa !18
  %41 = sub i32 16384, %40
  store i32 %41, ptr %10, align 4, !tbaa !9
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds [16384 x i8], ptr %11, i64 0, i64 0
  %44 = load i32, ptr %10, align 4, !tbaa !9
  %45 = zext i32 %44 to i64
  call void @strbuf_add(ptr noundef %42, ptr noundef %43, i64 noundef %45)
  br label %46

46:                                               ; preds = %33
  %47 = getelementptr inbounds %struct.z_stream_s, ptr %7, i32 0, i32 4
  %48 = load i32, ptr %47, align 8, !tbaa !18
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %33, label %50, !llvm.loop !20

50:                                               ; preds = %46
  %51 = getelementptr inbounds %struct.z_stream_s, ptr %7, i32 0, i32 1
  %52 = load i32, ptr %51, align 8, !tbaa !14
  %53 = icmp eq i32 %52, 0
  br i1 %53, label %54, label %55

54:                                               ; preds = %50
  br label %56

55:                                               ; preds = %50
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.11, i32 noundef 62, ptr noundef @__PRETTY_FUNCTION__.__compress__) #5
  unreachable

56:                                               ; preds = %54
  br label %57

57:                                               ; preds = %56
  %58 = load i32, ptr %9, align 4, !tbaa !9
  %59 = icmp ne i32 %58, 4
  br i1 %59, label %27, label %60, !llvm.loop !22

60:                                               ; preds = %57
  %61 = load i32, ptr %8, align 4, !tbaa !9
  %62 = icmp eq i32 %61, 1
  br i1 %62, label %63, label %64

63:                                               ; preds = %60
  br label %65

64:                                               ; preds = %60
  call void @__assert_fail(ptr noundef @.str.12, ptr noundef @.str.11, i32 noundef 65, ptr noundef @__PRETTY_FUNCTION__.__compress__) #5
  unreachable

65:                                               ; preds = %63
  %66 = call i32 @deflateEnd(ptr noundef %7)
  %67 = load i32, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 16384, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 112, ptr %7) #4
  ret i32 %67
}

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

declare i32 @deflateInit_(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #2

declare i32 @deflate(ptr noundef, i32 noundef) #2

declare void @strbuf_add(ptr noundef, ptr noundef, i64 noundef) #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

declare i32 @deflateEnd(ptr noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 = { noreturn nounwind "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 }
attributes #5 = { noreturn 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, !13, i64 8}
!12 = !{!"strbuf", !13, i64 0, !13, i64 8, !6, i64 16}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !10, i64 8}
!15 = !{!"z_stream_s", !6, i64 0, !10, i64 8, !13, i64 16, !6, i64 24, !10, i64 32, !13, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !10, i64 88, !13, i64 96, !13, i64 104}
!16 = !{!12, !6, i64 16}
!17 = !{!15, !6, i64 0}
!18 = !{!15, !10, i64 32}
!19 = !{!15, !6, i64 24}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


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

@.str.9 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [59 x i8], align 1
@__PRETTY_FUNCTION__.__compress__ = external hidden unnamed_addr constant [56 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [20 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @__compress__(ptr nocapture noundef readonly %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca %struct.z_stream_s, align 8
  %5 = alloca [16384 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 112, ptr nonnull %4) #4
  call void @z_stream_init(ptr noundef nonnull %4)
  %6 = call i32 @deflateInit_(ptr noundef nonnull %4, i32 noundef -1, ptr noundef nonnull @.str.9, i32 noundef 112) #4
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %8, label %7

7:                                                ; preds = %3
  call void @zerr(i32 noundef %6)
  br label %8

8:                                                ; preds = %7, %3
  call void @llvm.lifetime.start.p0(i64 16384, ptr nonnull %5) #4
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load i64, ptr %9, align 8, !tbaa !5
  %11 = trunc i64 %10 to i32
  %12 = getelementptr inbounds i8, ptr %4, i64 8
  store i32 %11, ptr %12, align 8, !tbaa !11
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !14
  store ptr %14, ptr %4, align 8, !tbaa !15
  %15 = icmp ult i32 %11, 16384
  %16 = getelementptr inbounds i8, ptr %4, i64 32
  %17 = getelementptr inbounds i8, ptr %4, i64 24
  br label %18

18:                                               ; preds = %32, %8
  %19 = phi i1 [ true, %32 ], [ %15, %8 ]
  %20 = select i1 %19, i32 4, i32 0
  br label %21

21:                                               ; preds = %21, %18
  store i32 16384, ptr %16, align 8, !tbaa !16
  store ptr %5, ptr %17, align 8, !tbaa !17
  %22 = call i32 @deflate(ptr noundef nonnull %4, i32 noundef %20) #4
  %23 = load i32, ptr %16, align 8, !tbaa !16
  %24 = sub i32 16384, %23
  %25 = zext i32 %24 to i64
  call void @strbuf_add(ptr noundef %1, ptr noundef nonnull %5, i64 noundef %25) #4
  %26 = load i32, ptr %16, align 8, !tbaa !16
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %21, label %28, !llvm.loop !18

28:                                               ; preds = %21
  %29 = load i32, ptr %12, align 8, !tbaa !11
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %32, label %31

31:                                               ; preds = %28
  call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.11, i32 noundef 62, ptr noundef nonnull @__PRETTY_FUNCTION__.__compress__) #5
  unreachable

32:                                               ; preds = %28
  br i1 %19, label %33, label %18, !llvm.loop !20

33:                                               ; preds = %32
  %34 = icmp eq i32 %22, 1
  br i1 %34, label %36, label %35

35:                                               ; preds = %33
  call void @__assert_fail(ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.11, i32 noundef 65, ptr noundef nonnull @__PRETTY_FUNCTION__.__compress__) #5
  unreachable

36:                                               ; preds = %33
  %37 = call i32 @deflateEnd(ptr noundef nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 16384, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 112, ptr nonnull %4) #4
  ret i32 1
}

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

declare i32 @deflateInit_(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare i32 @deflate(ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @strbuf_add(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

declare i32 @deflateEnd(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

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 = { noreturn nounwind "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 }
attributes #5 = { noreturn 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 8}
!6 = !{!"strbuf", !7, i64 0, !7, i64 8, !10, i64 16}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !13, i64 8}
!12 = !{!"z_stream_s", !10, i64 0, !13, i64 8, !7, i64 16, !10, i64 24, !13, i64 32, !7, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !13, i64 88, !7, i64 96, !7, i64 104}
!13 = !{!"int", !8, i64 0}
!14 = !{!6, !10, i64 16}
!15 = !{!12, !10, i64 0}
!16 = !{!12, !13, i64 32}
!17 = !{!12, !10, i64 24}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass