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

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.mbedtls_pk_context = type { ptr, ptr }
%struct.mbedtls_entropy_context = type { %struct.mbedtls_sha512_context, i32, [20 x %struct.mbedtls_entropy_source_state] }
%struct.mbedtls_sha512_context = type { [2 x i64], [8 x i64], [128 x i8], i32 }
%struct.mbedtls_entropy_source_state = type { ptr, ptr, i64, i64, i32 }
%struct.mbedtls_ctr_drbg_context = type { [16 x i8], i32, i32, i64, i32, %struct.mbedtls_aes_context, ptr, ptr }
%struct.mbedtls_aes_context = type { i32, ptr, [68 x i32] }

@.str = external hidden unnamed_addr constant [40 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 [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [42 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 [27 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [19 x i8], align 1

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

21:                                               ; preds = %2
  %22 = load ptr, ptr %5, align 8, !tbaa !9
  %23 = getelementptr inbounds ptr, ptr %22, i64 0
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef %24)
  br label %119

26:                                               ; preds = %2
  %27 = load ptr, ptr %5, align 8, !tbaa !9
  %28 = getelementptr inbounds ptr, ptr %27, i64 1
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  store ptr %29, ptr %15, align 8, !tbaa !9
  %30 = load ptr, ptr %5, align 8, !tbaa !9
  %31 = getelementptr inbounds ptr, ptr %30, i64 2
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  store ptr %32, ptr %16, align 8, !tbaa !9
  %33 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  %34 = load ptr, ptr @stdout, align 8, !tbaa !9
  %35 = call i32 @fflush(ptr noundef %34)
  store ptr @.str.2, ptr %17, align 8, !tbaa !9
  %36 = load ptr, ptr %17, align 8, !tbaa !9
  %37 = load ptr, ptr %17, align 8, !tbaa !9
  %38 = call i64 @strlen(ptr noundef %37) #7
  %39 = call i32 @mbedtls_ctr_drbg_seed(ptr noundef %14, ptr noundef @mbedtls_entropy_func, ptr noundef %13, ptr noundef %36, i64 noundef %38)
  store i32 %39, ptr %7, align 4, !tbaa !5
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = icmp ne i32 %40, 0
  br i1 %41, label %42, label %45

42:                                               ; preds = %26
  %43 = load i32, ptr %7, align 4, !tbaa !5
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %43)
  br label %119

45:                                               ; preds = %26
  %46 = load ptr, ptr %15, align 8, !tbaa !9
  %47 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, ptr noundef %46)
  %48 = load ptr, ptr @stdout, align 8, !tbaa !9
  %49 = call i32 @fflush(ptr noundef %48)
  %50 = load ptr, ptr %15, align 8, !tbaa !9
  %51 = call i32 @mbedtls_pk_parse_keyfile(ptr noundef %12, ptr noundef %50, ptr noundef @.str.5)
  store i32 %51, ptr %7, align 4, !tbaa !5
  %52 = load i32, ptr %7, align 4, !tbaa !5
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %59

54:                                               ; preds = %45
  %55 = load ptr, ptr %15, align 8, !tbaa !9
  %56 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, ptr noundef %55)
  %57 = load i32, ptr %7, align 4, !tbaa !5
  %58 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %57)
  br label %119

59:                                               ; preds = %45
  %60 = call i32 @mbedtls_pk_can_do(ptr noundef %12, i32 noundef 1)
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %64, label %62

62:                                               ; preds = %59
  store i32 0, ptr %7, align 4, !tbaa !5
  %63 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  br label %119

64:                                               ; preds = %59
  %65 = getelementptr inbounds { ptr, ptr }, ptr %12, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8
  %67 = getelementptr inbounds { ptr, ptr }, ptr %12, i32 0, i32 1
  %68 = load ptr, ptr %67, align 8
  %69 = call ptr @mbedtls_pk_rsa(ptr %66, ptr %68)
  call void @mbedtls_rsa_set_padding(ptr noundef %69, i32 noundef 0, i32 noundef 8)
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  %71 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  %72 = load ptr, ptr @stdout, align 8, !tbaa !9
  %73 = call i32 @fflush(ptr noundef %72)
  %74 = call ptr @mbedtls_md_info_from_type(i32 noundef 8)
  %75 = load ptr, ptr %16, align 8, !tbaa !9
  %76 = getelementptr inbounds [64 x i8], ptr %8, i64 0, i64 0
  %77 = call i32 @mbedtls_md_file(ptr noundef %74, ptr noundef %75, ptr noundef %76)
  store i32 %77, ptr %7, align 4, !tbaa !5
  %78 = load i32, ptr %7, align 4, !tbaa !5
  %79 = icmp ne i32 %78, 0
  br i1 %79, label %80, label %83

80:                                               ; preds = %64
  %81 = load ptr, ptr %16, align 8, !tbaa !9
  %82 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, ptr noundef %81)
  br label %119

83:                                               ; preds = %64
  store i64 0, ptr %18, align 8, !tbaa !11
  %84 = getelementptr inbounds [64 x i8], ptr %8, i64 0, i64 0
  %85 = getelementptr inbounds [1024 x i8], ptr %9, i64 0, i64 0
  %86 = call i32 @mbedtls_pk_sign(ptr noundef %12, i32 noundef 8, ptr noundef %84, i64 noundef 0, ptr noundef %85, ptr noundef %18, ptr noundef @mbedtls_ctr_drbg_random, ptr noundef %14)
  store i32 %86, ptr %7, align 4, !tbaa !5
  %87 = load i32, ptr %7, align 4, !tbaa !5
  %88 = icmp ne i32 %87, 0
  br i1 %88, label %89, label %92

89:                                               ; preds = %83
  %90 = load i32, ptr %7, align 4, !tbaa !5
  %91 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, i32 noundef %90)
  br label %119

92:                                               ; preds = %83
  %93 = getelementptr inbounds [512 x i8], ptr %10, i64 0, i64 0
  %94 = load ptr, ptr %16, align 8, !tbaa !9
  %95 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef %93, i64 noundef 512, ptr noundef @.str.13, ptr noundef %94) #6
  %96 = getelementptr inbounds [512 x i8], ptr %10, i64 0, i64 0
  %97 = call noalias ptr @fopen(ptr noundef %96, ptr noundef @.str.14)
  store ptr %97, ptr %6, align 8, !tbaa !9
  %98 = load ptr, ptr %6, align 8, !tbaa !9
  %99 = icmp eq ptr %98, null
  br i1 %99, label %100, label %103

100:                                              ; preds = %92
  store i32 1, ptr %7, align 4, !tbaa !5
  %101 = getelementptr inbounds [512 x i8], ptr %10, i64 0, i64 0
  %102 = call i32 (ptr, ...) @printf(ptr noundef @.str.15, ptr noundef %101)
  br label %119

103:                                              ; preds = %92
  %104 = getelementptr inbounds [1024 x i8], ptr %9, i64 0, i64 0
  %105 = load i64, ptr %18, align 8, !tbaa !11
  %106 = load ptr, ptr %6, align 8, !tbaa !9
  %107 = call i64 @fwrite(ptr noundef %104, i64 noundef 1, i64 noundef %105, ptr noundef %106)
  %108 = load i64, ptr %18, align 8, !tbaa !11
  %109 = icmp ne i64 %107, %108
  br i1 %109, label %110, label %114

110:                                              ; preds = %103
  %111 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  %112 = load ptr, ptr %6, align 8, !tbaa !9
  %113 = call i32 @fclose(ptr noundef %112)
  br label %119

114:                                              ; preds = %103
  %115 = load ptr, ptr %6, align 8, !tbaa !9
  %116 = call i32 @fclose(ptr noundef %115)
  %117 = getelementptr inbounds [512 x i8], ptr %10, i64 0, i64 0
  %118 = call i32 (ptr, ...) @printf(ptr noundef @.str.17, ptr noundef %117)
  br label %119

119:                                              ; preds = %114, %110, %100, %89, %80, %62, %54, %42, %21
  %120 = load i32, ptr %7, align 4, !tbaa !5
  %121 = icmp ne i32 %120, 0
  br i1 %121, label %122, label %127

122:                                              ; preds = %119
  %123 = load i32, ptr %7, align 4, !tbaa !5
  %124 = getelementptr inbounds [80 x i8], ptr %11, i64 0, i64 0
  call void @mbedtls_strerror(i32 noundef %123, ptr noundef %124, i64 noundef 80)
  %125 = getelementptr inbounds [80 x i8], ptr %11, i64 0, i64 0
  %126 = call i32 (ptr, ...) @printf(ptr noundef @.str.18, ptr noundef %125)
  br label %127

127:                                              ; preds = %122, %119
  call void @mbedtls_pk_free(ptr noundef %12)
  call void @mbedtls_ctr_drbg_free(ptr noundef %14)
  call void @mbedtls_entropy_free(ptr noundef %13)
  %128 = load i32, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 344, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 1024, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 80, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 512, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 1024, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 64, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  ret i32 %128
}

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

declare void @mbedtls_entropy_init(ptr noundef) #2

declare void @mbedtls_pk_init(ptr noundef) #2

declare void @mbedtls_ctr_drbg_init(ptr noundef) #2

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

declare i32 @fflush(ptr noundef) #2

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

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

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

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

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @mbedtls_pk_rsa(ptr, ptr) #4

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

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

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

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

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #2

declare i32 @fclose(ptr noundef) #2

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

declare void @mbedtls_pk_free(ptr noundef) #2

declare void @mbedtls_ctr_drbg_free(ptr noundef) #2

declare void @mbedtls_entropy_free(ptr noundef) #2

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!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}


; 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_pk_context = type { ptr, ptr }
%struct.mbedtls_entropy_context = type { %struct.mbedtls_sha512_context, i32, [20 x %struct.mbedtls_entropy_source_state] }
%struct.mbedtls_sha512_context = type { [2 x i64], [8 x i64], [128 x i8], i32 }
%struct.mbedtls_entropy_source_state = type { ptr, ptr, i64, i64, i32 }
%struct.mbedtls_ctr_drbg_context = type { [16 x i8], i32, i32, i64, i32, %struct.mbedtls_aes_context, ptr, ptr }
%struct.mbedtls_aes_context = type { i32, ptr, [68 x i32] }

@.str = external hidden unnamed_addr constant [40 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 [13 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [1 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [42 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 [27 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [19 x i8], align 1

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

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

14:                                               ; preds = %2
  %15 = getelementptr inbounds i8, ptr %1, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %1, i64 16
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %20 = load ptr, ptr @stdout, align 8, !tbaa !5
  %21 = call i32 @fflush(ptr noundef %20)
  %22 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) @.str.2) #7
  %23 = call i32 @mbedtls_ctr_drbg_seed(ptr noundef nonnull %9, ptr noundef nonnull @mbedtls_entropy_func, ptr noundef nonnull %8, ptr noundef nonnull @.str.2, i64 noundef %22) #6
  %.not30 = icmp eq i32 %23, 0
  br i1 %.not30, label %26, label %24

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

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

31:                                               ; preds = %26
  %32 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef %16)
  %33 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i32 noundef %30)
  br label %71

34:                                               ; preds = %26
  %35 = call i32 @mbedtls_pk_can_do(ptr noundef nonnull %7, i32 noundef 1) #6
  %.not32 = icmp eq i32 %35, 0
  br i1 %.not32, label %36, label %38

36:                                               ; preds = %34
  %37 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  br label %73

38:                                               ; preds = %34
  %39 = load ptr, ptr %7, align 8
  %40 = getelementptr inbounds i8, ptr %7, i64 8
  %41 = load ptr, ptr %40, align 8
  %42 = call ptr @mbedtls_pk_rsa(ptr %39, ptr %41)
  call void @mbedtls_rsa_set_padding(ptr noundef %42, i32 noundef 0, i32 noundef 8) #6
  %43 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  %44 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  %45 = load ptr, ptr @stdout, align 8, !tbaa !5
  %46 = call i32 @fflush(ptr noundef %45)
  %47 = call ptr @mbedtls_md_info_from_type(i32 noundef 8) #6
  %48 = call i32 @mbedtls_md_file(ptr noundef %47, ptr noundef %18, ptr noundef nonnull %3) #6
  %.not33 = icmp eq i32 %48, 0
  br i1 %.not33, label %51, label %49

49:                                               ; preds = %38
  %50 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef %18)
  br label %71

51:                                               ; preds = %38
  store i64 0, ptr %10, align 8, !tbaa !9
  %52 = call i32 @mbedtls_pk_sign(ptr noundef nonnull %7, i32 noundef 8, ptr noundef nonnull %3, i64 noundef 0, ptr noundef nonnull %4, ptr noundef nonnull %10, ptr noundef nonnull @mbedtls_ctr_drbg_random, ptr noundef nonnull %9) #6
  %.not34 = icmp eq i32 %52, 0
  br i1 %.not34, label %55, label %53

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

55:                                               ; preds = %51
  %56 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr noundef nonnull dereferenceable(1) %5, i64 noundef 512, ptr noundef nonnull @.str.13, ptr noundef %18) #6
  %57 = call noalias ptr @fopen(ptr noundef nonnull %5, ptr noundef nonnull @.str.14)
  %58 = icmp eq ptr %57, null
  br i1 %58, label %59, label %61

59:                                               ; preds = %55
  %60 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15, ptr noundef nonnull %5)
  br label %71

61:                                               ; preds = %55
  %62 = load i64, ptr %10, align 8, !tbaa !9
  %63 = call i64 @fwrite(ptr noundef nonnull %4, i64 noundef 1, i64 noundef %62, ptr noundef nonnull %57)
  %64 = load i64, ptr %10, align 8, !tbaa !9
  %.not35 = icmp eq i64 %63, %64
  br i1 %.not35, label %68, label %65

65:                                               ; preds = %61
  %66 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16)
  %67 = call i32 @fclose(ptr noundef nonnull %57)
  br label %73

68:                                               ; preds = %61
  %69 = call i32 @fclose(ptr noundef nonnull %57)
  %70 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17, ptr noundef nonnull %5)
  br label %73

71:                                               ; preds = %24, %31, %49, %53, %59
  %.0.ph = phi i32 [ 1, %59 ], [ %52, %53 ], [ %48, %49 ], [ %30, %31 ], [ %23, %24 ]
  call void @mbedtls_strerror(i32 noundef %.0.ph, ptr noundef nonnull %6, i64 noundef 80) #6
  %72 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.18, ptr noundef nonnull %6)
  br label %73

73:                                               ; preds = %11, %36, %65, %68, %71
  %.040 = phi i32 [ %.0.ph, %71 ], [ 0, %11 ], [ 0, %65 ], [ 0, %68 ], [ 0, %36 ]
  call void @mbedtls_pk_free(ptr noundef nonnull %7) #6
  call void @mbedtls_ctr_drbg_free(ptr noundef nonnull %9) #6
  call void @mbedtls_entropy_free(ptr noundef nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 344, ptr nonnull %9) #6
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %3) #6
  ret i32 %.040
}

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

declare void @mbedtls_pk_init(ptr noundef) local_unnamed_addr #2

declare void @mbedtls_ctr_drbg_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 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_pk_parse_keyfile(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @mbedtls_pk_rsa(ptr, ptr) local_unnamed_addr #5

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

declare i32 @mbedtls_ctr_drbg_random(ptr noundef, ptr noundef, i64 noundef) #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 noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #3

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

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

declare void @mbedtls_pk_free(ptr noundef) local_unnamed_addr #2

declare void @mbedtls_ctr_drbg_free(ptr noundef) local_unnamed_addr #2

declare void @mbedtls_entropy_free(ptr noundef) local_unnamed_addr #2

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

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

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

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


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