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

; 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 zeroext i1 @Hacl_Impl_P256_DH_ecp256dh_i(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [16 x i64], align 16
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca [4 x i64], align 16
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  %20 = alloca ptr, align 8
  %21 = alloca i64, align 8
  %22 = alloca i64, align 8
  %23 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 128, ptr %5) #4
  call void @llvm.memset.p0.i64(ptr align 16 %5, i8 0, i64 128, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %24 = getelementptr inbounds [16 x i64], ptr %5, i64 0, i64 0
  store ptr %24, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %25 = getelementptr inbounds [16 x i64], ptr %5, i64 0, i64 0
  %26 = getelementptr inbounds i64, ptr %25, i64 4
  store ptr %26, ptr %7, align 8, !tbaa !5
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  call void @bn_from_bytes_be4(ptr noundef %27, ptr noundef %28)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = call i64 @bn_is_lt_order_and_gt_zero_mask4(ptr noundef %29)
  store i64 %30, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #4
  call void @llvm.memset.p0.i64(ptr align 16 %9, i8 0, i64 32, i1 false)
  %31 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 0
  store i64 1, ptr %31, align 16, !tbaa !9
  %32 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 1
  store i64 0, ptr %32, align 8, !tbaa !9
  %33 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 2
  store i64 0, ptr %33, align 16, !tbaa !9
  %34 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 3
  store i64 0, ptr %34, align 8, !tbaa !9
  br label %35

35:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %36, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %37 = load i32, ptr %10, align 4, !tbaa !11
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !9
  store i64 %40, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %41 = load i64, ptr %12, align 8, !tbaa !9
  %42 = load i64, ptr %8, align 8, !tbaa !9
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load i32, ptr %10, align 4, !tbaa !11
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds i64, ptr %43, i64 %45
  %47 = load i64, ptr %46, align 8, !tbaa !9
  %48 = load i64, ptr %12, align 8, !tbaa !9
  %49 = xor i64 %47, %48
  %50 = and i64 %42, %49
  %51 = xor i64 %41, %50
  store i64 %51, ptr %13, align 8, !tbaa !9
  %52 = load i64, ptr %13, align 8, !tbaa !9
  %53 = load ptr, ptr %11, align 8, !tbaa !5
  %54 = load i32, ptr %10, align 4, !tbaa !11
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds i64, ptr %53, i64 %55
  store i64 %52, ptr %56, align 8, !tbaa !9
  %57 = load i32, ptr %10, align 4, !tbaa !11
  %58 = add i32 %57, 1
  store i32 %58, ptr %10, align 4, !tbaa !11
  %59 = load i32, ptr %10, align 4, !tbaa !11
  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.start.p0(i64 8, ptr %14) #4
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %60, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %61 = load i32, ptr %10, align 4, !tbaa !11
  %62 = zext i32 %61 to i64
  %63 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 %62
  %64 = load i64, ptr %63, align 8, !tbaa !9
  store i64 %64, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %65 = load i64, ptr %15, align 8, !tbaa !9
  %66 = load i64, ptr %8, align 8, !tbaa !9
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = load i32, ptr %10, align 4, !tbaa !11
  %69 = zext i32 %68 to i64
  %70 = getelementptr inbounds i64, ptr %67, i64 %69
  %71 = load i64, ptr %70, align 8, !tbaa !9
  %72 = load i64, ptr %15, align 8, !tbaa !9
  %73 = xor i64 %71, %72
  %74 = and i64 %66, %73
  %75 = xor i64 %65, %74
  store i64 %75, ptr %16, align 8, !tbaa !9
  %76 = load i64, ptr %16, align 8, !tbaa !9
  %77 = load ptr, ptr %14, align 8, !tbaa !5
  %78 = load i32, ptr %10, align 4, !tbaa !11
  %79 = zext i32 %78 to i64
  %80 = getelementptr inbounds i64, ptr %77, i64 %79
  store i64 %76, ptr %80, align 8, !tbaa !9
  %81 = load i32, ptr %10, align 4, !tbaa !11
  %82 = add i32 %81, 1
  store i32 %82, ptr %10, align 4, !tbaa !11
  %83 = load i32, ptr %10, align 4, !tbaa !11
  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.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %84, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %85 = load i32, ptr %10, align 4, !tbaa !11
  %86 = zext i32 %85 to i64
  %87 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 %86
  %88 = load i64, ptr %87, align 8, !tbaa !9
  store i64 %88, ptr %18, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %89 = load i64, ptr %18, align 8, !tbaa !9
  %90 = load i64, ptr %8, align 8, !tbaa !9
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = load i32, ptr %10, align 4, !tbaa !11
  %93 = zext i32 %92 to i64
  %94 = getelementptr inbounds i64, ptr %91, i64 %93
  %95 = load i64, ptr %94, align 8, !tbaa !9
  %96 = load i64, ptr %18, align 8, !tbaa !9
  %97 = xor i64 %95, %96
  %98 = and i64 %90, %97
  %99 = xor i64 %89, %98
  store i64 %99, ptr %19, align 8, !tbaa !9
  %100 = load i64, ptr %19, align 8, !tbaa !9
  %101 = load ptr, ptr %17, align 8, !tbaa !5
  %102 = load i32, ptr %10, align 4, !tbaa !11
  %103 = zext i32 %102 to i64
  %104 = getelementptr inbounds i64, ptr %101, i64 %103
  store i64 %100, ptr %104, align 8, !tbaa !9
  %105 = load i32, ptr %10, align 4, !tbaa !11
  %106 = add i32 %105, 1
  store i32 %106, ptr %10, align 4, !tbaa !11
  %107 = load i32, ptr %10, align 4, !tbaa !11
  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.start.p0(i64 8, ptr %20) #4
  %108 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %108, ptr %20, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  %109 = load i32, ptr %10, align 4, !tbaa !11
  %110 = zext i32 %109 to i64
  %111 = getelementptr inbounds [4 x i64], ptr %9, i64 0, i64 %110
  %112 = load i64, ptr %111, align 8, !tbaa !9
  store i64 %112, ptr %21, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  %113 = load i64, ptr %21, align 8, !tbaa !9
  %114 = load i64, ptr %8, align 8, !tbaa !9
  %115 = load ptr, ptr %6, align 8, !tbaa !5
  %116 = load i32, ptr %10, align 4, !tbaa !11
  %117 = zext i32 %116 to i64
  %118 = getelementptr inbounds i64, ptr %115, i64 %117
  %119 = load i64, ptr %118, align 8, !tbaa !9
  %120 = load i64, ptr %21, align 8, !tbaa !9
  %121 = xor i64 %119, %120
  %122 = and i64 %114, %121
  %123 = xor i64 %113, %122
  store i64 %123, ptr %22, align 8, !tbaa !9
  %124 = load i64, ptr %22, align 8, !tbaa !9
  %125 = load ptr, ptr %20, align 8, !tbaa !5
  %126 = load i32, ptr %10, align 4, !tbaa !11
  %127 = zext i32 %126 to i64
  %128 = getelementptr inbounds i64, ptr %125, i64 %127
  store i64 %124, ptr %128, align 8, !tbaa !9
  %129 = load i32, ptr %10, align 4, !tbaa !11
  %130 = add i32 %129, 1
  store i32 %130, ptr %10, align 4, !tbaa !11
  %131 = load i32, ptr %10, align 4, !tbaa !11
  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.end.p0(i64 4, ptr %10) #4
  br label %132

132:                                              ; preds = %35
  br label %133

133:                                              ; preds = %132
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #4
  %134 = load i64, ptr %8, align 8, !tbaa !9
  store i64 %134, ptr %23, align 8, !tbaa !9
  %135 = load ptr, ptr %7, align 8, !tbaa !5
  %136 = load ptr, ptr %6, align 8, !tbaa !5
  call void @point_mul_g(ptr noundef %135, ptr noundef %136)
  %137 = load ptr, ptr %3, align 8, !tbaa !5
  %138 = load ptr, ptr %7, align 8, !tbaa !5
  call void @point_store(ptr noundef %137, ptr noundef %138)
  %139 = load i64, ptr %23, align 8, !tbaa !9
  %140 = icmp eq i64 %139, -1
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 128, ptr %5) #4
  ret i1 %140
}

; 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 void @bn_from_bytes_be4(ptr noundef, ptr noundef) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @bn_is_lt_order_and_gt_zero_mask4(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: inlinehint nounwind uwtable
declare hidden void @point_mul_g(ptr noundef, ptr noundef) #3

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

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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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 zeroext i1 @Hacl_Impl_P256_DH_ecp256dh_i(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca [16 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %3) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(128) %3, i8 0, i64 128, i1 false)
  %4 = getelementptr inbounds i8, ptr %3, i64 32
  call void @bn_from_bytes_be4(ptr noundef nonnull %3, ptr noundef %1)
  %5 = call i64 @bn_is_lt_order_and_gt_zero_mask4(ptr noundef nonnull %3)
  %6 = load i64, ptr %3, align 16, !tbaa !5
  %7 = xor i64 %6, 1
  %8 = and i64 %7, %5
  %9 = xor i64 %8, 1
  store i64 %9, ptr %3, align 16, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %3, i64 8
  %11 = load <2 x i64>, ptr %10, align 8, !tbaa !5
  %12 = insertelement <2 x i64> poison, i64 %5, i64 0
  %13 = shufflevector <2 x i64> %12, <2 x i64> poison, <2 x i32> zeroinitializer
  %14 = and <2 x i64> %11, %13
  store <2 x i64> %14, ptr %10, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %3, i64 24
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %17 = and i64 %16, %5
  store i64 %17, ptr %15, align 8, !tbaa !5
  call void @point_mul_g(ptr noundef nonnull %4, ptr noundef nonnull %3)
  call void @point_store(ptr noundef %0, ptr noundef nonnull %4)
  %18 = icmp eq i64 %5, -1
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %3) #4
  ret i1 %18
}

; 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 void @bn_from_bytes_be4(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @bn_is_lt_order_and_gt_zero_mask4(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: inlinehint nounwind uwtable
declare hidden void @point_mul_g(ptr noundef, ptr noundef) local_unnamed_addr #3

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

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: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass