; LLVM IR from specinfo-ua/UAPKI :: library/uapkic/src (math-ecp-internal)

; 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.EcGfpCtx_st = type { ptr, ptr, ptr, i8, i64 }
%struct.EcPrecomp_st = type { i32, %union.anon }
%union.anon = type { ptr }
%struct.EcPrecompComb_st = type { ptr, i32 }
%struct.EcPrecompWin_st = type { ptr, i32, i32 }

@.str = external hidden unnamed_addr constant [27 x i8], align 1

; 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 void @stacktrace_add(ptr noundef, i64 noundef, i32 noundef) #1

declare i64 @int_bit_len(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare hidden void @ecp_double_point(ptr noundef, ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden void @ecp_point_zero(ptr noundef, ptr noundef) #2

declare ptr @ec_point_copy_with_alloc(ptr noundef) #1

declare void @ec_point_free(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @ecp_dual_mul_opt(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #2 {
  %7 = alloca ptr, align 8
  %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 ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca ptr, align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store ptr null, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  store ptr null, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store i32 0, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  store i32 0, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  store ptr null, ptr %19, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %6
  %23 = load ptr, ptr %12, align 8, !tbaa !5
  %24 = call ptr @ec_point_copy_with_alloc(ptr noundef %23)
  store ptr %24, ptr %19, align 8, !tbaa !5
  %25 = icmp eq ptr null, %24
  br i1 %25, label %26, label %28

26:                                               ; preds = %22
  store i32 2, ptr %18, align 4, !tbaa !9
  %27 = load i32, ptr %18, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 685, i32 noundef %27)
  br label %234

28:                                               ; preds = %22
  br label %29

29:                                               ; preds = %28
  br label %30

30:                                               ; preds = %29
  store i32 0, ptr %20, align 4, !tbaa !9
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.EcGfpCtx_st, ptr %31, i32 0, i32 4
  %33 = load i64, ptr %32, align 8, !tbaa !11
  %34 = trunc i64 %33 to i32
  %35 = mul nsw i32 8, %34
  %36 = sext i32 %35 to i64
  %37 = mul i64 %36, 8
  %38 = trunc i64 %37 to i32
  store i32 %38, ptr %21, align 4, !tbaa !9
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = icmp ne ptr %39, null
  br i1 %40, label %41, label %105

41:                                               ; preds = %30
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.EcPrecomp_st, ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 8, !tbaa !15
  %45 = icmp eq i32 %44, 1
  br i1 %45, label %46, label %62

46:                                               ; preds = %41
  %47 = load i32, ptr %21, align 4, !tbaa !9
  %48 = load ptr, ptr %8, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.EcPrecomp_st, ptr %48, i32 0, i32 1
  %50 = load ptr, ptr %49, align 8, !tbaa !17
  %51 = getelementptr inbounds %struct.EcPrecompComb_st, ptr %50, i32 0, i32 1
  %52 = load i32, ptr %51, align 8, !tbaa !18
  %53 = add nsw i32 %47, %52
  %54 = sub nsw i32 %53, 1
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.EcPrecomp_st, ptr %55, i32 0, i32 1
  %57 = load ptr, ptr %56, align 8, !tbaa !17
  %58 = getelementptr inbounds %struct.EcPrecompComb_st, ptr %57, i32 0, i32 1
  %59 = load i32, ptr %58, align 8, !tbaa !18
  %60 = sdiv i32 %54, %59
  %61 = sub nsw i32 %60, 1
  store i32 %61, ptr %20, align 4, !tbaa !9
  br label %104

62:                                               ; preds = %41
  %63 = load ptr, ptr %8, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.EcPrecomp_st, ptr %63, i32 0, i32 0
  %65 = load i32, ptr %64, align 8, !tbaa !15
  %66 = icmp eq i32 %65, 0
  br i1 %66, label %67, label %103

67:                                               ; preds = %62
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = call i64 @int_bit_len(ptr noundef %68)
  %70 = trunc i64 %69 to i32
  store i32 %70, ptr %20, align 4, !tbaa !9
  br label %71

71:                                               ; preds = %67
  %72 = load ptr, ptr %9, align 8, !tbaa !5
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.EcPrecomp_st, ptr %73, i32 0, i32 1
  %75 = load ptr, ptr %74, align 8, !tbaa !17
  %76 = getelementptr inbounds %struct.EcPrecompWin_st, ptr %75, i32 0, i32 2
  %77 = load i32, ptr %76, align 4, !tbaa !20
  %78 = call i32 @int_get_naf(ptr noundef %72, i32 noundef %77, ptr noundef %14)
  store i32 %78, ptr %18, align 4, !tbaa !9
  %79 = load i32, ptr %18, align 4, !tbaa !9
  %80 = icmp ne i32 %79, 0
  br i1 %80, label %81, label %83

81:                                               ; preds = %71
  %82 = load i32, ptr %18, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 698, i32 noundef %82)
  br label %234

83:                                               ; preds = %71
  br label %84

84:                                               ; preds = %83
  br label %85

85:                                               ; preds = %84
  br label %86

86:                                               ; preds = %99, %85
  %87 = load ptr, ptr %14, align 8, !tbaa !5
  %88 = load i32, ptr %20, align 4, !tbaa !9
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds i32, ptr %87, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !9
  %92 = icmp eq i32 %91, 0
  br i1 %92, label %93, label %96

93:                                               ; preds = %86
  %94 = load i32, ptr %20, align 4, !tbaa !9
  %95 = icmp sgt i32 %94, 0
  br label %96

96:                                               ; preds = %93, %86
  %97 = phi i1 [ false, %86 ], [ %95, %93 ]
  br i1 %97, label %98, label %102

98:                                               ; preds = %96
  br label %99

99:                                               ; preds = %98
  %100 = load i32, ptr %20, align 4, !tbaa !9
  %101 = add nsw i32 %100, -1
  store i32 %101, ptr %20, align 4, !tbaa !9
  br label %86, !llvm.loop !22

102:                                              ; preds = %96
  br label %103

103:                                              ; preds = %102, %62
  br label %104

104:                                              ; preds = %103, %46
  br label %105

105:                                              ; preds = %104, %30
  %106 = load ptr, ptr %10, align 8, !tbaa !5
  %107 = icmp ne ptr %106, null
  br i1 %107, label %108, label %172

108:                                              ; preds = %105
  %109 = load ptr, ptr %10, align 8, !tbaa !5
  %110 = getelementptr inbounds %struct.EcPrecomp_st, ptr %109, i32 0, i32 0
  %111 = load i32, ptr %110, align 8, !tbaa !15
  %112 = icmp eq i32 %111, 1
  br i1 %112, label %113, label %129

113:                                              ; preds = %108
  %114 = load i32, ptr %21, align 4, !tbaa !9
  %115 = load ptr, ptr %10, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct.EcPrecomp_st, ptr %115, i32 0, i32 1
  %117 = load ptr, ptr %116, align 8, !tbaa !17
  %118 = getelementptr inbounds %struct.EcPrecompComb_st, ptr %117, i32 0, i32 1
  %119 = load i32, ptr %118, align 8, !tbaa !18
  %120 = add nsw i32 %114, %119
  %121 = sub nsw i32 %120, 1
  %122 = load ptr, ptr %10, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.EcPrecomp_st, ptr %122, i32 0, i32 1
  %124 = load ptr, ptr %123, align 8, !tbaa !17
  %125 = getelementptr inbounds %struct.EcPrecompComb_st, ptr %124, i32 0, i32 1
  %126 = load i32, ptr %125, align 8, !tbaa !18
  %127 = sdiv i32 %121, %126
  %128 = sub nsw i32 %127, 1
  store i32 %128, ptr %16, align 4, !tbaa !9
  br label %171

129:                                              ; preds = %108
  %130 = load ptr, ptr %10, align 8, !tbaa !5
  %131 = getelementptr inbounds %struct.EcPrecomp_st, ptr %130, i32 0, i32 0
  %132 = load i32, ptr %131, align 8, !tbaa !15
  %133 = icmp eq i32 %132, 0
  br i1 %133, label %134, label %170

134:                                              ; preds = %129
  %135 = load ptr, ptr %11, align 8, !tbaa !5
  %136 = call i64 @int_bit_len(ptr noundef %135)
  %137 = trunc i64 %136 to i32
  store i32 %137, ptr %16, align 4, !tbaa !9
  br label %138

138:                                              ; preds = %134
  %139 = load ptr, ptr %11, align 8, !tbaa !5
  %140 = load ptr, ptr %10, align 8, !tbaa !5
  %141 = getelementptr inbounds %struct.EcPrecomp_st, ptr %140, i32 0, i32 1
  %142 = load ptr, ptr %141, align 8, !tbaa !17
  %143 = getelementptr inbounds %struct.EcPrecompWin_st, ptr %142, i32 0, i32 2
  %144 = load i32, ptr %143, align 4, !tbaa !20
  %145 = call i32 @int_get_naf(ptr noundef %139, i32 noundef %144, ptr noundef %13)
  store i32 %145, ptr %18, align 4, !tbaa !9
  %146 = load i32, ptr %18, align 4, !tbaa !9
  %147 = icmp ne i32 %146, 0
  br i1 %147, label %148, label %150

148:                                              ; preds = %138
  %149 = load i32, ptr %18, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 711, i32 noundef %149)
  br label %234

150:                                              ; preds = %138
  br label %151

151:                                              ; preds = %150
  br label %152

152:                                              ; preds = %151
  br label %153

153:                                              ; preds = %166, %152
  %154 = load ptr, ptr %13, align 8, !tbaa !5
  %155 = load i32, ptr %16, align 4, !tbaa !9
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds i32, ptr %154, i64 %156
  %158 = load i32, ptr %157, align 4, !tbaa !9
  %159 = icmp eq i32 %158, 0
  br i1 %159, label %160, label %163

160:                                              ; preds = %153
  %161 = load i32, ptr %16, align 4, !tbaa !9
  %162 = icmp sgt i32 %161, 0
  br label %163

163:                                              ; preds = %160, %153
  %164 = phi i1 [ false, %153 ], [ %162, %160 ]
  br i1 %164, label %165, label %169

165:                                              ; preds = %163
  br label %166

166:                                              ; preds = %165
  %167 = load i32, ptr %16, align 4, !tbaa !9
  %168 = add nsw i32 %167, -1
  store i32 %168, ptr %16, align 4, !tbaa !9
  br label %153, !llvm.loop !24

169:                                              ; preds = %163
  br label %170

170:                                              ; preds = %169, %129
  br label %171

171:                                              ; preds = %170, %113
  br label %172

172:                                              ; preds = %171, %105
  %173 = load i32, ptr %20, align 4, !tbaa !9
  %174 = load i32, ptr %16, align 4, !tbaa !9
  %175 = icmp sgt i32 %173, %174
  br i1 %175, label %176, label %178

176:                                              ; preds = %172
  %177 = load i32, ptr %20, align 4, !tbaa !9
  br label %180

178:                                              ; preds = %172
  %179 = load i32, ptr %16, align 4, !tbaa !9
  br label %180

180:                                              ; preds = %178, %176
  %181 = phi i32 [ %177, %176 ], [ %179, %178 ]
  store i32 %181, ptr %15, align 4, !tbaa !9
  %182 = load ptr, ptr %7, align 8, !tbaa !5
  %183 = load ptr, ptr %12, align 8, !tbaa !5
  call void @ecp_point_zero(ptr noundef %182, ptr noundef %183)
  %184 = load i32, ptr %15, align 4, !tbaa !9
  store i32 %184, ptr %17, align 4, !tbaa !9
  br label %185

185:                                              ; preds = %218, %180
  %186 = load i32, ptr %17, align 4, !tbaa !9
  %187 = icmp sge i32 %186, 0
  br i1 %187, label %188, label %221

188:                                              ; preds = %185
  %189 = load ptr, ptr %7, align 8, !tbaa !5
  %190 = load ptr, ptr %12, align 8, !tbaa !5
  %191 = load ptr, ptr %12, align 8, !tbaa !5
  call void @ecp_double_point(ptr noundef %189, ptr noundef %190, ptr noundef %191)
  %192 = load ptr, ptr %8, align 8, !tbaa !5
  %193 = icmp ne ptr %192, null
  br i1 %193, label %194, label %202

194:                                              ; preds = %188
  %195 = load ptr, ptr %7, align 8, !tbaa !5
  %196 = load ptr, ptr %8, align 8, !tbaa !5
  %197 = load ptr, ptr %9, align 8, !tbaa !5
  %198 = load ptr, ptr %14, align 8, !tbaa !5
  %199 = load ptr, ptr %12, align 8, !tbaa !5
  %200 = load i32, ptr %17, align 4, !tbaa !9
  %201 = load i32, ptr %20, align 4, !tbaa !9
  call void @ecp_dual_mul_opt_step(ptr noundef %195, ptr noundef %196, ptr noundef %197, ptr noundef %198, ptr noundef %199, i32 noundef %200, i32 noundef %201)
  br label %202

202:                                              ; preds = %194, %188
  %203 = load ptr, ptr %11, align 8, !tbaa !5
  %204 = icmp ne ptr %203, null
  br i1 %204, label %205, label %217

205:                                              ; preds = %202
  %206 = load ptr, ptr %10, align 8, !tbaa !5
  %207 = icmp ne ptr %206, null
  br i1 %207, label %208, label %216

208:                                              ; preds = %205
  %209 = load ptr, ptr %7, align 8, !tbaa !5
  %210 = load ptr, ptr %10, align 8, !tbaa !5
  %211 = load ptr, ptr %11, align 8, !tbaa !5
  %212 = load ptr, ptr %13, align 8, !tbaa !5
  %213 = load ptr, ptr %12, align 8, !tbaa !5
  %214 = load i32, ptr %17, align 4, !tbaa !9
  %215 = load i32, ptr %16, align 4, !tbaa !9
  call void @ecp_dual_mul_opt_step(ptr noundef %209, ptr noundef %210, ptr noundef %211, ptr noundef %212, ptr noundef %213, i32 noundef %214, i32 noundef %215)
  br label %216

216:                                              ; preds = %208, %205
  br label %217

217:                                              ; preds = %216, %202
  br label %218

218:                                              ; preds = %217
  %219 = load i32, ptr %17, align 4, !tbaa !9
  %220 = add nsw i32 %219, -1
  store i32 %220, ptr %17, align 4, !tbaa !9
  br label %185, !llvm.loop !25

221:                                              ; preds = %185
  %222 = load ptr, ptr %7, align 8, !tbaa !5
  %223 = load ptr, ptr %8, align 8, !tbaa !5
  %224 = load ptr, ptr %9, align 8, !tbaa !5
  %225 = load ptr, ptr %14, align 8, !tbaa !5
  %226 = load ptr, ptr %19, align 8, !tbaa !5
  call void @ecp_dual_mul_opt_extra_addition(ptr noundef %222, ptr noundef %223, ptr noundef %224, ptr noundef %225, ptr noundef %226)
  %227 = load ptr, ptr %7, align 8, !tbaa !5
  %228 = load ptr, ptr %10, align 8, !tbaa !5
  %229 = load ptr, ptr %11, align 8, !tbaa !5
  %230 = load ptr, ptr %13, align 8, !tbaa !5
  %231 = load ptr, ptr %19, align 8, !tbaa !5
  call void @ecp_dual_mul_opt_extra_addition(ptr noundef %227, ptr noundef %228, ptr noundef %229, ptr noundef %230, ptr noundef %231)
  %232 = load ptr, ptr %7, align 8, !tbaa !5
  %233 = load ptr, ptr %12, align 8, !tbaa !5
  call void @ecp_point_to_affine(ptr noundef %232, ptr noundef %233)
  br label %234

234:                                              ; preds = %221, %148, %81, %26
  %235 = load ptr, ptr %19, align 8, !tbaa !5
  call void @ec_point_free(ptr noundef %235)
  %236 = load ptr, ptr %13, align 8, !tbaa !5
  call void @free(ptr noundef %236) #4
  %237 = load ptr, ptr %14, align 8, !tbaa !5
  call void @free(ptr noundef %237) #4
  %238 = load i32, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  ret i32 %238
}

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

; Function Attrs: nounwind uwtable
declare hidden void @ecp_dual_mul_opt_step(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @ecp_dual_mul_opt_extra_addition(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

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 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !14, i64 32}
!12 = !{!"EcGfpCtx_st", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !14, i64 32}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !10, i64 0}
!16 = !{!"EcPrecomp_st", !10, i64 0, !7, i64 8}
!17 = !{!7, !7, i64 0}
!18 = !{!19, !10, i64 8}
!19 = !{!"EcPrecompComb_st", !6, i64 0, !10, i64 8}
!20 = !{!21, !10, i64 12}
!21 = !{!"EcPrecompWin_st", !6, i64 0, !10, i64 8, !10, i64 12}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}
!25 = distinct !{!25, !23}


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

@.str = external hidden unnamed_addr constant [27 x i8], align 1

; 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 void @stacktrace_add(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

declare i64 @int_bit_len(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden void @ecp_double_point(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare hidden void @ecp_point_zero(ptr noundef, ptr noundef) local_unnamed_addr #2

declare ptr @ec_point_copy_with_alloc(ptr noundef) local_unnamed_addr #1

declare void @ec_point_free(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @ecp_dual_mul_opt(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) local_unnamed_addr #2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #5
  store ptr null, ptr %8, align 8, !tbaa !5
  %9 = tail call ptr @ec_point_copy_with_alloc(ptr noundef %5) #5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %11, label %12

11:                                               ; preds = %6
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 685, i32 noundef 2) #5
  br label %87

12:                                               ; preds = %6
  %13 = getelementptr inbounds i8, ptr %0, i64 32
  %14 = load i64, ptr %13, align 8, !tbaa !9
  %15 = trunc i64 %14 to i32
  %16 = shl i32 %15, 6
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %.loopexit88, label %17

17:                                               ; preds = %12
  %18 = load i32, ptr %1, align 8, !tbaa !13
  switch i32 %18, label %.loopexit88 [
    i32 1, label %19
    i32 0, label %28
  ]

19:                                               ; preds = %17
  %20 = getelementptr inbounds i8, ptr %1, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !16
  %22 = getelementptr inbounds i8, ptr %21, i64 8
  %23 = load i32, ptr %22, align 8, !tbaa !17
  %24 = add i32 %16, -1
  %25 = add i32 %24, %23
  %26 = sdiv i32 %25, %23
  %27 = add nsw i32 %26, -1
  br label %.loopexit88

28:                                               ; preds = %17
  %29 = tail call i64 @int_bit_len(ptr noundef %2) #5
  %30 = getelementptr inbounds i8, ptr %1, i64 8
  %31 = load ptr, ptr %30, align 8, !tbaa !16
  %32 = getelementptr inbounds i8, ptr %31, i64 12
  %33 = load i32, ptr %32, align 4, !tbaa !19
  %34 = call i32 @int_get_naf(ptr noundef %2, i32 noundef %33, ptr noundef nonnull %8) #5
  %.not85 = icmp eq i32 %34, 0
  br i1 %.not85, label %.preheader87, label %37

.preheader87:                                     ; preds = %28
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %sext = shl i64 %29, 32
  %36 = ashr exact i64 %sext, 32
  br label %38

37:                                               ; preds = %28
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 698, i32 noundef %34) #5
  br label %87

38:                                               ; preds = %38, %.preheader87
  %indvars.iv = phi i64 [ %indvars.iv.next, %38 ], [ %36, %.preheader87 ]
  %39 = getelementptr inbounds i32, ptr %35, i64 %indvars.iv
  %40 = load i32, ptr %39, align 4, !tbaa !21
  %41 = icmp eq i32 %40, 0
  %42 = icmp sgt i64 %indvars.iv, 0
  %43 = and i1 %42, %41
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  br i1 %43, label %38, label %.loopexit88.loopexit, !llvm.loop !22

.loopexit88.loopexit:                             ; preds = %38
  %44 = trunc nsw i64 %indvars.iv to i32
  br label %.loopexit88

.loopexit88:                                      ; preds = %.loopexit88.loopexit, %17, %19, %12
  %.171 = phi i32 [ %27, %19 ], [ 0, %12 ], [ 0, %17 ], [ %44, %.loopexit88.loopexit ]
  %45 = icmp ne ptr %3, null
  br i1 %45, label %46, label %.loopexit

46:                                               ; preds = %.loopexit88
  %47 = load i32, ptr %3, align 8, !tbaa !13
  switch i32 %47, label %.loopexit [
    i32 1, label %48
    i32 0, label %57
  ]

48:                                               ; preds = %46
  %49 = getelementptr inbounds i8, ptr %3, i64 8
  %50 = load ptr, ptr %49, align 8, !tbaa !16
  %51 = getelementptr inbounds i8, ptr %50, i64 8
  %52 = load i32, ptr %51, align 8, !tbaa !17
  %53 = add i32 %16, -1
  %54 = add i32 %53, %52
  %55 = sdiv i32 %54, %52
  %56 = add nsw i32 %55, -1
  br label %.loopexit

57:                                               ; preds = %46
  %58 = call i64 @int_bit_len(ptr noundef %4) #5
  %59 = getelementptr inbounds i8, ptr %3, i64 8
  %60 = load ptr, ptr %59, align 8, !tbaa !16
  %61 = getelementptr inbounds i8, ptr %60, i64 12
  %62 = load i32, ptr %61, align 4, !tbaa !19
  %63 = call i32 @int_get_naf(ptr noundef %4, i32 noundef %62, ptr noundef nonnull %7) #5
  %.not86 = icmp eq i32 %63, 0
  br i1 %.not86, label %.preheader, label %66

.preheader:                                       ; preds = %57
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  %sext98 = shl i64 %58, 32
  %65 = ashr exact i64 %sext98, 32
  br label %67

66:                                               ; preds = %57
  call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 711, i32 noundef %63) #5
  br label %87

67:                                               ; preds = %67, %.preheader
  %indvars.iv95 = phi i64 [ %indvars.iv.next96, %67 ], [ %65, %.preheader ]
  %68 = getelementptr inbounds i32, ptr %64, i64 %indvars.iv95
  %69 = load i32, ptr %68, align 4, !tbaa !21
  %70 = icmp eq i32 %69, 0
  %71 = icmp sgt i64 %indvars.iv95, 0
  %72 = and i1 %71, %70
  %indvars.iv.next96 = add nsw i64 %indvars.iv95, -1
  br i1 %72, label %67, label %.loopexit.loopexit, !llvm.loop !24

.loopexit.loopexit:                               ; preds = %67
  %73 = trunc nsw i64 %indvars.iv95 to i32
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %46, %48, %.loopexit88
  %.1 = phi i32 [ %56, %48 ], [ 0, %.loopexit88 ], [ 0, %46 ], [ %73, %.loopexit.loopexit ]
  %74 = call i32 @llvm.smax.i32(i32 %.171, i32 %.1)
  call void @ecp_point_zero(ptr noundef %0, ptr noundef %5)
  %75 = icmp sgt i32 %74, -1
  br i1 %75, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.loopexit
  %76 = icmp ne ptr %4, null
  %or.cond = and i1 %45, %76
  br i1 %.not, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph
  br i1 %or.cond, label %.lr.ph.split.us.split.us, label %.lr.ph.split.us.split

.lr.ph.split.us.split.us:                         ; preds = %.lr.ph.split.us, %.lr.ph.split.us.split.us
  %.07489.us.us = phi i32 [ %78, %.lr.ph.split.us.split.us ], [ %74, %.lr.ph.split.us ]
  call void @ecp_double_point(ptr noundef %0, ptr noundef %5, ptr noundef %5)
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  call void @ecp_dual_mul_opt_step(ptr noundef %0, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef %77, ptr noundef %5, i32 noundef %.07489.us.us, i32 noundef %.1)
  %78 = add nsw i32 %.07489.us.us, -1
  %.not105 = icmp eq i32 %.07489.us.us, 0
  br i1 %.not105, label %._crit_edge, label %.lr.ph.split.us.split.us, !llvm.loop !25

.lr.ph.split.us.split:                            ; preds = %.lr.ph.split.us, %.lr.ph.split.us.split
  %.07489.us = phi i32 [ %79, %.lr.ph.split.us.split ], [ %74, %.lr.ph.split.us ]
  call void @ecp_double_point(ptr noundef %0, ptr noundef %5, ptr noundef %5)
  %79 = add nsw i32 %.07489.us, -1
  %.not104 = icmp eq i32 %.07489.us, 0
  br i1 %.not104, label %._crit_edge, label %.lr.ph.split.us.split, !llvm.loop !25

.lr.ph.split:                                     ; preds = %.lr.ph
  br i1 %or.cond, label %.lr.ph.split.split.us, label %.lr.ph.split.split

.lr.ph.split.split.us:                            ; preds = %.lr.ph.split, %.lr.ph.split.split.us
  %.07489.us90 = phi i32 [ %82, %.lr.ph.split.split.us ], [ %74, %.lr.ph.split ]
  call void @ecp_double_point(ptr noundef %0, ptr noundef %5, ptr noundef %5)
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  call void @ecp_dual_mul_opt_step(ptr noundef %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef %80, ptr noundef %5, i32 noundef %.07489.us90, i32 noundef %.171)
  %81 = load ptr, ptr %7, align 8, !tbaa !5
  call void @ecp_dual_mul_opt_step(ptr noundef %0, ptr noundef nonnull %3, ptr noundef nonnull %4, ptr noundef %81, ptr noundef %5, i32 noundef %.07489.us90, i32 noundef %.1)
  %82 = add nsw i32 %.07489.us90, -1
  %.not103 = icmp eq i32 %.07489.us90, 0
  br i1 %.not103, label %._crit_edge, label %.lr.ph.split.split.us, !llvm.loop !25

.lr.ph.split.split:                               ; preds = %.lr.ph.split, %.lr.ph.split.split
  %.07489 = phi i32 [ %84, %.lr.ph.split.split ], [ %74, %.lr.ph.split ]
  call void @ecp_double_point(ptr noundef %0, ptr noundef %5, ptr noundef %5)
  %83 = load ptr, ptr %8, align 8, !tbaa !5
  call void @ecp_dual_mul_opt_step(ptr noundef %0, ptr noundef nonnull %1, ptr noundef %2, ptr noundef %83, ptr noundef %5, i32 noundef %.07489, i32 noundef %.171)
  %84 = add nsw i32 %.07489, -1
  %.not102 = icmp eq i32 %.07489, 0
  br i1 %.not102, label %._crit_edge, label %.lr.ph.split.split, !llvm.loop !25

._crit_edge:                                      ; preds = %.lr.ph.split.split, %.lr.ph.split.split.us, %.lr.ph.split.us.split, %.lr.ph.split.us.split.us, %.loopexit
  %85 = load ptr, ptr %8, align 8, !tbaa !5
  call void @ecp_dual_mul_opt_extra_addition(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %85, ptr noundef nonnull %9)
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  call void @ecp_dual_mul_opt_extra_addition(ptr noundef %0, ptr noundef %3, ptr noundef %4, ptr noundef %86, ptr noundef nonnull %9)
  call void @ecp_point_to_affine(ptr noundef %0, ptr noundef %5)
  br label %87

87:                                               ; preds = %._crit_edge, %66, %37, %11
  %.2 = phi i32 [ 2, %11 ], [ 0, %._crit_edge ], [ %63, %66 ], [ %34, %37 ]
  call void @ec_point_free(ptr noundef %9) #5
  %88 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %88) #5
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  call void @free(ptr noundef %89) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  ret i32 %.2
}

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

; Function Attrs: nounwind uwtable
declare hidden void @ecp_dual_mul_opt_step(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @ecp_dual_mul_opt_extra_addition(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #4

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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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"}
!9 = !{!10, !12, i64 32}
!10 = !{!"EcGfpCtx_st", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !12, i64 32}
!11 = !{!"_Bool", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"EcPrecomp_st", !15, i64 0, !7, i64 8}
!15 = !{!"int", !7, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !15, i64 8}
!18 = !{!"EcPrecompComb_st", !6, i64 0, !15, i64 8}
!19 = !{!20, !15, i64 12}
!20 = !{!"EcPrecompWin_st", !6, i64 0, !15, i64 8, !15, i64 12}
!21 = !{!15, !15, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}
!25 = distinct !{!25, !23}


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