; LLVM IR from albertobsd/keyhunt :: secp256k1/IntMod.ll (ZN3Int4AddCEPS_)

; 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.Int = type { %union.anon }
%union.anon = type { [5 x i64] }

; 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
define dso_local noundef i64 @_ZN3Int4AddCEPS_(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  store i8 0, ptr %5, align 1, !tbaa !9
  %7 = load i8, ptr %5, align 1, !tbaa !9
  %8 = getelementptr inbounds %class.Int, ptr %6, i32 0, i32 0
  %9 = getelementptr inbounds [5 x i64], ptr %8, i64 0, i64 0
  %10 = load i64, ptr %9, align 8, !tbaa !9
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %class.Int, ptr %11, i32 0, i32 0
  %13 = getelementptr inbounds [5 x i64], ptr %12, i64 0, i64 0
  %14 = load i64, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds %class.Int, ptr %6, i32 0, i32 0
  %16 = getelementptr inbounds [5 x i64], ptr %15, i64 0, i64 0
  %17 = getelementptr inbounds i64, ptr %16, i64 0
  %18 = call { i8, i64 } @llvm.x86.addcarry.64(i8 %7, i64 %10, i64 %14)
  %19 = extractvalue { i8, i64 } %18, 1
  store i64 %19, ptr %17, align 8
  %20 = extractvalue { i8, i64 } %18, 0
  store i8 %20, ptr %5, align 1, !tbaa !9
  %21 = load i8, ptr %5, align 1, !tbaa !9
  %22 = getelementptr inbounds %class.Int, ptr %6, i32 0, i32 0
  %23 = getelementptr inbounds [5 x i64], ptr %22, i64 0, i64 1
  %24 = load i64, ptr %23, align 8, !tbaa !9
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %class.Int, ptr %25, i32 0, i32 0
  %27 = getelementptr inbounds [5 x i64], ptr %26, i64 0, i64 1
  %28 = load i64, ptr %27, align 8, !tbaa !9
  %29 = getelementptr inbounds %class.Int, ptr %6, i32 0, i32 0
  %30 = getelementptr inbounds [5 x i64], ptr %29, i64 0, i64 0
  %31 = getelementptr inbounds i64, ptr %30, i64 1
  %32 = call { i8, i64 } @llvm.x86.addcarry.64(i8 %21, i64 %24, i64 %28)
  %33 = extractvalue { i8, i64 } %32, 1
  store i64 %33, ptr %31, align 8
  %34 = extractvalue { i8, i64 } %32, 0
  store i8 %34, ptr %5, align 1, !tbaa !9
  %35 = load i8, ptr %5, align 1, !tbaa !9
  %36 = getelementptr inbounds %class.Int, ptr %6, i32 0, i32 0
  %37 = getelementptr inbounds [5 x i64], ptr %36, i64 0, i64 2
  %38 = load i64, ptr %37, align 8, !tbaa !9
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %class.Int, ptr %39, i32 0, i32 0
  %41 = getelementptr inbounds [5 x i64], ptr %40, i64 0, i64 2
  %42 = load i64, ptr %41, align 8, !tbaa !9
  %43 = getelementptr inbounds %class.Int, ptr %6, i32 0, i32 0
  %44 = getelementptr inbounds [5 x i64], ptr %43, i64 0, i64 0
  %45 = getelementptr inbounds i64, ptr %44, i64 2
  %46 = call { i8, i64 } @llvm.x86.addcarry.64(i8 %35, i64 %38, i64 %42)
  %47 = extractvalue { i8, i64 } %46, 1
  store i64 %47, ptr %45, align 8
  %48 = extractvalue { i8, i64 } %46, 0
  store i8 %48, ptr %5, align 1, !tbaa !9
  %49 = load i8, ptr %5, align 1, !tbaa !9
  %50 = getelementptr inbounds %class.Int, ptr %6, i32 0, i32 0
  %51 = getelementptr inbounds [5 x i64], ptr %50, i64 0, i64 3
  %52 = load i64, ptr %51, align 8, !tbaa !9
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %class.Int, ptr %53, i32 0, i32 0
  %55 = getelementptr inbounds [5 x i64], ptr %54, i64 0, i64 3
  %56 = load i64, ptr %55, align 8, !tbaa !9
  %57 = getelementptr inbounds %class.Int, ptr %6, i32 0, i32 0
  %58 = getelementptr inbounds [5 x i64], ptr %57, i64 0, i64 0
  %59 = getelementptr inbounds i64, ptr %58, i64 3
  %60 = call { i8, i64 } @llvm.x86.addcarry.64(i8 %49, i64 %52, i64 %56)
  %61 = extractvalue { i8, i64 } %60, 1
  store i64 %61, ptr %59, align 8
  %62 = extractvalue { i8, i64 } %60, 0
  store i8 %62, ptr %5, align 1, !tbaa !9
  %63 = load i8, ptr %5, align 1, !tbaa !9
  %64 = getelementptr inbounds %class.Int, ptr %6, i32 0, i32 0
  %65 = getelementptr inbounds [5 x i64], ptr %64, i64 0, i64 4
  %66 = load i64, ptr %65, align 8, !tbaa !9
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %class.Int, ptr %67, i32 0, i32 0
  %69 = getelementptr inbounds [5 x i64], ptr %68, i64 0, i64 4
  %70 = load i64, ptr %69, align 8, !tbaa !9
  %71 = getelementptr inbounds %class.Int, ptr %6, i32 0, i32 0
  %72 = getelementptr inbounds [5 x i64], ptr %71, i64 0, i64 0
  %73 = getelementptr inbounds i64, ptr %72, i64 4
  %74 = call { i8, i64 } @llvm.x86.addcarry.64(i8 %63, i64 %66, i64 %70)
  %75 = extractvalue { i8, i64 } %74, 1
  store i64 %75, ptr %73, align 8
  %76 = extractvalue { i8, i64 } %74, 0
  store i8 %76, ptr %5, align 1, !tbaa !9
  %77 = load i8, ptr %5, align 1, !tbaa !9
  %78 = zext i8 %77 to i64
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  ret i64 %78
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare { i8, i64 } @llvm.x86.addcarry.64(i8, i64, i64) #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 = { nocallback nofree nosync nounwind willreturn memory(none) }
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 = !{!7, !7, i64 0}


; 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 nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local noundef range(i64 0, 256) i64 @_ZN3Int4AddCEPS_(ptr nocapture noundef nonnull align 8 dereferenceable(40) %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 align 2 {
  %3 = load i64, ptr %0, align 8, !tbaa !5
  %4 = load i64, ptr %1, align 8, !tbaa !5
  %5 = tail call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %3, i64 %4)
  %6 = extractvalue { i64, i1 } %5, 0
  %7 = extractvalue { i64, i1 } %5, 1
  %8 = zext i1 %7 to i8
  store i64 %6, ptr %0, align 8
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  %10 = load i64, ptr %9, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = load i64, ptr %11, align 8, !tbaa !5
  %13 = tail call { i8, i64 } @llvm.x86.addcarry.64(i8 %8, i64 %10, i64 %12)
  %14 = extractvalue { i8, i64 } %13, 1
  store i64 %14, ptr %9, align 8
  %15 = extractvalue { i8, i64 } %13, 0
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = load i64, ptr %16, align 8, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %1, i64 16
  %19 = load i64, ptr %18, align 8, !tbaa !5
  %20 = tail call { i8, i64 } @llvm.x86.addcarry.64(i8 %15, i64 %17, i64 %19)
  %21 = extractvalue { i8, i64 } %20, 1
  store i64 %21, ptr %16, align 8
  %22 = extractvalue { i8, i64 } %20, 0
  %23 = getelementptr inbounds i8, ptr %0, i64 24
  %24 = load i64, ptr %23, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %1, i64 24
  %26 = load i64, ptr %25, align 8, !tbaa !5
  %27 = tail call { i8, i64 } @llvm.x86.addcarry.64(i8 %22, i64 %24, i64 %26)
  %28 = extractvalue { i8, i64 } %27, 1
  store i64 %28, ptr %23, align 8
  %29 = extractvalue { i8, i64 } %27, 0
  %30 = getelementptr inbounds i8, ptr %0, i64 32
  %31 = load i64, ptr %30, align 8, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %1, i64 32
  %33 = load i64, ptr %32, align 8, !tbaa !5
  %34 = tail call { i8, i64 } @llvm.x86.addcarry.64(i8 %29, i64 %31, i64 %33)
  %35 = extractvalue { i8, i64 } %34, 1
  store i64 %35, ptr %30, align 8
  %36 = extractvalue { i8, i64 } %34, 0
  %37 = zext i8 %36 to i64
  ret i64 %37
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(none)
declare { i8, i64 } @llvm.x86.addcarry.64(i8, i64, i64) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.uadd.with.overflow.i64(i64, i64) #2

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(none) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass