; LLVM IR from kala13x/libxutils :: src/crypt (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"

@.str = external hidden unnamed_addr constant [5 x i8], align 1

; 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: nounwind uwtable
declare dso_local i32 @XSHA256_Compute(ptr noundef, i64 noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @XSHA256_ComputeSum(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i8, align 1
  %11 = alloca [32 x i8], align 16
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i64 %3, ptr %9, align 8, !tbaa !9
  %12 = load i64, ptr %7, align 8, !tbaa !9
  %13 = icmp ult i64 %12, 65
  br i1 %13, label %17, label %14

14:                                               ; preds = %4
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %18

17:                                               ; preds = %14, %4
  store i32 -1, ptr %5, align 4
  br label %47

18:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %11) #3
  %19 = getelementptr inbounds [32 x i8], ptr %11, i64 0, i64 0
  %20 = load i64, ptr %7, align 8, !tbaa !9
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = load i64, ptr %9, align 8, !tbaa !9
  %23 = call i32 @XSHA256_Compute(ptr noundef %19, i64 noundef %20, ptr noundef %21, i64 noundef %22)
  store i8 0, ptr %10, align 1, !tbaa !11
  br label %24

24:                                               ; preds = %41, %18
  %25 = load i8, ptr %10, align 1, !tbaa !11
  %26 = zext i8 %25 to i32
  %27 = icmp slt i32 %26, 32
  br i1 %27, label %28, label %44

28:                                               ; preds = %24
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = load i8, ptr %10, align 1, !tbaa !11
  %31 = zext i8 %30 to i32
  %32 = mul nsw i32 %31, 2
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i8, ptr %29, i64 %33
  %35 = load i8, ptr %10, align 1, !tbaa !11
  %36 = zext i8 %35 to i64
  %37 = getelementptr inbounds [32 x i8], ptr %11, i64 0, i64 %36
  %38 = load i8, ptr %37, align 1, !tbaa !11
  %39 = zext i8 %38 to i32
  %40 = call i64 (ptr, i64, ptr, ...) @xstrncpyf(ptr noundef %34, i64 noundef 3, ptr noundef @.str, i32 noundef %39)
  br label %41

41:                                               ; preds = %28
  %42 = load i8, ptr %10, align 1, !tbaa !11
  %43 = add i8 %42, 1
  store i8 %43, ptr %10, align 1, !tbaa !11
  br label %24, !llvm.loop !12

44:                                               ; preds = %24
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds i8, ptr %45, i64 64
  store i8 0, ptr %46, align 1, !tbaa !11
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #3
  br label %47

47:                                               ; preds = %44, %17
  %48 = load i32, ptr %5, align 4
  ret i32 %48
}

declare i64 @xstrncpyf(ptr noundef, i64 noundef, ptr noundef, ...) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!7, !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"

@.str = external hidden unnamed_addr constant [5 x i8], align 1

; 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

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @XSHA256_ComputeSum(ptr noundef %0, i64 noundef %1, ptr noundef %2, i64 noundef %3) local_unnamed_addr #1 {
  %5 = alloca [32 x i8], align 16
  %6 = icmp ult i64 %1, 65
  %7 = icmp eq ptr %0, null
  %or.cond = or i1 %7, %6
  br i1 %or.cond, label %169, label %8

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

169:                                              ; preds = %4, %8
  %.012 = phi i32 [ 1, %8 ], [ -1, %4 ]
  ret i32 %.012
}

declare i64 @xstrncpyf(ptr noundef, i64 noundef, ptr noundef, ...) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass