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

; 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 }

@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [43 x i8], align 1
@stdout = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [58 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 [53 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [7 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 [32 x i8], align 16
  %12 = alloca [1024 x i8], align 16
  %13 = alloca [512 x i8], align 16
  %14 = alloca %struct.mbedtls_mpi, align 8
  %15 = alloca %struct.mbedtls_mpi, align 8
  %16 = alloca %struct.mbedtls_mpi, align 8
  %17 = alloca %struct.mbedtls_mpi, align 8
  %18 = alloca %struct.mbedtls_mpi, align 8
  %19 = alloca %struct.mbedtls_mpi, align 8
  %20 = alloca %struct.mbedtls_mpi, align 8
  %21 = 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) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 1, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 1, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 336, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 1024, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 512, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %16) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %18) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %19) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %20) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %21) #4
  call void @mbedtls_rsa_init(ptr noundef %10, i32 noundef 0, i32 noundef 0)
  call void @mbedtls_mpi_init(ptr noundef %14)
  call void @mbedtls_mpi_init(ptr noundef %15)
  call void @mbedtls_mpi_init(ptr noundef %16)
  call void @mbedtls_mpi_init(ptr noundef %17)
  call void @mbedtls_mpi_init(ptr noundef %18)
  call void @mbedtls_mpi_init(ptr noundef %19)
  call void @mbedtls_mpi_init(ptr noundef %20)
  call void @mbedtls_mpi_init(ptr noundef %21)
  %22 = load i32, ptr %4, align 4, !tbaa !5
  %23 = icmp ne i32 %22, 2
  br i1 %23, label %24, label %26

24:                                               ; preds = %2
  %25 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  br label %161

26:                                               ; preds = %2
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  %28 = load ptr, ptr @stdout, align 8, !tbaa !9
  %29 = call i32 @fflush(ptr noundef %28)
  %30 = call noalias ptr @fopen(ptr noundef @.str.2, ptr noundef @.str.3)
  store ptr %30, ptr %6, align 8, !tbaa !9
  %31 = icmp eq ptr %30, null
  br i1 %31, label %32, label %34

32:                                               ; preds = %26
  %33 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %161

34:                                               ; preds = %26
  %35 = load ptr, ptr %6, align 8, !tbaa !9
  %36 = call i32 @mbedtls_mpi_read_file(ptr noundef %14, i32 noundef 16, ptr noundef %35)
  store i32 %36, ptr %7, align 4, !tbaa !5
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %66, label %38

38:                                               ; preds = %34
  %39 = load ptr, ptr %6, align 8, !tbaa !9
  %40 = call i32 @mbedtls_mpi_read_file(ptr noundef %18, i32 noundef 16, ptr noundef %39)
  store i32 %40, ptr %7, align 4, !tbaa !5
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %66, label %42

42:                                               ; preds = %38
  %43 = load ptr, ptr %6, align 8, !tbaa !9
  %44 = call i32 @mbedtls_mpi_read_file(ptr noundef %17, i32 noundef 16, ptr noundef %43)
  store i32 %44, ptr %7, align 4, !tbaa !5
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %66, label %46

46:                                               ; preds = %42
  %47 = load ptr, ptr %6, align 8, !tbaa !9
  %48 = call i32 @mbedtls_mpi_read_file(ptr noundef %15, i32 noundef 16, ptr noundef %47)
  store i32 %48, ptr %7, align 4, !tbaa !5
  %49 = icmp ne i32 %48, 0
  br i1 %49, label %66, label %50

50:                                               ; preds = %46
  %51 = load ptr, ptr %6, align 8, !tbaa !9
  %52 = call i32 @mbedtls_mpi_read_file(ptr noundef %16, i32 noundef 16, ptr noundef %51)
  store i32 %52, ptr %7, align 4, !tbaa !5
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %66, label %54

54:                                               ; preds = %50
  %55 = load ptr, ptr %6, align 8, !tbaa !9
  %56 = call i32 @mbedtls_mpi_read_file(ptr noundef %19, i32 noundef 16, ptr noundef %55)
  store i32 %56, ptr %7, align 4, !tbaa !5
  %57 = icmp ne i32 %56, 0
  br i1 %57, label %66, label %58

58:                                               ; preds = %54
  %59 = load ptr, ptr %6, align 8, !tbaa !9
  %60 = call i32 @mbedtls_mpi_read_file(ptr noundef %20, i32 noundef 16, ptr noundef %59)
  store i32 %60, ptr %7, align 4, !tbaa !5
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %66, label %62

62:                                               ; preds = %58
  %63 = load ptr, ptr %6, align 8, !tbaa !9
  %64 = call i32 @mbedtls_mpi_read_file(ptr noundef %21, i32 noundef 16, ptr noundef %63)
  store i32 %64, ptr %7, align 4, !tbaa !5
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %66, label %71

66:                                               ; preds = %62, %58, %54, %50, %46, %42, %38, %34
  %67 = load i32, ptr %7, align 4, !tbaa !5
  %68 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, i32 noundef %67)
  %69 = load ptr, ptr %6, align 8, !tbaa !9
  %70 = call i32 @fclose(ptr noundef %69)
  br label %161

71:                                               ; preds = %62
  %72 = load ptr, ptr %6, align 8, !tbaa !9
  %73 = call i32 @fclose(ptr noundef %72)
  %74 = call i32 @mbedtls_rsa_import(ptr noundef %10, ptr noundef %14, ptr noundef %15, ptr noundef %16, ptr noundef %17, ptr noundef %18)
  store i32 %74, ptr %7, align 4, !tbaa !5
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %76, label %79

76:                                               ; preds = %71
  %77 = load i32, ptr %7, align 4, !tbaa !5
  %78 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i32 noundef %77)
  br label %161

79:                                               ; preds = %71
  %80 = call i32 @mbedtls_rsa_complete(ptr noundef %10)
  store i32 %80, ptr %7, align 4, !tbaa !5
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %82, label %85

82:                                               ; preds = %79
  %83 = load i32, ptr %7, align 4, !tbaa !5
  %84 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %83)
  br label %161

85:                                               ; preds = %79
  %86 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  %87 = load ptr, ptr @stdout, align 8, !tbaa !9
  %88 = call i32 @fflush(ptr noundef %87)
  %89 = call i32 @mbedtls_rsa_check_privkey(ptr noundef %10)
  store i32 %89, ptr %7, align 4, !tbaa !5
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %91, label %95

91:                                               ; preds = %85
  %92 = load i32, ptr %7, align 4, !tbaa !5
  %93 = sub nsw i32 0, %92
  %94 = call i32 (ptr, ...) @printf(ptr noundef @.str.9, i32 noundef %93)
  br label %161

95:                                               ; preds = %85
  %96 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  %97 = load ptr, ptr @stdout, align 8, !tbaa !9
  %98 = call i32 @fflush(ptr noundef %97)
  %99 = call ptr @mbedtls_md_info_from_type(i32 noundef 6)
  %100 = load ptr, ptr %5, align 8, !tbaa !9
  %101 = getelementptr inbounds ptr, ptr %100, i64 1
  %102 = load ptr, ptr %101, align 8, !tbaa !9
  %103 = getelementptr inbounds [32 x i8], ptr %11, i64 0, i64 0
  %104 = call i32 @mbedtls_md_file(ptr noundef %99, ptr noundef %102, ptr noundef %103)
  store i32 %104, ptr %7, align 4, !tbaa !5
  %105 = icmp ne i32 %104, 0
  br i1 %105, label %106, label %111

106:                                              ; preds = %95
  %107 = load ptr, ptr %5, align 8, !tbaa !9
  %108 = getelementptr inbounds ptr, ptr %107, i64 1
  %109 = load ptr, ptr %108, align 8, !tbaa !9
  %110 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, ptr noundef %109)
  br label %161

111:                                              ; preds = %95
  %112 = getelementptr inbounds [32 x i8], ptr %11, i64 0, i64 0
  %113 = getelementptr inbounds [1024 x i8], ptr %12, i64 0, i64 0
  %114 = call i32 @mbedtls_rsa_pkcs1_sign(ptr noundef %10, ptr noundef null, ptr noundef null, i32 noundef 1, i32 noundef 6, i32 noundef 20, ptr noundef %112, ptr noundef %113)
  store i32 %114, ptr %7, align 4, !tbaa !5
  %115 = icmp ne i32 %114, 0
  br i1 %115, label %116, label %120

116:                                              ; preds = %111
  %117 = load i32, ptr %7, align 4, !tbaa !5
  %118 = sub nsw i32 0, %117
  %119 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, i32 noundef %118)
  br label %161

120:                                              ; preds = %111
  %121 = getelementptr inbounds [512 x i8], ptr %13, i64 0, i64 0
  %122 = load ptr, ptr %5, align 8, !tbaa !9
  %123 = getelementptr inbounds ptr, ptr %122, i64 1
  %124 = load ptr, ptr %123, align 8, !tbaa !9
  %125 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %121, i64 noundef 512, ptr noundef @.str.13, ptr noundef %124) #4
  %126 = getelementptr inbounds [512 x i8], ptr %13, i64 0, i64 0
  %127 = call noalias ptr @fopen(ptr noundef %126, ptr noundef @.str.14)
  store ptr %127, ptr %6, align 8, !tbaa !9
  %128 = icmp eq ptr %127, null
  br i1 %128, label %129, label %134

129:                                              ; preds = %120
  %130 = load ptr, ptr %5, align 8, !tbaa !9
  %131 = getelementptr inbounds ptr, ptr %130, i64 1
  %132 = load ptr, ptr %131, align 8, !tbaa !9
  %133 = call i32 (ptr, ...) @printf(ptr noundef @.str.15, ptr noundef %132)
  br label %161

134:                                              ; preds = %120
  store i64 0, ptr %9, align 8, !tbaa !11
  br label %135

135:                                              ; preds = %153, %134
  %136 = load i64, ptr %9, align 8, !tbaa !11
  %137 = getelementptr inbounds %struct.mbedtls_rsa_context, ptr %10, i32 0, i32 1
  %138 = load i64, ptr %137, align 8, !tbaa !13
  %139 = icmp ult i64 %136, %138
  br i1 %139, label %140, label %156

140:                                              ; preds = %135
  %141 = load ptr, ptr %6, align 8, !tbaa !9
  %142 = load i64, ptr %9, align 8, !tbaa !11
  %143 = getelementptr inbounds [1024 x i8], ptr %12, i64 0, i64 %142
  %144 = load i8, ptr %143, align 1, !tbaa !16
  %145 = zext i8 %144 to i32
  %146 = load i64, ptr %9, align 8, !tbaa !11
  %147 = add i64 %146, 1
  %148 = urem i64 %147, 16
  %149 = icmp eq i64 %148, 0
  %150 = zext i1 %149 to i64
  %151 = select i1 %149, ptr @.str.17, ptr @.str.18
  %152 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %141, ptr noundef @.str.16, i32 noundef %145, ptr noundef %151) #4
  br label %153

153:                                              ; preds = %140
  %154 = load i64, ptr %9, align 8, !tbaa !11
  %155 = add i64 %154, 1
  store i64 %155, ptr %9, align 8, !tbaa !11
  br label %135, !llvm.loop !17

156:                                              ; preds = %135
  %157 = load ptr, ptr %6, align 8, !tbaa !9
  %158 = call i32 @fclose(ptr noundef %157)
  %159 = getelementptr inbounds [512 x i8], ptr %13, i64 0, i64 0
  %160 = call i32 (ptr, ...) @printf(ptr noundef @.str.19, ptr noundef %159)
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %161

161:                                              ; preds = %156, %129, %116, %106, %91, %82, %76, %66, %32, %24
  call void @mbedtls_rsa_free(ptr noundef %10)
  call void @mbedtls_mpi_free(ptr noundef %14)
  call void @mbedtls_mpi_free(ptr noundef %15)
  call void @mbedtls_mpi_free(ptr noundef %16)
  call void @mbedtls_mpi_free(ptr noundef %17)
  call void @mbedtls_mpi_free(ptr noundef %18)
  call void @mbedtls_mpi_free(ptr noundef %19)
  call void @mbedtls_mpi_free(ptr noundef %20)
  call void @mbedtls_mpi_free(ptr noundef %21)
  %162 = load i32, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 24, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 512, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 1024, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 336, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  ret i32 %162
}

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

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

declare i32 @mbedtls_rsa_complete(ptr noundef) #2

declare i32 @mbedtls_rsa_check_privkey(ptr noundef) #2

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

declare ptr @mbedtls_md_info_from_type(i32 noundef) #2

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

; Function Attrs: nounwind
declare i32 @snprintf(ptr noundef, i64 noundef, ptr noundef, ...) #3

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

declare void @mbedtls_rsa_free(ptr noundef) #2

declare void @mbedtls_mpi_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 "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 }

!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 }

@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [43 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [58 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 [53 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [7 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 [32 x i8], align 16
  %5 = alloca [1024 x i8], align 16
  %6 = alloca [512 x i8], align 16
  %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
  call void @llvm.lifetime.start.p0(i64 336, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %10) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %11) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %12) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %13) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %14) #4
  call void @mbedtls_rsa_init(ptr noundef nonnull %3, i32 noundef 0, i32 noundef 0) #4
  call void @mbedtls_mpi_init(ptr noundef nonnull %7) #4
  call void @mbedtls_mpi_init(ptr noundef nonnull %8) #4
  call void @mbedtls_mpi_init(ptr noundef nonnull %9) #4
  call void @mbedtls_mpi_init(ptr noundef nonnull %10) #4
  call void @mbedtls_mpi_init(ptr noundef nonnull %11) #4
  call void @mbedtls_mpi_init(ptr noundef nonnull %12) #4
  call void @mbedtls_mpi_init(ptr noundef nonnull %13) #4
  call void @mbedtls_mpi_init(ptr noundef nonnull %14) #4
  %.not = icmp eq i32 %0, 2
  br i1 %.not, label %17, label %15

15:                                               ; preds = %2
  %16 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  br label %99

17:                                               ; preds = %2
  %18 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %19 = load ptr, ptr @stdout, align 8, !tbaa !5
  %20 = call i32 @fflush(ptr noundef %19)
  %21 = call noalias ptr @fopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3)
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %25

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

25:                                               ; preds = %17
  %26 = call i32 @mbedtls_mpi_read_file(ptr noundef nonnull %7, i32 noundef 16, ptr noundef nonnull %21) #4
  %.not42 = icmp eq i32 %26, 0
  br i1 %.not42, label %27, label %41

27:                                               ; preds = %25
  %28 = call i32 @mbedtls_mpi_read_file(ptr noundef nonnull %11, i32 noundef 16, ptr noundef nonnull %21) #4
  %.not43 = icmp eq i32 %28, 0
  br i1 %.not43, label %29, label %41

29:                                               ; preds = %27
  %30 = call i32 @mbedtls_mpi_read_file(ptr noundef nonnull %10, i32 noundef 16, ptr noundef nonnull %21) #4
  %.not44 = icmp eq i32 %30, 0
  br i1 %.not44, label %31, label %41

31:                                               ; preds = %29
  %32 = call i32 @mbedtls_mpi_read_file(ptr noundef nonnull %8, i32 noundef 16, ptr noundef nonnull %21) #4
  %.not45 = icmp eq i32 %32, 0
  br i1 %.not45, label %33, label %41

33:                                               ; preds = %31
  %34 = call i32 @mbedtls_mpi_read_file(ptr noundef nonnull %9, i32 noundef 16, ptr noundef nonnull %21) #4
  %.not46 = icmp eq i32 %34, 0
  br i1 %.not46, label %35, label %41

35:                                               ; preds = %33
  %36 = call i32 @mbedtls_mpi_read_file(ptr noundef nonnull %12, i32 noundef 16, ptr noundef nonnull %21) #4
  %.not47 = icmp eq i32 %36, 0
  br i1 %.not47, label %37, label %41

37:                                               ; preds = %35
  %38 = call i32 @mbedtls_mpi_read_file(ptr noundef nonnull %13, i32 noundef 16, ptr noundef nonnull %21) #4
  %.not48 = icmp eq i32 %38, 0
  br i1 %.not48, label %39, label %41

39:                                               ; preds = %37
  %40 = call i32 @mbedtls_mpi_read_file(ptr noundef nonnull %14, i32 noundef 16, ptr noundef nonnull %21) #4
  %.not49 = icmp eq i32 %40, 0
  br i1 %.not49, label %44, label %41

41:                                               ; preds = %39, %37, %35, %33, %31, %29, %27, %25
  %.027 = phi i32 [ %26, %25 ], [ %28, %27 ], [ %30, %29 ], [ %32, %31 ], [ %34, %33 ], [ %36, %35 ], [ %38, %37 ], [ %40, %39 ]
  %42 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, i32 noundef %.027)
  %43 = call i32 @fclose(ptr noundef nonnull %21)
  br label %99

44:                                               ; preds = %39
  %45 = call i32 @fclose(ptr noundef nonnull %21)
  %46 = call i32 @mbedtls_rsa_import(ptr noundef nonnull %3, ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef nonnull %9, ptr noundef nonnull %10, ptr noundef nonnull %11) #4
  %.not50 = icmp eq i32 %46, 0
  br i1 %.not50, label %49, label %47

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

49:                                               ; preds = %44
  %50 = call i32 @mbedtls_rsa_complete(ptr noundef nonnull %3) #4
  %.not51 = icmp eq i32 %50, 0
  br i1 %.not51, label %53, label %51

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

53:                                               ; preds = %49
  %54 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  %55 = load ptr, ptr @stdout, align 8, !tbaa !5
  %56 = call i32 @fflush(ptr noundef %55)
  %57 = call i32 @mbedtls_rsa_check_privkey(ptr noundef nonnull %3) #4
  %.not52 = icmp eq i32 %57, 0
  br i1 %.not52, label %61, label %58

58:                                               ; preds = %53
  %59 = sub nsw i32 0, %57
  %60 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9, i32 noundef %59)
  br label %99

61:                                               ; preds = %53
  %62 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  %63 = load ptr, ptr @stdout, align 8, !tbaa !5
  %64 = call i32 @fflush(ptr noundef %63)
  %65 = call ptr @mbedtls_md_info_from_type(i32 noundef 6) #4
  %66 = getelementptr inbounds i8, ptr %1, i64 8
  %67 = load ptr, ptr %66, align 8, !tbaa !5
  %68 = call i32 @mbedtls_md_file(ptr noundef %65, ptr noundef %67, ptr noundef nonnull %4) #4
  %.not53 = icmp eq i32 %68, 0
  br i1 %.not53, label %72, label %69

69:                                               ; preds = %61
  %70 = load ptr, ptr %66, align 8, !tbaa !5
  %71 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef %70)
  br label %99

72:                                               ; preds = %61
  %73 = call i32 @mbedtls_rsa_pkcs1_sign(ptr noundef nonnull %3, ptr noundef null, ptr noundef null, i32 noundef 1, i32 noundef 6, i32 noundef 20, ptr noundef nonnull %4, ptr noundef nonnull %5) #4
  %.not54 = icmp eq i32 %73, 0
  br i1 %.not54, label %77, label %74

74:                                               ; preds = %72
  %75 = sub nsw i32 0, %73
  %76 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, i32 noundef %75)
  br label %99

77:                                               ; preds = %72
  %78 = load ptr, ptr %66, align 8, !tbaa !5
  %79 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %6, i64 noundef 512, ptr noundef nonnull @.str.13, ptr noundef %78) #4
  %80 = call noalias ptr @fopen(ptr noundef nonnull %6, ptr noundef nonnull @.str.14)
  %81 = icmp eq ptr %80, null
  br i1 %81, label %84, label %.preheader

.preheader:                                       ; preds = %77
  %82 = getelementptr inbounds i8, ptr %3, i64 8
  %83 = load i64, ptr %82, align 8, !tbaa !9
  %.not56 = icmp eq i64 %83, 0
  br i1 %.not56, label %._crit_edge, label %.lr.ph

84:                                               ; preds = %77
  %85 = load ptr, ptr %66, align 8, !tbaa !5
  %86 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15, ptr noundef %85)
  br label %99

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.055 = phi i64 [ %90, %.lr.ph ], [ 0, %.preheader ]
  %87 = getelementptr inbounds [1024 x i8], ptr %5, i64 0, i64 %.055
  %88 = load i8, ptr %87, align 1, !tbaa !14
  %89 = zext i8 %88 to i32
  %90 = add nuw i64 %.055, 1
  %91 = and i64 %90, 15
  %92 = icmp eq i64 %91, 0
  %93 = select i1 %92, ptr @.str.17, ptr @.str.18
  %94 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %80, ptr noundef nonnull @.str.16, i32 noundef %89, ptr noundef nonnull %93) #4
  %95 = load i64, ptr %82, align 8, !tbaa !9
  %96 = icmp ult i64 %90, %95
  br i1 %96, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %97 = call i32 @fclose(ptr noundef nonnull %80)
  %98 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.19, ptr noundef nonnull %6)
  br label %99

99:                                               ; preds = %._crit_edge, %84, %74, %69, %58, %51, %47, %41, %23, %15
  %.026 = phi i32 [ 1, %15 ], [ 1, %23 ], [ 1, %41 ], [ 1, %47 ], [ 1, %51 ], [ 1, %58 ], [ 1, %69 ], [ 1, %74 ], [ 1, %84 ], [ 0, %._crit_edge ]
  call void @mbedtls_rsa_free(ptr noundef nonnull %3) #4
  call void @mbedtls_mpi_free(ptr noundef nonnull %7) #4
  call void @mbedtls_mpi_free(ptr noundef nonnull %8) #4
  call void @mbedtls_mpi_free(ptr noundef nonnull %9) #4
  call void @mbedtls_mpi_free(ptr noundef nonnull %10) #4
  call void @mbedtls_mpi_free(ptr noundef nonnull %11) #4
  call void @mbedtls_mpi_free(ptr noundef nonnull %12) #4
  call void @mbedtls_mpi_free(ptr noundef nonnull %13) #4
  call void @mbedtls_mpi_free(ptr noundef nonnull %14) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %14) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %13) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %12) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %11) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %10) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 336, ptr nonnull %3) #4
  ret i32 %.026
}

; 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_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

; 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_read_file(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 i32 @mbedtls_rsa_import(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @mbedtls_rsa_complete(ptr noundef) local_unnamed_addr #2

declare i32 @mbedtls_rsa_check_privkey(ptr noundef) local_unnamed_addr #2

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

declare ptr @mbedtls_md_info_from_type(i32 noundef) local_unnamed_addr #2

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

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

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

declare void @mbedtls_rsa_free(ptr noundef) local_unnamed_addr #2

declare void @mbedtls_mpi_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 = { nounwind }

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

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