; LLVM IR from DanEngelbrecht/longtail :: lib/blake2/ext (blake2s)

; 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.blake2s_state__ = type { [8 x i32], [2 x i32], [2 x i32], [64 x i8], i64, i64, i8 }
%struct.blake2s_param__ = type { i8, i8, i8, i8, i32, i32, i16, i8, i8, [8 x i8], [8 x i8] }

@blake2s_IV = external hidden constant [8 x i32], align 16

; Function Attrs: nounwind uwtable
define dso_local i32 @blake2s_init_param(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  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 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store ptr @blake2s_IV, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %9, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.blake2s_state__, ptr %10, i32 0, i32 0
  %12 = getelementptr inbounds [8 x i32], ptr %11, i64 0, i64 0
  store ptr %12, ptr %8, align 8, !tbaa !5
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %13, i8 0, i64 136, i1 false)
  store i64 0, ptr %5, align 8, !tbaa !9
  br label %14

14:                                               ; preds = %33, %2
  %15 = load i64, ptr %5, align 8, !tbaa !9
  %16 = icmp ult i64 %15, 32
  br i1 %16, label %17, label %36

17:                                               ; preds = %14
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = load i64, ptr %5, align 8, !tbaa !9
  %20 = getelementptr inbounds i8, ptr %18, i64 %19
  %21 = load i8, ptr %20, align 1, !tbaa !11
  %22 = zext i8 %21 to i32
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = load i64, ptr %5, align 8, !tbaa !9
  %25 = getelementptr inbounds i8, ptr %23, i64 %24
  %26 = load i8, ptr %25, align 1, !tbaa !11
  %27 = zext i8 %26 to i32
  %28 = xor i32 %22, %27
  %29 = trunc i32 %28 to i8
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = getelementptr inbounds i8, ptr %30, i64 %31
  store i8 %29, ptr %32, align 1, !tbaa !11
  br label %33

33:                                               ; preds = %17
  %34 = load i64, ptr %5, align 8, !tbaa !9
  %35 = add i64 %34, 1
  store i64 %35, ptr %5, align 8, !tbaa !9
  br label %14, !llvm.loop !12

36:                                               ; preds = %14
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.blake2s_param__, ptr %37, i32 0, i32 0
  %39 = load i8, ptr %38, align 1, !tbaa !14
  %40 = zext i8 %39 to i64
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.blake2s_state__, ptr %41, i32 0, i32 5
  store i64 %40, ptr %42, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret i32 0
}

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !7, i64 0}
!15 = !{!"blake2s_param__", !7, i64 0, !7, i64 1, !7, i64 2, !7, i64 3, !16, i64 4, !16, i64 8, !17, i64 12, !7, i64 14, !7, i64 15, !7, i64 16, !7, i64 24}
!16 = !{!"int", !7, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = !{!19, !10, i64 120}
!19 = !{!"blake2s_state__", !7, i64 0, !7, i64 32, !7, i64 40, !7, i64 48, !10, i64 112, !10, i64 120, !7, i64 128}


; 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"

@blake2s_IV = external hidden local_unnamed_addr constant [8 x i32], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local noundef i32 @blake2s_init_param(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(136) %0, i8 0, i64 136, i1 false)
  %3 = load i8, ptr @blake2s_IV, align 16, !tbaa !5
  %4 = load i8, ptr %1, align 1, !tbaa !5
  %5 = xor i8 %4, %3
  store i8 %5, ptr %0, align 1, !tbaa !5
  %6 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 1), align 1, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 1
  %8 = load i8, ptr %7, align 1, !tbaa !5
  %9 = xor i8 %8, %6
  %10 = getelementptr inbounds i8, ptr %0, i64 1
  store i8 %9, ptr %10, align 1, !tbaa !5
  %11 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 2), align 2, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %1, i64 2
  %13 = load i8, ptr %12, align 1, !tbaa !5
  %14 = xor i8 %13, %11
  %15 = getelementptr inbounds i8, ptr %0, i64 2
  store i8 %14, ptr %15, align 1, !tbaa !5
  %16 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 3), align 1, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %1, i64 3
  %18 = load i8, ptr %17, align 1, !tbaa !5
  %19 = xor i8 %18, %16
  %20 = getelementptr inbounds i8, ptr %0, i64 3
  store i8 %19, ptr %20, align 1, !tbaa !5
  %21 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 4), align 4, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %1, i64 4
  %23 = load i8, ptr %22, align 1, !tbaa !5
  %24 = xor i8 %23, %21
  %25 = getelementptr inbounds i8, ptr %0, i64 4
  store i8 %24, ptr %25, align 1, !tbaa !5
  %26 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 5), align 1, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %1, i64 5
  %28 = load i8, ptr %27, align 1, !tbaa !5
  %29 = xor i8 %28, %26
  %30 = getelementptr inbounds i8, ptr %0, i64 5
  store i8 %29, ptr %30, align 1, !tbaa !5
  %31 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 6), align 2, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %1, i64 6
  %33 = load i8, ptr %32, align 1, !tbaa !5
  %34 = xor i8 %33, %31
  %35 = getelementptr inbounds i8, ptr %0, i64 6
  store i8 %34, ptr %35, align 1, !tbaa !5
  %36 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 7), align 1, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %1, i64 7
  %38 = load i8, ptr %37, align 1, !tbaa !5
  %39 = xor i8 %38, %36
  %40 = getelementptr inbounds i8, ptr %0, i64 7
  store i8 %39, ptr %40, align 1, !tbaa !5
  %41 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 8), align 8, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %1, i64 8
  %43 = load i8, ptr %42, align 1, !tbaa !5
  %44 = xor i8 %43, %41
  %45 = getelementptr inbounds i8, ptr %0, i64 8
  store i8 %44, ptr %45, align 1, !tbaa !5
  %46 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 9), align 1, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %1, i64 9
  %48 = load i8, ptr %47, align 1, !tbaa !5
  %49 = xor i8 %48, %46
  %50 = getelementptr inbounds i8, ptr %0, i64 9
  store i8 %49, ptr %50, align 1, !tbaa !5
  %51 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 10), align 2, !tbaa !5
  %52 = getelementptr inbounds i8, ptr %1, i64 10
  %53 = load i8, ptr %52, align 1, !tbaa !5
  %54 = xor i8 %53, %51
  %55 = getelementptr inbounds i8, ptr %0, i64 10
  store i8 %54, ptr %55, align 1, !tbaa !5
  %56 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 11), align 1, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %1, i64 11
  %58 = load i8, ptr %57, align 1, !tbaa !5
  %59 = xor i8 %58, %56
  %60 = getelementptr inbounds i8, ptr %0, i64 11
  store i8 %59, ptr %60, align 1, !tbaa !5
  %61 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 12), align 4, !tbaa !5
  %62 = getelementptr inbounds i8, ptr %1, i64 12
  %63 = load i8, ptr %62, align 1, !tbaa !5
  %64 = xor i8 %63, %61
  %65 = getelementptr inbounds i8, ptr %0, i64 12
  store i8 %64, ptr %65, align 1, !tbaa !5
  %66 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 13), align 1, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %1, i64 13
  %68 = load i8, ptr %67, align 1, !tbaa !5
  %69 = xor i8 %68, %66
  %70 = getelementptr inbounds i8, ptr %0, i64 13
  store i8 %69, ptr %70, align 1, !tbaa !5
  %71 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 14), align 2, !tbaa !5
  %72 = getelementptr inbounds i8, ptr %1, i64 14
  %73 = load i8, ptr %72, align 1, !tbaa !5
  %74 = xor i8 %73, %71
  %75 = getelementptr inbounds i8, ptr %0, i64 14
  store i8 %74, ptr %75, align 1, !tbaa !5
  %76 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 15), align 1, !tbaa !5
  %77 = getelementptr inbounds i8, ptr %1, i64 15
  %78 = load i8, ptr %77, align 1, !tbaa !5
  %79 = xor i8 %78, %76
  %80 = getelementptr inbounds i8, ptr %0, i64 15
  store i8 %79, ptr %80, align 1, !tbaa !5
  %81 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 16), align 16, !tbaa !5
  %82 = getelementptr inbounds i8, ptr %1, i64 16
  %83 = load i8, ptr %82, align 1, !tbaa !5
  %84 = xor i8 %83, %81
  %85 = getelementptr inbounds i8, ptr %0, i64 16
  store i8 %84, ptr %85, align 1, !tbaa !5
  %86 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 17), align 1, !tbaa !5
  %87 = getelementptr inbounds i8, ptr %1, i64 17
  %88 = load i8, ptr %87, align 1, !tbaa !5
  %89 = xor i8 %88, %86
  %90 = getelementptr inbounds i8, ptr %0, i64 17
  store i8 %89, ptr %90, align 1, !tbaa !5
  %91 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 18), align 2, !tbaa !5
  %92 = getelementptr inbounds i8, ptr %1, i64 18
  %93 = load i8, ptr %92, align 1, !tbaa !5
  %94 = xor i8 %93, %91
  %95 = getelementptr inbounds i8, ptr %0, i64 18
  store i8 %94, ptr %95, align 1, !tbaa !5
  %96 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 19), align 1, !tbaa !5
  %97 = getelementptr inbounds i8, ptr %1, i64 19
  %98 = load i8, ptr %97, align 1, !tbaa !5
  %99 = xor i8 %98, %96
  %100 = getelementptr inbounds i8, ptr %0, i64 19
  store i8 %99, ptr %100, align 1, !tbaa !5
  %101 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 20), align 4, !tbaa !5
  %102 = getelementptr inbounds i8, ptr %1, i64 20
  %103 = load i8, ptr %102, align 1, !tbaa !5
  %104 = xor i8 %103, %101
  %105 = getelementptr inbounds i8, ptr %0, i64 20
  store i8 %104, ptr %105, align 1, !tbaa !5
  %106 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 21), align 1, !tbaa !5
  %107 = getelementptr inbounds i8, ptr %1, i64 21
  %108 = load i8, ptr %107, align 1, !tbaa !5
  %109 = xor i8 %108, %106
  %110 = getelementptr inbounds i8, ptr %0, i64 21
  store i8 %109, ptr %110, align 1, !tbaa !5
  %111 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 22), align 2, !tbaa !5
  %112 = getelementptr inbounds i8, ptr %1, i64 22
  %113 = load i8, ptr %112, align 1, !tbaa !5
  %114 = xor i8 %113, %111
  %115 = getelementptr inbounds i8, ptr %0, i64 22
  store i8 %114, ptr %115, align 1, !tbaa !5
  %116 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 23), align 1, !tbaa !5
  %117 = getelementptr inbounds i8, ptr %1, i64 23
  %118 = load i8, ptr %117, align 1, !tbaa !5
  %119 = xor i8 %118, %116
  %120 = getelementptr inbounds i8, ptr %0, i64 23
  store i8 %119, ptr %120, align 1, !tbaa !5
  %121 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 24), align 8, !tbaa !5
  %122 = getelementptr inbounds i8, ptr %1, i64 24
  %123 = load i8, ptr %122, align 1, !tbaa !5
  %124 = xor i8 %123, %121
  %125 = getelementptr inbounds i8, ptr %0, i64 24
  store i8 %124, ptr %125, align 1, !tbaa !5
  %126 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 25), align 1, !tbaa !5
  %127 = getelementptr inbounds i8, ptr %1, i64 25
  %128 = load i8, ptr %127, align 1, !tbaa !5
  %129 = xor i8 %128, %126
  %130 = getelementptr inbounds i8, ptr %0, i64 25
  store i8 %129, ptr %130, align 1, !tbaa !5
  %131 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 26), align 2, !tbaa !5
  %132 = getelementptr inbounds i8, ptr %1, i64 26
  %133 = load i8, ptr %132, align 1, !tbaa !5
  %134 = xor i8 %133, %131
  %135 = getelementptr inbounds i8, ptr %0, i64 26
  store i8 %134, ptr %135, align 1, !tbaa !5
  %136 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 27), align 1, !tbaa !5
  %137 = getelementptr inbounds i8, ptr %1, i64 27
  %138 = load i8, ptr %137, align 1, !tbaa !5
  %139 = xor i8 %138, %136
  %140 = getelementptr inbounds i8, ptr %0, i64 27
  store i8 %139, ptr %140, align 1, !tbaa !5
  %141 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 28), align 4, !tbaa !5
  %142 = getelementptr inbounds i8, ptr %1, i64 28
  %143 = load i8, ptr %142, align 1, !tbaa !5
  %144 = xor i8 %143, %141
  %145 = getelementptr inbounds i8, ptr %0, i64 28
  store i8 %144, ptr %145, align 1, !tbaa !5
  %146 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 29), align 1, !tbaa !5
  %147 = getelementptr inbounds i8, ptr %1, i64 29
  %148 = load i8, ptr %147, align 1, !tbaa !5
  %149 = xor i8 %148, %146
  %150 = getelementptr inbounds i8, ptr %0, i64 29
  store i8 %149, ptr %150, align 1, !tbaa !5
  %151 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 30), align 2, !tbaa !5
  %152 = getelementptr inbounds i8, ptr %1, i64 30
  %153 = load i8, ptr %152, align 1, !tbaa !5
  %154 = xor i8 %153, %151
  %155 = getelementptr inbounds i8, ptr %0, i64 30
  store i8 %154, ptr %155, align 1, !tbaa !5
  %156 = load i8, ptr getelementptr inbounds (i8, ptr @blake2s_IV, i64 31), align 1, !tbaa !5
  %157 = getelementptr inbounds i8, ptr %1, i64 31
  %158 = load i8, ptr %157, align 1, !tbaa !5
  %159 = xor i8 %158, %156
  %160 = getelementptr inbounds i8, ptr %0, i64 31
  store i8 %159, ptr %160, align 1, !tbaa !5
  %161 = load i8, ptr %1, align 1, !tbaa !8
  %162 = zext i8 %161 to i64
  %163 = getelementptr inbounds i8, ptr %0, i64 120
  store i64 %162, ptr %163, align 8, !tbaa !12
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn 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" }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }

!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"}
!8 = !{!9, !6, i64 0}
!9 = !{!"blake2s_param__", !6, i64 0, !6, i64 1, !6, i64 2, !6, i64 3, !10, i64 4, !10, i64 8, !11, i64 12, !6, i64 14, !6, i64 15, !6, i64 16, !6, i64 24}
!10 = !{!"int", !6, i64 0}
!11 = !{!"short", !6, i64 0}
!12 = !{!13, !14, i64 120}
!13 = !{!"blake2s_state__", !6, i64 0, !6, i64 32, !6, i64 40, !6, i64 48, !14, i64 112, !14, i64 120, !6, i64 128}
!14 = !{!"long", !6, i64 0}


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