; LLVM IR from philanc/luazen :: src/mono (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_abstract = type { ptr, [96 x i8], [32 x i8] }
%struct.crypto_sign_vtable = type { ptr, ptr, ptr, ptr, 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 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_abstract, 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_abstract, 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_abstract, 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_abstract, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.crypto_sign_vtable, ptr %23, i32 0, i32 3
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds [64 x i8], ptr %8, i64 0, i64 0
  call void %25(ptr noundef %26, ptr noundef %27)
  %28 = getelementptr inbounds [64 x i8], ptr %8, i64 0, i64 0
  call void @reduce(ptr noundef %28)
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  store i64 0, ptr %9, align 8, !tbaa !14
  br label %29

29:                                               ; preds = %41, %2
  %30 = load i64, ptr %9, align 8, !tbaa !14
  %31 = icmp ult i64 %30, 32
  br i1 %31, label %33, label %32

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

33:                                               ; preds = %29
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load i64, ptr %9, align 8, !tbaa !14
  %36 = getelementptr inbounds i8, ptr %34, i64 %35
  %37 = load i8, ptr %36, align 1, !tbaa !15
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = load i64, ptr %9, align 8, !tbaa !14
  %40 = getelementptr inbounds i8, ptr %38, i64 %39
  store i8 %37, ptr %40, align 1, !tbaa !15
  br label %41

41:                                               ; preds = %33
  %42 = load i64, ptr %9, align 8, !tbaa !14
  %43 = add i64 %42, 1
  store i64 %43, ptr %9, align 8, !tbaa !14
  br label %29, !llvm.loop !16

44:                                               ; preds = %32
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %45, i64 32
  %47 = getelementptr inbounds [64 x i8], ptr %8, i64 0, i64 0
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  call void @mul_add(ptr noundef %46, ptr noundef %47, ptr noundef %48, ptr noundef %49)
  %50 = getelementptr inbounds [64 x i8], ptr %8, i64 0, i64 0
  call void @crypto_wipe(ptr noundef %50, i64 noundef 64)
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.crypto_sign_ctx_abstract, ptr %52, i32 0, i32 0
  %54 = load ptr, ptr %53, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.crypto_sign_vtable, ptr %54, i32 0, i32 4
  %56 = load i64, ptr %55, align 8, !tbaa !18
  call void @crypto_wipe(ptr noundef %51, i64 noundef %56)
  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, !6, i64 0}
!10 = !{!"", !6, i64 0, !7, i64 8, !7, i64 104}
!11 = !{!12, !6, i64 24}
!12 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32}
!13 = !{!"long", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!12, !13, i64 32}


; 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 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 72
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %3) #2
  %5 = load ptr, ptr %0, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 24
  %7 = load ptr, ptr %6, align 8, !tbaa !10
  call void %7(ptr noundef nonnull %0, ptr noundef nonnull %3) #2
  call void @reduce(ptr noundef nonnull %3)
  %8 = load i8, ptr %4, align 1, !tbaa !13
  store i8 %8, ptr %1, align 1, !tbaa !13
  %9 = getelementptr i8, ptr %0, i64 73
  %10 = load i8, ptr %9, align 1, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %1, i64 1
  store i8 %10, ptr %11, align 1, !tbaa !13
  %12 = getelementptr i8, ptr %0, i64 74
  %13 = load i8, ptr %12, align 1, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %1, i64 2
  store i8 %13, ptr %14, align 1, !tbaa !13
  %15 = getelementptr i8, ptr %0, i64 75
  %16 = load i8, ptr %15, align 1, !tbaa !13
  %17 = getelementptr inbounds i8, ptr %1, i64 3
  store i8 %16, ptr %17, align 1, !tbaa !13
  %18 = getelementptr i8, ptr %0, i64 76
  %19 = load i8, ptr %18, align 1, !tbaa !13
  %20 = getelementptr inbounds i8, ptr %1, i64 4
  store i8 %19, ptr %20, align 1, !tbaa !13
  %21 = getelementptr i8, ptr %0, i64 77
  %22 = load i8, ptr %21, align 1, !tbaa !13
  %23 = getelementptr inbounds i8, ptr %1, i64 5
  store i8 %22, ptr %23, align 1, !tbaa !13
  %24 = getelementptr i8, ptr %0, i64 78
  %25 = load i8, ptr %24, align 1, !tbaa !13
  %26 = getelementptr inbounds i8, ptr %1, i64 6
  store i8 %25, ptr %26, align 1, !tbaa !13
  %27 = getelementptr i8, ptr %0, i64 79
  %28 = load i8, ptr %27, align 1, !tbaa !13
  %29 = getelementptr inbounds i8, ptr %1, i64 7
  store i8 %28, ptr %29, align 1, !tbaa !13
  %30 = getelementptr i8, ptr %0, i64 80
  %31 = load i8, ptr %30, align 1, !tbaa !13
  %32 = getelementptr inbounds i8, ptr %1, i64 8
  store i8 %31, ptr %32, align 1, !tbaa !13
  %33 = getelementptr i8, ptr %0, i64 81
  %34 = load i8, ptr %33, align 1, !tbaa !13
  %35 = getelementptr inbounds i8, ptr %1, i64 9
  store i8 %34, ptr %35, align 1, !tbaa !13
  %36 = getelementptr i8, ptr %0, i64 82
  %37 = load i8, ptr %36, align 1, !tbaa !13
  %38 = getelementptr inbounds i8, ptr %1, i64 10
  store i8 %37, ptr %38, align 1, !tbaa !13
  %39 = getelementptr i8, ptr %0, i64 83
  %40 = load i8, ptr %39, align 1, !tbaa !13
  %41 = getelementptr inbounds i8, ptr %1, i64 11
  store i8 %40, ptr %41, align 1, !tbaa !13
  %42 = getelementptr i8, ptr %0, i64 84
  %43 = load i8, ptr %42, align 1, !tbaa !13
  %44 = getelementptr inbounds i8, ptr %1, i64 12
  store i8 %43, ptr %44, align 1, !tbaa !13
  %45 = getelementptr i8, ptr %0, i64 85
  %46 = load i8, ptr %45, align 1, !tbaa !13
  %47 = getelementptr inbounds i8, ptr %1, i64 13
  store i8 %46, ptr %47, align 1, !tbaa !13
  %48 = getelementptr i8, ptr %0, i64 86
  %49 = load i8, ptr %48, align 1, !tbaa !13
  %50 = getelementptr inbounds i8, ptr %1, i64 14
  store i8 %49, ptr %50, align 1, !tbaa !13
  %51 = getelementptr i8, ptr %0, i64 87
  %52 = load i8, ptr %51, align 1, !tbaa !13
  %53 = getelementptr inbounds i8, ptr %1, i64 15
  store i8 %52, ptr %53, align 1, !tbaa !13
  %54 = getelementptr i8, ptr %0, i64 88
  %55 = load i8, ptr %54, align 1, !tbaa !13
  %56 = getelementptr inbounds i8, ptr %1, i64 16
  store i8 %55, ptr %56, align 1, !tbaa !13
  %57 = getelementptr i8, ptr %0, i64 89
  %58 = load i8, ptr %57, align 1, !tbaa !13
  %59 = getelementptr inbounds i8, ptr %1, i64 17
  store i8 %58, ptr %59, align 1, !tbaa !13
  %60 = getelementptr i8, ptr %0, i64 90
  %61 = load i8, ptr %60, align 1, !tbaa !13
  %62 = getelementptr inbounds i8, ptr %1, i64 18
  store i8 %61, ptr %62, align 1, !tbaa !13
  %63 = getelementptr i8, ptr %0, i64 91
  %64 = load i8, ptr %63, align 1, !tbaa !13
  %65 = getelementptr inbounds i8, ptr %1, i64 19
  store i8 %64, ptr %65, align 1, !tbaa !13
  %66 = getelementptr i8, ptr %0, i64 92
  %67 = load i8, ptr %66, align 1, !tbaa !13
  %68 = getelementptr inbounds i8, ptr %1, i64 20
  store i8 %67, ptr %68, align 1, !tbaa !13
  %69 = getelementptr i8, ptr %0, i64 93
  %70 = load i8, ptr %69, align 1, !tbaa !13
  %71 = getelementptr inbounds i8, ptr %1, i64 21
  store i8 %70, ptr %71, align 1, !tbaa !13
  %72 = getelementptr i8, ptr %0, i64 94
  %73 = load i8, ptr %72, align 1, !tbaa !13
  %74 = getelementptr inbounds i8, ptr %1, i64 22
  store i8 %73, ptr %74, align 1, !tbaa !13
  %75 = getelementptr i8, ptr %0, i64 95
  %76 = load i8, ptr %75, align 1, !tbaa !13
  %77 = getelementptr inbounds i8, ptr %1, i64 23
  store i8 %76, ptr %77, align 1, !tbaa !13
  %78 = getelementptr i8, ptr %0, i64 96
  %79 = load i8, ptr %78, align 1, !tbaa !13
  %80 = getelementptr inbounds i8, ptr %1, i64 24
  store i8 %79, ptr %80, align 1, !tbaa !13
  %81 = getelementptr i8, ptr %0, i64 97
  %82 = load i8, ptr %81, align 1, !tbaa !13
  %83 = getelementptr inbounds i8, ptr %1, i64 25
  store i8 %82, ptr %83, align 1, !tbaa !13
  %84 = getelementptr i8, ptr %0, i64 98
  %85 = load i8, ptr %84, align 1, !tbaa !13
  %86 = getelementptr inbounds i8, ptr %1, i64 26
  store i8 %85, ptr %86, align 1, !tbaa !13
  %87 = getelementptr i8, ptr %0, i64 99
  %88 = load i8, ptr %87, align 1, !tbaa !13
  %89 = getelementptr inbounds i8, ptr %1, i64 27
  store i8 %88, ptr %89, align 1, !tbaa !13
  %90 = getelementptr i8, ptr %0, i64 100
  %91 = load i8, ptr %90, align 1, !tbaa !13
  %92 = getelementptr inbounds i8, ptr %1, i64 28
  store i8 %91, ptr %92, align 1, !tbaa !13
  %93 = getelementptr i8, ptr %0, i64 101
  %94 = load i8, ptr %93, align 1, !tbaa !13
  %95 = getelementptr inbounds i8, ptr %1, i64 29
  store i8 %94, ptr %95, align 1, !tbaa !13
  %96 = getelementptr i8, ptr %0, i64 102
  %97 = load i8, ptr %96, align 1, !tbaa !13
  %98 = getelementptr inbounds i8, ptr %1, i64 30
  store i8 %97, ptr %98, align 1, !tbaa !13
  %99 = getelementptr i8, ptr %0, i64 103
  %100 = load i8, ptr %99, align 1, !tbaa !13
  %101 = getelementptr inbounds i8, ptr %1, i64 31
  store i8 %100, ptr %101, align 1, !tbaa !13
  %102 = getelementptr inbounds i8, ptr %0, i64 8
  %103 = getelementptr inbounds i8, ptr %0, i64 40
  %104 = getelementptr inbounds i8, ptr %1, i64 32
  call void @mul_add(ptr noundef nonnull %104, ptr noundef nonnull %3, ptr noundef nonnull %102, ptr noundef nonnull %103)
  call void @crypto_wipe(ptr noundef nonnull %3, i64 noundef 64)
  %105 = load ptr, ptr %0, align 8, !tbaa !5
  %106 = getelementptr inbounds i8, ptr %105, i64 32
  %107 = load i64, ptr %106, align 8, !tbaa !14
  call void @crypto_wipe(ptr noundef nonnull %0, i64 noundef %107)
  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, !7, i64 0}
!6 = !{!"", !7, i64 0, !8, i64 8, !8, i64 104}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!11, !7, i64 24}
!11 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !12, i64 32}
!12 = !{!"long", !8, i64 0}
!13 = !{!8, !8, i64 0}
!14 = !{!11, !12, i64 32}


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