; LLVM IR from tleonhardt/practical_cryptography_engineering :: mbedtls (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"

%struct.mbedtls_sha256_context = type { [2 x i32], [8 x i32], [64 x i8], i32 }

@.str = external hidden unnamed_addr constant [26 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1
@sha256_test_buf = external hidden constant [3 x [57 x i8]], align 16
@sha256_test_buflen = external hidden constant [3 x i32], align 4
@sha256_test_sum = external hidden constant [6 x [32 x i8]], align 16
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_sha256_init(ptr noundef) #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_sha256_free(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_sha256_starts(ptr noundef, i32 noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_sha256_update(ptr noundef, ptr noundef, i64 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_sha256_finish(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_sha256_self_test(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca [32 x i8], align 16
  %11 = alloca %struct.mbedtls_sha256_context, align 4
  %12 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 0, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 32, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 108, ptr %11) #7
  %13 = call noalias ptr @calloc(i64 noundef 1024, i64 noundef 1) #8
  store ptr %13, ptr %9, align 8, !tbaa !9
  %14 = load ptr, ptr %9, align 8, !tbaa !9
  %15 = icmp eq ptr null, %14
  br i1 %15, label %16, label %22

16:                                               ; preds = %1
  %17 = load i32, ptr %3, align 4, !tbaa !5
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %21

19:                                               ; preds = %16
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  br label %21

21:                                               ; preds = %19, %16
  store i32 1, ptr %2, align 4
  store i32 1, ptr %12, align 4
  br label %105

22:                                               ; preds = %1
  call void @mbedtls_sha256_init(ptr noundef %11)
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %93, %22
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = icmp slt i32 %24, 6
  br i1 %25, label %26, label %96

26:                                               ; preds = %23
  %27 = load i32, ptr %4, align 4, !tbaa !5
  %28 = srem i32 %27, 3
  store i32 %28, ptr %5, align 4, !tbaa !5
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = icmp slt i32 %29, 3
  %31 = zext i1 %30 to i32
  store i32 %31, ptr %6, align 4, !tbaa !5
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = icmp ne i32 %32, 0
  br i1 %33, label %34, label %41

34:                                               ; preds = %26
  %35 = load i32, ptr %6, align 4, !tbaa !5
  %36 = mul nsw i32 %35, 32
  %37 = sub nsw i32 256, %36
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %37, i32 noundef %39)
  br label %41

41:                                               ; preds = %34, %26
  %42 = load i32, ptr %6, align 4, !tbaa !5
  call void @mbedtls_sha256_starts(ptr noundef %11, i32 noundef %42)
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = icmp eq i32 %43, 2
  br i1 %44, label %45, label %58

45:                                               ; preds = %41
  %46 = load ptr, ptr %9, align 8, !tbaa !9
  store i32 1000, ptr %7, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 1 %46, i8 97, i64 1000, i1 false)
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %54, %45
  %48 = load i32, ptr %5, align 4, !tbaa !5
  %49 = icmp slt i32 %48, 1000
  br i1 %49, label %50, label %57

50:                                               ; preds = %47
  %51 = load ptr, ptr %9, align 8, !tbaa !9
  %52 = load i32, ptr %7, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  call void @mbedtls_sha256_update(ptr noundef %11, ptr noundef %51, i64 noundef %53)
  br label %54

54:                                               ; preds = %50
  %55 = load i32, ptr %5, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %5, align 4, !tbaa !5
  br label %47, !llvm.loop !11

57:                                               ; preds = %47
  br label %68

58:                                               ; preds = %41
  %59 = load i32, ptr %5, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [3 x [57 x i8]], ptr @sha256_test_buf, i64 0, i64 %60
  %62 = getelementptr inbounds [57 x i8], ptr %61, i64 0, i64 0
  %63 = load i32, ptr %5, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [3 x i32], ptr @sha256_test_buflen, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  call void @mbedtls_sha256_update(ptr noundef %11, ptr noundef %62, i64 noundef %67)
  br label %68

68:                                               ; preds = %58, %57
  %69 = getelementptr inbounds [32 x i8], ptr %10, i64 0, i64 0
  call void @mbedtls_sha256_finish(ptr noundef %11, ptr noundef %69)
  %70 = getelementptr inbounds [32 x i8], ptr %10, i64 0, i64 0
  %71 = load i32, ptr %4, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [6 x [32 x i8]], ptr @sha256_test_sum, i64 0, i64 %72
  %74 = getelementptr inbounds [32 x i8], ptr %73, i64 0, i64 0
  %75 = load i32, ptr %6, align 4, !tbaa !5
  %76 = mul nsw i32 %75, 4
  %77 = sub nsw i32 32, %76
  %78 = sext i32 %77 to i64
  %79 = call i32 @memcmp(ptr noundef %70, ptr noundef %74, i64 noundef %78) #9
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %87

81:                                               ; preds = %68
  %82 = load i32, ptr %3, align 4, !tbaa !5
  %83 = icmp ne i32 %82, 0
  br i1 %83, label %84, label %86

84:                                               ; preds = %81
  %85 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %86

86:                                               ; preds = %84, %81
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %102

87:                                               ; preds = %68
  %88 = load i32, ptr %3, align 4, !tbaa !5
  %89 = icmp ne i32 %88, 0
  br i1 %89, label %90, label %92

90:                                               ; preds = %87
  %91 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  br label %92

92:                                               ; preds = %90, %87
  br label %93

93:                                               ; preds = %92
  %94 = load i32, ptr %4, align 4, !tbaa !5
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %4, align 4, !tbaa !5
  br label %23, !llvm.loop !13

96:                                               ; preds = %23
  %97 = load i32, ptr %3, align 4, !tbaa !5
  %98 = icmp ne i32 %97, 0
  br i1 %98, label %99, label %101

99:                                               ; preds = %96
  %100 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %101

101:                                              ; preds = %99, %96
  br label %102

102:                                              ; preds = %101, %86
  call void @mbedtls_sha256_free(ptr noundef %11)
  %103 = load ptr, ptr %9, align 8, !tbaa !9
  call void @free(ptr noundef %103) #7
  %104 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %104, ptr %2, align 4
  store i32 1, ptr %12, align 4
  br label %105

105:                                              ; preds = %102, %21
  call void @llvm.lifetime.end.p0(i64 108, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  %106 = load i32, ptr %2, align 4
  ret i32 %106
}

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #3

declare i32 @printf(ptr noundef, ...) #4

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #5

; Function Attrs: nounwind
declare void @free(ptr noundef) #6

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 nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind allocsize(0,1) "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 #4 = { "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 #5 = { nounwind willreturn memory(read) "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 #6 = { nounwind "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 #7 = { nounwind }
attributes #8 = { nounwind allocsize(0,1) }
attributes #9 = { nounwind willreturn memory(read) }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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

%struct.mbedtls_sha256_context = type { [2 x i32], [8 x i32], [64 x i8], i32 }

@.str = external hidden unnamed_addr constant [26 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [20 x i8], align 1
@sha256_test_buf = external hidden constant [3 x [57 x i8]], align 16
@sha256_test_buflen = external hidden local_unnamed_addr constant [3 x i32], align 4
@sha256_test_sum = external hidden constant [6 x [32 x i8]], align 16
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_sha256_init(ptr noundef) local_unnamed_addr #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

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_sha256_free(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_sha256_starts(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_sha256_update(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @mbedtls_sha256_finish(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @mbedtls_sha256_self_test(i32 noundef %0) local_unnamed_addr #0 {
  %2 = alloca [32 x i8], align 16
  %3 = alloca %struct.mbedtls_sha256_context, align 4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #7
  call void @llvm.lifetime.start.p0(i64 108, ptr nonnull %3) #7
  %4 = tail call noalias dereferenceable_or_null(1024) ptr @calloc(i64 noundef 1024, i64 noundef 1) #8
  %5 = icmp eq ptr %4, null
  br i1 %5, label %6, label %9

6:                                                ; preds = %1
  %.not32 = icmp eq i32 %0, 0
  br i1 %.not32, label %51, label %7

7:                                                ; preds = %6
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  br label %51

9:                                                ; preds = %1
  call void @mbedtls_sha256_init(ptr noundef nonnull %3)
  %.not30 = icmp eq i32 %0, 0
  br i1 %.not30, label %.loopexit.us, label %.loopexit

.loopexit.us:                                     ; preds = %9
  call void @mbedtls_sha256_starts(ptr noundef nonnull %3, i32 noundef 1)
  %10 = load i32, ptr @sha256_test_buflen, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  call void @mbedtls_sha256_update(ptr noundef nonnull %3, ptr noundef nonnull @sha256_test_buf, i64 noundef %11)
  call void @mbedtls_sha256_finish(ptr noundef nonnull %3, ptr noundef nonnull %2)
  %bcmp.us = call i32 @bcmp(ptr noundef nonnull dereferenceable(28) %2, ptr noundef nonnull dereferenceable(28) @sha256_test_sum, i64 28)
  %.not31.us = icmp eq i32 %bcmp.us, 0
  br i1 %.not31.us, label %.loopexit.us.1, label %.critedge

.loopexit.us.1:                                   ; preds = %.loopexit.us
  call void @mbedtls_sha256_starts(ptr noundef nonnull %3, i32 noundef 1)
  %12 = load i32, ptr getelementptr inbounds (i8, ptr @sha256_test_buflen, i64 4), align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  call void @mbedtls_sha256_update(ptr noundef nonnull %3, ptr noundef nonnull getelementptr inbounds (i8, ptr @sha256_test_buf, i64 57), i64 noundef %13)
  call void @mbedtls_sha256_finish(ptr noundef nonnull %3, ptr noundef nonnull %2)
  %bcmp.us.1 = call i32 @bcmp(ptr noundef nonnull dereferenceable(28) %2, ptr noundef nonnull dereferenceable(28) getelementptr inbounds (i8, ptr @sha256_test_sum, i64 32), i64 28)
  %.not31.us.1 = icmp eq i32 %bcmp.us.1, 0
  br i1 %.not31.us.1, label %14, label %.critedge

14:                                               ; preds = %.loopexit.us.1
  call void @mbedtls_sha256_starts(ptr noundef nonnull %3, i32 noundef 1)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(1000) %4, i8 97, i64 1000, i1 false)
  br label %15

15:                                               ; preds = %15, %14
  %.02733.us.2 = phi i32 [ 0, %14 ], [ %16, %15 ]
  call void @mbedtls_sha256_update(ptr noundef nonnull %3, ptr noundef nonnull %4, i64 noundef 1000)
  %16 = add nuw nsw i32 %.02733.us.2, 1
  %exitcond.246.not = icmp eq i32 %16, 1000
  br i1 %exitcond.246.not, label %.loopexit.us.2, label %15, !llvm.loop !9

.loopexit.us.2:                                   ; preds = %15
  call void @mbedtls_sha256_finish(ptr noundef nonnull %3, ptr noundef nonnull %2)
  %bcmp.us.2 = call i32 @bcmp(ptr noundef nonnull dereferenceable(28) %2, ptr noundef nonnull dereferenceable(28) getelementptr inbounds (i8, ptr @sha256_test_sum, i64 64), i64 28)
  %.not31.us.2 = icmp eq i32 %bcmp.us.2, 0
  br i1 %.not31.us.2, label %.loopexit.us.3, label %.critedge

.loopexit.us.3:                                   ; preds = %.loopexit.us.2
  call void @mbedtls_sha256_starts(ptr noundef nonnull %3, i32 noundef 0)
  %17 = load i32, ptr @sha256_test_buflen, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  call void @mbedtls_sha256_update(ptr noundef nonnull %3, ptr noundef nonnull @sha256_test_buf, i64 noundef %18)
  call void @mbedtls_sha256_finish(ptr noundef nonnull %3, ptr noundef nonnull %2)
  %bcmp.us.3 = call i32 @bcmp(ptr noundef nonnull dereferenceable(32) %2, ptr noundef nonnull dereferenceable(32) getelementptr inbounds (i8, ptr @sha256_test_sum, i64 96), i64 32)
  %.not31.us.3 = icmp eq i32 %bcmp.us.3, 0
  br i1 %.not31.us.3, label %.loopexit.us.4, label %.critedge

.loopexit.us.4:                                   ; preds = %.loopexit.us.3
  call void @mbedtls_sha256_starts(ptr noundef nonnull %3, i32 noundef 0)
  %19 = load i32, ptr getelementptr inbounds (i8, ptr @sha256_test_buflen, i64 4), align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  call void @mbedtls_sha256_update(ptr noundef nonnull %3, ptr noundef nonnull getelementptr inbounds (i8, ptr @sha256_test_buf, i64 57), i64 noundef %20)
  call void @mbedtls_sha256_finish(ptr noundef nonnull %3, ptr noundef nonnull %2)
  %bcmp.us.4 = call i32 @bcmp(ptr noundef nonnull dereferenceable(32) %2, ptr noundef nonnull dereferenceable(32) getelementptr inbounds (i8, ptr @sha256_test_sum, i64 128), i64 32)
  %.not31.us.4 = icmp eq i32 %bcmp.us.4, 0
  br i1 %.not31.us.4, label %21, label %.critedge

21:                                               ; preds = %.loopexit.us.4
  call void @mbedtls_sha256_starts(ptr noundef nonnull %3, i32 noundef 0)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(1000) %4, i8 97, i64 1000, i1 false)
  br label %22

22:                                               ; preds = %22, %21
  %.02733.us.5 = phi i32 [ 0, %21 ], [ %23, %22 ]
  call void @mbedtls_sha256_update(ptr noundef nonnull %3, ptr noundef nonnull %4, i64 noundef 1000)
  %23 = add nuw nsw i32 %.02733.us.5, 1
  %exitcond.547.not = icmp eq i32 %23, 1000
  br i1 %exitcond.547.not, label %.loopexit.us.5, label %22, !llvm.loop !9

.loopexit.us.5:                                   ; preds = %22
  call void @mbedtls_sha256_finish(ptr noundef nonnull %3, ptr noundef nonnull %2)
  %bcmp.us.5 = call i32 @bcmp(ptr noundef nonnull dereferenceable(32) %2, ptr noundef nonnull dereferenceable(32) getelementptr inbounds (i8, ptr @sha256_test_sum, i64 160), i64 32)
  %.not31.us.5 = icmp ne i32 %bcmp.us.5, 0
  %brmerge = or i1 %.not31.us.5, %.not30
  %.mux = zext i1 %.not31.us.5 to i32
  br i1 %brmerge, label %.critedge, label %.critedge.sink.split

.loopexit:                                        ; preds = %9
  %24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef 224, i32 noundef 1)
  call void @mbedtls_sha256_starts(ptr noundef nonnull %3, i32 noundef 1)
  %25 = load i32, ptr @sha256_test_buflen, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  call void @mbedtls_sha256_update(ptr noundef nonnull %3, ptr noundef nonnull @sha256_test_buf, i64 noundef %26)
  call void @mbedtls_sha256_finish(ptr noundef nonnull %3, ptr noundef nonnull %2)
  %bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(28) %2, ptr noundef nonnull dereferenceable(28) @sha256_test_sum, i64 28)
  %.not31 = icmp eq i32 %bcmp, 0
  br i1 %.not31, label %.loopexit.1, label %.critedge.sink.split

.loopexit.1:                                      ; preds = %.loopexit
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %28 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef 224, i32 noundef 2)
  call void @mbedtls_sha256_starts(ptr noundef nonnull %3, i32 noundef 1)
  %29 = load i32, ptr getelementptr inbounds (i8, ptr @sha256_test_buflen, i64 4), align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  call void @mbedtls_sha256_update(ptr noundef nonnull %3, ptr noundef nonnull getelementptr inbounds (i8, ptr @sha256_test_buf, i64 57), i64 noundef %30)
  call void @mbedtls_sha256_finish(ptr noundef nonnull %3, ptr noundef nonnull %2)
  %bcmp.1 = call i32 @bcmp(ptr noundef nonnull dereferenceable(28) %2, ptr noundef nonnull dereferenceable(28) getelementptr inbounds (i8, ptr @sha256_test_sum, i64 32), i64 28)
  %.not31.1 = icmp eq i32 %bcmp.1, 0
  br i1 %.not31.1, label %31, label %.critedge.sink.split

31:                                               ; preds = %.loopexit.1
  %32 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %33 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef 224, i32 noundef 3)
  call void @mbedtls_sha256_starts(ptr noundef nonnull %3, i32 noundef 1)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(1000) %4, i8 97, i64 1000, i1 false)
  br label %34

34:                                               ; preds = %34, %31
  %.02733.2 = phi i32 [ 0, %31 ], [ %35, %34 ]
  call void @mbedtls_sha256_update(ptr noundef nonnull %3, ptr noundef nonnull %4, i64 noundef 1000)
  %35 = add nuw nsw i32 %.02733.2, 1
  %exitcond.2.not = icmp eq i32 %35, 1000
  br i1 %exitcond.2.not, label %.loopexit.2, label %34, !llvm.loop !9

.loopexit.2:                                      ; preds = %34
  call void @mbedtls_sha256_finish(ptr noundef nonnull %3, ptr noundef nonnull %2)
  %bcmp.2 = call i32 @bcmp(ptr noundef nonnull dereferenceable(28) %2, ptr noundef nonnull dereferenceable(28) getelementptr inbounds (i8, ptr @sha256_test_sum, i64 64), i64 28)
  %.not31.2 = icmp eq i32 %bcmp.2, 0
  br i1 %.not31.2, label %.loopexit.3, label %.critedge.sink.split

.loopexit.3:                                      ; preds = %.loopexit.2
  %36 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %37 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef 256, i32 noundef 1)
  call void @mbedtls_sha256_starts(ptr noundef nonnull %3, i32 noundef 0)
  %38 = load i32, ptr @sha256_test_buflen, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  call void @mbedtls_sha256_update(ptr noundef nonnull %3, ptr noundef nonnull @sha256_test_buf, i64 noundef %39)
  call void @mbedtls_sha256_finish(ptr noundef nonnull %3, ptr noundef nonnull %2)
  %bcmp.3 = call i32 @bcmp(ptr noundef nonnull dereferenceable(32) %2, ptr noundef nonnull dereferenceable(32) getelementptr inbounds (i8, ptr @sha256_test_sum, i64 96), i64 32)
  %.not31.3 = icmp eq i32 %bcmp.3, 0
  br i1 %.not31.3, label %.loopexit.4, label %.critedge.sink.split

.loopexit.4:                                      ; preds = %.loopexit.3
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %41 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef 256, i32 noundef 2)
  call void @mbedtls_sha256_starts(ptr noundef nonnull %3, i32 noundef 0)
  %42 = load i32, ptr getelementptr inbounds (i8, ptr @sha256_test_buflen, i64 4), align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  call void @mbedtls_sha256_update(ptr noundef nonnull %3, ptr noundef nonnull getelementptr inbounds (i8, ptr @sha256_test_buf, i64 57), i64 noundef %43)
  call void @mbedtls_sha256_finish(ptr noundef nonnull %3, ptr noundef nonnull %2)
  %bcmp.4 = call i32 @bcmp(ptr noundef nonnull dereferenceable(32) %2, ptr noundef nonnull dereferenceable(32) getelementptr inbounds (i8, ptr @sha256_test_sum, i64 128), i64 32)
  %.not31.4 = icmp eq i32 %bcmp.4, 0
  br i1 %.not31.4, label %44, label %.critedge.sink.split

44:                                               ; preds = %.loopexit.4
  %45 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %46 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef 256, i32 noundef 3)
  call void @mbedtls_sha256_starts(ptr noundef nonnull %3, i32 noundef 0)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(1000) %4, i8 97, i64 1000, i1 false)
  br label %47

47:                                               ; preds = %47, %44
  %.02733.5 = phi i32 [ 0, %44 ], [ %48, %47 ]
  call void @mbedtls_sha256_update(ptr noundef nonnull %3, ptr noundef nonnull %4, i64 noundef 1000)
  %48 = add nuw nsw i32 %.02733.5, 1
  %exitcond.5.not = icmp eq i32 %48, 1000
  br i1 %exitcond.5.not, label %.loopexit.5, label %47, !llvm.loop !9

.loopexit.5:                                      ; preds = %47
  call void @mbedtls_sha256_finish(ptr noundef nonnull %3, ptr noundef nonnull %2)
  %bcmp.5 = call i32 @bcmp(ptr noundef nonnull dereferenceable(32) %2, ptr noundef nonnull dereferenceable(32) getelementptr inbounds (i8, ptr @sha256_test_sum, i64 160), i64 32)
  %.not31.5 = icmp eq i32 %bcmp.5, 0
  br i1 %.not31.5, label %.split38.us.loopexit39, label %.critedge.sink.split

.split38.us.loopexit39:                           ; preds = %.loopexit.5
  %49 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br i1 %.not30, label %.critedge, label %.critedge.sink.split

.critedge.sink.split:                             ; preds = %.split38.us.loopexit39, %.loopexit.us.5, %.loopexit, %.loopexit.1, %.loopexit.2, %.loopexit.3, %.loopexit.4, %.loopexit.5
  %.str.2.sink = phi ptr [ @.str.2, %.loopexit.5 ], [ @.str.2, %.loopexit.4 ], [ @.str.2, %.loopexit.3 ], [ @.str.2, %.loopexit.2 ], [ @.str.2, %.loopexit.1 ], [ @.str.2, %.loopexit ], [ @.str.4, %.loopexit.us.5 ], [ @.str.4, %.split38.us.loopexit39 ]
  %.025.ph = phi i32 [ 1, %.loopexit.5 ], [ 1, %.loopexit.4 ], [ 1, %.loopexit.3 ], [ 1, %.loopexit.2 ], [ 1, %.loopexit.1 ], [ 1, %.loopexit ], [ 0, %.loopexit.us.5 ], [ 0, %.split38.us.loopexit39 ]
  %50 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.2.sink)
  br label %.critedge

.critedge:                                        ; preds = %.critedge.sink.split, %.loopexit.us.5, %.loopexit.us, %.loopexit.us.1, %.loopexit.us.2, %.loopexit.us.3, %.loopexit.us.4, %.split38.us.loopexit39
  %.025 = phi i32 [ 0, %.split38.us.loopexit39 ], [ %.mux, %.loopexit.us.5 ], [ 1, %.loopexit.us.4 ], [ 1, %.loopexit.us.3 ], [ 1, %.loopexit.us.2 ], [ 1, %.loopexit.us.1 ], [ 1, %.loopexit.us ], [ %.025.ph, %.critedge.sink.split ]
  call void @mbedtls_sha256_free(ptr noundef nonnull %3)
  call void @free(ptr noundef %4) #7
  br label %51

51:                                               ; preds = %6, %7, %.critedge
  %.0 = phi i32 [ %.025, %.critedge ], [ 1, %7 ], [ 1, %6 ]
  call void @llvm.lifetime.end.p0(i64 108, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #7
  ret i32 %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #5

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #6

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #4 = { nofree nounwind "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 #5 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #6 = { nofree nounwind willreturn memory(argmem: read) }
attributes #7 = { nounwind }
attributes #8 = { nounwind allocsize(0,1) }

!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/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass