; LLVM IR from BabitMF/bmf :: bmf_lite/src/algorithm/modules/operators/utils (SHA256)

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

%"class.bmf_lite::SHA256" = type { [64 x i8], i32, i64, [8 x i32] }

; 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: mustprogress nounwind uwtable
define dso_local void @_ZN8bmf_lite6SHA2566revertERSt5arrayIhLm32EE(ptr noundef nonnull align 8 dereferenceable(112) %0, ptr noundef nonnull align 1 dereferenceable(32) %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #2
  store i8 0, ptr %5, align 1, !tbaa !9
  br label %9

9:                                                ; preds = %46, %2
  %10 = load i8, ptr %5, align 1, !tbaa !9
  %11 = zext i8 %10 to i32
  %12 = icmp slt i32 %11, 4
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #2
  br label %49

14:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #2
  store i8 0, ptr %7, align 1, !tbaa !9
  br label %15

15:                                               ; preds = %42, %14
  %16 = load i8, ptr %7, align 1, !tbaa !9
  %17 = zext i8 %16 to i32
  %18 = icmp slt i32 %17, 8
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #2
  br label %45

20:                                               ; preds = %15
  %21 = getelementptr inbounds %"class.bmf_lite::SHA256", ptr %8, i32 0, i32 3
  %22 = load i8, ptr %7, align 1, !tbaa !9
  %23 = zext i8 %22 to i64
  %24 = getelementptr inbounds [8 x i32], ptr %21, i64 0, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !10
  %26 = load i8, ptr %5, align 1, !tbaa !9
  %27 = zext i8 %26 to i32
  %28 = mul nsw i32 %27, 8
  %29 = sub nsw i32 24, %28
  %30 = lshr i32 %25, %29
  %31 = and i32 %30, 255
  %32 = trunc i32 %31 to i8
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = load i8, ptr %5, align 1, !tbaa !9
  %35 = zext i8 %34 to i32
  %36 = load i8, ptr %7, align 1, !tbaa !9
  %37 = zext i8 %36 to i32
  %38 = mul nsw i32 %37, 4
  %39 = add nsw i32 %35, %38
  %40 = sext i32 %39 to i64
  %41 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %33, i64 noundef %40) #2
  store i8 %32, ptr %41, align 1, !tbaa !9
  br label %42

42:                                               ; preds = %20
  %43 = load i8, ptr %7, align 1, !tbaa !9
  %44 = add i8 %43, 1
  store i8 %44, ptr %7, align 1, !tbaa !9
  br label %15, !llvm.loop !12

45:                                               ; preds = %19
  br label %46

46:                                               ; preds = %45
  %47 = load i8, ptr %5, align 1, !tbaa !9
  %48 = add i8 %47, 1
  store i8 %48, ptr %5, align 1, !tbaa !9
  br label %9, !llvm.loop !14

49:                                               ; preds = %13
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32), i64 noundef) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; 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
define dso_local void @_ZN8bmf_lite6SHA2566revertERSt5arrayIhLm32EE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(112) %0, ptr noundef nonnull align 1 dereferenceable(32) %1) local_unnamed_addr #0 align 2 {
.preheader:
  %2 = getelementptr inbounds i8, ptr %0, i64 80
  %3 = load i32, ptr %2, align 8, !tbaa !5
  %4 = lshr i32 %3, 24
  %5 = trunc nuw i32 %4 to i8
  %6 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 0) #1
  store i8 %5, ptr %6, align 1, !tbaa !9
  %7 = getelementptr inbounds i8, ptr %0, i64 84
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = lshr i32 %8, 24
  %10 = trunc nuw i32 %9 to i8
  %11 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 4) #1
  store i8 %10, ptr %11, align 1, !tbaa !9
  %12 = getelementptr inbounds i8, ptr %0, i64 88
  %13 = load i32, ptr %12, align 8, !tbaa !5
  %14 = lshr i32 %13, 24
  %15 = trunc nuw i32 %14 to i8
  %16 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 8) #1
  store i8 %15, ptr %16, align 1, !tbaa !9
  %17 = getelementptr inbounds i8, ptr %0, i64 92
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = lshr i32 %18, 24
  %20 = trunc nuw i32 %19 to i8
  %21 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 12) #1
  store i8 %20, ptr %21, align 1, !tbaa !9
  %22 = getelementptr inbounds i8, ptr %0, i64 96
  %23 = load i32, ptr %22, align 8, !tbaa !5
  %24 = lshr i32 %23, 24
  %25 = trunc nuw i32 %24 to i8
  %26 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 16) #1
  store i8 %25, ptr %26, align 1, !tbaa !9
  %27 = getelementptr inbounds i8, ptr %0, i64 100
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = lshr i32 %28, 24
  %30 = trunc nuw i32 %29 to i8
  %31 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 20) #1
  store i8 %30, ptr %31, align 1, !tbaa !9
  %32 = getelementptr inbounds i8, ptr %0, i64 104
  %33 = load i32, ptr %32, align 8, !tbaa !5
  %34 = lshr i32 %33, 24
  %35 = trunc nuw i32 %34 to i8
  %36 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 24) #1
  store i8 %35, ptr %36, align 1, !tbaa !9
  %37 = getelementptr inbounds i8, ptr %0, i64 108
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = lshr i32 %38, 24
  %40 = trunc nuw i32 %39 to i8
  %41 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 28) #1
  store i8 %40, ptr %41, align 1, !tbaa !9
  %42 = load i32, ptr %2, align 8, !tbaa !5
  %43 = lshr i32 %42, 16
  %44 = trunc i32 %43 to i8
  %45 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 1) #1
  store i8 %44, ptr %45, align 1, !tbaa !9
  %46 = load i32, ptr %7, align 4, !tbaa !5
  %47 = lshr i32 %46, 16
  %48 = trunc i32 %47 to i8
  %49 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 5) #1
  store i8 %48, ptr %49, align 1, !tbaa !9
  %50 = load i32, ptr %12, align 8, !tbaa !5
  %51 = lshr i32 %50, 16
  %52 = trunc i32 %51 to i8
  %53 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 9) #1
  store i8 %52, ptr %53, align 1, !tbaa !9
  %54 = load i32, ptr %17, align 4, !tbaa !5
  %55 = lshr i32 %54, 16
  %56 = trunc i32 %55 to i8
  %57 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 13) #1
  store i8 %56, ptr %57, align 1, !tbaa !9
  %58 = load i32, ptr %22, align 8, !tbaa !5
  %59 = lshr i32 %58, 16
  %60 = trunc i32 %59 to i8
  %61 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 17) #1
  store i8 %60, ptr %61, align 1, !tbaa !9
  %62 = load i32, ptr %27, align 4, !tbaa !5
  %63 = lshr i32 %62, 16
  %64 = trunc i32 %63 to i8
  %65 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 21) #1
  store i8 %64, ptr %65, align 1, !tbaa !9
  %66 = load i32, ptr %32, align 8, !tbaa !5
  %67 = lshr i32 %66, 16
  %68 = trunc i32 %67 to i8
  %69 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 25) #1
  store i8 %68, ptr %69, align 1, !tbaa !9
  %70 = load i32, ptr %37, align 4, !tbaa !5
  %71 = lshr i32 %70, 16
  %72 = trunc i32 %71 to i8
  %73 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 29) #1
  store i8 %72, ptr %73, align 1, !tbaa !9
  %74 = load i32, ptr %2, align 8, !tbaa !5
  %75 = lshr i32 %74, 8
  %76 = trunc i32 %75 to i8
  %77 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 2) #1
  store i8 %76, ptr %77, align 1, !tbaa !9
  %78 = load i32, ptr %7, align 4, !tbaa !5
  %79 = lshr i32 %78, 8
  %80 = trunc i32 %79 to i8
  %81 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 6) #1
  store i8 %80, ptr %81, align 1, !tbaa !9
  %82 = load i32, ptr %12, align 8, !tbaa !5
  %83 = lshr i32 %82, 8
  %84 = trunc i32 %83 to i8
  %85 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 10) #1
  store i8 %84, ptr %85, align 1, !tbaa !9
  %86 = load i32, ptr %17, align 4, !tbaa !5
  %87 = lshr i32 %86, 8
  %88 = trunc i32 %87 to i8
  %89 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 14) #1
  store i8 %88, ptr %89, align 1, !tbaa !9
  %90 = load i32, ptr %22, align 8, !tbaa !5
  %91 = lshr i32 %90, 8
  %92 = trunc i32 %91 to i8
  %93 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 18) #1
  store i8 %92, ptr %93, align 1, !tbaa !9
  %94 = load i32, ptr %27, align 4, !tbaa !5
  %95 = lshr i32 %94, 8
  %96 = trunc i32 %95 to i8
  %97 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 22) #1
  store i8 %96, ptr %97, align 1, !tbaa !9
  %98 = load i32, ptr %32, align 8, !tbaa !5
  %99 = lshr i32 %98, 8
  %100 = trunc i32 %99 to i8
  %101 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 26) #1
  store i8 %100, ptr %101, align 1, !tbaa !9
  %102 = load i32, ptr %37, align 4, !tbaa !5
  %103 = lshr i32 %102, 8
  %104 = trunc i32 %103 to i8
  %105 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 30) #1
  store i8 %104, ptr %105, align 1, !tbaa !9
  %106 = load i32, ptr %2, align 8, !tbaa !5
  %107 = trunc i32 %106 to i8
  %108 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 3) #1
  store i8 %107, ptr %108, align 1, !tbaa !9
  %109 = load i32, ptr %7, align 4, !tbaa !5
  %110 = trunc i32 %109 to i8
  %111 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 7) #1
  store i8 %110, ptr %111, align 1, !tbaa !9
  %112 = load i32, ptr %12, align 8, !tbaa !5
  %113 = trunc i32 %112 to i8
  %114 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 11) #1
  store i8 %113, ptr %114, align 1, !tbaa !9
  %115 = load i32, ptr %17, align 4, !tbaa !5
  %116 = trunc i32 %115 to i8
  %117 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 15) #1
  store i8 %116, ptr %117, align 1, !tbaa !9
  %118 = load i32, ptr %22, align 8, !tbaa !5
  %119 = trunc i32 %118 to i8
  %120 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 19) #1
  store i8 %119, ptr %120, align 1, !tbaa !9
  %121 = load i32, ptr %27, align 4, !tbaa !5
  %122 = trunc i32 %121 to i8
  %123 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 23) #1
  store i8 %122, ptr %123, align 1, !tbaa !9
  %124 = load i32, ptr %32, align 8, !tbaa !5
  %125 = trunc i32 %124 to i8
  %126 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 27) #1
  store i8 %125, ptr %126, align 1, !tbaa !9
  %127 = load i32, ptr %37, align 4, !tbaa !5
  %128 = trunc i32 %127 to i8
  %129 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32) %1, i64 noundef 31) #1
  store i8 %128, ptr %129, align 1, !tbaa !9
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt5arrayIhLm32EEixEm(ptr noundef nonnull align 1 dereferenceable(32), i64 noundef) local_unnamed_addr #0 align 2

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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}


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