; LLVM IR from ARMmbed/mbed-crypto :: programs/pkey (dh_genprime)

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

@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [96 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [44 x i8], align 1
@stdout = external global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [6 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 i32, align 4
  %8 = alloca %struct.mbedtls_mpi, align 8
  %9 = alloca %struct.mbedtls_mpi, align 8
  %10 = alloca %struct.mbedtls_mpi, align 8
  %11 = alloca %struct.mbedtls_entropy_context, align 8
  %12 = alloca %struct.mbedtls_ctr_drbg_context, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i32, align 4
  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
  store i32 1, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 1032, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 344, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  store ptr @.str, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  store i32 2048, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  call void @mbedtls_mpi_init(ptr noundef %8)
  call void @mbedtls_mpi_init(ptr noundef %9)
  call void @mbedtls_mpi_init(ptr noundef %10)
  call void @mbedtls_ctr_drbg_init(ptr noundef %12)
  call void @mbedtls_entropy_init(ptr noundef %11)
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = icmp eq i32 %20, 0
  br i1 %21, label %22, label %26

22:                                               ; preds = %2
  br label %23

23:                                               ; preds = %57, %55, %40, %22
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  %25 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %25, ptr %3, align 4
  store i32 1, ptr %19, align 4
  br label %142

26:                                               ; preds = %2
  store i32 1, ptr %16, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %59, %26
  %28 = load i32, ptr %16, align 4, !tbaa !5
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %31, label %62

31:                                               ; preds = %27
  %32 = load ptr, ptr %5, align 8, !tbaa !9
  %33 = load i32, ptr %16, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds ptr, ptr %32, i64 %34
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  store ptr %36, ptr %17, align 8, !tbaa !9
  %37 = load ptr, ptr %17, align 8, !tbaa !9
  %38 = call ptr @strchr(ptr noundef %37, i32 noundef 61) #6
  store ptr %38, ptr %18, align 8, !tbaa !9
  %39 = icmp eq ptr %38, null
  br i1 %39, label %40, label %41

40:                                               ; preds = %31
  br label %23

41:                                               ; preds = %31
  %42 = load ptr, ptr %18, align 8, !tbaa !9
  %43 = getelementptr inbounds i8, ptr %42, i32 1
  store ptr %43, ptr %18, align 8, !tbaa !9
  store i8 0, ptr %42, align 1, !tbaa !11
  %44 = load ptr, ptr %17, align 8, !tbaa !9
  %45 = call i32 @strcmp(ptr noundef %44, ptr noundef @.str.2) #6
  %46 = icmp eq i32 %45, 0
  br i1 %46, label %47, label %57

47:                                               ; preds = %41
  %48 = load ptr, ptr %18, align 8, !tbaa !9
  %49 = call i32 @atoi(ptr noundef %48) #6
  store i32 %49, ptr %15, align 4, !tbaa !5
  %50 = load i32, ptr %15, align 4, !tbaa !5
  %51 = icmp slt i32 %50, 0
  br i1 %51, label %55, label %52

52:                                               ; preds = %47
  %53 = load i32, ptr %15, align 4, !tbaa !5
  %54 = icmp sgt i32 %53, 8192
  br i1 %54, label %55, label %56

55:                                               ; preds = %52, %47
  br label %23

56:                                               ; preds = %52
  br label %58

57:                                               ; preds = %41
  br label %23

58:                                               ; preds = %56
  br label %59

59:                                               ; preds = %58
  %60 = load i32, ptr %16, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %16, align 4, !tbaa !5
  br label %27, !llvm.loop !12

62:                                               ; preds = %27
  %63 = call i32 @mbedtls_mpi_read_string(ptr noundef %8, i32 noundef 10, ptr noundef @.str.3)
  store i32 %63, ptr %6, align 4, !tbaa !5
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %68

65:                                               ; preds = %62
  %66 = load i32, ptr %6, align 4, !tbaa !5
  %67 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %66)
  br label %140

68:                                               ; preds = %62
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  %71 = load ptr, ptr @stdout, align 8, !tbaa !9
  %72 = call i32 @fflush(ptr noundef %71)
  %73 = load ptr, ptr %13, align 8, !tbaa !9
  %74 = load ptr, ptr %13, align 8, !tbaa !9
  %75 = call i64 @strlen(ptr noundef %74) #6
  %76 = call i32 @mbedtls_ctr_drbg_seed(ptr noundef %12, ptr noundef @mbedtls_entropy_func, ptr noundef %11, ptr noundef %73, i64 noundef %75)
  store i32 %76, ptr %6, align 4, !tbaa !5
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %78, label %81

78:                                               ; preds = %68
  %79 = load i32, ptr %6, align 4, !tbaa !5
  %80 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %79)
  br label %140

81:                                               ; preds = %68
  %82 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  %83 = load ptr, ptr @stdout, align 8, !tbaa !9
  %84 = call i32 @fflush(ptr noundef %83)
  %85 = load i32, ptr %15, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = call i32 @mbedtls_mpi_gen_prime(ptr noundef %9, i64 noundef %86, i32 noundef 1, ptr noundef @mbedtls_ctr_drbg_random, ptr noundef %12)
  store i32 %87, ptr %6, align 4, !tbaa !5
  %88 = icmp ne i32 %87, 0
  br i1 %88, label %89, label %92

89:                                               ; preds = %81
  %90 = load i32, ptr %6, align 4, !tbaa !5
  %91 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, i32 noundef %90)
  br label %140

92:                                               ; preds = %81
  %93 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  %94 = load ptr, ptr @stdout, align 8, !tbaa !9
  %95 = call i32 @fflush(ptr noundef %94)
  %96 = call i32 @mbedtls_mpi_sub_int(ptr noundef %10, ptr noundef %9, i64 noundef 1)
  store i32 %96, ptr %6, align 4, !tbaa !5
  %97 = icmp ne i32 %96, 0
  br i1 %97, label %98, label %101

98:                                               ; preds = %92
  %99 = load i32, ptr %6, align 4, !tbaa !5
  %100 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, i32 noundef %99)
  br label %140

101:                                              ; preds = %92
  %102 = call i32 @mbedtls_mpi_div_int(ptr noundef %10, ptr noundef null, ptr noundef %10, i64 noundef 2)
  store i32 %102, ptr %6, align 4, !tbaa !5
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %104, label %107

104:                                              ; preds = %101
  %105 = load i32, ptr %6, align 4, !tbaa !5
  %106 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, i32 noundef %105)
  br label %140

107:                                              ; preds = %101
  %108 = call i32 @mbedtls_mpi_is_prime_ext(ptr noundef %10, i32 noundef 50, ptr noundef @mbedtls_ctr_drbg_random, ptr noundef %12)
  store i32 %108, ptr %6, align 4, !tbaa !5
  %109 = icmp ne i32 %108, 0
  br i1 %109, label %110, label %113

110:                                              ; preds = %107
  %111 = load i32, ptr %6, align 4, !tbaa !5
  %112 = call i32 (ptr, ...) @printf(ptr noundef @.str.13, i32 noundef %111)
  br label %140

113:                                              ; preds = %107
  %114 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  %115 = load ptr, ptr @stdout, align 8, !tbaa !9
  %116 = call i32 @fflush(ptr noundef %115)
  %117 = call noalias ptr @fopen(ptr noundef @.str.15, ptr noundef @.str.16)
  store ptr %117, ptr %14, align 8, !tbaa !9
  %118 = icmp eq ptr %117, null
  br i1 %118, label %119, label %121

119:                                              ; preds = %113
  %120 = call i32 (ptr, ...) @printf(ptr noundef @.str.17)
  br label %140

121:                                              ; preds = %113
  %122 = load ptr, ptr %14, align 8, !tbaa !9
  %123 = call i32 @mbedtls_mpi_write_file(ptr noundef @.str.18, ptr noundef %9, i32 noundef 16, ptr noundef %122)
  %124 = icmp ne i32 %123, 0
  %125 = zext i1 %124 to i32
  store i32 %125, ptr %6, align 4, !tbaa !5
  br i1 %124, label %131, label %126

126:                                              ; preds = %121
  %127 = load ptr, ptr %14, align 8, !tbaa !9
  %128 = call i32 @mbedtls_mpi_write_file(ptr noundef @.str.19, ptr noundef %8, i32 noundef 16, ptr noundef %127)
  %129 = icmp ne i32 %128, 0
  %130 = zext i1 %129 to i32
  store i32 %130, ptr %6, align 4, !tbaa !5
  br i1 %129, label %131, label %136

131:                                              ; preds = %126, %121
  %132 = load i32, ptr %6, align 4, !tbaa !5
  %133 = call i32 (ptr, ...) @printf(ptr noundef @.str.20, i32 noundef %132)
  %134 = load ptr, ptr %14, align 8, !tbaa !9
  %135 = call i32 @fclose(ptr noundef %134)
  br label %140

136:                                              ; preds = %126
  %137 = call i32 (ptr, ...) @printf(ptr noundef @.str.21)
  %138 = load ptr, ptr %14, align 8, !tbaa !9
  %139 = call i32 @fclose(ptr noundef %138)
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %140

140:                                              ; preds = %136, %131, %119, %110, %104, %98, %89, %78, %65
  call void @mbedtls_mpi_free(ptr noundef %8)
  call void @mbedtls_mpi_free(ptr noundef %9)
  call void @mbedtls_mpi_free(ptr noundef %10)
  call void @mbedtls_ctr_drbg_free(ptr noundef %12)
  call void @mbedtls_entropy_free(ptr noundef %11)
  %141 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %141, ptr %3, align 4
  store i32 1, ptr %19, align 4
  br label %142

142:                                              ; preds = %140, %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 344, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 1032, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  %143 = load i32, ptr %3, align 4
  ret i32 %143
}

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

declare void @mbedtls_mpi_init(ptr noundef) #2

declare void @mbedtls_ctr_drbg_init(ptr noundef) #2

declare void @mbedtls_entropy_init(ptr noundef) #2

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

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strchr(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #3

; Function Attrs: inlinehint nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr noundef nonnull) #4

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

declare i32 @fflush(ptr noundef) #2

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

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

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

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

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

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

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

declare noalias ptr @fopen(ptr noundef, ptr noundef) #2

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

declare i32 @fclose(ptr noundef) #2

declare void @mbedtls_mpi_free(ptr noundef) #2

declare void @mbedtls_ctr_drbg_free(ptr noundef) #2

declare void @mbedtls_entropy_free(ptr noundef) #2

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

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 = { inlinehint nounwind willreturn memory(read) 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 #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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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

@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [96 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [44 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca %struct.mbedtls_mpi, align 8
  %4 = alloca %struct.mbedtls_mpi, align 8
  %5 = alloca %struct.mbedtls_mpi, align 8
  %6 = alloca %struct.mbedtls_entropy_context, align 8
  %7 = alloca %struct.mbedtls_ctr_drbg_context, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %3) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 1032, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 344, ptr nonnull %7) #6
  call void @mbedtls_mpi_init(ptr noundef nonnull %3) #6
  call void @mbedtls_mpi_init(ptr noundef nonnull %4) #6
  call void @mbedtls_mpi_init(ptr noundef nonnull %5) #6
  call void @mbedtls_ctr_drbg_init(ptr noundef nonnull %7) #6
  call void @mbedtls_entropy_init(ptr noundef nonnull %6) #6
  %8 = icmp eq i32 %0, 0
  br i1 %8, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %2
  %9 = icmp sgt i32 %0, 1
  br i1 %9, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %.preheader
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %.lr.ph

.loopexit:                                        ; preds = %16, %19, %.lr.ph, %2
  %10 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %76

11:                                               ; preds = %19
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !5

.lr.ph:                                           ; preds = %.lr.ph.preheader, %11
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next, %11 ]
  %12 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv
  %13 = load ptr, ptr %12, align 8, !tbaa !7
  %14 = call ptr @strchr(ptr noundef nonnull dereferenceable(1) %13, i32 noundef 61) #7
  %15 = icmp eq ptr %14, null
  br i1 %15, label %.loopexit, label %16

16:                                               ; preds = %.lr.ph
  store i8 0, ptr %14, align 1, !tbaa !11
  %17 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %13, ptr noundef nonnull dereferenceable(1) @.str.2) #7
  %18 = icmp eq i32 %17, 0
  br i1 %18, label %19, label %.loopexit

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %14, i64 1
  %21 = call i32 @atoi(ptr nocapture noundef %20) #7
  %or.cond = icmp ugt i32 %21, 8192
  br i1 %or.cond, label %.loopexit, label %11

._crit_edge.loopexit:                             ; preds = %11
  %22 = zext nneg i32 %21 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %.030.lcssa = phi i64 [ 2048, %.preheader ], [ %22, %._crit_edge.loopexit ]
  %23 = call i32 @mbedtls_mpi_read_string(ptr noundef nonnull %3, i32 noundef 10, ptr noundef nonnull @.str.3) #6
  %.not = icmp eq i32 %23, 0
  br i1 %.not, label %26, label %24

24:                                               ; preds = %._crit_edge
  %25 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %23)
  br label %75

26:                                               ; preds = %._crit_edge
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %28 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %29 = load ptr, ptr @stdout, align 8, !tbaa !7
  %30 = call i32 @fflush(ptr noundef %29)
  %31 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) @.str) #7
  %32 = call i32 @mbedtls_ctr_drbg_seed(ptr noundef nonnull %7, ptr noundef nonnull @mbedtls_entropy_func, ptr noundef nonnull %6, ptr noundef nonnull @.str, i64 noundef %31) #6
  %.not43 = icmp eq i32 %32, 0
  br i1 %.not43, label %35, label %33

33:                                               ; preds = %26
  %34 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef %32)
  br label %75

35:                                               ; preds = %26
  %36 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  %37 = load ptr, ptr @stdout, align 8, !tbaa !7
  %38 = call i32 @fflush(ptr noundef %37)
  %39 = call i32 @mbedtls_mpi_gen_prime(ptr noundef nonnull %4, i64 noundef %.030.lcssa, i32 noundef 1, ptr noundef nonnull @mbedtls_ctr_drbg_random, ptr noundef nonnull %7) #6
  %.not44 = icmp eq i32 %39, 0
  br i1 %.not44, label %42, label %40

40:                                               ; preds = %35
  %41 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, i32 noundef %39)
  br label %75

42:                                               ; preds = %35
  %43 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  %44 = load ptr, ptr @stdout, align 8, !tbaa !7
  %45 = call i32 @fflush(ptr noundef %44)
  %46 = call i32 @mbedtls_mpi_sub_int(ptr noundef nonnull %5, ptr noundef nonnull %4, i64 noundef 1) #6
  %.not45 = icmp eq i32 %46, 0
  br i1 %.not45, label %49, label %47

47:                                               ; preds = %42
  %48 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, i32 noundef %46)
  br label %75

49:                                               ; preds = %42
  %50 = call i32 @mbedtls_mpi_div_int(ptr noundef nonnull %5, ptr noundef null, ptr noundef nonnull %5, i64 noundef 2) #6
  %.not46 = icmp eq i32 %50, 0
  br i1 %.not46, label %53, label %51

51:                                               ; preds = %49
  %52 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, i32 noundef %50)
  br label %75

53:                                               ; preds = %49
  %54 = call i32 @mbedtls_mpi_is_prime_ext(ptr noundef nonnull %5, i32 noundef 50, ptr noundef nonnull @mbedtls_ctr_drbg_random, ptr noundef nonnull %7) #6
  %.not47 = icmp eq i32 %54, 0
  br i1 %.not47, label %57, label %55

55:                                               ; preds = %53
  %56 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13, i32 noundef %54)
  br label %75

57:                                               ; preds = %53
  %58 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14)
  %59 = load ptr, ptr @stdout, align 8, !tbaa !7
  %60 = call i32 @fflush(ptr noundef %59)
  %61 = call noalias ptr @fopen(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.16)
  %62 = icmp eq ptr %61, null
  br i1 %62, label %63, label %65

63:                                               ; preds = %57
  %64 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17)
  br label %75

65:                                               ; preds = %57
  %66 = call i32 @mbedtls_mpi_write_file(ptr noundef nonnull @.str.18, ptr noundef nonnull %4, i32 noundef 16, ptr noundef nonnull %61) #6
  %.not48 = icmp eq i32 %66, 0
  br i1 %.not48, label %67, label %69

67:                                               ; preds = %65
  %68 = call i32 @mbedtls_mpi_write_file(ptr noundef nonnull @.str.19, ptr noundef nonnull %3, i32 noundef 16, ptr noundef nonnull %61) #6
  %.not49 = icmp eq i32 %68, 0
  br i1 %.not49, label %72, label %69

69:                                               ; preds = %67, %65
  %70 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20, i32 noundef 1)
  %71 = call i32 @fclose(ptr noundef nonnull %61)
  br label %75

72:                                               ; preds = %67
  %73 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.21)
  %74 = call i32 @fclose(ptr noundef nonnull %61)
  br label %75

75:                                               ; preds = %72, %69, %63, %55, %51, %47, %40, %33, %24
  %.032 = phi i32 [ 1, %24 ], [ 1, %33 ], [ 1, %40 ], [ 1, %47 ], [ 1, %51 ], [ 1, %55 ], [ 1, %63 ], [ 1, %69 ], [ 0, %72 ]
  call void @mbedtls_mpi_free(ptr noundef nonnull %3) #6
  call void @mbedtls_mpi_free(ptr noundef nonnull %4) #6
  call void @mbedtls_mpi_free(ptr noundef nonnull %5) #6
  call void @mbedtls_ctr_drbg_free(ptr noundef nonnull %7) #6
  call void @mbedtls_entropy_free(ptr noundef nonnull %6) #6
  br label %76

76:                                               ; preds = %75, %.loopexit
  %.0 = phi i32 [ 1, %.loopexit ], [ %.032, %75 ]
  call void @llvm.lifetime.end.p0(i64 344, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 1032, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %3) #6
  ret i32 %.0
}

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

declare void @mbedtls_mpi_init(ptr noundef) local_unnamed_addr #2

declare void @mbedtls_ctr_drbg_init(ptr noundef) local_unnamed_addr #2

declare void @mbedtls_entropy_init(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strchr(ptr noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i32 @atoi(ptr nocapture noundef nonnull) local_unnamed_addr #5

declare i32 @mbedtls_mpi_read_string(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

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

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

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

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

declare i32 @mbedtls_mpi_gen_prime(ptr noundef, i64 noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare i32 @mbedtls_mpi_sub_int(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

declare i32 @mbedtls_mpi_div_int(ptr noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

declare i32 @mbedtls_mpi_is_prime_ext(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #3

declare i32 @mbedtls_mpi_write_file(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

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

declare void @mbedtls_mpi_free(ptr noundef) local_unnamed_addr #2

declare void @mbedtls_ctr_drbg_free(ptr noundef) local_unnamed_addr #2

declare void @mbedtls_entropy_free(ptr 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

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 = { "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 = { 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 #4 = { 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 #5 = { inlinehint mustprogress nofree nounwind willreturn memory(read) 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 #6 = { nounwind }
attributes #7 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!9, !9, i64 0}


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