; 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.tinfl_decompressor_tag = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, [3 x i32], i64, i64, [3 x %struct.tinfl_huff_table], [4 x i8], [457 x i8] }
%struct.tinfl_huff_table = type { [288 x i8], [1024 x i16], [576 x i16] }

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

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

23:                                               ; preds = %5
  store i32 -1, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %81

24:                                               ; preds = %5
  br label %25

25:                                               ; preds = %24
  %26 = getelementptr inbounds %struct.tinfl_decompressor_tag, ptr %13, i32 0, i32 0
  store i32 0, ptr %26, align 8, !tbaa !13
  br label %27

27:                                               ; preds = %25
  br label %28

28:                                               ; preds = %27
  br label %29

29:                                               ; preds = %76, %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = load i64, ptr %30, align 8, !tbaa !11
  %32 = load i64, ptr %15, align 8, !tbaa !11
  %33 = sub i64 %31, %32
  store i64 %33, ptr %18, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #3
  %34 = load i64, ptr %16, align 8, !tbaa !11
  %35 = sub i64 32768, %34
  store i64 %35, ptr %19, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = load i64, ptr %15, align 8, !tbaa !11
  %38 = getelementptr inbounds i8, ptr %36, i64 %37
  %39 = load ptr, ptr %14, align 8, !tbaa !5
  %40 = load ptr, ptr %14, align 8, !tbaa !5
  %41 = load i64, ptr %16, align 8, !tbaa !11
  %42 = getelementptr inbounds i8, ptr %40, i64 %41
  %43 = load i32, ptr %11, align 4, !tbaa !9
  %44 = and i32 %43, -7
  %45 = call i32 @tinfl_decompress(ptr noundef %13, ptr noundef %38, ptr noundef %18, ptr noundef %39, ptr noundef %42, ptr noundef %19, i32 noundef %44)
  store i32 %45, ptr %20, align 4, !tbaa !15
  %46 = load i64, ptr %18, align 8, !tbaa !11
  %47 = load i64, ptr %15, align 8, !tbaa !11
  %48 = add i64 %47, %46
  store i64 %48, ptr %15, align 8, !tbaa !11
  %49 = load i64, ptr %19, align 8, !tbaa !11
  %50 = icmp ne i64 %49, 0
  br i1 %50, label %51, label %62

51:                                               ; preds = %29
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = load ptr, ptr %14, align 8, !tbaa !5
  %54 = load i64, ptr %16, align 8, !tbaa !11
  %55 = getelementptr inbounds i8, ptr %53, i64 %54
  %56 = load i64, ptr %19, align 8, !tbaa !11
  %57 = trunc i64 %56 to i32
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = call noundef i32 %52(ptr noundef %55, i32 noundef %57, ptr noundef %58)
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %62, label %61

61:                                               ; preds = %51
  store i32 4, ptr %17, align 4
  br label %74

62:                                               ; preds = %51, %29
  %63 = load i32, ptr %20, align 4, !tbaa !15
  %64 = icmp ne i32 %63, 2
  br i1 %64, label %65, label %69

65:                                               ; preds = %62
  %66 = load i32, ptr %20, align 4, !tbaa !15
  %67 = icmp eq i32 %66, 0
  %68 = zext i1 %67 to i32
  store i32 %68, ptr %12, align 4, !tbaa !9
  store i32 4, ptr %17, align 4
  br label %74

69:                                               ; preds = %62
  %70 = load i64, ptr %16, align 8, !tbaa !11
  %71 = load i64, ptr %19, align 8, !tbaa !11
  %72 = add i64 %70, %71
  %73 = and i64 %72, 32767
  store i64 %73, ptr %16, align 8, !tbaa !11
  store i32 0, ptr %17, align 4
  br label %74

74:                                               ; preds = %69, %65, %61
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  %75 = load i32, ptr %17, align 4
  switch i32 %75, label %83 [
    i32 0, label %76
    i32 4, label %77
  ]

76:                                               ; preds = %74
  br label %29, !llvm.loop !17

77:                                               ; preds = %74
  %78 = load i64, ptr %15, align 8, !tbaa !11
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  store i64 %78, ptr %79, align 8, !tbaa !11
  %80 = load i32, ptr %12, align 4, !tbaa !9
  store i32 %80, ptr %6, align 4
  store i32 1, ptr %17, align 4
  br label %81

81:                                               ; preds = %77, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  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 11000, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  %82 = load i32, ptr %6, align 4
  ret i32 %82

83:                                               ; preds = %74
  unreachable
}

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, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"_ZTS22tinfl_decompressor_tag", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !7, i64 44, !12, i64 56, !12, i64 64, !7, i64 72, !7, i64 10536, !7, i64 10540}
!15 = !{!16, !16, i64 0}
!16 = !{!"_ZTS12tinfl_status", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; 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 nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef i32 @tinfl_decompress_mem_to_callback(ptr nocapture noundef readnone %0, ptr nocapture noundef readnone %1, ptr nocapture noundef readnone %2, ptr nocapture noundef readnone %3, i32 noundef %4) local_unnamed_addr #0 {
  ret i32 -1
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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" }

!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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,PostOrderFunctionAttrsPass,PromotePass,SROAPass,SimplifyCFGPass