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

; 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 @ecrdsa_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 i32, align 4
  %14 = alloca i32, align 4
  %15 = 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 4, ptr %13) #3
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %16

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

19:                                               ; preds = %16
  store i32 2, ptr %13, align 4, !tbaa !9
  %20 = load i32, ptr %13, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 50, i32 noundef %20, ptr noundef null)
  br label %246

21:                                               ; preds = %16
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  br label %24

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

31:                                               ; preds = %24
  store i32 2, ptr %13, align 4, !tbaa !9
  %32 = load i32, ptr %13, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 51, i32 noundef %32, ptr noundef null)
  br label %246

33:                                               ; preds = %24
  br label %34

34:                                               ; preds = %33
  br label %35

35:                                               ; preds = %34
  br label %36

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

39:                                               ; preds = %36
  store i32 2, ptr %13, align 4, !tbaa !9
  %40 = load i32, ptr %13, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 52, i32 noundef %40, ptr noundef null)
  br label %246

41:                                               ; preds = %36
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  br label %44

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

47:                                               ; preds = %44
  store i32 2, ptr %13, align 4, !tbaa !9
  %48 = load i32, ptr %13, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 53, i32 noundef %48, ptr noundef null)
  br label %246

49:                                               ; preds = %44
  br label %50

50:                                               ; preds = %49
  br label %51

51:                                               ; preds = %50
  br label %52

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

55:                                               ; preds = %52
  store i32 2, ptr %13, align 4, !tbaa !9
  %56 = load i32, ptr %13, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 54, i32 noundef %56, ptr noundef null)
  br label %246

57:                                               ; preds = %52
  br label %58

58:                                               ; preds = %57
  br label %59

59:                                               ; preds = %58
  br label %60

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

69:                                               ; preds = %60
  store i32 2, ptr %13, align 4, !tbaa !9
  %70 = load i32, ptr %13, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 56, i32 noundef %70)
  br label %246

71:                                               ; preds = %60
  br label %72

72:                                               ; preds = %71
  br label %73

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

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

85:                                               ; preds = %76, %73
  br label %86

86:                                               ; preds = %85
  store i32 6, ptr %13, align 4, !tbaa !9
  %87 = load i32, ptr %13, align 4, !tbaa !9
  call void @stacktrace_create(ptr noundef @.str, i64 noundef 58, i32 noundef %87, ptr noundef null)
  br label %246

88:                                               ; No predecessors!
  br label %89

89:                                               ; preds = %88
  br label %90

90:                                               ; preds = %89, %76
  %91 = load ptr, ptr %11, align 8, !tbaa !5
  %92 = load ptr, ptr %6, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.EcCtx_st, ptr %92, i32 0, i32 0
  %94 = load ptr, ptr %93, align 8, !tbaa !11
  %95 = getelementptr inbounds %struct.EcParamsCtx_st, ptr %94, i32 0, i32 2
  %96 = load ptr, ptr %95, align 8, !tbaa !20
  %97 = getelementptr inbounds %struct.WordArray_st, ptr %96, i32 0, i32 1
  %98 = load i64, ptr %97, align 8, !tbaa !21
  call void @wa_change_len(ptr noundef %91, i64 noundef %98)
  %99 = load ptr, ptr %6, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.EcCtx_st, ptr %99, i32 0, i32 0
  %101 = load ptr, ptr %100, align 8, !tbaa !11
  %102 = getelementptr inbounds %struct.EcParamsCtx_st, ptr %101, i32 0, i32 10
  %103 = load ptr, ptr %102, align 8, !tbaa !23
  %104 = icmp eq ptr %103, null
  br i1 %104, label %105, label %127

105:                                              ; preds = %90
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %106 = load i32, ptr @default_opt_level, align 4, !tbaa !9
  %107 = lshr i32 %106, 8
  %108 = and i32 %107, 15
  store i32 %108, ptr %14, align 4, !tbaa !9
  %109 = load i32, ptr %14, align 4, !tbaa !9
  %110 = icmp eq i32 %109, 0
  br i1 %110, label %111, label %112

111:                                              ; preds = %105
  store i32 5, ptr %14, align 4, !tbaa !9
  br label %112

112:                                              ; preds = %111, %105
  br label %113

113:                                              ; preds = %112
  %114 = load ptr, ptr %6, align 8, !tbaa !5
  %115 = load i32, ptr %14, align 4, !tbaa !9
  %116 = call i32 @ec_set_sign_precomp(ptr noundef %114, i32 noundef 0, i32 noundef %115)
  store i32 %116, ptr %13, align 4, !tbaa !9
  %117 = load i32, ptr %13, align 4, !tbaa !9
  %118 = icmp ne i32 %117, 0
  br i1 %118, label %119, label %121

119:                                              ; preds = %113
  %120 = load i32, ptr %13, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 68, i32 noundef %120)
  store i32 4, ptr %15, align 4
  br label %124

121:                                              ; preds = %113
  br label %122

122:                                              ; preds = %121
  br label %123

123:                                              ; preds = %122
  store i32 0, ptr %15, align 4
  br label %124

124:                                              ; preds = %123, %119
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  %125 = load i32, ptr %15, align 4
  switch i32 %125, label %250 [
    i32 0, label %126
    i32 4, label %246
  ]

126:                                              ; preds = %124
  br label %127

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

128:                                              ; preds = %127
  %129 = load ptr, ptr %6, align 8, !tbaa !5
  %130 = getelementptr inbounds %struct.EcCtx_st, ptr %129, i32 0, i32 0
  %131 = load ptr, ptr %130, align 8, !tbaa !11
  %132 = getelementptr inbounds %struct.EcParamsCtx_st, ptr %131, i32 0, i32 3
  %133 = load ptr, ptr %132, align 8, !tbaa !24
  %134 = getelementptr inbounds %struct.EcGfpCtx_st, ptr %133, i32 0, i32 4
  %135 = load i64, ptr %134, align 8, !tbaa !25
  %136 = call ptr @ec_point_alloc(i64 noundef %135)
  store ptr %136, ptr %12, align 8, !tbaa !5
  %137 = icmp eq ptr null, %136
  br i1 %137, label %138, label %140

138:                                              ; preds = %128
  store i32 2, ptr %13, align 4, !tbaa !9
  %139 = load i32, ptr %13, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 71, i32 noundef %139)
  br label %246

140:                                              ; preds = %128
  br label %141

141:                                              ; preds = %140
  br label %142

142:                                              ; preds = %141
  %143 = load ptr, ptr %6, align 8, !tbaa !5
  %144 = getelementptr inbounds %struct.EcCtx_st, ptr %143, i32 0, i32 0
  %145 = load ptr, ptr %144, align 8, !tbaa !11
  %146 = getelementptr inbounds %struct.EcParamsCtx_st, ptr %145, i32 0, i32 3
  %147 = load ptr, ptr %146, align 8, !tbaa !24
  %148 = getelementptr inbounds %struct.EcGfpCtx_st, ptr %147, i32 0, i32 0
  %149 = load ptr, ptr %148, align 8, !tbaa !27
  %150 = getelementptr inbounds %struct.GfpCtx_st, ptr %149, i32 0, i32 0
  %151 = load ptr, ptr %150, align 8, !tbaa !28
  %152 = call i64 @int_bit_len(ptr noundef %151)
  %153 = add i64 %152, 7
  %154 = udiv i64 %153, 8
  store i64 %154, ptr %10, align 8, !tbaa !30
  br label %155

155:                                              ; preds = %142
  %156 = load ptr, ptr %6, align 8, !tbaa !5
  %157 = getelementptr inbounds %struct.EcCtx_st, ptr %156, i32 0, i32 0
  %158 = load ptr, ptr %157, align 8, !tbaa !11
  %159 = getelementptr inbounds %struct.EcParamsCtx_st, ptr %158, i32 0, i32 3
  %160 = load ptr, ptr %159, align 8, !tbaa !24
  %161 = load ptr, ptr %6, align 8, !tbaa !5
  %162 = getelementptr inbounds %struct.EcCtx_st, ptr %161, i32 0, i32 0
  %163 = load ptr, ptr %162, align 8, !tbaa !11
  %164 = getelementptr inbounds %struct.EcParamsCtx_st, ptr %163, i32 0, i32 10
  %165 = load ptr, ptr %164, align 8, !tbaa !23
  %166 = load ptr, ptr %11, align 8, !tbaa !5
  %167 = load ptr, ptr %12, align 8, !tbaa !5
  %168 = call i32 @ecp_dual_mul_opt(ptr noundef %160, ptr noundef %165, ptr noundef %166, ptr noundef null, ptr noundef null, ptr noundef %167)
  store i32 %168, ptr %13, align 4, !tbaa !9
  %169 = load i32, ptr %13, align 4, !tbaa !9
  %170 = icmp ne i32 %169, 0
  br i1 %170, label %171, label %173

171:                                              ; preds = %155
  %172 = load i32, ptr %13, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 73, i32 noundef %172)
  br label %246

173:                                              ; preds = %155
  br label %174

174:                                              ; preds = %173
  br label %175

175:                                              ; preds = %174
  br label %176

176:                                              ; preds = %175
  %177 = load ptr, ptr %12, align 8, !tbaa !5
  %178 = getelementptr inbounds %struct.ECPoint_st, ptr %177, i32 0, i32 0
  %179 = load ptr, ptr %178, align 8, !tbaa !31
  %180 = call ptr @wa_to_ba(ptr noundef %179)
  %181 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %180, ptr %181, align 8, !tbaa !5
  %182 = icmp eq ptr null, %180
  br i1 %182, label %183, label %185

183:                                              ; preds = %176
  store i32 2, ptr %13, align 4, !tbaa !9
  %184 = load i32, ptr %13, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 75, i32 noundef %184)
  br label %246

185:                                              ; preds = %176
  br label %186

186:                                              ; preds = %185
  br label %187

187:                                              ; preds = %186
  br label %188

188:                                              ; preds = %187
  %189 = load ptr, ptr %12, align 8, !tbaa !5
  %190 = getelementptr inbounds %struct.ECPoint_st, ptr %189, i32 0, i32 1
  %191 = load ptr, ptr %190, align 8, !tbaa !33
  %192 = call ptr @wa_to_ba(ptr noundef %191)
  %193 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %192, ptr %193, align 8, !tbaa !5
  %194 = icmp eq ptr null, %192
  br i1 %194, label %195, label %197

195:                                              ; preds = %188
  store i32 2, ptr %13, align 4, !tbaa !9
  %196 = load i32, ptr %13, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 76, i32 noundef %196)
  br label %246

197:                                              ; preds = %188
  br label %198

198:                                              ; preds = %197
  br label %199

199:                                              ; preds = %198
  br label %200

200:                                              ; preds = %199
  %201 = load ptr, ptr %8, align 8, !tbaa !5
  %202 = load ptr, ptr %201, align 8, !tbaa !5
  %203 = load i64, ptr %10, align 8, !tbaa !30
  %204 = call i32 @ba_change_len(ptr noundef %202, i64 noundef %203)
  store i32 %204, ptr %13, align 4, !tbaa !9
  %205 = load i32, ptr %13, align 4, !tbaa !9
  %206 = icmp ne i32 %205, 0
  br i1 %206, label %207, label %209

207:                                              ; preds = %200
  %208 = load i32, ptr %13, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 77, i32 noundef %208)
  br label %246

209:                                              ; preds = %200
  br label %210

210:                                              ; preds = %209
  br label %211

211:                                              ; preds = %210
  br label %212

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

219:                                              ; preds = %212
  %220 = load i32, ptr %13, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 78, i32 noundef %220)
  br label %246

221:                                              ; preds = %212
  br label %222

222:                                              ; preds = %221
  br label %223

223:                                              ; preds = %222
  br label %224

224:                                              ; preds = %223
  %225 = load ptr, ptr %8, align 8, !tbaa !5
  %226 = load ptr, ptr %225, align 8, !tbaa !5
  %227 = call i32 @ba_swap(ptr noundef %226)
  store i32 %227, ptr %13, align 4, !tbaa !9
  %228 = load i32, ptr %13, align 4, !tbaa !9
  %229 = icmp ne i32 %228, 0
  br i1 %229, label %230, label %232

230:                                              ; preds = %224
  %231 = load i32, ptr %13, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 79, i32 noundef %231)
  br label %246

232:                                              ; preds = %224
  br label %233

233:                                              ; preds = %232
  br label %234

234:                                              ; preds = %233
  br label %235

235:                                              ; preds = %234
  %236 = load ptr, ptr %9, align 8, !tbaa !5
  %237 = load ptr, ptr %236, align 8, !tbaa !5
  %238 = call i32 @ba_swap(ptr noundef %237)
  store i32 %238, ptr %13, align 4, !tbaa !9
  %239 = load i32, ptr %13, align 4, !tbaa !9
  %240 = icmp ne i32 %239, 0
  br i1 %240, label %241, label %243

241:                                              ; preds = %235
  %242 = load i32, ptr %13, align 4, !tbaa !9
  call void @stacktrace_add(ptr noundef @.str, i64 noundef 80, i32 noundef %242)
  br label %246

243:                                              ; preds = %235
  br label %244

244:                                              ; preds = %243
  br label %245

245:                                              ; preds = %244
  br label %246

246:                                              ; preds = %245, %241, %230, %219, %207, %195, %183, %171, %138, %124, %86, %69, %55, %47, %39, %31, %19
  %247 = load ptr, ptr %12, align 8, !tbaa !5
  call void @ec_point_free(ptr noundef %247)
  %248 = load ptr, ptr %11, align 8, !tbaa !5
  call void @wa_free_private(ptr noundef %248)
  %249 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %249, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %250

250:                                              ; preds = %246, %124
  call void @llvm.lifetime.end.p0(i64 4, 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
  %251 = load i32, ptr %5, align 4
  ret i32 %251
}

; 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 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 @ecrdsa_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 50, i32 noundef 2, ptr noundef null) #2
  br label %101

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 51, i32 noundef 2, ptr noundef null) #2
  br label %101

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

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

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

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

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

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

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 56, i32 noundef 2) #2
  br label %101

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 58, i32 noundef 6, ptr noundef null) #2
  br label %101

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 80
  %41 = load ptr, ptr %40, align 8, !tbaa !21
  %42 = icmp eq ptr %41, null
  br i1 %42, label %43, label %.thread

43:                                               ; preds = %33
  %44 = load i32, ptr @default_opt_level, align 4, !tbaa !22
  %45 = lshr i32 %44, 8
  %46 = and i32 %45, 15
  %47 = icmp eq i32 %46, 0
  %spec.store.select = select i1 %47, i32 5, i32 %46
  %48 = tail call i32 @ec_set_sign_precomp(ptr noundef nonnull %0, i32 noundef 0, i32 noundef %spec.store.select) #2
  %.not79 = icmp eq i32 %48, 0
  br i1 %.not79, label %..thread_crit_edge, label %49

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

49:                                               ; preds = %43
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 68, i32 noundef %48) #2
  br label %101

.thread:                                          ; preds = %..thread_crit_edge, %33
  %50 = phi ptr [ %.pre, %..thread_crit_edge ], [ %39, %33 ]
  %51 = getelementptr inbounds i8, ptr %50, i64 24
  %52 = load ptr, ptr %51, align 8, !tbaa !23
  %53 = getelementptr inbounds i8, ptr %52, i64 32
  %54 = load i64, ptr %53, align 8, !tbaa !24
  %55 = tail call ptr @ec_point_alloc(i64 noundef %54) #2
  %56 = icmp eq ptr %55, null
  br i1 %56, label %57, label %58

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

58:                                               ; preds = %.thread
  %59 = load ptr, ptr %0, align 8, !tbaa !5
  %60 = getelementptr inbounds i8, ptr %59, i64 24
  %61 = load ptr, ptr %60, align 8, !tbaa !23
  %62 = load ptr, ptr %61, align 8, !tbaa !26
  %63 = load ptr, ptr %62, align 8, !tbaa !27
  %64 = tail call i64 @int_bit_len(ptr noundef %63) #2
  %65 = add i64 %64, 7
  %66 = lshr i64 %65, 3
  %67 = load ptr, ptr %0, align 8, !tbaa !5
  %68 = getelementptr inbounds i8, ptr %67, i64 24
  %69 = load ptr, ptr %68, align 8, !tbaa !23
  %70 = getelementptr inbounds i8, ptr %67, i64 80
  %71 = load ptr, ptr %70, align 8, !tbaa !21
  %72 = tail call i32 @ecp_dual_mul_opt(ptr noundef %69, ptr noundef %71, ptr noundef nonnull %21, ptr noundef null, ptr noundef null, ptr noundef nonnull %55) #2
  %.not80 = icmp eq i32 %72, 0
  br i1 %.not80, label %74, label %73

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

74:                                               ; preds = %58
  %75 = load ptr, ptr %55, align 8, !tbaa !29
  %76 = tail call ptr @wa_to_ba(ptr noundef %75) #2
  store ptr %76, ptr %2, align 8, !tbaa !31
  %77 = icmp eq ptr %76, null
  br i1 %77, label %78, label %79

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

79:                                               ; preds = %74
  %80 = getelementptr inbounds i8, ptr %55, i64 8
  %81 = load ptr, ptr %80, align 8, !tbaa !32
  %82 = tail call ptr @wa_to_ba(ptr noundef %81) #2
  store ptr %82, ptr %3, align 8, !tbaa !31
  %83 = icmp eq ptr %82, null
  br i1 %83, label %84, label %85

84:                                               ; preds = %79
  tail call void @stacktrace_add(ptr noundef nonnull @.str, i64 noundef 76, i32 noundef 2) #2
  br label %101

85:                                               ; preds = %79
  %86 = load ptr, ptr %2, align 8, !tbaa !31
  %87 = tail call i32 @ba_change_len(ptr noundef %86, i64 noundef %66) #2
  %.not81 = icmp eq i32 %87, 0
  br i1 %.not81, label %89, label %88

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

89:                                               ; preds = %85
  %90 = load ptr, ptr %3, align 8, !tbaa !31
  %91 = tail call i32 @ba_change_len(ptr noundef %90, i64 noundef %66) #2
  %.not82 = icmp eq i32 %91, 0
  br i1 %.not82, label %93, label %92

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

93:                                               ; preds = %89
  %94 = load ptr, ptr %2, align 8, !tbaa !31
  %95 = tail call i32 @ba_swap(ptr noundef %94) #2
  %.not83 = icmp eq i32 %95, 0
  br i1 %.not83, label %97, label %96

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

97:                                               ; preds = %93
  %98 = load ptr, ptr %3, align 8, !tbaa !31
  %99 = tail call i32 @ba_swap(ptr noundef %98) #2
  %.not84 = icmp eq i32 %99, 0
  br i1 %.not84, label %101, label %100

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

101:                                              ; preds = %49, %97, %100, %96, %92, %88, %84, %78, %73, %57, %32, %23, %16, %14, %12, %10, %5
  %.061 = phi ptr [ null, %23 ], [ %21, %32 ], [ %21, %49 ], [ %21, %57 ], [ %21, %73 ], [ %21, %78 ], [ %21, %84 ], [ %21, %88 ], [ %21, %92 ], [ %21, %96 ], [ %21, %100 ], [ %21, %97 ], [ null, %16 ], [ null, %14 ], [ null, %12 ], [ null, %10 ], [ null, %5 ]
  %.060 = phi ptr [ null, %23 ], [ null, %32 ], [ null, %49 ], [ null, %57 ], [ %55, %73 ], [ %55, %78 ], [ %55, %84 ], [ %55, %88 ], [ %55, %92 ], [ %55, %96 ], [ %55, %100 ], [ %55, %97 ], [ null, %16 ], [ null, %14 ], [ null, %12 ], [ null, %10 ], [ null, %5 ]
  %.059 = phi i32 [ 2, %23 ], [ 6, %32 ], [ %48, %49 ], [ 2, %57 ], [ %72, %73 ], [ 2, %78 ], [ 2, %84 ], [ %87, %88 ], [ %91, %92 ], [ %95, %96 ], [ %99, %100 ], [ 0, %97 ], [ 2, %16 ], [ 2, %14 ], [ 2, %12 ], [ 2, %10 ], [ 2, %5 ]
  tail call void @ec_point_free(ptr noundef %.060) #2
  tail call void @wa_free_private(ptr noundef %.061) #2
  ret i32 %.059
}

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