; LLVM IR from glaretechnologies/substrata :: opus/opus-1.3.1/celt (entdec)

; 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.ec_ctx = type { ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @ec_dec_init(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.ec_ctx, ptr %8, i32 0, i32 0
  store ptr %7, ptr %9, align 8, !tbaa !11
  %10 = load i32, ptr %6, align 4, !tbaa !9
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.ec_ctx, ptr %11, i32 0, i32 1
  store i32 %10, ptr %12, align 8, !tbaa !13
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.ec_ctx, ptr %13, i32 0, i32 2
  store i32 0, ptr %14, align 4, !tbaa !14
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.ec_ctx, ptr %15, i32 0, i32 3
  store i32 0, ptr %16, align 8, !tbaa !15
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.ec_ctx, ptr %17, i32 0, i32 4
  store i32 0, ptr %18, align 4, !tbaa !16
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.ec_ctx, ptr %19, i32 0, i32 5
  store i32 9, ptr %20, align 8, !tbaa !17
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ec_ctx, ptr %21, i32 0, i32 6
  store i32 0, ptr %22, align 4, !tbaa !18
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.ec_ctx, ptr %23, i32 0, i32 7
  store i32 128, ptr %24, align 8, !tbaa !19
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = call i32 @ec_read_byte(ptr noundef %25)
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ec_ctx, ptr %27, i32 0, i32 10
  store i32 %26, ptr %28, align 4, !tbaa !20
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ec_ctx, ptr %29, i32 0, i32 7
  %31 = load i32, ptr %30, align 8, !tbaa !19
  %32 = sub i32 %31, 1
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ec_ctx, ptr %33, i32 0, i32 10
  %35 = load i32, ptr %34, align 4, !tbaa !20
  %36 = ashr i32 %35, 1
  %37 = sub i32 %32, %36
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ec_ctx, ptr %38, i32 0, i32 8
  store i32 %37, ptr %39, align 4, !tbaa !21
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.ec_ctx, ptr %40, i32 0, i32 11
  store i32 0, ptr %41, align 8, !tbaa !22
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  call void @ec_dec_normalize(ptr noundef %42)
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i32 @ec_read_byte(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @ec_dec_normalize(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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"ec_ctx", !6, i64 0, !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, !10, i64 44, !10, i64 48}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 12}
!15 = !{!12, !10, i64 16}
!16 = !{!12, !10, i64 20}
!17 = !{!12, !10, i64 24}
!18 = !{!12, !10, i64 28}
!19 = !{!12, !10, i64 32}
!20 = !{!12, !10, i64 44}
!21 = !{!12, !10, i64 36}
!22 = !{!12, !10, i64 48}


; 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 dso_local void @ec_dec_init(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  store ptr %1, ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %2, ptr %4, align 8, !tbaa !11
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  store <4 x i32> <i32 0, i32 0, i32 0, i32 9>, ptr %5, align 4, !tbaa !12
  %6 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 0, ptr %6, align 4, !tbaa !13
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 128, ptr %7, align 8, !tbaa !14
  %8 = tail call i32 @ec_read_byte(ptr noundef nonnull %0)
  %9 = getelementptr inbounds i8, ptr %0, i64 44
  store i32 %8, ptr %9, align 4, !tbaa !15
  %10 = load i32, ptr %7, align 8, !tbaa !14
  %11 = ashr i32 %8, 1
  %12 = xor i32 %11, -1
  %13 = add i32 %10, %12
  %14 = getelementptr inbounds i8, ptr %0, i64 36
  store i32 %13, ptr %14, align 4, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 0, ptr %15, align 8, !tbaa !17
  tail call void @ec_dec_normalize(ptr noundef nonnull %0)
  ret void
}

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

; Function Attrs: nounwind uwtable
declare hidden void @ec_dec_normalize(ptr noundef) local_unnamed_addr #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, !7, i64 0}
!6 = !{!"ec_ctx", !7, i64 0, !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, !10, i64 44, !10, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!10, !10, i64 0}
!13 = !{!6, !10, i64 28}
!14 = !{!6, !10, i64 32}
!15 = !{!6, !10, i64 44}
!16 = !{!6, !10, i64 36}
!17 = !{!6, !10, i64 48}


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