; LLVM IR from ARMmbed/mbed-crypto :: library (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 { i32, %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_init(ptr noundef) #1

declare void @mbedtls_sha512_free(ptr noundef) #1

declare void @mbedtls_platform_zeroize(ptr noundef, i64 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 i64, align 8
  %13 = alloca ptr, align 8
  %14 = alloca [64 x i8], align 16
  %15 = 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %16, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 64, ptr %14) #5
  %17 = load i64, ptr %7, align 8, !tbaa !9
  %18 = icmp ugt i64 %17, 64
  br i1 %18, label %19, label %20

19:                                               ; preds = %3
  store i32 -60, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %142

20:                                               ; preds = %3
  br label %21

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

25:                                               ; preds = %21
  store i32 -60, ptr %8, align 4, !tbaa !11
  br label %139

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

30:                                               ; preds = %26
  br label %139

31:                                               ; preds = %26
  store i32 1, ptr %11, align 4, !tbaa !11
  store i64 0, ptr %12, align 8, !tbaa !9
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %32

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

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

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

55:                                               ; preds = %54, %38
  %56 = load ptr, ptr %13, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.mbedtls_entropy_context, ptr %56, i32 0, i32 3
  %58 = load i32, ptr %10, align 4, !tbaa !11
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %57, i64 0, i64 %59
  %61 = getelementptr inbounds %struct.mbedtls_entropy_source_state, ptr %60, i32 0, i32 4
  %62 = load i32, ptr %61, align 8, !tbaa !19
  %63 = icmp eq i32 %62, 1
  br i1 %63, label %64, label %74

64:                                               ; preds = %55
  %65 = load ptr, ptr %13, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.mbedtls_entropy_context, ptr %65, i32 0, i32 3
  %67 = load i32, ptr %10, align 4, !tbaa !11
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %66, i64 0, i64 %68
  %70 = getelementptr inbounds %struct.mbedtls_entropy_source_state, ptr %69, i32 0, i32 2
  %71 = load i64, ptr %70, align 8, !tbaa !16
  %72 = load i64, ptr %12, align 8, !tbaa !9
  %73 = add i64 %72, %71
  store i64 %73, ptr %12, align 8, !tbaa !9
  br label %74

74:                                               ; preds = %64, %55
  br label %75

75:                                               ; preds = %74
  %76 = load i32, ptr %10, align 4, !tbaa !11
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %10, align 4, !tbaa !11
  br label %32, !llvm.loop !20

78:                                               ; preds = %32
  br label %79

79:                                               ; preds = %78
  %80 = load i32, ptr %11, align 4, !tbaa !11
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %82, label %85

82:                                               ; preds = %79
  %83 = load i64, ptr %12, align 8, !tbaa !9
  %84 = icmp ult i64 %83, 64
  br label %85

85:                                               ; preds = %82, %79
  %86 = phi i1 [ true, %79 ], [ %84, %82 ]
  br i1 %86, label %21, label %87, !llvm.loop !22

87:                                               ; preds = %85
  %88 = getelementptr inbounds [64 x i8], ptr %14, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %88, i8 0, i64 64, i1 false)
  %89 = load ptr, ptr %13, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.mbedtls_entropy_context, ptr %89, i32 0, i32 1
  %91 = getelementptr inbounds [64 x i8], ptr %14, i64 0, i64 0
  %92 = call i32 @mbedtls_sha512_finish_ret(ptr noundef %90, ptr noundef %91)
  store i32 %92, ptr %8, align 4, !tbaa !11
  %93 = icmp ne i32 %92, 0
  br i1 %93, label %94, label %95

94:                                               ; preds = %87
  br label %139

95:                                               ; preds = %87
  %96 = load ptr, ptr %13, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.mbedtls_entropy_context, ptr %96, i32 0, i32 1
  call void @mbedtls_sha512_free(ptr noundef %97)
  %98 = load ptr, ptr %13, align 8, !tbaa !5
  %99 = getelementptr inbounds %struct.mbedtls_entropy_context, ptr %98, i32 0, i32 1
  call void @mbedtls_sha512_init(ptr noundef %99)
  %100 = load ptr, ptr %13, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.mbedtls_entropy_context, ptr %100, i32 0, i32 1
  %102 = call i32 @mbedtls_sha512_starts_ret(ptr noundef %101, i32 noundef 0)
  store i32 %102, ptr %8, align 4, !tbaa !11
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %104, label %105

104:                                              ; preds = %95
  br label %139

105:                                              ; preds = %95
  %106 = load ptr, ptr %13, align 8, !tbaa !5
  %107 = getelementptr inbounds %struct.mbedtls_entropy_context, ptr %106, i32 0, i32 1
  %108 = getelementptr inbounds [64 x i8], ptr %14, i64 0, i64 0
  %109 = call i32 @mbedtls_sha512_update_ret(ptr noundef %107, ptr noundef %108, i64 noundef 64)
  store i32 %109, ptr %8, align 4, !tbaa !11
  %110 = icmp ne i32 %109, 0
  br i1 %110, label %111, label %112

111:                                              ; preds = %105
  br label %139

112:                                              ; preds = %105
  %113 = getelementptr inbounds [64 x i8], ptr %14, i64 0, i64 0
  %114 = getelementptr inbounds [64 x i8], ptr %14, i64 0, i64 0
  %115 = call i32 @mbedtls_sha512_ret(ptr noundef %113, i64 noundef 64, ptr noundef %114, i32 noundef 0)
  store i32 %115, ptr %8, align 4, !tbaa !11
  %116 = icmp ne i32 %115, 0
  br i1 %116, label %117, label %118

117:                                              ; preds = %112
  br label %139

118:                                              ; preds = %112
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %119

119:                                              ; preds = %132, %118
  %120 = load i32, ptr %10, align 4, !tbaa !11
  %121 = load ptr, ptr %13, align 8, !tbaa !5
  %122 = getelementptr inbounds %struct.mbedtls_entropy_context, ptr %121, i32 0, i32 2
  %123 = load i32, ptr %122, align 8, !tbaa !13
  %124 = icmp slt i32 %120, %123
  br i1 %124, label %125, label %135

125:                                              ; preds = %119
  %126 = load ptr, ptr %13, align 8, !tbaa !5
  %127 = getelementptr inbounds %struct.mbedtls_entropy_context, ptr %126, i32 0, i32 3
  %128 = load i32, ptr %10, align 4, !tbaa !11
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %127, i64 0, i64 %129
  %131 = getelementptr inbounds %struct.mbedtls_entropy_source_state, ptr %130, i32 0, i32 2
  store i64 0, ptr %131, align 8, !tbaa !16
  br label %132

132:                                              ; preds = %125
  %133 = load i32, ptr %10, align 4, !tbaa !11
  %134 = add nsw i32 %133, 1
  store i32 %134, ptr %10, align 4, !tbaa !11
  br label %119, !llvm.loop !23

135:                                              ; preds = %119
  %136 = load ptr, ptr %6, align 8, !tbaa !5
  %137 = getelementptr inbounds [64 x i8], ptr %14, i64 0, i64 0
  %138 = load i64, ptr %7, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %136, ptr align 16 %137, i64 %138, i1 false)
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %139

139:                                              ; preds = %135, %117, %111, %104, %94, %30, %25
  %140 = getelementptr inbounds [64 x i8], ptr %14, i64 0, i64 0
  call void @mbedtls_platform_zeroize(ptr noundef %140, i64 noundef 64)
  %141 = load i32, ptr %8, align 4, !tbaa !11
  store i32 %141, ptr %4, align 4
  store i32 1, ptr %15, align 4
  br label %142

142:                                              ; preds = %139, %19
  call void @llvm.lifetime.end.p0(i64 64, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, 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
  %143 = load i32, ptr %4, align 4
  ret i32 %143
}

declare i32 @mbedtls_sha512_finish_ret(ptr noundef, ptr noundef) #1

declare i32 @mbedtls_sha512_starts_ret(ptr noundef, i32 noundef) #1

declare i32 @mbedtls_sha512_update_ret(ptr noundef, ptr noundef, i64 noundef) #1

declare i32 @mbedtls_sha512_ret(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 224}
!14 = !{!"mbedtls_entropy_context", !12, i64 0, !15, i64 8, !12, i64 224, !7, i64 232}
!15 = !{!"mbedtls_sha512_context", !7, i64 0, !7, i64 16, !7, i64 80, !12, i64 208}
!16 = !{!17, !10, i64 16}
!17 = !{!"mbedtls_entropy_source_state", !6, i64 0, !6, i64 8, !10, i64 16, !10, i64 24, !12, i64 32}
!18 = !{!17, !10, i64 24}
!19 = !{!17, !12, i64 32}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}
!23 = distinct !{!23, !21}


; 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_init(ptr noundef) local_unnamed_addr #1

declare void @mbedtls_sha512_free(ptr noundef) local_unnamed_addr #1

declare void @mbedtls_platform_zeroize(ptr noundef, i64 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 %66, label %.preheader50

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

8:                                                ; preds = %.preheader50, %._crit_edge
  %.036 = phi i32 [ %9, %._crit_edge ], [ 0, %.preheader50 ]
  %9 = add nuw nsw i32 %.036, 1
  %exitcond59 = icmp eq i32 %.036, 257
  br i1 %exitcond59, 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 %.preheader49, label %.loopexit

.preheader49:                                     ; 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

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

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  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.1, %.lr.ph ]
  %.03153 = phi i64 [ 0, %.lr.ph.preheader.new ], [ %spec.select48.1, %.lr.ph ]
  %.03252 = phi i32 [ 1, %.lr.ph.preheader.new ], [ %spec.select.1, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.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
  %21 = getelementptr inbounds i8, ptr %15, i64 32
  %22 = load i32, ptr %21, align 8, !tbaa !16
  %23 = icmp eq i32 %22, 1
  %24 = select i1 %23, i64 %17, i64 0
  %spec.select48 = add i64 %24, %.03153
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %25 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %7, i64 0, i64 %indvars.iv.next
  %26 = getelementptr inbounds i8, ptr %25, i64 16
  %27 = load i64, ptr %26, align 8, !tbaa !11
  %28 = getelementptr inbounds i8, ptr %25, i64 24
  %29 = load i64, ptr %28, align 8, !tbaa !15
  %30 = icmp ult i64 %27, %29
  %31 = select i1 %30, i1 true, i1 %20
  %spec.select.1 = select i1 %31, i32 0, i32 %.03252
  %32 = getelementptr inbounds i8, ptr %25, i64 32
  %33 = load i32, ptr %32, align 8, !tbaa !16
  %34 = icmp eq i32 %33, 1
  %35 = select i1 %34, i64 %27, i64 0
  %spec.select48.1 = add i64 %35, %spec.select48
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !17

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %spec.select.lcssa.ph = phi i32 [ poison, %.lr.ph.preheader ], [ %spec.select.1, %.lr.ph ]
  %spec.select48.lcssa.ph = phi i64 [ poison, %.lr.ph.preheader ], [ %spec.select48.1, %.lr.ph ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.1, %.lr.ph ]
  %.03153.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %spec.select48.1, %.lr.ph ]
  %.03252.unr = phi i32 [ 1, %.lr.ph.preheader ], [ %spec.select.1, %.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.loopexit.unr-lcssa
  %36 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %7, i64 0, i64 %indvars.iv.unr
  %37 = getelementptr inbounds i8, ptr %36, i64 16
  %38 = load i64, ptr %37, align 8, !tbaa !11
  %39 = getelementptr inbounds i8, ptr %36, i64 24
  %40 = load i64, ptr %39, align 8, !tbaa !15
  %41 = icmp ult i64 %38, %40
  %spec.select.epil = select i1 %41, i32 0, i32 %.03252.unr
  %42 = getelementptr inbounds i8, ptr %36, i64 32
  %43 = load i32, ptr %42, align 8, !tbaa !16
  %44 = icmp eq i32 %43, 1
  %45 = select i1 %44, i64 %38, i64 0
  %spec.select48.epil = add i64 %45, %.03153.unr
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.loopexit.unr-lcssa, %.preheader49
  %.032.lcssa = phi i32 [ 1, %.preheader49 ], [ %spec.select.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %spec.select.epil, %.lr.ph.epil ]
  %.031.lcssa = phi i64 [ 0, %.preheader49 ], [ %spec.select48.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %spec.select48.epil, %.lr.ph.epil ]
  %.not43 = icmp eq i32 %.032.lcssa, 0
  %46 = icmp ult i64 %.031.lcssa, 64
  %47 = select i1 %.not43, i1 true, i1 %46
  br i1 %47, label %8, label %48, !llvm.loop !19

48:                                               ; preds = %._crit_edge
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(64) %4, i8 0, i64 64, i1 false)
  %49 = getelementptr inbounds i8, ptr %0, i64 8
  %50 = call i32 @mbedtls_sha512_finish_ret(ptr noundef nonnull %49, ptr noundef nonnull %4) #5
  %.not44 = icmp eq i32 %50, 0
  br i1 %.not44, label %51, label %.loopexit

51:                                               ; preds = %48
  call void @mbedtls_sha512_free(ptr noundef nonnull %49) #5
  call void @mbedtls_sha512_init(ptr noundef nonnull %49) #5
  %52 = call i32 @mbedtls_sha512_starts_ret(ptr noundef nonnull %49, i32 noundef 0) #5
  %.not45 = icmp eq i32 %52, 0
  br i1 %.not45, label %53, label %.loopexit

53:                                               ; preds = %51
  %54 = call i32 @mbedtls_sha512_update_ret(ptr noundef nonnull %49, ptr noundef nonnull %4, i64 noundef 64) #5
  %.not46 = icmp eq i32 %54, 0
  br i1 %.not46, label %55, label %.loopexit

55:                                               ; preds = %53
  %56 = call i32 @mbedtls_sha512_ret(ptr noundef nonnull %4, i64 noundef 64, ptr noundef nonnull %4, i32 noundef 0) #5
  %.not47 = icmp eq i32 %56, 0
  br i1 %.not47, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %55
  %57 = load i32, ptr %6, align 8, !tbaa !5
  %58 = icmp sgt i32 %57, 0
  br i1 %58, label %.lr.ph56, label %._crit_edge57

.lr.ph56:                                         ; preds = %.preheader
  %wide.trip.count63 = zext nneg i32 %57 to i64
  %xtraiter67 = and i64 %wide.trip.count63, 3
  %59 = icmp ult i32 %57, 4
  br i1 %59, label %._crit_edge57.loopexit.unr-lcssa, label %.lr.ph56.new

.lr.ph56.new:                                     ; preds = %.lr.ph56
  %unroll_iter69 = and i64 %wide.trip.count63, 2147483644
  br label %60

60:                                               ; preds = %60, %.lr.ph56.new
  %indvars.iv60 = phi i64 [ 0, %.lr.ph56.new ], [ %indvars.iv.next61.3, %60 ]
  %niter70 = phi i64 [ 0, %.lr.ph56.new ], [ %niter70.next.3, %60 ]
  %61 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %7, i64 0, i64 %indvars.iv60, i32 2
  store i64 0, ptr %61, align 8, !tbaa !11
  %indvars.iv.next61 = or disjoint i64 %indvars.iv60, 1
  %62 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %7, i64 0, i64 %indvars.iv.next61, i32 2
  store i64 0, ptr %62, align 8, !tbaa !11
  %indvars.iv.next61.1 = or disjoint i64 %indvars.iv60, 2
  %63 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %7, i64 0, i64 %indvars.iv.next61.1, i32 2
  store i64 0, ptr %63, align 8, !tbaa !11
  %indvars.iv.next61.2 = or disjoint i64 %indvars.iv60, 3
  %64 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %7, i64 0, i64 %indvars.iv.next61.2, i32 2
  store i64 0, ptr %64, align 8, !tbaa !11
  %indvars.iv.next61.3 = add nuw nsw i64 %indvars.iv60, 4
  %niter70.next.3 = add i64 %niter70, 4
  %niter70.ncmp.3 = icmp eq i64 %niter70.next.3, %unroll_iter69
  br i1 %niter70.ncmp.3, label %._crit_edge57.loopexit.unr-lcssa, label %60, !llvm.loop !20

._crit_edge57.loopexit.unr-lcssa:                 ; preds = %60, %.lr.ph56
  %indvars.iv60.unr = phi i64 [ 0, %.lr.ph56 ], [ %indvars.iv.next61.3, %60 ]
  %lcmp.mod68.not = icmp eq i64 %xtraiter67, 0
  br i1 %lcmp.mod68.not, label %._crit_edge57, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge57.loopexit.unr-lcssa, %.epil.preheader
  %indvars.iv60.epil = phi i64 [ %indvars.iv.next61.epil, %.epil.preheader ], [ %indvars.iv60.unr, %._crit_edge57.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge57.loopexit.unr-lcssa ]
  %65 = getelementptr inbounds [20 x %struct.mbedtls_entropy_source_state], ptr %7, i64 0, i64 %indvars.iv60.epil, i32 2
  store i64 0, ptr %65, align 8, !tbaa !11
  %indvars.iv.next61.epil = add nuw nsw i64 %indvars.iv60.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter67
  br i1 %epil.iter.cmp.not, label %._crit_edge57, label %.epil.preheader, !llvm.loop !21

._crit_edge57:                                    ; preds = %._crit_edge57.loopexit.unr-lcssa, %.epil.preheader, %.preheader
  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 = %8, %10, %55, %53, %51, %48, %._crit_edge57
  %.037 = phi i32 [ %50, %48 ], [ %52, %51 ], [ %54, %53 ], [ %56, %55 ], [ 0, %._crit_edge57 ], [ -60, %8 ], [ %11, %10 ]
  call void @mbedtls_platform_zeroize(ptr noundef nonnull %4, i64 noundef 64) #5
  br label %66

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

declare i32 @mbedtls_sha512_finish_ret(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @mbedtls_sha512_starts_ret(ptr noundef, i32 noundef) local_unnamed_addr #1

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

declare i32 @mbedtls_sha512_ret(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, !7, i64 224}
!6 = !{!"mbedtls_entropy_context", !7, i64 0, !10, i64 8, !7, i64 224, !8, i64 232}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"mbedtls_sha512_context", !8, i64 0, !8, i64 16, !8, i64 80, !7, i64 208}
!11 = !{!12, !14, i64 16}
!12 = !{!"mbedtls_entropy_source_state", !13, i64 0, !13, i64 8, !14, i64 16, !14, i64 24, !7, i64 32}
!13 = !{!"any pointer", !8, i64 0}
!14 = !{!"long", !8, i64 0}
!15 = !{!12, !14, i64 24}
!16 = !{!12, !7, i64 32}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = distinct !{!20, !18}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.unroll.disable"}


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