; LLVM IR from tleonhardt/practical_cryptography_engineering :: mbedtls (entropy)

; 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_entropy_context = type { %struct.mbedtls_sha512_context, i32, [20 x %struct.mbedtls_entropy_source_state] }
%struct.mbedtls_sha512_context = type { [2 x i64], [8 x i64], [128 x i8], i32 }
%struct.mbedtls_entropy_source_state = type { ptr, ptr, i64, i64, i32 }

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

declare void @mbedtls_sha512_starts(ptr noundef, i32 noundef) #1

; 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 hidden i32 @entropy_gather_internal(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_entropy_func(ptr noundef %0, ptr noundef %1, i64 noundef %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca [64 x i8], align 16
  %14 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %15, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr %13) #5
  %16 = load i64, ptr %7, align 8, !tbaa !9
  %17 = icmp ugt i64 %16, 64
  br i1 %17, label %18, label %19

18:                                               ; preds = %3
  store i32 -60, ptr %4, align 4
  store i32 1, ptr %14, align 4
  br label %99

19:                                               ; preds = %3
  br label %20

20:                                               ; preds = %59, %19
  %21 = load i32, ptr %9, align 4, !tbaa !11
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %9, align 4, !tbaa !11
  %23 = icmp sgt i32 %21, 256
  br i1 %23, label %24, label %25

24:                                               ; preds = %20
  store i32 -60, ptr %8, align 4, !tbaa !11
  br label %97

25:                                               ; preds = %20
  %26 = load ptr, ptr %12, align 8, !tbaa !5
  %27 = call i32 @entropy_gather_internal(ptr noundef %26)
  store i32 %27, ptr %8, align 4, !tbaa !11
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %25
  br label %97

30:                                               ; preds = %25
  store i32 1, ptr %11, align 4, !tbaa !11
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %31

31:                                               ; preds = %55, %30
  %32 = load i32, ptr %10, align 4, !tbaa !11
  %33 = load ptr, ptr %12, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.mbedtls_entropy_context, ptr %33, i32 0, i32 1
  %35 = load i32, ptr %34, align 8, !tbaa !13
  %36 = icmp slt i32 %32, %35
  br i1 %36, label %37, label %58

37:                                               ; preds = %31
  %38 = load ptr, ptr %12, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.mbedtls_entropy_context, ptr %38, i32 0, i32 2
  %40 = load i32, ptr %10, align 4, !tbaa !11
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %39, i64 0, i64 %41
  %43 = getelementptr inbounds %struct.mbedtls_entropy_source_state, ptr %42, i32 0, i32 2
  %44 = load i64, ptr %43, align 8, !tbaa !16
  %45 = load ptr, ptr %12, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.mbedtls_entropy_context, ptr %45, i32 0, i32 2
  %47 = load i32, ptr %10, align 4, !tbaa !11
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %46, i64 0, i64 %48
  %50 = getelementptr inbounds %struct.mbedtls_entropy_source_state, ptr %49, i32 0, i32 3
  %51 = load i64, ptr %50, align 8, !tbaa !18
  %52 = icmp ult i64 %44, %51
  br i1 %52, label %53, label %54

53:                                               ; preds = %37
  store i32 0, ptr %11, align 4, !tbaa !11
  br label %54

54:                                               ; preds = %53, %37
  br label %55

55:                                               ; preds = %54
  %56 = load i32, ptr %10, align 4, !tbaa !11
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %10, align 4, !tbaa !11
  br label %31, !llvm.loop !19

58:                                               ; preds = %31
  br label %59

59:                                               ; preds = %58
  %60 = load i32, ptr %11, align 4, !tbaa !11
  %61 = icmp ne i32 %60, 0
  %62 = xor i1 %61, true
  br i1 %62, label %20, label %63, !llvm.loop !21

63:                                               ; preds = %59
  %64 = getelementptr inbounds [64 x i8], ptr %13, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %64, i8 0, i64 64, i1 false)
  %65 = load ptr, ptr %12, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.mbedtls_entropy_context, ptr %65, i32 0, i32 0
  %67 = getelementptr inbounds [64 x i8], ptr %13, i64 0, i64 0
  call void @mbedtls_sha512_finish(ptr noundef %66, ptr noundef %67)
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.mbedtls_entropy_context, ptr %68, i32 0, i32 0
  call void @llvm.memset.p0.i64(ptr align 8 %69, i8 0, i64 216, i1 false)
  %70 = load ptr, ptr %12, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.mbedtls_entropy_context, ptr %70, i32 0, i32 0
  call void @mbedtls_sha512_starts(ptr noundef %71, i32 noundef 0)
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.mbedtls_entropy_context, ptr %72, i32 0, i32 0
  %74 = getelementptr inbounds [64 x i8], ptr %13, i64 0, i64 0
  call void @mbedtls_sha512_update(ptr noundef %73, ptr noundef %74, i64 noundef 64)
  %75 = getelementptr inbounds [64 x i8], ptr %13, i64 0, i64 0
  %76 = getelementptr inbounds [64 x i8], ptr %13, i64 0, i64 0
  call void @mbedtls_sha512(ptr noundef %75, i64 noundef 64, ptr noundef %76, i32 noundef 0)
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %77

77:                                               ; preds = %90, %63
  %78 = load i32, ptr %10, align 4, !tbaa !11
  %79 = load ptr, ptr %12, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.mbedtls_entropy_context, ptr %79, i32 0, i32 1
  %81 = load i32, ptr %80, align 8, !tbaa !13
  %82 = icmp slt i32 %78, %81
  br i1 %82, label %83, label %93

83:                                               ; preds = %77
  %84 = load ptr, ptr %12, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.mbedtls_entropy_context, ptr %84, i32 0, i32 2
  %86 = load i32, ptr %10, align 4, !tbaa !11
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %85, i64 0, i64 %87
  %89 = getelementptr inbounds %struct.mbedtls_entropy_source_state, ptr %88, i32 0, i32 2
  store i64 0, ptr %89, align 8, !tbaa !16
  br label %90

90:                                               ; preds = %83
  %91 = load i32, ptr %10, align 4, !tbaa !11
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %10, align 4, !tbaa !11
  br label %77, !llvm.loop !22

93:                                               ; preds = %77
  %94 = load ptr, ptr %6, align 8, !tbaa !5
  %95 = getelementptr inbounds [64 x i8], ptr %13, i64 0, i64 0
  %96 = load i64, ptr %7, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %94, ptr align 16 %95, i64 %96, i1 false)
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %97

97:                                               ; preds = %93, %29, %24
  %98 = load i32, ptr %8, align 4, !tbaa !11
  store i32 %98, ptr %4, align 4
  store i32 1, ptr %14, align 4
  br label %99

99:                                               ; preds = %97, %18
  call void @llvm.lifetime.end.p0(i64 64, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %100 = load i32, ptr %4, align 4
  ret i32 %100
}

declare void @mbedtls_sha512_finish(ptr noundef, ptr noundef) #1

declare void @mbedtls_sha512_update(ptr noundef, ptr noundef, i64 noundef) #1

declare void @mbedtls_sha512(ptr noundef, i64 noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 216}
!14 = !{!"", !15, i64 0, !12, i64 216, !7, i64 224}
!15 = !{!"", !7, i64 0, !7, i64 16, !7, i64 80, !12, i64 208}
!16 = !{!17, !10, i64 16}
!17 = !{!"", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 24, !12, i64 32}
!18 = !{!17, !10, i64 24}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = distinct !{!22, !20}


; 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_entropy_source_state = type { ptr, ptr, i64, i64, i32 }

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

declare void @mbedtls_sha512_starts(ptr noundef, i32 noundef) local_unnamed_addr #1

; 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 hidden i32 @entropy_gather_internal(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_entropy_func(ptr noundef %0, ptr nocapture noundef writeonly %1, i64 noundef %2) local_unnamed_addr #3 {
  %4 = alloca [64 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %4) #5
  %5 = icmp ugt i64 %2, 64
  br i1 %5, label %.loopexit, label %.preheader31

.preheader31:                                     ; preds = %3
  %6 = getelementptr inbounds i8, ptr %0, i64 216
  %7 = getelementptr inbounds i8, ptr %0, i64 224
  br label %8

8:                                                ; preds = %.preheader31, %._crit_edge
  %.027 = phi i32 [ %9, %._crit_edge ], [ 0, %.preheader31 ]
  %9 = add nuw nsw i32 %.027, 1
  %exitcond39 = icmp eq i32 %.027, 257
  br i1 %exitcond39, label %.loopexit, label %10

10:                                               ; preds = %8
  %11 = tail call i32 @entropy_gather_internal(ptr noundef %0)
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %10
  %12 = load i32, ptr %6, align 8, !tbaa !5
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph.preheader, label %._crit_edge.thread

.lr.ph.preheader:                                 ; preds = %.preheader
  %wide.trip.count = zext nneg i32 %12 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %14 = icmp ult i32 %12, 4
  br i1 %14, label %._crit_edge.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %.02433 = phi i32 [ 1, %.lr.ph.preheader.new ], [ %spec.select.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %15 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %7, i64 0, i64 %indvars.iv
  %16 = getelementptr inbounds i8, ptr %15, i64 16
  %17 = load i64, ptr %16, align 8, !tbaa !11
  %18 = getelementptr inbounds i8, ptr %15, i64 24
  %19 = load i64, ptr %18, align 8, !tbaa !15
  %20 = icmp ult i64 %17, %19
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %21 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %7, i64 0, i64 %indvars.iv.next
  %22 = getelementptr inbounds i8, ptr %21, i64 16
  %23 = load i64, ptr %22, align 8, !tbaa !11
  %24 = getelementptr inbounds i8, ptr %21, i64 24
  %25 = load i64, ptr %24, align 8, !tbaa !15
  %26 = icmp ult i64 %23, %25
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %27 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %7, i64 0, i64 %indvars.iv.next.1
  %28 = getelementptr inbounds i8, ptr %27, i64 16
  %29 = load i64, ptr %28, align 8, !tbaa !11
  %30 = getelementptr inbounds i8, ptr %27, i64 24
  %31 = load i64, ptr %30, align 8, !tbaa !15
  %32 = icmp ult i64 %29, %31
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %33 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %7, i64 0, i64 %indvars.iv.next.2
  %34 = getelementptr inbounds i8, ptr %33, i64 16
  %35 = load i64, ptr %34, align 8, !tbaa !11
  %36 = getelementptr inbounds i8, ptr %33, i64 24
  %37 = load i64, ptr %36, align 8, !tbaa !15
  %38 = icmp ult i64 %35, %37
  %39 = select i1 %38, i1 true, i1 %32
  %40 = select i1 %39, i1 true, i1 %26
  %41 = select i1 %40, i1 true, i1 %20
  %spec.select.3 = select i1 %41, i32 0, i32 %.02433
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.unr-lcssa, label %.lr.ph, !llvm.loop !16

._crit_edge.unr-lcssa:                            ; preds = %.lr.ph, %.lr.ph.preheader
  %spec.select.lcssa.ph = phi i32 [ poison, %.lr.ph.preheader ], [ %spec.select.3, %.lr.ph ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %.02433.unr = phi i32 [ 1, %.lr.ph.preheader ], [ %spec.select.3, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %._crit_edge.unr-lcssa ]
  %.02433.epil = phi i32 [ %spec.select.epil, %.lr.ph.epil ], [ %.02433.unr, %._crit_edge.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.unr-lcssa ]
  %42 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %7, i64 0, i64 %indvars.iv.epil
  %43 = getelementptr inbounds i8, ptr %42, i64 16
  %44 = load i64, ptr %43, align 8, !tbaa !11
  %45 = getelementptr inbounds i8, ptr %42, i64 24
  %46 = load i64, ptr %45, align 8, !tbaa !15
  %47 = icmp ult i64 %44, %46
  %spec.select.epil = select i1 %47, i32 0, i32 %.02433.epil
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !18

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.unr-lcssa
  %spec.select.lcssa = phi i32 [ %spec.select.lcssa.ph, %._crit_edge.unr-lcssa ], [ %spec.select.epil, %.lr.ph.epil ]
  %.not30 = icmp eq i32 %spec.select.lcssa, 0
  br i1 %.not30, label %8, label %._crit_edge.thread, !llvm.loop !20

._crit_edge.thread:                               ; preds = %.preheader, %._crit_edge
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(64) %4, i8 0, i64 64, i1 false)
  call void @mbedtls_sha512_finish(ptr noundef nonnull %0, ptr noundef nonnull %4) #5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(216) %0, i8 0, i64 216, i1 false)
  call void @mbedtls_sha512_starts(ptr noundef nonnull %0, i32 noundef 0) #5
  call void @mbedtls_sha512_update(ptr noundef nonnull %0, ptr noundef nonnull %4, i64 noundef 64) #5
  call void @mbedtls_sha512(ptr noundef nonnull %4, i64 noundef 64, ptr noundef nonnull %4, i32 noundef 0) #5
  %48 = load i32, ptr %6, align 8, !tbaa !5
  %49 = icmp sgt i32 %48, 0
  br i1 %49, label %.lr.ph36, label %._crit_edge37

.lr.ph36:                                         ; preds = %._crit_edge.thread
  %wide.trip.count43 = zext nneg i32 %48 to i64
  %xtraiter48 = and i64 %wide.trip.count43, 3
  %50 = icmp ult i32 %48, 4
  br i1 %50, label %._crit_edge37.loopexit.unr-lcssa, label %.lr.ph36.new

.lr.ph36.new:                                     ; preds = %.lr.ph36
  %unroll_iter51 = and i64 %wide.trip.count43, 2147483644
  br label %51

51:                                               ; preds = %51, %.lr.ph36.new
  %indvars.iv40 = phi i64 [ 0, %.lr.ph36.new ], [ %indvars.iv.next41.3, %51 ]
  %niter52 = phi i64 [ 0, %.lr.ph36.new ], [ %niter52.next.3, %51 ]
  %52 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %7, i64 0, i64 %indvars.iv40, i32 2
  store i64 0, ptr %52, align 8, !tbaa !11
  %indvars.iv.next41 = or disjoint i64 %indvars.iv40, 1
  %53 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %7, i64 0, i64 %indvars.iv.next41, i32 2
  store i64 0, ptr %53, align 8, !tbaa !11
  %indvars.iv.next41.1 = or disjoint i64 %indvars.iv40, 2
  %54 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %7, i64 0, i64 %indvars.iv.next41.1, i32 2
  store i64 0, ptr %54, align 8, !tbaa !11
  %indvars.iv.next41.2 = or disjoint i64 %indvars.iv40, 3
  %55 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %7, i64 0, i64 %indvars.iv.next41.2, i32 2
  store i64 0, ptr %55, align 8, !tbaa !11
  %indvars.iv.next41.3 = add nuw nsw i64 %indvars.iv40, 4
  %niter52.next.3 = add i64 %niter52, 4
  %niter52.ncmp.3 = icmp eq i64 %niter52.next.3, %unroll_iter51
  br i1 %niter52.ncmp.3, label %._crit_edge37.loopexit.unr-lcssa, label %51, !llvm.loop !21

._crit_edge37.loopexit.unr-lcssa:                 ; preds = %51, %.lr.ph36
  %indvars.iv40.unr = phi i64 [ 0, %.lr.ph36 ], [ %indvars.iv.next41.3, %51 ]
  %lcmp.mod50.not = icmp eq i64 %xtraiter48, 0
  br i1 %lcmp.mod50.not, label %._crit_edge37, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge37.loopexit.unr-lcssa, %.epil.preheader
  %indvars.iv40.epil = phi i64 [ %indvars.iv.next41.epil, %.epil.preheader ], [ %indvars.iv40.unr, %._crit_edge37.loopexit.unr-lcssa ]
  %epil.iter49 = phi i64 [ %epil.iter49.next, %.epil.preheader ], [ 0, %._crit_edge37.loopexit.unr-lcssa ]
  %56 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %7, i64 0, i64 %indvars.iv40.epil, i32 2
  store i64 0, ptr %56, align 8, !tbaa !11
  %indvars.iv.next41.epil = add nuw nsw i64 %indvars.iv40.epil, 1
  %epil.iter49.next = add i64 %epil.iter49, 1
  %epil.iter49.cmp.not = icmp eq i64 %epil.iter49.next, %xtraiter48
  br i1 %epil.iter49.cmp.not, label %._crit_edge37, label %.epil.preheader, !llvm.loop !22

._crit_edge37:                                    ; preds = %._crit_edge37.loopexit.unr-lcssa, %.epil.preheader, %._crit_edge.thread
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %1, ptr nonnull align 16 %4, i64 %2, i1 false)
  br label %.loopexit

.loopexit:                                        ; preds = %10, %8, %._crit_edge37, %3
  %.0 = phi i32 [ -60, %3 ], [ 0, %._crit_edge37 ], [ -60, %8 ], [ %11, %10 ]
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %4) #5
  ret i32 %.0
}

declare void @mbedtls_sha512_finish(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @mbedtls_sha512_update(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

declare void @mbedtls_sha512(ptr noundef, i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #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 #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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, !10, i64 216}
!6 = !{!"", !7, i64 0, !10, i64 216, !8, i64 224}
!7 = !{!"", !8, i64 0, !8, i64 16, !8, i64 80, !10, i64 208}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !14, i64 16}
!12 = !{!"", !13, i64 0, !13, i64 8, !14, i64 16, !14, i64 24, !10, i64 32}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"long", !8, i64 0}
!15 = !{!12, !14, i64 24}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.unroll.disable"}
!20 = distinct !{!20, !17}
!21 = distinct !{!21, !17}
!22 = distinct !{!22, !19}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass