; LLVM IR from tleonhardt/practical_cryptography_engineering :: ecdh_read_server_pub_write_client_pub (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_ecdh_context = type { %struct.mbedtls_ecp_group, %struct.mbedtls_mpi, %struct.mbedtls_ecp_point, %struct.mbedtls_ecp_point, %struct.mbedtls_mpi, i32, %struct.mbedtls_ecp_point, %struct.mbedtls_ecp_point, %struct.mbedtls_mpi }
%struct.mbedtls_ecp_group = type { i32, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_ecp_point, %struct.mbedtls_mpi, i64, i64, i32, ptr, ptr, ptr, ptr, ptr, i64 }
%struct.mbedtls_ecp_point = type { %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi }
%struct.mbedtls_mpi = type { i32, i64, 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] }

@__const.main.pers = external hidden unnamed_addr constant [5 x i8], align 1
@.str = external hidden unnamed_addr constant [24 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [43 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 [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.14 = 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 i32, align 4
  %7 = alloca %struct.mbedtls_ecdh_context, align 8
  %8 = alloca %struct.mbedtls_entropy_context, align 8
  %9 = alloca %struct.mbedtls_ctr_drbg_context, align 8
  %10 = alloca [66 x i8], align 16
  %11 = alloca [66 x i8], align 16
  %12 = alloca [66 x i8], align 16
  %13 = alloca [66 x i8], align 16
  %14 = alloca [5 x i8], align 1
  %15 = alloca [80 x i8], align 16
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 616, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 1024, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 344, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 66, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 66, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 66, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 66, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 5, ptr %14) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %14, ptr align 1 @__const.main.pers, i64 5, i1 false)
  call void @llvm.lifetime.start.p0(i64 80, ptr %15) #4
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = load ptr, ptr %5, align 8, !tbaa !9
  call void @mbedtls_ecdh_init(ptr noundef %7)
  call void @mbedtls_ctr_drbg_init(ptr noundef %9)
  call void @mbedtls_entropy_init(ptr noundef %8)
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  %21 = load ptr, ptr @stdout, align 8, !tbaa !9
  %22 = call i32 @fflush(ptr noundef %21)
  %23 = getelementptr inbounds [5 x i8], ptr %14, i64 0, i64 0
  %24 = call i32 @mbedtls_ctr_drbg_seed(ptr noundef %9, ptr noundef @mbedtls_entropy_func, ptr noundef %8, ptr noundef %23, i64 noundef 5)
  store i32 %24, ptr %6, align 4, !tbaa !5
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %30

27:                                               ; preds = %2
  %28 = load i32, ptr %6, align 4, !tbaa !5
  %29 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %28)
  br label %122

30:                                               ; preds = %2
  %31 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %33 = load ptr, ptr @stdout, align 8, !tbaa !9
  %34 = call i32 @fflush(ptr noundef %33)
  %35 = getelementptr inbounds %struct.mbedtls_ecdh_context, ptr %7, i32 0, i32 0
  %36 = call i32 @mbedtls_ecp_group_load(ptr noundef %35, i32 noundef 5)
  store i32 %36, ptr %6, align 4, !tbaa !5
  %37 = load i32, ptr %6, align 4, !tbaa !5
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %42

39:                                               ; preds = %30
  %40 = load i32, ptr %6, align 4, !tbaa !5
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i32 noundef %40)
  br label %122

42:                                               ; preds = %30
  %43 = getelementptr inbounds %struct.mbedtls_ecdh_context, ptr %7, i32 0, i32 0
  %44 = getelementptr inbounds %struct.mbedtls_ecdh_context, ptr %7, i32 0, i32 1
  %45 = getelementptr inbounds %struct.mbedtls_ecdh_context, ptr %7, i32 0, i32 2
  %46 = call i32 @mbedtls_ecdh_gen_public(ptr noundef %43, ptr noundef %44, ptr noundef %45, ptr noundef @mbedtls_ctr_drbg_random, ptr noundef %9)
  store i32 %46, ptr %6, align 4, !tbaa !5
  %47 = load i32, ptr %6, align 4, !tbaa !5
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %52

49:                                               ; preds = %42
  %50 = load i32, ptr %6, align 4, !tbaa !5
  %51 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i32 noundef %50)
  br label %122

52:                                               ; preds = %42
  %53 = getelementptr inbounds %struct.mbedtls_ecdh_context, ptr %7, i32 0, i32 2
  %54 = getelementptr inbounds %struct.mbedtls_ecp_point, ptr %53, i32 0, i32 0
  %55 = getelementptr inbounds [66 x i8], ptr %10, i64 0, i64 0
  %56 = call i32 @mbedtls_mpi_write_binary(ptr noundef %54, ptr noundef %55, i64 noundef 66)
  store i32 %56, ptr %6, align 4, !tbaa !5
  %57 = load i32, ptr %6, align 4, !tbaa !5
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %62

59:                                               ; preds = %52
  %60 = load i32, ptr %6, align 4, !tbaa !5
  %61 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, i32 noundef %60)
  br label %122

62:                                               ; preds = %52
  %63 = getelementptr inbounds %struct.mbedtls_ecdh_context, ptr %7, i32 0, i32 2
  %64 = getelementptr inbounds %struct.mbedtls_ecp_point, ptr %63, i32 0, i32 1
  %65 = getelementptr inbounds [66 x i8], ptr %11, i64 0, i64 0
  %66 = call i32 @mbedtls_mpi_write_binary(ptr noundef %64, ptr noundef %65, i64 noundef 66)
  store i32 %66, ptr %6, align 4, !tbaa !5
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %69, label %72

69:                                               ; preds = %62
  %70 = load i32, ptr %6, align 4, !tbaa !5
  %71 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, i32 noundef %70)
  br label %122

72:                                               ; preds = %62
  %73 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %74 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  %75 = load ptr, ptr @stdout, align 8, !tbaa !9
  %76 = call i32 @fflush(ptr noundef %75)
  %77 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  %78 = load ptr, ptr @stdout, align 8, !tbaa !9
  %79 = call i32 @fflush(ptr noundef %78)
  %80 = getelementptr inbounds %struct.mbedtls_ecdh_context, ptr %7, i32 0, i32 3
  %81 = getelementptr inbounds %struct.mbedtls_ecp_point, ptr %80, i32 0, i32 2
  %82 = call i32 @mbedtls_mpi_lset(ptr noundef %81, i64 noundef 1)
  store i32 %82, ptr %6, align 4, !tbaa !5
  %83 = load i32, ptr %6, align 4, !tbaa !5
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %85, label %88

85:                                               ; preds = %72
  %86 = load i32, ptr %6, align 4, !tbaa !5
  %87 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, i32 noundef %86)
  br label %122

88:                                               ; preds = %72
  %89 = getelementptr inbounds %struct.mbedtls_ecdh_context, ptr %7, i32 0, i32 3
  %90 = getelementptr inbounds %struct.mbedtls_ecp_point, ptr %89, i32 0, i32 0
  %91 = getelementptr inbounds [66 x i8], ptr %12, i64 0, i64 0
  %92 = call i32 @mbedtls_mpi_read_binary(ptr noundef %90, ptr noundef %91, i64 noundef 66)
  store i32 %92, ptr %6, align 4, !tbaa !5
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = icmp ne i32 %93, 0
  br i1 %94, label %95, label %98

95:                                               ; preds = %88
  %96 = load i32, ptr %6, align 4, !tbaa !5
  %97 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, i32 noundef %96)
  br label %122

98:                                               ; preds = %88
  %99 = getelementptr inbounds %struct.mbedtls_ecdh_context, ptr %7, i32 0, i32 3
  %100 = getelementptr inbounds %struct.mbedtls_ecp_point, ptr %99, i32 0, i32 1
  %101 = getelementptr inbounds [66 x i8], ptr %13, i64 0, i64 0
  %102 = call i32 @mbedtls_mpi_read_binary(ptr noundef %100, ptr noundef %101, i64 noundef 66)
  store i32 %102, ptr %6, align 4, !tbaa !5
  %103 = load i32, ptr %6, align 4, !tbaa !5
  %104 = icmp ne i32 %103, 0
  br i1 %104, label %105, label %108

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

108:                                              ; preds = %98
  %109 = getelementptr inbounds %struct.mbedtls_ecdh_context, ptr %7, i32 0, i32 0
  %110 = getelementptr inbounds %struct.mbedtls_ecdh_context, ptr %7, i32 0, i32 4
  %111 = getelementptr inbounds %struct.mbedtls_ecdh_context, ptr %7, i32 0, i32 3
  %112 = getelementptr inbounds %struct.mbedtls_ecdh_context, ptr %7, i32 0, i32 1
  %113 = call i32 @mbedtls_ecdh_compute_shared(ptr noundef %109, ptr noundef %110, ptr noundef %111, ptr noundef %112, ptr noundef @mbedtls_ctr_drbg_random, ptr noundef %9)
  store i32 %113, ptr %6, align 4, !tbaa !5
  %114 = load i32, ptr %6, align 4, !tbaa !5
  %115 = icmp ne i32 %114, 0
  br i1 %115, label %116, label %120

116:                                              ; preds = %108
  %117 = load i32, ptr %6, align 4, !tbaa !5
  %118 = sub nsw i32 0, %117
  %119 = call i32 (ptr, ...) @printf(ptr noundef @.str.13, i32 noundef %118)
  br label %122

120:                                              ; preds = %108
  %121 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %122

122:                                              ; preds = %120, %116, %105, %95, %85, %69, %59, %49, %39, %27
  %123 = load i32, ptr %6, align 4, !tbaa !5
  %124 = icmp ne i32 %123, 0
  br i1 %124, label %125, label %130

125:                                              ; preds = %122
  %126 = load i32, ptr %6, align 4, !tbaa !5
  %127 = getelementptr inbounds [80 x i8], ptr %15, i64 0, i64 0
  call void @mbedtls_strerror(i32 noundef %126, ptr noundef %127, i64 noundef 80)
  %128 = getelementptr inbounds [80 x i8], ptr %15, i64 0, i64 0
  %129 = call i32 (ptr, ...) @printf(ptr noundef @.str.14, ptr noundef %128)
  br label %130

130:                                              ; preds = %125, %122
  call void @mbedtls_ecdh_free(ptr noundef %7)
  call void @mbedtls_ctr_drbg_free(ptr noundef %9)
  call void @mbedtls_entropy_free(ptr noundef %8)
  %131 = load i32, ptr %6, align 4, !tbaa !5
  %132 = icmp ne i32 %131, 0
  %133 = zext i1 %132 to i32
  call void @llvm.lifetime.end.p0(i64 80, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 5, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 66, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 66, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 66, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 66, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 344, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 1024, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 616, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  ret i32 %133
}

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

; 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) #2

declare void @mbedtls_ecdh_init(ptr noundef) #3

declare void @mbedtls_ctr_drbg_init(ptr noundef) #3

declare void @mbedtls_entropy_init(ptr noundef) #3

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

declare i32 @fflush(ptr noundef) #3

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

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

declare i32 @mbedtls_ecp_group_load(ptr noundef, i32 noundef) #3

declare i32 @mbedtls_ecdh_gen_public(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

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

declare i32 @mbedtls_mpi_write_binary(ptr noundef, ptr noundef, i64 noundef) #3

declare i32 @mbedtls_mpi_lset(ptr noundef, i64 noundef) #3

declare i32 @mbedtls_mpi_read_binary(ptr noundef, ptr noundef, i64 noundef) #3

declare i32 @mbedtls_ecdh_compute_shared(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

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

declare void @mbedtls_ecdh_free(ptr noundef) #3

declare void @mbedtls_ctr_drbg_free(ptr noundef) #3

declare void @mbedtls_entropy_free(ptr noundef) #3

; 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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}


; 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_ecdh_context = type { %struct.mbedtls_ecp_group, %struct.mbedtls_mpi, %struct.mbedtls_ecp_point, %struct.mbedtls_ecp_point, %struct.mbedtls_mpi, i32, %struct.mbedtls_ecp_point, %struct.mbedtls_ecp_point, %struct.mbedtls_mpi }
%struct.mbedtls_ecp_group = type { i32, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_ecp_point, %struct.mbedtls_mpi, i64, i64, i32, ptr, ptr, ptr, ptr, ptr, i64 }
%struct.mbedtls_ecp_point = type { %struct.mbedtls_mpi, %struct.mbedtls_mpi, %struct.mbedtls_mpi }
%struct.mbedtls_mpi = type { i32, i64, 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] }

@__const.main.pers = external hidden unnamed_addr constant [5 x i8], align 1
@.str = external hidden unnamed_addr constant [24 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [43 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 [5 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [82 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = alloca %struct.mbedtls_ecdh_context, align 8
  %4 = alloca %struct.mbedtls_entropy_context, align 8
  %5 = alloca %struct.mbedtls_ctr_drbg_context, align 8
  %6 = alloca [66 x i8], align 16
  %7 = alloca [66 x i8], align 16
  %8 = alloca [66 x i8], align 16
  %9 = alloca [66 x i8], align 16
  %10 = alloca [5 x i8], align 1
  %11 = alloca [80 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 616, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 344, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 66, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 66, ptr nonnull %7) #5
  call void @llvm.lifetime.start.p0(i64 66, ptr nonnull %8) #5
  call void @llvm.lifetime.start.p0(i64 66, ptr nonnull %9) #5
  call void @llvm.lifetime.start.p0(i64 5, ptr nonnull %10) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(5) %10, ptr noundef nonnull align 1 dereferenceable(5) @__const.main.pers, i64 5, i1 false)
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %11) #5
  call void @mbedtls_ecdh_init(ptr noundef nonnull %3) #5
  call void @mbedtls_ctr_drbg_init(ptr noundef nonnull %5) #5
  call void @mbedtls_entropy_init(ptr noundef nonnull %4) #5
  %12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %14 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %15 = load ptr, ptr @stdout, align 8, !tbaa !5
  %16 = call i32 @fflush(ptr noundef %15)
  %17 = call i32 @mbedtls_ctr_drbg_seed(ptr noundef nonnull %5, ptr noundef nonnull @mbedtls_entropy_func, ptr noundef nonnull %4, ptr noundef nonnull %10, i64 noundef 5) #5
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %20, label %18

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

20:                                               ; preds = %2
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %22 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %23 = load ptr, ptr @stdout, align 8, !tbaa !5
  %24 = call i32 @fflush(ptr noundef %23)
  %25 = call i32 @mbedtls_ecp_group_load(ptr noundef nonnull %3, i32 noundef 5) #5
  %.not31 = icmp eq i32 %25, 0
  br i1 %.not31, label %28, label %26

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

28:                                               ; preds = %20
  %29 = getelementptr inbounds i8, ptr %3, i64 248
  %30 = getelementptr inbounds i8, ptr %3, i64 272
  %31 = call i32 @mbedtls_ecdh_gen_public(ptr noundef nonnull %3, ptr noundef nonnull %29, ptr noundef nonnull %30, ptr noundef nonnull @mbedtls_ctr_drbg_random, ptr noundef nonnull %5) #5
  %.not32 = icmp eq i32 %31, 0
  br i1 %.not32, label %34, label %32

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

34:                                               ; preds = %28
  %35 = call i32 @mbedtls_mpi_write_binary(ptr noundef nonnull %30, ptr noundef nonnull %6, i64 noundef 66) #5
  %.not33 = icmp eq i32 %35, 0
  br i1 %.not33, label %38, label %36

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

38:                                               ; preds = %34
  %39 = getelementptr inbounds i8, ptr %3, i64 296
  %40 = call i32 @mbedtls_mpi_write_binary(ptr noundef nonnull %39, ptr noundef nonnull %7, i64 noundef 66) #5
  %.not34 = icmp eq i32 %40, 0
  br i1 %.not34, label %43, label %41

41:                                               ; preds = %38
  %42 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, i32 noundef %40)
  br label %73

43:                                               ; preds = %38
  %44 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %45 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  %46 = load ptr, ptr @stdout, align 8, !tbaa !5
  %47 = call i32 @fflush(ptr noundef %46)
  %48 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  %49 = load ptr, ptr @stdout, align 8, !tbaa !5
  %50 = call i32 @fflush(ptr noundef %49)
  %51 = getelementptr inbounds i8, ptr %3, i64 344
  %52 = getelementptr inbounds i8, ptr %3, i64 392
  %53 = call i32 @mbedtls_mpi_lset(ptr noundef nonnull %52, i64 noundef 1) #5
  %.not35 = icmp eq i32 %53, 0
  br i1 %.not35, label %56, label %54

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

56:                                               ; preds = %43
  %57 = call i32 @mbedtls_mpi_read_binary(ptr noundef nonnull %51, ptr noundef nonnull %8, i64 noundef 66) #5
  %.not36 = icmp eq i32 %57, 0
  br i1 %.not36, label %60, label %58

58:                                               ; preds = %56
  %59 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, i32 noundef %57)
  br label %73

60:                                               ; preds = %56
  %61 = getelementptr inbounds i8, ptr %3, i64 368
  %62 = call i32 @mbedtls_mpi_read_binary(ptr noundef nonnull %61, ptr noundef nonnull %9, i64 noundef 66) #5
  %.not37 = icmp eq i32 %62, 0
  br i1 %.not37, label %65, label %63

63:                                               ; preds = %60
  %64 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, i32 noundef %62)
  br label %73

65:                                               ; preds = %60
  %66 = getelementptr inbounds i8, ptr %3, i64 416
  %67 = call i32 @mbedtls_ecdh_compute_shared(ptr noundef nonnull %3, ptr noundef nonnull %66, ptr noundef nonnull %51, ptr noundef nonnull %29, ptr noundef nonnull @mbedtls_ctr_drbg_random, ptr noundef nonnull %5) #5
  %.not38 = icmp eq i32 %67, 0
  br i1 %.not38, label %71, label %68

68:                                               ; preds = %65
  %69 = sub nsw i32 0, %67
  %70 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13, i32 noundef %69)
  br label %73

71:                                               ; preds = %65
  %72 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %75

73:                                               ; preds = %18, %26, %32, %36, %41, %54, %58, %63, %68
  %.0.ph = phi i32 [ %67, %68 ], [ %62, %63 ], [ %57, %58 ], [ %53, %54 ], [ %40, %41 ], [ %35, %36 ], [ %31, %32 ], [ %25, %26 ], [ %17, %18 ]
  call void @mbedtls_strerror(i32 noundef %.0.ph, ptr noundef nonnull %11, i64 noundef 80) #5
  %74 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, ptr noundef nonnull %11)
  br label %75

75:                                               ; preds = %71, %73
  %76 = phi i32 [ 1, %73 ], [ 0, %71 ]
  call void @mbedtls_ecdh_free(ptr noundef nonnull %3) #5
  call void @mbedtls_ctr_drbg_free(ptr noundef nonnull %5) #5
  call void @mbedtls_entropy_free(ptr noundef nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %11) #5
  call void @llvm.lifetime.end.p0(i64 5, ptr nonnull %10) #5
  call void @llvm.lifetime.end.p0(i64 66, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 66, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 66, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 66, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 344, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 616, ptr nonnull %3) #5
  ret i32 %76
}

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

; 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) #2

declare void @mbedtls_ecdh_init(ptr noundef) local_unnamed_addr #3

declare void @mbedtls_ctr_drbg_init(ptr noundef) local_unnamed_addr #3

declare void @mbedtls_entropy_init(ptr noundef) local_unnamed_addr #3

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

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

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

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

declare i32 @mbedtls_ecp_group_load(ptr noundef, i32 noundef) local_unnamed_addr #3

declare i32 @mbedtls_ecdh_gen_public(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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

declare i32 @mbedtls_mpi_write_binary(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

declare i32 @mbedtls_mpi_lset(ptr noundef, i64 noundef) local_unnamed_addr #3

declare i32 @mbedtls_mpi_read_binary(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #3

declare i32 @mbedtls_ecdh_compute_shared(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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

declare void @mbedtls_ecdh_free(ptr noundef) local_unnamed_addr #3

declare void @mbedtls_ctr_drbg_free(ptr noundef) local_unnamed_addr #3

declare void @mbedtls_entropy_free(ptr noundef) local_unnamed_addr #3

; 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 = { 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 #5 = { 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"}


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