; LLVM IR from square/subzero :: core/trezor-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.ecdsa_curve = type { %struct.bignum256, %struct.curve_point, %struct.bignum256, %struct.bignum256, i32, %struct.bignum256, [64 x [8 x %struct.curve_point]] }
%struct.curve_point = type { %struct.bignum256, %struct.bignum256 }

@.str.1 = external hidden unnamed_addr constant [75 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [20 x i8], align 1
@__PRETTY_FUNCTION__.scalar_multiply = external hidden unnamed_addr constant [76 x i8], align 1
@scalar_multiply.a = external hidden global %struct.bignum256, align 4
@scalar_multiply.jres = external hidden global %struct.jacobian_curve_point, align 4

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

; 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) #0

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @scalar_multiply(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ecdsa_curve, ptr %16, i32 0, i32 2
  %18 = call i32 @bn_is_less(ptr noundef %15, ptr noundef %17)
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %21

20:                                               ; preds = %3
  br label %22

21:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 546, ptr noundef @__PRETTY_FUNCTION__.scalar_multiply) #4
  unreachable

22:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.bignum256, ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds [9 x i32], ptr %24, i64 0, i64 0
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = and i32 %26, 1
  %28 = sub i32 %27, 1
  store i32 %28, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ecdsa_curve, ptr %29, i32 0, i32 0
  store ptr %30, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 1, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !9
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %69, %22
  %32 = load i32, ptr %8, align 4, !tbaa !9
  %33 = icmp slt i32 %32, 8
  br i1 %33, label %34, label %72

34:                                               ; preds = %31
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.bignum256, ptr %35, i32 0, i32 0
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [9 x i32], ptr %36, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !9
  %41 = load i32, ptr %13, align 4, !tbaa !9
  %42 = or i32 %41, %40
  store i32 %42, ptr %13, align 4, !tbaa !9
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.bignum256, ptr %43, i32 0, i32 0
  %45 = load i32, ptr %8, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [9 x i32], ptr %44, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !9
  %49 = add i32 1073741823, %48
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.ecdsa_curve, ptr %50, i32 0, i32 2
  %52 = getelementptr inbounds %struct.bignum256, ptr %51, i32 0, i32 0
  %53 = load i32, ptr %8, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [9 x i32], ptr %52, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = load i32, ptr %9, align 4, !tbaa !9
  %58 = and i32 %56, %57
  %59 = sub i32 %49, %58
  %60 = load i32, ptr %12, align 4, !tbaa !9
  %61 = add i32 %60, %59
  store i32 %61, ptr %12, align 4, !tbaa !9
  %62 = load i32, ptr %12, align 4, !tbaa !9
  %63 = and i32 %62, 1073741823
  %64 = load i32, ptr %8, align 4, !tbaa !9
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [9 x i32], ptr @scalar_multiply.a, i64 0, i64 %65
  store i32 %63, ptr %66, align 4, !tbaa !9
  %67 = load i32, ptr %12, align 4, !tbaa !9
  %68 = lshr i32 %67, 30
  store i32 %68, ptr %12, align 4, !tbaa !9
  br label %69

69:                                               ; preds = %34
  %70 = load i32, ptr %8, align 4, !tbaa !9
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %8, align 4, !tbaa !9
  br label %31, !llvm.loop !11

72:                                               ; preds = %31
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.bignum256, ptr %73, i32 0, i32 0
  %75 = load i32, ptr %8, align 4, !tbaa !9
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [9 x i32], ptr %74, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !9
  %79 = load i32, ptr %13, align 4, !tbaa !9
  %80 = or i32 %79, %78
  store i32 %80, ptr %13, align 4, !tbaa !9
  %81 = load i32, ptr %12, align 4, !tbaa !9
  %82 = add i32 %81, 65535
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.bignum256, ptr %83, i32 0, i32 0
  %85 = load i32, ptr %8, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [9 x i32], ptr %84, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !9
  %89 = add i32 %82, %88
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.ecdsa_curve, ptr %90, i32 0, i32 2
  %92 = getelementptr inbounds %struct.bignum256, ptr %91, i32 0, i32 0
  %93 = load i32, ptr %8, align 4, !tbaa !9
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [9 x i32], ptr %92, i64 0, i64 %94
  %96 = load i32, ptr %95, align 4, !tbaa !9
  %97 = load i32, ptr %9, align 4, !tbaa !9
  %98 = and i32 %96, %97
  %99 = sub i32 %89, %98
  %100 = load i32, ptr %8, align 4, !tbaa !9
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [9 x i32], ptr @scalar_multiply.a, i64 0, i64 %101
  store i32 %99, ptr %102, align 4, !tbaa !9
  %103 = load i32, ptr @scalar_multiply.a, align 4, !tbaa !9
  %104 = and i32 %103, 1
  %105 = icmp ne i32 %104, 0
  br i1 %105, label %106, label %107

106:                                              ; preds = %72
  br label %108

107:                                              ; preds = %72
  call void @__assert_fail(ptr noundef @.str.5, ptr noundef @.str.1, i32 noundef 569, ptr noundef @__PRETTY_FUNCTION__.scalar_multiply) #4
  unreachable

108:                                              ; preds = %106
  %109 = load i32, ptr %13, align 4, !tbaa !9
  %110 = icmp ne i32 %109, 0
  br i1 %110, label %113, label %111

111:                                              ; preds = %108
  %112 = load ptr, ptr %6, align 8, !tbaa !5
  call void @point_set_infinity(ptr noundef %112)
  store i32 1, ptr %14, align 4
  br label %198

113:                                              ; preds = %108
  %114 = load i32, ptr @scalar_multiply.a, align 4, !tbaa !9
  %115 = and i32 %114, 31
  store i32 %115, ptr %10, align 4, !tbaa !9
  %116 = load i32, ptr %10, align 4, !tbaa !9
  %117 = lshr i32 %116, 4
  %118 = sub i32 %117, 1
  %119 = load i32, ptr %10, align 4, !tbaa !9
  %120 = xor i32 %119, %118
  store i32 %120, ptr %10, align 4, !tbaa !9
  %121 = load i32, ptr %10, align 4, !tbaa !9
  %122 = and i32 %121, 15
  store i32 %122, ptr %10, align 4, !tbaa !9
  %123 = load ptr, ptr %4, align 8, !tbaa !5
  %124 = getelementptr inbounds %struct.ecdsa_curve, ptr %123, i32 0, i32 6
  %125 = getelementptr inbounds [64 x [8 x %struct.curve_point]], ptr %124, i64 0, i64 0
  %126 = load i32, ptr %10, align 4, !tbaa !9
  %127 = lshr i32 %126, 1
  %128 = zext i32 %127 to i64
  %129 = getelementptr inbounds [8 x %struct.curve_point], ptr %125, i64 0, i64 %128
  %130 = load ptr, ptr %11, align 8, !tbaa !5
  call void @curve_to_jacobian(ptr noundef %129, ptr noundef @scalar_multiply.jres, ptr noundef %130)
  store i32 1, ptr %7, align 4, !tbaa !9
  br label %131

131:                                              ; preds = %187, %113
  %132 = load i32, ptr %7, align 4, !tbaa !9
  %133 = icmp slt i32 %132, 64
  br i1 %133, label %134, label %190

134:                                              ; preds = %131
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %135

135:                                              ; preds = %155, %134
  %136 = load i32, ptr %8, align 4, !tbaa !9
  %137 = icmp slt i32 %136, 8
  br i1 %137, label %138, label %158

138:                                              ; preds = %135
  %139 = load i32, ptr %8, align 4, !tbaa !9
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [9 x i32], ptr @scalar_multiply.a, i64 0, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !9
  %143 = lshr i32 %142, 4
  %144 = load i32, ptr %8, align 4, !tbaa !9
  %145 = add nsw i32 %144, 1
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [9 x i32], ptr @scalar_multiply.a, i64 0, i64 %146
  %148 = load i32, ptr %147, align 4, !tbaa !9
  %149 = and i32 %148, 15
  %150 = shl i32 %149, 26
  %151 = or i32 %143, %150
  %152 = load i32, ptr %8, align 4, !tbaa !9
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [9 x i32], ptr @scalar_multiply.a, i64 0, i64 %153
  store i32 %151, ptr %154, align 4, !tbaa !9
  br label %155

155:                                              ; preds = %138
  %156 = load i32, ptr %8, align 4, !tbaa !9
  %157 = add nsw i32 %156, 1
  store i32 %157, ptr %8, align 4, !tbaa !9
  br label %135, !llvm.loop !13

158:                                              ; preds = %135
  %159 = load i32, ptr %8, align 4, !tbaa !9
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [9 x i32], ptr @scalar_multiply.a, i64 0, i64 %160
  %162 = load i32, ptr %161, align 4, !tbaa !9
  %163 = lshr i32 %162, 4
  store i32 %163, ptr %161, align 4, !tbaa !9
  %164 = load i32, ptr @scalar_multiply.a, align 4, !tbaa !9
  %165 = and i32 %164, 31
  store i32 %165, ptr %10, align 4, !tbaa !9
  %166 = load i32, ptr %10, align 4, !tbaa !9
  %167 = lshr i32 %166, 4
  %168 = sub i32 %167, 1
  %169 = load i32, ptr %10, align 4, !tbaa !9
  %170 = xor i32 %169, %168
  store i32 %170, ptr %10, align 4, !tbaa !9
  %171 = load i32, ptr %10, align 4, !tbaa !9
  %172 = and i32 %171, 15
  store i32 %172, ptr %10, align 4, !tbaa !9
  %173 = load i32, ptr %10, align 4, !tbaa !9
  %174 = and i32 %173, 1
  %175 = sub i32 %174, 1
  %176 = load ptr, ptr %11, align 8, !tbaa !5
  call void @conditional_negate(i32 noundef %175, ptr noundef getelementptr inbounds (%struct.jacobian_curve_point, ptr @scalar_multiply.jres, i32 0, i32 1), ptr noundef %176)
  %177 = load ptr, ptr %4, align 8, !tbaa !5
  %178 = getelementptr inbounds %struct.ecdsa_curve, ptr %177, i32 0, i32 6
  %179 = load i32, ptr %7, align 4, !tbaa !9
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds [64 x [8 x %struct.curve_point]], ptr %178, i64 0, i64 %180
  %182 = load i32, ptr %10, align 4, !tbaa !9
  %183 = lshr i32 %182, 1
  %184 = zext i32 %183 to i64
  %185 = getelementptr inbounds [8 x %struct.curve_point], ptr %181, i64 0, i64 %184
  %186 = load ptr, ptr %4, align 8, !tbaa !5
  call void @point_jacobian_add(ptr noundef %185, ptr noundef @scalar_multiply.jres, ptr noundef %186)
  br label %187

187:                                              ; preds = %158
  %188 = load i32, ptr %7, align 4, !tbaa !9
  %189 = add nsw i32 %188, 1
  store i32 %189, ptr %7, align 4, !tbaa !9
  br label %131, !llvm.loop !14

190:                                              ; preds = %131
  %191 = load i32, ptr @scalar_multiply.a, align 4, !tbaa !9
  %192 = lshr i32 %191, 4
  %193 = and i32 %192, 1
  %194 = sub i32 %193, 1
  %195 = load ptr, ptr %11, align 8, !tbaa !5
  call void @conditional_negate(i32 noundef %194, ptr noundef getelementptr inbounds (%struct.jacobian_curve_point, ptr @scalar_multiply.jres, i32 0, i32 1), ptr noundef %195)
  %196 = load ptr, ptr %6, align 8, !tbaa !5
  %197 = load ptr, ptr %11, align 8, !tbaa !5
  call void @jacobian_to_curve(ptr noundef @scalar_multiply.jres, ptr noundef %196, ptr noundef %197)
  call void @memzero(ptr noundef @scalar_multiply.a, i64 noundef 36)
  call void @memzero(ptr noundef @scalar_multiply.jres, i64 noundef 108)
  store i32 0, ptr %14, align 4
  br label %198

198:                                              ; preds = %190, %111
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  %199 = load i32, ptr %14, align 4
  switch i32 %199, label %201 [
    i32 0, label %200
    i32 1, label %200
  ]

200:                                              ; preds = %198, %198
  ret void

201:                                              ; preds = %198
  unreachable
}

attributes #0 = { nocallback nofree nosync 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 = { 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 #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { noreturn nounwind }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !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 [75 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [20 x i8], align 1
@__PRETTY_FUNCTION__.scalar_multiply = external hidden unnamed_addr constant [76 x i8], align 1
@scalar_multiply.a = external hidden global %struct.bignum256, align 4
@scalar_multiply.jres = external hidden global %struct.jacobian_curve_point, align 4

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

; Function Attrs: nounwind uwtable
declare dso_local void @conditional_negate(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @scalar_multiply(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 108
  %5 = tail call i32 @bn_is_less(ptr noundef %1, ptr noundef nonnull %4) #3
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %6, label %7

6:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 546, ptr noundef nonnull @__PRETTY_FUNCTION__.scalar_multiply) #4
  unreachable

7:                                                ; preds = %3
  %8 = load i32, ptr %1, align 4, !tbaa !5
  %9 = and i32 %8, 1
  %10 = add nsw i32 %9, -1
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = and i32 %11, %10
  %13 = add i32 %8, 1073741824
  %14 = sub i32 %13, %12
  %15 = and i32 %14, 1073741823
  store i32 %15, ptr @scalar_multiply.a, align 4, !tbaa !5
  %16 = lshr i32 %14, 30
  %17 = getelementptr inbounds i8, ptr %1, i64 4
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %0, i64 112
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = and i32 %20, %10
  %22 = add nuw nsw i32 %16, 1073741823
  %23 = add i32 %22, %18
  %24 = sub i32 %23, %21
  %25 = and i32 %24, 1073741823
  store i32 %25, ptr getelementptr inbounds (i8, ptr @scalar_multiply.a, i64 4), align 4, !tbaa !5
  %26 = lshr i32 %24, 30
  %27 = getelementptr inbounds i8, ptr %1, i64 8
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %0, i64 116
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = and i32 %30, %10
  %32 = add nuw nsw i32 %26, 1073741823
  %33 = add i32 %32, %28
  %34 = sub i32 %33, %31
  %35 = and i32 %34, 1073741823
  store i32 %35, ptr getelementptr inbounds (i8, ptr @scalar_multiply.a, i64 8), align 4, !tbaa !5
  %36 = lshr i32 %34, 30
  %37 = getelementptr inbounds i8, ptr %1, i64 12
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %0, i64 120
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = and i32 %40, %10
  %42 = add nuw nsw i32 %36, 1073741823
  %43 = add i32 %42, %38
  %44 = sub i32 %43, %41
  %45 = and i32 %44, 1073741823
  store i32 %45, ptr getelementptr inbounds (i8, ptr @scalar_multiply.a, i64 12), align 4, !tbaa !5
  %46 = lshr i32 %44, 30
  %47 = getelementptr inbounds i8, ptr %1, i64 16
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %0, i64 124
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = and i32 %50, %10
  %52 = add nuw nsw i32 %46, 1073741823
  %53 = add i32 %52, %48
  %54 = sub i32 %53, %51
  %55 = and i32 %54, 1073741823
  store i32 %55, ptr getelementptr inbounds (i8, ptr @scalar_multiply.a, i64 16), align 4, !tbaa !5
  %56 = lshr i32 %54, 30
  %57 = getelementptr inbounds i8, ptr %1, i64 20
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = getelementptr inbounds i8, ptr %0, i64 128
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = and i32 %60, %10
  %62 = add nuw nsw i32 %56, 1073741823
  %63 = add i32 %62, %58
  %64 = sub i32 %63, %61
  %65 = and i32 %64, 1073741823
  store i32 %65, ptr getelementptr inbounds (i8, ptr @scalar_multiply.a, i64 20), align 4, !tbaa !5
  %66 = lshr i32 %64, 30
  %67 = getelementptr inbounds i8, ptr %1, i64 24
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = getelementptr inbounds i8, ptr %0, i64 132
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = and i32 %70, %10
  %72 = add nuw nsw i32 %66, 1073741823
  %73 = add i32 %72, %68
  %74 = sub i32 %73, %71
  %75 = and i32 %74, 1073741823
  store i32 %75, ptr getelementptr inbounds (i8, ptr @scalar_multiply.a, i64 24), align 4, !tbaa !5
  %76 = lshr i32 %74, 30
  %77 = getelementptr inbounds i8, ptr %1, i64 28
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = getelementptr inbounds i8, ptr %0, i64 136
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = and i32 %80, %10
  %82 = add nuw nsw i32 %76, 1073741823
  %83 = add i32 %82, %78
  %84 = sub i32 %83, %81
  %85 = and i32 %84, 1073741823
  store i32 %85, ptr getelementptr inbounds (i8, ptr @scalar_multiply.a, i64 28), align 4, !tbaa !5
  %86 = lshr i32 %84, 30
  %87 = getelementptr inbounds i8, ptr %1, i64 32
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = add nuw nsw i32 %86, 65535
  %90 = add i32 %89, %88
  %91 = getelementptr inbounds i8, ptr %0, i64 140
  %92 = load i32, ptr %91, align 4, !tbaa !5
  %93 = and i32 %92, %10
  %94 = sub i32 %90, %93
  store i32 %94, ptr getelementptr inbounds (i8, ptr @scalar_multiply.a, i64 32), align 4, !tbaa !5
  %95 = and i32 %14, 1
  %.not58 = icmp eq i32 %95, 0
  br i1 %.not58, label %96, label %97

96:                                               ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.1, i32 noundef 569, ptr noundef nonnull @__PRETTY_FUNCTION__.scalar_multiply) #4
  unreachable

97:                                               ; preds = %7
  %98 = or i32 %18, %8
  %99 = or i32 %28, %98
  %100 = or i32 %38, %99
  %101 = or i32 %48, %100
  %102 = or i32 %58, %101
  %103 = or i32 %68, %102
  %104 = or i32 %78, %103
  %105 = or i32 %88, %104
  %.not59 = icmp eq i32 %105, 0
  br i1 %.not59, label %106, label %107

106:                                              ; preds = %97
  tail call void @point_set_infinity(ptr noundef %2)
  br label %149

107:                                              ; preds = %97
  %108 = lshr i32 %14, 4
  %109 = and i32 %108, 1
  %110 = add nuw nsw i32 %109, 15
  %111 = xor i32 %110, %14
  %112 = getelementptr inbounds i8, ptr %0, i64 220
  %113 = lshr i32 %111, 1
  %114 = and i32 %113, 7
  %115 = zext nneg i32 %114 to i64
  %116 = getelementptr inbounds [8 x %struct.curve_point], ptr %112, i64 0, i64 %115
  tail call void @curve_to_jacobian(ptr noundef nonnull %116, ptr noundef nonnull @scalar_multiply.jres, ptr noundef nonnull %0)
  br label %.preheader

.preheader:                                       ; preds = %107, %.preheader
  %indvars.iv = phi i64 [ 1, %107 ], [ %indvars.iv.next, %.preheader ]
  %117 = load i32, ptr @scalar_multiply.a, align 4, !tbaa !5
  %118 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @scalar_multiply.a, i64 4), align 4, !tbaa !5
  %119 = insertelement <4 x i32> poison, i32 %117, i64 0
  %120 = shufflevector <4 x i32> %119, <4 x i32> %118, <4 x i32> <i32 0, i32 4, i32 5, i32 6>
  %121 = lshr <4 x i32> %120, <i32 4, i32 4, i32 4, i32 4>
  %122 = shl <4 x i32> %118, <i32 26, i32 26, i32 26, i32 26>
  %123 = and <4 x i32> %122, <i32 1006632960, i32 1006632960, i32 1006632960, i32 1006632960>
  %124 = or <4 x i32> %123, %121
  store <4 x i32> %124, ptr @scalar_multiply.a, align 4, !tbaa !5
  %125 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @scalar_multiply.a, i64 20), align 4, !tbaa !5
  %126 = shufflevector <4 x i32> %118, <4 x i32> %125, <4 x i32> <i32 3, i32 4, i32 5, i32 6>
  %127 = lshr <4 x i32> %126, <i32 4, i32 4, i32 4, i32 4>
  %128 = shl <4 x i32> %125, <i32 26, i32 26, i32 26, i32 26>
  %129 = and <4 x i32> %128, <i32 1006632960, i32 1006632960, i32 1006632960, i32 1006632960>
  %130 = or <4 x i32> %129, %127
  store <4 x i32> %130, ptr getelementptr inbounds (i8, ptr @scalar_multiply.a, i64 16), align 4, !tbaa !5
  %131 = extractelement <4 x i32> %125, i64 3
  %132 = lshr i32 %131, 4
  store i32 %132, ptr getelementptr inbounds (i8, ptr @scalar_multiply.a, i64 32), align 4, !tbaa !5
  %133 = lshr i32 %117, 8
  %134 = and i32 %133, 1
  %135 = add nuw nsw i32 %134, 15
  %136 = extractelement <4 x i32> %124, i64 0
  %137 = xor i32 %135, %136
  %138 = and i32 %137, 1
  %139 = add nsw i32 %138, -1
  tail call void @conditional_negate(i32 noundef %139, ptr noundef nonnull getelementptr inbounds (i8, ptr @scalar_multiply.jres, i64 36), ptr noundef %0)
  %140 = lshr i32 %137, 1
  %141 = and i32 %140, 7
  %142 = zext nneg i32 %141 to i64
  %143 = getelementptr inbounds [64 x [8 x %struct.curve_point]], ptr %112, i64 0, i64 %indvars.iv, i64 %142
  tail call void @point_jacobian_add(ptr noundef nonnull %143, ptr noundef nonnull @scalar_multiply.jres, ptr noundef %0)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 64
  br i1 %exitcond.not, label %144, label %.preheader, !llvm.loop !9

144:                                              ; preds = %.preheader
  %145 = load i32, ptr @scalar_multiply.a, align 4, !tbaa !5
  %146 = lshr i32 %145, 4
  %147 = and i32 %146, 1
  %148 = add nsw i32 %147, -1
  tail call void @conditional_negate(i32 noundef %148, ptr noundef nonnull getelementptr inbounds (i8, ptr @scalar_multiply.jres, i64 36), ptr noundef %0)
  tail call void @jacobian_to_curve(ptr noundef nonnull @scalar_multiply.jres, ptr noundef %2, ptr noundef %0)
  tail call void @memzero(ptr noundef nonnull @scalar_multiply.a, i64 noundef 36) #3
  tail call void @memzero(ptr noundef nonnull @scalar_multiply.jres, i64 noundef 108) #3
  br label %149

149:                                              ; preds = %144, %106
  ret void
}

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 = { 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 #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 }
attributes #4 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass