; LLVM IR from albertobsd/keyhunt :: secp256k1/SECP256K1.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 { %union.anon }
%union.anon = type { [5 x i64] }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9Secp256K1C2Ev(ptr noundef nonnull align 8 dereferenceable(983240) %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(120) %6)
  %7 = getelementptr inbounds %class.Secp256K1, ptr %5, i32 0, i32 1
  invoke void @_ZN3IntC1Ev(ptr noundef nonnull align 8 dereferenceable(40) %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(40) %9)
          to label %10 unwind label %20

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(120) %15)
          to label %16 unwind label %24

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 = %8, %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 %34

24:                                               ; preds = %14
  %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
  %28 = icmp eq ptr %12, %15
  br i1 %28, label %33, label %29

29:                                               ; preds = %29, %24
  %30 = phi ptr [ %15, %24 ], [ %31, %29 ]
  %31 = getelementptr inbounds %class.Point, ptr %30, i64 -1
  call void @_ZN5PointD1Ev(ptr noundef nonnull align 8 dereferenceable(120) %31) #3
  %32 = icmp eq ptr %31, %12
  br i1 %32, label %33, label %29

33:                                               ; preds = %29, %24
  br label %34

34:                                               ; preds = %33, %20
  call void @_ZN5PointD1Ev(ptr noundef nonnull align 8 dereferenceable(120) %6) #3
  br label %35

35:                                               ; preds = %34
  %36 = load ptr, ptr %3, align 8
  %37 = load i32, ptr %4, align 4
  %38 = insertvalue { ptr, i32 } poison, ptr %36, 0
  %39 = insertvalue { ptr, i32 } %38, i32 %37, 1
  resume { ptr, i32 } %39
}

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN5PointD1Ev(ptr noundef nonnull align 8 dereferenceable(120)) 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(983240) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN5PointC1Ev(ptr noundef nonnull align 8 dereferenceable(120) %0)
  %2 = getelementptr inbounds i8, ptr %0, i64 120
  invoke void @_ZN3IntC1Ev(ptr noundef nonnull align 8 dereferenceable(40) %2)
          to label %3 unwind label %8

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

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

5:                                                ; preds = %.preheader12
  %.add = add nuw nsw i64 %.idx, 120
  %6 = icmp eq i64 %.add, 983240
  br i1 %6, label %7, label %.preheader12

7:                                                ; preds = %5
  ret void

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

10:                                               ; preds = %.preheader12
  %11 = landingpad { ptr, i32 }
          cleanup
  %12 = icmp eq i64 %.idx, 200
  br i1 %12, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %10, %.preheader
  %.idx7 = phi i64 [ %.add8, %.preheader ], [ %.idx, %10 ]
  %.add8 = add nsw i64 %.idx7, -120
  %.ptr10 = getelementptr inbounds i8, ptr %0, i64 %.add8
  tail call void @_ZN5PointD1Ev(ptr noundef nonnull align 8 dereferenceable(120) %.ptr10) #3
  %13 = icmp eq i64 %.add8, 200
  br i1 %13, label %.loopexit, label %.preheader

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

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN5PointD1Ev(ptr noundef nonnull align 8 dereferenceable(120)) 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