; LLVM IR from sca-secure-library-sca25519/sca25519 :: STM32F407-static (test)

; 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: nounwind uwtable
define dso_local i32 @test_point() #1 {
  %1 = alloca [32 x i8], align 16
  %2 = alloca [32 x i8], align 16
  %3 = alloca [32 x i8], align 16
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 32, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %46, %0
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = icmp slt i32 %9, 10
  br i1 %10, label %11, label %49

11:                                               ; preds = %8
  call void @randombytes(ptr noundef %1, i64 noundef 32)
  %12 = getelementptr inbounds [32 x i8], ptr %2, i64 0, i64 0
  %13 = getelementptr inbounds [32 x i8], ptr %1, i64 0, i64 0
  %14 = call i32 @crypto_scalarmult_curve25519(ptr noundef %12, ptr noundef %13)
  store i32 %14, ptr %7, align 4, !tbaa !5
  %15 = getelementptr inbounds [32 x i8], ptr %3, i64 0, i64 0
  %16 = getelementptr inbounds [32 x i8], ptr %1, i64 0, i64 0
  %17 = call i32 @crypto_scalarmult_curve25519(ptr noundef %15, ptr noundef %16)
  %18 = load i32, ptr %7, align 4, !tbaa !5
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %11
  br label %46

21:                                               ; preds = %11
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %42, %21
  %23 = load i32, ptr %5, align 4, !tbaa !5
  %24 = icmp slt i32 %23, 32
  br i1 %24, label %25, label %45

25:                                               ; preds = %22
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [32 x i8], ptr %2, i64 0, i64 %27
  %29 = load i8, ptr %28, align 1, !tbaa !9
  %30 = zext i8 %29 to i32
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [32 x i8], ptr %3, i64 0, i64 %32
  %34 = load i8, ptr %33, align 1, !tbaa !9
  %35 = zext i8 %34 to i32
  %36 = icmp ne i32 %30, %35
  br i1 %36, label %37, label %41

37:                                               ; preds = %25
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = load i32, ptr %6, align 4, !tbaa !5
  %40 = or i32 %39, %38
  store i32 %40, ptr %6, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %37, %25
  br label %42

42:                                               ; preds = %41
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %5, align 4, !tbaa !5
  br label %22, !llvm.loop !10

45:                                               ; preds = %22
  br label %46

46:                                               ; preds = %45, %20
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %4, align 4, !tbaa !5
  br label %8, !llvm.loop !12

49:                                               ; preds = %8
  %50 = load i32, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %1) #3
  ret i32 %50
}

declare void @randombytes(ptr noundef, i64 noundef) #2

declare i32 @crypto_scalarmult_curve25519(ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


; 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: 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 nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @test_point() local_unnamed_addr #1 {
.loopexit:
  %0 = alloca [32 x i8], align 16
  %1 = alloca [32 x i8], align 16
  %2 = alloca [32 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %0) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #3
  call void @randombytes(ptr noundef nonnull %0, i64 noundef 32) #3
  %3 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %1, ptr noundef nonnull %0) #3
  %4 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %2, ptr noundef nonnull %0) #3
  %.not = icmp eq i32 %3, 0
  call void @randombytes(ptr noundef nonnull %0, i64 noundef 32) #3
  %5 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %1, ptr noundef nonnull %0) #3
  %6 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %2, ptr noundef nonnull %0) #3
  %.not.1 = icmp eq i32 %5, 0
  br i1 %.not.1, label %.preheader.preheader.1, label %.loopexit.1

.preheader.preheader.1:                           ; preds = %.loopexit
  %7 = load <32 x i8>, ptr %1, align 16, !tbaa !5
  %8 = load <32 x i8>, ptr %2, align 16, !tbaa !5
  %9 = icmp eq <32 x i8> %7, %8
  %10 = freeze <32 x i1> %9
  %11 = bitcast <32 x i1> %10 to i32
  %12 = icmp ne i32 %11, -1
  %13 = zext i1 %12 to i32
  br label %.loopexit.1

.loopexit.1:                                      ; preds = %.preheader.preheader.1, %.loopexit
  %.3.1 = phi i32 [ 0, %.loopexit ], [ %13, %.preheader.preheader.1 ]
  call void @randombytes(ptr noundef nonnull %0, i64 noundef 32) #3
  %14 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %1, ptr noundef nonnull %0) #3
  %15 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %2, ptr noundef nonnull %0) #3
  %.not.2 = icmp eq i32 %14, 0
  br i1 %.not.2, label %.preheader.preheader.2, label %.loopexit.2

.preheader.preheader.2:                           ; preds = %.loopexit.1
  %16 = load <32 x i8>, ptr %1, align 16, !tbaa !5
  %17 = load <32 x i8>, ptr %2, align 16, !tbaa !5
  %18 = icmp eq <32 x i8> %16, %17
  %19 = freeze <32 x i1> %18
  %20 = bitcast <32 x i1> %19 to i32
  %21 = icmp eq i32 %20, -1
  %22 = select i1 %21, i32 0, i32 2
  %spec.select.31.2 = or disjoint i32 %22, %.3.1
  br label %.loopexit.2

.loopexit.2:                                      ; preds = %.preheader.preheader.2, %.loopexit.1
  %.3.2 = phi i32 [ %.3.1, %.loopexit.1 ], [ %spec.select.31.2, %.preheader.preheader.2 ]
  call void @randombytes(ptr noundef nonnull %0, i64 noundef 32) #3
  %23 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %1, ptr noundef nonnull %0) #3
  %24 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %2, ptr noundef nonnull %0) #3
  %.not.3 = icmp eq i32 %23, 0
  br i1 %.not.3, label %.preheader.preheader.3, label %.loopexit.3

.preheader.preheader.3:                           ; preds = %.loopexit.2
  %25 = load <32 x i8>, ptr %1, align 16, !tbaa !5
  %26 = load <32 x i8>, ptr %2, align 16, !tbaa !5
  %27 = icmp eq <32 x i8> %25, %26
  %28 = freeze <32 x i1> %27
  %29 = bitcast <32 x i1> %28 to i32
  %30 = icmp eq i32 %29, -1
  %31 = select i1 %30, i32 0, i32 3
  %spec.select.31.3 = or i32 %31, %.3.2
  br label %.loopexit.3

.loopexit.3:                                      ; preds = %.preheader.preheader.3, %.loopexit.2
  %.3.3 = phi i32 [ %.3.2, %.loopexit.2 ], [ %spec.select.31.3, %.preheader.preheader.3 ]
  call void @randombytes(ptr noundef nonnull %0, i64 noundef 32) #3
  %32 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %1, ptr noundef nonnull %0) #3
  %33 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %2, ptr noundef nonnull %0) #3
  %.not.4 = icmp eq i32 %32, 0
  br i1 %.not.4, label %.preheader.preheader.4, label %.loopexit.4

.preheader.preheader.4:                           ; preds = %.loopexit.3
  %34 = load <32 x i8>, ptr %1, align 16, !tbaa !5
  %35 = load <32 x i8>, ptr %2, align 16, !tbaa !5
  %36 = icmp eq <32 x i8> %34, %35
  %37 = freeze <32 x i1> %36
  %38 = bitcast <32 x i1> %37 to i32
  %39 = icmp eq i32 %38, -1
  %40 = select i1 %39, i32 0, i32 4
  %spec.select.31.4 = or i32 %40, %.3.3
  br label %.loopexit.4

.loopexit.4:                                      ; preds = %.preheader.preheader.4, %.loopexit.3
  %.3.4 = phi i32 [ %.3.3, %.loopexit.3 ], [ %spec.select.31.4, %.preheader.preheader.4 ]
  call void @randombytes(ptr noundef nonnull %0, i64 noundef 32) #3
  %41 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %1, ptr noundef nonnull %0) #3
  %42 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %2, ptr noundef nonnull %0) #3
  %.not.5 = icmp eq i32 %41, 0
  br i1 %.not.5, label %.preheader.preheader.5, label %.loopexit.5

.preheader.preheader.5:                           ; preds = %.loopexit.4
  %43 = load <32 x i8>, ptr %1, align 16, !tbaa !5
  %44 = load <32 x i8>, ptr %2, align 16, !tbaa !5
  %45 = icmp eq <32 x i8> %43, %44
  %46 = freeze <32 x i1> %45
  %47 = bitcast <32 x i1> %46 to i32
  %48 = icmp eq i32 %47, -1
  %49 = select i1 %48, i32 0, i32 5
  %spec.select.31.5 = or i32 %49, %.3.4
  br label %.loopexit.5

.loopexit.5:                                      ; preds = %.preheader.preheader.5, %.loopexit.4
  %.3.5 = phi i32 [ %.3.4, %.loopexit.4 ], [ %spec.select.31.5, %.preheader.preheader.5 ]
  call void @randombytes(ptr noundef nonnull %0, i64 noundef 32) #3
  %50 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %1, ptr noundef nonnull %0) #3
  %51 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %2, ptr noundef nonnull %0) #3
  %.not.6 = icmp eq i32 %50, 0
  br i1 %.not.6, label %.preheader.preheader.6, label %.loopexit.6

.preheader.preheader.6:                           ; preds = %.loopexit.5
  %52 = load <32 x i8>, ptr %1, align 16, !tbaa !5
  %53 = load <32 x i8>, ptr %2, align 16, !tbaa !5
  %54 = icmp eq <32 x i8> %52, %53
  %55 = freeze <32 x i1> %54
  %56 = bitcast <32 x i1> %55 to i32
  %57 = icmp eq i32 %56, -1
  %58 = select i1 %57, i32 0, i32 6
  %spec.select.31.6 = or i32 %58, %.3.5
  br label %.loopexit.6

.loopexit.6:                                      ; preds = %.preheader.preheader.6, %.loopexit.5
  %.3.6 = phi i32 [ %.3.5, %.loopexit.5 ], [ %spec.select.31.6, %.preheader.preheader.6 ]
  call void @randombytes(ptr noundef nonnull %0, i64 noundef 32) #3
  %59 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %1, ptr noundef nonnull %0) #3
  %60 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %2, ptr noundef nonnull %0) #3
  %.not.7 = icmp eq i32 %59, 0
  br i1 %.not.7, label %.preheader.preheader.7, label %.loopexit.7

.preheader.preheader.7:                           ; preds = %.loopexit.6
  %61 = load <32 x i8>, ptr %1, align 16, !tbaa !5
  %62 = load <32 x i8>, ptr %2, align 16, !tbaa !5
  %63 = icmp eq <32 x i8> %61, %62
  %64 = freeze <32 x i1> %63
  %65 = bitcast <32 x i1> %64 to i32
  %66 = icmp eq i32 %65, -1
  %67 = select i1 %66, i32 0, i32 7
  %spec.select.31.7 = or i32 %67, %.3.6
  br label %.loopexit.7

.loopexit.7:                                      ; preds = %.preheader.preheader.7, %.loopexit.6
  %.3.7 = phi i32 [ %.3.6, %.loopexit.6 ], [ %spec.select.31.7, %.preheader.preheader.7 ]
  call void @randombytes(ptr noundef nonnull %0, i64 noundef 32) #3
  %68 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %1, ptr noundef nonnull %0) #3
  %69 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %2, ptr noundef nonnull %0) #3
  %.not.8 = icmp eq i32 %68, 0
  br i1 %.not.8, label %.preheader.preheader.8, label %.loopexit.8

.preheader.preheader.8:                           ; preds = %.loopexit.7
  %70 = load <32 x i8>, ptr %1, align 16, !tbaa !5
  %71 = load <32 x i8>, ptr %2, align 16, !tbaa !5
  %72 = icmp eq <32 x i8> %70, %71
  %73 = freeze <32 x i1> %72
  %74 = bitcast <32 x i1> %73 to i32
  %75 = icmp eq i32 %74, -1
  %76 = select i1 %75, i32 0, i32 8
  %spec.select.31.8 = or i32 %76, %.3.7
  br label %.loopexit.8

.loopexit.8:                                      ; preds = %.preheader.preheader.8, %.loopexit.7
  %.3.8 = phi i32 [ %.3.7, %.loopexit.7 ], [ %spec.select.31.8, %.preheader.preheader.8 ]
  call void @randombytes(ptr noundef nonnull %0, i64 noundef 32) #3
  %77 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %1, ptr noundef nonnull %0) #3
  %78 = call i32 @crypto_scalarmult_curve25519(ptr noundef nonnull %2, ptr noundef nonnull %0) #3
  %.not.9 = icmp eq i32 %77, 0
  br i1 %.not.9, label %.preheader.preheader.9, label %.loopexit.9

.preheader.preheader.9:                           ; preds = %.loopexit.8
  %79 = load <32 x i8>, ptr %1, align 16, !tbaa !5
  %80 = load <32 x i8>, ptr %2, align 16, !tbaa !5
  %81 = icmp eq <32 x i8> %79, %80
  %82 = freeze <32 x i1> %81
  %83 = bitcast <32 x i1> %82 to i32
  %84 = icmp eq i32 %83, -1
  %85 = select i1 %84, i32 0, i32 9
  %spec.select.31.9 = or i32 %85, %.3.8
  br label %.loopexit.9

.loopexit.9:                                      ; preds = %.preheader.preheader.9, %.loopexit.8
  %.3.9 = phi i32 [ %.3.8, %.loopexit.8 ], [ %spec.select.31.9, %.preheader.preheader.9 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %0) #3
  ret i32 %.3.9
}

declare void @randombytes(ptr noundef, i64 noundef) local_unnamed_addr #2

declare i32 @crypto_scalarmult_curve25519(ptr noundef, ptr noundef) local_unnamed_addr #2

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass