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

; 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 [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [44 x i8], align 1
@stdout = external global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [27 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 ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca %struct.mbedtls_rsa_context, align 8
  %11 = alloca %struct.mbedtls_entropy_context, align 8
  %12 = alloca %struct.mbedtls_ctr_drbg_context, align 8
  %13 = alloca [1024 x i8], align 16
  %14 = alloca [512 x i8], align 16
  %15 = alloca ptr, align 8
  %16 = alloca %struct.mbedtls_mpi, align 8
  %17 = alloca %struct.mbedtls_mpi, 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 8, ptr %6) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  store i32 1, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 1, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.start.p0(i64 336, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 1032, ptr %11) #7
  call void @llvm.lifetime.start.p0(i64 344, ptr %12) #7
  call void @llvm.lifetime.start.p0(i64 1024, ptr %13) #7
  call void @llvm.lifetime.start.p0(i64 512, ptr %14) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  store ptr @.str, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 24, ptr %16) #7
  call void @llvm.lifetime.start.p0(i64 24, ptr %17) #7
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = icmp ne i32 %18, 2
  br i1 %19, label %20, label %23

20:                                               ; preds = %2
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  %22 = load i32, ptr %8, align 4, !tbaa !5
  call void @exit(i32 noundef %22) #8
  unreachable

23:                                               ; preds = %2
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  %25 = load ptr, ptr @stdout, align 8, !tbaa !9
  %26 = call i32 @fflush(ptr noundef %25)
  call void @mbedtls_mpi_init(ptr noundef %16)
  call void @mbedtls_mpi_init(ptr noundef %17)
  call void @mbedtls_rsa_init(ptr noundef %10, i32 noundef 0, i32 noundef 0)
  call void @mbedtls_ctr_drbg_init(ptr noundef %12)
  call void @mbedtls_entropy_init(ptr noundef %11)
  %27 = load ptr, ptr %15, align 8, !tbaa !9
  %28 = load ptr, ptr %15, align 8, !tbaa !9
  %29 = call i64 @strlen(ptr noundef %28) #9
  %30 = call i32 @mbedtls_ctr_drbg_seed(ptr noundef %12, ptr noundef @mbedtls_entropy_func, ptr noundef %11, ptr noundef %27, i64 noundef %29)
  store i32 %30, ptr %7, align 4, !tbaa !5
  %31 = load i32, ptr %7, align 4, !tbaa !5
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %36

33:                                               ; preds = %23
  %34 = load i32, ptr %7, align 4, !tbaa !5
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %34)
  br label %128

36:                                               ; preds = %23
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %38 = load ptr, ptr @stdout, align 8, !tbaa !9
  %39 = call i32 @fflush(ptr noundef %38)
  %40 = call noalias ptr @fopen(ptr noundef @.str.5, ptr noundef @.str.6)
  store ptr %40, ptr %6, align 8, !tbaa !9
  %41 = icmp eq ptr %40, null
  br i1 %41, label %42, label %44

42:                                               ; preds = %36
  %43 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  br label %128

44:                                               ; preds = %36
  %45 = load ptr, ptr %6, align 8, !tbaa !9
  %46 = call i32 @mbedtls_mpi_read_file(ptr noundef %16, i32 noundef 16, ptr noundef %45)
  store i32 %46, ptr %7, align 4, !tbaa !5
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %52, label %48

48:                                               ; preds = %44
  %49 = load ptr, ptr %6, align 8, !tbaa !9
  %50 = call i32 @mbedtls_mpi_read_file(ptr noundef %17, i32 noundef 16, ptr noundef %49)
  store i32 %50, ptr %7, align 4, !tbaa !5
  %51 = icmp ne i32 %50, 0
  br i1 %51, label %52, label %57

52:                                               ; preds = %48, %44
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, i32 noundef %53)
  %55 = load ptr, ptr %6, align 8, !tbaa !9
  %56 = call i32 @fclose(ptr noundef %55)
  br label %128

57:                                               ; preds = %48
  %58 = load ptr, ptr %6, align 8, !tbaa !9
  %59 = call i32 @fclose(ptr noundef %58)
  %60 = call i32 @mbedtls_rsa_import(ptr noundef %10, ptr noundef %16, ptr noundef null, ptr noundef null, ptr noundef null, ptr noundef %17)
  store i32 %60, ptr %7, align 4, !tbaa !5
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %65

62:                                               ; preds = %57
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, i32 noundef %63)
  br label %128

65:                                               ; preds = %57
  %66 = load ptr, ptr %5, align 8, !tbaa !9
  %67 = getelementptr inbounds ptr, ptr %66, i64 1
  %68 = load ptr, ptr %67, align 8, !tbaa !9
  %69 = call i64 @strlen(ptr noundef %68) #9
  %70 = icmp ugt i64 %69, 100
  br i1 %70, label %71, label %73

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

73:                                               ; preds = %65
  %74 = getelementptr inbounds [1024 x i8], ptr %13, i64 0, i64 0
  %75 = load ptr, ptr %5, align 8, !tbaa !9
  %76 = getelementptr inbounds ptr, ptr %75, i64 1
  %77 = load ptr, ptr %76, align 8, !tbaa !9
  %78 = load ptr, ptr %5, align 8, !tbaa !9
  %79 = getelementptr inbounds ptr, ptr %78, i64 1
  %80 = load ptr, ptr %79, align 8, !tbaa !9
  %81 = call i64 @strlen(ptr noundef %80) #9
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %74, ptr align 1 %77, i64 %81, i1 false)
  %82 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  %83 = load ptr, ptr @stdout, align 8, !tbaa !9
  %84 = call i32 @fflush(ptr noundef %83)
  %85 = load ptr, ptr %5, align 8, !tbaa !9
  %86 = getelementptr inbounds ptr, ptr %85, i64 1
  %87 = load ptr, ptr %86, align 8, !tbaa !9
  %88 = call i64 @strlen(ptr noundef %87) #9
  %89 = getelementptr inbounds [1024 x i8], ptr %13, i64 0, i64 0
  %90 = getelementptr inbounds [512 x i8], ptr %14, i64 0, i64 0
  %91 = call i32 @mbedtls_rsa_pkcs1_encrypt(ptr noundef %10, ptr noundef @mbedtls_ctr_drbg_random, ptr noundef %12, i32 noundef 0, i64 noundef %88, ptr noundef %89, ptr noundef %90)
  store i32 %91, ptr %7, align 4, !tbaa !5
  %92 = load i32, ptr %7, align 4, !tbaa !5
  %93 = icmp ne i32 %92, 0
  br i1 %93, label %94, label %97

94:                                               ; preds = %73
  %95 = load i32, ptr %7, align 4, !tbaa !5
  %96 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, i32 noundef %95)
  br label %128

97:                                               ; preds = %73
  %98 = call noalias ptr @fopen(ptr noundef @.str.13, ptr noundef @.str.14)
  store ptr %98, ptr %6, align 8, !tbaa !9
  %99 = icmp eq ptr %98, null
  br i1 %99, label %100, label %102

100:                                              ; preds = %97
  %101 = call i32 (ptr, ...) @printf(ptr noundef @.str.15, ptr noundef @.str.13)
  br label %128

102:                                              ; preds = %97
  store i64 0, ptr %9, align 8, !tbaa !11
  br label %103

103:                                              ; preds = %121, %102
  %104 = load i64, ptr %9, align 8, !tbaa !11
  %105 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %10, i32 0, i32 1
  %106 = load i64, ptr %105, align 8, !tbaa !13
  %107 = icmp ult i64 %104, %106
  br i1 %107, label %108, label %124

108:                                              ; preds = %103
  %109 = load ptr, ptr %6, align 8, !tbaa !9
  %110 = load i64, ptr %9, align 8, !tbaa !11
  %111 = getelementptr inbounds [512 x i8], ptr %14, i64 0, i64 %110
  %112 = load i8, ptr %111, align 1, !tbaa !16
  %113 = zext i8 %112 to i32
  %114 = load i64, ptr %9, align 8, !tbaa !11
  %115 = add i64 %114, 1
  %116 = urem i64 %115, 16
  %117 = icmp eq i64 %116, 0
  %118 = zext i1 %117 to i64
  %119 = select i1 %117, ptr @.str.17, ptr @.str.18
  %120 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %109, ptr noundef @.str.16, i32 noundef %113, ptr noundef %119) #7
  br label %121

121:                                              ; preds = %108
  %122 = load i64, ptr %9, align 8, !tbaa !11
  %123 = add i64 %122, 1
  store i64 %123, ptr %9, align 8, !tbaa !11
  br label %103, !llvm.loop !17

124:                                              ; preds = %103
  %125 = load ptr, ptr %6, align 8, !tbaa !9
  %126 = call i32 @fclose(ptr noundef %125)
  %127 = call i32 (ptr, ...) @printf(ptr noundef @.str.19, ptr noundef @.str.13)
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %128

128:                                              ; preds = %124, %100, %94, %71, %62, %52, %42, %33
  call void @mbedtls_mpi_free(ptr noundef %16)
  call void @mbedtls_mpi_free(ptr noundef %17)
  call void @mbedtls_ctr_drbg_free(ptr noundef %12)
  call void @mbedtls_entropy_free(ptr noundef %11)
  call void @mbedtls_rsa_free(ptr noundef %10)
  %129 = load i32, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 24, ptr %17) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 512, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 1024, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 344, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 1032, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 336, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  ret i32 %129
}

; 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: noreturn nounwind
declare void @exit(i32 noundef) #3

declare i32 @fflush(ptr noundef) #2

declare void @mbedtls_mpi_init(ptr noundef) #2

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

declare void @mbedtls_ctr_drbg_init(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) #4

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

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

declare i32 @fclose(ptr noundef) #2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

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

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #6

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

declare void @mbedtls_rsa_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 = { noreturn 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 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 #7 = { nounwind }
attributes #8 = { noreturn nounwind }
attributes #9 = { 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 = !{!14, !12, i64 8}
!14 = !{!"mbedtls_rsa_context", !6, i64 0, !12, i64 8, !15, i64 16, !15, i64 40, !15, i64 64, !15, i64 88, !15, i64 112, !15, i64 136, !15, i64 160, !15, i64 184, !15, i64 208, !15, i64 232, !15, i64 256, !15, i64 280, !15, i64 304, !6, i64 328, !6, i64 332}
!15 = !{!"mbedtls_mpi", !6, i64 0, !12, i64 8, !10, i64 16}
!16 = !{!7, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"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_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 [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [51 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [44 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [27 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_rsa_context, align 8
  %4 = alloca %struct.mbedtls_entropy_context, align 8
  %5 = alloca %struct.mbedtls_ctr_drbg_context, align 8
  %6 = alloca [1024 x i8], align 16
  %7 = alloca [512 x i8], align 16
  %8 = alloca %struct.mbedtls_mpi, align 8
  %9 = alloca %struct.mbedtls_mpi, align 8
  call void @llvm.lifetime.start.p0(i64 336, ptr nonnull %3) #7
  call void @llvm.lifetime.start.p0(i64 1032, ptr nonnull %4) #7
  call void @llvm.lifetime.start.p0(i64 344, ptr nonnull %5) #7
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %6) #7
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %7) #7
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #7
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #7
  %.not = icmp eq i32 %0, 2
  br i1 %.not, label %12, label %10

10:                                               ; preds = %2
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  tail call void @exit(i32 noundef 1) #8
  unreachable

12:                                               ; preds = %2
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %14 = load ptr, ptr @stdout, align 8, !tbaa !5
  %15 = tail call i32 @fflush(ptr noundef %14)
  call void @mbedtls_mpi_init(ptr noundef nonnull %8) #7
  call void @mbedtls_mpi_init(ptr noundef nonnull %9) #7
  call void @mbedtls_rsa_init(ptr noundef nonnull %3, i32 noundef 0, i32 noundef 0) #7
  call void @mbedtls_ctr_drbg_init(ptr noundef nonnull %5) #7
  call void @mbedtls_entropy_init(ptr noundef nonnull %4) #7
  %16 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) @.str) #9
  %17 = call i32 @mbedtls_ctr_drbg_seed(ptr noundef nonnull %5, ptr noundef nonnull @mbedtls_entropy_func, ptr noundef nonnull %4, ptr noundef nonnull @.str, i64 noundef %16) #7
  %.not34 = icmp eq i32 %17, 0
  br i1 %.not34, label %20, label %18

18:                                               ; preds = %12
  %19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %17)
  br label %75

20:                                               ; preds = %12
  %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 = call noalias ptr @fopen(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6)
  %25 = icmp eq ptr %24, null
  br i1 %25, label %26, label %28

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

28:                                               ; preds = %20
  %29 = call i32 @mbedtls_mpi_read_file(ptr noundef nonnull %8, i32 noundef 16, ptr noundef nonnull %24) #7
  %.not35 = icmp eq i32 %29, 0
  br i1 %.not35, label %30, label %32

30:                                               ; preds = %28
  %31 = call i32 @mbedtls_mpi_read_file(ptr noundef nonnull %9, i32 noundef 16, ptr noundef nonnull %24) #7
  %.not36 = icmp eq i32 %31, 0
  br i1 %.not36, label %35, label %32

32:                                               ; preds = %30, %28
  %.025 = phi i32 [ %29, %28 ], [ %31, %30 ]
  %33 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, i32 noundef %.025)
  %34 = call i32 @fclose(ptr noundef nonnull %24)
  br label %75

35:                                               ; preds = %30
  %36 = call i32 @fclose(ptr noundef nonnull %24)
  %37 = call i32 @mbedtls_rsa_import(ptr noundef nonnull %3, ptr noundef nonnull %8, ptr noundef null, ptr noundef null, ptr noundef null, ptr noundef nonnull %9) #7
  %.not37 = icmp eq i32 %37, 0
  br i1 %.not37, label %40, label %38

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

40:                                               ; preds = %35
  %41 = getelementptr inbounds i8, ptr %1, i64 8
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  %43 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %42) #9
  %44 = icmp ugt i64 %43, 100
  br i1 %44, label %45, label %47

45:                                               ; preds = %40
  %46 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  br label %75

47:                                               ; preds = %40
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 %6, ptr align 1 %42, i64 %43, i1 false)
  %48 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  %49 = load ptr, ptr @stdout, align 8, !tbaa !5
  %50 = call i32 @fflush(ptr noundef %49)
  %51 = load ptr, ptr %41, align 8, !tbaa !5
  %52 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %51) #9
  %53 = call i32 @mbedtls_rsa_pkcs1_encrypt(ptr noundef nonnull %3, ptr noundef nonnull @mbedtls_ctr_drbg_random, ptr noundef nonnull %5, i32 noundef 0, i64 noundef %52, ptr noundef nonnull %6, ptr noundef nonnull %7) #7
  %.not38 = icmp eq i32 %53, 0
  br i1 %.not38, label %56, label %54

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

56:                                               ; preds = %47
  %57 = call noalias ptr @fopen(ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.14)
  %58 = icmp eq ptr %57, null
  br i1 %58, label %61, label %.preheader

.preheader:                                       ; preds = %56
  %59 = getelementptr inbounds i8, ptr %3, i64 8
  %60 = load i64, ptr %59, align 8, !tbaa !9
  %.not40 = icmp eq i64 %60, 0
  br i1 %.not40, label %._crit_edge, label %.lr.ph

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

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.039 = phi i64 [ %66, %.lr.ph ], [ 0, %.preheader ]
  %63 = getelementptr inbounds [512 x i8], ptr %7, i64 0, i64 %.039
  %64 = load i8, ptr %63, align 1, !tbaa !14
  %65 = zext i8 %64 to i32
  %66 = add nuw i64 %.039, 1
  %67 = and i64 %66, 15
  %68 = icmp eq i64 %67, 0
  %69 = select i1 %68, ptr @.str.17, ptr @.str.18
  %70 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %57, ptr noundef nonnull @.str.16, i32 noundef %65, ptr noundef nonnull %69) #7
  %71 = load i64, ptr %59, align 8, !tbaa !9
  %72 = icmp ult i64 %66, %71
  br i1 %72, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %73 = call i32 @fclose(ptr noundef nonnull %57)
  %74 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.19, ptr noundef nonnull @.str.13)
  br label %75

75:                                               ; preds = %._crit_edge, %61, %54, %45, %38, %32, %26, %18
  %.024 = phi i32 [ 1, %18 ], [ 1, %26 ], [ 1, %32 ], [ 1, %38 ], [ 1, %45 ], [ 1, %54 ], [ 1, %61 ], [ 0, %._crit_edge ]
  call void @mbedtls_mpi_free(ptr noundef nonnull %8) #7
  call void @mbedtls_mpi_free(ptr noundef nonnull %9) #7
  call void @mbedtls_ctr_drbg_free(ptr noundef nonnull %5) #7
  call void @mbedtls_entropy_free(ptr noundef nonnull %4) #7
  call void @mbedtls_rsa_free(ptr noundef nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #7
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 344, ptr nonnull %5) #7
  call void @llvm.lifetime.end.p0(i64 1032, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 336, ptr nonnull %3) #7
  ret i32 %.024
}

; 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: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #3

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

declare void @mbedtls_mpi_init(ptr noundef) local_unnamed_addr #4

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

declare void @mbedtls_ctr_drbg_init(ptr noundef) local_unnamed_addr #4

declare void @mbedtls_entropy_init(ptr noundef) local_unnamed_addr #4

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

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

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

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

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

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

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

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

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

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 = { noreturn 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 = { "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 = { 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 #6 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }
attributes #8 = { noreturn nounwind }
attributes #9 = { 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 = !{!10, !12, i64 8}
!10 = !{!"mbedtls_rsa_context", !11, i64 0, !12, i64 8, !13, i64 16, !13, i64 40, !13, i64 64, !13, i64 88, !13, i64 112, !13, i64 136, !13, i64 160, !13, i64 184, !13, i64 208, !13, i64 232, !13, i64 256, !13, i64 280, !13, i64 304, !11, i64 328, !11, i64 332}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!"mbedtls_mpi", !11, i64 0, !12, i64 8, !6, i64 16}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass