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

21:                                               ; preds = %4
  %22 = getelementptr inbounds %struct.tinfl_decompressor_tag, ptr %10, i32 0, i32 0
  store i32 0, ptr %22, align 8, !tbaa !13
  br label %23

23:                                               ; preds = %21
  br label %24

24:                                               ; preds = %23
  br label %25

25:                                               ; preds = %85, %24
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #2
  %26 = load i64, ptr %7, align 8, !tbaa !9
  %27 = load i64, ptr %13, align 8, !tbaa !9
  %28 = sub i64 %26, %27
  store i64 %28, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #2
  %29 = load i64, ptr %14, align 8, !tbaa !9
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = load i64, ptr %30, align 8, !tbaa !9
  %32 = sub i64 %29, %31
  store i64 %32, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #2
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load i64, ptr %13, align 8, !tbaa !9
  %35 = getelementptr inbounds i8, ptr %33, i64 %34
  %36 = load ptr, ptr %11, align 8, !tbaa !5
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = icmp ne ptr %37, null
  br i1 %38, label %39, label %44

39:                                               ; preds = %25
  %40 = load ptr, ptr %11, align 8, !tbaa !5
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load i64, ptr %41, align 8, !tbaa !9
  %43 = getelementptr inbounds i8, ptr %40, i64 %42
  br label %45

44:                                               ; preds = %25
  br label %45

45:                                               ; preds = %44, %39
  %46 = phi ptr [ %43, %39 ], [ null, %44 ]
  %47 = load i32, ptr %9, align 4, !tbaa !11
  %48 = and i32 %47, -3
  %49 = or i32 %48, 4
  %50 = call i32 @tinfl_decompress(ptr noundef %10, ptr noundef %35, ptr noundef %15, ptr noundef %36, ptr noundef %46, ptr noundef %16, i32 noundef %49)
  store i32 %50, ptr %18, align 4, !tbaa !15
  %51 = load i32, ptr %18, align 4, !tbaa !15
  %52 = icmp slt i32 %51, 0
  br i1 %52, label %56, label %53

53:                                               ; preds = %45
  %54 = load i32, ptr %18, align 4, !tbaa !15
  %55 = icmp eq i32 %54, 1
  br i1 %55, label %56, label %58

56:                                               ; preds = %53, %45
  %57 = load ptr, ptr %8, align 8, !tbaa !5
  store i64 0, ptr %57, align 8, !tbaa !9
  store ptr null, ptr %5, align 8
  store i32 1, ptr %19, align 4
  br label %83

58:                                               ; preds = %53
  %59 = load i64, ptr %15, align 8, !tbaa !9
  %60 = load i64, ptr %13, align 8, !tbaa !9
  %61 = add i64 %60, %59
  store i64 %61, ptr %13, align 8, !tbaa !9
  %62 = load i64, ptr %16, align 8, !tbaa !9
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = load i64, ptr %63, align 8, !tbaa !9
  %65 = add i64 %64, %62
  store i64 %65, ptr %63, align 8, !tbaa !9
  %66 = load i32, ptr %18, align 4, !tbaa !15
  %67 = icmp eq i32 %66, 0
  br i1 %67, label %68, label %69

68:                                               ; preds = %58
  store i32 4, ptr %19, align 4
  br label %83

69:                                               ; preds = %58
  %70 = load i64, ptr %14, align 8, !tbaa !9
  %71 = mul i64 %70, 2
  store i64 %71, ptr %17, align 8, !tbaa !9
  %72 = load i64, ptr %17, align 8, !tbaa !9
  %73 = icmp ult i64 %72, 128
  br i1 %73, label %74, label %75

74:                                               ; preds = %69
  store i64 128, ptr %17, align 8, !tbaa !9
  br label %75

75:                                               ; preds = %74, %69
  store ptr null, ptr %12, align 8, !tbaa !5
  %76 = load ptr, ptr %12, align 8, !tbaa !5
  %77 = icmp ne ptr %76, null
  br i1 %77, label %80, label %78

78:                                               ; preds = %75
  %79 = load ptr, ptr %8, align 8, !tbaa !5
  store i64 0, ptr %79, align 8, !tbaa !9
  store ptr null, ptr %5, align 8
  store i32 1, ptr %19, align 4
  br label %83

80:                                               ; preds = %75
  %81 = load ptr, ptr %12, align 8, !tbaa !5
  store ptr %81, ptr %11, align 8, !tbaa !5
  %82 = load i64, ptr %17, align 8, !tbaa !9
  store i64 %82, ptr %14, align 8, !tbaa !9
  store i32 0, ptr %19, align 4
  br label %83

83:                                               ; preds = %80, %78, %68, %56
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #2
  %84 = load i32, ptr %19, align 4
  switch i32 %84, label %88 [
    i32 0, label %85
    i32 4, label %86
  ]

85:                                               ; preds = %83
  br label %25, !llvm.loop !17

86:                                               ; preds = %83
  %87 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %87, ptr %5, align 8
  store i32 1, ptr %19, align 4
  br label %88

88:                                               ; preds = %86, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 11000, ptr %10) #2
  %89 = load ptr, ptr %5, align 8
  ret ptr %89
}

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 = { 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, !12, i64 0}
!14 = !{!"_ZTS22tinfl_decompressor_tag", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !12, i64 40, !7, i64 44, !10, i64 56, !10, 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"

%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: 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 nounwind uwtable
declare dso_local i32 @tinfl_decompress(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local noalias noundef ptr @tinfl_decompress_mem_to_heap(ptr noundef %0, i64 noundef %1, ptr nocapture noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = alloca %struct.tinfl_decompressor_tag, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 11000, ptr nonnull %5) #2
  store i64 0, ptr %2, align 8, !tbaa !5
  store i32 0, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #2
  store i64 %1, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #2
  store i64 0, ptr %7, align 8, !tbaa !5
  %8 = and i32 %3, -7
  %9 = or disjoint i32 %8, 4
  %10 = call i32 @tinfl_decompress(ptr noundef nonnull %5, ptr noundef %0, ptr noundef nonnull %6, ptr noundef null, ptr noundef null, ptr noundef nonnull %7, i32 noundef %9)
  %11 = icmp slt i32 %10, 0
  %12 = icmp eq i32 %10, 1
  %or.cond = or i1 %11, %12
  br i1 %or.cond, label %.critedge, label %13

13:                                               ; preds = %4
  %14 = load i64, ptr %7, align 8, !tbaa !5
  %15 = load i64, ptr %2, align 8, !tbaa !5
  %16 = add i64 %15, %14
  store i64 %16, ptr %2, align 8, !tbaa !5
  %17 = icmp eq i32 %10, 0
  br i1 %17, label %18, label %.critedge

18:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #2
  br label %19

.critedge:                                        ; preds = %13, %4
  store i64 0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #2
  br label %19

19:                                               ; preds = %.critedge, %18
  call void @llvm.lifetime.end.p0(i64 11000, ptr nonnull %5) #2
  ret ptr null
}

attributes #0 = { mustprogress 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 = { 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 = !{!"_ZTS22tinfl_decompressor_tag", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !7, i64 44, !6, i64 56, !6, i64 64, !7, i64 72, !7, i64 10536, !7, i64 10540}
!11 = !{!"int", !7, i64 0}


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