; LLVM IR from trustwallet/wallet-core :: trezor-crypto/crypto (ecdsa)

; 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.bignum256 = type { [9 x i32] }
%struct.jacobian_curve_point = type { %struct.bignum256, %struct.bignum256, %struct.bignum256 }
%struct.curve_point = type { %struct.bignum256, %struct.bignum256 }
%struct.ecdsa_curve = type { %struct.bignum256, %struct.curve_point, %struct.bignum256, %struct.bignum256, i32, %struct.bignum256, [64 x [8 x %struct.curve_point]] }

@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1
@__PRETTY_FUNCTION__.point_multiply = external hidden unnamed_addr constant [95 x i8], align 1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

; Function Attrs: nounwind uwtable
declare dso_local void @point_set_infinity(ptr noundef) #1

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

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

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #4

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

; Function Attrs: nounwind uwtable
define dso_local i32 @point_multiply(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %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 i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %struct.bignum256, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca %struct.jacobian_curve_point, align 4
  %21 = alloca [8 x %struct.curve_point], align 16
  %22 = alloca ptr, align 8
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = 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
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ecdsa_curve, ptr %27, i32 0, i32 2
  %29 = call i32 @bn_is_less(ptr noundef %26, ptr noundef %28)
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %32, label %31

31:                                               ; preds = %4
  store i32 1, ptr %5, align 4
  br label %239

32:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 36, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  store ptr null, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  store i32 0, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 0, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.bignum256, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds [9 x i32], ptr %34, i64 0, i64 0
  %36 = load i32, ptr %35, align 4, !tbaa !9
  %37 = and i32 %36, 1
  %38 = sub i32 %37, 1
  store i32 %38, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  store i32 0, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  store i32 0, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  store i32 0, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 108, ptr %20) #6
  call void @llvm.lifetime.start.p0(i64 576, ptr %21) #6
  call void @llvm.memset.p0.i64(ptr align 16 %21, i8 0, i64 576, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #6
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ecdsa_curve, ptr %39, i32 0, i32 0
  store ptr %40, ptr %22, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #6
  store i32 1, ptr %23, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #6
  store i32 0, ptr %24, align 4, !tbaa !9
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %80, %32
  %42 = load i32, ptr %11, align 4, !tbaa !9
  %43 = icmp slt i32 %42, 8
  br i1 %43, label %44, label %83

44:                                               ; preds = %41
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.bignum256, ptr %45, i32 0, i32 0
  %47 = load i32, ptr %11, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [9 x i32], ptr %46, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !9
  %51 = load i32, ptr %24, align 4, !tbaa !9
  %52 = or i32 %51, %50
  store i32 %52, ptr %24, align 4, !tbaa !9
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.bignum256, ptr %53, i32 0, i32 0
  %55 = load i32, ptr %11, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [9 x i32], ptr %54, i64 0, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !9
  %59 = add i32 536870911, %58
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ecdsa_curve, ptr %60, i32 0, i32 2
  %62 = getelementptr inbounds %struct.bignum256, ptr %61, i32 0, i32 0
  %63 = load i32, ptr %11, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [9 x i32], ptr %62, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !9
  %67 = load i32, ptr %16, align 4, !tbaa !9
  %68 = and i32 %66, %67
  %69 = sub i32 %59, %68
  %70 = load i32, ptr %23, align 4, !tbaa !9
  %71 = add i32 %70, %69
  store i32 %71, ptr %23, align 4, !tbaa !9
  %72 = load i32, ptr %23, align 4, !tbaa !9
  %73 = and i32 %72, 536870911
  %74 = getelementptr inbounds %struct.bignum256, ptr %12, i32 0, i32 0
  %75 = load i32, ptr %11, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [9 x i32], ptr %74, i64 0, i64 %76
  store i32 %73, ptr %77, align 4, !tbaa !9
  %78 = load i32, ptr %23, align 4, !tbaa !9
  %79 = lshr i32 %78, 29
  store i32 %79, ptr %23, align 4, !tbaa !9
  br label %80

80:                                               ; preds = %44
  %81 = load i32, ptr %11, align 4, !tbaa !9
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %11, align 4, !tbaa !9
  br label %41, !llvm.loop !11

83:                                               ; preds = %41
  %84 = load ptr, ptr %7, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.bignum256, ptr %84, i32 0, i32 0
  %86 = load i32, ptr %11, align 4, !tbaa !9
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [9 x i32], ptr %85, i64 0, i64 %87
  %89 = load i32, ptr %88, align 4, !tbaa !9
  %90 = load i32, ptr %24, align 4, !tbaa !9
  %91 = or i32 %90, %89
  store i32 %91, ptr %24, align 4, !tbaa !9
  %92 = load i32, ptr %23, align 4, !tbaa !9
  %93 = add i32 %92, 16777215
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.bignum256, ptr %94, i32 0, i32 0
  %96 = load i32, ptr %11, align 4, !tbaa !9
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [9 x i32], ptr %95, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !9
  %100 = add i32 %93, %99
  %101 = load ptr, ptr %6, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.ecdsa_curve, ptr %101, i32 0, i32 2
  %103 = getelementptr inbounds %struct.bignum256, ptr %102, i32 0, i32 0
  %104 = load i32, ptr %11, align 4, !tbaa !9
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [9 x i32], ptr %103, i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !9
  %108 = load i32, ptr %16, align 4, !tbaa !9
  %109 = and i32 %107, %108
  %110 = sub i32 %100, %109
  %111 = getelementptr inbounds %struct.bignum256, ptr %12, i32 0, i32 0
  %112 = load i32, ptr %11, align 4, !tbaa !9
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [9 x i32], ptr %111, i64 0, i64 %113
  store i32 %110, ptr %114, align 4, !tbaa !9
  %115 = getelementptr inbounds %struct.bignum256, ptr %12, i32 0, i32 0
  %116 = getelementptr inbounds [9 x i32], ptr %115, i64 0, i64 0
  %117 = load i32, ptr %116, align 4, !tbaa !9
  %118 = and i32 %117, 1
  %119 = icmp ne i32 %118, 0
  br i1 %119, label %120, label %121

120:                                              ; preds = %83
  br label %122

121:                                              ; preds = %83
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 442, ptr noundef @__PRETTY_FUNCTION__.point_multiply) #7
  unreachable

122:                                              ; preds = %120
  %123 = load i32, ptr %24, align 4, !tbaa !9
  %124 = icmp ne i32 %123, 0
  br i1 %124, label %127, label %125

125:                                              ; preds = %122
  %126 = load ptr, ptr %9, align 8, !tbaa !5
  call void @point_set_infinity(ptr noundef %126)
  store i32 1, ptr %5, align 4
  store i32 1, ptr %25, align 4
  br label %238

127:                                              ; preds = %122
  %128 = getelementptr inbounds [8 x %struct.curve_point], ptr %21, i64 0, i64 7
  %129 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %128, ptr align 4 %129, i64 72, i1 false), !tbaa.struct !13
  %130 = load ptr, ptr %6, align 8, !tbaa !5
  %131 = getelementptr inbounds [8 x %struct.curve_point], ptr %21, i64 0, i64 7
  call void @point_double(ptr noundef %130, ptr noundef %131)
  %132 = getelementptr inbounds [8 x %struct.curve_point], ptr %21, i64 0, i64 0
  %133 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %132, ptr align 4 %133, i64 72, i1 false), !tbaa.struct !13
  store i32 1, ptr %10, align 4, !tbaa !9
  br label %134

134:                                              ; preds = %150, %127
  %135 = load i32, ptr %10, align 4, !tbaa !9
  %136 = icmp slt i32 %135, 8
  br i1 %136, label %137, label %153

137:                                              ; preds = %134
  %138 = load i32, ptr %10, align 4, !tbaa !9
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [8 x %struct.curve_point], ptr %21, i64 0, i64 %139
  %141 = getelementptr inbounds [8 x %struct.curve_point], ptr %21, i64 0, i64 7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %140, ptr align 8 %141, i64 72, i1 false), !tbaa.struct !13
  %142 = load ptr, ptr %6, align 8, !tbaa !5
  %143 = load i32, ptr %10, align 4, !tbaa !9
  %144 = sub nsw i32 %143, 1
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [8 x %struct.curve_point], ptr %21, i64 0, i64 %145
  %147 = load i32, ptr %10, align 4, !tbaa !9
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [8 x %struct.curve_point], ptr %21, i64 0, i64 %148
  call void @point_add(ptr noundef %142, ptr noundef %146, ptr noundef %149)
  br label %150

150:                                              ; preds = %137
  %151 = load i32, ptr %10, align 4, !tbaa !9
  %152 = add nsw i32 %151, 1
  store i32 %152, ptr %10, align 4, !tbaa !9
  br label %134, !llvm.loop !15

153:                                              ; preds = %134
  %154 = getelementptr inbounds %struct.bignum256, ptr %12, i32 0, i32 0
  %155 = getelementptr inbounds [9 x i32], ptr %154, i64 0, i64 8
  store ptr %155, ptr %13, align 8, !tbaa !5
  %156 = load ptr, ptr %13, align 8, !tbaa !5
  %157 = load i32, ptr %156, align 4, !tbaa !9
  store i32 %157, ptr %14, align 4, !tbaa !9
  store i32 20, ptr %15, align 4, !tbaa !9
  %158 = load i32, ptr %14, align 4, !tbaa !9
  %159 = load i32, ptr %15, align 4, !tbaa !9
  %160 = lshr i32 %158, %159
  store i32 %160, ptr %17, align 4, !tbaa !9
  %161 = load i32, ptr %17, align 4, !tbaa !9
  %162 = lshr i32 %161, 4
  %163 = sub i32 %162, 1
  store i32 %163, ptr %18, align 4, !tbaa !9
  %164 = load i32, ptr %18, align 4, !tbaa !9
  %165 = load i32, ptr %17, align 4, !tbaa !9
  %166 = xor i32 %165, %164
  store i32 %166, ptr %17, align 4, !tbaa !9
  %167 = load i32, ptr %17, align 4, !tbaa !9
  %168 = and i32 %167, 15
  store i32 %168, ptr %17, align 4, !tbaa !9
  %169 = load i32, ptr %17, align 4, !tbaa !9
  %170 = lshr i32 %169, 1
  %171 = zext i32 %170 to i64
  %172 = getelementptr inbounds [8 x %struct.curve_point], ptr %21, i64 0, i64 %171
  %173 = load ptr, ptr %22, align 8, !tbaa !5
  call void @curve_to_jacobian(ptr noundef %172, ptr noundef %20, ptr noundef %173)
  store i32 62, ptr %10, align 4, !tbaa !9
  br label %174

174:                                              ; preds = %228, %153
  %175 = load i32, ptr %10, align 4, !tbaa !9
  %176 = icmp sge i32 %175, 0
  br i1 %176, label %177, label %231

177:                                              ; preds = %174
  %178 = load ptr, ptr %6, align 8, !tbaa !5
  call void @point_jacobian_double(ptr noundef %20, ptr noundef %178)
  %179 = load ptr, ptr %6, align 8, !tbaa !5
  call void @point_jacobian_double(ptr noundef %20, ptr noundef %179)
  %180 = load ptr, ptr %6, align 8, !tbaa !5
  call void @point_jacobian_double(ptr noundef %20, ptr noundef %180)
  %181 = load ptr, ptr %6, align 8, !tbaa !5
  call void @point_jacobian_double(ptr noundef %20, ptr noundef %181)
  %182 = load i32, ptr %15, align 4, !tbaa !9
  %183 = sub nsw i32 %182, 4
  store i32 %183, ptr %15, align 4, !tbaa !9
  %184 = load i32, ptr %15, align 4, !tbaa !9
  %185 = icmp slt i32 %184, 0
  br i1 %185, label %186, label %201

186:                                              ; preds = %177
  %187 = load i32, ptr %14, align 4, !tbaa !9
  %188 = load i32, ptr %15, align 4, !tbaa !9
  %189 = sub nsw i32 0, %188
  %190 = shl i32 %187, %189
  store i32 %190, ptr %17, align 4, !tbaa !9
  %191 = load ptr, ptr %13, align 8, !tbaa !5
  %192 = getelementptr inbounds i32, ptr %191, i32 -1
  store ptr %192, ptr %13, align 8, !tbaa !5
  %193 = load i32, ptr %192, align 4, !tbaa !9
  store i32 %193, ptr %14, align 4, !tbaa !9
  %194 = load i32, ptr %15, align 4, !tbaa !9
  %195 = add nsw i32 %194, 29
  store i32 %195, ptr %15, align 4, !tbaa !9
  %196 = load i32, ptr %14, align 4, !tbaa !9
  %197 = load i32, ptr %15, align 4, !tbaa !9
  %198 = lshr i32 %196, %197
  %199 = load i32, ptr %17, align 4, !tbaa !9
  %200 = or i32 %199, %198
  store i32 %200, ptr %17, align 4, !tbaa !9
  br label %205

201:                                              ; preds = %177
  %202 = load i32, ptr %14, align 4, !tbaa !9
  %203 = load i32, ptr %15, align 4, !tbaa !9
  %204 = lshr i32 %202, %203
  store i32 %204, ptr %17, align 4, !tbaa !9
  br label %205

205:                                              ; preds = %201, %186
  %206 = load i32, ptr %17, align 4, !tbaa !9
  %207 = and i32 %206, 31
  store i32 %207, ptr %17, align 4, !tbaa !9
  %208 = load i32, ptr %17, align 4, !tbaa !9
  %209 = lshr i32 %208, 4
  %210 = sub i32 %209, 1
  store i32 %210, ptr %19, align 4, !tbaa !9
  %211 = load i32, ptr %19, align 4, !tbaa !9
  %212 = load i32, ptr %17, align 4, !tbaa !9
  %213 = xor i32 %212, %211
  store i32 %213, ptr %17, align 4, !tbaa !9
  %214 = load i32, ptr %17, align 4, !tbaa !9
  %215 = and i32 %214, 15
  store i32 %215, ptr %17, align 4, !tbaa !9
  %216 = load i32, ptr %18, align 4, !tbaa !9
  %217 = load i32, ptr %19, align 4, !tbaa !9
  %218 = xor i32 %216, %217
  %219 = and i32 %218, 1
  %220 = getelementptr inbounds %struct.jacobian_curve_point, ptr %20, i32 0, i32 2
  %221 = load ptr, ptr %22, align 8, !tbaa !5
  call void @bn_cnegate(i32 noundef %219, ptr noundef %220, ptr noundef %221)
  %222 = load i32, ptr %17, align 4, !tbaa !9
  %223 = lshr i32 %222, 1
  %224 = zext i32 %223 to i64
  %225 = getelementptr inbounds [8 x %struct.curve_point], ptr %21, i64 0, i64 %224
  %226 = load ptr, ptr %6, align 8, !tbaa !5
  call void @point_jacobian_add(ptr noundef %225, ptr noundef %20, ptr noundef %226)
  %227 = load i32, ptr %19, align 4, !tbaa !9
  store i32 %227, ptr %18, align 4, !tbaa !9
  br label %228

228:                                              ; preds = %205
  %229 = load i32, ptr %10, align 4, !tbaa !9
  %230 = add nsw i32 %229, -1
  store i32 %230, ptr %10, align 4, !tbaa !9
  br label %174, !llvm.loop !16

231:                                              ; preds = %174
  %232 = load i32, ptr %18, align 4, !tbaa !9
  %233 = and i32 %232, 1
  %234 = getelementptr inbounds %struct.jacobian_curve_point, ptr %20, i32 0, i32 2
  %235 = load ptr, ptr %22, align 8, !tbaa !5
  call void @bn_cnegate(i32 noundef %233, ptr noundef %234, ptr noundef %235)
  %236 = load ptr, ptr %9, align 8, !tbaa !5
  %237 = load ptr, ptr %22, align 8, !tbaa !5
  call void @jacobian_to_curve(ptr noundef %20, ptr noundef %236, ptr noundef %237)
  call void @memzero(ptr noundef %12, i64 noundef 36)
  call void @memzero(ptr noundef %20, i64 noundef 108)
  store i32 0, ptr %5, align 4
  store i32 1, ptr %25, align 4
  br label %238

238:                                              ; preds = %231, %125
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #6
  call void @llvm.lifetime.end.p0(i64 576, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 108, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 36, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %239

239:                                              ; preds = %238, %31
  %240 = load i32, ptr %5, align 4
  ret i32 %240
}

declare i32 @bn_is_less(ptr noundef, ptr noundef) #5

declare void @bn_cnegate(i32 noundef, ptr noundef, ptr noundef) #5

declare void @memzero(ptr noundef, i64 noundef) #5

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { "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 #6 = { nounwind }
attributes #7 = { noreturn 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{i64 0, i64 36, !14, i64 36, i64 36, !14}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}


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

%struct.bignum256 = type { [9 x i32] }
%struct.jacobian_curve_point = type { %struct.bignum256, %struct.bignum256, %struct.bignum256 }
%struct.curve_point = type { %struct.bignum256, %struct.bignum256 }

@.str.1 = external hidden unnamed_addr constant [86 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [20 x i8], align 1
@__PRETTY_FUNCTION__.point_multiply = external hidden unnamed_addr constant [95 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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

; Function Attrs: nounwind uwtable
declare dso_local void @point_set_infinity(ptr noundef) local_unnamed_addr #1

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

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

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #4

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @point_multiply(ptr noundef %0, ptr noundef %1, ptr nocapture noundef readonly %2, ptr noundef %3) local_unnamed_addr #1 {
  %5 = alloca %struct.bignum256, align 4
  %6 = alloca %struct.jacobian_curve_point, align 4
  %7 = alloca [8 x %struct.curve_point], align 16
  %8 = getelementptr inbounds i8, ptr %0, i64 108
  %9 = tail call i32 @bn_is_less(ptr noundef %1, ptr noundef nonnull %8) #6
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %164, label %10

10:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 36, ptr nonnull %5) #6
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %12 = and i32 %11, 1
  %13 = add nsw i32 %12, -1
  call void @llvm.lifetime.start.p0(i64 108, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 576, ptr nonnull %7) #6
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(576) %7, i8 0, i64 512, i1 false)
  %14 = load i32, ptr %8, align 4, !tbaa !5
  %15 = and i32 %14, %13
  %16 = add i32 %11, 536870912
  %17 = sub i32 %16, %15
  %18 = and i32 %17, 536870911
  store i32 %18, ptr %5, align 4, !tbaa !5
  %19 = lshr i32 %17, 29
  %20 = getelementptr inbounds i8, ptr %1, i64 4
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %0, i64 112
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = and i32 %23, %13
  %25 = add nuw nsw i32 %19, 536870911
  %26 = add i32 %25, %21
  %27 = sub i32 %26, %24
  %28 = and i32 %27, 536870911
  %29 = getelementptr inbounds i8, ptr %5, i64 4
  store i32 %28, ptr %29, align 4, !tbaa !5
  %30 = lshr i32 %27, 29
  %31 = getelementptr inbounds i8, ptr %1, i64 8
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %0, i64 116
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = and i32 %34, %13
  %36 = add nuw nsw i32 %30, 536870911
  %37 = add i32 %36, %32
  %38 = sub i32 %37, %35
  %39 = and i32 %38, 536870911
  %40 = getelementptr inbounds i8, ptr %5, i64 8
  store i32 %39, ptr %40, align 4, !tbaa !5
  %41 = lshr i32 %38, 29
  %42 = getelementptr inbounds i8, ptr %1, i64 12
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %0, i64 120
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = and i32 %45, %13
  %47 = add nuw nsw i32 %41, 536870911
  %48 = add i32 %47, %43
  %49 = sub i32 %48, %46
  %50 = and i32 %49, 536870911
  %51 = getelementptr inbounds i8, ptr %5, i64 12
  store i32 %50, ptr %51, align 4, !tbaa !5
  %52 = lshr i32 %49, 29
  %53 = getelementptr inbounds i8, ptr %1, i64 16
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %0, i64 124
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = and i32 %56, %13
  %58 = add nuw nsw i32 %52, 536870911
  %59 = add i32 %58, %54
  %60 = sub i32 %59, %57
  %61 = and i32 %60, 536870911
  %62 = getelementptr inbounds i8, ptr %5, i64 16
  store i32 %61, ptr %62, align 4, !tbaa !5
  %63 = lshr i32 %60, 29
  %64 = getelementptr inbounds i8, ptr %1, i64 20
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = getelementptr inbounds i8, ptr %0, i64 128
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = and i32 %67, %13
  %69 = add nuw nsw i32 %63, 536870911
  %70 = add i32 %69, %65
  %71 = sub i32 %70, %68
  %72 = and i32 %71, 536870911
  %73 = getelementptr inbounds i8, ptr %5, i64 20
  store i32 %72, ptr %73, align 4, !tbaa !5
  %74 = lshr i32 %71, 29
  %75 = getelementptr inbounds i8, ptr %1, i64 24
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = getelementptr inbounds i8, ptr %0, i64 132
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = and i32 %78, %13
  %80 = add nuw nsw i32 %74, 536870911
  %81 = add i32 %80, %76
  %82 = sub i32 %81, %79
  %83 = and i32 %82, 536870911
  %84 = getelementptr inbounds i8, ptr %5, i64 24
  store i32 %83, ptr %84, align 4, !tbaa !5
  %85 = lshr i32 %82, 29
  %86 = getelementptr inbounds i8, ptr %1, i64 28
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = getelementptr inbounds i8, ptr %0, i64 136
  %89 = load i32, ptr %88, align 4, !tbaa !5
  %90 = and i32 %89, %13
  %91 = add nuw nsw i32 %85, 536870911
  %92 = add i32 %91, %87
  %93 = sub i32 %92, %90
  %94 = and i32 %93, 536870911
  %95 = getelementptr inbounds i8, ptr %5, i64 28
  store i32 %94, ptr %95, align 4, !tbaa !5
  %96 = lshr i32 %93, 29
  %97 = getelementptr inbounds i8, ptr %1, i64 32
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = add nuw nsw i32 %96, 16777215
  %100 = add i32 %99, %98
  %101 = getelementptr inbounds i8, ptr %0, i64 140
  %102 = load i32, ptr %101, align 4, !tbaa !5
  %103 = and i32 %102, %13
  %104 = sub i32 %100, %103
  %105 = getelementptr inbounds i8, ptr %5, i64 32
  store i32 %104, ptr %105, align 4, !tbaa !5
  %106 = load i32, ptr %5, align 4, !tbaa !5
  %107 = and i32 %106, 1
  %.not95 = icmp eq i32 %107, 0
  br i1 %.not95, label %108, label %109

108:                                              ; preds = %10
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 442, ptr noundef nonnull @__PRETTY_FUNCTION__.point_multiply) #7
  unreachable

109:                                              ; preds = %10
  %110 = or i32 %21, %11
  %111 = or i32 %32, %110
  %112 = or i32 %43, %111
  %113 = or i32 %54, %112
  %114 = or i32 %65, %113
  %115 = or i32 %76, %114
  %116 = or i32 %87, %115
  %117 = or i32 %98, %116
  %.not96 = icmp eq i32 %117, 0
  br i1 %.not96, label %118, label %119

118:                                              ; preds = %109
  tail call void @point_set_infinity(ptr noundef %3)
  br label %163

119:                                              ; preds = %109
  %120 = getelementptr inbounds i8, ptr %7, i64 504
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %120, ptr noundef nonnull align 4 dereferenceable(72) %2, i64 72, i1 false), !tbaa.struct !9
  call void @point_double(ptr noundef nonnull %0, ptr noundef nonnull %120)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(72) %7, ptr noundef nonnull align 4 dereferenceable(72) %2, i64 72, i1 false), !tbaa.struct !9
  %121 = getelementptr inbounds i8, ptr %7, i64 72
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %121, ptr noundef nonnull align 8 dereferenceable(72) %120, i64 72, i1 false), !tbaa.struct !9
  call void @point_add(ptr noundef nonnull %0, ptr noundef nonnull %7, ptr noundef nonnull %121)
  %122 = getelementptr inbounds i8, ptr %7, i64 144
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(72) %122, ptr noundef nonnull align 8 dereferenceable(72) %120, i64 72, i1 false), !tbaa.struct !9
  call void @point_add(ptr noundef nonnull %0, ptr noundef nonnull %121, ptr noundef nonnull %122)
  %123 = getelementptr inbounds i8, ptr %7, i64 216
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %123, ptr noundef nonnull align 8 dereferenceable(72) %120, i64 72, i1 false), !tbaa.struct !9
  call void @point_add(ptr noundef nonnull %0, ptr noundef nonnull %122, ptr noundef nonnull %123)
  %124 = getelementptr inbounds i8, ptr %7, i64 288
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(72) %124, ptr noundef nonnull align 8 dereferenceable(72) %120, i64 72, i1 false), !tbaa.struct !9
  call void @point_add(ptr noundef nonnull %0, ptr noundef nonnull %123, ptr noundef nonnull %124)
  %125 = getelementptr inbounds i8, ptr %7, i64 360
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %125, ptr noundef nonnull align 8 dereferenceable(72) %120, i64 72, i1 false), !tbaa.struct !9
  call void @point_add(ptr noundef nonnull %0, ptr noundef nonnull %124, ptr noundef nonnull %125)
  %126 = getelementptr inbounds i8, ptr %7, i64 432
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(72) %126, ptr noundef nonnull align 8 dereferenceable(72) %120, i64 72, i1 false), !tbaa.struct !9
  call void @point_add(ptr noundef nonnull %0, ptr noundef nonnull %125, ptr noundef nonnull %126)
  call void @point_add(ptr noundef nonnull %0, ptr noundef nonnull %126, ptr noundef nonnull %120)
  %127 = lshr i32 %104, 24
  %128 = add nsw i32 %127, -1
  %129 = lshr i32 %104, 21
  %130 = lshr i32 %128, 1
  %131 = xor i32 %130, %129
  %132 = and i32 %131, 7
  %133 = zext nneg i32 %132 to i64
  %134 = getelementptr inbounds [8 x %struct.curve_point], ptr %7, i64 0, i64 %133
  call void @curve_to_jacobian(ptr noundef nonnull %134, ptr noundef nonnull %6, ptr noundef nonnull %0)
  %135 = getelementptr inbounds i8, ptr %6, i64 72
  br label %136

136:                                              ; preds = %119, %149
  %.082106 = phi i32 [ %128, %119 ], [ %152, %149 ]
  %.185105 = phi i32 [ 62, %119 ], [ %160, %149 ]
  %.086104 = phi i32 [ 20, %119 ], [ %.187, %149 ]
  %.088103 = phi i32 [ %104, %119 ], [ %.189, %149 ]
  %.090102 = phi ptr [ %105, %119 ], [ %.191, %149 ]
  call void @point_jacobian_double(ptr noundef nonnull %6, ptr noundef %0)
  call void @point_jacobian_double(ptr noundef nonnull %6, ptr noundef %0)
  call void @point_jacobian_double(ptr noundef nonnull %6, ptr noundef %0)
  call void @point_jacobian_double(ptr noundef nonnull %6, ptr noundef %0)
  %137 = icmp slt i32 %.086104, 4
  br i1 %137, label %138, label %146

138:                                              ; preds = %136
  %139 = sub nsw i32 4, %.086104
  %140 = shl i32 %.088103, %139
  %141 = getelementptr inbounds i8, ptr %.090102, i64 -4
  %142 = load i32, ptr %141, align 4, !tbaa !5
  %143 = add nsw i32 %.086104, 25
  %144 = lshr i32 %142, %143
  %145 = or i32 %144, %140
  br label %149

146:                                              ; preds = %136
  %147 = add nsw i32 %.086104, -4
  %148 = lshr i32 %.088103, %147
  br label %149

149:                                              ; preds = %146, %138
  %.191 = phi ptr [ %141, %138 ], [ %.090102, %146 ]
  %.189 = phi i32 [ %142, %138 ], [ %.088103, %146 ]
  %.187 = phi i32 [ %143, %138 ], [ %147, %146 ]
  %.083 = phi i32 [ %145, %138 ], [ %148, %146 ]
  %150 = lshr i32 %.083, 4
  %151 = and i32 %150, 1
  %152 = add nsw i32 %151, -1
  %153 = xor i32 %152, %.083
  %154 = xor i32 %152, %.082106
  %155 = and i32 %154, 1
  call void @bn_cnegate(i32 noundef %155, ptr noundef nonnull %135, ptr noundef %0) #6
  %156 = lshr i32 %153, 1
  %157 = and i32 %156, 7
  %158 = zext nneg i32 %157 to i64
  %159 = getelementptr inbounds [8 x %struct.curve_point], ptr %7, i64 0, i64 %158
  call void @point_jacobian_add(ptr noundef nonnull %159, ptr noundef nonnull %6, ptr noundef %0)
  %160 = add nsw i32 %.185105, -1
  %.not112 = icmp eq i32 %.185105, 0
  br i1 %.not112, label %161, label %136, !llvm.loop !11

161:                                              ; preds = %149
  %162 = and i32 %152, 1
  call void @bn_cnegate(i32 noundef %162, ptr noundef nonnull %135, ptr noundef %0) #6
  call void @jacobian_to_curve(ptr noundef nonnull %6, ptr noundef %3, ptr noundef %0)
  call void @memzero(ptr noundef nonnull %5, i64 noundef 36) #6
  call void @memzero(ptr noundef nonnull %6, i64 noundef 108) #6
  br label %163

163:                                              ; preds = %161, %118
  %.081 = phi i32 [ 0, %161 ], [ 1, %118 ]
  call void @llvm.lifetime.end.p0(i64 576, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 108, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 36, ptr nonnull %5) #6
  br label %164

164:                                              ; preds = %4, %163
  %.1 = phi i32 [ %.081, %163 ], [ 1, %4 ]
  ret i32 %.1
}

declare i32 @bn_is_less(ptr noundef, ptr noundef) local_unnamed_addr #5

declare void @bn_cnegate(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #5

declare void @memzero(ptr noundef, i64 noundef) local_unnamed_addr #5

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { noreturn nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { "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 #6 = { nounwind }
attributes #7 = { noreturn 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{i64 0, i64 36, !10, i64 36, i64 36, !10}
!10 = !{!7, !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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