; LLVM IR from hadryansalles/Luz :: deps/optick (optick_miniz)

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

; 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
declare dso_local i32 @mz_deflateInit(ptr noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local i32 @mz_deflateEnd(ptr noundef) #1

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

; Function Attrs: mustprogress uwtable
define dso_local i32 @mz_compress2(ptr noundef %0, ptr noundef %1, ptr noundef %2, i64 noundef %3, i32 noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %struct.mz_stream_s, align 8
  %14 = alloca i32, align 4
  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 i64 %3, ptr %10, align 8, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 112, ptr %13) #3
  call void @llvm.memset.p0.i64(ptr align 8 %13, i8 0, i64 112, i1 false)
  %15 = load i64, ptr %10, align 8, !tbaa !9
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  %17 = load i64, ptr %16, align 8, !tbaa !9
  %18 = or i64 %15, %17
  %19 = icmp ugt i64 %18, 4294967295
  br i1 %19, label %20, label %21

20:                                               ; preds = %5
  store i32 -10000, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %57

21:                                               ; preds = %5
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.mz_stream_s, ptr %13, i32 0, i32 0
  store ptr %22, ptr %23, align 8, !tbaa !13
  %24 = load i64, ptr %10, align 8, !tbaa !9
  %25 = trunc i64 %24 to i32
  %26 = getelementptr inbounds %struct.mz_stream_s, ptr %13, i32 0, i32 1
  store i32 %25, ptr %26, align 8, !tbaa !15
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.mz_stream_s, ptr %13, i32 0, i32 3
  store ptr %27, ptr %28, align 8, !tbaa !16
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = load i64, ptr %29, align 8, !tbaa !9
  %31 = trunc i64 %30 to i32
  %32 = getelementptr inbounds %struct.mz_stream_s, ptr %13, i32 0, i32 4
  store i32 %31, ptr %32, align 8, !tbaa !17
  %33 = load i32, ptr %11, align 4, !tbaa !11
  %34 = call i32 @mz_deflateInit(ptr noundef %13, i32 noundef %33)
  store i32 %34, ptr %12, align 4, !tbaa !11
  %35 = load i32, ptr %12, align 4, !tbaa !11
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %39

37:                                               ; preds = %21
  %38 = load i32, ptr %12, align 4, !tbaa !11
  store i32 %38, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %57

39:                                               ; preds = %21
  %40 = call i32 @mz_deflate(ptr noundef %13, i32 noundef 4)
  store i32 %40, ptr %12, align 4, !tbaa !11
  %41 = load i32, ptr %12, align 4, !tbaa !11
  %42 = icmp ne i32 %41, 1
  br i1 %42, label %43, label %52

43:                                               ; preds = %39
  %44 = call i32 @mz_deflateEnd(ptr noundef %13)
  %45 = load i32, ptr %12, align 4, !tbaa !11
  %46 = icmp eq i32 %45, 0
  br i1 %46, label %47, label %48

47:                                               ; preds = %43
  br label %50

48:                                               ; preds = %43
  %49 = load i32, ptr %12, align 4, !tbaa !11
  br label %50

50:                                               ; preds = %48, %47
  %51 = phi i32 [ -5, %47 ], [ %49, %48 ]
  store i32 %51, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %57

52:                                               ; preds = %39
  %53 = getelementptr inbounds %struct.mz_stream_s, ptr %13, i32 0, i32 5
  %54 = load i64, ptr %53, align 8, !tbaa !18
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  store i64 %54, ptr %55, align 8, !tbaa !9
  %56 = call i32 @mz_deflateEnd(ptr noundef %13)
  store i32 %56, ptr %6, align 4
  store i32 1, ptr %14, align 4
  br label %57

57:                                               ; preds = %52, %50, %37, %20
  call void @llvm.lifetime.end.p0(i64 112, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  %58 = load i32, ptr %6, align 4
  ret i32 %58
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTS11mz_stream_s", !6, i64 0, !12, i64 8, !10, i64 16, !6, i64 24, !12, i64 32, !10, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !12, i64 88, !10, i64 96, !10, i64 104}
!15 = !{!14, !12, i64 8}
!16 = !{!14, !6, i64 24}
!17 = !{!14, !12, i64 32}
!18 = !{!14, !10, i64 40}


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

; 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
declare dso_local i32 @mz_deflateInit(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local i32 @mz_deflateEnd(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local i32 @mz_compress2(ptr noundef %0, ptr nocapture noundef %1, ptr noundef %2, i64 noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = alloca %struct.mz_stream_s, align 8
  call void @llvm.lifetime.start.p0(i64 112, ptr nonnull %6) #3
  %7 = getelementptr inbounds i8, ptr %6, i64 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(112) %7, i8 0, i64 104, i1 false)
  %8 = load i64, ptr %1, align 8, !tbaa !5
  %9 = or i64 %8, %3
  %10 = icmp ugt i64 %9, 4294967295
  br i1 %10, label %28, label %11

11:                                               ; preds = %5
  store ptr %2, ptr %6, align 8, !tbaa !9
  %12 = trunc nuw i64 %3 to i32
  %13 = getelementptr inbounds i8, ptr %6, i64 8
  store i32 %12, ptr %13, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %6, i64 24
  store ptr %0, ptr %14, align 8, !tbaa !14
  %15 = trunc nuw i64 %8 to i32
  %16 = getelementptr inbounds i8, ptr %6, i64 32
  store i32 %15, ptr %16, align 8, !tbaa !15
  %17 = call i32 @mz_deflateInit(ptr noundef nonnull %6, i32 noundef %4)
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %18, label %28

18:                                               ; preds = %11
  %19 = call i32 @mz_deflate(ptr noundef nonnull %6, i32 noundef 4)
  %.not15 = icmp eq i32 %19, 1
  br i1 %.not15, label %24, label %20

20:                                               ; preds = %18
  %21 = call i32 @mz_deflateEnd(ptr noundef nonnull %6)
  %22 = icmp eq i32 %19, 0
  %23 = select i1 %22, i32 -5, i32 %19
  br label %28

24:                                               ; preds = %18
  %25 = getelementptr inbounds i8, ptr %6, i64 40
  %26 = load i64, ptr %25, align 8, !tbaa !16
  store i64 %26, ptr %1, align 8, !tbaa !5
  %27 = call i32 @mz_deflateEnd(ptr noundef nonnull %6)
  br label %28

28:                                               ; preds = %11, %5, %24, %20
  %.0 = phi i32 [ %23, %20 ], [ %27, %24 ], [ -10000, %5 ], [ %17, %11 ]
  call void @llvm.lifetime.end.p0(i64 112, ptr nonnull %6) #3
  ret i32 %.0
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTS11mz_stream_s", !11, i64 0, !12, i64 8, !6, i64 16, !11, i64 24, !12, i64 32, !6, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !11, i64 72, !11, i64 80, !12, i64 88, !6, i64 96, !6, i64 104}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 8}
!14 = !{!10, !11, i64 24}
!15 = !{!10, !12, i64 32}
!16 = !{!10, !6, i64 40}


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