; LLVM IR from albertobsd/keyhunt :: hash/sha512.ll (Z16hmac_sha512_initR7CSHA512PKh)

; 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: mustprogress nounwind uwtable
declare dso_local void @_ZN7CSHA51210InitializeEv(ptr noundef nonnull align 8 dereferenceable(208)) #0 align 2

; 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: mustprogress uwtable
declare dso_local void @_ZN7CSHA51214WriteDirect128EPKh(ptr noundef nonnull align 8 dereferenceable(208), ptr noundef) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z16hmac_sha512_initR7CSHA512PKh(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [16 x i64], align 16
  %6 = alloca ptr, align 8
  %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 128, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %8, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %9

9:                                                ; preds = %22, %2
  %10 = load i32, ptr %7, align 4, !tbaa !9
  %11 = icmp slt i32 %10, 16
  br i1 %11, label %12, label %25

12:                                               ; preds = %9
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = load i32, ptr %7, align 4, !tbaa !9
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds i64, ptr %13, i64 %15
  %17 = load i64, ptr %16, align 8, !tbaa !11
  %18 = xor i64 %17, 3906369333256140342
  %19 = load i32, ptr %7, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [16 x i64], ptr %5, i64 0, i64 %20
  store i64 %18, ptr %21, align 8, !tbaa !11
  br label %22

22:                                               ; preds = %12
  %23 = load i32, ptr %7, align 4, !tbaa !9
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr %7, align 4, !tbaa !9
  br label %9, !llvm.loop !13

25:                                               ; preds = %9
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN7CSHA51210InitializeEv(ptr noundef nonnull align 8 dereferenceable(208) %26)
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds [16 x i64], ptr %5, i64 0, i64 0
  call void @_ZN7CSHA51214WriteDirect128EPKh(ptr noundef nonnull align 8 dereferenceable(208) %27, ptr noundef %28)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 128, ptr %5) #3
  ret void
}

attributes #0 = { mustprogress 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 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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 nounwind uwtable
declare dso_local void @_ZN7CSHA51210InitializeEv(ptr noundef nonnull align 8 dereferenceable(208)) local_unnamed_addr #0 align 2

; 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: mustprogress uwtable
declare dso_local void @_ZN7CSHA51214WriteDirect128EPKh(ptr noundef nonnull align 8 dereferenceable(208), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z16hmac_sha512_initR7CSHA512PKh(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  %3 = alloca [16 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %3) #3
  %4 = load <2 x i64>, ptr %1, align 8, !tbaa !5
  %5 = xor <2 x i64> %4, <i64 3906369333256140342, i64 3906369333256140342>
  store <2 x i64> %5, ptr %3, align 16, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 16
  %7 = getelementptr inbounds i8, ptr %3, i64 16
  %8 = load <2 x i64>, ptr %6, align 8, !tbaa !5
  %9 = xor <2 x i64> %8, <i64 3906369333256140342, i64 3906369333256140342>
  store <2 x i64> %9, ptr %7, align 16, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %1, i64 32
  %11 = getelementptr inbounds i8, ptr %3, i64 32
  %12 = load <2 x i64>, ptr %10, align 8, !tbaa !5
  %13 = xor <2 x i64> %12, <i64 3906369333256140342, i64 3906369333256140342>
  store <2 x i64> %13, ptr %11, align 16, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %1, i64 48
  %15 = getelementptr inbounds i8, ptr %3, i64 48
  %16 = load <2 x i64>, ptr %14, align 8, !tbaa !5
  %17 = xor <2 x i64> %16, <i64 3906369333256140342, i64 3906369333256140342>
  store <2 x i64> %17, ptr %15, align 16, !tbaa !5
  %18 = getelementptr inbounds i8, ptr %1, i64 64
  %19 = getelementptr inbounds i8, ptr %3, i64 64
  %20 = load <2 x i64>, ptr %18, align 8, !tbaa !5
  %21 = xor <2 x i64> %20, <i64 3906369333256140342, i64 3906369333256140342>
  store <2 x i64> %21, ptr %19, align 16, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %1, i64 80
  %23 = getelementptr inbounds i8, ptr %3, i64 80
  %24 = load <2 x i64>, ptr %22, align 8, !tbaa !5
  %25 = xor <2 x i64> %24, <i64 3906369333256140342, i64 3906369333256140342>
  store <2 x i64> %25, ptr %23, align 16, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %1, i64 96
  %27 = getelementptr inbounds i8, ptr %3, i64 96
  %28 = load <2 x i64>, ptr %26, align 8, !tbaa !5
  %29 = xor <2 x i64> %28, <i64 3906369333256140342, i64 3906369333256140342>
  store <2 x i64> %29, ptr %27, align 16, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %1, i64 112
  %31 = getelementptr inbounds i8, ptr %3, i64 112
  %32 = load <2 x i64>, ptr %30, align 8, !tbaa !5
  %33 = xor <2 x i64> %32, <i64 3906369333256140342, i64 3906369333256140342>
  store <2 x i64> %33, ptr %31, align 16, !tbaa !5
  tail call void @_ZN7CSHA51210InitializeEv(ptr noundef nonnull align 8 dereferenceable(208) %0)
  call void @_ZN7CSHA51214WriteDirect128EPKh(ptr noundef nonnull align 8 dereferenceable(208) %0, ptr noundef nonnull %3)
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %3) #3
  ret void
}

attributes #0 = { mustprogress 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 = { mustprogress 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass