; LLVM IR from tleonhardt/practical_cryptography_engineering :: mbedtls (ecp)

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

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

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

declare i32 @mbedtls_mpi_cmp_int(ptr noundef, i64 noundef) #1

declare i32 @mbedtls_mpi_cmp_mpi(ptr noundef, ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_ecp_mul(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @ecp_get_type(ptr noundef) #3

declare i64 @mbedtls_mpi_bitlen(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_ecp_gen_keypair_base(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #2 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca [66 x i8], align 16
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.mbedtls_ecp_group, ptr %20, i32 0, i32 7
  %22 = load i64, ptr %21, align 8, !tbaa !9
  %23 = add i64 %22, 7
  %24 = udiv i64 %23, 8
  store i64 %24, ptr %15, align 8, !tbaa !15
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = call i32 @ecp_get_type(ptr noundef %25)
  %27 = icmp eq i32 %26, 2
  br i1 %27, label %28, label %108

28:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  br label %29

29:                                               ; preds = %41, %28
  br label %30

30:                                               ; preds = %29
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = load i64, ptr %15, align 8, !tbaa !15
  %33 = load ptr, ptr %12, align 8, !tbaa !5
  %34 = load ptr, ptr %13, align 8, !tbaa !5
  %35 = call i32 @mbedtls_mpi_fill_random(ptr noundef %31, i64 noundef %32, ptr noundef %33, ptr noundef %34)
  store i32 %35, ptr %14, align 4, !tbaa !16
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %38

37:                                               ; preds = %30
  store i32 6, ptr %17, align 4
  br label %105

38:                                               ; preds = %30
  br label %39

39:                                               ; preds = %38
  br label %40

40:                                               ; preds = %39
  br label %41

41:                                               ; preds = %40
  %42 = load ptr, ptr %10, align 8, !tbaa !5
  %43 = call i64 @mbedtls_mpi_bitlen(ptr noundef %42)
  %44 = icmp eq i64 %43, 0
  br i1 %44, label %29, label %45, !llvm.loop !17

45:                                               ; preds = %41
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = call i64 @mbedtls_mpi_bitlen(ptr noundef %46)
  %48 = sub i64 %47, 1
  store i64 %48, ptr %16, align 8, !tbaa !15
  %49 = load i64, ptr %16, align 8, !tbaa !15
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.mbedtls_ecp_group, ptr %50, i32 0, i32 7
  %52 = load i64, ptr %51, align 8, !tbaa !9
  %53 = icmp ugt i64 %49, %52
  br i1 %53, label %54, label %68

54:                                               ; preds = %45
  br label %55

55:                                               ; preds = %54
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = load i64, ptr %16, align 8, !tbaa !15
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.mbedtls_ecp_group, ptr %58, i32 0, i32 7
  %60 = load i64, ptr %59, align 8, !tbaa !9
  %61 = sub i64 %57, %60
  %62 = call i32 @mbedtls_mpi_shift_r(ptr noundef %56, i64 noundef %61)
  store i32 %62, ptr %14, align 4, !tbaa !16
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %65

64:                                               ; preds = %55
  store i32 6, ptr %17, align 4
  br label %105

65:                                               ; preds = %55
  br label %66

66:                                               ; preds = %65
  br label %67

67:                                               ; preds = %66
  br label %80

68:                                               ; preds = %45
  br label %69

69:                                               ; preds = %68
  %70 = load ptr, ptr %10, align 8, !tbaa !5
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.mbedtls_ecp_group, ptr %71, i32 0, i32 7
  %73 = load i64, ptr %72, align 8, !tbaa !9
  %74 = call i32 @mbedtls_mpi_set_bit(ptr noundef %70, i64 noundef %73, i8 noundef zeroext 1)
  store i32 %74, ptr %14, align 4, !tbaa !16
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %76, label %77

76:                                               ; preds = %69
  store i32 6, ptr %17, align 4
  br label %105

77:                                               ; preds = %69
  br label %78

78:                                               ; preds = %77
  br label %79

79:                                               ; preds = %78
  br label %80

80:                                               ; preds = %79, %67
  br label %81

81:                                               ; preds = %80
  %82 = load ptr, ptr %10, align 8, !tbaa !5
  %83 = call i32 @mbedtls_mpi_set_bit(ptr noundef %82, i64 noundef 0, i8 noundef zeroext 0)
  store i32 %83, ptr %14, align 4, !tbaa !16
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %85, label %86

85:                                               ; preds = %81
  store i32 6, ptr %17, align 4
  br label %105

86:                                               ; preds = %81
  br label %87

87:                                               ; preds = %86
  br label %88

88:                                               ; preds = %87
  br label %89

89:                                               ; preds = %88
  %90 = load ptr, ptr %10, align 8, !tbaa !5
  %91 = call i32 @mbedtls_mpi_set_bit(ptr noundef %90, i64 noundef 1, i8 noundef zeroext 0)
  store i32 %91, ptr %14, align 4, !tbaa !16
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %93, label %94

93:                                               ; preds = %89
  store i32 6, ptr %17, align 4
  br label %105

94:                                               ; preds = %89
  br label %95

95:                                               ; preds = %94
  br label %96

96:                                               ; preds = %95
  br label %97

97:                                               ; preds = %96
  %98 = load ptr, ptr %10, align 8, !tbaa !5
  %99 = call i32 @mbedtls_mpi_set_bit(ptr noundef %98, i64 noundef 2, i8 noundef zeroext 0)
  store i32 %99, ptr %14, align 4, !tbaa !16
  %100 = icmp ne i32 %99, 0
  br i1 %100, label %101, label %102

101:                                              ; preds = %97
  store i32 6, ptr %17, align 4
  br label %105

102:                                              ; preds = %97
  br label %103

103:                                              ; preds = %102
  br label %104

104:                                              ; preds = %103
  store i32 0, ptr %17, align 4
  br label %105

105:                                              ; preds = %104, %101, %93, %85, %76, %64, %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  %106 = load i32, ptr %17, align 4
  switch i32 %106, label %186 [
    i32 0, label %107
    i32 6, label %173
  ]

107:                                              ; preds = %105
  br label %172

108:                                              ; preds = %6
  %109 = load ptr, ptr %8, align 8, !tbaa !5
  %110 = call i32 @ecp_get_type(ptr noundef %109)
  %111 = icmp eq i32 %110, 1
  br i1 %111, label %112, label %170

112:                                              ; preds = %108
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  store i32 0, ptr %18, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 66, ptr %19) #4
  br label %113

113:                                              ; preds = %164, %112
  br label %114

114:                                              ; preds = %113
  %115 = load ptr, ptr %12, align 8, !tbaa !5
  %116 = load ptr, ptr %13, align 8, !tbaa !5
  %117 = getelementptr inbounds [66 x i8], ptr %19, i64 0, i64 0
  %118 = load i64, ptr %15, align 8, !tbaa !15
  %119 = call i32 %115(ptr noundef %116, ptr noundef %117, i64 noundef %118)
  store i32 %119, ptr %14, align 4, !tbaa !16
  %120 = icmp ne i32 %119, 0
  br i1 %120, label %121, label %122

121:                                              ; preds = %114
  store i32 6, ptr %17, align 4
  br label %167

122:                                              ; preds = %114
  br label %123

123:                                              ; preds = %122
  br label %124

124:                                              ; preds = %123
  br label %125

125:                                              ; preds = %124
  %126 = load ptr, ptr %10, align 8, !tbaa !5
  %127 = getelementptr inbounds [66 x i8], ptr %19, i64 0, i64 0
  %128 = load i64, ptr %15, align 8, !tbaa !15
  %129 = call i32 @mbedtls_mpi_read_binary(ptr noundef %126, ptr noundef %127, i64 noundef %128)
  store i32 %129, ptr %14, align 4, !tbaa !16
  %130 = icmp ne i32 %129, 0
  br i1 %130, label %131, label %132

131:                                              ; preds = %125
  store i32 6, ptr %17, align 4
  br label %167

132:                                              ; preds = %125
  br label %133

133:                                              ; preds = %132
  br label %134

134:                                              ; preds = %133
  br label %135

135:                                              ; preds = %134
  %136 = load ptr, ptr %10, align 8, !tbaa !5
  %137 = load i64, ptr %15, align 8, !tbaa !15
  %138 = mul i64 8, %137
  %139 = load ptr, ptr %8, align 8, !tbaa !5
  %140 = getelementptr inbounds %struct.mbedtls_ecp_group, ptr %139, i32 0, i32 7
  %141 = load i64, ptr %140, align 8, !tbaa !9
  %142 = sub i64 %138, %141
  %143 = call i32 @mbedtls_mpi_shift_r(ptr noundef %136, i64 noundef %142)
  store i32 %143, ptr %14, align 4, !tbaa !16
  %144 = icmp ne i32 %143, 0
  br i1 %144, label %145, label %146

145:                                              ; preds = %135
  store i32 6, ptr %17, align 4
  br label %167

146:                                              ; preds = %135
  br label %147

147:                                              ; preds = %146
  br label %148

148:                                              ; preds = %147
  %149 = load i32, ptr %18, align 4, !tbaa !16
  %150 = add nsw i32 %149, 1
  store i32 %150, ptr %18, align 4, !tbaa !16
  %151 = icmp sgt i32 %150, 30
  br i1 %151, label %152, label %153

152:                                              ; preds = %148
  store i32 -19712, ptr %7, align 4
  store i32 1, ptr %17, align 4
  br label %167

153:                                              ; preds = %148
  br label %154

154:                                              ; preds = %153
  %155 = load ptr, ptr %10, align 8, !tbaa !5
  %156 = call i32 @mbedtls_mpi_cmp_int(ptr noundef %155, i64 noundef 1)
  %157 = icmp slt i32 %156, 0
  br i1 %157, label %164, label %158

158:                                              ; preds = %154
  %159 = load ptr, ptr %10, align 8, !tbaa !5
  %160 = load ptr, ptr %8, align 8, !tbaa !5
  %161 = getelementptr inbounds %struct.mbedtls_ecp_group, ptr %160, i32 0, i32 5
  %162 = call i32 @mbedtls_mpi_cmp_mpi(ptr noundef %159, ptr noundef %161)
  %163 = icmp sge i32 %162, 0
  br label %164

164:                                              ; preds = %158, %154
  %165 = phi i1 [ true, %154 ], [ %163, %158 ]
  br i1 %165, label %113, label %166, !llvm.loop !19

166:                                              ; preds = %164
  store i32 0, ptr %17, align 4
  br label %167

167:                                              ; preds = %166, %152, %145, %131, %121
  call void @llvm.lifetime.end.p0(i64 66, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  %168 = load i32, ptr %17, align 4
  switch i32 %168, label %186 [
    i32 0, label %169
    i32 6, label %173
  ]

169:                                              ; preds = %167
  br label %171

170:                                              ; preds = %108
  store i32 -20352, ptr %7, align 4
  store i32 1, ptr %17, align 4
  br label %186

171:                                              ; preds = %169
  br label %172

172:                                              ; preds = %171, %107
  br label %173

173:                                              ; preds = %172, %167, %105
  %174 = load i32, ptr %14, align 4, !tbaa !16
  %175 = icmp ne i32 %174, 0
  br i1 %175, label %176, label %178

176:                                              ; preds = %173
  %177 = load i32, ptr %14, align 4, !tbaa !16
  store i32 %177, ptr %7, align 4
  store i32 1, ptr %17, align 4
  br label %186

178:                                              ; preds = %173
  %179 = load ptr, ptr %8, align 8, !tbaa !5
  %180 = load ptr, ptr %11, align 8, !tbaa !5
  %181 = load ptr, ptr %10, align 8, !tbaa !5
  %182 = load ptr, ptr %9, align 8, !tbaa !5
  %183 = load ptr, ptr %12, align 8, !tbaa !5
  %184 = load ptr, ptr %13, align 8, !tbaa !5
  %185 = call i32 @mbedtls_ecp_mul(ptr noundef %179, ptr noundef %180, ptr noundef %181, ptr noundef %182, ptr noundef %183, ptr noundef %184)
  store i32 %185, ptr %7, align 4
  store i32 1, ptr %17, align 4
  br label %186

186:                                              ; preds = %178, %176, %170, %167, %105
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  %187 = load i32, ptr %7, align 4
  ret i32 %187
}

declare i32 @mbedtls_mpi_fill_random(ptr noundef, i64 noundef, ptr noundef, ptr noundef) #1

declare i32 @mbedtls_mpi_shift_r(ptr noundef, i64 noundef) #1

declare i32 @mbedtls_mpi_set_bit(ptr noundef, i64 noundef, i8 noundef zeroext) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 #2 = { 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 #3 = { 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 #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, !13, i64 184}
!10 = !{!"", !11, i64 0, !12, i64 8, !12, i64 32, !12, i64 56, !14, i64 80, !12, i64 152, !13, i64 176, !13, i64 184, !11, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !13, i64 240}
!11 = !{!"int", !7, i64 0}
!12 = !{!"", !11, i64 0, !13, i64 8, !6, i64 16}
!13 = !{!"long", !7, i64 0}
!14 = !{!"", !12, i64 0, !12, i64 24, !12, i64 48}
!15 = !{!13, !13, i64 0}
!16 = !{!11, !11, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


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

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

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

declare i32 @mbedtls_mpi_cmp_int(ptr noundef, i64 noundef) local_unnamed_addr #1

declare i32 @mbedtls_mpi_cmp_mpi(ptr noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @mbedtls_ecp_mul(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @ecp_get_type(ptr noundef) local_unnamed_addr #3

declare i64 @mbedtls_mpi_bitlen(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @mbedtls_ecp_gen_keypair_base(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) local_unnamed_addr #2 {
  %7 = alloca [66 x i8], align 16
  %8 = getelementptr inbounds i8, ptr %0, i64 184
  %9 = load i64, ptr %8, align 8, !tbaa !5
  %10 = add i64 %9, 7
  %11 = lshr i64 %10, 3
  %12 = tail call i32 @ecp_get_type(ptr noundef %0)
  %13 = icmp eq i32 %12, 2
  br i1 %13, label %.preheader, label %34

.preheader:                                       ; preds = %6, %15
  %14 = tail call i32 @mbedtls_mpi_fill_random(ptr noundef %2, i64 noundef %11, ptr noundef %4, ptr noundef %5) #4
  %.not63 = icmp eq i32 %14, 0
  br i1 %.not63, label %15, label %.thread74

15:                                               ; preds = %.preheader
  %16 = tail call i64 @mbedtls_mpi_bitlen(ptr noundef %2) #4
  %17 = icmp eq i64 %16, 0
  br i1 %17, label %.preheader, label %18, !llvm.loop !14

18:                                               ; preds = %15
  %19 = tail call i64 @mbedtls_mpi_bitlen(ptr noundef %2) #4
  %20 = add i64 %19, -1
  %21 = load i64, ptr %8, align 8, !tbaa !5
  %22 = icmp ugt i64 %20, %21
  br i1 %22, label %23, label %26

23:                                               ; preds = %18
  %24 = sub i64 %20, %21
  %25 = tail call i32 @mbedtls_mpi_shift_r(ptr noundef %2, i64 noundef %24) #4
  %.not65 = icmp eq i32 %25, 0
  br i1 %.not65, label %28, label %.thread74

26:                                               ; preds = %18
  %27 = tail call i32 @mbedtls_mpi_set_bit(ptr noundef %2, i64 noundef %21, i8 noundef zeroext 1) #4
  %.not64 = icmp eq i32 %27, 0
  br i1 %.not64, label %28, label %.thread74

28:                                               ; preds = %23, %26
  %29 = tail call i32 @mbedtls_mpi_set_bit(ptr noundef %2, i64 noundef 0, i8 noundef zeroext 0) #4
  %.not66 = icmp eq i32 %29, 0
  br i1 %.not66, label %30, label %.thread74

30:                                               ; preds = %28
  %31 = tail call i32 @mbedtls_mpi_set_bit(ptr noundef %2, i64 noundef 1, i8 noundef zeroext 0) #4
  %.not67 = icmp eq i32 %31, 0
  br i1 %.not67, label %32, label %.thread74

32:                                               ; preds = %30
  %33 = tail call i32 @mbedtls_mpi_set_bit(ptr noundef %2, i64 noundef 2, i8 noundef zeroext 0) #4
  %.not68 = icmp eq i32 %33, 0
  br i1 %.not68, label %.thread77, label %.thread74

34:                                               ; preds = %6
  %35 = tail call i32 @ecp_get_type(ptr noundef nonnull %0)
  %36 = icmp eq i32 %35, 1
  br i1 %36, label %37, label %.thread74

37:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 66, ptr nonnull %7) #4
  %38 = call i32 %4(ptr noundef %5, ptr noundef nonnull %7, i64 noundef %11) #4
  %.not85 = icmp eq i32 %38, 0
  br i1 %.not85, label %.lr.ph, label %.thread81

.lr.ph:                                           ; preds = %37
  %39 = and i64 %10, -8
  %40 = getelementptr inbounds i8, ptr %0, i64 152
  br label %41

41:                                               ; preds = %.lr.ph, %.critedge.backedge
  %.086 = phi i32 [ 0, %.lr.ph ], [ %48, %.critedge.backedge ]
  %42 = call i32 @mbedtls_mpi_read_binary(ptr noundef %2, ptr noundef nonnull %7, i64 noundef %11) #4
  %.not61 = icmp eq i32 %42, 0
  br i1 %.not61, label %43, label %.thread81

43:                                               ; preds = %41
  %44 = load i64, ptr %8, align 8, !tbaa !5
  %45 = sub i64 %39, %44
  %46 = call i32 @mbedtls_mpi_shift_r(ptr noundef %2, i64 noundef %45) #4
  %.not62 = icmp eq i32 %46, 0
  br i1 %.not62, label %47, label %.thread81

47:                                               ; preds = %43
  %48 = add nuw nsw i32 %.086, 1
  %exitcond = icmp eq i32 %.086, 30
  br i1 %exitcond, label %56, label %49

49:                                               ; preds = %47
  %50 = call i32 @mbedtls_mpi_cmp_int(ptr noundef %2, i64 noundef 1) #4
  %51 = icmp slt i32 %50, 0
  br i1 %51, label %.critedge.backedge, label %52

52:                                               ; preds = %49
  %53 = call i32 @mbedtls_mpi_cmp_mpi(ptr noundef %2, ptr noundef nonnull %40) #4
  %54 = icmp sgt i32 %53, -1
  br i1 %54, label %.critedge.backedge, label %57

.critedge.backedge:                               ; preds = %52, %49
  %55 = call i32 %4(ptr noundef %5, ptr noundef nonnull %7, i64 noundef %11) #4
  %.not = icmp eq i32 %55, 0
  br i1 %.not, label %41, label %.thread81, !llvm.loop !16

56:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 66, ptr nonnull %7) #4
  br label %.thread74

.thread81:                                        ; preds = %.critedge.backedge, %41, %43, %37
  %.145.ph.ph = phi i32 [ %38, %37 ], [ %46, %43 ], [ %42, %41 ], [ %55, %.critedge.backedge ]
  call void @llvm.lifetime.end.p0(i64 66, ptr nonnull %7) #4
  br label %.thread74

57:                                               ; preds = %52
  call void @llvm.lifetime.end.p0(i64 66, ptr nonnull %7) #4
  br label %.thread77

.thread77:                                        ; preds = %32, %57
  %58 = call i32 @mbedtls_ecp_mul(ptr noundef nonnull %0, ptr noundef %3, ptr noundef %2, ptr noundef %1, ptr noundef %4, ptr noundef %5)
  br label %.thread74

.thread74:                                        ; preds = %.preheader, %32, %30, %28, %26, %23, %.thread81, %56, %34, %.thread77
  %.143 = phi i32 [ %58, %.thread77 ], [ -19712, %56 ], [ -20352, %34 ], [ %.145.ph.ph, %.thread81 ], [ %33, %32 ], [ %31, %30 ], [ %29, %28 ], [ %27, %26 ], [ %25, %23 ], [ %14, %.preheader ]
  ret i32 %.143
}

declare i32 @mbedtls_mpi_fill_random(ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @mbedtls_mpi_shift_r(ptr noundef, i64 noundef) local_unnamed_addr #1

declare i32 @mbedtls_mpi_set_bit(ptr noundef, i64 noundef, i8 noundef zeroext) local_unnamed_addr #1

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 #2 = { 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 #3 = { 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 #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, !11, i64 184}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 32, !10, i64 56, !13, i64 80, !10, i64 152, !11, i64 176, !11, i64 184, !7, i64 192, !12, i64 200, !12, i64 208, !12, i64 216, !12, i64 224, !12, i64 232, !11, i64 240}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"", !7, i64 0, !11, i64 8, !12, i64 16}
!11 = !{!"long", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"", !10, i64 0, !10, i64 24, !10, i64 48}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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