; 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

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

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

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

18:                                               ; preds = %4
  store i32 -10000, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %58

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

34:                                               ; preds = %19
  %35 = load i32, ptr %11, align 4, !tbaa !17
  store i32 %35, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %58

36:                                               ; preds = %19
  %37 = call i32 @mz_inflate(ptr noundef %10, i32 noundef 4)
  store i32 %37, ptr %11, align 4, !tbaa !17
  %38 = load i32, ptr %11, align 4, !tbaa !17
  %39 = icmp ne i32 %38, 1
  br i1 %39, label %40, label %53

40:                                               ; preds = %36
  %41 = call i32 @mz_inflateEnd(ptr noundef %10)
  %42 = load i32, ptr %11, align 4, !tbaa !17
  %43 = icmp eq i32 %42, -5
  br i1 %43, label %44, label %49

44:                                               ; preds = %40
  %45 = getelementptr inbounds %struct.mz_stream_s, ptr %10, i32 0, i32 1
  %46 = load i32, ptr %45, align 8, !tbaa !14
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  br label %51

49:                                               ; preds = %44, %40
  %50 = load i32, ptr %11, align 4, !tbaa !17
  br label %51

51:                                               ; preds = %49, %48
  %52 = phi i32 [ -3, %48 ], [ %50, %49 ]
  store i32 %52, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %58

53:                                               ; preds = %36
  %54 = getelementptr inbounds %struct.mz_stream_s, ptr %10, i32 0, i32 5
  %55 = load i64, ptr %54, align 8, !tbaa !18
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  store i64 %55, ptr %56, align 8, !tbaa !9
  %57 = call i32 @mz_inflateEnd(ptr noundef %10)
  store i32 %57, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %58

58:                                               ; preds = %53, %51, %34, %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 112, ptr %10) #3
  %59 = load i32, ptr %5, align 4
  ret i32 %59
}

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

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

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

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

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

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

17:                                               ; preds = %10
  %18 = call i32 @mz_inflate(ptr noundef nonnull %5, i32 noundef 4)
  %.not16 = icmp eq i32 %18, 1
  br i1 %.not16, label %25, label %19

19:                                               ; preds = %17
  %20 = call i32 @mz_inflateEnd(ptr noundef nonnull %5)
  %21 = icmp ne i32 %18, -5
  %22 = load i32, ptr %12, align 8
  %23 = icmp ne i32 %22, 0
  %or.cond = select i1 %21, i1 true, i1 %23
  %24 = select i1 %or.cond, i32 %18, i32 -3
  br label %29

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

29:                                               ; preds = %10, %4, %25, %19
  %.0 = phi i32 [ %24, %19 ], [ %28, %25 ], [ -10000, %4 ], [ %16, %10 ]
  call void @llvm.lifetime.end.p0(i64 112, ptr nonnull %5) #3
  ret i32 %.0
}

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