; LLVM IR from ARMmbed/mbed-crypto :: library (ctr_drbg)

; 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_ctr_drbg_context = type { [16 x i8], i32, i32, i64, i32, %struct.mbedtls_aes_context, ptr, ptr }
%struct.mbedtls_aes_context = type { i32, ptr, [68 x 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_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: nounwind uwtable
declare hidden i32 @block_cipher_df(ptr noundef, ptr noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden i32 @ctr_drbg_update_internal(ptr noundef, ptr noundef) #3

; 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 i32 @mbedtls_ctr_drbg_reseed(ptr noundef, ptr noundef, i64 noundef) #3

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

24:                                               ; preds = %5
  store i32 -54, ptr %6, align 4
  store i32 1, ptr %19, align 4
  br label %135

25:                                               ; preds = %5
  %26 = load i64, ptr %11, align 8, !tbaa !9
  %27 = icmp ugt i64 %26, 256
  br i1 %27, label %28, label %29

28:                                               ; preds = %25
  store i32 -56, ptr %6, align 4
  store i32 1, ptr %19, align 4
  br label %135

29:                                               ; preds = %25
  %30 = getelementptr inbounds [48 x i8], ptr %14, i64 0, i64 0
  call void @llvm.memset.p0.i64(ptr align 16 %30, i8 0, i64 48, i1 false)
  %31 = load ptr, ptr %13, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.mbedtls_ctr_drbg_context, ptr %31, i32 0, i32 1
  %33 = load i32, ptr %32, align 8, !tbaa !13
  %34 = load ptr, ptr %13, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.mbedtls_ctr_drbg_context, ptr %34, i32 0, i32 4
  %36 = load i32, ptr %35, align 8, !tbaa !16
  %37 = icmp sgt i32 %33, %36
  br i1 %37, label %43, label %38

38:                                               ; preds = %29
  %39 = load ptr, ptr %13, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.mbedtls_ctr_drbg_context, ptr %39, i32 0, i32 2
  %41 = load i32, ptr %40, align 4, !tbaa !17
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %43, label %52

43:                                               ; preds = %38, %29
  %44 = load ptr, ptr %13, align 8, !tbaa !5
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = load i64, ptr %11, align 8, !tbaa !9
  %47 = call i32 @mbedtls_ctr_drbg_reseed(ptr noundef %44, ptr noundef %45, i64 noundef %46)
  store i32 %47, ptr %12, align 4, !tbaa !11
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %51

49:                                               ; preds = %43
  %50 = load i32, ptr %12, align 4, !tbaa !11
  store i32 %50, ptr %6, align 4
  store i32 1, ptr %19, align 4
  br label %135

51:                                               ; preds = %43
  store i64 0, ptr %11, align 8, !tbaa !9
  br label %52

52:                                               ; preds = %51, %38
  %53 = load i64, ptr %11, align 8, !tbaa !9
  %54 = icmp ugt i64 %53, 0
  br i1 %54, label %55, label %69

55:                                               ; preds = %52
  %56 = getelementptr inbounds [48 x i8], ptr %14, i64 0, i64 0
  %57 = load ptr, ptr %10, align 8, !tbaa !5
  %58 = load i64, ptr %11, align 8, !tbaa !9
  %59 = call i32 @block_cipher_df(ptr noundef %56, ptr noundef %57, i64 noundef %58)
  store i32 %59, ptr %12, align 4, !tbaa !11
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %61, label %62

61:                                               ; preds = %55
  br label %131

62:                                               ; preds = %55
  %63 = load ptr, ptr %13, align 8, !tbaa !5
  %64 = getelementptr inbounds [48 x i8], ptr %14, i64 0, i64 0
  %65 = call i32 @ctr_drbg_update_internal(ptr noundef %63, ptr noundef %64)
  store i32 %65, ptr %12, align 4, !tbaa !11
  %66 = icmp ne i32 %65, 0
  br i1 %66, label %67, label %68

67:                                               ; preds = %62
  br label %131

68:                                               ; preds = %62
  br label %69

69:                                               ; preds = %68, %52
  br label %70

70:                                               ; preds = %109, %69
  %71 = load i64, ptr %9, align 8, !tbaa !9
  %72 = icmp ugt i64 %71, 0
  br i1 %72, label %73, label %120

73:                                               ; preds = %70
  store i32 16, ptr %17, align 4, !tbaa !11
  br label %74

74:                                               ; preds = %90, %73
  %75 = load i32, ptr %17, align 4, !tbaa !11
  %76 = icmp sgt i32 %75, 0
  br i1 %76, label %77, label %93

77:                                               ; preds = %74
  %78 = load ptr, ptr %13, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.mbedtls_ctr_drbg_context, ptr %78, i32 0, i32 0
  %80 = load i32, ptr %17, align 4, !tbaa !11
  %81 = sub nsw i32 %80, 1
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [16 x i8], ptr %79, i64 0, i64 %82
  %84 = load i8, ptr %83, align 1, !tbaa !18
  %85 = add i8 %84, 1
  store i8 %85, ptr %83, align 1, !tbaa !18
  %86 = zext i8 %85 to i32
  %87 = icmp ne i32 %86, 0
  br i1 %87, label %88, label %89

88:                                               ; preds = %77
  br label %93

89:                                               ; preds = %77
  br label %90

90:                                               ; preds = %89
  %91 = load i32, ptr %17, align 4, !tbaa !11
  %92 = add nsw i32 %91, -1
  store i32 %92, ptr %17, align 4, !tbaa !11
  br label %74, !llvm.loop !19

93:                                               ; preds = %88, %74
  %94 = load ptr, ptr %13, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.mbedtls_ctr_drbg_context, ptr %94, i32 0, i32 5
  %96 = load ptr, ptr %13, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.mbedtls_ctr_drbg_context, ptr %96, i32 0, i32 0
  %98 = getelementptr inbounds [16 x i8], ptr %97, i64 0, i64 0
  %99 = getelementptr inbounds [16 x i8], ptr %16, i64 0, i64 0
  %100 = call i32 @mbedtls_aes_crypt_ecb(ptr noundef %95, i32 noundef 1, ptr noundef %98, ptr noundef %99)
  store i32 %100, ptr %12, align 4, !tbaa !11
  %101 = icmp ne i32 %100, 0
  br i1 %101, label %102, label %103

102:                                              ; preds = %93
  br label %131

103:                                              ; preds = %93
  %104 = load i64, ptr %9, align 8, !tbaa !9
  %105 = icmp ugt i64 %104, 16
  br i1 %105, label %106, label %107

106:                                              ; preds = %103
  br label %109

107:                                              ; preds = %103
  %108 = load i64, ptr %9, align 8, !tbaa !9
  br label %109

109:                                              ; preds = %107, %106
  %110 = phi i64 [ 16, %106 ], [ %108, %107 ]
  store i64 %110, ptr %18, align 8, !tbaa !9
  %111 = load ptr, ptr %15, align 8, !tbaa !5
  %112 = getelementptr inbounds [16 x i8], ptr %16, i64 0, i64 0
  %113 = load i64, ptr %18, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %111, ptr align 16 %112, i64 %113, i1 false)
  %114 = load i64, ptr %18, align 8, !tbaa !9
  %115 = load ptr, ptr %15, align 8, !tbaa !5
  %116 = getelementptr inbounds i8, ptr %115, i64 %114
  store ptr %116, ptr %15, align 8, !tbaa !5
  %117 = load i64, ptr %18, align 8, !tbaa !9
  %118 = load i64, ptr %9, align 8, !tbaa !9
  %119 = sub i64 %118, %117
  store i64 %119, ptr %9, align 8, !tbaa !9
  br label %70, !llvm.loop !21

120:                                              ; preds = %70
  %121 = load ptr, ptr %13, align 8, !tbaa !5
  %122 = getelementptr inbounds [48 x i8], ptr %14, i64 0, i64 0
  %123 = call i32 @ctr_drbg_update_internal(ptr noundef %121, ptr noundef %122)
  store i32 %123, ptr %12, align 4, !tbaa !11
  %124 = icmp ne i32 %123, 0
  br i1 %124, label %125, label %126

125:                                              ; preds = %120
  br label %131

126:                                              ; preds = %120
  %127 = load ptr, ptr %13, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.mbedtls_ctr_drbg_context, ptr %127, i32 0, i32 1
  %129 = load i32, ptr %128, align 8, !tbaa !13
  %130 = add nsw i32 %129, 1
  store i32 %130, ptr %128, align 8, !tbaa !13
  br label %131

131:                                              ; preds = %126, %125, %102, %67, %61
  %132 = getelementptr inbounds [48 x i8], ptr %14, i64 0, i64 0
  call void @mbedtls_platform_zeroize(ptr noundef %132, i64 noundef 48)
  %133 = getelementptr inbounds [16 x i8], ptr %16, i64 0, i64 0
  call void @mbedtls_platform_zeroize(ptr noundef %133, i64 noundef 16)
  %134 = load i32, ptr %12, align 4, !tbaa !11
  store i32 %134, ptr %6, align 4
  store i32 1, ptr %19, align 4
  br label %135

135:                                              ; preds = %131, %49, %28, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 48, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  %136 = load i32, ptr %6, align 4
  ret i32 %136
}

declare i32 @mbedtls_aes_crypt_ecb(ptr noundef, i32 noundef, ptr noundef, ptr 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 16}
!14 = !{!"mbedtls_ctr_drbg_context", !7, i64 0, !12, i64 16, !12, i64 20, !10, i64 24, !12, i64 32, !15, i64 40, !6, i64 328, !6, i64 336}
!15 = !{!"mbedtls_aes_context", !12, i64 0, !6, i64 8, !7, i64 16}
!16 = !{!14, !12, i64 32}
!17 = !{!14, !12, i64 20}
!18 = !{!7, !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !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"

; 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_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: nounwind uwtable
declare hidden i32 @block_cipher_df(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i32 @ctr_drbg_update_internal(ptr noundef, ptr noundef) local_unnamed_addr #3

; 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 i32 @mbedtls_ctr_drbg_reseed(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_ctr_drbg_random_with_add(ptr noundef %0, ptr nocapture noundef writeonly %1, i64 noundef %2, ptr noundef %3, i64 noundef %4) local_unnamed_addr #3 {
  %6 = alloca [48 x i8], align 16
  %7 = alloca [16 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #6
  %8 = icmp ugt i64 %2, 1024
  br i1 %8, label %100, label %9

9:                                                ; preds = %5
  %10 = icmp ugt i64 %4, 256
  br i1 %10, label %100, label %11

11:                                               ; preds = %9
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(48) %6, i8 0, i64 48, i1 false)
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load i32, ptr %12, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  %15 = load i32, ptr %14, align 8, !tbaa !13
  %16 = icmp sgt i32 %13, %15
  br i1 %16, label %20, label %17

17:                                               ; preds = %11
  %18 = getelementptr inbounds i8, ptr %0, i64 20
  %19 = load i32, ptr %18, align 4, !tbaa !14
  %.not = icmp eq i32 %19, 0
  br i1 %.not, label %22, label %20

20:                                               ; preds = %17, %11
  %21 = tail call i32 @mbedtls_ctr_drbg_reseed(ptr noundef nonnull %0, ptr noundef %3, i64 noundef %4)
  %.not45 = icmp eq i32 %21, 0
  br i1 %.not45, label %.thread, label %100

22:                                               ; preds = %17
  %.not46 = icmp eq i64 %4, 0
  br i1 %.not46, label %.thread, label %23

23:                                               ; preds = %22
  %24 = call i32 @block_cipher_df(ptr noundef nonnull %6, ptr noundef %3, i64 noundef %4)
  %.not47 = icmp eq i32 %24, 0
  br i1 %.not47, label %25, label %.loopexit

25:                                               ; preds = %23
  %26 = call i32 @ctr_drbg_update_internal(ptr noundef nonnull %0, ptr noundef nonnull %6)
  %.not48 = icmp eq i32 %26, 0
  br i1 %.not48, label %.thread, label %.loopexit

.thread:                                          ; preds = %20, %25, %22
  %.not4955 = icmp eq i64 %2, 0
  br i1 %.not4955, label %._crit_edge, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %.thread
  %27 = getelementptr inbounds i8, ptr %0, i64 40
  %28 = getelementptr inbounds i8, ptr %0, i64 15
  %29 = getelementptr inbounds i8, ptr %0, i64 14
  %30 = getelementptr inbounds i8, ptr %0, i64 13
  %31 = getelementptr inbounds i8, ptr %0, i64 12
  %32 = getelementptr inbounds i8, ptr %0, i64 11
  %33 = getelementptr inbounds i8, ptr %0, i64 10
  %34 = getelementptr inbounds i8, ptr %0, i64 9
  %35 = getelementptr inbounds i8, ptr %0, i64 8
  %36 = getelementptr inbounds i8, ptr %0, i64 7
  %37 = getelementptr inbounds i8, ptr %0, i64 6
  %38 = getelementptr inbounds i8, ptr %0, i64 5
  %39 = getelementptr inbounds i8, ptr %0, i64 4
  %40 = getelementptr inbounds i8, ptr %0, i64 3
  %41 = getelementptr inbounds i8, ptr %0, i64 2
  %42 = getelementptr inbounds i8, ptr %0, i64 1
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %92
  %.03457 = phi ptr [ %1, %.preheader.lr.ph ], [ %94, %92 ]
  %.03556 = phi i64 [ %2, %.preheader.lr.ph ], [ %95, %92 ]
  %43 = load i8, ptr %28, align 1, !tbaa !15
  %44 = add i8 %43, 1
  store i8 %44, ptr %28, align 1, !tbaa !15
  %.not51 = icmp eq i8 %44, 0
  br i1 %.not51, label %45, label %90, !llvm.loop !16

45:                                               ; preds = %.preheader
  %46 = load i8, ptr %29, align 1, !tbaa !15
  %47 = add i8 %46, 1
  store i8 %47, ptr %29, align 1, !tbaa !15
  %.not51.1 = icmp eq i8 %47, 0
  br i1 %.not51.1, label %48, label %90, !llvm.loop !16

48:                                               ; preds = %45
  %49 = load i8, ptr %30, align 1, !tbaa !15
  %50 = add i8 %49, 1
  store i8 %50, ptr %30, align 1, !tbaa !15
  %.not51.2 = icmp eq i8 %50, 0
  br i1 %.not51.2, label %51, label %90, !llvm.loop !16

51:                                               ; preds = %48
  %52 = load i8, ptr %31, align 1, !tbaa !15
  %53 = add i8 %52, 1
  store i8 %53, ptr %31, align 1, !tbaa !15
  %.not51.3 = icmp eq i8 %53, 0
  br i1 %.not51.3, label %54, label %90, !llvm.loop !16

54:                                               ; preds = %51
  %55 = load i8, ptr %32, align 1, !tbaa !15
  %56 = add i8 %55, 1
  store i8 %56, ptr %32, align 1, !tbaa !15
  %.not51.4 = icmp eq i8 %56, 0
  br i1 %.not51.4, label %57, label %90, !llvm.loop !16

57:                                               ; preds = %54
  %58 = load i8, ptr %33, align 1, !tbaa !15
  %59 = add i8 %58, 1
  store i8 %59, ptr %33, align 1, !tbaa !15
  %.not51.5 = icmp eq i8 %59, 0
  br i1 %.not51.5, label %60, label %90, !llvm.loop !16

60:                                               ; preds = %57
  %61 = load i8, ptr %34, align 1, !tbaa !15
  %62 = add i8 %61, 1
  store i8 %62, ptr %34, align 1, !tbaa !15
  %.not51.6 = icmp eq i8 %62, 0
  br i1 %.not51.6, label %63, label %90, !llvm.loop !16

63:                                               ; preds = %60
  %64 = load i8, ptr %35, align 1, !tbaa !15
  %65 = add i8 %64, 1
  store i8 %65, ptr %35, align 1, !tbaa !15
  %.not51.7 = icmp eq i8 %65, 0
  br i1 %.not51.7, label %66, label %90, !llvm.loop !16

66:                                               ; preds = %63
  %67 = load i8, ptr %36, align 1, !tbaa !15
  %68 = add i8 %67, 1
  store i8 %68, ptr %36, align 1, !tbaa !15
  %.not51.8 = icmp eq i8 %68, 0
  br i1 %.not51.8, label %69, label %90, !llvm.loop !16

69:                                               ; preds = %66
  %70 = load i8, ptr %37, align 1, !tbaa !15
  %71 = add i8 %70, 1
  store i8 %71, ptr %37, align 1, !tbaa !15
  %.not51.9 = icmp eq i8 %71, 0
  br i1 %.not51.9, label %72, label %90, !llvm.loop !16

72:                                               ; preds = %69
  %73 = load i8, ptr %38, align 1, !tbaa !15
  %74 = add i8 %73, 1
  store i8 %74, ptr %38, align 1, !tbaa !15
  %.not51.10 = icmp eq i8 %74, 0
  br i1 %.not51.10, label %75, label %90, !llvm.loop !16

75:                                               ; preds = %72
  %76 = load i8, ptr %39, align 1, !tbaa !15
  %77 = add i8 %76, 1
  store i8 %77, ptr %39, align 1, !tbaa !15
  %.not51.11 = icmp eq i8 %77, 0
  br i1 %.not51.11, label %78, label %90, !llvm.loop !16

78:                                               ; preds = %75
  %79 = load i8, ptr %40, align 1, !tbaa !15
  %80 = add i8 %79, 1
  store i8 %80, ptr %40, align 1, !tbaa !15
  %.not51.12 = icmp eq i8 %80, 0
  br i1 %.not51.12, label %81, label %90, !llvm.loop !16

81:                                               ; preds = %78
  %82 = load i8, ptr %41, align 1, !tbaa !15
  %83 = add i8 %82, 1
  store i8 %83, ptr %41, align 1, !tbaa !15
  %.not51.13 = icmp eq i8 %83, 0
  br i1 %.not51.13, label %84, label %90, !llvm.loop !16

84:                                               ; preds = %81
  %85 = load i8, ptr %42, align 1, !tbaa !15
  %86 = add i8 %85, 1
  store i8 %86, ptr %42, align 1, !tbaa !15
  %.not51.14 = icmp eq i8 %86, 0
  br i1 %.not51.14, label %87, label %90, !llvm.loop !16

87:                                               ; preds = %84
  %88 = load i8, ptr %0, align 1, !tbaa !15
  %89 = add i8 %88, 1
  store i8 %89, ptr %0, align 1, !tbaa !15
  br label %90

90:                                               ; preds = %87, %84, %81, %78, %75, %72, %69, %66, %63, %60, %57, %54, %51, %48, %45, %.preheader
  %91 = call i32 @mbedtls_aes_crypt_ecb(ptr noundef nonnull %27, i32 noundef 1, ptr noundef nonnull %0, ptr noundef nonnull %7) #6
  %.not52 = icmp eq i32 %91, 0
  br i1 %.not52, label %92, label %.loopexit

92:                                               ; preds = %90
  %93 = call i64 @llvm.umin.i64(i64 %.03556, i64 16)
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %.03457, ptr nonnull align 16 %7, i64 %93, i1 false)
  %94 = getelementptr inbounds i8, ptr %.03457, i64 %93
  %95 = sub i64 %.03556, %93
  %.not49 = icmp eq i64 %95, 0
  br i1 %.not49, label %._crit_edge, label %.preheader, !llvm.loop !18

._crit_edge:                                      ; preds = %92, %.thread
  %96 = call i32 @ctr_drbg_update_internal(ptr noundef nonnull %0, ptr noundef nonnull %6)
  %.not50 = icmp eq i32 %96, 0
  br i1 %.not50, label %97, label %.loopexit

97:                                               ; preds = %._crit_edge
  %98 = load i32, ptr %12, align 8, !tbaa !5
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %12, align 8, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %90, %._crit_edge, %25, %23, %97
  %.036 = phi i32 [ %24, %23 ], [ %26, %25 ], [ %96, %._crit_edge ], [ 0, %97 ], [ %91, %90 ]
  call void @mbedtls_platform_zeroize(ptr noundef nonnull %6, i64 noundef 48) #6
  call void @mbedtls_platform_zeroize(ptr noundef nonnull %7, i64 noundef 16) #6
  br label %100

100:                                              ; preds = %20, %9, %5, %.loopexit
  %.0 = phi i32 [ %.036, %.loopexit ], [ -54, %5 ], [ -56, %9 ], [ %21, %20 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %6) #6
  ret i32 %.0
}

declare i32 @mbedtls_aes_crypt_ecb(ptr noundef, i32 noundef, ptr noundef, ptr 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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #5

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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, !9, i64 16}
!6 = !{!"mbedtls_ctr_drbg_context", !7, i64 0, !9, i64 16, !9, i64 20, !10, i64 24, !9, i64 32, !11, i64 40, !12, i64 328, !12, i64 336}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!"mbedtls_aes_context", !9, i64 0, !12, i64 8, !7, i64 16}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!6, !9, i64 32}
!14 = !{!6, !9, i64 20}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}


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