; LLVM IR from SSBMTonberry/pocketlzma :: ref_spec/lzma1900/C (Bcj2Enc)

; 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.CBcj2Enc = type { [4 x ptr], [4 x ptr], ptr, ptr, i32, i32, i8, i8, i32, i64, i64, i32, i32, i32, i32, i32, i32, [8 x i8], i32, [258 x i16] }

; Function Attrs: nounwind uwtable
define dso_local void @Bcj2Enc_Init(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.CBcj2Enc, ptr %4, i32 0, i32 4
  store i32 5, ptr %5, align 8, !tbaa !9
  %6 = load ptr, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.CBcj2Enc, ptr %6, i32 0, i32 5
  store i32 0, ptr %7, align 4, !tbaa !13
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.CBcj2Enc, ptr %8, i32 0, i32 6
  store i8 0, ptr %9, align 8, !tbaa !14
  %10 = load ptr, ptr %2, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.CBcj2Enc, ptr %10, i32 0, i32 7
  store i8 0, ptr %11, align 1, !tbaa !15
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.CBcj2Enc, ptr %12, i32 0, i32 8
  store i32 -1, ptr %13, align 4, !tbaa !16
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.CBcj2Enc, ptr %14, i32 0, i32 9
  store i64 0, ptr %15, align 8, !tbaa !17
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.CBcj2Enc, ptr %16, i32 0, i32 10
  store i64 1, ptr %17, align 8, !tbaa !18
  %18 = load ptr, ptr %2, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.CBcj2Enc, ptr %18, i32 0, i32 11
  store i32 0, ptr %19, align 8, !tbaa !19
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.CBcj2Enc, ptr %20, i32 0, i32 12
  store i32 0, ptr %21, align 4, !tbaa !20
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.CBcj2Enc, ptr %22, i32 0, i32 13
  store i32 0, ptr %23, align 8, !tbaa !21
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.CBcj2Enc, ptr %24, i32 0, i32 14
  store i32 67108864, ptr %25, align 4, !tbaa !22
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.CBcj2Enc, ptr %26, i32 0, i32 16
  store i32 0, ptr %27, align 4, !tbaa !23
  %28 = load ptr, ptr %2, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.CBcj2Enc, ptr %28, i32 0, i32 18
  store i32 0, ptr %29, align 8, !tbaa !24
  store i32 0, ptr %3, align 4, !tbaa !25
  br label %30

30:                                               ; preds = %40, %1
  %31 = load i32, ptr %3, align 4, !tbaa !25
  %32 = zext i32 %31 to i64
  %33 = icmp ult i64 %32, 258
  br i1 %33, label %34, label %43

34:                                               ; preds = %30
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.CBcj2Enc, ptr %35, i32 0, i32 19
  %37 = load i32, ptr %3, align 4, !tbaa !25
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds [258 x i16], ptr %36, i64 0, i64 %38
  store i16 1024, ptr %39, align 2, !tbaa !26
  br label %40

40:                                               ; preds = %34
  %41 = load i32, ptr %3, align 4, !tbaa !25
  %42 = add i32 %41, 1
  store i32 %42, ptr %3, align 4, !tbaa !25
  br label %30, !llvm.loop !28

43:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 nosync nounwind willreturn memory(argmem: readwrite) }
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/C++ TBAA"}
!9 = !{!10, !11, i64 80}
!10 = !{!"", !7, i64 0, !7, i64 32, !6, i64 64, !6, i64 72, !11, i64 80, !11, i64 84, !7, i64 88, !7, i64 89, !11, i64 92, !12, i64 96, !12, i64 104, !11, i64 112, !11, i64 116, !11, i64 120, !11, i64 124, !11, i64 128, !11, i64 132, !7, i64 136, !11, i64 144, !7, i64 148}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!10, !11, i64 84}
!14 = !{!10, !7, i64 88}
!15 = !{!10, !7, i64 89}
!16 = !{!10, !11, i64 92}
!17 = !{!10, !12, i64 96}
!18 = !{!10, !12, i64 104}
!19 = !{!10, !11, i64 112}
!20 = !{!10, !11, i64 116}
!21 = !{!10, !11, i64 120}
!22 = !{!10, !11, i64 124}
!23 = !{!10, !11, i64 132}
!24 = !{!10, !11, i64 144}
!25 = !{!11, !11, i64 0}
!26 = !{!27, !27, i64 0}
!27 = !{!"short", !7, i64 0}
!28 = distinct !{!28, !29}
!29 = !{!"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"

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: write) uwtable
define dso_local void @Bcj2Enc_Init(ptr nocapture noundef writeonly %0) local_unnamed_addr #0 {
vector.ph:
  %1 = getelementptr inbounds i8, ptr %0, i64 80
  store i32 5, ptr %1, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 84
  store i32 0, ptr %2, align 4, !tbaa !12
  %3 = getelementptr inbounds i8, ptr %0, i64 88
  store i8 0, ptr %3, align 8, !tbaa !13
  %4 = getelementptr inbounds i8, ptr %0, i64 89
  store i8 0, ptr %4, align 1, !tbaa !14
  %5 = getelementptr inbounds i8, ptr %0, i64 92
  store i32 -1, ptr %5, align 4, !tbaa !15
  %6 = getelementptr inbounds i8, ptr %0, i64 96
  store i64 0, ptr %6, align 8, !tbaa !16
  %7 = getelementptr inbounds i8, ptr %0, i64 104
  store i64 1, ptr %7, align 8, !tbaa !17
  %8 = getelementptr inbounds i8, ptr %0, i64 112
  store <4 x i32> <i32 0, i32 0, i32 0, i32 67108864>, ptr %8, align 8, !tbaa !18
  %9 = getelementptr inbounds i8, ptr %0, i64 132
  store i32 0, ptr %9, align 4, !tbaa !19
  %10 = getelementptr inbounds i8, ptr %0, i64 144
  store i32 0, ptr %10, align 8, !tbaa !20
  %11 = getelementptr inbounds i8, ptr %0, i64 148
  %12 = getelementptr inbounds i8, ptr %0, i64 164
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %11, align 2, !tbaa !21
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %12, align 2, !tbaa !21
  %13 = getelementptr inbounds i8, ptr %0, i64 180
  %14 = getelementptr inbounds i8, ptr %0, i64 196
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %13, align 2, !tbaa !21
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %14, align 2, !tbaa !21
  %15 = getelementptr inbounds i8, ptr %0, i64 212
  %16 = getelementptr inbounds i8, ptr %0, i64 228
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %15, align 2, !tbaa !21
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %16, align 2, !tbaa !21
  %17 = getelementptr inbounds i8, ptr %0, i64 244
  %18 = getelementptr inbounds i8, ptr %0, i64 260
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %17, align 2, !tbaa !21
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %18, align 2, !tbaa !21
  %19 = getelementptr inbounds i8, ptr %0, i64 276
  %20 = getelementptr inbounds i8, ptr %0, i64 292
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %19, align 2, !tbaa !21
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %20, align 2, !tbaa !21
  %21 = getelementptr inbounds i8, ptr %0, i64 308
  %22 = getelementptr inbounds i8, ptr %0, i64 324
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %21, align 2, !tbaa !21
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %22, align 2, !tbaa !21
  %23 = getelementptr inbounds i8, ptr %0, i64 340
  %24 = getelementptr inbounds i8, ptr %0, i64 356
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %23, align 2, !tbaa !21
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %24, align 2, !tbaa !21
  %25 = getelementptr inbounds i8, ptr %0, i64 372
  %26 = getelementptr inbounds i8, ptr %0, i64 388
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %25, align 2, !tbaa !21
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %26, align 2, !tbaa !21
  %27 = getelementptr inbounds i8, ptr %0, i64 404
  %28 = getelementptr inbounds i8, ptr %0, i64 420
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %27, align 2, !tbaa !21
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %28, align 2, !tbaa !21
  %29 = getelementptr inbounds i8, ptr %0, i64 436
  %30 = getelementptr inbounds i8, ptr %0, i64 452
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %29, align 2, !tbaa !21
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %30, align 2, !tbaa !21
  %31 = getelementptr inbounds i8, ptr %0, i64 468
  %32 = getelementptr inbounds i8, ptr %0, i64 484
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %31, align 2, !tbaa !21
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %32, align 2, !tbaa !21
  %33 = getelementptr inbounds i8, ptr %0, i64 500
  %34 = getelementptr inbounds i8, ptr %0, i64 516
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %33, align 2, !tbaa !21
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %34, align 2, !tbaa !21
  %35 = getelementptr inbounds i8, ptr %0, i64 532
  %36 = getelementptr inbounds i8, ptr %0, i64 548
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %35, align 2, !tbaa !21
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %36, align 2, !tbaa !21
  %37 = getelementptr inbounds i8, ptr %0, i64 564
  %38 = getelementptr inbounds i8, ptr %0, i64 580
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %37, align 2, !tbaa !21
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %38, align 2, !tbaa !21
  %39 = getelementptr inbounds i8, ptr %0, i64 596
  %40 = getelementptr inbounds i8, ptr %0, i64 612
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %39, align 2, !tbaa !21
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %40, align 2, !tbaa !21
  %41 = getelementptr inbounds i8, ptr %0, i64 628
  %42 = getelementptr inbounds i8, ptr %0, i64 644
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %41, align 2, !tbaa !21
  store <8 x i16> <i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024, i16 1024>, ptr %42, align 2, !tbaa !21
  %43 = getelementptr inbounds i8, ptr %0, i64 660
  store i16 1024, ptr %43, align 2, !tbaa !21
  %44 = getelementptr inbounds i8, ptr %0, i64 662
  store i16 1024, ptr %44, align 2, !tbaa !21
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind 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" }

!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 80}
!6 = !{!"", !7, i64 0, !7, i64 32, !9, i64 64, !9, i64 72, !10, i64 80, !10, i64 84, !7, i64 88, !7, i64 89, !10, i64 92, !11, i64 96, !11, i64 104, !10, i64 112, !10, i64 116, !10, i64 120, !10, i64 124, !10, i64 128, !10, i64 132, !7, i64 136, !10, i64 144, !7, i64 148}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"any pointer", !7, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!"long long", !7, i64 0}
!12 = !{!6, !10, i64 84}
!13 = !{!6, !7, i64 88}
!14 = !{!6, !7, i64 89}
!15 = !{!6, !10, i64 92}
!16 = !{!6, !11, i64 96}
!17 = !{!6, !11, i64 104}
!18 = !{!10, !10, i64 0}
!19 = !{!6, !10, i64 132}
!20 = !{!6, !10, i64 144}
!21 = !{!22, !22, i64 0}
!22 = !{!"short", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass