; LLVM IR from fwip/fastqz :: libzpaq.ll (ZN7libzpaq9Predictor7predictEv)

; 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.libzpaq::Predictor" = type <{ i32, i32, [256 x i32], [256 x i32], ptr, [256 x %"struct.libzpaq::Component"], [256 x i32], [1024 x i32], [4096 x i16], [32768 x i16], %"class.libzpaq::StateTable", ptr, i32, [4 x i8] }>
%"struct.libzpaq::Component" = type { i64, i64, i64, i64, i64, %"class.libzpaq::Array", %"class.libzpaq::Array.0", %"class.libzpaq::Array.2" }
%"class.libzpaq::Array" = type <{ ptr, i64, i32, [4 x i8] }>
%"class.libzpaq::Array.0" = type <{ ptr, i64, i32, [4 x i8] }>
%"class.libzpaq::Array.2" = type <{ ptr, i64, i32, [4 x i8] }>
%"class.libzpaq::StateTable" = type { [1024 x i8] }

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7libzpaq6allocxERPhRii(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) #1

declare void @_ZN7libzpaq5errorEPKc(ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7libzpaq9Predictor7predictEv(ptr noundef nonnull align 8 dereferenceable(110620) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  %5 = getelementptr inbounds %"class.libzpaq::Predictor", ptr %4, i32 0, i32 11
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = icmp ne ptr %6, null
  br i1 %7, label %29, label %8

8:                                                ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %9 = call noundef i32 @_ZN7libzpaq9Predictor10assemble_pEv(ptr noundef nonnull align 8 dereferenceable(110620) %4)
  store i32 %9, ptr %3, align 4, !tbaa !13
  %10 = getelementptr inbounds %"class.libzpaq::Predictor", ptr %4, i32 0, i32 11
  %11 = getelementptr inbounds %"class.libzpaq::Predictor", ptr %4, i32 0, i32 12
  %12 = load i32, ptr %3, align 4, !tbaa !13
  call void @_ZN7libzpaq6allocxERPhRii(ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull align 4 dereferenceable(4) %11, i32 noundef %12)
  %13 = getelementptr inbounds %"class.libzpaq::Predictor", ptr %4, i32 0, i32 11
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %27

16:                                               ; preds = %8
  %17 = load i32, ptr %3, align 4, !tbaa !13
  %18 = call noundef i32 @_ZN7libzpaq9Predictor10assemble_pEv(ptr noundef nonnull align 8 dereferenceable(110620) %4)
  %19 = icmp ne i32 %17, %18
  br i1 %19, label %27, label %20

20:                                               ; preds = %16
  %21 = load i32, ptr %3, align 4, !tbaa !13
  %22 = icmp slt i32 %21, 10
  br i1 %22, label %27, label %23

23:                                               ; preds = %20
  %24 = getelementptr inbounds %"class.libzpaq::Predictor", ptr %4, i32 0, i32 12
  %25 = load i32, ptr %24, align 8, !tbaa !14
  %26 = icmp slt i32 %25, 10
  br i1 %26, label %27, label %28

27:                                               ; preds = %23, %20, %16, %8
  call void @_ZN7libzpaq5errorEPKc(ptr noundef @.str.44)
  br label %28

28:                                               ; preds = %27, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  br label %29

29:                                               ; preds = %28, %1
  %30 = getelementptr inbounds %"class.libzpaq::Predictor", ptr %4, i32 0, i32 11
  %31 = load ptr, ptr %30, align 8, !tbaa !9
  %32 = getelementptr inbounds i8, ptr %31, i64 0
  %33 = call noundef i32 %32(ptr noundef %4)
  ret i32 %33
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN7libzpaq9Predictor10assemble_pEv(ptr noundef nonnull align 8 dereferenceable(110620)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 #3 = { 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++ TBAA"}
!9 = !{!10, !6, i64 110608}
!10 = !{!"_ZTSN7libzpaq9PredictorE", !11, i64 0, !11, i64 4, !7, i64 8, !7, i64 1032, !6, i64 2056, !7, i64 2064, !7, i64 30736, !7, i64 31760, !7, i64 35856, !7, i64 44048, !12, i64 109584, !6, i64 110608, !11, i64 110616}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTSN7libzpaq10StateTableE", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 110616}


; 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.44 = external hidden unnamed_addr constant [21 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7libzpaq6allocxERPhRii(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 4 dereferenceable(4), i32 noundef) local_unnamed_addr #0

declare void @_ZN7libzpaq5errorEPKc(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7libzpaq9Predictor7predictEv(ptr noundef nonnull align 8 dereferenceable(110620) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 110608
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %4, label %15

4:                                                ; preds = %1
  %5 = tail call noundef i32 @_ZN7libzpaq9Predictor10assemble_pEv(ptr noundef nonnull align 8 dereferenceable(110620) %0)
  %6 = getelementptr inbounds i8, ptr %0, i64 110616
  tail call void @_ZN7libzpaq6allocxERPhRii(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 4 dereferenceable(4) %6, i32 noundef %5)
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %.not4 = icmp eq ptr %7, null
  br i1 %.not4, label %14, label %8

8:                                                ; preds = %4
  %9 = tail call noundef i32 @_ZN7libzpaq9Predictor10assemble_pEv(ptr noundef nonnull align 8 dereferenceable(110620) %0)
  %10 = icmp ne i32 %5, %9
  %11 = icmp slt i32 %5, 10
  %or.cond = or i1 %11, %10
  %12 = load i32, ptr %6, align 8
  %13 = icmp slt i32 %12, 10
  %or.cond6 = select i1 %or.cond, i1 true, i1 %13
  br i1 %or.cond6, label %14, label %15

14:                                               ; preds = %8, %4
  tail call void @_ZN7libzpaq5errorEPKc(ptr noundef nonnull @.str.44)
  br label %15

15:                                               ; preds = %14, %8, %1
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = tail call noundef i32 %16(ptr noundef nonnull %0)
  ret i32 %17
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZN7libzpaq9Predictor10assemble_pEv(ptr noundef nonnull align 8 dereferenceable(110620)) local_unnamed_addr #0 align 2

attributes #0 = { 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 #1 = { "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 110608}
!6 = !{!"_ZTSN7libzpaq9PredictorE", !7, i64 0, !7, i64 4, !8, i64 8, !8, i64 1032, !10, i64 2056, !8, i64 2064, !8, i64 30736, !8, i64 31760, !8, i64 35856, !8, i64 44048, !11, i64 109584, !10, i64 110608, !7, i64 110616}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_ZTSN7libzpaq10StateTableE", !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass