; LLVM IR from intel/cryptography-primitives :: sources/ippcp/gfpec (pcpgfp_sqrt)

; 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._gsModEngine = type { ptr, i32, i32, i32, i32, i32, ptr, ptr, ptr, i64, ptr, ptr, ptr, ptr, i32, i32, ptr }
%struct._gsModMethod = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local i32 @cpGFpSqrt(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %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 i32, align 4
  %16 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._gsModEngine, ptr %17, i32 0, i32 3
  %19 = load i32, ptr %18, align 8, !tbaa !9
  store i32 %19, ptr %7, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct._gsModEngine, ptr %20, i32 0, i32 5
  %22 = load i32, ptr %21, align 8, !tbaa !14
  store i32 %22, ptr %8, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 1, ptr %9, align 4, !tbaa !13
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = load i32, ptr %7, align 4, !tbaa !13
  %25 = call i32 @cpGFpElementIsEquChunk(ptr noundef %23, i32 noundef %24, i64 noundef 0)
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %31

27:                                               ; preds = %3
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = load i32, ptr %7, align 4, !tbaa !13
  %30 = call ptr @cpGFpElementPad(ptr noundef %28, i32 noundef %29, i64 noundef 0)
  br label %234

31:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = call ptr @gsModPoolAlloc(ptr noundef %32, i32 noundef 4)
  store ptr %33, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = load i32, ptr %8, align 4, !tbaa !13
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds i64, ptr %34, i64 %36
  store ptr %37, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %38 = load ptr, ptr %11, align 8, !tbaa !5
  %39 = load i32, ptr %8, align 4, !tbaa !13
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i64, ptr %38, i64 %40
  store ptr %41, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %42 = load ptr, ptr %12, align 8, !tbaa !5
  %43 = load i32, ptr %8, align 4, !tbaa !13
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i64, ptr %42, i64 %44
  store ptr %45, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %46 = load ptr, ptr %13, align 8, !tbaa !5
  %47 = load i32, ptr %7, align 4, !tbaa !13
  %48 = call ptr @cpGFpElementSetChunk(ptr noundef %46, i32 noundef %47, i64 noundef 1)
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._gsModEngine, ptr %50, i32 0, i32 8
  %52 = load ptr, ptr %51, align 8, !tbaa !15
  %53 = load ptr, ptr %13, align 8, !tbaa !5
  %54 = load i32, ptr %7, align 4, !tbaa !13
  %55 = call i64 @cpSub_BNU(ptr noundef %49, ptr noundef %52, ptr noundef %53, i32 noundef %54)
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = load i32, ptr %7, align 4, !tbaa !13
  %58 = call i32 @factor2(ptr noundef %56, i32 noundef %57)
  store i32 %58, ptr %14, align 4, !tbaa !13
  %59 = load ptr, ptr %12, align 8, !tbaa !5
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._gsModEngine, ptr %60, i32 0, i32 13
  %62 = load ptr, ptr %61, align 8, !tbaa !16
  %63 = load ptr, ptr %10, align 8, !tbaa !5
  %64 = load i32, ptr %7, align 4, !tbaa !13
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = call ptr @cpGFpExp(ptr noundef %59, ptr noundef %62, ptr noundef %63, i32 noundef %64, ptr noundef %65)
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  %69 = load ptr, ptr %13, align 8, !tbaa !5
  %70 = load i32, ptr %7, align 4, !tbaa !13
  %71 = call i64 @cpSub_BNU(ptr noundef %67, ptr noundef %68, ptr noundef %69, i32 noundef %70)
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = load i32, ptr %7, align 4, !tbaa !13
  %75 = call i32 @cpLSR_BNU(ptr noundef %72, ptr noundef %73, i32 noundef %74, i32 noundef 1)
  %76 = load ptr, ptr %11, align 8, !tbaa !5
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = load ptr, ptr %10, align 8, !tbaa !5
  %79 = load i32, ptr %7, align 4, !tbaa !13
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = call ptr @cpGFpExp(ptr noundef %76, ptr noundef %77, ptr noundef %78, i32 noundef %79, ptr noundef %80)
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct._gsModEngine, ptr %82, i32 0, i32 6
  %84 = load ptr, ptr %83, align 8, !tbaa !17
  %85 = getelementptr inbounds %struct._gsModMethod, ptr %84, i32 0, i32 2
  %86 = load ptr, ptr %85, align 8, !tbaa !18
  %87 = load ptr, ptr %13, align 8, !tbaa !5
  %88 = load ptr, ptr %11, align 8, !tbaa !5
  %89 = load ptr, ptr %11, align 8, !tbaa !5
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  %91 = call ptr %86(ptr noundef %87, ptr noundef %88, ptr noundef %89, ptr noundef %90)
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct._gsModEngine, ptr %92, i32 0, i32 6
  %94 = load ptr, ptr %93, align 8, !tbaa !17
  %95 = getelementptr inbounds %struct._gsModMethod, ptr %94, i32 0, i32 2
  %96 = load ptr, ptr %95, align 8, !tbaa !18
  %97 = load ptr, ptr %13, align 8, !tbaa !5
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = load ptr, ptr %13, align 8, !tbaa !5
  %100 = load ptr, ptr %6, align 8, !tbaa !5
  %101 = call ptr %96(ptr noundef %97, ptr noundef %98, ptr noundef %99, ptr noundef %100)
  %102 = load ptr, ptr %6, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct._gsModEngine, ptr %102, i32 0, i32 6
  %104 = load ptr, ptr %103, align 8, !tbaa !17
  %105 = getelementptr inbounds %struct._gsModMethod, ptr %104, i32 0, i32 2
  %106 = load ptr, ptr %105, align 8, !tbaa !18
  %107 = load ptr, ptr %4, align 8, !tbaa !5
  %108 = load ptr, ptr %5, align 8, !tbaa !5
  %109 = load ptr, ptr %11, align 8, !tbaa !5
  %110 = load ptr, ptr %6, align 8, !tbaa !5
  %111 = call ptr %106(ptr noundef %107, ptr noundef %108, ptr noundef %109, ptr noundef %110)
  br label %112

112:                                              ; preds = %203, %31
  %113 = load ptr, ptr %13, align 8, !tbaa !5
  %114 = load i32, ptr %7, align 4, !tbaa !13
  %115 = load ptr, ptr %6, align 8, !tbaa !5
  %116 = getelementptr inbounds %struct._gsModEngine, ptr %115, i32 0, i32 10
  %117 = load ptr, ptr %116, align 8, !tbaa !20
  %118 = load i32, ptr %7, align 4, !tbaa !13
  %119 = call i32 @cpCmp_BNU(ptr noundef %113, i32 noundef %114, ptr noundef %117, i32 noundef %118)
  %120 = icmp eq i32 0, %119
  %121 = xor i1 %120, true
  br i1 %121, label %122, label %204

122:                                              ; preds = %112
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !13
  %123 = load ptr, ptr %10, align 8, !tbaa !5
  %124 = load ptr, ptr %13, align 8, !tbaa !5
  %125 = load i32, ptr %7, align 4, !tbaa !13
  %126 = call ptr @cpGFpElementCopy(ptr noundef %123, ptr noundef %124, i32 noundef %125)
  store i32 1, ptr %15, align 4, !tbaa !13
  br label %127

127:                                              ; preds = %152, %122
  %128 = load i32, ptr %15, align 4, !tbaa !13
  %129 = load i32, ptr %14, align 4, !tbaa !13
  %130 = icmp slt i32 %128, %129
  br i1 %130, label %131, label %155

131:                                              ; preds = %127
  %132 = load ptr, ptr %6, align 8, !tbaa !5
  %133 = getelementptr inbounds %struct._gsModEngine, ptr %132, i32 0, i32 6
  %134 = load ptr, ptr %133, align 8, !tbaa !17
  %135 = getelementptr inbounds %struct._gsModMethod, ptr %134, i32 0, i32 2
  %136 = load ptr, ptr %135, align 8, !tbaa !18
  %137 = load ptr, ptr %10, align 8, !tbaa !5
  %138 = load ptr, ptr %10, align 8, !tbaa !5
  %139 = load ptr, ptr %10, align 8, !tbaa !5
  %140 = load ptr, ptr %6, align 8, !tbaa !5
  %141 = call ptr %136(ptr noundef %137, ptr noundef %138, ptr noundef %139, ptr noundef %140)
  %142 = load ptr, ptr %10, align 8, !tbaa !5
  %143 = load i32, ptr %7, align 4, !tbaa !13
  %144 = load ptr, ptr %6, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct._gsModEngine, ptr %144, i32 0, i32 10
  %146 = load ptr, ptr %145, align 8, !tbaa !20
  %147 = load i32, ptr %7, align 4, !tbaa !13
  %148 = call i32 @cpCmp_BNU(ptr noundef %142, i32 noundef %143, ptr noundef %146, i32 noundef %147)
  %149 = icmp eq i32 0, %148
  br i1 %149, label %150, label %151

150:                                              ; preds = %131
  br label %155

151:                                              ; preds = %131
  br label %152

152:                                              ; preds = %151
  %153 = load i32, ptr %15, align 4, !tbaa !13
  %154 = add nsw i32 %153, 1
  store i32 %154, ptr %15, align 4, !tbaa !13
  br label %127, !llvm.loop !21

155:                                              ; preds = %150, %127
  %156 = load i32, ptr %15, align 4, !tbaa !13
  %157 = load i32, ptr %14, align 4, !tbaa !13
  %158 = icmp eq i32 %156, %157
  br i1 %158, label %159, label %160

159:                                              ; preds = %155
  store i32 0, ptr %9, align 4, !tbaa !13
  store i32 3, ptr %16, align 4
  br label %201

160:                                              ; preds = %155
  %161 = load ptr, ptr %10, align 8, !tbaa !5
  %162 = load ptr, ptr %12, align 8, !tbaa !5
  %163 = load i32, ptr %14, align 4, !tbaa !13
  %164 = load i32, ptr %15, align 4, !tbaa !13
  %165 = sub nsw i32 %163, %164
  %166 = sub nsw i32 %165, 1
  %167 = load ptr, ptr %6, align 8, !tbaa !5
  %168 = call ptr @cpGFpExp2(ptr noundef %161, ptr noundef %162, i32 noundef %166, ptr noundef %167)
  %169 = load ptr, ptr %6, align 8, !tbaa !5
  %170 = getelementptr inbounds %struct._gsModEngine, ptr %169, i32 0, i32 6
  %171 = load ptr, ptr %170, align 8, !tbaa !17
  %172 = getelementptr inbounds %struct._gsModMethod, ptr %171, i32 0, i32 2
  %173 = load ptr, ptr %172, align 8, !tbaa !18
  %174 = load ptr, ptr %12, align 8, !tbaa !5
  %175 = load ptr, ptr %10, align 8, !tbaa !5
  %176 = load ptr, ptr %10, align 8, !tbaa !5
  %177 = load ptr, ptr %6, align 8, !tbaa !5
  %178 = call ptr %173(ptr noundef %174, ptr noundef %175, ptr noundef %176, ptr noundef %177)
  %179 = load ptr, ptr %6, align 8, !tbaa !5
  %180 = getelementptr inbounds %struct._gsModEngine, ptr %179, i32 0, i32 6
  %181 = load ptr, ptr %180, align 8, !tbaa !17
  %182 = getelementptr inbounds %struct._gsModMethod, ptr %181, i32 0, i32 2
  %183 = load ptr, ptr %182, align 8, !tbaa !18
  %184 = load ptr, ptr %4, align 8, !tbaa !5
  %185 = load ptr, ptr %10, align 8, !tbaa !5
  %186 = load ptr, ptr %4, align 8, !tbaa !5
  %187 = load ptr, ptr %6, align 8, !tbaa !5
  %188 = call ptr %183(ptr noundef %184, ptr noundef %185, ptr noundef %186, ptr noundef %187)
  %189 = load ptr, ptr %6, align 8, !tbaa !5
  %190 = getelementptr inbounds %struct._gsModEngine, ptr %189, i32 0, i32 6
  %191 = load ptr, ptr %190, align 8, !tbaa !17
  %192 = getelementptr inbounds %struct._gsModMethod, ptr %191, i32 0, i32 2
  %193 = load ptr, ptr %192, align 8, !tbaa !18
  %194 = load ptr, ptr %13, align 8, !tbaa !5
  %195 = load ptr, ptr %12, align 8, !tbaa !5
  %196 = load ptr, ptr %13, align 8, !tbaa !5
  %197 = load ptr, ptr %6, align 8, !tbaa !5
  %198 = call ptr %193(ptr noundef %194, ptr noundef %195, ptr noundef %196, ptr noundef %197)
  %199 = load i32, ptr %15, align 4, !tbaa !13
  store i32 %199, ptr %14, align 4, !tbaa !13
  br label %200

200:                                              ; preds = %160
  store i32 0, ptr %16, align 4
  br label %201

201:                                              ; preds = %200, %159
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  %202 = load i32, ptr %16, align 4
  switch i32 %202, label %236 [
    i32 0, label %203
    i32 3, label %204
  ]

203:                                              ; preds = %201
  br label %112, !llvm.loop !23

204:                                              ; preds = %201, %112
  %205 = load ptr, ptr %6, align 8, !tbaa !5
  %206 = getelementptr inbounds %struct._gsModEngine, ptr %205, i32 0, i32 6
  %207 = load ptr, ptr %206, align 8, !tbaa !17
  %208 = getelementptr inbounds %struct._gsModMethod, ptr %207, i32 0, i32 1
  %209 = load ptr, ptr %208, align 8, !tbaa !24
  %210 = load ptr, ptr %10, align 8, !tbaa !5
  %211 = load ptr, ptr %4, align 8, !tbaa !5
  %212 = load ptr, ptr %6, align 8, !tbaa !5
  %213 = call ptr %209(ptr noundef %210, ptr noundef %211, ptr noundef %212)
  %214 = load ptr, ptr %10, align 8, !tbaa !5
  %215 = load i32, ptr %7, align 4, !tbaa !13
  %216 = load ptr, ptr %6, align 8, !tbaa !5
  %217 = getelementptr inbounds %struct._gsModEngine, ptr %216, i32 0, i32 12
  %218 = load ptr, ptr %217, align 8, !tbaa !25
  %219 = load i32, ptr %7, align 4, !tbaa !13
  %220 = call i32 @cpCmp_BNU(ptr noundef %214, i32 noundef %215, ptr noundef %218, i32 noundef %219)
  %221 = icmp eq i32 1, %220
  br i1 %221, label %222, label %232

222:                                              ; preds = %204
  %223 = load ptr, ptr %6, align 8, !tbaa !5
  %224 = getelementptr inbounds %struct._gsModEngine, ptr %223, i32 0, i32 6
  %225 = load ptr, ptr %224, align 8, !tbaa !17
  %226 = getelementptr inbounds %struct._gsModMethod, ptr %225, i32 0, i32 7
  %227 = load ptr, ptr %226, align 8, !tbaa !26
  %228 = load ptr, ptr %4, align 8, !tbaa !5
  %229 = load ptr, ptr %4, align 8, !tbaa !5
  %230 = load ptr, ptr %6, align 8, !tbaa !5
  %231 = call ptr %227(ptr noundef %228, ptr noundef %229, ptr noundef %230)
  br label %232

232:                                              ; preds = %222, %204
  %233 = load ptr, ptr %6, align 8, !tbaa !5
  call void @gsModPoolFree(ptr noundef %233, i32 noundef 4)
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %234

234:                                              ; preds = %232, %27
  %235 = load i32, ptr %9, align 4, !tbaa !13
  store i32 1, ptr %16, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret i32 %235

236:                                              ; preds = %201
  unreachable
}

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @cpGFpElementIsEquChunk(ptr noundef, i32 noundef, i64 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @cpGFpElementPad(ptr noundef, i32 noundef, i64 noundef) #2

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @cpGFpElementSetChunk(ptr noundef, i32 noundef, i64 noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden i32 @factor2(ptr noundef, i32 noundef) #0

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

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

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

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

; Function Attrs: nounwind uwtable
declare hidden ptr @cpGFpExp2(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

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

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

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 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 16}
!10 = !{!"_gsModEngine", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !12, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !11, i64 96, !11, i64 100, !6, i64 104}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 24}
!15 = !{!10, !6, i64 48}
!16 = !{!10, !6, i64 88}
!17 = !{!10, !6, i64 32}
!18 = !{!19, !6, i64 16}
!19 = !{!"_gsModMethod", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80}
!20 = !{!10, !6, i64 64}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}
!24 = !{!19, !6, i64 8}
!25 = !{!10, !6, i64 80}
!26 = !{!19, !6, i64 56}


; 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: nounwind uwtable
define dso_local range(i32 0, 2) i32 @cpGFpSqrt(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %2, i64 16
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %2, i64 24
  %7 = load i32, ptr %6, align 8, !tbaa !12
  %8 = tail call i32 @cpGFpElementIsEquChunk(ptr noundef %1, i32 noundef %5, i64 noundef 0)
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %11, label %9

9:                                                ; preds = %3
  %10 = tail call ptr @cpGFpElementPad(ptr noundef %0, i32 noundef %5, i64 noundef 0)
  br label %88

11:                                               ; preds = %3
  %12 = tail call ptr @gsModPoolAlloc(ptr noundef nonnull %2, i32 noundef 4)
  %13 = sext i32 %7 to i64
  %14 = getelementptr inbounds i64, ptr %12, i64 %13
  %15 = getelementptr inbounds i64, ptr %14, i64 %13
  %16 = getelementptr inbounds i64, ptr %15, i64 %13
  %17 = tail call ptr @cpGFpElementSetChunk(ptr noundef %16, i32 noundef %5, i64 noundef 1)
  %18 = getelementptr inbounds i8, ptr %2, i64 48
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  %20 = tail call i64 @cpSub_BNU(ptr noundef %12, ptr noundef %19, ptr noundef %16, i32 noundef %5) #3
  %21 = tail call i32 @factor2(ptr noundef %12, i32 noundef %5)
  %22 = getelementptr inbounds i8, ptr %2, i64 88
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = tail call ptr @cpGFpExp(ptr noundef %15, ptr noundef %23, ptr noundef %12, i32 noundef %5, ptr noundef nonnull %2) #3
  %25 = tail call i64 @cpSub_BNU(ptr noundef %12, ptr noundef %12, ptr noundef %16, i32 noundef %5) #3
  %26 = tail call i32 @cpLSR_BNU(ptr noundef %12, ptr noundef %12, i32 noundef %5, i32 noundef 1) #3
  %27 = tail call ptr @cpGFpExp(ptr noundef %14, ptr noundef %1, ptr noundef %12, i32 noundef %5, ptr noundef nonnull %2) #3
  %28 = getelementptr inbounds i8, ptr %2, i64 32
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  %30 = getelementptr inbounds i8, ptr %29, i64 16
  %31 = load ptr, ptr %30, align 8, !tbaa !16
  %32 = tail call ptr %31(ptr noundef %16, ptr noundef %14, ptr noundef %14, ptr noundef nonnull %2) #3
  %33 = load ptr, ptr %28, align 8, !tbaa !15
  %34 = getelementptr inbounds i8, ptr %33, i64 16
  %35 = load ptr, ptr %34, align 8, !tbaa !16
  %36 = tail call ptr %35(ptr noundef %16, ptr noundef %1, ptr noundef %16, ptr noundef nonnull %2) #3
  %37 = load ptr, ptr %28, align 8, !tbaa !15
  %38 = getelementptr inbounds i8, ptr %37, i64 16
  %39 = load ptr, ptr %38, align 8, !tbaa !16
  %40 = tail call ptr %39(ptr noundef %0, ptr noundef %1, ptr noundef %14, ptr noundef nonnull %2) #3
  %41 = getelementptr inbounds i8, ptr %2, i64 64
  %42 = load ptr, ptr %41, align 8, !tbaa !18
  %43 = tail call i32 @cpCmp_BNU(ptr noundef %16, i32 noundef %5, ptr noundef %42, i32 noundef %5)
  %.not113121 = icmp eq i32 %43, 0
  br i1 %.not113121, label %.thread, label %.lr.ph124

.lr.ph124:                                        ; preds = %11, %56
  %.0110122 = phi i32 [ %.0109.lcssa, %56 ], [ %21, %11 ]
  %44 = tail call ptr @cpGFpElementCopy(ptr noundef %12, ptr noundef %16, i32 noundef %5)
  %45 = icmp sgt i32 %.0110122, 1
  br i1 %45, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph124, %53
  %.0109118 = phi i32 [ %54, %53 ], [ 1, %.lr.ph124 ]
  %46 = load ptr, ptr %28, align 8, !tbaa !15
  %47 = getelementptr inbounds i8, ptr %46, i64 16
  %48 = load ptr, ptr %47, align 8, !tbaa !16
  %49 = tail call ptr %48(ptr noundef %12, ptr noundef %12, ptr noundef %12, ptr noundef nonnull %2) #3
  %50 = load ptr, ptr %41, align 8, !tbaa !18
  %51 = tail call i32 @cpCmp_BNU(ptr noundef %12, i32 noundef %5, ptr noundef %50, i32 noundef %5)
  %52 = icmp eq i32 %51, 0
  br i1 %52, label %._crit_edge, label %53

53:                                               ; preds = %.lr.ph
  %54 = add nuw nsw i32 %.0109118, 1
  %exitcond.not = icmp eq i32 %54, %.0110122
  br i1 %exitcond.not, label %.thread, label %.lr.ph, !llvm.loop !19

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph124
  %.0109.lcssa = phi i32 [ 1, %.lr.ph124 ], [ %.0109118, %.lr.ph ]
  %55 = icmp eq i32 %.0109.lcssa, %.0110122
  br i1 %55, label %.thread, label %56

56:                                               ; preds = %._crit_edge
  %57 = xor i32 %.0109.lcssa, -1
  %58 = add i32 %.0110122, %57
  %59 = tail call ptr @cpGFpExp2(ptr noundef %12, ptr noundef %15, i32 noundef %58, ptr noundef %2)
  %60 = load ptr, ptr %28, align 8, !tbaa !15
  %61 = getelementptr inbounds i8, ptr %60, i64 16
  %62 = load ptr, ptr %61, align 8, !tbaa !16
  %63 = tail call ptr %62(ptr noundef %15, ptr noundef %12, ptr noundef %12, ptr noundef %2) #3
  %64 = load ptr, ptr %28, align 8, !tbaa !15
  %65 = getelementptr inbounds i8, ptr %64, i64 16
  %66 = load ptr, ptr %65, align 8, !tbaa !16
  %67 = tail call ptr %66(ptr noundef %0, ptr noundef %12, ptr noundef %0, ptr noundef %2) #3
  %68 = load ptr, ptr %28, align 8, !tbaa !15
  %69 = getelementptr inbounds i8, ptr %68, i64 16
  %70 = load ptr, ptr %69, align 8, !tbaa !16
  %71 = tail call ptr %70(ptr noundef %16, ptr noundef %15, ptr noundef %16, ptr noundef %2) #3
  %72 = load ptr, ptr %41, align 8, !tbaa !18
  %73 = tail call i32 @cpCmp_BNU(ptr noundef %16, i32 noundef %5, ptr noundef %72, i32 noundef %5)
  %.not113 = icmp eq i32 %73, 0
  br i1 %.not113, label %.thread, label %.lr.ph124

.thread:                                          ; preds = %56, %._crit_edge, %53, %11
  %.2 = phi i32 [ 1, %11 ], [ 0, %53 ], [ 0, %._crit_edge ], [ 1, %56 ]
  %74 = load ptr, ptr %28, align 8, !tbaa !15
  %75 = getelementptr inbounds i8, ptr %74, i64 8
  %76 = load ptr, ptr %75, align 8, !tbaa !21
  %77 = tail call ptr %76(ptr noundef %12, ptr noundef %0, ptr noundef %2) #3
  %78 = getelementptr inbounds i8, ptr %2, i64 80
  %79 = load ptr, ptr %78, align 8, !tbaa !22
  %80 = tail call i32 @cpCmp_BNU(ptr noundef %12, i32 noundef %5, ptr noundef %79, i32 noundef %5)
  %81 = icmp eq i32 %80, 1
  br i1 %81, label %82, label %87

82:                                               ; preds = %.thread
  %83 = load ptr, ptr %28, align 8, !tbaa !15
  %84 = getelementptr inbounds i8, ptr %83, i64 56
  %85 = load ptr, ptr %84, align 8, !tbaa !23
  %86 = tail call ptr %85(ptr noundef %0, ptr noundef %0, ptr noundef nonnull %2) #3
  br label %87

87:                                               ; preds = %82, %.thread
  tail call void @gsModPoolFree(ptr noundef nonnull %2, i32 noundef 4)
  br label %88

88:                                               ; preds = %87, %9
  %.3 = phi i32 [ 1, %9 ], [ %.2, %87 ]
  ret i32 %.3
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @cpGFpElementIsEquChunk(ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @cpGFpElementPad(ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @gsModPoolAlloc(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @cpGFpElementSetChunk(ptr noundef, i32 noundef, i64 noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare hidden i32 @factor2(ptr noundef, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @cpCmp_BNU(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @cpGFpElementCopy(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @cpGFpExp2(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @gsModPoolFree(ptr noundef, i32 noundef) local_unnamed_addr #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 = { 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 #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 }

!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, !10, i64 16}
!6 = !{!"_gsModEngine", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !11, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !10, i64 96, !10, i64 100, !7, i64 104}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long long", !8, i64 0}
!12 = !{!6, !10, i64 24}
!13 = !{!6, !7, i64 48}
!14 = !{!6, !7, i64 88}
!15 = !{!6, !7, i64 32}
!16 = !{!17, !7, i64 16}
!17 = !{!"_gsModMethod", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80}
!18 = !{!6, !7, i64 64}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!17, !7, i64 8}
!22 = !{!6, !7, i64 80}
!23 = !{!17, !7, i64 56}


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