; 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: 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 dso_local void @crypto_blake2b_update(ptr noundef, ptr noundef, i64 noundef) #1

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

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

; Function Attrs: nounwind uwtable
declare hidden void @trim_scalar(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @crypto_sign_init_first_pass(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %10 = load ptr, ptr %4, 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 %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %13 = load ptr, ptr %4, 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 %8, align 8, !tbaa !5
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  call void @crypto_blake2b(ptr noundef %17, ptr noundef %18, i64 noundef 32)
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  call void @trim_scalar(ptr noundef %19)
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = icmp eq ptr %20, null
  br i1 %21, label %22, label %27

22:                                               ; preds = %3
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.crypto_sign_ctx, ptr %23, i32 0, i32 2
  %25 = getelementptr inbounds [32 x i8], ptr %24, i64 0, i64 0
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  call void @crypto_sign_public_key(ptr noundef %25, ptr noundef %26)
  br label %45

27:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %28

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

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

32:                                               ; preds = %28
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load i64, ptr %9, align 8, !tbaa !9
  %35 = getelementptr inbounds i8, ptr %33, i64 %34
  %36 = load i8, ptr %35, align 1, !tbaa !11
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.crypto_sign_ctx, ptr %37, i32 0, i32 2
  %39 = load i64, ptr %9, align 8, !tbaa !9
  %40 = getelementptr inbounds [32 x i8], ptr %38, i64 0, i64 %39
  store i8 %36, ptr %40, align 1, !tbaa !11
  br label %41

41:                                               ; preds = %32
  %42 = load i64, ptr %9, align 8, !tbaa !9
  %43 = add i64 %42, 1
  store i64 %43, ptr %9, align 8, !tbaa !9
  br label %28, !llvm.loop !12

44:                                               ; preds = %31
  br label %45

45:                                               ; preds = %44, %22
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.crypto_sign_ctx, ptr %46, i32 0, i32 0
  call void @crypto_blake2b_init(ptr noundef %47)
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.crypto_sign_ctx, ptr %48, i32 0, i32 0
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  call void @crypto_blake2b_update(ptr noundef %49, ptr noundef %50, i64 noundef 32)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #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, !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_blake2b_update(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

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

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

; 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(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @crypto_sign_init_first_pass(ptr noundef %0, ptr noundef %1, ptr noundef readonly %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 224
  tail call void @crypto_blake2b(ptr noundef nonnull %4, ptr noundef %1, i64 noundef 32)
  tail call void @trim_scalar(ptr noundef nonnull %4)
  %5 = icmp eq ptr %2, null
  %6 = getelementptr inbounds i8, ptr %0, i64 320
  br i1 %5, label %101, label %.preheader

.preheader:                                       ; preds = %3
  %7 = load i8, ptr %2, align 1, !tbaa !5
  store i8 %7, ptr %6, align 1, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %2, i64 1
  %9 = load i8, ptr %8, align 1, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 321
  store i8 %9, ptr %10, align 1, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %2, i64 2
  %12 = load i8, ptr %11, align 1, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 322
  store i8 %12, ptr %13, align 1, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %2, i64 3
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 323
  store i8 %15, ptr %16, align 1, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %2, i64 4
  %18 = load i8, ptr %17, align 1, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %0, i64 324
  store i8 %18, ptr %19, align 1, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %2, i64 5
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %0, i64 325
  store i8 %21, ptr %22, align 1, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %2, i64 6
  %24 = load i8, ptr %23, align 1, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %0, i64 326
  store i8 %24, ptr %25, align 1, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %2, i64 7
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %0, i64 327
  store i8 %27, ptr %28, align 1, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %2, i64 8
  %30 = load i8, ptr %29, align 1, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %0, i64 328
  store i8 %30, ptr %31, align 1, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %2, i64 9
  %33 = load i8, ptr %32, align 1, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %0, i64 329
  store i8 %33, ptr %34, align 1, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %2, i64 10
  %36 = load i8, ptr %35, align 1, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %0, i64 330
  store i8 %36, ptr %37, align 1, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %2, i64 11
  %39 = load i8, ptr %38, align 1, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %0, i64 331
  store i8 %39, ptr %40, align 1, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %2, i64 12
  %42 = load i8, ptr %41, align 1, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %0, i64 332
  store i8 %42, ptr %43, align 1, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %2, i64 13
  %45 = load i8, ptr %44, align 1, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %0, i64 333
  store i8 %45, ptr %46, align 1, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %2, i64 14
  %48 = load i8, ptr %47, align 1, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %0, i64 334
  store i8 %48, ptr %49, align 1, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %2, i64 15
  %51 = load i8, ptr %50, align 1, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %0, i64 335
  store i8 %51, ptr %52, align 1, !tbaa !5
  %53 = getelementptr inbounds i8, ptr %2, i64 16
  %54 = load i8, ptr %53, align 1, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %0, i64 336
  store i8 %54, ptr %55, align 1, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %2, i64 17
  %57 = load i8, ptr %56, align 1, !tbaa !5
  %58 = getelementptr inbounds i8, ptr %0, i64 337
  store i8 %57, ptr %58, align 1, !tbaa !5
  %59 = getelementptr inbounds i8, ptr %2, i64 18
  %60 = load i8, ptr %59, align 1, !tbaa !5
  %61 = getelementptr inbounds i8, ptr %0, i64 338
  store i8 %60, ptr %61, align 1, !tbaa !5
  %62 = getelementptr inbounds i8, ptr %2, i64 19
  %63 = load i8, ptr %62, align 1, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %0, i64 339
  store i8 %63, ptr %64, align 1, !tbaa !5
  %65 = getelementptr inbounds i8, ptr %2, i64 20
  %66 = load i8, ptr %65, align 1, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %0, i64 340
  store i8 %66, ptr %67, align 1, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %2, i64 21
  %69 = load i8, ptr %68, align 1, !tbaa !5
  %70 = getelementptr inbounds i8, ptr %0, i64 341
  store i8 %69, ptr %70, align 1, !tbaa !5
  %71 = getelementptr inbounds i8, ptr %2, i64 22
  %72 = load i8, ptr %71, align 1, !tbaa !5
  %73 = getelementptr inbounds i8, ptr %0, i64 342
  store i8 %72, ptr %73, align 1, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %2, i64 23
  %75 = load i8, ptr %74, align 1, !tbaa !5
  %76 = getelementptr inbounds i8, ptr %0, i64 343
  store i8 %75, ptr %76, align 1, !tbaa !5
  %77 = getelementptr inbounds i8, ptr %2, i64 24
  %78 = load i8, ptr %77, align 1, !tbaa !5
  %79 = getelementptr inbounds i8, ptr %0, i64 344
  store i8 %78, ptr %79, align 1, !tbaa !5
  %80 = getelementptr inbounds i8, ptr %2, i64 25
  %81 = load i8, ptr %80, align 1, !tbaa !5
  %82 = getelementptr inbounds i8, ptr %0, i64 345
  store i8 %81, ptr %82, align 1, !tbaa !5
  %83 = getelementptr inbounds i8, ptr %2, i64 26
  %84 = load i8, ptr %83, align 1, !tbaa !5
  %85 = getelementptr inbounds i8, ptr %0, i64 346
  store i8 %84, ptr %85, align 1, !tbaa !5
  %86 = getelementptr inbounds i8, ptr %2, i64 27
  %87 = load i8, ptr %86, align 1, !tbaa !5
  %88 = getelementptr inbounds i8, ptr %0, i64 347
  store i8 %87, ptr %88, align 1, !tbaa !5
  %89 = getelementptr inbounds i8, ptr %2, i64 28
  %90 = load i8, ptr %89, align 1, !tbaa !5
  %91 = getelementptr inbounds i8, ptr %0, i64 348
  store i8 %90, ptr %91, align 1, !tbaa !5
  %92 = getelementptr inbounds i8, ptr %2, i64 29
  %93 = load i8, ptr %92, align 1, !tbaa !5
  %94 = getelementptr inbounds i8, ptr %0, i64 349
  store i8 %93, ptr %94, align 1, !tbaa !5
  %95 = getelementptr inbounds i8, ptr %2, i64 30
  %96 = load i8, ptr %95, align 1, !tbaa !5
  %97 = getelementptr inbounds i8, ptr %0, i64 350
  store i8 %96, ptr %97, align 1, !tbaa !5
  %98 = getelementptr inbounds i8, ptr %2, i64 31
  %99 = load i8, ptr %98, align 1, !tbaa !5
  %100 = getelementptr inbounds i8, ptr %0, i64 351
  store i8 %99, ptr %100, align 1, !tbaa !5
  br label %.loopexit

101:                                              ; preds = %3
  tail call void @crypto_sign_public_key(ptr noundef nonnull %6, ptr noundef %1)
  br label %.loopexit

.loopexit:                                        ; preds = %.preheader, %101
  %102 = getelementptr inbounds i8, ptr %0, i64 256
  tail call void @crypto_blake2b_init(ptr noundef %0)
  tail call void @crypto_blake2b_update(ptr noundef %0, ptr noundef nonnull %102, i64 noundef 32)
  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" }

!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,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass