; LLVM IR from LoupVaillant/Monocypher-Utils :: src (monocypher)

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

%struct.crypto_sign_ctx = type { %struct.crypto_blake2b_ctx, [96 x i8], [32 x i8] }
%struct.crypto_blake2b_ctx = type { [8 x i64], [2 x i64], [16 x i64], i64, i64 }

; Function Attrs: nounwind uwtable
declare dso_local void @crypto_wipe(ptr noundef, i64 noundef) #0

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

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

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

; Function Attrs: nounwind uwtable
declare hidden void @reduce(ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @crypto_sign_final(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca [64 x i8], align 16
  %9 = 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 8, ptr %5) #2
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.crypto_sign_ctx, ptr %10, i32 0, i32 1
  %12 = getelementptr inbounds [96 x i8], ptr %11, i64 0, i64 0
  store ptr %12, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.crypto_sign_ctx, ptr %13, i32 0, i32 1
  %15 = getelementptr inbounds [96 x i8], ptr %14, i64 0, i64 0
  %16 = getelementptr inbounds i8, ptr %15, i64 32
  store ptr %16, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.crypto_sign_ctx, ptr %17, i32 0, i32 1
  %19 = getelementptr inbounds [96 x i8], ptr %18, i64 0, i64 0
  %20 = getelementptr inbounds i8, ptr %19, i64 64
  store ptr %20, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr %8) #2
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.crypto_sign_ctx, ptr %21, i32 0, i32 0
  %23 = getelementptr inbounds [64 x i8], ptr %8, i64 0, i64 0
  call void @crypto_blake2b_final(ptr noundef %22, ptr noundef %23)
  %24 = getelementptr inbounds [64 x i8], ptr %8, i64 0, i64 0
  call void @reduce(ptr noundef %24)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %25

25:                                               ; preds = %37, %2
  %26 = load i64, ptr %9, align 8, !tbaa !9
  %27 = icmp ult i64 %26, 32
  br i1 %27, label %29, label %28

28:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  br label %40

29:                                               ; preds = %25
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = load i64, ptr %9, align 8, !tbaa !9
  %32 = getelementptr inbounds i8, ptr %30, i64 %31
  %33 = load i8, ptr %32, align 1, !tbaa !11
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = load i64, ptr %9, align 8, !tbaa !9
  %36 = getelementptr inbounds i8, ptr %34, i64 %35
  store i8 %33, ptr %36, align 1, !tbaa !11
  br label %37

37:                                               ; preds = %29
  %38 = load i64, ptr %9, align 8, !tbaa !9
  %39 = add i64 %38, 1
  store i64 %39, ptr %9, align 8, !tbaa !9
  br label %25, !llvm.loop !12

40:                                               ; preds = %28
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %41, i64 32
  %43 = getelementptr inbounds [64 x i8], ptr %8, i64 0, i64 0
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  call void @mul_add(ptr noundef %42, ptr noundef %43, ptr noundef %44, ptr noundef %45)
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  call void @crypto_wipe(ptr noundef %46, i64 noundef 352)
  %47 = getelementptr inbounds [64 x i8], ptr %8, i64 0, i64 0
  call void @crypto_wipe(ptr noundef %47, i64 noundef 64)
  call void @llvm.lifetime.end.p0(i64 64, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @mul_add(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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
declare dso_local void @crypto_wipe(ptr noundef, i64 noundef) local_unnamed_addr #0

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @crypto_sign_final(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca [64 x i8], align 16
  %4 = getelementptr i8, ptr %0, i64 288
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %3) #2
  call void @crypto_blake2b_final(ptr noundef %0, ptr noundef nonnull %3)
  call void @reduce(ptr noundef nonnull %3)
  %5 = load i8, ptr %4, align 1, !tbaa !5
  store i8 %5, ptr %1, align 1, !tbaa !5
  %6 = getelementptr i8, ptr %0, i64 289
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %1, i64 1
  store i8 %7, ptr %8, align 1, !tbaa !5
  %9 = getelementptr i8, ptr %0, i64 290
  %10 = load i8, ptr %9, align 1, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %1, i64 2
  store i8 %10, ptr %11, align 1, !tbaa !5
  %12 = getelementptr i8, ptr %0, i64 291
  %13 = load i8, ptr %12, align 1, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %1, i64 3
  store i8 %13, ptr %14, align 1, !tbaa !5
  %15 = getelementptr i8, ptr %0, i64 292
  %16 = load i8, ptr %15, align 1, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %1, i64 4
  store i8 %16, ptr %17, align 1, !tbaa !5
  %18 = getelementptr i8, ptr %0, i64 293
  %19 = load i8, ptr %18, align 1, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %1, i64 5
  store i8 %19, ptr %20, align 1, !tbaa !5
  %21 = getelementptr i8, ptr %0, i64 294
  %22 = load i8, ptr %21, align 1, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %1, i64 6
  store i8 %22, ptr %23, align 1, !tbaa !5
  %24 = getelementptr i8, ptr %0, i64 295
  %25 = load i8, ptr %24, align 1, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %1, i64 7
  store i8 %25, ptr %26, align 1, !tbaa !5
  %27 = getelementptr i8, ptr %0, i64 296
  %28 = load i8, ptr %27, align 1, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %1, i64 8
  store i8 %28, ptr %29, align 1, !tbaa !5
  %30 = getelementptr i8, ptr %0, i64 297
  %31 = load i8, ptr %30, align 1, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %1, i64 9
  store i8 %31, ptr %32, align 1, !tbaa !5
  %33 = getelementptr i8, ptr %0, i64 298
  %34 = load i8, ptr %33, align 1, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %1, i64 10
  store i8 %34, ptr %35, align 1, !tbaa !5
  %36 = getelementptr i8, ptr %0, i64 299
  %37 = load i8, ptr %36, align 1, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %1, i64 11
  store i8 %37, ptr %38, align 1, !tbaa !5
  %39 = getelementptr i8, ptr %0, i64 300
  %40 = load i8, ptr %39, align 1, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %1, i64 12
  store i8 %40, ptr %41, align 1, !tbaa !5
  %42 = getelementptr i8, ptr %0, i64 301
  %43 = load i8, ptr %42, align 1, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %1, i64 13
  store i8 %43, ptr %44, align 1, !tbaa !5
  %45 = getelementptr i8, ptr %0, i64 302
  %46 = load i8, ptr %45, align 1, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %1, i64 14
  store i8 %46, ptr %47, align 1, !tbaa !5
  %48 = getelementptr i8, ptr %0, i64 303
  %49 = load i8, ptr %48, align 1, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %1, i64 15
  store i8 %49, ptr %50, align 1, !tbaa !5
  %51 = getelementptr i8, ptr %0, i64 304
  %52 = load i8, ptr %51, align 1, !tbaa !5
  %53 = getelementptr inbounds i8, ptr %1, i64 16
  store i8 %52, ptr %53, align 1, !tbaa !5
  %54 = getelementptr i8, ptr %0, i64 305
  %55 = load i8, ptr %54, align 1, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %1, i64 17
  store i8 %55, ptr %56, align 1, !tbaa !5
  %57 = getelementptr i8, ptr %0, i64 306
  %58 = load i8, ptr %57, align 1, !tbaa !5
  %59 = getelementptr inbounds i8, ptr %1, i64 18
  store i8 %58, ptr %59, align 1, !tbaa !5
  %60 = getelementptr i8, ptr %0, i64 307
  %61 = load i8, ptr %60, align 1, !tbaa !5
  %62 = getelementptr inbounds i8, ptr %1, i64 19
  store i8 %61, ptr %62, align 1, !tbaa !5
  %63 = getelementptr i8, ptr %0, i64 308
  %64 = load i8, ptr %63, align 1, !tbaa !5
  %65 = getelementptr inbounds i8, ptr %1, i64 20
  store i8 %64, ptr %65, align 1, !tbaa !5
  %66 = getelementptr i8, ptr %0, i64 309
  %67 = load i8, ptr %66, align 1, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %1, i64 21
  store i8 %67, ptr %68, align 1, !tbaa !5
  %69 = getelementptr i8, ptr %0, i64 310
  %70 = load i8, ptr %69, align 1, !tbaa !5
  %71 = getelementptr inbounds i8, ptr %1, i64 22
  store i8 %70, ptr %71, align 1, !tbaa !5
  %72 = getelementptr i8, ptr %0, i64 311
  %73 = load i8, ptr %72, align 1, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %1, i64 23
  store i8 %73, ptr %74, align 1, !tbaa !5
  %75 = getelementptr i8, ptr %0, i64 312
  %76 = load i8, ptr %75, align 1, !tbaa !5
  %77 = getelementptr inbounds i8, ptr %1, i64 24
  store i8 %76, ptr %77, align 1, !tbaa !5
  %78 = getelementptr i8, ptr %0, i64 313
  %79 = load i8, ptr %78, align 1, !tbaa !5
  %80 = getelementptr inbounds i8, ptr %1, i64 25
  store i8 %79, ptr %80, align 1, !tbaa !5
  %81 = getelementptr i8, ptr %0, i64 314
  %82 = load i8, ptr %81, align 1, !tbaa !5
  %83 = getelementptr inbounds i8, ptr %1, i64 26
  store i8 %82, ptr %83, align 1, !tbaa !5
  %84 = getelementptr i8, ptr %0, i64 315
  %85 = load i8, ptr %84, align 1, !tbaa !5
  %86 = getelementptr inbounds i8, ptr %1, i64 27
  store i8 %85, ptr %86, align 1, !tbaa !5
  %87 = getelementptr i8, ptr %0, i64 316
  %88 = load i8, ptr %87, align 1, !tbaa !5
  %89 = getelementptr inbounds i8, ptr %1, i64 28
  store i8 %88, ptr %89, align 1, !tbaa !5
  %90 = getelementptr i8, ptr %0, i64 317
  %91 = load i8, ptr %90, align 1, !tbaa !5
  %92 = getelementptr inbounds i8, ptr %1, i64 29
  store i8 %91, ptr %92, align 1, !tbaa !5
  %93 = getelementptr i8, ptr %0, i64 318
  %94 = load i8, ptr %93, align 1, !tbaa !5
  %95 = getelementptr inbounds i8, ptr %1, i64 30
  store i8 %94, ptr %95, align 1, !tbaa !5
  %96 = getelementptr i8, ptr %0, i64 319
  %97 = load i8, ptr %96, align 1, !tbaa !5
  %98 = getelementptr inbounds i8, ptr %1, i64 31
  store i8 %97, ptr %98, align 1, !tbaa !5
  %99 = getelementptr inbounds i8, ptr %0, i64 224
  %100 = getelementptr inbounds i8, ptr %0, i64 256
  %101 = getelementptr inbounds i8, ptr %1, i64 32
  call void @mul_add(ptr noundef nonnull %101, ptr noundef nonnull %3, ptr noundef nonnull %99, ptr noundef nonnull %100)
  call void @crypto_wipe(ptr noundef %0, i64 noundef 352)
  call void @crypto_wipe(ptr noundef nonnull %3, i64 noundef 64)
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %3) #2
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden void @mul_add(ptr noundef, ptr noundef, ptr noundef, 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" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


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