; LLVM IR from imkcat/CatCrypto :: Sources/ModuleMaps/Argon2 (core)

; 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.block_ = type { [128 x i64] }

; Function Attrs: nounwind uwtable
define dso_local void @xor_block(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = 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 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %23, %2
  %7 = load i32, ptr %5, align 4, !tbaa !9
  %8 = icmp slt i32 %7, 128
  br i1 %8, label %9, label %26

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

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

26:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

; 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

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, !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: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @xor_block(ptr nocapture noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
vector.memcheck:
  %scevgep = getelementptr i8, ptr %0, i64 1024
  %scevgep7 = getelementptr i8, ptr %1, i64 1024
  %bound0 = icmp ugt ptr %scevgep7, %0
  %bound1 = icmp ugt ptr %scevgep, %1
  %found.conflict = and i1 %bound0, %bound1
  br i1 %found.conflict, label %scalar.ph, label %vector.body

vector.body:                                      ; preds = %vector.memcheck, %vector.body
  %index = phi i64 [ %index.next.1, %vector.body ], [ 0, %vector.memcheck ]
  %2 = getelementptr inbounds [128 x i64], ptr %1, i64 0, i64 %index
  %3 = getelementptr inbounds i8, ptr %2, i64 16
  %wide.load = load <2 x i64>, ptr %2, align 8, !tbaa !5, !alias.scope !9
  %wide.load8 = load <2 x i64>, ptr %3, align 8, !tbaa !5, !alias.scope !9
  %4 = getelementptr inbounds [128 x i64], ptr %0, i64 0, i64 %index
  %5 = getelementptr inbounds i8, ptr %4, i64 16
  %wide.load9 = load <2 x i64>, ptr %4, align 8, !tbaa !5, !alias.scope !12, !noalias !9
  %wide.load10 = load <2 x i64>, ptr %5, align 8, !tbaa !5, !alias.scope !12, !noalias !9
  %6 = xor <2 x i64> %wide.load9, %wide.load
  %7 = xor <2 x i64> %wide.load10, %wide.load8
  store <2 x i64> %6, ptr %4, align 8, !tbaa !5, !alias.scope !12, !noalias !9
  store <2 x i64> %7, ptr %5, align 8, !tbaa !5, !alias.scope !12, !noalias !9
  %index.next = or disjoint i64 %index, 4
  %8 = getelementptr inbounds [128 x i64], ptr %1, i64 0, i64 %index.next
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  %wide.load.1 = load <2 x i64>, ptr %8, align 8, !tbaa !5, !alias.scope !9
  %wide.load8.1 = load <2 x i64>, ptr %9, align 8, !tbaa !5, !alias.scope !9
  %10 = getelementptr inbounds [128 x i64], ptr %0, i64 0, i64 %index.next
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  %wide.load9.1 = load <2 x i64>, ptr %10, align 8, !tbaa !5, !alias.scope !12, !noalias !9
  %wide.load10.1 = load <2 x i64>, ptr %11, align 8, !tbaa !5, !alias.scope !12, !noalias !9
  %12 = xor <2 x i64> %wide.load9.1, %wide.load.1
  %13 = xor <2 x i64> %wide.load10.1, %wide.load8.1
  store <2 x i64> %12, ptr %10, align 8, !tbaa !5, !alias.scope !12, !noalias !9
  store <2 x i64> %13, ptr %11, align 8, !tbaa !5, !alias.scope !12, !noalias !9
  %index.next.1 = add nuw nsw i64 %index, 8
  %14 = icmp eq i64 %index.next.1, 128
  br i1 %14, label %middle.block, label %vector.body, !llvm.loop !14

scalar.ph:                                        ; preds = %vector.memcheck, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.3, %scalar.ph ], [ 0, %vector.memcheck ]
  %15 = getelementptr inbounds [128 x i64], ptr %1, i64 0, i64 %indvars.iv
  %16 = load i64, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds [128 x i64], ptr %0, i64 0, i64 %indvars.iv
  %18 = load i64, ptr %17, align 8, !tbaa !5
  %19 = xor i64 %18, %16
  store i64 %19, ptr %17, align 8, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %20 = getelementptr inbounds [128 x i64], ptr %1, i64 0, i64 %indvars.iv.next
  %21 = load i64, ptr %20, align 8, !tbaa !5
  %22 = getelementptr inbounds [128 x i64], ptr %0, i64 0, i64 %indvars.iv.next
  %23 = load i64, ptr %22, align 8, !tbaa !5
  %24 = xor i64 %23, %21
  store i64 %24, ptr %22, align 8, !tbaa !5
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %25 = getelementptr inbounds [128 x i64], ptr %1, i64 0, i64 %indvars.iv.next.1
  %26 = load i64, ptr %25, align 8, !tbaa !5
  %27 = getelementptr inbounds [128 x i64], ptr %0, i64 0, i64 %indvars.iv.next.1
  %28 = load i64, ptr %27, align 8, !tbaa !5
  %29 = xor i64 %28, %26
  store i64 %29, ptr %27, align 8, !tbaa !5
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %30 = getelementptr inbounds [128 x i64], ptr %1, i64 0, i64 %indvars.iv.next.2
  %31 = load i64, ptr %30, align 8, !tbaa !5
  %32 = getelementptr inbounds [128 x i64], ptr %0, i64 0, i64 %indvars.iv.next.2
  %33 = load i64, ptr %32, align 8, !tbaa !5
  %34 = xor i64 %33, %31
  store i64 %34, ptr %32, align 8, !tbaa !5
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %exitcond.not.3 = icmp eq i64 %indvars.iv.next.3, 128
  br i1 %exitcond.not.3, label %middle.block, label %scalar.ph, !llvm.loop !18

middle.block:                                     ; preds = %vector.body, %scalar.ph
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: readwrite) 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10}
!10 = distinct !{!10, !11}
!11 = distinct !{!11, !"LVerDomain"}
!12 = !{!13}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !15, !16, !17}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!"llvm.loop.isvectorized", i32 1}
!17 = !{!"llvm.loop.unroll.runtime.disable"}
!18 = distinct !{!18, !15, !16}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopLoadEliminationPass,LoopRotatePass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass