; LLVM IR from DanEngelbrecht/longtail :: lib/brotli/ext/enc (encoder_dict)

; 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.SharedEncoderDictionary = type { i32, %struct.CompoundDictionary, %struct.ContextualEncoderDictionary, i32 }
%struct.CompoundDictionary = type { i64, i64, [16 x ptr], [16 x ptr], [16 x i64], i64, [16 x ptr] }
%struct.ContextualEncoderDictionary = type { i32, i8, [64 x i8], [64 x ptr], i64, %struct.BrotliEncoderDictionary, ptr }
%struct.BrotliEncoderDictionary = type { ptr, i32, i32, i64, ptr, ptr, ptr, ptr, %struct.BrotliTrie, i32, ptr, ptr, ptr, i64, ptr, i64, ptr, ptr }
%struct.BrotliTrie = type { ptr, i64, i64, %struct.BrotliTrieNode }
%struct.BrotliTrieNode = type { i8, i8, i8, i32, i32 }

; Function Attrs: nounwind uwtable
define hidden void @BrotliInitSharedEncoderDictionary(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.SharedEncoderDictionary, ptr %3, i32 0, i32 0
  store i32 -558043679, ptr %4, align 8, !tbaa !9
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.SharedEncoderDictionary, ptr %5, i32 0, i32 1
  %7 = getelementptr inbounds %struct.CompoundDictionary, ptr %6, i32 0, i32 0
  store i64 0, ptr %7, align 8, !tbaa !18
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.SharedEncoderDictionary, ptr %8, i32 0, i32 1
  %10 = getelementptr inbounds %struct.CompoundDictionary, ptr %9, i32 0, i32 1
  store i64 0, ptr %10, align 8, !tbaa !19
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.SharedEncoderDictionary, ptr %11, i32 0, i32 1
  %13 = getelementptr inbounds %struct.CompoundDictionary, ptr %12, i32 0, i32 4
  %14 = getelementptr inbounds [16 x i64], ptr %13, i64 0, i64 0
  store i64 0, ptr %14, align 8, !tbaa !20
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.SharedEncoderDictionary, ptr %15, i32 0, i32 1
  %17 = getelementptr inbounds %struct.CompoundDictionary, ptr %16, i32 0, i32 5
  store i64 0, ptr %17, align 8, !tbaa !21
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.SharedEncoderDictionary, ptr %18, i32 0, i32 2
  %20 = getelementptr inbounds %struct.ContextualEncoderDictionary, ptr %19, i32 0, i32 0
  store i32 0, ptr %20, align 8, !tbaa !22
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.SharedEncoderDictionary, ptr %21, i32 0, i32 2
  %23 = getelementptr inbounds %struct.ContextualEncoderDictionary, ptr %22, i32 0, i32 1
  store i8 1, ptr %23, align 4, !tbaa !23
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.SharedEncoderDictionary, ptr %24, i32 0, i32 2
  %26 = getelementptr inbounds %struct.ContextualEncoderDictionary, ptr %25, i32 0, i32 6
  store ptr null, ptr %26, align 8, !tbaa !24
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.SharedEncoderDictionary, ptr %27, i32 0, i32 2
  %29 = getelementptr inbounds %struct.ContextualEncoderDictionary, ptr %28, i32 0, i32 4
  store i64 1, ptr %29, align 8, !tbaa !25
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.SharedEncoderDictionary, ptr %30, i32 0, i32 2
  %32 = getelementptr inbounds %struct.ContextualEncoderDictionary, ptr %31, i32 0, i32 5
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.SharedEncoderDictionary, ptr %33, i32 0, i32 2
  %35 = getelementptr inbounds %struct.ContextualEncoderDictionary, ptr %34, i32 0, i32 3
  %36 = getelementptr inbounds [64 x ptr], ptr %35, i64 0, i64 0
  store ptr %32, ptr %36, align 8, !tbaa !5
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.SharedEncoderDictionary, ptr %37, i32 0, i32 2
  %39 = getelementptr inbounds %struct.ContextualEncoderDictionary, ptr %38, i32 0, i32 5
  call void @InitEncoderDictionary(ptr noundef %39)
  %40 = load ptr, ptr %2, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.SharedEncoderDictionary, ptr %40, i32 0, i32 2
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.SharedEncoderDictionary, ptr %42, i32 0, i32 2
  %44 = getelementptr inbounds %struct.ContextualEncoderDictionary, ptr %43, i32 0, i32 5
  %45 = getelementptr inbounds %struct.BrotliEncoderDictionary, ptr %44, i32 0, i32 10
  store ptr %41, ptr %45, align 8, !tbaa !26
  %46 = load ptr, ptr %2, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.SharedEncoderDictionary, ptr %46, i32 0, i32 3
  store i32 11, ptr %47, align 8, !tbaa !27
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @InitEncoderDictionary(ptr noundef) #0

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 0}
!10 = !{!"SharedEncoderDictionary", !11, i64 0, !12, i64 8, !14, i64 544, !11, i64 1312}
!11 = !{!"int", !7, i64 0}
!12 = !{!"CompoundDictionary", !13, i64 0, !13, i64 8, !7, i64 16, !7, i64 144, !7, i64 272, !13, i64 400, !7, i64 408}
!13 = !{!"long", !7, i64 0}
!14 = !{!"ContextualEncoderDictionary", !11, i64 0, !7, i64 4, !7, i64 5, !7, i64 72, !13, i64 584, !15, i64 592, !6, i64 760}
!15 = !{!"BrotliEncoderDictionary", !6, i64 0, !11, i64 8, !11, i64 12, !13, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !16, i64 56, !11, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !13, i64 128, !6, i64 136, !13, i64 144, !6, i64 152, !6, i64 160}
!16 = !{!"BrotliTrie", !6, i64 0, !13, i64 8, !13, i64 16, !17, i64 24}
!17 = !{!"BrotliTrieNode", !7, i64 0, !7, i64 1, !7, i64 2, !11, i64 4, !11, i64 8}
!18 = !{!10, !13, i64 8}
!19 = !{!10, !13, i64 16}
!20 = !{!13, !13, i64 0}
!21 = !{!10, !13, i64 408}
!22 = !{!10, !11, i64 544}
!23 = !{!10, !7, i64 548}
!24 = !{!10, !6, i64 1304}
!25 = !{!10, !13, i64 1128}
!26 = !{!10, !6, i64 1240}
!27 = !{!10, !11, i64 1312}


; 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: nounwind uwtable
define hidden void @BrotliInitSharedEncoderDictionary(ptr noundef %0) local_unnamed_addr #0 {
  store i32 -558043679, ptr %0, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 8
  %3 = getelementptr inbounds i8, ptr %0, i64 280
  store i64 0, ptr %3, align 8, !tbaa !17
  %4 = getelementptr inbounds i8, ptr %0, i64 408
  store i64 0, ptr %4, align 8, !tbaa !18
  %5 = getelementptr inbounds i8, ptr %0, i64 544
  store i32 0, ptr %5, align 8, !tbaa !19
  %6 = getelementptr inbounds i8, ptr %0, i64 548
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %2, i8 0, i64 16, i1 false)
  store i8 1, ptr %6, align 4, !tbaa !20
  %7 = getelementptr inbounds i8, ptr %0, i64 1304
  store ptr null, ptr %7, align 8, !tbaa !21
  %8 = getelementptr inbounds i8, ptr %0, i64 1128
  store i64 1, ptr %8, align 8, !tbaa !22
  %9 = getelementptr inbounds i8, ptr %0, i64 1136
  %10 = getelementptr inbounds i8, ptr %0, i64 616
  store ptr %9, ptr %10, align 8, !tbaa !23
  tail call void @InitEncoderDictionary(ptr noundef nonnull %9)
  %11 = getelementptr inbounds i8, ptr %0, i64 1240
  store ptr %5, ptr %11, align 8, !tbaa !24
  %12 = getelementptr inbounds i8, ptr %0, i64 1312
  store i32 11, ptr %12, align 8, !tbaa !25
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @InitEncoderDictionary(ptr noundef) local_unnamed_addr #0

; 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 = { 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 = { 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 0}
!6 = !{!"SharedEncoderDictionary", !7, i64 0, !10, i64 8, !12, i64 544, !7, i64 1312}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"CompoundDictionary", !11, i64 0, !11, i64 8, !8, i64 16, !8, i64 144, !8, i64 272, !11, i64 400, !8, i64 408}
!11 = !{!"long", !8, i64 0}
!12 = !{!"ContextualEncoderDictionary", !7, i64 0, !8, i64 4, !8, i64 5, !8, i64 72, !11, i64 584, !13, i64 592, !14, i64 760}
!13 = !{!"BrotliEncoderDictionary", !14, i64 0, !7, i64 8, !7, i64 12, !11, i64 16, !14, i64 24, !14, i64 32, !14, i64 40, !14, i64 48, !15, i64 56, !7, i64 96, !14, i64 104, !14, i64 112, !14, i64 120, !11, i64 128, !14, i64 136, !11, i64 144, !14, i64 152, !14, i64 160}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"BrotliTrie", !14, i64 0, !11, i64 8, !11, i64 16, !16, i64 24}
!16 = !{!"BrotliTrieNode", !8, i64 0, !8, i64 1, !8, i64 2, !7, i64 4, !7, i64 8}
!17 = !{!11, !11, i64 0}
!18 = !{!6, !11, i64 408}
!19 = !{!6, !7, i64 544}
!20 = !{!6, !8, i64 548}
!21 = !{!6, !14, i64 1304}
!22 = !{!6, !11, i64 1128}
!23 = !{!14, !14, i64 0}
!24 = !{!6, !14, i64 1240}
!25 = !{!6, !7, i64 1312}


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