; LLVM IR from digital-salon/Digital-Salon :: extern/include/contrib/Open3DGC (o3dgcArithmeticCodec)

; 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"

%"class.o3dgc::Arithmetic_Codec" = type <{ ptr, ptr, ptr, i32, i32, i32, i32, i32, [4 x i8] }>

@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: mustprogress noreturn uwtable
declare hidden void @_ZN5o3dgcL8AC_ErrorEPKc(ptr noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5o3dgc16Arithmetic_Codec13start_decoderEv(ptr noundef nonnull align 8 dereferenceable(44) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  %4 = getelementptr inbounds %"class.o3dgc::Arithmetic_Codec", ptr %3, i32 0, i32 7
  %5 = load i32, ptr %4, align 8, !tbaa !9
  %6 = icmp ne i32 %5, 0
  br i1 %6, label %7, label %8

7:                                                ; preds = %1
  call void @_ZN5o3dgcL8AC_ErrorEPKc(ptr noundef @.str.4) #2
  unreachable

8:                                                ; preds = %1
  %9 = getelementptr inbounds %"class.o3dgc::Arithmetic_Codec", ptr %3, i32 0, i32 6
  %10 = load i32, ptr %9, align 4, !tbaa !12
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %13

12:                                               ; preds = %8
  call void @_ZN5o3dgcL8AC_ErrorEPKc(ptr noundef @.str.3) #2
  unreachable

13:                                               ; preds = %8
  %14 = getelementptr inbounds %"class.o3dgc::Arithmetic_Codec", ptr %3, i32 0, i32 7
  store i32 2, ptr %14, align 8, !tbaa !9
  %15 = getelementptr inbounds %"class.o3dgc::Arithmetic_Codec", ptr %3, i32 0, i32 5
  store i32 -1, ptr %15, align 8, !tbaa !13
  %16 = getelementptr inbounds %"class.o3dgc::Arithmetic_Codec", ptr %3, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = getelementptr inbounds i8, ptr %17, i64 3
  %19 = getelementptr inbounds %"class.o3dgc::Arithmetic_Codec", ptr %3, i32 0, i32 2
  store ptr %18, ptr %19, align 8, !tbaa !15
  %20 = getelementptr inbounds %"class.o3dgc::Arithmetic_Codec", ptr %3, i32 0, i32 0
  %21 = load ptr, ptr %20, align 8, !tbaa !14
  %22 = getelementptr inbounds i8, ptr %21, i64 0
  %23 = load i8, ptr %22, align 1, !tbaa !16
  %24 = zext i8 %23 to i32
  %25 = shl i32 %24, 24
  %26 = getelementptr inbounds %"class.o3dgc::Arithmetic_Codec", ptr %3, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !14
  %28 = getelementptr inbounds i8, ptr %27, i64 1
  %29 = load i8, ptr %28, align 1, !tbaa !16
  %30 = zext i8 %29 to i32
  %31 = shl i32 %30, 16
  %32 = or i32 %25, %31
  %33 = getelementptr inbounds %"class.o3dgc::Arithmetic_Codec", ptr %3, i32 0, i32 0
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  %35 = getelementptr inbounds i8, ptr %34, i64 2
  %36 = load i8, ptr %35, align 1, !tbaa !16
  %37 = zext i8 %36 to i32
  %38 = shl i32 %37, 8
  %39 = or i32 %32, %38
  %40 = getelementptr inbounds %"class.o3dgc::Arithmetic_Codec", ptr %3, i32 0, i32 0
  %41 = load ptr, ptr %40, align 8, !tbaa !14
  %42 = getelementptr inbounds i8, ptr %41, i64 3
  %43 = load i8, ptr %42, align 1, !tbaa !16
  %44 = zext i8 %43 to i32
  %45 = or i32 %39, %44
  %46 = getelementptr inbounds %"class.o3dgc::Arithmetic_Codec", ptr %3, i32 0, i32 4
  store i32 %45, ptr %46, align 4, !tbaa !17
  ret void
}

attributes #0 = { mustprogress noreturn 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 = { 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 #2 = { noreturn }

!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, !11, i64 40}
!10 = !{!"_ZTSN5o3dgc16Arithmetic_CodecE", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 36}
!13 = !{!10, !11, i64 32}
!14 = !{!10, !6, i64 0}
!15 = !{!10, !6, i64 16}
!16 = !{!7, !7, i64 0}
!17 = !{!10, !11, i64 28}


; 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"

@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: mustprogress noreturn uwtable
declare hidden void @_ZN5o3dgcL8AC_ErrorEPKc(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5o3dgc16Arithmetic_Codec13start_decoderEv(ptr nocapture noundef nonnull align 8 dereferenceable(44) %0) local_unnamed_addr #1 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 40
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %5, label %4

4:                                                ; preds = %1
  tail call void @_ZN5o3dgcL8AC_ErrorEPKc(ptr noundef nonnull @.str.4) #2
  unreachable

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 36
  %7 = load i32, ptr %6, align 4, !tbaa !11
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %9, label %10

9:                                                ; preds = %5
  tail call void @_ZN5o3dgcL8AC_ErrorEPKc(ptr noundef nonnull @.str.3) #2
  unreachable

10:                                               ; preds = %5
  store i32 2, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  store i32 -1, ptr %11, align 8, !tbaa !12
  %12 = load ptr, ptr %0, align 8, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %12, i64 3
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %13, ptr %14, align 8, !tbaa !14
  %15 = load i8, ptr %12, align 1, !tbaa !15
  %16 = zext i8 %15 to i32
  %17 = shl nuw i32 %16, 24
  %18 = getelementptr inbounds i8, ptr %12, i64 1
  %19 = load i8, ptr %18, align 1, !tbaa !15
  %20 = zext i8 %19 to i32
  %21 = shl nuw nsw i32 %20, 16
  %22 = or disjoint i32 %21, %17
  %23 = getelementptr inbounds i8, ptr %12, i64 2
  %24 = load i8, ptr %23, align 1, !tbaa !15
  %25 = zext i8 %24 to i32
  %26 = shl nuw nsw i32 %25, 8
  %27 = or disjoint i32 %22, %26
  %28 = load i8, ptr %13, align 1, !tbaa !15
  %29 = zext i8 %28 to i32
  %30 = or disjoint i32 %27, %29
  %31 = getelementptr inbounds i8, ptr %0, i64 28
  store i32 %30, ptr %31, align 4, !tbaa !16
  ret void
}

attributes #0 = { mustprogress noreturn 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 = { 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 #2 = { noreturn }

!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, !10, i64 40}
!6 = !{!"_ZTSN5o3dgc16Arithmetic_CodecE", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 36}
!12 = !{!6, !10, i64 32}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !7, i64 16}
!15 = !{!8, !8, i64 0}
!16 = !{!6, !10, i64 28}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass