; LLVM IR from albertobsd/keyhunt :: gmp256k1/GMP256K1.ll (ZN9Secp256K1C2Ev)

; 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.Secp256K1 = type { %class.Point, %class.Int, %class.Int, [8192 x %class.Point] }
%class.Point = type { %class.Int, %class.Int, %class.Int }
%class.Int = type { [1 x %struct.__mpz_struct] }
%struct.__mpz_struct = type { i32, i32, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9Secp256K1C2Ev(ptr noundef nonnull align 8 dereferenceable(393296) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  %6 = getelementptr inbounds %class.Secp256K1, ptr %5, i32 0, i32 0
  call void @_ZN5PointC1Ev(ptr noundef nonnull align 8 dereferenceable(48) %6)
  %7 = getelementptr inbounds %class.Secp256K1, ptr %5, i32 0, i32 1
  invoke void @_ZN3IntC1Ev(ptr noundef nonnull align 8 dereferenceable(16) %7)
          to label %8 unwind label %20

8:                                                ; preds = %1
  %9 = getelementptr inbounds %class.Secp256K1, ptr %5, i32 0, i32 2
  invoke void @_ZN3IntC1Ev(ptr noundef nonnull align 8 dereferenceable(16) %9)
          to label %10 unwind label %24

10:                                               ; preds = %8
  %11 = getelementptr inbounds %class.Secp256K1, ptr %5, i32 0, i32 3
  %12 = getelementptr inbounds [8192 x %class.Point], ptr %11, i32 0, i32 0
  %13 = getelementptr inbounds %class.Point, ptr %12, i64 8192
  br label %14

14:                                               ; preds = %16, %10
  %15 = phi ptr [ %12, %10 ], [ %17, %16 ]
  invoke void @_ZN5PointC1Ev(ptr noundef nonnull align 8 dereferenceable(48) %15)
          to label %16 unwind label %28

16:                                               ; preds = %14
  %17 = getelementptr inbounds %class.Point, ptr %15, i64 1
  %18 = icmp eq ptr %17, %13
  br i1 %18, label %19, label %14

19:                                               ; preds = %16
  ret void

20:                                               ; preds = %1
  %21 = landingpad { ptr, i32 }
          cleanup
  %22 = extractvalue { ptr, i32 } %21, 0
  store ptr %22, ptr %3, align 8
  %23 = extractvalue { ptr, i32 } %21, 1
  store i32 %23, ptr %4, align 4
  br label %39

24:                                               ; preds = %8
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %3, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %4, align 4
  br label %38

28:                                               ; preds = %14
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %3, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %4, align 4
  %32 = icmp eq ptr %12, %15
  br i1 %32, label %37, label %33

33:                                               ; preds = %33, %28
  %34 = phi ptr [ %15, %28 ], [ %35, %33 ]
  %35 = getelementptr inbounds %class.Point, ptr %34, i64 -1
  call void @_ZN5PointD1Ev(ptr noundef nonnull align 8 dereferenceable(48) %35) #3
  %36 = icmp eq ptr %35, %12
  br i1 %36, label %37, label %33

37:                                               ; preds = %33, %28
  call void @_ZN3IntD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %9) #3
  br label %38

38:                                               ; preds = %37, %24
  call void @_ZN3IntD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %7) #3
  br label %39

39:                                               ; preds = %38, %20
  call void @_ZN5PointD1Ev(ptr noundef nonnull align 8 dereferenceable(48) %6) #3
  br label %40

40:                                               ; preds = %39
  %41 = load ptr, ptr %3, align 8
  %42 = load i32, ptr %4, align 4
  %43 = insertvalue { ptr, i32 } poison, ptr %41, 0
  %44 = insertvalue { ptr, i32 } %43, i32 %42, 1
  resume { ptr, i32 } %44
}

declare void @_ZN5PointC1Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #1

declare void @_ZN3IntC1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN5PointD1Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #2

; Function Attrs: nounwind
declare void @_ZN3IntD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #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" }
attributes #2 = { nounwind "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"}


; 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 uwtable
define dso_local void @_ZN9Secp256K1C2Ev(ptr noundef nonnull align 8 dereferenceable(393296) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN5PointC1Ev(ptr noundef nonnull align 8 dereferenceable(48) %0)
  %2 = getelementptr inbounds i8, ptr %0, i64 48
  invoke void @_ZN3IntC1Ev(ptr noundef nonnull align 8 dereferenceable(16) %2)
          to label %3 unwind label %8

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 64
  invoke void @_ZN3IntC1Ev(ptr noundef nonnull align 8 dereferenceable(16) %4)
          to label %.preheader14 unwind label %10

.preheader14:                                     ; preds = %3, %5
  %.idx = phi i64 [ %.add, %5 ], [ 80, %3 ]
  %.ptr.ptr = getelementptr inbounds i8, ptr %0, i64 %.idx
  invoke void @_ZN5PointC1Ev(ptr noundef nonnull align 8 dereferenceable(48) %.ptr.ptr)
          to label %5 unwind label %12

5:                                                ; preds = %.preheader14
  %.add = add nuw nsw i64 %.idx, 48
  %6 = icmp eq i64 %.add, 393296
  br i1 %6, label %7, label %.preheader14

7:                                                ; preds = %5
  ret void

8:                                                ; preds = %1
  %9 = landingpad { ptr, i32 }
          cleanup
  br label %17

10:                                               ; preds = %3
  %11 = landingpad { ptr, i32 }
          cleanup
  br label %16

12:                                               ; preds = %.preheader14
  %13 = landingpad { ptr, i32 }
          cleanup
  %14 = icmp eq i64 %.idx, 80
  br i1 %14, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %12, %.preheader
  %.idx8 = phi i64 [ %.add9, %.preheader ], [ %.idx, %12 ]
  %.add9 = add nsw i64 %.idx8, -48
  %.ptr11 = getelementptr inbounds i8, ptr %0, i64 %.add9
  tail call void @_ZN5PointD1Ev(ptr noundef nonnull align 8 dereferenceable(48) %.ptr11) #3
  %15 = icmp eq i64 %.add9, 80
  br i1 %15, label %.loopexit, label %.preheader

.loopexit:                                        ; preds = %.preheader, %12
  tail call void @_ZN3IntD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %4) #3
  br label %16

16:                                               ; preds = %.loopexit, %10
  %.pn = phi { ptr, i32 } [ %13, %.loopexit ], [ %11, %10 ]
  tail call void @_ZN3IntD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #3
  br label %17

17:                                               ; preds = %16, %8
  %.pn.pn = phi { ptr, i32 } [ %.pn, %16 ], [ %9, %8 ]
  tail call void @_ZN5PointD1Ev(ptr noundef nonnull align 8 dereferenceable(48) %0) #3
  resume { ptr, i32 } %.pn.pn
}

declare void @_ZN5PointC1Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #1

declare void @_ZN3IntC1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN5PointD1Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #2

; Function Attrs: nounwind
declare void @_ZN3IntD1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #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" }
attributes #2 = { nounwind "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)"}


; Effective O3 passes: EarlyCSEPass,GVNPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass