; LLVM IR from sca-secure-library-sca25519/sca25519 :: STM32F407-ephemeral/crypto/numerics (fe25519)

; 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 void @fe25519_pack(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  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 1, ptr %5) #2
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  call void @fe25519_reduceCompletely(ptr noundef %6)
  store i8 0, ptr %5, align 1, !tbaa !9
  br label %7

7:                                                ; preds = %21, %2
  %8 = load i8, ptr %5, align 1, !tbaa !9
  %9 = zext i8 %8 to i32
  %10 = icmp slt i32 %9, 32
  br i1 %10, label %11, label %24

11:                                               ; preds = %7
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = load i8, ptr %5, align 1, !tbaa !9
  %14 = zext i8 %13 to i64
  %15 = getelementptr inbounds [32 x i8], ptr %12, i64 0, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !9
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = load i8, ptr %5, align 1, !tbaa !9
  %19 = zext i8 %18 to i64
  %20 = getelementptr inbounds i8, ptr %17, i64 %19
  store i8 %16, ptr %20, align 1, !tbaa !9
  br label %21

21:                                               ; preds = %11
  %22 = load i8, ptr %5, align 1, !tbaa !9
  %23 = add i8 %22, 1
  store i8 %23, ptr %5, align 1, !tbaa !9
  br label %7, !llvm.loop !10

24:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #2
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @fe25519_reduceCompletely(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @fe25519_pack(ptr nocapture noundef writeonly %0, ptr noundef %1) local_unnamed_addr #0 {
  tail call void @fe25519_reduceCompletely(ptr noundef %1)
  %3 = load i8, ptr %1, align 1, !tbaa !5
  store i8 %3, ptr %0, align 1, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 1
  %5 = load i8, ptr %4, align 1, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 1
  store i8 %5, ptr %6, align 1, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 2
  %8 = load i8, ptr %7, align 1, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 2
  store i8 %8, ptr %9, align 1, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %1, i64 3
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 3
  store i8 %11, ptr %12, align 1, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %1, i64 4
  %14 = load i8, ptr %13, align 1, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 4
  store i8 %14, ptr %15, align 1, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %1, i64 5
  %17 = load i8, ptr %16, align 1, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %0, i64 5
  store i8 %17, ptr %18, align 1, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %1, i64 6
  %20 = load i8, ptr %19, align 1, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %0, i64 6
  store i8 %20, ptr %21, align 1, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %1, i64 7
  %23 = load i8, ptr %22, align 1, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %0, i64 7
  store i8 %23, ptr %24, align 1, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %1, i64 8
  %26 = load i8, ptr %25, align 1, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %0, i64 8
  store i8 %26, ptr %27, align 1, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %1, i64 9
  %29 = load i8, ptr %28, align 1, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %0, i64 9
  store i8 %29, ptr %30, align 1, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %1, i64 10
  %32 = load i8, ptr %31, align 1, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %0, i64 10
  store i8 %32, ptr %33, align 1, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %1, i64 11
  %35 = load i8, ptr %34, align 1, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %0, i64 11
  store i8 %35, ptr %36, align 1, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %1, i64 12
  %38 = load i8, ptr %37, align 1, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %0, i64 12
  store i8 %38, ptr %39, align 1, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %1, i64 13
  %41 = load i8, ptr %40, align 1, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %0, i64 13
  store i8 %41, ptr %42, align 1, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %1, i64 14
  %44 = load i8, ptr %43, align 1, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %0, i64 14
  store i8 %44, ptr %45, align 1, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %1, i64 15
  %47 = load i8, ptr %46, align 1, !tbaa !5
  %48 = getelementptr inbounds i8, ptr %0, i64 15
  store i8 %47, ptr %48, align 1, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %1, i64 16
  %50 = load i8, ptr %49, align 1, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %0, i64 16
  store i8 %50, ptr %51, align 1, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %1, i64 17
  %53 = load i8, ptr %52, align 1, !tbaa !5
  %54 = getelementptr inbounds i8, ptr %0, i64 17
  store i8 %53, ptr %54, align 1, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %1, i64 18
  %56 = load i8, ptr %55, align 1, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %0, i64 18
  store i8 %56, ptr %57, align 1, !tbaa !5
  %58 = getelementptr inbounds i8, ptr %1, i64 19
  %59 = load i8, ptr %58, align 1, !tbaa !5
  %60 = getelementptr inbounds i8, ptr %0, i64 19
  store i8 %59, ptr %60, align 1, !tbaa !5
  %61 = getelementptr inbounds i8, ptr %1, i64 20
  %62 = load i8, ptr %61, align 1, !tbaa !5
  %63 = getelementptr inbounds i8, ptr %0, i64 20
  store i8 %62, ptr %63, align 1, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %1, i64 21
  %65 = load i8, ptr %64, align 1, !tbaa !5
  %66 = getelementptr inbounds i8, ptr %0, i64 21
  store i8 %65, ptr %66, align 1, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %1, i64 22
  %68 = load i8, ptr %67, align 1, !tbaa !5
  %69 = getelementptr inbounds i8, ptr %0, i64 22
  store i8 %68, ptr %69, align 1, !tbaa !5
  %70 = getelementptr inbounds i8, ptr %1, i64 23
  %71 = load i8, ptr %70, align 1, !tbaa !5
  %72 = getelementptr inbounds i8, ptr %0, i64 23
  store i8 %71, ptr %72, align 1, !tbaa !5
  %73 = getelementptr inbounds i8, ptr %1, i64 24
  %74 = load i8, ptr %73, align 1, !tbaa !5
  %75 = getelementptr inbounds i8, ptr %0, i64 24
  store i8 %74, ptr %75, align 1, !tbaa !5
  %76 = getelementptr inbounds i8, ptr %1, i64 25
  %77 = load i8, ptr %76, align 1, !tbaa !5
  %78 = getelementptr inbounds i8, ptr %0, i64 25
  store i8 %77, ptr %78, align 1, !tbaa !5
  %79 = getelementptr inbounds i8, ptr %1, i64 26
  %80 = load i8, ptr %79, align 1, !tbaa !5
  %81 = getelementptr inbounds i8, ptr %0, i64 26
  store i8 %80, ptr %81, align 1, !tbaa !5
  %82 = getelementptr inbounds i8, ptr %1, i64 27
  %83 = load i8, ptr %82, align 1, !tbaa !5
  %84 = getelementptr inbounds i8, ptr %0, i64 27
  store i8 %83, ptr %84, align 1, !tbaa !5
  %85 = getelementptr inbounds i8, ptr %1, i64 28
  %86 = load i8, ptr %85, align 1, !tbaa !5
  %87 = getelementptr inbounds i8, ptr %0, i64 28
  store i8 %86, ptr %87, align 1, !tbaa !5
  %88 = getelementptr inbounds i8, ptr %1, i64 29
  %89 = load i8, ptr %88, align 1, !tbaa !5
  %90 = getelementptr inbounds i8, ptr %0, i64 29
  store i8 %89, ptr %90, align 1, !tbaa !5
  %91 = getelementptr inbounds i8, ptr %1, i64 30
  %92 = load i8, ptr %91, align 1, !tbaa !5
  %93 = getelementptr inbounds i8, ptr %0, i64 30
  store i8 %92, ptr %93, align 1, !tbaa !5
  %94 = getelementptr inbounds i8, ptr %1, i64 31
  %95 = load i8, ptr %94, align 1, !tbaa !5
  %96 = getelementptr inbounds i8, ptr %0, i64 31
  store i8 %95, ptr %96, align 1, !tbaa !5
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @fe25519_reduceCompletely(ptr noundef) local_unnamed_addr #0

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

!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,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass