; LLVM IR from kcchu/rust-tweetnacl :: tweetnacl (crypto_sign_ed25519_tweet_keypair)

; 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

declare void @randombytes(ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @crypto_hash_sha512_tweet(ptr noundef, ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @crypto_sign_ed25519_tweet_keypair(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [64 x i8], align 16
  %6 = alloca [4 x [16 x i64]], align 16
  %7 = alloca i32, align 4
  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 64, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 512, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  call void @randombytes(ptr noundef %8, i64 noundef 32)
  %9 = getelementptr inbounds [64 x i8], ptr %5, i64 0, i64 0
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = call i32 @crypto_hash_sha512_tweet(ptr noundef %9, ptr noundef %10, i64 noundef 32)
  %12 = getelementptr inbounds [64 x i8], ptr %5, i64 0, i64 0
  %13 = load i8, ptr %12, align 16, !tbaa !9
  %14 = zext i8 %13 to i32
  %15 = and i32 %14, 248
  %16 = trunc i32 %15 to i8
  store i8 %16, ptr %12, align 16, !tbaa !9
  %17 = getelementptr inbounds [64 x i8], ptr %5, i64 0, i64 31
  %18 = load i8, ptr %17, align 1, !tbaa !9
  %19 = zext i8 %18 to i32
  %20 = and i32 %19, 127
  %21 = trunc i32 %20 to i8
  store i8 %21, ptr %17, align 1, !tbaa !9
  %22 = getelementptr inbounds [64 x i8], ptr %5, i64 0, i64 31
  %23 = load i8, ptr %22, align 1, !tbaa !9
  %24 = zext i8 %23 to i32
  %25 = or i32 %24, 64
  %26 = trunc i32 %25 to i8
  store i8 %26, ptr %22, align 1, !tbaa !9
  %27 = getelementptr inbounds [4 x [16 x i64]], ptr %6, i64 0, i64 0
  %28 = getelementptr inbounds [64 x i8], ptr %5, i64 0, i64 0
  call void @scalarbase(ptr noundef %27, ptr noundef %28)
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds [4 x [16 x i64]], ptr %6, i64 0, i64 0
  call void @pack(ptr noundef %29, ptr noundef %30)
  store i32 0, ptr %7, align 4, !tbaa !10
  br label %31

31:                                               ; preds = %45, %2
  %32 = load i32, ptr %7, align 4, !tbaa !10
  %33 = icmp slt i32 %32, 32
  br i1 %33, label %34, label %48

34:                                               ; preds = %31
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = load i32, ptr %7, align 4, !tbaa !10
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds i8, ptr %35, i64 %37
  %39 = load i8, ptr %38, align 1, !tbaa !9
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = load i32, ptr %7, align 4, !tbaa !10
  %42 = add nsw i32 32, %41
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds i8, ptr %40, i64 %43
  store i8 %39, ptr %44, align 1, !tbaa !9
  br label %45

45:                                               ; preds = %34
  %46 = load i32, ptr %7, align 4, !tbaa !10
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %7, align 4, !tbaa !10
  br label %31, !llvm.loop !12

48:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 512, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 64, ptr %5) #3
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare hidden void @scalarbase(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @pack(ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #3 = { 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 = !{!11, !11, i64 0}
!11 = !{!"int", !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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

declare void @randombytes(ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @crypto_hash_sha512_tweet(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @crypto_sign_ed25519_tweet_keypair(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca [64 x i8], align 16
  %4 = alloca [4 x [16 x i64]], align 16
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %4) #3
  tail call void @randombytes(ptr noundef %1, i64 noundef 32) #3
  %5 = call i32 @crypto_hash_sha512_tweet(ptr noundef nonnull %3, ptr noundef %1, i64 noundef 32)
  %6 = load i8, ptr %3, align 16, !tbaa !5
  %7 = and i8 %6, -8
  store i8 %7, ptr %3, align 16, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %3, i64 31
  %9 = load i8, ptr %8, align 1, !tbaa !5
  %10 = and i8 %9, 63
  %11 = or disjoint i8 %10, 64
  store i8 %11, ptr %8, align 1, !tbaa !5
  call void @scalarbase(ptr noundef nonnull %4, ptr noundef nonnull %3)
  call void @pack(ptr noundef %0, ptr noundef nonnull %4)
  %12 = load i8, ptr %0, align 1, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %1, i64 32
  store i8 %12, ptr %13, align 1, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 1
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %1, i64 33
  store i8 %15, ptr %16, align 1, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %0, i64 2
  %18 = load i8, ptr %17, align 1, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %1, i64 34
  store i8 %18, ptr %19, align 1, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %0, i64 3
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %1, i64 35
  store i8 %21, ptr %22, align 1, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %0, i64 4
  %24 = load i8, ptr %23, align 1, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %1, i64 36
  store i8 %24, ptr %25, align 1, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %0, i64 5
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %1, i64 37
  store i8 %27, ptr %28, align 1, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %0, i64 6
  %30 = load i8, ptr %29, align 1, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %1, i64 38
  store i8 %30, ptr %31, align 1, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %0, i64 7
  %33 = load i8, ptr %32, align 1, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %1, i64 39
  store i8 %33, ptr %34, align 1, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %0, i64 8
  %36 = load i8, ptr %35, align 1, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %1, i64 40
  store i8 %36, ptr %37, align 1, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %0, i64 9
  %39 = load i8, ptr %38, align 1, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %1, i64 41
  store i8 %39, ptr %40, align 1, !tbaa !5
  %41 = getelementptr inbounds i8, ptr %0, i64 10
  %42 = load i8, ptr %41, align 1, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %1, i64 42
  store i8 %42, ptr %43, align 1, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %0, i64 11
  %45 = load i8, ptr %44, align 1, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %1, i64 43
  store i8 %45, ptr %46, align 1, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %0, i64 12
  %48 = load i8, ptr %47, align 1, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %1, i64 44
  store i8 %48, ptr %49, align 1, !tbaa !5
  %50 = getelementptr inbounds i8, ptr %0, i64 13
  %51 = load i8, ptr %50, align 1, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %1, i64 45
  store i8 %51, ptr %52, align 1, !tbaa !5
  %53 = getelementptr inbounds i8, ptr %0, i64 14
  %54 = load i8, ptr %53, align 1, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %1, i64 46
  store i8 %54, ptr %55, align 1, !tbaa !5
  %56 = getelementptr inbounds i8, ptr %0, i64 15
  %57 = load i8, ptr %56, align 1, !tbaa !5
  %58 = getelementptr inbounds i8, ptr %1, i64 47
  store i8 %57, ptr %58, align 1, !tbaa !5
  %59 = getelementptr inbounds i8, ptr %0, i64 16
  %60 = load i8, ptr %59, align 1, !tbaa !5
  %61 = getelementptr inbounds i8, ptr %1, i64 48
  store i8 %60, ptr %61, align 1, !tbaa !5
  %62 = getelementptr inbounds i8, ptr %0, i64 17
  %63 = load i8, ptr %62, align 1, !tbaa !5
  %64 = getelementptr inbounds i8, ptr %1, i64 49
  store i8 %63, ptr %64, align 1, !tbaa !5
  %65 = getelementptr inbounds i8, ptr %0, i64 18
  %66 = load i8, ptr %65, align 1, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %1, i64 50
  store i8 %66, ptr %67, align 1, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %0, i64 19
  %69 = load i8, ptr %68, align 1, !tbaa !5
  %70 = getelementptr inbounds i8, ptr %1, i64 51
  store i8 %69, ptr %70, align 1, !tbaa !5
  %71 = getelementptr inbounds i8, ptr %0, i64 20
  %72 = load i8, ptr %71, align 1, !tbaa !5
  %73 = getelementptr inbounds i8, ptr %1, i64 52
  store i8 %72, ptr %73, align 1, !tbaa !5
  %74 = getelementptr inbounds i8, ptr %0, i64 21
  %75 = load i8, ptr %74, align 1, !tbaa !5
  %76 = getelementptr inbounds i8, ptr %1, i64 53
  store i8 %75, ptr %76, align 1, !tbaa !5
  %77 = getelementptr inbounds i8, ptr %0, i64 22
  %78 = load i8, ptr %77, align 1, !tbaa !5
  %79 = getelementptr inbounds i8, ptr %1, i64 54
  store i8 %78, ptr %79, align 1, !tbaa !5
  %80 = getelementptr inbounds i8, ptr %0, i64 23
  %81 = load i8, ptr %80, align 1, !tbaa !5
  %82 = getelementptr inbounds i8, ptr %1, i64 55
  store i8 %81, ptr %82, align 1, !tbaa !5
  %83 = getelementptr inbounds i8, ptr %0, i64 24
  %84 = load i8, ptr %83, align 1, !tbaa !5
  %85 = getelementptr inbounds i8, ptr %1, i64 56
  store i8 %84, ptr %85, align 1, !tbaa !5
  %86 = getelementptr inbounds i8, ptr %0, i64 25
  %87 = load i8, ptr %86, align 1, !tbaa !5
  %88 = getelementptr inbounds i8, ptr %1, i64 57
  store i8 %87, ptr %88, align 1, !tbaa !5
  %89 = getelementptr inbounds i8, ptr %0, i64 26
  %90 = load i8, ptr %89, align 1, !tbaa !5
  %91 = getelementptr inbounds i8, ptr %1, i64 58
  store i8 %90, ptr %91, align 1, !tbaa !5
  %92 = getelementptr inbounds i8, ptr %0, i64 27
  %93 = load i8, ptr %92, align 1, !tbaa !5
  %94 = getelementptr inbounds i8, ptr %1, i64 59
  store i8 %93, ptr %94, align 1, !tbaa !5
  %95 = getelementptr inbounds i8, ptr %0, i64 28
  %96 = load i8, ptr %95, align 1, !tbaa !5
  %97 = getelementptr inbounds i8, ptr %1, i64 60
  store i8 %96, ptr %97, align 1, !tbaa !5
  %98 = getelementptr inbounds i8, ptr %0, i64 29
  %99 = load i8, ptr %98, align 1, !tbaa !5
  %100 = getelementptr inbounds i8, ptr %1, i64 61
  store i8 %99, ptr %100, align 1, !tbaa !5
  %101 = getelementptr inbounds i8, ptr %0, i64 30
  %102 = load i8, ptr %101, align 1, !tbaa !5
  %103 = getelementptr inbounds i8, ptr %1, i64 62
  store i8 %102, ptr %103, align 1, !tbaa !5
  %104 = getelementptr inbounds i8, ptr %0, i64 31
  %105 = load i8, ptr %104, align 1, !tbaa !5
  %106 = getelementptr inbounds i8, ptr %1, i64 63
  store i8 %105, ptr %106, align 1, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %4) #3
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %3) #3
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare hidden void @scalarbase(ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @pack(ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #3 = { 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,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass