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

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

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

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @Hacl_Curve25519_51_ecdh(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca [32 x i8], align 16
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca i8, align 1
  %12 = alloca i8, align 1
  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 32, ptr %7) #4
  call void @llvm.memset.p0.i64(ptr align 16 %7, i8 0, i64 32, i1 false)
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  call void @Hacl_Curve25519_51_scalarmult(ptr noundef %13, ptr noundef %14, ptr noundef %15)
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #4
  store i8 -1, ptr %8, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !10
  br label %16

16:                                               ; preds = %37, %3
  %17 = load i32, ptr %9, align 4, !tbaa !10
  %18 = icmp ult i32 %17, 32
  br i1 %18, label %20, label %19

19:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %40

20:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #4
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = load i32, ptr %9, align 4, !tbaa !10
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds i8, ptr %21, i64 %23
  %25 = load i8, ptr %24, align 1, !tbaa !9
  %26 = load i32, ptr %9, align 4, !tbaa !10
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds [32 x i8], ptr %7, i64 0, i64 %27
  %29 = load i8, ptr %28, align 1, !tbaa !9
  %30 = call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %25, i8 noundef zeroext %29)
  store i8 %30, ptr %10, align 1, !tbaa !9
  %31 = load i8, ptr %10, align 1, !tbaa !9
  %32 = zext i8 %31 to i32
  %33 = load i8, ptr %8, align 1, !tbaa !9
  %34 = zext i8 %33 to i32
  %35 = and i32 %32, %34
  %36 = trunc i32 %35 to i8
  store i8 %36, ptr %8, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  br label %37

37:                                               ; preds = %20
  %38 = load i32, ptr %9, align 4, !tbaa !10
  %39 = add i32 %38, 1
  store i32 %39, ptr %9, align 4, !tbaa !10
  br label %16, !llvm.loop !12

40:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #4
  %41 = load i8, ptr %8, align 1, !tbaa !9
  store i8 %41, ptr %11, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #4
  %42 = load i8, ptr %11, align 1, !tbaa !9
  %43 = zext i8 %42 to i32
  %44 = icmp eq i32 %43, 255
  %45 = zext i1 %44 to i8
  store i8 %45, ptr %12, align 1, !tbaa !14
  %46 = load i8, ptr %12, align 1, !tbaa !14, !range !16, !noundef !17
  %47 = trunc i8 %46 to i1
  %48 = xor i1 %47, true
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %7) #4
  ret i1 %48
}

; Function Attrs: noinline nounwind uwtable
declare hidden zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext, i8 noundef zeroext) #3

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 = { noinline 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !15, i64 0}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{i8 0, i8 2}
!17 = !{}


; 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
declare dso_local void @Hacl_Curve25519_51_scalarmult(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @Hacl_Curve25519_51_ecdh(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  tail call void @Hacl_Curve25519_51_scalarmult(ptr noundef %0, ptr noundef %1, ptr noundef %2)
  %4 = load i8, ptr %0, align 1, !tbaa !5
  %5 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %4, i8 noundef zeroext 0)
  %6 = getelementptr inbounds i8, ptr %0, i64 1
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %8 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %7, i8 noundef zeroext 0)
  %9 = and i8 %8, %5
  %10 = getelementptr inbounds i8, ptr %0, i64 2
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %12 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %11, i8 noundef zeroext 0)
  %13 = and i8 %12, %9
  %14 = getelementptr inbounds i8, ptr %0, i64 3
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %16 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %15, i8 noundef zeroext 0)
  %17 = and i8 %16, %13
  %18 = getelementptr inbounds i8, ptr %0, i64 4
  %19 = load i8, ptr %18, align 1, !tbaa !5
  %20 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %19, i8 noundef zeroext 0)
  %21 = and i8 %20, %17
  %22 = getelementptr inbounds i8, ptr %0, i64 5
  %23 = load i8, ptr %22, align 1, !tbaa !5
  %24 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %23, i8 noundef zeroext 0)
  %25 = and i8 %24, %21
  %26 = getelementptr inbounds i8, ptr %0, i64 6
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %28 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %27, i8 noundef zeroext 0)
  %29 = and i8 %28, %25
  %30 = getelementptr inbounds i8, ptr %0, i64 7
  %31 = load i8, ptr %30, align 1, !tbaa !5
  %32 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %31, i8 noundef zeroext 0)
  %33 = and i8 %32, %29
  %34 = getelementptr inbounds i8, ptr %0, i64 8
  %35 = load i8, ptr %34, align 1, !tbaa !5
  %36 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %35, i8 noundef zeroext 0)
  %37 = and i8 %36, %33
  %38 = getelementptr inbounds i8, ptr %0, i64 9
  %39 = load i8, ptr %38, align 1, !tbaa !5
  %40 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %39, i8 noundef zeroext 0)
  %41 = and i8 %40, %37
  %42 = getelementptr inbounds i8, ptr %0, i64 10
  %43 = load i8, ptr %42, align 1, !tbaa !5
  %44 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %43, i8 noundef zeroext 0)
  %45 = and i8 %44, %41
  %46 = getelementptr inbounds i8, ptr %0, i64 11
  %47 = load i8, ptr %46, align 1, !tbaa !5
  %48 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %47, i8 noundef zeroext 0)
  %49 = and i8 %48, %45
  %50 = getelementptr inbounds i8, ptr %0, i64 12
  %51 = load i8, ptr %50, align 1, !tbaa !5
  %52 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %51, i8 noundef zeroext 0)
  %53 = and i8 %52, %49
  %54 = getelementptr inbounds i8, ptr %0, i64 13
  %55 = load i8, ptr %54, align 1, !tbaa !5
  %56 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %55, i8 noundef zeroext 0)
  %57 = and i8 %56, %53
  %58 = getelementptr inbounds i8, ptr %0, i64 14
  %59 = load i8, ptr %58, align 1, !tbaa !5
  %60 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %59, i8 noundef zeroext 0)
  %61 = and i8 %60, %57
  %62 = getelementptr inbounds i8, ptr %0, i64 15
  %63 = load i8, ptr %62, align 1, !tbaa !5
  %64 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %63, i8 noundef zeroext 0)
  %65 = and i8 %64, %61
  %66 = getelementptr inbounds i8, ptr %0, i64 16
  %67 = load i8, ptr %66, align 1, !tbaa !5
  %68 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %67, i8 noundef zeroext 0)
  %69 = and i8 %68, %65
  %70 = getelementptr inbounds i8, ptr %0, i64 17
  %71 = load i8, ptr %70, align 1, !tbaa !5
  %72 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %71, i8 noundef zeroext 0)
  %73 = and i8 %72, %69
  %74 = getelementptr inbounds i8, ptr %0, i64 18
  %75 = load i8, ptr %74, align 1, !tbaa !5
  %76 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %75, i8 noundef zeroext 0)
  %77 = and i8 %76, %73
  %78 = getelementptr inbounds i8, ptr %0, i64 19
  %79 = load i8, ptr %78, align 1, !tbaa !5
  %80 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %79, i8 noundef zeroext 0)
  %81 = and i8 %80, %77
  %82 = getelementptr inbounds i8, ptr %0, i64 20
  %83 = load i8, ptr %82, align 1, !tbaa !5
  %84 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %83, i8 noundef zeroext 0)
  %85 = and i8 %84, %81
  %86 = getelementptr inbounds i8, ptr %0, i64 21
  %87 = load i8, ptr %86, align 1, !tbaa !5
  %88 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %87, i8 noundef zeroext 0)
  %89 = and i8 %88, %85
  %90 = getelementptr inbounds i8, ptr %0, i64 22
  %91 = load i8, ptr %90, align 1, !tbaa !5
  %92 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %91, i8 noundef zeroext 0)
  %93 = and i8 %92, %89
  %94 = getelementptr inbounds i8, ptr %0, i64 23
  %95 = load i8, ptr %94, align 1, !tbaa !5
  %96 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %95, i8 noundef zeroext 0)
  %97 = and i8 %96, %93
  %98 = getelementptr inbounds i8, ptr %0, i64 24
  %99 = load i8, ptr %98, align 1, !tbaa !5
  %100 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %99, i8 noundef zeroext 0)
  %101 = and i8 %100, %97
  %102 = getelementptr inbounds i8, ptr %0, i64 25
  %103 = load i8, ptr %102, align 1, !tbaa !5
  %104 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %103, i8 noundef zeroext 0)
  %105 = and i8 %104, %101
  %106 = getelementptr inbounds i8, ptr %0, i64 26
  %107 = load i8, ptr %106, align 1, !tbaa !5
  %108 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %107, i8 noundef zeroext 0)
  %109 = and i8 %108, %105
  %110 = getelementptr inbounds i8, ptr %0, i64 27
  %111 = load i8, ptr %110, align 1, !tbaa !5
  %112 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %111, i8 noundef zeroext 0)
  %113 = and i8 %112, %109
  %114 = getelementptr inbounds i8, ptr %0, i64 28
  %115 = load i8, ptr %114, align 1, !tbaa !5
  %116 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %115, i8 noundef zeroext 0)
  %117 = and i8 %116, %113
  %118 = getelementptr inbounds i8, ptr %0, i64 29
  %119 = load i8, ptr %118, align 1, !tbaa !5
  %120 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %119, i8 noundef zeroext 0)
  %121 = and i8 %120, %117
  %122 = getelementptr inbounds i8, ptr %0, i64 30
  %123 = load i8, ptr %122, align 1, !tbaa !5
  %124 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %123, i8 noundef zeroext 0)
  %125 = and i8 %124, %121
  %126 = getelementptr inbounds i8, ptr %0, i64 31
  %127 = load i8, ptr %126, align 1, !tbaa !5
  %128 = tail call zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext %127, i8 noundef zeroext 0)
  %129 = and i8 %128, %125
  %130 = icmp ne i8 %129, -1
  ret i1 %130
}

; Function Attrs: noinline nounwind uwtable
declare hidden zeroext i8 @FStar_UInt8_eq_mask(i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #1

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 = { noinline 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" }

!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/C++ TBAA"}


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