; LLVM IR from tleonhardt/practical_cryptography_engineering :: kdf (main)

; 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 }
%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] }
%struct.mbedtls_md_context_t = type { ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [47 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [43 x i8], align 1
@stdout = external global ptr, align 8
@__const.main.pers = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [19 x i8], align 1

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

21:                                               ; preds = %2
  %22 = load ptr, ptr %5, align 8, !tbaa !9
  %23 = getelementptr inbounds ptr, ptr %22, i64 0
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = load ptr, ptr %5, align 8, !tbaa !9
  %26 = getelementptr inbounds ptr, ptr %25, i64 0
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef %24, ptr noundef %27)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %13, align 4
  br label %138

29:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %30 = load ptr, ptr %5, align 8, !tbaa !9
  %31 = getelementptr inbounds ptr, ptr %30, i64 1
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  store ptr %32, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %33 = load ptr, ptr %5, align 8, !tbaa !9
  %34 = getelementptr inbounds ptr, ptr %33, i64 1
  %35 = load ptr, ptr %34, align 8, !tbaa !9
  %36 = call i64 @strlen(ptr noundef %35) #6
  store i64 %36, ptr %15, align 8, !tbaa !11
  %37 = load ptr, ptr %5, align 8, !tbaa !9
  %38 = getelementptr inbounds ptr, ptr %37, i64 1
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = load i64, ptr %15, align 8, !tbaa !11
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, ptr noundef %39, i64 noundef %40)
  call void @mbedtls_ctr_drbg_init(ptr noundef %8)
  call void @mbedtls_entropy_init(ptr noundef %7)
  call void @mbedtls_md_init(ptr noundef %9)
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  %43 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %45 = load ptr, ptr @stdout, align 8, !tbaa !9
  %46 = call i32 @fflush(ptr noundef %45)
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %16, ptr align 1 @__const.main.pers, i64 4, i1 false)
  %47 = getelementptr inbounds [4 x i8], ptr %16, i64 0, i64 0
  %48 = call i32 @mbedtls_ctr_drbg_seed(ptr noundef %8, ptr noundef @mbedtls_entropy_func, ptr noundef %7, ptr noundef %47, i64 noundef 4)
  store i32 %48, ptr %6, align 4, !tbaa !5
  %49 = load i32, ptr %6, align 4, !tbaa !5
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %54

51:                                               ; preds = %29
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %52)
  br label %126

54:                                               ; preds = %29
  %55 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  %56 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  %57 = load ptr, ptr @stdout, align 8, !tbaa !9
  %58 = call i32 @fflush(ptr noundef %57)
  %59 = call ptr @mbedtls_md_info_from_type(i32 noundef 8)
  %60 = call i32 @mbedtls_md_setup(ptr noundef %9, ptr noundef %59, i32 noundef 1)
  store i32 %60, ptr %6, align 4, !tbaa !5
  %61 = load i32, ptr %6, align 4, !tbaa !5
  %62 = icmp ne i32 %61, 0
  br i1 %62, label %63, label %67

63:                                               ; preds = %54
  %64 = load i32, ptr %6, align 4, !tbaa !5
  %65 = sub nsw i32 0, %64
  %66 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, i32 noundef %65)
  br label %126

67:                                               ; preds = %54
  %68 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  %70 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 0
  %71 = call i32 @mbedtls_ctr_drbg_random(ptr noundef %8, ptr noundef %70, i64 noundef 16)
  store i32 %71, ptr %6, align 4, !tbaa !5
  %72 = load i32, ptr %6, align 4, !tbaa !5
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %74, label %78

74:                                               ; preds = %67
  %75 = load i32, ptr %6, align 4, !tbaa !5
  %76 = sub nsw i32 0, %75
  %77 = call i32 (ptr, ...) @printf(ptr noundef @.str.10, i32 noundef %76)
  br label %126

78:                                               ; preds = %67
  %79 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  %80 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  %81 = load ptr, ptr %14, align 8, !tbaa !9
  %82 = load i64, ptr %15, align 8, !tbaa !11
  %83 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 0
  %84 = getelementptr inbounds [32 x i8], ptr %11, i64 0, i64 0
  %85 = call i32 @mbedtls_pkcs5_pbkdf2_hmac(ptr noundef %9, ptr noundef %81, i64 noundef %82, ptr noundef %83, i64 noundef 16, i32 noundef 100000, i32 noundef 32, ptr noundef %84)
  store i32 %85, ptr %6, align 4, !tbaa !5
  %86 = load i32, ptr %6, align 4, !tbaa !5
  %87 = icmp ne i32 %86, 0
  br i1 %87, label %88, label %92

88:                                               ; preds = %78
  %89 = load i32, ptr %6, align 4, !tbaa !5
  %90 = sub nsw i32 0, %89
  %91 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, i32 noundef %90)
  br label %126

92:                                               ; preds = %78
  %93 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  %94 = call i32 (ptr, ...) @printf(ptr noundef @.str.13, i32 noundef 16)
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  store i64 0, ptr %17, align 8, !tbaa !11
  br label %95

95:                                               ; preds = %105, %92
  %96 = load i64, ptr %17, align 8, !tbaa !11
  %97 = icmp ult i64 %96, 16
  br i1 %97, label %99, label %98

98:                                               ; preds = %95
  store i32 3, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  br label %108

99:                                               ; preds = %95
  %100 = load i64, ptr %17, align 8, !tbaa !11
  %101 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 %100
  %102 = load i8, ptr %101, align 1, !tbaa !13
  %103 = zext i8 %102 to i32
  %104 = call i32 (ptr, ...) @printf(ptr noundef @.str.14, i32 noundef %103)
  br label %105

105:                                              ; preds = %99
  %106 = load i64, ptr %17, align 8, !tbaa !11
  %107 = add i64 %106, 1
  store i64 %107, ptr %17, align 8, !tbaa !11
  br label %95, !llvm.loop !14

108:                                              ; preds = %98
  %109 = call i32 (ptr, ...) @printf(ptr noundef @.str.15)
  %110 = call i32 (ptr, ...) @printf(ptr noundef @.str.16, i32 noundef 32)
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  store i64 0, ptr %18, align 8, !tbaa !11
  br label %111

111:                                              ; preds = %121, %108
  %112 = load i64, ptr %18, align 8, !tbaa !11
  %113 = icmp ult i64 %112, 32
  br i1 %113, label %115, label %114

114:                                              ; preds = %111
  store i32 6, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  br label %124

115:                                              ; preds = %111
  %116 = load i64, ptr %18, align 8, !tbaa !11
  %117 = getelementptr inbounds [32 x i8], ptr %11, i64 0, i64 %116
  %118 = load i8, ptr %117, align 1, !tbaa !13
  %119 = zext i8 %118 to i32
  %120 = call i32 (ptr, ...) @printf(ptr noundef @.str.14, i32 noundef %119)
  br label %121

121:                                              ; preds = %115
  %122 = load i64, ptr %18, align 8, !tbaa !11
  %123 = add i64 %122, 1
  store i64 %123, ptr %18, align 8, !tbaa !11
  br label %111, !llvm.loop !16

124:                                              ; preds = %114
  %125 = call i32 (ptr, ...) @printf(ptr noundef @.str.15)
  br label %126

126:                                              ; preds = %124, %88, %74, %63, %51
  %127 = load i32, ptr %6, align 4, !tbaa !5
  %128 = icmp ne i32 %127, 0
  br i1 %128, label %129, label %134

129:                                              ; preds = %126
  %130 = load i32, ptr %6, align 4, !tbaa !5
  %131 = getelementptr inbounds [80 x i8], ptr %12, i64 0, i64 0
  call void @mbedtls_strerror(i32 noundef %130, ptr noundef %131, i64 noundef 80)
  %132 = getelementptr inbounds [80 x i8], ptr %12, i64 0, i64 0
  %133 = call i32 (ptr, ...) @printf(ptr noundef @.str.17, ptr noundef %132)
  br label %134

134:                                              ; preds = %129, %126
  call void @mbedtls_ctr_drbg_free(ptr noundef %8)
  call void @mbedtls_entropy_free(ptr noundef %7)
  call void @mbedtls_md_free(ptr noundef %9)
  %135 = load i32, ptr %6, align 4, !tbaa !5
  %136 = icmp ne i32 %135, 0
  %137 = zext i1 %136 to i32
  store i32 %137, ptr %3, align 4
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %138

138:                                              ; preds = %134, %21
  call void @llvm.lifetime.end.p0(i64 80, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 344, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %139 = load i32, ptr %3, align 4
  ret i32 %139
}

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

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

declare void @mbedtls_ctr_drbg_init(ptr noundef) #2

declare void @mbedtls_entropy_init(ptr noundef) #2

declare void @mbedtls_md_init(ptr noundef) #2

declare i32 @fflush(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) #4

declare i32 @mbedtls_ctr_drbg_seed(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) #2

declare i32 @mbedtls_entropy_func(ptr noundef, ptr noundef, i64 noundef) #2

declare i32 @mbedtls_md_setup(ptr noundef, ptr noundef, i32 noundef) #2

declare ptr @mbedtls_md_info_from_type(i32 noundef) #2

declare i32 @mbedtls_ctr_drbg_random(ptr noundef, ptr noundef, i64 noundef) #2

declare i32 @mbedtls_pkcs5_pbkdf2_hmac(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, i32 noundef, i32 noundef, ptr noundef) #2

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

declare void @mbedtls_strerror(i32 noundef, ptr noundef, i64 noundef) #2

declare void @mbedtls_ctr_drbg_free(ptr noundef) #2

declare void @mbedtls_entropy_free(ptr noundef) #2

declare void @mbedtls_md_free(ptr noundef) #2

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { nounwind willreturn memory(read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }
attributes #6 = { nounwind willreturn memory(read) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


; 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_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 }
%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] }
%struct.mbedtls_md_context_t = type { ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [47 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [43 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@__const.main.pers = external hidden unnamed_addr constant [4 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [63 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca %struct.mbedtls_entropy_context, align 8
  %4 = alloca %struct.mbedtls_ctr_drbg_context, align 8
  %5 = alloca %struct.mbedtls_md_context_t, align 8
  %6 = alloca [16 x i8], align 16
  %7 = alloca [32 x i8], align 16
  %8 = alloca [80 x i8], align 16
  %9 = alloca [4 x i8], align 4
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 344, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %7) #5
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %8) #5
  %10 = icmp slt i32 %0, 2
  br i1 %10, label %11, label %14

11:                                               ; preds = %2
  %12 = load ptr, ptr %1, align 8, !tbaa !5
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef %12, ptr noundef %12)
  br label %252

14:                                               ; preds = %2
  %15 = getelementptr inbounds i8, ptr %1, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %16) #6
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, ptr noundef %16, i64 noundef %17)
  call void @mbedtls_ctr_drbg_init(ptr noundef nonnull %4) #5
  call void @mbedtls_entropy_init(ptr noundef nonnull %3) #5
  call void @mbedtls_md_init(ptr noundef nonnull %5) #5
  %19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %22 = load ptr, ptr @stdout, align 8, !tbaa !5
  %23 = call i32 @fflush(ptr noundef %22)
  %24 = load i32, ptr @__const.main.pers, align 1
  store i32 %24, ptr %9, align 4
  %25 = call i32 @mbedtls_ctr_drbg_seed(ptr noundef nonnull %4, ptr noundef nonnull @mbedtls_entropy_func, ptr noundef nonnull %3, ptr noundef nonnull %9, i64 noundef 4) #5
  %.not = icmp eq i32 %25, 0
  br i1 %.not, label %28, label %26

26:                                               ; preds = %14
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %25)
  br label %248

28:                                               ; preds = %14
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %30 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  %31 = load ptr, ptr @stdout, align 8, !tbaa !5
  %32 = call i32 @fflush(ptr noundef %31)
  %33 = call ptr @mbedtls_md_info_from_type(i32 noundef 8) #5
  %34 = call i32 @mbedtls_md_setup(ptr noundef nonnull %5, ptr noundef %33, i32 noundef 1) #5
  %.not33 = icmp eq i32 %34, 0
  br i1 %.not33, label %38, label %35

35:                                               ; preds = %28
  %36 = sub nsw i32 0, %34
  %37 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, i32 noundef %36)
  br label %248

38:                                               ; preds = %28
  %39 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %40 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  %41 = call i32 @mbedtls_ctr_drbg_random(ptr noundef nonnull %4, ptr noundef nonnull %6, i64 noundef 16) #5
  %.not34 = icmp eq i32 %41, 0
  br i1 %.not34, label %45, label %42

42:                                               ; preds = %38
  %43 = sub nsw i32 0, %41
  %44 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10, i32 noundef %43)
  br label %248

45:                                               ; preds = %38
  %46 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %47 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  %48 = call i32 @mbedtls_pkcs5_pbkdf2_hmac(ptr noundef nonnull %5, ptr noundef %16, i64 noundef %17, ptr noundef nonnull %6, i64 noundef 16, i32 noundef 100000, i32 noundef 32, ptr noundef nonnull %7) #5
  %.not35 = icmp eq i32 %48, 0
  br i1 %.not35, label %52, label %49

49:                                               ; preds = %45
  %50 = sub nsw i32 0, %48
  %51 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, i32 noundef %50)
  br label %248

52:                                               ; preds = %45
  %53 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %54 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13, i32 noundef 16)
  %55 = load i8, ptr %6, align 16, !tbaa !9
  %56 = zext i8 %55 to i32
  %57 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %56)
  %58 = getelementptr inbounds i8, ptr %6, i64 1
  %59 = load i8, ptr %58, align 1, !tbaa !9
  %60 = zext i8 %59 to i32
  %61 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %60)
  %62 = getelementptr inbounds i8, ptr %6, i64 2
  %63 = load i8, ptr %62, align 2, !tbaa !9
  %64 = zext i8 %63 to i32
  %65 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %64)
  %66 = getelementptr inbounds i8, ptr %6, i64 3
  %67 = load i8, ptr %66, align 1, !tbaa !9
  %68 = zext i8 %67 to i32
  %69 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %68)
  %70 = getelementptr inbounds i8, ptr %6, i64 4
  %71 = load i8, ptr %70, align 4, !tbaa !9
  %72 = zext i8 %71 to i32
  %73 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %72)
  %74 = getelementptr inbounds i8, ptr %6, i64 5
  %75 = load i8, ptr %74, align 1, !tbaa !9
  %76 = zext i8 %75 to i32
  %77 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %76)
  %78 = getelementptr inbounds i8, ptr %6, i64 6
  %79 = load i8, ptr %78, align 2, !tbaa !9
  %80 = zext i8 %79 to i32
  %81 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %80)
  %82 = getelementptr inbounds i8, ptr %6, i64 7
  %83 = load i8, ptr %82, align 1, !tbaa !9
  %84 = zext i8 %83 to i32
  %85 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %84)
  %86 = getelementptr inbounds i8, ptr %6, i64 8
  %87 = load i8, ptr %86, align 8, !tbaa !9
  %88 = zext i8 %87 to i32
  %89 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %88)
  %90 = getelementptr inbounds i8, ptr %6, i64 9
  %91 = load i8, ptr %90, align 1, !tbaa !9
  %92 = zext i8 %91 to i32
  %93 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %92)
  %94 = getelementptr inbounds i8, ptr %6, i64 10
  %95 = load i8, ptr %94, align 2, !tbaa !9
  %96 = zext i8 %95 to i32
  %97 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %96)
  %98 = getelementptr inbounds i8, ptr %6, i64 11
  %99 = load i8, ptr %98, align 1, !tbaa !9
  %100 = zext i8 %99 to i32
  %101 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %100)
  %102 = getelementptr inbounds i8, ptr %6, i64 12
  %103 = load i8, ptr %102, align 4, !tbaa !9
  %104 = zext i8 %103 to i32
  %105 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %104)
  %106 = getelementptr inbounds i8, ptr %6, i64 13
  %107 = load i8, ptr %106, align 1, !tbaa !9
  %108 = zext i8 %107 to i32
  %109 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %108)
  %110 = getelementptr inbounds i8, ptr %6, i64 14
  %111 = load i8, ptr %110, align 2, !tbaa !9
  %112 = zext i8 %111 to i32
  %113 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %112)
  %114 = getelementptr inbounds i8, ptr %6, i64 15
  %115 = load i8, ptr %114, align 1, !tbaa !9
  %116 = zext i8 %115 to i32
  %117 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %116)
  %118 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15)
  %119 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16, i32 noundef 32)
  %120 = load i8, ptr %7, align 16, !tbaa !9
  %121 = zext i8 %120 to i32
  %122 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %121)
  %123 = getelementptr inbounds i8, ptr %7, i64 1
  %124 = load i8, ptr %123, align 1, !tbaa !9
  %125 = zext i8 %124 to i32
  %126 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %125)
  %127 = getelementptr inbounds i8, ptr %7, i64 2
  %128 = load i8, ptr %127, align 2, !tbaa !9
  %129 = zext i8 %128 to i32
  %130 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %129)
  %131 = getelementptr inbounds i8, ptr %7, i64 3
  %132 = load i8, ptr %131, align 1, !tbaa !9
  %133 = zext i8 %132 to i32
  %134 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %133)
  %135 = getelementptr inbounds i8, ptr %7, i64 4
  %136 = load i8, ptr %135, align 4, !tbaa !9
  %137 = zext i8 %136 to i32
  %138 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %137)
  %139 = getelementptr inbounds i8, ptr %7, i64 5
  %140 = load i8, ptr %139, align 1, !tbaa !9
  %141 = zext i8 %140 to i32
  %142 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %141)
  %143 = getelementptr inbounds i8, ptr %7, i64 6
  %144 = load i8, ptr %143, align 2, !tbaa !9
  %145 = zext i8 %144 to i32
  %146 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %145)
  %147 = getelementptr inbounds i8, ptr %7, i64 7
  %148 = load i8, ptr %147, align 1, !tbaa !9
  %149 = zext i8 %148 to i32
  %150 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %149)
  %151 = getelementptr inbounds i8, ptr %7, i64 8
  %152 = load i8, ptr %151, align 8, !tbaa !9
  %153 = zext i8 %152 to i32
  %154 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %153)
  %155 = getelementptr inbounds i8, ptr %7, i64 9
  %156 = load i8, ptr %155, align 1, !tbaa !9
  %157 = zext i8 %156 to i32
  %158 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %157)
  %159 = getelementptr inbounds i8, ptr %7, i64 10
  %160 = load i8, ptr %159, align 2, !tbaa !9
  %161 = zext i8 %160 to i32
  %162 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %161)
  %163 = getelementptr inbounds i8, ptr %7, i64 11
  %164 = load i8, ptr %163, align 1, !tbaa !9
  %165 = zext i8 %164 to i32
  %166 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %165)
  %167 = getelementptr inbounds i8, ptr %7, i64 12
  %168 = load i8, ptr %167, align 4, !tbaa !9
  %169 = zext i8 %168 to i32
  %170 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %169)
  %171 = getelementptr inbounds i8, ptr %7, i64 13
  %172 = load i8, ptr %171, align 1, !tbaa !9
  %173 = zext i8 %172 to i32
  %174 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %173)
  %175 = getelementptr inbounds i8, ptr %7, i64 14
  %176 = load i8, ptr %175, align 2, !tbaa !9
  %177 = zext i8 %176 to i32
  %178 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %177)
  %179 = getelementptr inbounds i8, ptr %7, i64 15
  %180 = load i8, ptr %179, align 1, !tbaa !9
  %181 = zext i8 %180 to i32
  %182 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %181)
  %183 = getelementptr inbounds i8, ptr %7, i64 16
  %184 = load i8, ptr %183, align 16, !tbaa !9
  %185 = zext i8 %184 to i32
  %186 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %185)
  %187 = getelementptr inbounds i8, ptr %7, i64 17
  %188 = load i8, ptr %187, align 1, !tbaa !9
  %189 = zext i8 %188 to i32
  %190 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %189)
  %191 = getelementptr inbounds i8, ptr %7, i64 18
  %192 = load i8, ptr %191, align 2, !tbaa !9
  %193 = zext i8 %192 to i32
  %194 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %193)
  %195 = getelementptr inbounds i8, ptr %7, i64 19
  %196 = load i8, ptr %195, align 1, !tbaa !9
  %197 = zext i8 %196 to i32
  %198 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %197)
  %199 = getelementptr inbounds i8, ptr %7, i64 20
  %200 = load i8, ptr %199, align 4, !tbaa !9
  %201 = zext i8 %200 to i32
  %202 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %201)
  %203 = getelementptr inbounds i8, ptr %7, i64 21
  %204 = load i8, ptr %203, align 1, !tbaa !9
  %205 = zext i8 %204 to i32
  %206 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %205)
  %207 = getelementptr inbounds i8, ptr %7, i64 22
  %208 = load i8, ptr %207, align 2, !tbaa !9
  %209 = zext i8 %208 to i32
  %210 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %209)
  %211 = getelementptr inbounds i8, ptr %7, i64 23
  %212 = load i8, ptr %211, align 1, !tbaa !9
  %213 = zext i8 %212 to i32
  %214 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %213)
  %215 = getelementptr inbounds i8, ptr %7, i64 24
  %216 = load i8, ptr %215, align 8, !tbaa !9
  %217 = zext i8 %216 to i32
  %218 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %217)
  %219 = getelementptr inbounds i8, ptr %7, i64 25
  %220 = load i8, ptr %219, align 1, !tbaa !9
  %221 = zext i8 %220 to i32
  %222 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %221)
  %223 = getelementptr inbounds i8, ptr %7, i64 26
  %224 = load i8, ptr %223, align 2, !tbaa !9
  %225 = zext i8 %224 to i32
  %226 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %225)
  %227 = getelementptr inbounds i8, ptr %7, i64 27
  %228 = load i8, ptr %227, align 1, !tbaa !9
  %229 = zext i8 %228 to i32
  %230 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %229)
  %231 = getelementptr inbounds i8, ptr %7, i64 28
  %232 = load i8, ptr %231, align 4, !tbaa !9
  %233 = zext i8 %232 to i32
  %234 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %233)
  %235 = getelementptr inbounds i8, ptr %7, i64 29
  %236 = load i8, ptr %235, align 1, !tbaa !9
  %237 = zext i8 %236 to i32
  %238 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %237)
  %239 = getelementptr inbounds i8, ptr %7, i64 30
  %240 = load i8, ptr %239, align 2, !tbaa !9
  %241 = zext i8 %240 to i32
  %242 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %241)
  %243 = getelementptr inbounds i8, ptr %7, i64 31
  %244 = load i8, ptr %243, align 1, !tbaa !9
  %245 = zext i8 %244 to i32
  %246 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, i32 noundef %245)
  %247 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15)
  br label %250

248:                                              ; preds = %26, %35, %42, %49
  %.028.ph = phi i32 [ %48, %49 ], [ %41, %42 ], [ %34, %35 ], [ %25, %26 ]
  call void @mbedtls_strerror(i32 noundef %.028.ph, ptr noundef nonnull %8, i64 noundef 80) #5
  %249 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17, ptr noundef nonnull %8)
  br label %250

250:                                              ; preds = %52, %248
  %251 = phi i32 [ 1, %248 ], [ 0, %52 ]
  call void @mbedtls_ctr_drbg_free(ptr noundef nonnull %4) #5
  call void @mbedtls_entropy_free(ptr noundef nonnull %3) #5
  call void @mbedtls_md_free(ptr noundef nonnull %5) #5
  br label %252

252:                                              ; preds = %250, %11
  %.027 = phi i32 [ -1, %11 ], [ %251, %250 ]
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 344, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %3) #5
  ret i32 %.027
}

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #3

declare void @mbedtls_ctr_drbg_init(ptr noundef) local_unnamed_addr #4

declare void @mbedtls_entropy_init(ptr noundef) local_unnamed_addr #4

declare void @mbedtls_md_init(ptr noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #2

declare i32 @mbedtls_ctr_drbg_seed(ptr noundef, ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

declare i32 @mbedtls_entropy_func(ptr noundef, ptr noundef, i64 noundef) #4

declare i32 @mbedtls_md_setup(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

declare ptr @mbedtls_md_info_from_type(i32 noundef) local_unnamed_addr #4

declare i32 @mbedtls_ctr_drbg_random(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

declare i32 @mbedtls_pkcs5_pbkdf2_hmac(ptr noundef, ptr noundef, i64 noundef, ptr noundef, i64 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

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

declare void @mbedtls_strerror(i32 noundef, ptr noundef, i64 noundef) local_unnamed_addr #4

declare void @mbedtls_ctr_drbg_free(ptr noundef) local_unnamed_addr #4

declare void @mbedtls_entropy_free(ptr noundef) local_unnamed_addr #4

declare void @mbedtls_md_free(ptr noundef) local_unnamed_addr #4

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 }
attributes #6 = { nounwind willreturn memory(read) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass