; LLVM IR from cryspen/libcrux :: sys/hacl/c/src (Hacl_EC_Ed25519)

; 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"

; Function Attrs: nounwind uwtable
define dso_local void @Hacl_EC_Ed25519_felem_mul(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [10 x i128], align 16
  %8 = alloca i32, align 4
  %9 = alloca i128, align 16
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 160, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %24, %3
  %11 = load i32, ptr %8, align 4, !tbaa !9
  %12 = icmp ult i32 %11, 10
  br i1 %12, label %14, label %13

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

14:                                               ; preds = %10
  %15 = call { i64, i64 } @FStar_UInt128_uint64_to_uint128(i64 noundef 0)
  %16 = getelementptr inbounds { i64, i64 }, ptr %9, i32 0, i32 0
  %17 = extractvalue { i64, i64 } %15, 0
  store i64 %17, ptr %16, align 16
  %18 = getelementptr inbounds { i64, i64 }, ptr %9, i32 0, i32 1
  %19 = extractvalue { i64, i64 } %15, 1
  store i64 %19, ptr %18, align 8
  %20 = load i128, ptr %9, align 16, !tbaa !11
  %21 = load i32, ptr %8, align 4, !tbaa !9
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds [10 x i128], ptr %7, i64 0, i64 %22
  store i128 %20, ptr %23, align 16, !tbaa !11
  br label %24

24:                                               ; preds = %14
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = add i32 %25, 1
  store i32 %26, ptr %8, align 4, !tbaa !9
  br label %10, !llvm.loop !13

27:                                               ; preds = %13
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds [10 x i128], ptr %7, i64 0, i64 0
  call void @Hacl_Impl_Curve25519_Field51_fmul(ptr noundef %28, ptr noundef %29, ptr noundef %30, ptr noundef %31)
  call void @llvm.lifetime.end.p0(i64 160, ptr %7) #3
  ret void
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden { i64, i64 } @FStar_UInt128_uint64_to_uint128(i64 noundef) #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @Hacl_Impl_Curve25519_Field51_fmul(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"__int128", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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: nounwind uwtable
define dso_local void @Hacl_EC_Ed25519_felem_mul(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca [10 x i128], align 16
  call void @llvm.lifetime.start.p0(i64 160, ptr nonnull %4) #3
  %5 = tail call { i64, i64 } @FStar_UInt128_uint64_to_uint128(i64 noundef 0)
  %6 = extractvalue { i64, i64 } %5, 0
  %7 = extractvalue { i64, i64 } %5, 1
  %.sroa.2.0.insert.ext = zext i64 %7 to i128
  %.sroa.2.0.insert.shift = shl nuw i128 %.sroa.2.0.insert.ext, 64
  %.sroa.0.0.insert.ext = zext i64 %6 to i128
  %.sroa.0.0.insert.insert = or disjoint i128 %.sroa.2.0.insert.shift, %.sroa.0.0.insert.ext
  store i128 %.sroa.0.0.insert.insert, ptr %4, align 16, !tbaa !5
  %8 = tail call { i64, i64 } @FStar_UInt128_uint64_to_uint128(i64 noundef 0)
  %9 = extractvalue { i64, i64 } %8, 0
  %10 = extractvalue { i64, i64 } %8, 1
  %.sroa.2.0.insert.ext.1 = zext i64 %10 to i128
  %.sroa.2.0.insert.shift.1 = shl nuw i128 %.sroa.2.0.insert.ext.1, 64
  %.sroa.0.0.insert.ext.1 = zext i64 %9 to i128
  %.sroa.0.0.insert.insert.1 = or disjoint i128 %.sroa.2.0.insert.shift.1, %.sroa.0.0.insert.ext.1
  %11 = getelementptr inbounds i8, ptr %4, i64 16
  store i128 %.sroa.0.0.insert.insert.1, ptr %11, align 16, !tbaa !5
  %12 = tail call { i64, i64 } @FStar_UInt128_uint64_to_uint128(i64 noundef 0)
  %13 = extractvalue { i64, i64 } %12, 0
  %14 = extractvalue { i64, i64 } %12, 1
  %.sroa.2.0.insert.ext.2 = zext i64 %14 to i128
  %.sroa.2.0.insert.shift.2 = shl nuw i128 %.sroa.2.0.insert.ext.2, 64
  %.sroa.0.0.insert.ext.2 = zext i64 %13 to i128
  %.sroa.0.0.insert.insert.2 = or disjoint i128 %.sroa.2.0.insert.shift.2, %.sroa.0.0.insert.ext.2
  %15 = getelementptr inbounds i8, ptr %4, i64 32
  store i128 %.sroa.0.0.insert.insert.2, ptr %15, align 16, !tbaa !5
  %16 = tail call { i64, i64 } @FStar_UInt128_uint64_to_uint128(i64 noundef 0)
  %17 = extractvalue { i64, i64 } %16, 0
  %18 = extractvalue { i64, i64 } %16, 1
  %.sroa.2.0.insert.ext.3 = zext i64 %18 to i128
  %.sroa.2.0.insert.shift.3 = shl nuw i128 %.sroa.2.0.insert.ext.3, 64
  %.sroa.0.0.insert.ext.3 = zext i64 %17 to i128
  %.sroa.0.0.insert.insert.3 = or disjoint i128 %.sroa.2.0.insert.shift.3, %.sroa.0.0.insert.ext.3
  %19 = getelementptr inbounds i8, ptr %4, i64 48
  store i128 %.sroa.0.0.insert.insert.3, ptr %19, align 16, !tbaa !5
  %20 = tail call { i64, i64 } @FStar_UInt128_uint64_to_uint128(i64 noundef 0)
  %21 = extractvalue { i64, i64 } %20, 0
  %22 = extractvalue { i64, i64 } %20, 1
  %.sroa.2.0.insert.ext.4 = zext i64 %22 to i128
  %.sroa.2.0.insert.shift.4 = shl nuw i128 %.sroa.2.0.insert.ext.4, 64
  %.sroa.0.0.insert.ext.4 = zext i64 %21 to i128
  %.sroa.0.0.insert.insert.4 = or disjoint i128 %.sroa.2.0.insert.shift.4, %.sroa.0.0.insert.ext.4
  %23 = getelementptr inbounds i8, ptr %4, i64 64
  store i128 %.sroa.0.0.insert.insert.4, ptr %23, align 16, !tbaa !5
  %24 = tail call { i64, i64 } @FStar_UInt128_uint64_to_uint128(i64 noundef 0)
  %25 = extractvalue { i64, i64 } %24, 0
  %26 = extractvalue { i64, i64 } %24, 1
  %.sroa.2.0.insert.ext.5 = zext i64 %26 to i128
  %.sroa.2.0.insert.shift.5 = shl nuw i128 %.sroa.2.0.insert.ext.5, 64
  %.sroa.0.0.insert.ext.5 = zext i64 %25 to i128
  %.sroa.0.0.insert.insert.5 = or disjoint i128 %.sroa.2.0.insert.shift.5, %.sroa.0.0.insert.ext.5
  %27 = getelementptr inbounds i8, ptr %4, i64 80
  store i128 %.sroa.0.0.insert.insert.5, ptr %27, align 16, !tbaa !5
  %28 = tail call { i64, i64 } @FStar_UInt128_uint64_to_uint128(i64 noundef 0)
  %29 = extractvalue { i64, i64 } %28, 0
  %30 = extractvalue { i64, i64 } %28, 1
  %.sroa.2.0.insert.ext.6 = zext i64 %30 to i128
  %.sroa.2.0.insert.shift.6 = shl nuw i128 %.sroa.2.0.insert.ext.6, 64
  %.sroa.0.0.insert.ext.6 = zext i64 %29 to i128
  %.sroa.0.0.insert.insert.6 = or disjoint i128 %.sroa.2.0.insert.shift.6, %.sroa.0.0.insert.ext.6
  %31 = getelementptr inbounds i8, ptr %4, i64 96
  store i128 %.sroa.0.0.insert.insert.6, ptr %31, align 16, !tbaa !5
  %32 = tail call { i64, i64 } @FStar_UInt128_uint64_to_uint128(i64 noundef 0)
  %33 = extractvalue { i64, i64 } %32, 0
  %34 = extractvalue { i64, i64 } %32, 1
  %.sroa.2.0.insert.ext.7 = zext i64 %34 to i128
  %.sroa.2.0.insert.shift.7 = shl nuw i128 %.sroa.2.0.insert.ext.7, 64
  %.sroa.0.0.insert.ext.7 = zext i64 %33 to i128
  %.sroa.0.0.insert.insert.7 = or disjoint i128 %.sroa.2.0.insert.shift.7, %.sroa.0.0.insert.ext.7
  %35 = getelementptr inbounds i8, ptr %4, i64 112
  store i128 %.sroa.0.0.insert.insert.7, ptr %35, align 16, !tbaa !5
  %36 = tail call { i64, i64 } @FStar_UInt128_uint64_to_uint128(i64 noundef 0)
  %37 = extractvalue { i64, i64 } %36, 0
  %38 = extractvalue { i64, i64 } %36, 1
  %.sroa.2.0.insert.ext.8 = zext i64 %38 to i128
  %.sroa.2.0.insert.shift.8 = shl nuw i128 %.sroa.2.0.insert.ext.8, 64
  %.sroa.0.0.insert.ext.8 = zext i64 %37 to i128
  %.sroa.0.0.insert.insert.8 = or disjoint i128 %.sroa.2.0.insert.shift.8, %.sroa.0.0.insert.ext.8
  %39 = getelementptr inbounds i8, ptr %4, i64 128
  store i128 %.sroa.0.0.insert.insert.8, ptr %39, align 16, !tbaa !5
  %40 = tail call { i64, i64 } @FStar_UInt128_uint64_to_uint128(i64 noundef 0)
  %41 = extractvalue { i64, i64 } %40, 0
  %42 = extractvalue { i64, i64 } %40, 1
  %.sroa.2.0.insert.ext.9 = zext i64 %42 to i128
  %.sroa.2.0.insert.shift.9 = shl nuw i128 %.sroa.2.0.insert.ext.9, 64
  %.sroa.0.0.insert.ext.9 = zext i64 %41 to i128
  %.sroa.0.0.insert.insert.9 = or disjoint i128 %.sroa.2.0.insert.shift.9, %.sroa.0.0.insert.ext.9
  %43 = getelementptr inbounds i8, ptr %4, i64 144
  store i128 %.sroa.0.0.insert.insert.9, ptr %43, align 16, !tbaa !5
  call void @Hacl_Impl_Curve25519_Field51_fmul(ptr noundef %2, ptr noundef %0, ptr noundef %1, ptr noundef nonnull %4)
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %4) #3
  ret void
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden { i64, i64 } @FStar_UInt128_uint64_to_uint128(i64 noundef) local_unnamed_addr #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @Hacl_Impl_Curve25519_Field51_fmul(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #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 = !{!"__int128", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass