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

; 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_Curve25519_64_scalarmult(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 [8 x i64], align 16
  %8 = alloca [4 x i64], align 16
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  %20 = alloca ptr, align 8
  %21 = alloca ptr, align 8
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  %24 = alloca i64, align 8
  %25 = alloca ptr, align 8
  %26 = alloca ptr, align 8
  %27 = alloca i64, align 8
  %28 = alloca i64, align 8
  %29 = alloca i64, align 8
  %30 = alloca i64, align 8
  %31 = alloca ptr, align 8
  %32 = alloca ptr, align 8
  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 64, ptr %7) #4
  call void @llvm.memset.p0.i64(ptr align 16 %7, i8 0, i64 64, i1 false)
  call void @llvm.lifetime.start.p0(i64 32, ptr %8) #4
  call void @llvm.memset.p0.i64(ptr align 16 %8, i8 0, i64 32, i1 false)
  br label %33

33:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %34 = getelementptr inbounds [4 x i64], ptr %8, i64 0, i64 0
  store ptr %34, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = mul i32 %36, 8
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds i8, ptr %35, i64 %38
  store ptr %39, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %40 = load ptr, ptr %11, align 8, !tbaa !5
  %41 = call i64 @load64(ptr noundef %40)
  %42 = call i64 @__uint64_identity(i64 noundef %41)
  store i64 %42, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %43 = load i64, ptr %12, align 8, !tbaa !11
  store i64 %43, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %44 = load i64, ptr %13, align 8, !tbaa !11
  store i64 %44, ptr %14, align 8, !tbaa !11
  %45 = load i64, ptr %14, align 8, !tbaa !11
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = load i32, ptr %9, align 4, !tbaa !9
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds i64, ptr %46, i64 %48
  store i64 %45, ptr %49, align 8, !tbaa !11
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = add i32 %50, 1
  store i32 %51, ptr %9, align 4, !tbaa !9
  %52 = load i32, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %53 = getelementptr inbounds [4 x i64], ptr %8, i64 0, i64 0
  store ptr %53, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = load i32, ptr %9, align 4, !tbaa !9
  %56 = mul i32 %55, 8
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds i8, ptr %54, i64 %57
  store ptr %58, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %59 = load ptr, ptr %16, align 8, !tbaa !5
  %60 = call i64 @load64(ptr noundef %59)
  %61 = call i64 @__uint64_identity(i64 noundef %60)
  store i64 %61, ptr %17, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %62 = load i64, ptr %17, align 8, !tbaa !11
  store i64 %62, ptr %18, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %63 = load i64, ptr %18, align 8, !tbaa !11
  store i64 %63, ptr %19, align 8, !tbaa !11
  %64 = load i64, ptr %19, align 8, !tbaa !11
  %65 = load ptr, ptr %15, align 8, !tbaa !5
  %66 = load i32, ptr %9, align 4, !tbaa !9
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds i64, ptr %65, i64 %67
  store i64 %64, ptr %68, align 8, !tbaa !11
  %69 = load i32, ptr %9, align 4, !tbaa !9
  %70 = add i32 %69, 1
  store i32 %70, ptr %9, align 4, !tbaa !9
  %71 = load i32, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  %72 = getelementptr inbounds [4 x i64], ptr %8, i64 0, i64 0
  store ptr %72, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = load i32, ptr %9, align 4, !tbaa !9
  %75 = mul i32 %74, 8
  %76 = zext i32 %75 to i64
  %77 = getelementptr inbounds i8, ptr %73, i64 %76
  store ptr %77, ptr %21, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  %78 = load ptr, ptr %21, align 8, !tbaa !5
  %79 = call i64 @load64(ptr noundef %78)
  %80 = call i64 @__uint64_identity(i64 noundef %79)
  store i64 %80, ptr %22, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #4
  %81 = load i64, ptr %22, align 8, !tbaa !11
  store i64 %81, ptr %23, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #4
  %82 = load i64, ptr %23, align 8, !tbaa !11
  store i64 %82, ptr %24, align 8, !tbaa !11
  %83 = load i64, ptr %24, align 8, !tbaa !11
  %84 = load ptr, ptr %20, align 8, !tbaa !5
  %85 = load i32, ptr %9, align 4, !tbaa !9
  %86 = zext i32 %85 to i64
  %87 = getelementptr inbounds i64, ptr %84, i64 %86
  store i64 %83, ptr %87, align 8, !tbaa !11
  %88 = load i32, ptr %9, align 4, !tbaa !9
  %89 = add i32 %88, 1
  store i32 %89, ptr %9, align 4, !tbaa !9
  %90 = load i32, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %25) #4
  %91 = getelementptr inbounds [4 x i64], ptr %8, i64 0, i64 0
  store ptr %91, ptr %25, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %26) #4
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = load i32, ptr %9, align 4, !tbaa !9
  %94 = mul i32 %93, 8
  %95 = zext i32 %94 to i64
  %96 = getelementptr inbounds i8, ptr %92, i64 %95
  store ptr %96, ptr %26, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %27) #4
  %97 = load ptr, ptr %26, align 8, !tbaa !5
  %98 = call i64 @load64(ptr noundef %97)
  %99 = call i64 @__uint64_identity(i64 noundef %98)
  store i64 %99, ptr %27, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #4
  %100 = load i64, ptr %27, align 8, !tbaa !11
  store i64 %100, ptr %28, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %29) #4
  %101 = load i64, ptr %28, align 8, !tbaa !11
  store i64 %101, ptr %29, align 8, !tbaa !11
  %102 = load i64, ptr %29, align 8, !tbaa !11
  %103 = load ptr, ptr %25, align 8, !tbaa !5
  %104 = load i32, ptr %9, align 4, !tbaa !9
  %105 = zext i32 %104 to i64
  %106 = getelementptr inbounds i64, ptr %103, i64 %105
  store i64 %102, ptr %106, align 8, !tbaa !11
  %107 = load i32, ptr %9, align 4, !tbaa !9
  %108 = add i32 %107, 1
  store i32 %108, ptr %9, align 4, !tbaa !9
  %109 = load i32, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %29) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %27) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %26) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %25) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %110

110:                                              ; preds = %33
  br label %111

111:                                              ; preds = %110
  call void @llvm.lifetime.start.p0(i64 8, ptr %30) #4
  %112 = getelementptr inbounds [4 x i64], ptr %8, i64 0, i64 3
  %113 = load i64, ptr %112, align 8, !tbaa !11
  store i64 %113, ptr %30, align 8, !tbaa !11
  %114 = load i64, ptr %30, align 8, !tbaa !11
  %115 = and i64 %114, 9223372036854775807
  %116 = getelementptr inbounds [4 x i64], ptr %8, i64 0, i64 3
  store i64 %115, ptr %116, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %31) #4
  %117 = getelementptr inbounds [8 x i64], ptr %7, i64 0, i64 0
  store ptr %117, ptr %31, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %32) #4
  %118 = getelementptr inbounds [8 x i64], ptr %7, i64 0, i64 0
  %119 = getelementptr inbounds i64, ptr %118, i64 4
  store ptr %119, ptr %32, align 8, !tbaa !5
  %120 = load ptr, ptr %32, align 8, !tbaa !5
  %121 = getelementptr inbounds i64, ptr %120, i64 0
  store i64 1, ptr %121, align 8, !tbaa !11
  %122 = load ptr, ptr %32, align 8, !tbaa !5
  %123 = getelementptr inbounds i64, ptr %122, i64 1
  store i64 0, ptr %123, align 8, !tbaa !11
  %124 = load ptr, ptr %32, align 8, !tbaa !5
  %125 = getelementptr inbounds i64, ptr %124, i64 2
  store i64 0, ptr %125, align 8, !tbaa !11
  %126 = load ptr, ptr %32, align 8, !tbaa !5
  %127 = getelementptr inbounds i64, ptr %126, i64 3
  store i64 0, ptr %127, align 8, !tbaa !11
  %128 = getelementptr inbounds [4 x i64], ptr %8, i64 0, i64 0
  %129 = load i64, ptr %128, align 16, !tbaa !11
  %130 = load ptr, ptr %31, align 8, !tbaa !5
  %131 = getelementptr inbounds i64, ptr %130, i64 0
  store i64 %129, ptr %131, align 8, !tbaa !11
  %132 = getelementptr inbounds [4 x i64], ptr %8, i64 0, i64 1
  %133 = load i64, ptr %132, align 8, !tbaa !11
  %134 = load ptr, ptr %31, align 8, !tbaa !5
  %135 = getelementptr inbounds i64, ptr %134, i64 1
  store i64 %133, ptr %135, align 8, !tbaa !11
  %136 = getelementptr inbounds [4 x i64], ptr %8, i64 0, i64 2
  %137 = load i64, ptr %136, align 16, !tbaa !11
  %138 = load ptr, ptr %31, align 8, !tbaa !5
  %139 = getelementptr inbounds i64, ptr %138, i64 2
  store i64 %137, ptr %139, align 8, !tbaa !11
  %140 = getelementptr inbounds [4 x i64], ptr %8, i64 0, i64 3
  %141 = load i64, ptr %140, align 8, !tbaa !11
  %142 = load ptr, ptr %31, align 8, !tbaa !5
  %143 = getelementptr inbounds i64, ptr %142, i64 3
  store i64 %141, ptr %143, align 8, !tbaa !11
  %144 = getelementptr inbounds [8 x i64], ptr %7, i64 0, i64 0
  %145 = load ptr, ptr %5, align 8, !tbaa !5
  %146 = getelementptr inbounds [8 x i64], ptr %7, i64 0, i64 0
  call void @montgomery_ladder(ptr noundef %144, ptr noundef %145, ptr noundef %146)
  %147 = load ptr, ptr %4, align 8, !tbaa !5
  %148 = getelementptr inbounds [8 x i64], ptr %7, i64 0, i64 0
  call void @encode_point(ptr noundef %147, ptr noundef %148)
  call void @llvm.lifetime.end.p0(i64 8, ptr %32) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %31) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %30) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %7) #4
  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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @__uint64_identity(i64 noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @load64(ptr noundef) #3

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

; Function Attrs: nounwind uwtable
declare hidden void @montgomery_ladder(ptr noundef, ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @encode_point(ptr noundef, ptr noundef) #0

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !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: nounwind uwtable
define dso_local void @Hacl_Curve25519_64_scalarmult(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca [8 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %4) #4
  %5 = tail call i64 @load64(ptr noundef %2)
  %6 = tail call i64 @__uint64_identity(i64 noundef %5)
  %7 = getelementptr inbounds i8, ptr %2, i64 8
  %8 = tail call i64 @load64(ptr noundef nonnull %7)
  %9 = tail call i64 @__uint64_identity(i64 noundef %8)
  %10 = getelementptr inbounds i8, ptr %2, i64 16
  %11 = tail call i64 @load64(ptr noundef nonnull %10)
  %12 = tail call i64 @__uint64_identity(i64 noundef %11)
  %13 = getelementptr inbounds i8, ptr %2, i64 24
  %14 = tail call i64 @load64(ptr noundef nonnull %13)
  %15 = tail call i64 @__uint64_identity(i64 noundef %14)
  %16 = and i64 %15, 9223372036854775807
  %17 = getelementptr inbounds i8, ptr %4, i64 32
  store i64 1, ptr %17, align 16, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %4, i64 40
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %18, i8 0, i64 24, i1 false)
  store i64 %6, ptr %4, align 16, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %9, ptr %19, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %4, i64 16
  store i64 %12, ptr %20, align 16, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %4, i64 24
  store i64 %16, ptr %21, align 8, !tbaa !5
  call void @montgomery_ladder(ptr noundef nonnull %4, ptr noundef %1, ptr noundef nonnull %4)
  call void @encode_point(ptr noundef %0, ptr noundef nonnull %4)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %4) #4
  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: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @__uint64_identity(i64 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @load64(ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
declare hidden void @montgomery_ladder(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @encode_point(ptr noundef, ptr noundef) local_unnamed_addr #0

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


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass