; 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: 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
declare hidden void @trim_scalar(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @crypto_sign_init_first_pass_custom_hash(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %12 = load ptr, ptr %8, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.crypto_sign_ctx_abstract, ptr %13, i32 0, i32 0
  store ptr %12, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.crypto_sign_ctx_abstract, ptr %15, i32 0, i32 1
  %17 = getelementptr inbounds [96 x i8], ptr %16, i64 0, i64 0
  store ptr %17, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.crypto_sign_ctx_abstract, ptr %18, i32 0, i32 1
  %20 = getelementptr inbounds [96 x i8], ptr %19, i64 0, i64 0
  %21 = getelementptr inbounds i8, ptr %20, i64 32
  store ptr %21, ptr %10, align 8, !tbaa !5
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.crypto_sign_ctx_abstract, ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct.crypto_sign_vtable, ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  %27 = load ptr, ptr %9, align 8, !tbaa !5
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  call void %26(ptr noundef %27, ptr noundef %28, i64 noundef 32)
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  call void @trim_scalar(ptr noundef %29)
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = icmp eq ptr %30, null
  br i1 %31, label %32, label %40

32:                                               ; preds = %4
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.crypto_sign_ctx_abstract, ptr %33, i32 0, i32 2
  %35 = getelementptr inbounds [32 x i8], ptr %34, i64 0, i64 0
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.crypto_sign_ctx_abstract, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  call void @crypto_sign_public_key_custom_hash(ptr noundef %35, ptr noundef %36, ptr noundef %39)
  br label %58

40:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  store i64 0, ptr %11, align 8, !tbaa !14
  br label %41

41:                                               ; preds = %54, %40
  %42 = load i64, ptr %11, align 8, !tbaa !14
  %43 = icmp ult i64 %42, 32
  br i1 %43, label %45, label %44

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

45:                                               ; preds = %41
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = load i64, ptr %11, align 8, !tbaa !14
  %48 = getelementptr inbounds i8, ptr %46, i64 %47
  %49 = load i8, ptr %48, align 1, !tbaa !15
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.crypto_sign_ctx_abstract, ptr %50, i32 0, i32 2
  %52 = load i64, ptr %11, align 8, !tbaa !14
  %53 = getelementptr inbounds [32 x i8], ptr %51, i64 0, i64 %52
  store i8 %49, ptr %53, align 1, !tbaa !15
  br label %54

54:                                               ; preds = %45
  %55 = load i64, ptr %11, align 8, !tbaa !14
  %56 = add i64 %55, 1
  store i64 %56, ptr %11, align 8, !tbaa !14
  br label %41, !llvm.loop !16

57:                                               ; preds = %44
  br label %58

58:                                               ; preds = %57, %32
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.crypto_sign_ctx_abstract, ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !9
  %62 = getelementptr inbounds %struct.crypto_sign_vtable, ptr %61, i32 0, i32 1
  %63 = load ptr, ptr %62, align 8, !tbaa !18
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  call void %63(ptr noundef %64)
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.crypto_sign_ctx_abstract, ptr %65, i32 0, i32 0
  %67 = load ptr, ptr %66, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct.crypto_sign_vtable, ptr %67, i32 0, i32 2
  %69 = load ptr, ptr %68, align 8, !tbaa !19
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = load ptr, ptr %10, align 8, !tbaa !5
  call void %69(ptr noundef %70, ptr noundef %71, i64 noundef 32)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  ret void
}

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 = !{!10, !6, i64 0}
!10 = !{!"", !6, i64 0, !7, i64 8, !7, i64 104}
!11 = !{!12, !6, i64 0}
!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, !6, i64 8}
!19 = !{!12, !6, i64 16}


; 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 hidden void @trim_scalar(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @crypto_sign_init_first_pass_custom_hash(ptr noundef %0, ptr noundef %1, ptr noundef readonly %2, ptr noundef %3) local_unnamed_addr #0 {
  store ptr %3, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load ptr, ptr %3, align 8, !tbaa !10
  tail call void %6(ptr noundef nonnull %5, ptr noundef %1, i64 noundef 32) #1
  tail call void @trim_scalar(ptr noundef nonnull %5)
  %7 = icmp eq ptr %2, null
  %8 = getelementptr inbounds i8, ptr %0, i64 104
  br i1 %7, label %103, label %.preheader

.preheader:                                       ; preds = %4
  %9 = load i8, ptr %2, align 1, !tbaa !13
  store i8 %9, ptr %8, align 1, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %2, i64 1
  %11 = load i8, ptr %10, align 1, !tbaa !13
  %12 = getelementptr inbounds i8, ptr %0, i64 105
  store i8 %11, ptr %12, align 1, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %2, i64 2
  %14 = load i8, ptr %13, align 1, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %0, i64 106
  store i8 %14, ptr %15, align 1, !tbaa !13
  %16 = getelementptr inbounds i8, ptr %2, i64 3
  %17 = load i8, ptr %16, align 1, !tbaa !13
  %18 = getelementptr inbounds i8, ptr %0, i64 107
  store i8 %17, ptr %18, align 1, !tbaa !13
  %19 = getelementptr inbounds i8, ptr %2, i64 4
  %20 = load i8, ptr %19, align 1, !tbaa !13
  %21 = getelementptr inbounds i8, ptr %0, i64 108
  store i8 %20, ptr %21, align 1, !tbaa !13
  %22 = getelementptr inbounds i8, ptr %2, i64 5
  %23 = load i8, ptr %22, align 1, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %0, i64 109
  store i8 %23, ptr %24, align 1, !tbaa !13
  %25 = getelementptr inbounds i8, ptr %2, i64 6
  %26 = load i8, ptr %25, align 1, !tbaa !13
  %27 = getelementptr inbounds i8, ptr %0, i64 110
  store i8 %26, ptr %27, align 1, !tbaa !13
  %28 = getelementptr inbounds i8, ptr %2, i64 7
  %29 = load i8, ptr %28, align 1, !tbaa !13
  %30 = getelementptr inbounds i8, ptr %0, i64 111
  store i8 %29, ptr %30, align 1, !tbaa !13
  %31 = getelementptr inbounds i8, ptr %2, i64 8
  %32 = load i8, ptr %31, align 1, !tbaa !13
  %33 = getelementptr inbounds i8, ptr %0, i64 112
  store i8 %32, ptr %33, align 1, !tbaa !13
  %34 = getelementptr inbounds i8, ptr %2, i64 9
  %35 = load i8, ptr %34, align 1, !tbaa !13
  %36 = getelementptr inbounds i8, ptr %0, i64 113
  store i8 %35, ptr %36, align 1, !tbaa !13
  %37 = getelementptr inbounds i8, ptr %2, i64 10
  %38 = load i8, ptr %37, align 1, !tbaa !13
  %39 = getelementptr inbounds i8, ptr %0, i64 114
  store i8 %38, ptr %39, align 1, !tbaa !13
  %40 = getelementptr inbounds i8, ptr %2, i64 11
  %41 = load i8, ptr %40, align 1, !tbaa !13
  %42 = getelementptr inbounds i8, ptr %0, i64 115
  store i8 %41, ptr %42, align 1, !tbaa !13
  %43 = getelementptr inbounds i8, ptr %2, i64 12
  %44 = load i8, ptr %43, align 1, !tbaa !13
  %45 = getelementptr inbounds i8, ptr %0, i64 116
  store i8 %44, ptr %45, align 1, !tbaa !13
  %46 = getelementptr inbounds i8, ptr %2, i64 13
  %47 = load i8, ptr %46, align 1, !tbaa !13
  %48 = getelementptr inbounds i8, ptr %0, i64 117
  store i8 %47, ptr %48, align 1, !tbaa !13
  %49 = getelementptr inbounds i8, ptr %2, i64 14
  %50 = load i8, ptr %49, align 1, !tbaa !13
  %51 = getelementptr inbounds i8, ptr %0, i64 118
  store i8 %50, ptr %51, align 1, !tbaa !13
  %52 = getelementptr inbounds i8, ptr %2, i64 15
  %53 = load i8, ptr %52, align 1, !tbaa !13
  %54 = getelementptr inbounds i8, ptr %0, i64 119
  store i8 %53, ptr %54, align 1, !tbaa !13
  %55 = getelementptr inbounds i8, ptr %2, i64 16
  %56 = load i8, ptr %55, align 1, !tbaa !13
  %57 = getelementptr inbounds i8, ptr %0, i64 120
  store i8 %56, ptr %57, align 1, !tbaa !13
  %58 = getelementptr inbounds i8, ptr %2, i64 17
  %59 = load i8, ptr %58, align 1, !tbaa !13
  %60 = getelementptr inbounds i8, ptr %0, i64 121
  store i8 %59, ptr %60, align 1, !tbaa !13
  %61 = getelementptr inbounds i8, ptr %2, i64 18
  %62 = load i8, ptr %61, align 1, !tbaa !13
  %63 = getelementptr inbounds i8, ptr %0, i64 122
  store i8 %62, ptr %63, align 1, !tbaa !13
  %64 = getelementptr inbounds i8, ptr %2, i64 19
  %65 = load i8, ptr %64, align 1, !tbaa !13
  %66 = getelementptr inbounds i8, ptr %0, i64 123
  store i8 %65, ptr %66, align 1, !tbaa !13
  %67 = getelementptr inbounds i8, ptr %2, i64 20
  %68 = load i8, ptr %67, align 1, !tbaa !13
  %69 = getelementptr inbounds i8, ptr %0, i64 124
  store i8 %68, ptr %69, align 1, !tbaa !13
  %70 = getelementptr inbounds i8, ptr %2, i64 21
  %71 = load i8, ptr %70, align 1, !tbaa !13
  %72 = getelementptr inbounds i8, ptr %0, i64 125
  store i8 %71, ptr %72, align 1, !tbaa !13
  %73 = getelementptr inbounds i8, ptr %2, i64 22
  %74 = load i8, ptr %73, align 1, !tbaa !13
  %75 = getelementptr inbounds i8, ptr %0, i64 126
  store i8 %74, ptr %75, align 1, !tbaa !13
  %76 = getelementptr inbounds i8, ptr %2, i64 23
  %77 = load i8, ptr %76, align 1, !tbaa !13
  %78 = getelementptr inbounds i8, ptr %0, i64 127
  store i8 %77, ptr %78, align 1, !tbaa !13
  %79 = getelementptr inbounds i8, ptr %2, i64 24
  %80 = load i8, ptr %79, align 1, !tbaa !13
  %81 = getelementptr inbounds i8, ptr %0, i64 128
  store i8 %80, ptr %81, align 1, !tbaa !13
  %82 = getelementptr inbounds i8, ptr %2, i64 25
  %83 = load i8, ptr %82, align 1, !tbaa !13
  %84 = getelementptr inbounds i8, ptr %0, i64 129
  store i8 %83, ptr %84, align 1, !tbaa !13
  %85 = getelementptr inbounds i8, ptr %2, i64 26
  %86 = load i8, ptr %85, align 1, !tbaa !13
  %87 = getelementptr inbounds i8, ptr %0, i64 130
  store i8 %86, ptr %87, align 1, !tbaa !13
  %88 = getelementptr inbounds i8, ptr %2, i64 27
  %89 = load i8, ptr %88, align 1, !tbaa !13
  %90 = getelementptr inbounds i8, ptr %0, i64 131
  store i8 %89, ptr %90, align 1, !tbaa !13
  %91 = getelementptr inbounds i8, ptr %2, i64 28
  %92 = load i8, ptr %91, align 1, !tbaa !13
  %93 = getelementptr inbounds i8, ptr %0, i64 132
  store i8 %92, ptr %93, align 1, !tbaa !13
  %94 = getelementptr inbounds i8, ptr %2, i64 29
  %95 = load i8, ptr %94, align 1, !tbaa !13
  %96 = getelementptr inbounds i8, ptr %0, i64 133
  store i8 %95, ptr %96, align 1, !tbaa !13
  %97 = getelementptr inbounds i8, ptr %2, i64 30
  %98 = load i8, ptr %97, align 1, !tbaa !13
  %99 = getelementptr inbounds i8, ptr %0, i64 134
  store i8 %98, ptr %99, align 1, !tbaa !13
  %100 = getelementptr inbounds i8, ptr %2, i64 31
  %101 = load i8, ptr %100, align 1, !tbaa !13
  %102 = getelementptr inbounds i8, ptr %0, i64 135
  store i8 %101, ptr %102, align 1, !tbaa !13
  br label %.loopexit

103:                                              ; preds = %4
  %104 = load ptr, ptr %0, align 8, !tbaa !5
  tail call void @crypto_sign_public_key_custom_hash(ptr noundef nonnull %8, ptr noundef %1, ptr noundef %104)
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %103
  %105 = getelementptr inbounds i8, ptr %0, i64 40
  %106 = load ptr, ptr %0, align 8, !tbaa !5
  %107 = getelementptr inbounds i8, ptr %106, i64 8
  %108 = load ptr, ptr %107, align 8, !tbaa !14
  tail call void %108(ptr noundef nonnull %0) #1
  %109 = load ptr, ptr %0, align 8, !tbaa !5
  %110 = getelementptr inbounds i8, ptr %109, i64 16
  %111 = load ptr, ptr %110, align 8, !tbaa !15
  tail call void %111(ptr noundef nonnull %0, ptr noundef nonnull %105, i64 noundef 32) #1
  ret void
}

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 = { 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 0}
!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, !7, i64 8}
!15 = !{!11, !7, i64 16}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass