; LLVM IR from sca-secure-library-sca25519/sca25519 :: cw/sca25519_cw_st (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"

@__const.test_curve25519_static_once.correct_res = external hidden unnamed_addr constant [32 x i8], 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: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

declare i32 @crypto_scalarmult_base_curve25519(ptr noundef) #2

; 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_curve25519_static_once() #3 {
  %1 = alloca [32 x i8], align 16
  %2 = alloca [32 x i8], align 16
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 32, ptr %1) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr %2) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %2, ptr align 16 @__const.test_curve25519_static_once.correct_res, i64 32, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store volatile i32 0, ptr %4, align 4, !tbaa !5
  %5 = getelementptr inbounds [32 x i8], ptr %1, i64 0, i64 0
  %6 = call i32 @crypto_scalarmult_base_curve25519(ptr noundef %5)
  %7 = load volatile i32, ptr %4, align 4, !tbaa !5
  %8 = or i32 %7, %6
  store volatile i32 %8, ptr %4, align 4, !tbaa !5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %28, %0
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = icmp slt i32 %10, 32
  br i1 %11, label %12, label %31

12:                                               ; preds = %9
  %13 = load i32, ptr %3, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [32 x i8], ptr %1, i64 0, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !9
  %17 = zext i8 %16 to i32
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [32 x i8], ptr %2, i64 0, i64 %19
  %21 = load i8, ptr %20, align 1, !tbaa !9
  %22 = zext i8 %21 to i32
  %23 = icmp ne i32 %17, %22
  br i1 %23, label %24, label %27

24:                                               ; preds = %12
  %25 = load volatile i32, ptr %4, align 4, !tbaa !5
  %26 = or i32 %25, 1
  store volatile i32 %26, ptr %4, align 4, !tbaa !5
  br label %31

27:                                               ; preds = %12
  br label %28

28:                                               ; preds = %27
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %3, align 4, !tbaa !5
  br label %9, !llvm.loop !10

31:                                               ; preds = %24, %9
  %32 = load volatile i32, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %1) #4
  ret i32 %32
}

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


; 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.test_curve25519_static_once.correct_res = external hidden unnamed_addr constant [32 x i8], align 16

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

declare i32 @crypto_scalarmult_base_curve25519(ptr noundef) local_unnamed_addr #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
define dso_local i32 @test_curve25519_static_once() local_unnamed_addr #2 {
  %1 = alloca [32 x i8], align 16
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2)
  store volatile i32 0, ptr %2, align 4, !tbaa !5
  %3 = call i32 @crypto_scalarmult_base_curve25519(ptr noundef nonnull %1) #3
  %.0..0..0..0. = load volatile i32, ptr %2, align 4, !tbaa !5
  %4 = or i32 %.0..0..0..0., %3
  store volatile i32 %4, ptr %2, align 4, !tbaa !5
  %5 = load i8, ptr %1, align 16, !tbaa !9
  %6 = load i8, ptr @__const.test_curve25519_static_once.correct_res, align 16, !tbaa !9
  %.not = icmp eq i8 %5, %6
  br i1 %.not, label %7, label %131

7:                                                ; preds = %0
  %8 = getelementptr inbounds i8, ptr %1, i64 1
  %9 = load i8, ptr %8, align 1, !tbaa !9
  %10 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 1), align 1, !tbaa !9
  %.not.1 = icmp eq i8 %9, %10
  br i1 %.not.1, label %11, label %131

11:                                               ; preds = %7
  %12 = getelementptr inbounds i8, ptr %1, i64 2
  %13 = load i8, ptr %12, align 2, !tbaa !9
  %14 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 2), align 2, !tbaa !9
  %.not.2 = icmp eq i8 %13, %14
  br i1 %.not.2, label %15, label %131

15:                                               ; preds = %11
  %16 = getelementptr inbounds i8, ptr %1, i64 3
  %17 = load i8, ptr %16, align 1, !tbaa !9
  %18 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 3), align 1, !tbaa !9
  %.not.3 = icmp eq i8 %17, %18
  br i1 %.not.3, label %19, label %131

19:                                               ; preds = %15
  %20 = getelementptr inbounds i8, ptr %1, i64 4
  %21 = load i8, ptr %20, align 4, !tbaa !9
  %22 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 4), align 4, !tbaa !9
  %.not.4 = icmp eq i8 %21, %22
  br i1 %.not.4, label %23, label %131

23:                                               ; preds = %19
  %24 = getelementptr inbounds i8, ptr %1, i64 5
  %25 = load i8, ptr %24, align 1, !tbaa !9
  %26 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 5), align 1, !tbaa !9
  %.not.5 = icmp eq i8 %25, %26
  br i1 %.not.5, label %27, label %131

27:                                               ; preds = %23
  %28 = getelementptr inbounds i8, ptr %1, i64 6
  %29 = load i8, ptr %28, align 2, !tbaa !9
  %30 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 6), align 2, !tbaa !9
  %.not.6 = icmp eq i8 %29, %30
  br i1 %.not.6, label %31, label %131

31:                                               ; preds = %27
  %32 = getelementptr inbounds i8, ptr %1, i64 7
  %33 = load i8, ptr %32, align 1, !tbaa !9
  %34 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 7), align 1, !tbaa !9
  %.not.7 = icmp eq i8 %33, %34
  br i1 %.not.7, label %35, label %131

35:                                               ; preds = %31
  %36 = getelementptr inbounds i8, ptr %1, i64 8
  %37 = load i8, ptr %36, align 8, !tbaa !9
  %38 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 8), align 8, !tbaa !9
  %.not.8 = icmp eq i8 %37, %38
  br i1 %.not.8, label %39, label %131

39:                                               ; preds = %35
  %40 = getelementptr inbounds i8, ptr %1, i64 9
  %41 = load i8, ptr %40, align 1, !tbaa !9
  %42 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 9), align 1, !tbaa !9
  %.not.9 = icmp eq i8 %41, %42
  br i1 %.not.9, label %43, label %131

43:                                               ; preds = %39
  %44 = getelementptr inbounds i8, ptr %1, i64 10
  %45 = load i8, ptr %44, align 2, !tbaa !9
  %46 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 10), align 2, !tbaa !9
  %.not.10 = icmp eq i8 %45, %46
  br i1 %.not.10, label %47, label %131

47:                                               ; preds = %43
  %48 = getelementptr inbounds i8, ptr %1, i64 11
  %49 = load i8, ptr %48, align 1, !tbaa !9
  %50 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 11), align 1, !tbaa !9
  %.not.11 = icmp eq i8 %49, %50
  br i1 %.not.11, label %51, label %131

51:                                               ; preds = %47
  %52 = getelementptr inbounds i8, ptr %1, i64 12
  %53 = load i8, ptr %52, align 4, !tbaa !9
  %54 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 12), align 4, !tbaa !9
  %.not.12 = icmp eq i8 %53, %54
  br i1 %.not.12, label %55, label %131

55:                                               ; preds = %51
  %56 = getelementptr inbounds i8, ptr %1, i64 13
  %57 = load i8, ptr %56, align 1, !tbaa !9
  %58 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 13), align 1, !tbaa !9
  %.not.13 = icmp eq i8 %57, %58
  br i1 %.not.13, label %59, label %131

59:                                               ; preds = %55
  %60 = getelementptr inbounds i8, ptr %1, i64 14
  %61 = load i8, ptr %60, align 2, !tbaa !9
  %62 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 14), align 2, !tbaa !9
  %.not.14 = icmp eq i8 %61, %62
  br i1 %.not.14, label %63, label %131

63:                                               ; preds = %59
  %64 = getelementptr inbounds i8, ptr %1, i64 15
  %65 = load i8, ptr %64, align 1, !tbaa !9
  %66 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 15), align 1, !tbaa !9
  %.not.15 = icmp eq i8 %65, %66
  br i1 %.not.15, label %67, label %131

67:                                               ; preds = %63
  %68 = getelementptr inbounds i8, ptr %1, i64 16
  %69 = load i8, ptr %68, align 16, !tbaa !9
  %70 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 16), align 16, !tbaa !9
  %.not.16 = icmp eq i8 %69, %70
  br i1 %.not.16, label %71, label %131

71:                                               ; preds = %67
  %72 = getelementptr inbounds i8, ptr %1, i64 17
  %73 = load i8, ptr %72, align 1, !tbaa !9
  %74 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 17), align 1, !tbaa !9
  %.not.17 = icmp eq i8 %73, %74
  br i1 %.not.17, label %75, label %131

75:                                               ; preds = %71
  %76 = getelementptr inbounds i8, ptr %1, i64 18
  %77 = load i8, ptr %76, align 2, !tbaa !9
  %78 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 18), align 2, !tbaa !9
  %.not.18 = icmp eq i8 %77, %78
  br i1 %.not.18, label %79, label %131

79:                                               ; preds = %75
  %80 = getelementptr inbounds i8, ptr %1, i64 19
  %81 = load i8, ptr %80, align 1, !tbaa !9
  %82 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 19), align 1, !tbaa !9
  %.not.19 = icmp eq i8 %81, %82
  br i1 %.not.19, label %83, label %131

83:                                               ; preds = %79
  %84 = getelementptr inbounds i8, ptr %1, i64 20
  %85 = load i8, ptr %84, align 4, !tbaa !9
  %86 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 20), align 4, !tbaa !9
  %.not.20 = icmp eq i8 %85, %86
  br i1 %.not.20, label %87, label %131

87:                                               ; preds = %83
  %88 = getelementptr inbounds i8, ptr %1, i64 21
  %89 = load i8, ptr %88, align 1, !tbaa !9
  %90 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 21), align 1, !tbaa !9
  %.not.21 = icmp eq i8 %89, %90
  br i1 %.not.21, label %91, label %131

91:                                               ; preds = %87
  %92 = getelementptr inbounds i8, ptr %1, i64 22
  %93 = load i8, ptr %92, align 2, !tbaa !9
  %94 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 22), align 2, !tbaa !9
  %.not.22 = icmp eq i8 %93, %94
  br i1 %.not.22, label %95, label %131

95:                                               ; preds = %91
  %96 = getelementptr inbounds i8, ptr %1, i64 23
  %97 = load i8, ptr %96, align 1, !tbaa !9
  %98 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 23), align 1, !tbaa !9
  %.not.23 = icmp eq i8 %97, %98
  br i1 %.not.23, label %99, label %131

99:                                               ; preds = %95
  %100 = getelementptr inbounds i8, ptr %1, i64 24
  %101 = load i8, ptr %100, align 8, !tbaa !9
  %102 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 24), align 8, !tbaa !9
  %.not.24 = icmp eq i8 %101, %102
  br i1 %.not.24, label %103, label %131

103:                                              ; preds = %99
  %104 = getelementptr inbounds i8, ptr %1, i64 25
  %105 = load i8, ptr %104, align 1, !tbaa !9
  %106 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 25), align 1, !tbaa !9
  %.not.25 = icmp eq i8 %105, %106
  br i1 %.not.25, label %107, label %131

107:                                              ; preds = %103
  %108 = getelementptr inbounds i8, ptr %1, i64 26
  %109 = load i8, ptr %108, align 2, !tbaa !9
  %110 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 26), align 2, !tbaa !9
  %.not.26 = icmp eq i8 %109, %110
  br i1 %.not.26, label %111, label %131

111:                                              ; preds = %107
  %112 = getelementptr inbounds i8, ptr %1, i64 27
  %113 = load i8, ptr %112, align 1, !tbaa !9
  %114 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 27), align 1, !tbaa !9
  %.not.27 = icmp eq i8 %113, %114
  br i1 %.not.27, label %115, label %131

115:                                              ; preds = %111
  %116 = getelementptr inbounds i8, ptr %1, i64 28
  %117 = load i8, ptr %116, align 4, !tbaa !9
  %118 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 28), align 4, !tbaa !9
  %.not.28 = icmp eq i8 %117, %118
  br i1 %.not.28, label %119, label %131

119:                                              ; preds = %115
  %120 = getelementptr inbounds i8, ptr %1, i64 29
  %121 = load i8, ptr %120, align 1, !tbaa !9
  %122 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 29), align 1, !tbaa !9
  %.not.29 = icmp eq i8 %121, %122
  br i1 %.not.29, label %123, label %131

123:                                              ; preds = %119
  %124 = getelementptr inbounds i8, ptr %1, i64 30
  %125 = load i8, ptr %124, align 2, !tbaa !9
  %126 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 30), align 2, !tbaa !9
  %.not.30 = icmp eq i8 %125, %126
  br i1 %.not.30, label %127, label %131

127:                                              ; preds = %123
  %128 = getelementptr inbounds i8, ptr %1, i64 31
  %129 = load i8, ptr %128, align 1, !tbaa !9
  %130 = load i8, ptr getelementptr inbounds (i8, ptr @__const.test_curve25519_static_once.correct_res, i64 31), align 1, !tbaa !9
  %.not.31 = icmp eq i8 %129, %130
  br i1 %.not.31, label %.loopexit, label %131

131:                                              ; preds = %127, %123, %119, %115, %111, %107, %103, %99, %95, %91, %87, %83, %79, %75, %71, %67, %63, %59, %55, %51, %47, %43, %39, %35, %31, %27, %23, %19, %15, %11, %7, %0
  %.0..0..0..0.1 = load volatile i32, ptr %2, align 4, !tbaa !5
  %132 = or i32 %.0..0..0..0.1, 1
  store volatile i32 %132, ptr %2, align 4, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %127, %131
  %.0..0..0..0.2 = load volatile i32, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2)
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #3
  ret i32 %.0..0..0..0.2
}

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass