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

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

@__const.Hacl_K256_ECDSA_secret_to_public.oneq = external hidden unnamed_addr constant [4 x i64], align 16

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @Hacl_Impl_K256_Point_point_store(ptr noundef, ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @load_qelem_check(ptr noundef, ptr noundef) #4

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @Hacl_K256_ECDSA_secret_to_public(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [19 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 152, ptr %5) #5
  call void @llvm.memset.p0.i64(ptr align 16 %5, i8 0, i64 152, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %24 = getelementptr inbounds [19 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) #5
  %25 = getelementptr inbounds [19 x i64], ptr %5, i64 0, i64 0
  %26 = getelementptr inbounds i64, ptr %25, i64 15
  store ptr %26, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = call i64 @load_qelem_check(ptr noundef %27, ptr noundef %28)
  store i64 %29, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %9, ptr align 16 @__const.Hacl_K256_ECDSA_secret_to_public.oneq, i64 32, i1 false)
  br label %30

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

127:                                              ; preds = %30
  br label %128

128:                                              ; preds = %127
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #5
  %129 = load i64, ptr %8, align 8, !tbaa !9
  store i64 %129, ptr %23, align 8, !tbaa !9
  %130 = load ptr, ptr %6, align 8, !tbaa !5
  %131 = load ptr, ptr %7, align 8, !tbaa !5
  call void @point_mul_g(ptr noundef %130, ptr noundef %131)
  %132 = load ptr, ptr %3, align 8, !tbaa !5
  %133 = load ptr, ptr %6, align 8, !tbaa !5
  call void @Hacl_Impl_K256_Point_point_store(ptr noundef %132, ptr noundef %133)
  %134 = load i64, ptr %23, align 8, !tbaa !9
  %135 = icmp eq i64 %134, -1
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 152, ptr %5) #5
  ret i1 %135
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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"

@__const.Hacl_K256_ECDSA_secret_to_public.oneq = external hidden unnamed_addr constant [4 x i64], align 16

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @Hacl_Impl_K256_Point_point_store(ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @Hacl_K256_ECDSA_secret_to_public(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca [19 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 152, ptr nonnull %3) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(152) %3, i8 0, i64 152, i1 false)
  %4 = getelementptr inbounds i8, ptr %3, i64 120
  %5 = call i64 @load_qelem_check(ptr noundef nonnull %4, ptr noundef %1)
  %6 = load <2 x i64>, ptr @__const.Hacl_K256_ECDSA_secret_to_public.oneq, align 16, !tbaa !5
  %7 = load <2 x i64>, ptr %4, align 8, !tbaa !5
  %8 = xor <2 x i64> %7, %6
  %9 = insertelement <2 x i64> poison, i64 %5, i64 0
  %10 = shufflevector <2 x i64> %9, <2 x i64> poison, <2 x i32> zeroinitializer
  %11 = and <2 x i64> %8, %10
  %12 = xor <2 x i64> %11, %6
  store <2 x i64> %12, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %3, i64 136
  %14 = load <2 x i64>, ptr getelementptr inbounds (i8, ptr @__const.Hacl_K256_ECDSA_secret_to_public.oneq, i64 16), align 16, !tbaa !5
  %15 = load <2 x i64>, ptr %13, align 8, !tbaa !5
  %16 = xor <2 x i64> %15, %14
  %17 = and <2 x i64> %16, %10
  %18 = xor <2 x i64> %17, %14
  store <2 x i64> %18, ptr %13, align 8, !tbaa !5
  call void @point_mul_g(ptr noundef nonnull %3, ptr noundef nonnull %4)
  call void @Hacl_Impl_K256_Point_point_store(ptr noundef %0, ptr noundef nonnull %3)
  %19 = icmp eq i64 %5, -1
  call void @llvm.lifetime.end.p0(i64 152, ptr nonnull %3) #4
  ret i1 %19
}

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