; 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 nounwind uwtable
declare dso_local ptr @miniz_def_alloc_func(ptr noundef, i64 noundef, i64 noundef) #1

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

; Function Attrs: mustprogress uwtable
define dso_local i32 @mz_deflateInit2(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #2 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %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
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !9
  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
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %17 = load i32, ptr %9, align 4, !tbaa !9
  %18 = load i32, ptr %11, align 4, !tbaa !9
  %19 = load i32, ptr %13, align 4, !tbaa !9
  %20 = call i32 @tdefl_create_comp_flags_from_zip_params(i32 noundef %17, i32 noundef %18, i32 noundef %19)
  %21 = or i32 8192, %20
  store i32 %21, ptr %15, align 4, !tbaa !9
  %22 = load ptr, ptr %8, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %25, label %24

24:                                               ; preds = %6
  store i32 -2, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %93

25:                                               ; preds = %6
  %26 = load i32, ptr %10, align 4, !tbaa !9
  %27 = icmp ne i32 %26, 8
  br i1 %27, label %41, label %28

28:                                               ; preds = %25
  %29 = load i32, ptr %12, align 4, !tbaa !9
  %30 = icmp slt i32 %29, 1
  br i1 %30, label %41, label %31

31:                                               ; preds = %28
  %32 = load i32, ptr %12, align 4, !tbaa !9
  %33 = icmp sgt i32 %32, 9
  br i1 %33, label %41, label %34

34:                                               ; preds = %31
  %35 = load i32, ptr %11, align 4, !tbaa !9
  %36 = icmp ne i32 %35, 15
  br i1 %36, label %37, label %42

37:                                               ; preds = %34
  %38 = load i32, ptr %11, align 4, !tbaa !9
  %39 = sub nsw i32 0, %38
  %40 = icmp ne i32 %39, 15
  br i1 %40, label %41, label %42

41:                                               ; preds = %37, %31, %28, %25
  store i32 -10000, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %93

42:                                               ; preds = %37, %34
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.mz_stream_s, ptr %43, i32 0, i32 11
  store i32 0, ptr %44, align 8, !tbaa !11
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.mz_stream_s, ptr %45, i32 0, i32 12
  store i64 1, ptr %46, align 8, !tbaa !14
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.mz_stream_s, ptr %47, i32 0, i32 6
  store ptr null, ptr %48, align 8, !tbaa !15
  %49 = load ptr, ptr %8, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.mz_stream_s, ptr %49, i32 0, i32 13
  store i64 0, ptr %50, align 8, !tbaa !16
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.mz_stream_s, ptr %51, i32 0, i32 2
  store i64 0, ptr %52, align 8, !tbaa !17
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.mz_stream_s, ptr %53, i32 0, i32 5
  store i64 0, ptr %54, align 8, !tbaa !18
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.mz_stream_s, ptr %55, i32 0, i32 8
  %57 = load ptr, ptr %56, align 8, !tbaa !19
  %58 = icmp ne ptr %57, null
  br i1 %58, label %62, label %59

59:                                               ; preds = %42
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.mz_stream_s, ptr %60, i32 0, i32 8
  store ptr @miniz_def_alloc_func, ptr %61, align 8, !tbaa !19
  br label %62

62:                                               ; preds = %59, %42
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.mz_stream_s, ptr %63, i32 0, i32 9
  %65 = load ptr, ptr %64, align 8, !tbaa !20
  %66 = icmp ne ptr %65, null
  br i1 %66, label %70, label %67

67:                                               ; preds = %62
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.mz_stream_s, ptr %68, i32 0, i32 9
  store ptr @miniz_def_free_func, ptr %69, align 8, !tbaa !20
  br label %70

70:                                               ; preds = %67, %62
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.mz_stream_s, ptr %71, i32 0, i32 8
  %73 = load ptr, ptr %72, align 8, !tbaa !19
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.mz_stream_s, ptr %74, i32 0, i32 10
  %76 = load ptr, ptr %75, align 8, !tbaa !21
  %77 = call noundef ptr %73(ptr noundef %76, i64 noundef 1, i64 noundef 319352)
  store ptr %77, ptr %14, align 8, !tbaa !5
  %78 = load ptr, ptr %14, align 8, !tbaa !5
  %79 = icmp ne ptr %78, null
  br i1 %79, label %81, label %80

80:                                               ; preds = %70
  store i32 -4, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %93

81:                                               ; preds = %70
  %82 = load ptr, ptr %14, align 8, !tbaa !5
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.mz_stream_s, ptr %83, i32 0, i32 7
  store ptr %82, ptr %84, align 8, !tbaa !22
  %85 = load ptr, ptr %14, align 8, !tbaa !5
  %86 = load i32, ptr %15, align 4, !tbaa !9
  %87 = call i32 @tdefl_init(ptr noundef %85, ptr noundef null, ptr noundef null, i32 noundef %86)
  %88 = icmp ne i32 %87, 0
  br i1 %88, label %89, label %92

89:                                               ; preds = %81
  %90 = load ptr, ptr %8, align 8, !tbaa !5
  %91 = call i32 @mz_deflateEnd(ptr noundef %90)
  store i32 -10000, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %93

92:                                               ; preds = %81
  store i32 0, ptr %7, align 4
  store i32 1, ptr %16, align 4
  br label %93

93:                                               ; preds = %92, %89, %80, %41, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %94 = load i32, ptr %7, align 4
  ret i32 %94
}

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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, !10, i64 88}
!12 = !{!"_ZTS11mz_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}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !13, i64 96}
!15 = !{!12, !6, i64 48}
!16 = !{!12, !13, i64 104}
!17 = !{!12, !13, i64 16}
!18 = !{!12, !13, i64 40}
!19 = !{!12, !6, i64 64}
!20 = !{!12, !6, i64 72}
!21 = !{!12, !6, i64 80}
!22 = !{!12, !6, i64 56}


; 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: mustprogress nounwind uwtable
declare dso_local ptr @miniz_def_alloc_func(ptr noundef, i64 noundef, i64 noundef) #0

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

; Function Attrs: mustprogress uwtable
define dso_local range(i32 -10000, 1) i32 @mz_deflateInit2(ptr noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #1 {
  %7 = tail call i32 @tdefl_create_comp_flags_from_zip_params(i32 noundef %1, i32 noundef %3, i32 noundef %5)
  %8 = or i32 %7, 8192
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %37, label %9

9:                                                ; preds = %6
  %10 = icmp ne i32 %2, 8
  %11 = add i32 %4, -10
  %12 = icmp ult i32 %11, -9
  %or.cond3 = or i1 %10, %12
  br i1 %or.cond3, label %37, label %13

13:                                               ; preds = %9
  switch i32 %3, label %37 [
    i32 15, label %14
    i32 -15, label %14
  ]

14:                                               ; preds = %13, %13
  %15 = getelementptr inbounds i8, ptr %0, i64 88
  store i32 0, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 96
  store i64 1, ptr %16, align 8, !tbaa !12
  %17 = getelementptr inbounds i8, ptr %0, i64 104
  store i64 0, ptr %17, align 8, !tbaa !13
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 0, ptr %18, align 8, !tbaa !14
  %19 = getelementptr inbounds i8, ptr %0, i64 40
  %20 = getelementptr inbounds i8, ptr %0, i64 64
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %19, i8 0, i64 16, i1 false)
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %.not35 = icmp eq ptr %21, null
  br i1 %.not35, label %22, label %23

22:                                               ; preds = %14
  store ptr @miniz_def_alloc_func, ptr %20, align 8, !tbaa !15
  br label %23

23:                                               ; preds = %22, %14
  %24 = phi ptr [ @miniz_def_alloc_func, %22 ], [ %21, %14 ]
  %25 = getelementptr inbounds i8, ptr %0, i64 72
  %26 = load ptr, ptr %25, align 8, !tbaa !16
  %.not36 = icmp eq ptr %26, null
  br i1 %.not36, label %27, label %28

27:                                               ; preds = %23
  store ptr @miniz_def_free_func, ptr %25, align 8, !tbaa !16
  br label %28

28:                                               ; preds = %27, %23
  %29 = getelementptr inbounds i8, ptr %0, i64 80
  %30 = load ptr, ptr %29, align 8, !tbaa !17
  %31 = tail call noundef ptr %24(ptr noundef %30, i64 noundef 1, i64 noundef 319352)
  %.not37 = icmp eq ptr %31, null
  br i1 %.not37, label %37, label %32

32:                                               ; preds = %28
  %33 = getelementptr inbounds i8, ptr %0, i64 56
  store ptr %31, ptr %33, align 8, !tbaa !18
  %34 = tail call i32 @tdefl_init(ptr noundef nonnull %31, ptr noundef null, ptr noundef null, i32 noundef %8)
  %.not38 = icmp eq i32 %34, 0
  br i1 %.not38, label %37, label %35

35:                                               ; preds = %32
  %36 = tail call i32 @mz_deflateEnd(ptr noundef nonnull %0)
  br label %37

37:                                               ; preds = %32, %28, %9, %13, %6, %35
  %.0 = phi i32 [ -10000, %35 ], [ -2, %6 ], [ -10000, %13 ], [ -10000, %9 ], [ -4, %28 ], [ 0, %32 ]
  ret i32 %.0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i32 @tdefl_init(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

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

; 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 = { 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 #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) }

!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 88}
!6 = !{!"_ZTS11mz_stream_s", !7, i64 0, !10, i64 8, !11, i64 16, !7, i64 24, !10, i64 32, !11, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !10, i64 88, !11, i64 96, !11, i64 104}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!6, !11, i64 96}
!13 = !{!6, !11, i64 104}
!14 = !{!6, !11, i64 16}
!15 = !{!6, !7, i64 64}
!16 = !{!6, !7, i64 72}
!17 = !{!6, !7, i64 80}
!18 = !{!6, !7, i64 56}


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