; LLVM IR from specinfo-ua/UAPKI :: library/uapkic/src (ecgdsa)

; 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.EcCtx_st = type { ptr, ptr, ptr, ptr, i8, i8 }
%struct.EcParamsCtx_st = type { i32, ptr, ptr, ptr, ptr, i8, i64, ptr, ptr, i32, ptr }
%struct.ByteArray_st = type { ptr, i64 }
%struct.WordArray_st = type { ptr, i64 }
%struct.EcGfpCtx_st = type { ptr, ptr, ptr, i8, i64 }
%struct.GfpCtx_st = type { ptr, ptr, ptr, ptr }
%struct.ECPoint_st = type { ptr, ptr, ptr }

@.str = external hidden unnamed_addr constant [16 x i8], align 1
@default_opt_level = external global i32, align 4

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

17:                                               ; preds = %4
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = icmp ne ptr %18, null
  br i1 %19, label %22, label %20

20:                                               ; preds = %17
  store i32 2, ptr %14, align 4, !tbaa !9
  %21 = load i32, ptr %14, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 51, i32 noundef %21, ptr noundef null)
  br label %261

22:                                               ; preds = %17
  br label %23

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23
  br label %25

25:                                               ; preds = %24
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.EcCtx_st, ptr %26, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !11
  %29 = getelementptr inbounds %struct.EcParamsCtx_st, ptr %28, i32 0, i32 0
  %30 = load i32, ptr %29, align 8, !tbaa !14
  %31 = icmp eq i32 %30, 0
  br i1 %31, label %34, label %32

32:                                               ; preds = %25
  store i32 2, ptr %14, align 4, !tbaa !9
  %33 = load i32, ptr %14, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 52, i32 noundef %33, ptr noundef null)
  br label %261

34:                                               ; preds = %25
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  br label %37

37:                                               ; preds = %36
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %42, label %40

40:                                               ; preds = %37
  store i32 2, ptr %14, align 4, !tbaa !9
  %41 = load i32, ptr %14, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 53, i32 noundef %41, ptr noundef null)
  br label %261

42:                                               ; preds = %37
  br label %43

43:                                               ; preds = %42
  br label %44

44:                                               ; preds = %43
  br label %45

45:                                               ; preds = %44
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = icmp ne ptr %46, null
  br i1 %47, label %50, label %48

48:                                               ; preds = %45
  store i32 2, ptr %14, align 4, !tbaa !9
  %49 = load i32, ptr %14, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 54, i32 noundef %49, ptr noundef null)
  br label %261

50:                                               ; preds = %45
  br label %51

51:                                               ; preds = %50
  br label %52

52:                                               ; preds = %51
  br label %53

53:                                               ; preds = %52
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = icmp ne ptr %54, null
  br i1 %55, label %58, label %56

56:                                               ; preds = %53
  store i32 2, ptr %14, align 4, !tbaa !9
  %57 = load i32, ptr %14, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 55, i32 noundef %57, ptr noundef null)
  br label %261

58:                                               ; preds = %53
  br label %59

59:                                               ; preds = %58
  br label %60

60:                                               ; preds = %59
  br label %61

61:                                               ; preds = %60
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.ByteArray_st, ptr %62, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8, !tbaa !17
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.ByteArray_st, ptr %65, i32 0, i32 1
  %67 = load i64, ptr %66, align 8, !tbaa !19
  %68 = call ptr @wa_alloc_from_be(ptr noundef %64, i64 noundef %67)
  store ptr %68, ptr %11, align 8, !tbaa !5
  %69 = icmp eq ptr null, %68
  br i1 %69, label %70, label %72

70:                                               ; preds = %61
  store i32 2, ptr %14, align 4, !tbaa !9
  %71 = load i32, ptr %14, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 57, i32 noundef %71)
  br label %261

72:                                               ; preds = %61
  br label %73

73:                                               ; preds = %72
  br label %74

74:                                               ; preds = %73
  %75 = load ptr, ptr %11, align 8, !tbaa !5
  %76 = call zeroext i1 @int_is_zero(ptr noundef %75)
  br i1 %76, label %86, label %77

77:                                               ; preds = %74
  %78 = load ptr, ptr %11, align 8, !tbaa !5
  %79 = load ptr, ptr %6, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.EcCtx_st, ptr %79, i32 0, i32 0
  %81 = load ptr, ptr %80, align 8, !tbaa !11
  %82 = getelementptr inbounds %struct.EcParamsCtx_st, ptr %81, i32 0, i32 2
  %83 = load ptr, ptr %82, align 8, !tbaa !20
  %84 = call i32 @int_cmp(ptr noundef %78, ptr noundef %83)
  %85 = icmp sge i32 %84, 0
  br i1 %85, label %86, label %91

86:                                               ; preds = %77, %74
  br label %87

87:                                               ; preds = %86
  store i32 6, ptr %14, align 4, !tbaa !9
  %88 = load i32, ptr %14, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 59, i32 noundef %88, ptr noundef null)
  br label %261

89:                                               ; No predecessors!
  br label %90

90:                                               ; preds = %89
  br label %91

91:                                               ; preds = %90, %77
  %92 = load ptr, ptr %11, align 8, !tbaa !5
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.EcCtx_st, ptr %93, i32 0, i32 0
  %95 = load ptr, ptr %94, align 8, !tbaa !11
  %96 = getelementptr inbounds %struct.EcParamsCtx_st, ptr %95, i32 0, i32 2
  %97 = load ptr, ptr %96, align 8, !tbaa !20
  %98 = getelementptr inbounds %struct.WordArray_st, ptr %97, i32 0, i32 1
  %99 = load i64, ptr %98, align 8, !tbaa !21
  call void @wa_change_len(ptr noundef %92, i64 noundef %99)
  br label %100

100:                                              ; preds = %91
  %101 = load ptr, ptr %11, align 8, !tbaa !5
  %102 = load ptr, ptr %6, align 8, !tbaa !5
  %103 = getelementptr inbounds %struct.EcCtx_st, ptr %102, i32 0, i32 0
  %104 = load ptr, ptr %103, align 8, !tbaa !11
  %105 = getelementptr inbounds %struct.EcParamsCtx_st, ptr %104, i32 0, i32 2
  %106 = load ptr, ptr %105, align 8, !tbaa !20
  %107 = call ptr @gfp_mod_inv_core(ptr noundef %101, ptr noundef %106)
  store ptr %107, ptr %12, align 8, !tbaa !5
  %108 = icmp eq ptr null, %107
  br i1 %108, label %109, label %111

109:                                              ; preds = %100
  store i32 2, ptr %14, align 4, !tbaa !9
  %110 = load i32, ptr %14, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 63, i32 noundef %110)
  br label %261

111:                                              ; preds = %100
  br label %112

112:                                              ; preds = %111
  br label %113

113:                                              ; preds = %112
  %114 = load ptr, ptr %6, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.EcCtx_st, ptr %114, i32 0, i32 0
  %116 = load ptr, ptr %115, align 8, !tbaa !11
  %117 = getelementptr inbounds %struct.EcParamsCtx_st, ptr %116, i32 0, i32 10
  %118 = load ptr, ptr %117, align 8, !tbaa !23
  %119 = icmp eq ptr %118, null
  br i1 %119, label %120, label %142

120:                                              ; preds = %113
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %121 = load i32, ptr @default_opt_level, align 4, !tbaa !9
  %122 = lshr i32 %121, 8
  %123 = and i32 %122, 15
  store i32 %123, ptr %15, align 4, !tbaa !9
  %124 = load i32, ptr %15, align 4, !tbaa !9
  %125 = icmp eq i32 %124, 0
  br i1 %125, label %126, label %127

126:                                              ; preds = %120
  store i32 5, ptr %15, align 4, !tbaa !9
  br label %127

127:                                              ; preds = %126, %120
  br label %128

128:                                              ; preds = %127
  %129 = load ptr, ptr %6, align 8, !tbaa !5
  %130 = load i32, ptr %15, align 4, !tbaa !9
  %131 = call i32 @ec_set_sign_precomp(ptr noundef %129, i32 noundef 0, i32 noundef %130)
  store i32 %131, ptr %14, align 4, !tbaa !9
  %132 = load i32, ptr %14, align 4, !tbaa !9
  %133 = icmp ne i32 %132, 0
  br i1 %133, label %134, label %136

134:                                              ; preds = %128
  %135 = load i32, ptr %14, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 70, i32 noundef %135)
  store i32 4, ptr %16, align 4
  br label %139

136:                                              ; preds = %128
  br label %137

137:                                              ; preds = %136
  br label %138

138:                                              ; preds = %137
  store i32 0, ptr %16, align 4
  br label %139

139:                                              ; preds = %138, %134
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  %140 = load i32, ptr %16, align 4
  switch i32 %140, label %266 [
    i32 0, label %141
    i32 4, label %261
  ]

141:                                              ; preds = %139
  br label %142

142:                                              ; preds = %141, %113
  br label %143

143:                                              ; preds = %142
  %144 = load ptr, ptr %6, align 8, !tbaa !5
  %145 = getelementptr inbounds %struct.EcCtx_st, ptr %144, i32 0, i32 0
  %146 = load ptr, ptr %145, align 8, !tbaa !11
  %147 = getelementptr inbounds %struct.EcParamsCtx_st, ptr %146, i32 0, i32 3
  %148 = load ptr, ptr %147, align 8, !tbaa !24
  %149 = getelementptr inbounds %struct.EcGfpCtx_st, ptr %148, i32 0, i32 4
  %150 = load i64, ptr %149, align 8, !tbaa !25
  %151 = call ptr @ec_point_alloc(i64 noundef %150)
  store ptr %151, ptr %13, align 8, !tbaa !5
  %152 = icmp eq ptr null, %151
  br i1 %152, label %153, label %155

153:                                              ; preds = %143
  store i32 2, ptr %14, align 4, !tbaa !9
  %154 = load i32, ptr %14, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 73, i32 noundef %154)
  br label %261

155:                                              ; preds = %143
  br label %156

156:                                              ; preds = %155
  br label %157

157:                                              ; preds = %156
  %158 = load ptr, ptr %6, align 8, !tbaa !5
  %159 = getelementptr inbounds %struct.EcCtx_st, ptr %158, i32 0, i32 0
  %160 = load ptr, ptr %159, align 8, !tbaa !11
  %161 = getelementptr inbounds %struct.EcParamsCtx_st, ptr %160, i32 0, i32 3
  %162 = load ptr, ptr %161, align 8, !tbaa !24
  %163 = getelementptr inbounds %struct.EcGfpCtx_st, ptr %162, i32 0, i32 0
  %164 = load ptr, ptr %163, align 8, !tbaa !27
  %165 = getelementptr inbounds %struct.GfpCtx_st, ptr %164, i32 0, i32 0
  %166 = load ptr, ptr %165, align 8, !tbaa !28
  %167 = call i64 @int_bit_len(ptr noundef %166)
  %168 = add i64 %167, 7
  %169 = udiv i64 %168, 8
  store i64 %169, ptr %10, align 8, !tbaa !30
  br label %170

170:                                              ; preds = %157
  %171 = load ptr, ptr %6, align 8, !tbaa !5
  %172 = getelementptr inbounds %struct.EcCtx_st, ptr %171, i32 0, i32 0
  %173 = load ptr, ptr %172, align 8, !tbaa !11
  %174 = getelementptr inbounds %struct.EcParamsCtx_st, ptr %173, i32 0, i32 3
  %175 = load ptr, ptr %174, align 8, !tbaa !24
  %176 = load ptr, ptr %6, align 8, !tbaa !5
  %177 = getelementptr inbounds %struct.EcCtx_st, ptr %176, i32 0, i32 0
  %178 = load ptr, ptr %177, align 8, !tbaa !11
  %179 = getelementptr inbounds %struct.EcParamsCtx_st, ptr %178, i32 0, i32 10
  %180 = load ptr, ptr %179, align 8, !tbaa !23
  %181 = load ptr, ptr %12, align 8, !tbaa !5
  %182 = load ptr, ptr %13, align 8, !tbaa !5
  %183 = call i32 @ecp_dual_mul_opt(ptr noundef %175, ptr noundef %180, ptr noundef %181, ptr noundef null, ptr noundef null, ptr noundef %182)
  store i32 %183, ptr %14, align 4, !tbaa !9
  %184 = load i32, ptr %14, align 4, !tbaa !9
  %185 = icmp ne i32 %184, 0
  br i1 %185, label %186, label %188

186:                                              ; preds = %170
  %187 = load i32, ptr %14, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 75, i32 noundef %187)
  br label %261

188:                                              ; preds = %170
  br label %189

189:                                              ; preds = %188
  br label %190

190:                                              ; preds = %189
  br label %191

191:                                              ; preds = %190
  %192 = load ptr, ptr %13, align 8, !tbaa !5
  %193 = getelementptr inbounds %struct.ECPoint_st, ptr %192, i32 0, i32 0
  %194 = load ptr, ptr %193, align 8, !tbaa !31
  %195 = call ptr @wa_to_ba(ptr noundef %194)
  %196 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %195, ptr %196, align 8, !tbaa !5
  %197 = icmp eq ptr null, %195
  br i1 %197, label %198, label %200

198:                                              ; preds = %191
  store i32 2, ptr %14, align 4, !tbaa !9
  %199 = load i32, ptr %14, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 77, i32 noundef %199)
  br label %261

200:                                              ; preds = %191
  br label %201

201:                                              ; preds = %200
  br label %202

202:                                              ; preds = %201
  br label %203

203:                                              ; preds = %202
  %204 = load ptr, ptr %13, align 8, !tbaa !5
  %205 = getelementptr inbounds %struct.ECPoint_st, ptr %204, i32 0, i32 1
  %206 = load ptr, ptr %205, align 8, !tbaa !33
  %207 = call ptr @wa_to_ba(ptr noundef %206)
  %208 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %207, ptr %208, align 8, !tbaa !5
  %209 = icmp eq ptr null, %207
  br i1 %209, label %210, label %212

210:                                              ; preds = %203
  store i32 2, ptr %14, align 4, !tbaa !9
  %211 = load i32, ptr %14, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 78, i32 noundef %211)
  br label %261

212:                                              ; preds = %203
  br label %213

213:                                              ; preds = %212
  br label %214

214:                                              ; preds = %213
  br label %215

215:                                              ; preds = %214
  %216 = load ptr, ptr %8, align 8, !tbaa !5
  %217 = load ptr, ptr %216, align 8, !tbaa !5
  %218 = load i64, ptr %10, align 8, !tbaa !30
  %219 = call i32 @ba_change_len(ptr noundef %217, i64 noundef %218)
  store i32 %219, ptr %14, align 4, !tbaa !9
  %220 = load i32, ptr %14, align 4, !tbaa !9
  %221 = icmp ne i32 %220, 0
  br i1 %221, label %222, label %224

222:                                              ; preds = %215
  %223 = load i32, ptr %14, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 79, i32 noundef %223)
  br label %261

224:                                              ; preds = %215
  br label %225

225:                                              ; preds = %224
  br label %226

226:                                              ; preds = %225
  br label %227

227:                                              ; preds = %226
  %228 = load ptr, ptr %9, align 8, !tbaa !5
  %229 = load ptr, ptr %228, align 8, !tbaa !5
  %230 = load i64, ptr %10, align 8, !tbaa !30
  %231 = call i32 @ba_change_len(ptr noundef %229, i64 noundef %230)
  store i32 %231, ptr %14, align 4, !tbaa !9
  %232 = load i32, ptr %14, align 4, !tbaa !9
  %233 = icmp ne i32 %232, 0
  br i1 %233, label %234, label %236

234:                                              ; preds = %227
  %235 = load i32, ptr %14, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 80, i32 noundef %235)
  br label %261

236:                                              ; preds = %227
  br label %237

237:                                              ; preds = %236
  br label %238

238:                                              ; preds = %237
  br label %239

239:                                              ; preds = %238
  %240 = load ptr, ptr %8, align 8, !tbaa !5
  %241 = load ptr, ptr %240, align 8, !tbaa !5
  %242 = call i32 @ba_swap(ptr noundef %241)
  store i32 %242, ptr %14, align 4, !tbaa !9
  %243 = load i32, ptr %14, align 4, !tbaa !9
  %244 = icmp ne i32 %243, 0
  br i1 %244, label %245, label %247

245:                                              ; preds = %239
  %246 = load i32, ptr %14, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 81, i32 noundef %246)
  br label %261

247:                                              ; preds = %239
  br label %248

248:                                              ; preds = %247
  br label %249

249:                                              ; preds = %248
  br label %250

250:                                              ; preds = %249
  %251 = load ptr, ptr %9, align 8, !tbaa !5
  %252 = load ptr, ptr %251, align 8, !tbaa !5
  %253 = call i32 @ba_swap(ptr noundef %252)
  store i32 %253, ptr %14, align 4, !tbaa !9
  %254 = load i32, ptr %14, align 4, !tbaa !9
  %255 = icmp ne i32 %254, 0
  br i1 %255, label %256, label %258

256:                                              ; preds = %250
  %257 = load i32, ptr %14, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 82, i32 noundef %257)
  br label %261

258:                                              ; preds = %250
  br label %259

259:                                              ; preds = %258
  br label %260

260:                                              ; preds = %259
  br label %261

261:                                              ; preds = %260, %256, %245, %234, %222, %210, %198, %186, %153, %139, %109, %87, %70, %56, %48, %40, %32, %20
  %262 = load ptr, ptr %13, align 8, !tbaa !5
  call void @ec_point_free(ptr noundef %262)
  %263 = load ptr, ptr %11, align 8, !tbaa !5
  call void @wa_free_private(ptr noundef %263)
  %264 = load ptr, ptr %12, align 8, !tbaa !5
  call void @wa_free_private(ptr noundef %264)
  %265 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %265, ptr %5, align 4
  store i32 1, ptr %16, align 4
  br label %266

266:                                              ; preds = %261, %139
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %267 = load i32, ptr %5, align 4
  ret i32 %267
}

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

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

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

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

declare zeroext i1 @int_is_zero(ptr noundef) #2

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

declare void @wa_change_len(ptr noundef, i64 noundef) #2

declare ptr @gfp_mod_inv_core(ptr noundef, ptr noundef) #2

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

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

declare ptr @ec_point_alloc(i64 noundef) #2

declare i64 @int_bit_len(ptr noundef) #2

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

declare ptr @wa_to_ba(ptr noundef) #2

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

declare i32 @ba_swap(ptr noundef) #2

declare void @ec_point_free(ptr noundef) #2

declare void @wa_free_private(ptr 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 = { "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, !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, !6, i64 0}
!12 = !{!"EcCtx_st", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !13, i64 33}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!15, !10, i64 0}
!15 = !{!"EcParamsCtx_st", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !13, i64 40, !16, i64 48, !6, i64 56, !6, i64 64, !10, i64 72, !6, i64 80}
!16 = !{!"long", !7, i64 0}
!17 = !{!18, !6, i64 0}
!18 = !{!"ByteArray_st", !6, i64 0, !16, i64 8}
!19 = !{!18, !16, i64 8}
!20 = !{!15, !6, i64 16}
!21 = !{!22, !16, i64 8}
!22 = !{!"WordArray_st", !6, i64 0, !16, i64 8}
!23 = !{!15, !6, i64 80}
!24 = !{!15, !6, i64 24}
!25 = !{!26, !16, i64 32}
!26 = !{!"EcGfpCtx_st", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !16, i64 32}
!27 = !{!26, !6, i64 0}
!28 = !{!29, !6, i64 0}
!29 = !{!"GfpCtx_st", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!30 = !{!16, !16, i64 0}
!31 = !{!32, !6, i64 0}
!32 = !{!"ECPoint_st", !6, i64 0, !6, i64 8, !6, i64 16}
!33 = !{!32, !6, i64 8}


; 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 [16 x i8], align 1
@default_opt_level = external local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local i32 @ecgdsa_get_pubkey(ptr noundef %0, ptr noundef readonly %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %5, label %6

5:                                                ; preds = %4
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 51, i32 noundef 2, ptr noundef null) #2
  br label %108

6:                                                ; preds = %4
  %7 = load ptr, ptr %0, align 8, !tbaa !5
  %8 = load i32, ptr %7, align 8, !tbaa !11
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %11, label %10

10:                                               ; preds = %6
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 52, i32 noundef 2, ptr noundef null) #2
  br label %108

11:                                               ; preds = %6
  %.not83 = icmp eq ptr %1, null
  br i1 %.not83, label %12, label %13

12:                                               ; preds = %11
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 53, i32 noundef 2, ptr noundef null) #2
  br label %108

13:                                               ; preds = %11
  %.not84 = icmp eq ptr %2, null
  br i1 %.not84, label %14, label %15

14:                                               ; preds = %13
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 54, i32 noundef 2, ptr noundef null) #2
  br label %108

15:                                               ; preds = %13
  %.not85 = icmp eq ptr %3, null
  br i1 %.not85, label %16, label %17

16:                                               ; preds = %15
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 55, i32 noundef 2, ptr noundef null) #2
  br label %108

17:                                               ; preds = %15
  %18 = load ptr, ptr %1, align 8, !tbaa !15
  %19 = getelementptr inbounds i8, ptr %1, i64 8
  %20 = load i64, ptr %19, align 8, !tbaa !17
  %21 = tail call ptr @wa_alloc_from_be(ptr noundef %18, i64 noundef %20) #2
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %17
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 57, i32 noundef 2) #2
  br label %108

24:                                               ; preds = %17
  %25 = tail call zeroext i1 @int_is_zero(ptr noundef nonnull %21) #2
  br i1 %25, label %32, label %26

26:                                               ; preds = %24
  %27 = load ptr, ptr %0, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 16
  %29 = load ptr, ptr %28, align 8, !tbaa !18
  %30 = tail call i32 @int_cmp(ptr noundef nonnull %21, ptr noundef %29) #2
  %31 = icmp sgt i32 %30, -1
  br i1 %31, label %32, label %33

32:                                               ; preds = %24, %26
  tail call void @stacktrace_create(ptr noundef nonnull @.str, i64 noundef 59, i32 noundef 6, ptr noundef null) #2
  br label %108

33:                                               ; preds = %26
  %34 = load ptr, ptr %0, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %34, i64 16
  %36 = load ptr, ptr %35, align 8, !tbaa !18
  %37 = getelementptr inbounds i8, ptr %36, i64 8
  %38 = load i64, ptr %37, align 8, !tbaa !19
  tail call void @wa_change_len(ptr noundef nonnull %21, i64 noundef %38) #2
  %39 = load ptr, ptr %0, align 8, !tbaa !5
  %40 = getelementptr inbounds i8, ptr %39, i64 16
  %41 = load ptr, ptr %40, align 8, !tbaa !18
  %42 = tail call ptr @gfp_mod_inv_core(ptr noundef nonnull %21, ptr noundef %41) #2
  %43 = icmp eq ptr %42, null
  br i1 %43, label %44, label %45

44:                                               ; preds = %33
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 63, i32 noundef 2) #2
  br label %108

45:                                               ; preds = %33
  %46 = load ptr, ptr %0, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %46, i64 80
  %48 = load ptr, ptr %47, align 8, !tbaa !21
  %49 = icmp eq ptr %48, null
  br i1 %49, label %50, label %.thread

50:                                               ; preds = %45
  %51 = load i32, ptr @default_opt_level, align 4, !tbaa !22
  %52 = lshr i32 %51, 8
  %53 = and i32 %52, 15
  %54 = icmp eq i32 %53, 0
  %spec.store.select = select i1 %54, i32 5, i32 %53
  %55 = tail call i32 @ec_set_sign_precomp(ptr noundef nonnull %0, i32 noundef 0, i32 noundef %spec.store.select) #2
  %.not86 = icmp eq i32 %55, 0
  br i1 %.not86, label %..thread_crit_edge, label %56

..thread_crit_edge:                               ; preds = %50
  %.pre = load ptr, ptr %0, align 8, !tbaa !5
  br label %.thread

56:                                               ; preds = %50
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 70, i32 noundef %55) #2
  br label %108

.thread:                                          ; preds = %..thread_crit_edge, %45
  %57 = phi ptr [ %.pre, %..thread_crit_edge ], [ %46, %45 ]
  %58 = getelementptr inbounds i8, ptr %57, i64 24
  %59 = load ptr, ptr %58, align 8, !tbaa !23
  %60 = getelementptr inbounds i8, ptr %59, i64 32
  %61 = load i64, ptr %60, align 8, !tbaa !24
  %62 = tail call ptr @ec_point_alloc(i64 noundef %61) #2
  %63 = icmp eq ptr %62, null
  br i1 %63, label %64, label %65

64:                                               ; preds = %.thread
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 73, i32 noundef 2) #2
  br label %108

65:                                               ; preds = %.thread
  %66 = load ptr, ptr %0, align 8, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %66, i64 24
  %68 = load ptr, ptr %67, align 8, !tbaa !23
  %69 = load ptr, ptr %68, align 8, !tbaa !26
  %70 = load ptr, ptr %69, align 8, !tbaa !27
  %71 = tail call i64 @int_bit_len(ptr noundef %70) #2
  %72 = add i64 %71, 7
  %73 = lshr i64 %72, 3
  %74 = load ptr, ptr %0, align 8, !tbaa !5
  %75 = getelementptr inbounds i8, ptr %74, i64 24
  %76 = load ptr, ptr %75, align 8, !tbaa !23
  %77 = getelementptr inbounds i8, ptr %74, i64 80
  %78 = load ptr, ptr %77, align 8, !tbaa !21
  %79 = tail call i32 @ecp_dual_mul_opt(ptr noundef %76, ptr noundef %78, ptr noundef nonnull %42, ptr noundef null, ptr noundef null, ptr noundef nonnull %62) #2
  %.not87 = icmp eq i32 %79, 0
  br i1 %.not87, label %81, label %80

80:                                               ; preds = %65
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 75, i32 noundef %79) #2
  br label %108

81:                                               ; preds = %65
  %82 = load ptr, ptr %62, align 8, !tbaa !29
  %83 = tail call ptr @wa_to_ba(ptr noundef %82) #2
  store ptr %83, ptr %2, align 8, !tbaa !31
  %84 = icmp eq ptr %83, null
  br i1 %84, label %85, label %86

85:                                               ; preds = %81
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 77, i32 noundef 2) #2
  br label %108

86:                                               ; preds = %81
  %87 = getelementptr inbounds i8, ptr %62, i64 8
  %88 = load ptr, ptr %87, align 8, !tbaa !32
  %89 = tail call ptr @wa_to_ba(ptr noundef %88) #2
  store ptr %89, ptr %3, align 8, !tbaa !31
  %90 = icmp eq ptr %89, null
  br i1 %90, label %91, label %92

91:                                               ; preds = %86
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 78, i32 noundef 2) #2
  br label %108

92:                                               ; preds = %86
  %93 = load ptr, ptr %2, align 8, !tbaa !31
  %94 = tail call i32 @ba_change_len(ptr noundef %93, i64 noundef %73) #2
  %.not88 = icmp eq i32 %94, 0
  br i1 %.not88, label %96, label %95

95:                                               ; preds = %92
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 79, i32 noundef %94) #2
  br label %108

96:                                               ; preds = %92
  %97 = load ptr, ptr %3, align 8, !tbaa !31
  %98 = tail call i32 @ba_change_len(ptr noundef %97, i64 noundef %73) #2
  %.not89 = icmp eq i32 %98, 0
  br i1 %.not89, label %100, label %99

99:                                               ; preds = %96
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 80, i32 noundef %98) #2
  br label %108

100:                                              ; preds = %96
  %101 = load ptr, ptr %2, align 8, !tbaa !31
  %102 = tail call i32 @ba_swap(ptr noundef %101) #2
  %.not90 = icmp eq i32 %102, 0
  br i1 %.not90, label %104, label %103

103:                                              ; preds = %100
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 81, i32 noundef %102) #2
  br label %108

104:                                              ; preds = %100
  %105 = load ptr, ptr %3, align 8, !tbaa !31
  %106 = tail call i32 @ba_swap(ptr noundef %105) #2
  %.not91 = icmp eq i32 %106, 0
  br i1 %.not91, label %108, label %107

107:                                              ; preds = %104
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 82, i32 noundef %106) #2
  br label %108

108:                                              ; preds = %56, %104, %107, %103, %99, %95, %91, %85, %80, %64, %44, %32, %23, %16, %14, %12, %10, %5
  %.066 = phi ptr [ null, %23 ], [ %21, %32 ], [ %21, %44 ], [ %21, %56 ], [ %21, %64 ], [ %21, %80 ], [ %21, %85 ], [ %21, %91 ], [ %21, %95 ], [ %21, %99 ], [ %21, %103 ], [ %21, %107 ], [ %21, %104 ], [ null, %16 ], [ null, %14 ], [ null, %12 ], [ null, %10 ], [ null, %5 ]
  %.065 = phi ptr [ null, %23 ], [ null, %32 ], [ null, %44 ], [ %42, %56 ], [ %42, %64 ], [ %42, %80 ], [ %42, %85 ], [ %42, %91 ], [ %42, %95 ], [ %42, %99 ], [ %42, %103 ], [ %42, %107 ], [ %42, %104 ], [ null, %16 ], [ null, %14 ], [ null, %12 ], [ null, %10 ], [ null, %5 ]
  %.064 = phi ptr [ null, %23 ], [ null, %32 ], [ null, %44 ], [ null, %56 ], [ null, %64 ], [ %62, %80 ], [ %62, %85 ], [ %62, %91 ], [ %62, %95 ], [ %62, %99 ], [ %62, %103 ], [ %62, %107 ], [ %62, %104 ], [ null, %16 ], [ null, %14 ], [ null, %12 ], [ null, %10 ], [ null, %5 ]
  %.063 = phi i32 [ 2, %23 ], [ 6, %32 ], [ 2, %44 ], [ %55, %56 ], [ 2, %64 ], [ %79, %80 ], [ 2, %85 ], [ 2, %91 ], [ %94, %95 ], [ %98, %99 ], [ %102, %103 ], [ %106, %107 ], [ 0, %104 ], [ 2, %16 ], [ 2, %14 ], [ 2, %12 ], [ 2, %10 ], [ 2, %5 ]
  tail call void @ec_point_free(ptr noundef %.064) #2
  tail call void @wa_free_private(ptr noundef %.066) #2
  tail call void @wa_free_private(ptr noundef %.065) #2
  ret i32 %.063
}

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

declare ptr @wa_alloc_from_be(ptr noundef, i64 noundef) local_unnamed_addr #1

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

declare zeroext i1 @int_is_zero(ptr noundef) local_unnamed_addr #1

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

declare void @wa_change_len(ptr noundef, i64 noundef) local_unnamed_addr #1

declare ptr @gfp_mod_inv_core(ptr noundef, ptr noundef) local_unnamed_addr #1

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

declare ptr @ec_point_alloc(i64 noundef) local_unnamed_addr #1

declare i64 @int_bit_len(ptr noundef) local_unnamed_addr #1

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

declare ptr @wa_to_ba(ptr noundef) local_unnamed_addr #1

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

declare i32 @ba_swap(ptr noundef) local_unnamed_addr #1

declare void @ec_point_free(ptr noundef) local_unnamed_addr #1

declare void @wa_free_private(ptr 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 = { "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 }

!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, !7, i64 0}
!6 = !{!"EcCtx_st", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !10, i64 33}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Bool", !8, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"EcParamsCtx_st", !13, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !14, i64 48, !7, i64 56, !7, i64 64, !13, i64 72, !7, i64 80}
!13 = !{!"int", !8, i64 0}
!14 = !{!"long", !8, i64 0}
!15 = !{!16, !7, i64 0}
!16 = !{!"ByteArray_st", !7, i64 0, !14, i64 8}
!17 = !{!16, !14, i64 8}
!18 = !{!12, !7, i64 16}
!19 = !{!20, !14, i64 8}
!20 = !{!"WordArray_st", !7, i64 0, !14, i64 8}
!21 = !{!12, !7, i64 80}
!22 = !{!13, !13, i64 0}
!23 = !{!12, !7, i64 24}
!24 = !{!25, !14, i64 32}
!25 = !{!"EcGfpCtx_st", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !14, i64 32}
!26 = !{!25, !7, i64 0}
!27 = !{!28, !7, i64 0}
!28 = !{!"GfpCtx_st", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!29 = !{!30, !7, i64 0}
!30 = !{!"ECPoint_st", !7, i64 0, !7, i64 8, !7, i64 16}
!31 = !{!7, !7, i64 0}
!32 = !{!30, !7, i64 8}


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