; LLVM IR from gbanegas/CryptoSith :: gf/GFieldPol.ll (ZNK11galoisfield9GFieldPoleqERKS0_)

; 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.galoisfield::GFieldPol" = type { ptr, %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<galoisfield::GFieldElement, std::allocator<galoisfield::GFieldElement>>::_Vector_impl" }
%"struct.std::_Vector_base<galoisfield::GFieldElement, std::allocator<galoisfield::GFieldElement>>::_Vector_impl" = type { %"struct.std::_Vector_base<galoisfield::GFieldElement, std::allocator<galoisfield::GFieldElement>>::_Vector_impl_data" }
%"struct.std::_Vector_base<galoisfield::GFieldElement, std::allocator<galoisfield::GFieldElement>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; 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 nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN11galoisfield13GFieldElementESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(12) ptr @_ZNKSt6vectorIN11galoisfield13GFieldElementESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZNK11galoisfield9GFieldPoleqERKS0_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) #2 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  %9 = getelementptr inbounds %"class.galoisfield::GFieldPol", ptr %8, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %"class.galoisfield::GFieldPol", ptr %11, i32 0, i32 0
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = icmp eq ptr %10, %13
  br i1 %14, label %15, label %50

15:                                               ; preds = %2
  %16 = getelementptr inbounds %"class.galoisfield::GFieldPol", ptr %8, i32 0, i32 1
  %17 = call noundef i64 @_ZNKSt6vectorIN11galoisfield13GFieldElementESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %16) #4
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %"class.galoisfield::GFieldPol", ptr %18, i32 0, i32 1
  %20 = call noundef i64 @_ZNKSt6vectorIN11galoisfield13GFieldElementESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %19) #4
  %21 = icmp ne i64 %17, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %15
  store i1 false, ptr %3, align 1
  br label %51

23:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !15
  br label %24

24:                                               ; preds = %44, %23
  %25 = load i32, ptr %6, align 4, !tbaa !15
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds %"class.galoisfield::GFieldPol", ptr %8, i32 0, i32 1
  %28 = call noundef i64 @_ZNKSt6vectorIN11galoisfield13GFieldElementESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %27) #4
  %29 = icmp ult i64 %26, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %24
  store i32 2, ptr %7, align 4
  br label %47

31:                                               ; preds = %24
  %32 = getelementptr inbounds %"class.galoisfield::GFieldPol", ptr %8, i32 0, i32 1
  %33 = load i32, ptr %6, align 4, !tbaa !15
  %34 = zext i32 %33 to i64
  %35 = call noundef nonnull align 8 dereferenceable(12) ptr @_ZNKSt6vectorIN11galoisfield13GFieldElementESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %32, i64 noundef %34) #4
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %"class.galoisfield::GFieldPol", ptr %36, i32 0, i32 1
  %38 = load i32, ptr %6, align 4, !tbaa !15
  %39 = zext i32 %38 to i64
  %40 = call noundef nonnull align 8 dereferenceable(12) ptr @_ZNKSt6vectorIN11galoisfield13GFieldElementESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %37, i64 noundef %39) #4
  %41 = call noundef zeroext i1 @_ZNK11galoisfield13GFieldElementneERKS0_(ptr noundef nonnull align 8 dereferenceable(12) %35, ptr noundef nonnull align 8 dereferenceable(12) %40)
  br i1 %41, label %42, label %43

42:                                               ; preds = %31
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %47

43:                                               ; preds = %31
  br label %44

44:                                               ; preds = %43
  %45 = load i32, ptr %6, align 4, !tbaa !15
  %46 = add i32 %45, 1
  store i32 %46, ptr %6, align 4, !tbaa !15
  br label %24, !llvm.loop !17

47:                                               ; preds = %42, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %48 = load i32, ptr %7, align 4
  switch i32 %48, label %53 [
    i32 2, label %49
    i32 1, label %51
  ]

49:                                               ; preds = %47
  store i1 true, ptr %3, align 1
  br label %51

50:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %51

51:                                               ; preds = %50, %49, %47, %22
  %52 = load i1, ptr %3, align 1
  ret i1 %52

53:                                               ; preds = %47
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK11galoisfield13GFieldElementneERKS0_(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef nonnull align 8 dereferenceable(12)) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 #2 = { 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 #3 = { inlinehint mustprogress 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 #4 = { 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 0}
!10 = !{!"_ZTSN11galoisfield9GFieldPolE", !6, i64 0, !11, i64 8}
!11 = !{!"_ZTSSt6vectorIN11galoisfield13GFieldElementESaIS1_EE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseIN11galoisfield13GFieldElementESaIS1_EE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIN11galoisfield13GFieldElementESaIS1_EE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIN11galoisfield13GFieldElementESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"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: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN11galoisfield13GFieldElementESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(12) ptr @_ZNKSt6vectorIN11galoisfield13GFieldElementESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK11galoisfield9GFieldPoleqERKS0_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1) local_unnamed_addr #0 align 2 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = load ptr, ptr %1, align 8, !tbaa !5
  %5 = icmp eq ptr %3, %4
  br i1 %5, label %6, label %.loopexit

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = tail call noundef i64 @_ZNKSt6vectorIN11galoisfield13GFieldElementESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #2
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = tail call noundef i64 @_ZNKSt6vectorIN11galoisfield13GFieldElementESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #2
  %.not = icmp eq i64 %8, %10
  br i1 %.not, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %6
  %11 = tail call noundef i64 @_ZNKSt6vectorIN11galoisfield13GFieldElementESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #2
  %12 = icmp eq i64 %11, 0
  br i1 %12, label %.loopexit, label %.lr.ph

13:                                               ; preds = %.lr.ph
  %14 = add i32 %.0912, 1
  %15 = zext i32 %14 to i64
  %16 = tail call noundef i64 @_ZNKSt6vectorIN11galoisfield13GFieldElementESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #2
  %.not15 = icmp ugt i64 %16, %15
  br i1 %.not15, label %.lr.ph, label %.loopexit.loopexit, !llvm.loop !14

.lr.ph:                                           ; preds = %.preheader, %13
  %17 = phi i64 [ %15, %13 ], [ 0, %.preheader ]
  %.0912 = phi i32 [ %14, %13 ], [ 0, %.preheader ]
  %18 = tail call noundef nonnull align 8 dereferenceable(12) ptr @_ZNKSt6vectorIN11galoisfield13GFieldElementESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %17) #2
  %19 = tail call noundef nonnull align 8 dereferenceable(12) ptr @_ZNKSt6vectorIN11galoisfield13GFieldElementESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %17) #2
  %20 = tail call noundef zeroext i1 @_ZNK11galoisfield13GFieldElementneERKS0_(ptr noundef nonnull align 8 dereferenceable(12) %18, ptr noundef nonnull align 8 dereferenceable(12) %19)
  br i1 %20, label %.loopexit.loopexit, label %13

.loopexit.loopexit:                               ; preds = %13, %.lr.ph
  %.1.ph = xor i1 %20, true
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.preheader, %2, %6
  %.1 = phi i1 [ false, %6 ], [ false, %2 ], [ true, %.preheader ], [ %.1.ph, %.loopexit.loopexit ]
  ret i1 %.1
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK11galoisfield13GFieldElementneERKS0_(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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 #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, !7, i64 0}
!6 = !{!"_ZTSN11galoisfield9GFieldPolE", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt6vectorIN11galoisfield13GFieldElementESaIS1_EE", !11, i64 0}
!11 = !{!"_ZTSSt12_Vector_baseIN11galoisfield13GFieldElementESaIS1_EE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseIN11galoisfield13GFieldElementESaIS1_EE12_Vector_implE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseIN11galoisfield13GFieldElementESaIS1_EE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass