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

; 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_rsa_context = type { i32, i64, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, i32, i32 }
%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 [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [44 x i8], align 1
@stdout = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca %struct.mbedtls_rsa_context, align 8
  %5 = alloca %struct.mbedtls_entropy_context, align 8
  %6 = alloca %struct.mbedtls_ctr_drbg_context, align 8
  %7 = alloca %struct.mbedtls_mpi, align 8
  %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_mpi, align 8
  %12 = alloca %struct.mbedtls_mpi, align 8
  %13 = alloca %struct.mbedtls_mpi, align 8
  %14 = alloca %struct.mbedtls_mpi, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 1, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 336, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 1032, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 344, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  store ptr null, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  store ptr null, ptr %16, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  store ptr @.str, ptr %17, align 8, !tbaa !9
  call void @mbedtls_ctr_drbg_init(ptr noundef %6)
  call void @mbedtls_rsa_init(ptr noundef %4, i32 noundef 0, i32 noundef 0)
  call void @mbedtls_mpi_init(ptr noundef %7)
  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_mpi_init(ptr noundef %11)
  call void @mbedtls_mpi_init(ptr noundef %12)
  call void @mbedtls_mpi_init(ptr noundef %13)
  call void @mbedtls_mpi_init(ptr noundef %14)
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  %19 = load ptr, ptr @stdout, align 8, !tbaa !9
  %20 = call i32 @fflush(ptr noundef %19)
  call void @mbedtls_entropy_init(ptr noundef %5)
  %21 = load ptr, ptr %17, align 8, !tbaa !9
  %22 = load ptr, ptr %17, align 8, !tbaa !9
  %23 = call i64 @strlen(ptr noundef %22) #5
  %24 = call i32 @mbedtls_ctr_drbg_seed(ptr noundef %6, ptr noundef @mbedtls_entropy_func, ptr noundef %5, ptr noundef %21, i64 noundef %23)
  store i32 %24, ptr %2, align 4, !tbaa !5
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %29

26:                                               ; preds = %0
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %27)
  br label %110

29:                                               ; preds = %0
  %30 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef 2048)
  %31 = load ptr, ptr @stdout, align 8, !tbaa !9
  %32 = call i32 @fflush(ptr noundef %31)
  %33 = call i32 @mbedtls_rsa_gen_key(ptr noundef %4, ptr noundef @mbedtls_ctr_drbg_random, ptr noundef %6, i32 noundef 2048, i32 noundef 65537)
  store i32 %33, ptr %2, align 4, !tbaa !5
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %38

35:                                               ; preds = %29
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %36)
  br label %110

38:                                               ; preds = %29
  %39 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %40 = load ptr, ptr @stdout, align 8, !tbaa !9
  %41 = call i32 @fflush(ptr noundef %40)
  %42 = call i32 @mbedtls_rsa_export(ptr noundef %4, ptr noundef %7, ptr noundef %8, ptr noundef %9, ptr noundef %10, ptr noundef %11)
  store i32 %42, ptr %2, align 4, !tbaa !5
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %47, label %44

44:                                               ; preds = %38
  %45 = call i32 @mbedtls_rsa_export_crt(ptr noundef %4, ptr noundef %12, ptr noundef %13, ptr noundef %14)
  store i32 %45, ptr %2, align 4, !tbaa !5
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %49

47:                                               ; preds = %44, %38
  %48 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  br label %110

49:                                               ; preds = %44
  %50 = call noalias ptr @fopen(ptr noundef @.str.7, ptr noundef @.str.8)
  store ptr %50, ptr %15, align 8, !tbaa !9
  %51 = icmp eq ptr %50, null
  br i1 %51, label %52, label %54

52:                                               ; preds = %49
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  br label %110

54:                                               ; preds = %49
  %55 = load ptr, ptr %15, align 8, !tbaa !9
  %56 = call i32 @mbedtls_mpi_write_file(ptr noundef @.str.10, ptr noundef %7, i32 noundef 16, ptr noundef %55)
  store i32 %56, ptr %2, align 4, !tbaa !5
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %62, label %58

58:                                               ; preds = %54
  %59 = load ptr, ptr %15, align 8, !tbaa !9
  %60 = call i32 @mbedtls_mpi_write_file(ptr noundef @.str.11, ptr noundef %11, i32 noundef 16, ptr noundef %59)
  store i32 %60, ptr %2, align 4, !tbaa !5
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %65

62:                                               ; preds = %58, %54
  %63 = load i32, ptr %2, align 4, !tbaa !5
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, i32 noundef %63)
  br label %110

65:                                               ; preds = %58
  %66 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  %67 = load ptr, ptr @stdout, align 8, !tbaa !9
  %68 = call i32 @fflush(ptr noundef %67)
  %69 = call noalias ptr @fopen(ptr noundef @.str.14, ptr noundef @.str.8)
  store ptr %69, ptr %16, align 8, !tbaa !9
  %70 = icmp eq ptr %69, null
  br i1 %70, label %71, label %73

71:                                               ; preds = %65
  %72 = call i32 (ptr, ...) @printf(ptr noundef @.str.15)
  br label %110

73:                                               ; preds = %65
  %74 = load ptr, ptr %16, align 8, !tbaa !9
  %75 = call i32 @mbedtls_mpi_write_file(ptr noundef @.str.10, ptr noundef %7, i32 noundef 16, ptr noundef %74)
  store i32 %75, ptr %2, align 4, !tbaa !5
  %76 = icmp ne i32 %75, 0
  br i1 %76, label %105, label %77

77:                                               ; preds = %73
  %78 = load ptr, ptr %16, align 8, !tbaa !9
  %79 = call i32 @mbedtls_mpi_write_file(ptr noundef @.str.11, ptr noundef %11, i32 noundef 16, ptr noundef %78)
  store i32 %79, ptr %2, align 4, !tbaa !5
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %105, label %81

81:                                               ; preds = %77
  %82 = load ptr, ptr %16, align 8, !tbaa !9
  %83 = call i32 @mbedtls_mpi_write_file(ptr noundef @.str.16, ptr noundef %10, i32 noundef 16, ptr noundef %82)
  store i32 %83, ptr %2, align 4, !tbaa !5
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %105, label %85

85:                                               ; preds = %81
  %86 = load ptr, ptr %16, align 8, !tbaa !9
  %87 = call i32 @mbedtls_mpi_write_file(ptr noundef @.str.17, ptr noundef %8, i32 noundef 16, ptr noundef %86)
  store i32 %87, ptr %2, align 4, !tbaa !5
  %88 = icmp ne i32 %87, 0
  br i1 %88, label %105, label %89

89:                                               ; preds = %85
  %90 = load ptr, ptr %16, align 8, !tbaa !9
  %91 = call i32 @mbedtls_mpi_write_file(ptr noundef @.str.18, ptr noundef %9, i32 noundef 16, ptr noundef %90)
  store i32 %91, ptr %2, align 4, !tbaa !5
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %105, label %93

93:                                               ; preds = %89
  %94 = load ptr, ptr %16, align 8, !tbaa !9
  %95 = call i32 @mbedtls_mpi_write_file(ptr noundef @.str.19, ptr noundef %12, i32 noundef 16, ptr noundef %94)
  store i32 %95, ptr %2, align 4, !tbaa !5
  %96 = icmp ne i32 %95, 0
  br i1 %96, label %105, label %97

97:                                               ; preds = %93
  %98 = load ptr, ptr %16, align 8, !tbaa !9
  %99 = call i32 @mbedtls_mpi_write_file(ptr noundef @.str.20, ptr noundef %13, i32 noundef 16, ptr noundef %98)
  store i32 %99, ptr %2, align 4, !tbaa !5
  %100 = icmp ne i32 %99, 0
  br i1 %100, label %105, label %101

101:                                              ; preds = %97
  %102 = load ptr, ptr %16, align 8, !tbaa !9
  %103 = call i32 @mbedtls_mpi_write_file(ptr noundef @.str.21, ptr noundef %14, i32 noundef 16, ptr noundef %102)
  store i32 %103, ptr %2, align 4, !tbaa !5
  %104 = icmp ne i32 %103, 0
  br i1 %104, label %105, label %108

105:                                              ; preds = %101, %97, %93, %89, %85, %81, %77, %73
  %106 = load i32, ptr %2, align 4, !tbaa !5
  %107 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, i32 noundef %106)
  br label %110

108:                                              ; preds = %101
  %109 = call i32 (ptr, ...) @printf(ptr noundef @.str.22)
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %110

110:                                              ; preds = %108, %105, %71, %62, %52, %47, %35, %26
  %111 = load ptr, ptr %15, align 8, !tbaa !9
  %112 = icmp ne ptr %111, null
  br i1 %112, label %113, label %116

113:                                              ; preds = %110
  %114 = load ptr, ptr %15, align 8, !tbaa !9
  %115 = call i32 @fclose(ptr noundef %114)
  br label %116

116:                                              ; preds = %113, %110
  %117 = load ptr, ptr %16, align 8, !tbaa !9
  %118 = icmp ne ptr %117, null
  br i1 %118, label %119, label %122

119:                                              ; preds = %116
  %120 = load ptr, ptr %16, align 8, !tbaa !9
  %121 = call i32 @fclose(ptr noundef %120)
  br label %122

122:                                              ; preds = %119, %116
  call void @mbedtls_mpi_free(ptr noundef %7)
  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_mpi_free(ptr noundef %11)
  call void @mbedtls_mpi_free(ptr noundef %12)
  call void @mbedtls_mpi_free(ptr noundef %13)
  call void @mbedtls_mpi_free(ptr noundef %14)
  call void @mbedtls_rsa_free(ptr noundef %4)
  call void @mbedtls_ctr_drbg_free(ptr noundef %6)
  call void @mbedtls_entropy_free(ptr noundef %5)
  %123 = load i32, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 344, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 1032, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 336, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i32 %123
}

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

declare void @mbedtls_ctr_drbg_init(ptr noundef) #2

declare void @mbedtls_rsa_init(ptr noundef, i32 noundef, i32 noundef) #2

declare void @mbedtls_mpi_init(ptr noundef) #2

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

declare i32 @fflush(ptr noundef) #2

declare void @mbedtls_entropy_init(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_rsa_gen_key(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #2

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

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

declare i32 @mbedtls_rsa_export_crt(ptr noundef, ptr 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_rsa_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 = { nounwind }
attributes #5 = { 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}


; 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_rsa_context = type { i32, i64, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, i32, i32 }
%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 [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [44 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [46 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [53 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @main() local_unnamed_addr #0 {
  %1 = alloca %struct.mbedtls_rsa_context, align 8
  %2 = alloca %struct.mbedtls_entropy_context, align 8
  %3 = alloca %struct.mbedtls_ctr_drbg_context, align 8
  %4 = alloca %struct.mbedtls_mpi, align 8
  %5 = alloca %struct.mbedtls_mpi, align 8
  %6 = alloca %struct.mbedtls_mpi, align 8
  %7 = alloca %struct.mbedtls_mpi, align 8
  %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_mpi, align 8
  call void @llvm.lifetime.start.p0(i64 336, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 1032, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 344, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %10) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %11) #5
  call void @mbedtls_ctr_drbg_init(ptr noundef nonnull %3) #5
  call void @mbedtls_rsa_init(ptr noundef nonnull %1, i32 noundef 0, i32 noundef 0) #5
  call void @mbedtls_mpi_init(ptr noundef nonnull %4) #5
  call void @mbedtls_mpi_init(ptr noundef nonnull %5) #5
  call void @mbedtls_mpi_init(ptr noundef nonnull %6) #5
  call void @mbedtls_mpi_init(ptr noundef nonnull %7) #5
  call void @mbedtls_mpi_init(ptr noundef nonnull %8) #5
  call void @mbedtls_mpi_init(ptr noundef nonnull %9) #5
  call void @mbedtls_mpi_init(ptr noundef nonnull %10) #5
  call void @mbedtls_mpi_init(ptr noundef nonnull %11) #5
  %12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %13 = load ptr, ptr @stdout, align 8, !tbaa !5
  %14 = call i32 @fflush(ptr noundef %13)
  call void @mbedtls_entropy_init(ptr noundef nonnull %2) #5
  %15 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) @.str) #6
  %16 = call i32 @mbedtls_ctr_drbg_seed(ptr noundef nonnull %3, ptr noundef nonnull @mbedtls_entropy_func, ptr noundef nonnull %2, ptr noundef nonnull @.str, i64 noundef %15) #5
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %19, label %17

17:                                               ; preds = %0
  %18 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %16)
  br label %.thread60

19:                                               ; preds = %0
  %20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef 2048)
  %21 = load ptr, ptr @stdout, align 8, !tbaa !5
  %22 = call i32 @fflush(ptr noundef %21)
  %23 = call i32 @mbedtls_rsa_gen_key(ptr noundef nonnull %1, ptr noundef nonnull @mbedtls_ctr_drbg_random, ptr noundef nonnull %3, i32 noundef 2048, i32 noundef 65537) #5
  %.not39 = icmp eq i32 %23, 0
  br i1 %.not39, label %26, label %24

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

26:                                               ; preds = %19
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %28 = load ptr, ptr @stdout, align 8, !tbaa !5
  %29 = call i32 @fflush(ptr noundef %28)
  %30 = call i32 @mbedtls_rsa_export(ptr noundef nonnull %1, ptr noundef nonnull %4, ptr noundef nonnull %5, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef nonnull %8) #5
  %.not40 = icmp eq i32 %30, 0
  br i1 %.not40, label %31, label %33

31:                                               ; preds = %26
  %32 = call i32 @mbedtls_rsa_export_crt(ptr noundef nonnull %1, ptr noundef nonnull %9, ptr noundef nonnull %10, ptr noundef nonnull %11) #5
  %.not41 = icmp eq i32 %32, 0
  br i1 %.not41, label %35, label %33

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

35:                                               ; preds = %31
  %36 = call noalias ptr @fopen(ptr noundef nonnull @.str.7, ptr noundef nonnull @.str.8)
  %37 = icmp eq ptr %36, null
  br i1 %37, label %38, label %40

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

40:                                               ; preds = %35
  %41 = call i32 @mbedtls_mpi_write_file(ptr noundef nonnull @.str.10, ptr noundef nonnull %4, i32 noundef 16, ptr noundef nonnull %36) #5
  %.not42 = icmp eq i32 %41, 0
  br i1 %.not42, label %42, label %44

42:                                               ; preds = %40
  %43 = call i32 @mbedtls_mpi_write_file(ptr noundef nonnull @.str.11, ptr noundef nonnull %8, i32 noundef 16, ptr noundef nonnull %36) #5
  %.not43 = icmp eq i32 %43, 0
  br i1 %.not43, label %46, label %44

44:                                               ; preds = %42, %40
  %.0 = phi i32 [ %41, %40 ], [ %43, %42 ]
  %45 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, i32 noundef %.0)
  br label %.thread66

46:                                               ; preds = %42
  %47 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13)
  %48 = load ptr, ptr @stdout, align 8, !tbaa !5
  %49 = call i32 @fflush(ptr noundef %48)
  %50 = call noalias ptr @fopen(ptr noundef nonnull @.str.14, ptr noundef nonnull @.str.8)
  %51 = icmp eq ptr %50, null
  br i1 %51, label %52, label %54

52:                                               ; preds = %46
  %53 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15)
  br label %.thread66

54:                                               ; preds = %46
  %55 = call i32 @mbedtls_mpi_write_file(ptr noundef nonnull @.str.10, ptr noundef nonnull %4, i32 noundef 16, ptr noundef nonnull %50) #5
  %.not44 = icmp eq i32 %55, 0
  br i1 %.not44, label %56, label %70

56:                                               ; preds = %54
  %57 = call i32 @mbedtls_mpi_write_file(ptr noundef nonnull @.str.11, ptr noundef nonnull %8, i32 noundef 16, ptr noundef nonnull %50) #5
  %.not45 = icmp eq i32 %57, 0
  br i1 %.not45, label %58, label %70

58:                                               ; preds = %56
  %59 = call i32 @mbedtls_mpi_write_file(ptr noundef nonnull @.str.16, ptr noundef nonnull %7, i32 noundef 16, ptr noundef nonnull %50) #5
  %.not46 = icmp eq i32 %59, 0
  br i1 %.not46, label %60, label %70

60:                                               ; preds = %58
  %61 = call i32 @mbedtls_mpi_write_file(ptr noundef nonnull @.str.17, ptr noundef nonnull %5, i32 noundef 16, ptr noundef nonnull %50) #5
  %.not47 = icmp eq i32 %61, 0
  br i1 %.not47, label %62, label %70

62:                                               ; preds = %60
  %63 = call i32 @mbedtls_mpi_write_file(ptr noundef nonnull @.str.18, ptr noundef nonnull %6, i32 noundef 16, ptr noundef nonnull %50) #5
  %.not48 = icmp eq i32 %63, 0
  br i1 %.not48, label %64, label %70

64:                                               ; preds = %62
  %65 = call i32 @mbedtls_mpi_write_file(ptr noundef nonnull @.str.19, ptr noundef nonnull %9, i32 noundef 16, ptr noundef nonnull %50) #5
  %.not49 = icmp eq i32 %65, 0
  br i1 %.not49, label %66, label %70

66:                                               ; preds = %64
  %67 = call i32 @mbedtls_mpi_write_file(ptr noundef nonnull @.str.20, ptr noundef nonnull %10, i32 noundef 16, ptr noundef nonnull %50) #5
  %.not50 = icmp eq i32 %67, 0
  br i1 %.not50, label %68, label %70

68:                                               ; preds = %66
  %69 = call i32 @mbedtls_mpi_write_file(ptr noundef nonnull @.str.21, ptr noundef nonnull %11, i32 noundef 16, ptr noundef nonnull %50) #5
  %.not51 = icmp eq i32 %69, 0
  br i1 %.not51, label %72, label %70

70:                                               ; preds = %68, %66, %64, %62, %60, %58, %56, %54
  %.1 = phi i32 [ %55, %54 ], [ %57, %56 ], [ %59, %58 ], [ %61, %60 ], [ %63, %62 ], [ %65, %64 ], [ %67, %66 ], [ %69, %68 ]
  %71 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, i32 noundef %.1)
  br label %75

72:                                               ; preds = %68
  %73 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.22)
  br label %75

.thread66:                                        ; preds = %44, %52
  %74 = call i32 @fclose(ptr noundef nonnull %36)
  br label %.thread60

75:                                               ; preds = %70, %72
  %.022 = phi i32 [ 1, %70 ], [ 0, %72 ]
  %76 = call i32 @fclose(ptr noundef nonnull %36)
  %77 = call i32 @fclose(ptr noundef nonnull %50)
  br label %.thread60

.thread60:                                        ; preds = %17, %24, %33, %38, %.thread66, %75
  %.0225864 = phi i32 [ %.022, %75 ], [ 1, %.thread66 ], [ 1, %38 ], [ 1, %33 ], [ 1, %24 ], [ 1, %17 ]
  call void @mbedtls_mpi_free(ptr noundef nonnull %4) #5
  call void @mbedtls_mpi_free(ptr noundef nonnull %5) #5
  call void @mbedtls_mpi_free(ptr noundef nonnull %6) #5
  call void @mbedtls_mpi_free(ptr noundef nonnull %7) #5
  call void @mbedtls_mpi_free(ptr noundef nonnull %8) #5
  call void @mbedtls_mpi_free(ptr noundef nonnull %9) #5
  call void @mbedtls_mpi_free(ptr noundef nonnull %10) #5
  call void @mbedtls_mpi_free(ptr noundef nonnull %11) #5
  call void @mbedtls_rsa_free(ptr noundef nonnull %1) #5
  call void @mbedtls_ctr_drbg_free(ptr noundef nonnull %3) #5
  call void @mbedtls_entropy_free(ptr noundef nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %11) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %10) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 344, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 1032, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 336, ptr nonnull %1) #5
  ret i32 %.0225864
}

; 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_ctr_drbg_init(ptr noundef) local_unnamed_addr #2

declare void @mbedtls_rsa_init(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare void @mbedtls_mpi_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: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #3

declare void @mbedtls_entropy_init(ptr noundef) local_unnamed_addr #2

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_rsa_gen_key(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

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

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

declare i32 @mbedtls_rsa_export_crt(ptr noundef, ptr 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_rsa_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 = { 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"}


; Effective O3 passes: CorrelatedValuePropagationPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass