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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_ctr_drbg_reseed(ptr noundef, ptr noundef, i64 noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden i32 @block_cipher_df(ptr noundef, ptr noundef, i64 noundef) #2

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

; 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) #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) #2 {
  %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 %119

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 %119

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 %119

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 %63

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)
  %60 = load ptr, ptr %13, align 8, !tbaa !5
  %61 = getelementptr inbounds [48 x i8], ptr %14, i64 0, i64 0
  %62 = call i32 @ctr_drbg_update_internal(ptr noundef %60, ptr noundef %61)
  br label %63

63:                                               ; preds = %55, %52
  br label %64

64:                                               ; preds = %100, %63
  %65 = load i64, ptr %9, align 8, !tbaa !9
  %66 = icmp ugt i64 %65, 0
  br i1 %66, label %67, label %111

67:                                               ; preds = %64
  store i32 16, ptr %17, align 4, !tbaa !11
  br label %68

68:                                               ; preds = %84, %67
  %69 = load i32, ptr %17, align 4, !tbaa !11
  %70 = icmp sgt i32 %69, 0
  br i1 %70, label %71, label %87

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

82:                                               ; preds = %71
  br label %87

83:                                               ; preds = %71
  br label %84

84:                                               ; preds = %83
  %85 = load i32, ptr %17, align 4, !tbaa !11
  %86 = add nsw i32 %85, -1
  store i32 %86, ptr %17, align 4, !tbaa !11
  br label %68, !llvm.loop !19

87:                                               ; preds = %82, %68
  %88 = load ptr, ptr %13, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.mbedtls_ctr_drbg_context, ptr %88, i32 0, i32 5
  %90 = load ptr, ptr %13, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.mbedtls_ctr_drbg_context, ptr %90, i32 0, i32 0
  %92 = getelementptr inbounds [16 x i8], ptr %91, i64 0, i64 0
  %93 = getelementptr inbounds [16 x i8], ptr %16, i64 0, i64 0
  %94 = call i32 @mbedtls_aes_crypt_ecb(ptr noundef %89, i32 noundef 1, ptr noundef %92, ptr noundef %93)
  %95 = load i64, ptr %9, align 8, !tbaa !9
  %96 = icmp ugt i64 %95, 16
  br i1 %96, label %97, label %98

97:                                               ; preds = %87
  br label %100

98:                                               ; preds = %87
  %99 = load i64, ptr %9, align 8, !tbaa !9
  br label %100

100:                                              ; preds = %98, %97
  %101 = phi i64 [ 16, %97 ], [ %99, %98 ]
  store i64 %101, ptr %18, align 8, !tbaa !9
  %102 = load ptr, ptr %15, align 8, !tbaa !5
  %103 = getelementptr inbounds [16 x i8], ptr %16, i64 0, i64 0
  %104 = load i64, ptr %18, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %102, ptr align 16 %103, i64 %104, i1 false)
  %105 = load i64, ptr %18, align 8, !tbaa !9
  %106 = load ptr, ptr %15, align 8, !tbaa !5
  %107 = getelementptr inbounds i8, ptr %106, i64 %105
  store ptr %107, ptr %15, align 8, !tbaa !5
  %108 = load i64, ptr %18, align 8, !tbaa !9
  %109 = load i64, ptr %9, align 8, !tbaa !9
  %110 = sub i64 %109, %108
  store i64 %110, ptr %9, align 8, !tbaa !9
  br label %64, !llvm.loop !21

111:                                              ; preds = %64
  %112 = load ptr, ptr %13, align 8, !tbaa !5
  %113 = getelementptr inbounds [48 x i8], ptr %14, i64 0, i64 0
  %114 = call i32 @ctr_drbg_update_internal(ptr noundef %112, ptr noundef %113)
  %115 = load ptr, ptr %13, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.mbedtls_ctr_drbg_context, ptr %115, i32 0, i32 1
  %117 = load i32, ptr %116, align 8, !tbaa !13
  %118 = add nsw i32 %117, 1
  store i32 %118, ptr %116, align 8, !tbaa !13
  store i32 0, ptr %6, align 4
  store i32 1, ptr %19, align 4
  br label %119

119:                                              ; preds = %111, %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
  %120 = load i32, ptr %6, align 4
  ret i32 %120
}

declare i32 @mbedtls_aes_crypt_ecb(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #4

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 }

!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 = !{!"", !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 = !{!"", !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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden i32 @block_cipher_df(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

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

; 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) #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 #2 {
  %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 %97, label %9

9:                                                ; preds = %5
  %10 = icmp ugt i64 %4, 256
  br i1 %10, label %97, 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)
  %.not39 = icmp eq i32 %21, 0
  br i1 %.not39, label %.thread, label %97

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

23:                                               ; preds = %22
  %24 = call i32 @block_cipher_df(ptr noundef nonnull %6, ptr noundef %3, i64 noundef %4)
  %25 = call i32 @ctr_drbg_update_internal(ptr noundef nonnull %0, ptr noundef nonnull %6)
  br label %.thread

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

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

.preheader:                                       ; preds = %.preheader.lr.ph, %89
  %.03347 = phi ptr [ %1, %.preheader.lr.ph ], [ %92, %89 ]
  %.03446 = phi i64 [ %2, %.preheader.lr.ph ], [ %93, %89 ]
  %42 = load i8, ptr %27, align 1, !tbaa !15
  %43 = add i8 %42, 1
  store i8 %43, ptr %27, align 1, !tbaa !15
  %.not42 = icmp eq i8 %43, 0
  br i1 %.not42, label %44, label %89, !llvm.loop !16

44:                                               ; preds = %.preheader
  %45 = load i8, ptr %28, align 1, !tbaa !15
  %46 = add i8 %45, 1
  store i8 %46, ptr %28, align 1, !tbaa !15
  %.not42.1 = icmp eq i8 %46, 0
  br i1 %.not42.1, label %47, label %89, !llvm.loop !16

47:                                               ; preds = %44
  %48 = load i8, ptr %29, align 1, !tbaa !15
  %49 = add i8 %48, 1
  store i8 %49, ptr %29, align 1, !tbaa !15
  %.not42.2 = icmp eq i8 %49, 0
  br i1 %.not42.2, label %50, label %89, !llvm.loop !16

50:                                               ; preds = %47
  %51 = load i8, ptr %30, align 1, !tbaa !15
  %52 = add i8 %51, 1
  store i8 %52, ptr %30, align 1, !tbaa !15
  %.not42.3 = icmp eq i8 %52, 0
  br i1 %.not42.3, label %53, label %89, !llvm.loop !16

53:                                               ; preds = %50
  %54 = load i8, ptr %31, align 1, !tbaa !15
  %55 = add i8 %54, 1
  store i8 %55, ptr %31, align 1, !tbaa !15
  %.not42.4 = icmp eq i8 %55, 0
  br i1 %.not42.4, label %56, label %89, !llvm.loop !16

56:                                               ; preds = %53
  %57 = load i8, ptr %32, align 1, !tbaa !15
  %58 = add i8 %57, 1
  store i8 %58, ptr %32, align 1, !tbaa !15
  %.not42.5 = icmp eq i8 %58, 0
  br i1 %.not42.5, label %59, label %89, !llvm.loop !16

59:                                               ; preds = %56
  %60 = load i8, ptr %33, align 1, !tbaa !15
  %61 = add i8 %60, 1
  store i8 %61, ptr %33, align 1, !tbaa !15
  %.not42.6 = icmp eq i8 %61, 0
  br i1 %.not42.6, label %62, label %89, !llvm.loop !16

62:                                               ; preds = %59
  %63 = load i8, ptr %34, align 1, !tbaa !15
  %64 = add i8 %63, 1
  store i8 %64, ptr %34, align 1, !tbaa !15
  %.not42.7 = icmp eq i8 %64, 0
  br i1 %.not42.7, label %65, label %89, !llvm.loop !16

65:                                               ; preds = %62
  %66 = load i8, ptr %35, align 1, !tbaa !15
  %67 = add i8 %66, 1
  store i8 %67, ptr %35, align 1, !tbaa !15
  %.not42.8 = icmp eq i8 %67, 0
  br i1 %.not42.8, label %68, label %89, !llvm.loop !16

68:                                               ; preds = %65
  %69 = load i8, ptr %36, align 1, !tbaa !15
  %70 = add i8 %69, 1
  store i8 %70, ptr %36, align 1, !tbaa !15
  %.not42.9 = icmp eq i8 %70, 0
  br i1 %.not42.9, label %71, label %89, !llvm.loop !16

71:                                               ; preds = %68
  %72 = load i8, ptr %37, align 1, !tbaa !15
  %73 = add i8 %72, 1
  store i8 %73, ptr %37, align 1, !tbaa !15
  %.not42.10 = icmp eq i8 %73, 0
  br i1 %.not42.10, label %74, label %89, !llvm.loop !16

74:                                               ; preds = %71
  %75 = load i8, ptr %38, align 1, !tbaa !15
  %76 = add i8 %75, 1
  store i8 %76, ptr %38, align 1, !tbaa !15
  %.not42.11 = icmp eq i8 %76, 0
  br i1 %.not42.11, label %77, label %89, !llvm.loop !16

77:                                               ; preds = %74
  %78 = load i8, ptr %39, align 1, !tbaa !15
  %79 = add i8 %78, 1
  store i8 %79, ptr %39, align 1, !tbaa !15
  %.not42.12 = icmp eq i8 %79, 0
  br i1 %.not42.12, label %80, label %89, !llvm.loop !16

80:                                               ; preds = %77
  %81 = load i8, ptr %40, align 1, !tbaa !15
  %82 = add i8 %81, 1
  store i8 %82, ptr %40, align 1, !tbaa !15
  %.not42.13 = icmp eq i8 %82, 0
  br i1 %.not42.13, label %83, label %89, !llvm.loop !16

83:                                               ; preds = %80
  %84 = load i8, ptr %41, align 1, !tbaa !15
  %85 = add i8 %84, 1
  store i8 %85, ptr %41, align 1, !tbaa !15
  %.not42.14 = icmp eq i8 %85, 0
  br i1 %.not42.14, label %86, label %89, !llvm.loop !16

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

89:                                               ; preds = %86, %83, %80, %77, %74, %71, %68, %65, %62, %59, %56, %53, %50, %47, %44, %.preheader
  %90 = call i32 @mbedtls_aes_crypt_ecb(ptr noundef nonnull %26, i32 noundef 1, ptr noundef nonnull %0, ptr noundef nonnull %7) #6
  %91 = call i64 @llvm.umin.i64(i64 %.03446, i64 16)
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %.03347, ptr nonnull align 16 %7, i64 %91, i1 false)
  %92 = getelementptr inbounds i8, ptr %.03347, i64 %91
  %93 = sub i64 %.03446, %91
  %.not41 = icmp eq i64 %93, 0
  br i1 %.not41, label %._crit_edge, label %.preheader, !llvm.loop !18

._crit_edge:                                      ; preds = %89, %.thread
  %94 = call i32 @ctr_drbg_update_internal(ptr noundef nonnull %0, ptr noundef nonnull %6)
  %95 = load i32, ptr %12, align 8, !tbaa !5
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %12, align 8, !tbaa !5
  br label %97

97:                                               ; preds = %20, %9, %5, %._crit_edge
  %.0 = phi i32 [ 0, %._crit_edge ], [ -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 #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"", !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 = !{!"", !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,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass