; LLVM IR from itchio/go-brotli :: dec (state)

; 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.BrotliDecoderStateStruct = type { i32, i32, %struct.BrotliBitReader, ptr, ptr, ptr, %union.anon, i32, i32, i32, i32, i32, i32, i32, [4 x i32], i32, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.HuffmanTreeGroup, %struct.HuffmanTreeGroup, %struct.HuffmanTreeGroup, ptr, ptr, i32, i32, i32, i32, [3 x i32], [3 x i32], [6 x i32], i32, i32, i32, i32, ptr, ptr, i8, i32, i32, i32, i32, i64, i64, i32, i32, i32, [32 x %struct.HuffmanCode], ptr, [720 x i16], [32 x i32], [18 x i8], [16 x i16], i32, ptr, i32, i32, i32, [646 x %struct.HuffmanCode], i32, [65 x i32], i32, i32, i32, i32, i32, i32, i32, i16, i32, i32, i32, ptr, ptr, ptr, [8 x i32] }
%struct.BrotliBitReader = type { i64, i32, ptr, i64 }
%union.anon = type { i64 }
%struct.HuffmanTreeGroup = type { ptr, ptr, i16, i16 }
%struct.HuffmanCode = type { i8, i16 }

; Function Attrs: nounwind uwtable
define hidden void @BrotliDecoderStateMetablockBegin(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %3, i32 0, i32 31
  store i32 0, ptr %4, align 8, !tbaa !9
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %5, i32 0, i32 33
  %7 = getelementptr inbounds [3 x i32], ptr %6, i64 0, i64 0
  store i32 268435456, ptr %7, align 8, !tbaa !16
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %8, i32 0, i32 33
  %10 = getelementptr inbounds [3 x i32], ptr %9, i64 0, i64 1
  store i32 268435456, ptr %10, align 4, !tbaa !16
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %11, i32 0, i32 33
  %13 = getelementptr inbounds [3 x i32], ptr %12, i64 0, i64 2
  store i32 268435456, ptr %13, align 8, !tbaa !16
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %14, i32 0, i32 34
  %16 = getelementptr inbounds [3 x i32], ptr %15, i64 0, i64 0
  store i32 1, ptr %16, align 4, !tbaa !16
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %17, i32 0, i32 34
  %19 = getelementptr inbounds [3 x i32], ptr %18, i64 0, i64 1
  store i32 1, ptr %19, align 4, !tbaa !16
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %20, i32 0, i32 34
  %22 = getelementptr inbounds [3 x i32], ptr %21, i64 0, i64 2
  store i32 1, ptr %22, align 4, !tbaa !16
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %23, i32 0, i32 35
  %25 = getelementptr inbounds [6 x i32], ptr %24, i64 0, i64 0
  store i32 1, ptr %25, align 8, !tbaa !16
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %26, i32 0, i32 35
  %28 = getelementptr inbounds [6 x i32], ptr %27, i64 0, i64 1
  store i32 0, ptr %28, align 4, !tbaa !16
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %29, i32 0, i32 35
  %31 = getelementptr inbounds [6 x i32], ptr %30, i64 0, i64 2
  store i32 1, ptr %31, align 8, !tbaa !16
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %32, i32 0, i32 35
  %34 = getelementptr inbounds [6 x i32], ptr %33, i64 0, i64 3
  store i32 0, ptr %34, align 4, !tbaa !16
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %35, i32 0, i32 35
  %37 = getelementptr inbounds [6 x i32], ptr %36, i64 0, i64 4
  store i32 1, ptr %37, align 8, !tbaa !16
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %38, i32 0, i32 35
  %40 = getelementptr inbounds [6 x i32], ptr %39, i64 0, i64 5
  store i32 0, ptr %40, align 4, !tbaa !16
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %41, i32 0, i32 77
  store ptr null, ptr %42, align 8, !tbaa !17
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %43, i32 0, i32 78
  store ptr null, ptr %44, align 8, !tbaa !18
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %45, i32 0, i32 40
  store ptr null, ptr %46, align 8, !tbaa !19
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %47, i32 0, i32 22
  store ptr null, ptr %48, align 8, !tbaa !20
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %49, i32 0, i32 41
  store ptr null, ptr %50, align 8, !tbaa !21
  %51 = load ptr, ptr %2, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %51, i32 0, i32 23
  store ptr null, ptr %52, align 8, !tbaa !22
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %53, i32 0, i32 42
  store i8 0, ptr %54, align 8, !tbaa !23
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %55, i32 0, i32 20
  store ptr null, ptr %56, align 8, !tbaa !24
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %57, i32 0, i32 21
  store ptr null, ptr %58, align 8, !tbaa !25
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %59, i32 0, i32 24
  %61 = getelementptr inbounds %struct.HuffmanTreeGroup, ptr %60, i32 0, i32 1
  store ptr null, ptr %61, align 8, !tbaa !26
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %62, i32 0, i32 24
  %64 = getelementptr inbounds %struct.HuffmanTreeGroup, ptr %63, i32 0, i32 0
  store ptr null, ptr %64, align 8, !tbaa !27
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %65, i32 0, i32 25
  %67 = getelementptr inbounds %struct.HuffmanTreeGroup, ptr %66, i32 0, i32 1
  store ptr null, ptr %67, align 8, !tbaa !28
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %68, i32 0, i32 25
  %70 = getelementptr inbounds %struct.HuffmanTreeGroup, ptr %69, i32 0, i32 0
  store ptr null, ptr %70, align 8, !tbaa !29
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %71, i32 0, i32 26
  %73 = getelementptr inbounds %struct.HuffmanTreeGroup, ptr %72, i32 0, i32 1
  store ptr null, ptr %73, align 8, !tbaa !30
  %74 = load ptr, ptr %2, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.BrotliDecoderStateStruct, ptr %74, i32 0, i32 26
  %76 = getelementptr inbounds %struct.HuffmanTreeGroup, ptr %75, i32 0, i32 0
  store ptr null, ptr %76, align 8, !tbaa !31
  ret void
}

attributes #0 = { 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" }

!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/C++ TBAA"}
!9 = !{!10, !11, i64 280}
!10 = !{!"BrotliDecoderStateStruct", !11, i64 0, !11, i64 4, !12, i64 8, !6, i64 40, !6, i64 48, !6, i64 56, !7, i64 64, !11, i64 72, !11, i64 76, !11, i64 80, !11, i64 84, !11, i64 88, !11, i64 92, !11, i64 96, !7, i64 100, !11, i64 116, !11, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !14, i64 184, !14, i64 208, !14, i64 232, !6, i64 256, !6, i64 264, !11, i64 272, !11, i64 276, !11, i64 280, !11, i64 284, !7, i64 288, !7, i64 300, !7, i64 312, !11, i64 336, !11, i64 340, !11, i64 344, !11, i64 348, !6, i64 352, !6, i64 360, !7, i64 368, !11, i64 372, !11, i64 376, !11, i64 380, !11, i64 384, !13, i64 392, !13, i64 400, !11, i64 408, !11, i64 412, !11, i64 416, !7, i64 420, !6, i64 552, !7, i64 560, !7, i64 2000, !7, i64 2128, !7, i64 2146, !11, i64 2180, !6, i64 2184, !11, i64 2192, !11, i64 2196, !11, i64 2200, !7, i64 2204, !11, i64 4788, !7, i64 4792, !11, i64 5052, !11, i64 5056, !11, i64 5060, !11, i64 5064, !11, i64 5068, !11, i64 5072, !11, i64 5076, !11, i64 5080, !11, i64 5080, !11, i64 5080, !11, i64 5080, !11, i64 5080, !11, i64 5080, !11, i64 5084, !11, i64 5088, !11, i64 5092, !6, i64 5096, !6, i64 5104, !6, i64 5112, !7, i64 5120}
!11 = !{!"int", !7, i64 0}
!12 = !{!"", !13, i64 0, !11, i64 8, !6, i64 16, !13, i64 24}
!13 = !{!"long", !7, i64 0}
!14 = !{!"", !6, i64 0, !6, i64 8, !15, i64 16, !15, i64 18}
!15 = !{!"short", !7, i64 0}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !6, i64 5096}
!18 = !{!10, !6, i64 5104}
!19 = !{!10, !6, i64 352}
!20 = !{!10, !6, i64 168}
!21 = !{!10, !6, i64 360}
!22 = !{!10, !6, i64 176}
!23 = !{!10, !7, i64 368}
!24 = !{!10, !6, i64 152}
!25 = !{!10, !6, i64 160}
!26 = !{!10, !6, i64 192}
!27 = !{!10, !6, i64 184}
!28 = !{!10, !6, i64 216}
!29 = !{!10, !6, i64 208}
!30 = !{!10, !6, i64 240}
!31 = !{!10, !6, i64 232}


; 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(argmem: write) uwtable
define hidden void @BrotliDecoderStateMetablockBegin(ptr nocapture noundef writeonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 280
  store i32 0, ptr %2, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 288
  store <4 x i32> <i32 268435456, i32 268435456, i32 268435456, i32 1>, ptr %3, align 8, !tbaa !15
  %4 = getelementptr inbounds i8, ptr %0, i64 304
  store <4 x i32> <i32 1, i32 1, i32 1, i32 0>, ptr %4, align 4, !tbaa !15
  %5 = getelementptr inbounds i8, ptr %0, i64 320
  store <4 x i32> <i32 1, i32 0, i32 1, i32 0>, ptr %5, align 8, !tbaa !15
  %6 = getelementptr inbounds i8, ptr %0, i64 5096
  %7 = getelementptr inbounds i8, ptr %0, i64 352
  %8 = getelementptr inbounds i8, ptr %0, i64 152
  %9 = getelementptr inbounds i8, ptr %0, i64 208
  %10 = getelementptr inbounds i8, ptr %0, i64 232
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %8, i8 0, i64 48, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %9, i8 0, i64 16, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %10, i8 0, i64 16, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(17) %7, i8 0, i64 17, i1 false)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %6, i8 0, i64 16, i1 false)
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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 = { 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, !7, i64 280}
!6 = !{!"BrotliDecoderStateStruct", !7, i64 0, !7, i64 4, !10, i64 8, !12, i64 40, !12, i64 48, !12, i64 56, !8, i64 64, !7, i64 72, !7, i64 76, !7, i64 80, !7, i64 84, !7, i64 88, !7, i64 92, !7, i64 96, !8, i64 100, !7, i64 116, !7, i64 120, !12, i64 128, !12, i64 136, !12, i64 144, !12, i64 152, !12, i64 160, !12, i64 168, !12, i64 176, !13, i64 184, !13, i64 208, !13, i64 232, !12, i64 256, !12, i64 264, !7, i64 272, !7, i64 276, !7, i64 280, !7, i64 284, !8, i64 288, !8, i64 300, !8, i64 312, !7, i64 336, !7, i64 340, !7, i64 344, !7, i64 348, !12, i64 352, !12, i64 360, !8, i64 368, !7, i64 372, !7, i64 376, !7, i64 380, !7, i64 384, !11, i64 392, !11, i64 400, !7, i64 408, !7, i64 412, !7, i64 416, !8, i64 420, !12, i64 552, !8, i64 560, !8, i64 2000, !8, i64 2128, !8, i64 2146, !7, i64 2180, !12, i64 2184, !7, i64 2192, !7, i64 2196, !7, i64 2200, !8, i64 2204, !7, i64 4788, !8, i64 4792, !7, i64 5052, !7, i64 5056, !7, i64 5060, !7, i64 5064, !7, i64 5068, !7, i64 5072, !7, i64 5076, !7, i64 5080, !7, i64 5080, !7, i64 5080, !7, i64 5080, !7, i64 5080, !7, i64 5080, !7, i64 5084, !7, i64 5088, !7, i64 5092, !12, i64 5096, !12, i64 5104, !12, i64 5112, !8, i64 5120}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !11, i64 0, !7, i64 8, !12, i64 16, !11, i64 24}
!11 = !{!"long", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"", !12, i64 0, !12, i64 8, !14, i64 16, !14, i64 18}
!14 = !{!"short", !8, i64 0}
!15 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,TailCallElimPass