Nuitka
The Python compiler
Loading...
Searching...
No Matches
HelpersOperationBinaryMult.c
1// Copyright 2025, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
2
3/* WARNING, this code is GENERATED. Modify the template HelperOperationBinary.c.j2 instead! */
4
5/* This file is included from another C file, help IDEs to still parse it on its own. */
6#ifdef __IDE_ONLY__
7#include "nuitka/prelude.h"
8#endif
9
10#include "HelpersOperationBinaryMultUtils.c"
11/* C helpers for type specialized "*" (MULT) operations */
12
13#if PYTHON_VERSION < 0x300
14/* Code referring to "INT" corresponds to Python2 'int' and "INT" to Python2 'int'. */
15static PyObject *_BINARY_OPERATION_MULT_OBJECT_INT_INT(PyObject *operand1, PyObject *operand2) {
16 CHECK_OBJECT(operand1);
17 assert(PyInt_CheckExact(operand1));
18 CHECK_OBJECT(operand2);
19 assert(PyInt_CheckExact(operand2));
20
21 PyObject *result;
22
23 // Not every code path will make use of all possible results.
24#if defined(_MSC_VER)
25#pragma warning(push)
26#pragma warning(disable : 4101)
27#endif
28 NUITKA_MAY_BE_UNUSED bool cbool_result;
29 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
30 NUITKA_MAY_BE_UNUSED long clong_result;
31 NUITKA_MAY_BE_UNUSED double cfloat_result;
32#if defined(_MSC_VER)
33#pragma warning(pop)
34#endif
35
36 CHECK_OBJECT(operand1);
37 assert(PyInt_CheckExact(operand1));
38 CHECK_OBJECT(operand2);
39 assert(PyInt_CheckExact(operand2));
40
41 const long a = PyInt_AS_LONG(operand1);
42 const long b = PyInt_AS_LONG(operand2);
43
44 const long longprod = (long)((unsigned long)a * b);
45 const double doubleprod = (double)a * (double)b;
46 const double doubled_longprod = (double)longprod;
47
48 if (likely(doubled_longprod == doubleprod)) {
49 clong_result = longprod;
50 goto exit_result_ok_clong;
51 } else {
52 const double diff = doubled_longprod - doubleprod;
53 const double absdiff = diff >= 0.0 ? diff : -diff;
54 const double absprod = doubleprod >= 0.0 ? doubleprod : -doubleprod;
55
56 if (likely(32.0 * absdiff <= absprod)) {
57 clong_result = longprod;
58 goto exit_result_ok_clong;
59 }
60 }
61
62 {
63 PyObject *operand1_object = operand1;
64 PyObject *operand2_object = operand2;
65
66 PyObject *r = PyLong_Type.tp_as_number->nb_multiply(operand1_object, operand2_object);
67 assert(r != Py_NotImplemented);
68
69 obj_result = r;
70 goto exit_result_object;
71 }
72
73exit_result_ok_clong:
74 result = Nuitka_PyInt_FromLong(clong_result);
75 goto exit_result_ok;
76
77exit_result_object:
78 if (unlikely(obj_result == NULL)) {
79 goto exit_result_exception;
80 }
81 result = obj_result;
82 goto exit_result_ok;
83
84exit_result_ok:
85 return result;
86
87exit_result_exception:
88 return NULL;
89}
90
91PyObject *BINARY_OPERATION_MULT_OBJECT_INT_INT(PyObject *operand1, PyObject *operand2) {
92 return _BINARY_OPERATION_MULT_OBJECT_INT_INT(operand1, operand2);
93}
94#endif
95
96#if PYTHON_VERSION < 0x300
97/* Code referring to "OBJECT" corresponds to any Python object and "INT" to Python2 'int'. */
98static HEDLEY_NEVER_INLINE PyObject *__BINARY_OPERATION_MULT_OBJECT_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
99 PyTypeObject *type1 = Py_TYPE(operand1);
100
101#if defined(_MSC_VER)
102#pragma warning(push)
103#pragma warning(disable : 4101)
104#endif
105 NUITKA_MAY_BE_UNUSED bool cbool_result;
106 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
107#if defined(_MSC_VER)
108#pragma warning(pop)
109#endif
110
111 binaryfunc slot1 =
112 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_multiply : NULL;
113 binaryfunc slot2 = NULL;
114
115 if (!(type1 == &PyInt_Type)) {
116 // Different types, need to consider second value slot.
117
118 slot2 = PyInt_Type.tp_as_number->nb_multiply;
119
120 if (slot1 == slot2) {
121 slot2 = NULL;
122 }
123 }
124
125 if (slot1 != NULL) {
126 PyObject *x = slot1(operand1, operand2);
127
128 if (x != Py_NotImplemented) {
129 obj_result = x;
130 goto exit_binary_result_object;
131 }
132
133 Py_DECREF_IMMORTAL(x);
134 }
135
136 if (slot2 != NULL) {
137 PyObject *x = slot2(operand1, operand2);
138
139 if (x != Py_NotImplemented) {
140 obj_result = x;
141 goto exit_binary_result_object;
142 }
143
144 Py_DECREF_IMMORTAL(x);
145 }
146
147#if PYTHON_VERSION < 0x300
148 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
149 coercion c1 =
150 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
151
152 if (c1 != NULL) {
153 PyObject *coerced1 = operand1;
154 PyObject *coerced2 = operand2;
155
156 int err = c1(&coerced1, &coerced2);
157
158 if (unlikely(err < 0)) {
159 goto exit_binary_exception;
160 }
161
162 if (err == 0) {
163 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
164
165 if (likely(mv == NULL)) {
166 binaryfunc slot = mv->nb_multiply;
167
168 if (likely(slot != NULL)) {
169 PyObject *x = slot(coerced1, coerced2);
170
171 Py_DECREF(coerced1);
172 Py_DECREF(coerced2);
173
174 obj_result = x;
175 goto exit_binary_result_object;
176 }
177 }
178
179 // nb_coerce took a reference.
180 Py_DECREF(coerced1);
181 Py_DECREF(coerced2);
182 }
183 }
184 coercion c2 = PyInt_Type.tp_as_number->nb_coerce;
185
186 if (c2 != NULL) {
187 PyObject *coerced1 = operand1;
188 PyObject *coerced2 = operand2;
189
190 int err = c2(&coerced2, &coerced1);
191
192 if (unlikely(err < 0)) {
193 goto exit_binary_exception;
194 }
195
196 if (err == 0) {
197 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
198
199 if (likely(mv == NULL)) {
200 binaryfunc slot = mv->nb_multiply;
201
202 if (likely(slot != NULL)) {
203 PyObject *x = slot(coerced1, coerced2);
204
205 Py_DECREF(coerced1);
206 Py_DECREF(coerced2);
207
208 obj_result = x;
209 goto exit_binary_result_object;
210 }
211 }
212
213 // nb_coerce took a reference.
214 Py_DECREF(coerced1);
215 Py_DECREF(coerced2);
216 }
217 }
218 }
219#endif
220
221 {
222 // Special case for "+" and "*", also works as sequence concat/repeat.
223 ssizeargfunc sq_slot = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_repeat : NULL;
224
225 if (sq_slot != NULL) {
226 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand1, operand2);
227
228 obj_result = result;
229 goto exit_binary_result_object;
230 }
231 }
232 // No sequence repeat slot sq_repeat available for this type.
233
234 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: '%s' and 'int'", type1->tp_name);
235 goto exit_binary_exception;
236
237exit_binary_result_object:
238 return obj_result;
239
240exit_binary_exception:
241 return NULL;
242}
243static PyObject *_BINARY_OPERATION_MULT_OBJECT_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
244 CHECK_OBJECT(operand1);
245 CHECK_OBJECT(operand2);
246 assert(PyInt_CheckExact(operand2));
247
248 PyTypeObject *type1 = Py_TYPE(operand1);
249
250 if (type1 == &PyInt_Type) {
251 PyObject *result;
252
253 // return _BINARY_OPERATION_MULT_OBJECT_INT_INT(operand1, operand2);
254
255 // Not every code path will make use of all possible results.
256#if defined(_MSC_VER)
257#pragma warning(push)
258#pragma warning(disable : 4101)
259#endif
260 NUITKA_MAY_BE_UNUSED bool cbool_result;
261 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
262 NUITKA_MAY_BE_UNUSED long clong_result;
263 NUITKA_MAY_BE_UNUSED double cfloat_result;
264#if defined(_MSC_VER)
265#pragma warning(pop)
266#endif
267
268 CHECK_OBJECT(operand1);
269 assert(PyInt_CheckExact(operand1));
270 CHECK_OBJECT(operand2);
271 assert(PyInt_CheckExact(operand2));
272
273 const long a = PyInt_AS_LONG(operand1);
274 const long b = PyInt_AS_LONG(operand2);
275
276 const long longprod = (long)((unsigned long)a * b);
277 const double doubleprod = (double)a * (double)b;
278 const double doubled_longprod = (double)longprod;
279
280 if (likely(doubled_longprod == doubleprod)) {
281 clong_result = longprod;
282 goto exit_result_ok_clong;
283 } else {
284 const double diff = doubled_longprod - doubleprod;
285 const double absdiff = diff >= 0.0 ? diff : -diff;
286 const double absprod = doubleprod >= 0.0 ? doubleprod : -doubleprod;
287
288 if (likely(32.0 * absdiff <= absprod)) {
289 clong_result = longprod;
290 goto exit_result_ok_clong;
291 }
292 }
293
294 {
295 PyObject *operand1_object = operand1;
296 PyObject *operand2_object = operand2;
297
298 PyObject *r = PyLong_Type.tp_as_number->nb_multiply(operand1_object, operand2_object);
299 assert(r != Py_NotImplemented);
300
301 obj_result = r;
302 goto exit_result_object;
303 }
304
305 exit_result_ok_clong:
306 result = Nuitka_PyInt_FromLong(clong_result);
307 goto exit_result_ok;
308
309 exit_result_object:
310 if (unlikely(obj_result == NULL)) {
311 goto exit_result_exception;
312 }
313 result = obj_result;
314 goto exit_result_ok;
315
316 exit_result_ok:
317 return result;
318
319 exit_result_exception:
320 return NULL;
321 }
322
323 return __BINARY_OPERATION_MULT_OBJECT_OBJECT_INT(operand1, operand2);
324}
325
326PyObject *BINARY_OPERATION_MULT_OBJECT_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
327 return _BINARY_OPERATION_MULT_OBJECT_OBJECT_INT(operand1, operand2);
328}
329#endif
330
331#if PYTHON_VERSION < 0x300
332/* Code referring to "INT" corresponds to Python2 'int' and "OBJECT" to any Python object. */
333static HEDLEY_NEVER_INLINE PyObject *__BINARY_OPERATION_MULT_OBJECT_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
334 PyTypeObject *type2 = Py_TYPE(operand2);
335
336#if defined(_MSC_VER)
337#pragma warning(push)
338#pragma warning(disable : 4101)
339#endif
340 NUITKA_MAY_BE_UNUSED bool cbool_result;
341 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
342#if defined(_MSC_VER)
343#pragma warning(pop)
344#endif
345
346 binaryfunc slot1 = PyInt_Type.tp_as_number->nb_multiply;
347 binaryfunc slot2 = NULL;
348
349 if (!(&PyInt_Type == type2)) {
350 // Different types, need to consider second value slot.
351
352 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_multiply : NULL;
353
354 if (slot1 == slot2) {
355 slot2 = NULL;
356 }
357 }
358
359 if (slot1 != NULL) {
360 if (slot2 != NULL) {
361 if (Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
362 PyObject *x = slot2(operand1, operand2);
363
364 if (x != Py_NotImplemented) {
365 obj_result = x;
366 goto exit_binary_result_object;
367 }
368
369 Py_DECREF_IMMORTAL(x);
370 slot2 = NULL;
371 }
372 }
373
374 PyObject *x = slot1(operand1, operand2);
375
376 if (x != Py_NotImplemented) {
377 obj_result = x;
378 goto exit_binary_result_object;
379 }
380
381 Py_DECREF_IMMORTAL(x);
382 }
383
384 if (slot2 != NULL) {
385 PyObject *x = slot2(operand1, operand2);
386
387 if (x != Py_NotImplemented) {
388 obj_result = x;
389 goto exit_binary_result_object;
390 }
391
392 Py_DECREF_IMMORTAL(x);
393 }
394
395#if PYTHON_VERSION < 0x300
396 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
397 coercion c1 = PyInt_Type.tp_as_number->nb_coerce;
398
399 if (c1 != NULL) {
400 PyObject *coerced1 = operand1;
401 PyObject *coerced2 = operand2;
402
403 int err = c1(&coerced1, &coerced2);
404
405 if (unlikely(err < 0)) {
406 goto exit_binary_exception;
407 }
408
409 if (err == 0) {
410 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
411
412 if (likely(mv == NULL)) {
413 binaryfunc slot = mv->nb_multiply;
414
415 if (likely(slot != NULL)) {
416 PyObject *x = slot(coerced1, coerced2);
417
418 Py_DECREF(coerced1);
419 Py_DECREF(coerced2);
420
421 obj_result = x;
422 goto exit_binary_result_object;
423 }
424 }
425
426 // nb_coerce took a reference.
427 Py_DECREF(coerced1);
428 Py_DECREF(coerced2);
429 }
430 }
431 coercion c2 =
432 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
433
434 if (c2 != NULL) {
435 PyObject *coerced1 = operand1;
436 PyObject *coerced2 = operand2;
437
438 int err = c2(&coerced2, &coerced1);
439
440 if (unlikely(err < 0)) {
441 goto exit_binary_exception;
442 }
443
444 if (err == 0) {
445 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
446
447 if (likely(mv == NULL)) {
448 binaryfunc slot = mv->nb_multiply;
449
450 if (likely(slot != NULL)) {
451 PyObject *x = slot(coerced1, coerced2);
452
453 Py_DECREF(coerced1);
454 Py_DECREF(coerced2);
455
456 obj_result = x;
457 goto exit_binary_result_object;
458 }
459 }
460
461 // nb_coerce took a reference.
462 Py_DECREF(coerced1);
463 Py_DECREF(coerced2);
464 }
465 }
466 }
467#endif
468
469 {
470 // No sequence repeat slot sq_repeat available for this type.
471 }
472 // Special case for "*", also work with sequence repeat from right argument.
473 {
474 ssizeargfunc sq_slot = type2->tp_as_sequence != NULL ? type2->tp_as_sequence->sq_repeat : NULL;
475
476 if (sq_slot != NULL) {
477 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand2, operand1);
478
479 obj_result = result;
480 goto exit_binary_result_object;
481 }
482 }
483
484 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: 'int' and '%s'", type2->tp_name);
485 goto exit_binary_exception;
486
487exit_binary_result_object:
488 return obj_result;
489
490exit_binary_exception:
491 return NULL;
492}
493static PyObject *_BINARY_OPERATION_MULT_OBJECT_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
494 CHECK_OBJECT(operand1);
495 assert(PyInt_CheckExact(operand1));
496 CHECK_OBJECT(operand2);
497
498 PyTypeObject *type2 = Py_TYPE(operand2);
499
500 if (&PyInt_Type == type2) {
501 PyObject *result;
502
503 // return _BINARY_OPERATION_MULT_OBJECT_INT_INT(operand1, operand2);
504
505 // Not every code path will make use of all possible results.
506#if defined(_MSC_VER)
507#pragma warning(push)
508#pragma warning(disable : 4101)
509#endif
510 NUITKA_MAY_BE_UNUSED bool cbool_result;
511 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
512 NUITKA_MAY_BE_UNUSED long clong_result;
513 NUITKA_MAY_BE_UNUSED double cfloat_result;
514#if defined(_MSC_VER)
515#pragma warning(pop)
516#endif
517
518 CHECK_OBJECT(operand1);
519 assert(PyInt_CheckExact(operand1));
520 CHECK_OBJECT(operand2);
521 assert(PyInt_CheckExact(operand2));
522
523 const long a = PyInt_AS_LONG(operand1);
524 const long b = PyInt_AS_LONG(operand2);
525
526 const long longprod = (long)((unsigned long)a * b);
527 const double doubleprod = (double)a * (double)b;
528 const double doubled_longprod = (double)longprod;
529
530 if (likely(doubled_longprod == doubleprod)) {
531 clong_result = longprod;
532 goto exit_result_ok_clong;
533 } else {
534 const double diff = doubled_longprod - doubleprod;
535 const double absdiff = diff >= 0.0 ? diff : -diff;
536 const double absprod = doubleprod >= 0.0 ? doubleprod : -doubleprod;
537
538 if (likely(32.0 * absdiff <= absprod)) {
539 clong_result = longprod;
540 goto exit_result_ok_clong;
541 }
542 }
543
544 {
545 PyObject *operand1_object = operand1;
546 PyObject *operand2_object = operand2;
547
548 PyObject *r = PyLong_Type.tp_as_number->nb_multiply(operand1_object, operand2_object);
549 assert(r != Py_NotImplemented);
550
551 obj_result = r;
552 goto exit_result_object;
553 }
554
555 exit_result_ok_clong:
556 result = Nuitka_PyInt_FromLong(clong_result);
557 goto exit_result_ok;
558
559 exit_result_object:
560 if (unlikely(obj_result == NULL)) {
561 goto exit_result_exception;
562 }
563 result = obj_result;
564 goto exit_result_ok;
565
566 exit_result_ok:
567 return result;
568
569 exit_result_exception:
570 return NULL;
571 }
572
573 return __BINARY_OPERATION_MULT_OBJECT_INT_OBJECT(operand1, operand2);
574}
575
576PyObject *BINARY_OPERATION_MULT_OBJECT_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
577 return _BINARY_OPERATION_MULT_OBJECT_INT_OBJECT(operand1, operand2);
578}
579#endif
580
581#if PYTHON_VERSION < 0x300
582/* Code referring to "INT" corresponds to Python2 'int' and "INT" to Python2 'int'. */
583static nuitka_bool _BINARY_OPERATION_MULT_NBOOL_INT_INT(PyObject *operand1, PyObject *operand2) {
584 CHECK_OBJECT(operand1);
585 assert(PyInt_CheckExact(operand1));
586 CHECK_OBJECT(operand2);
587 assert(PyInt_CheckExact(operand2));
588
589 nuitka_bool result;
590
591 // Not every code path will make use of all possible results.
592#if defined(_MSC_VER)
593#pragma warning(push)
594#pragma warning(disable : 4101)
595#endif
596 NUITKA_MAY_BE_UNUSED bool cbool_result;
597 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
598 NUITKA_MAY_BE_UNUSED long clong_result;
599 NUITKA_MAY_BE_UNUSED double cfloat_result;
600#if defined(_MSC_VER)
601#pragma warning(pop)
602#endif
603
604 CHECK_OBJECT(operand1);
605 assert(PyInt_CheckExact(operand1));
606 CHECK_OBJECT(operand2);
607 assert(PyInt_CheckExact(operand2));
608
609 const long a = PyInt_AS_LONG(operand1);
610 const long b = PyInt_AS_LONG(operand2);
611
612 const long longprod = (long)((unsigned long)a * b);
613 const double doubleprod = (double)a * (double)b;
614 const double doubled_longprod = (double)longprod;
615
616 if (likely(doubled_longprod == doubleprod)) {
617 clong_result = longprod;
618 goto exit_result_ok_clong;
619 } else {
620 const double diff = doubled_longprod - doubleprod;
621 const double absdiff = diff >= 0.0 ? diff : -diff;
622 const double absprod = doubleprod >= 0.0 ? doubleprod : -doubleprod;
623
624 if (likely(32.0 * absdiff <= absprod)) {
625 clong_result = longprod;
626 goto exit_result_ok_clong;
627 }
628 }
629
630 {
631 PyObject *operand1_object = operand1;
632 PyObject *operand2_object = operand2;
633
634 PyObject *r = PyLong_Type.tp_as_number->nb_multiply(operand1_object, operand2_object);
635 assert(r != Py_NotImplemented);
636
637 obj_result = r;
638 goto exit_result_object;
639 }
640
641exit_result_ok_clong:
642 result = clong_result != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
643 goto exit_result_ok;
644
645exit_result_object:
646 if (unlikely(obj_result == NULL)) {
647 goto exit_result_exception;
648 }
649 result = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
650 Py_DECREF(obj_result);
651 goto exit_result_ok;
652
653exit_result_ok:
654 return result;
655
656exit_result_exception:
657 return NUITKA_BOOL_EXCEPTION;
658}
659
660nuitka_bool BINARY_OPERATION_MULT_NBOOL_INT_INT(PyObject *operand1, PyObject *operand2) {
661 return _BINARY_OPERATION_MULT_NBOOL_INT_INT(operand1, operand2);
662}
663#endif
664
665#if PYTHON_VERSION < 0x300
666/* Code referring to "OBJECT" corresponds to any Python object and "INT" to Python2 'int'. */
667static HEDLEY_NEVER_INLINE nuitka_bool __BINARY_OPERATION_MULT_NBOOL_OBJECT_INT(PyObject *operand1,
668 PyObject *operand2) {
669 PyTypeObject *type1 = Py_TYPE(operand1);
670
671#if defined(_MSC_VER)
672#pragma warning(push)
673#pragma warning(disable : 4101)
674#endif
675 NUITKA_MAY_BE_UNUSED bool cbool_result;
676 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
677#if defined(_MSC_VER)
678#pragma warning(pop)
679#endif
680
681 binaryfunc slot1 =
682 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_multiply : NULL;
683 binaryfunc slot2 = NULL;
684
685 if (!(type1 == &PyInt_Type)) {
686 // Different types, need to consider second value slot.
687
688 slot2 = PyInt_Type.tp_as_number->nb_multiply;
689
690 if (slot1 == slot2) {
691 slot2 = NULL;
692 }
693 }
694
695 if (slot1 != NULL) {
696 PyObject *x = slot1(operand1, operand2);
697
698 if (x != Py_NotImplemented) {
699 obj_result = x;
700 goto exit_binary_result_object;
701 }
702
703 Py_DECREF_IMMORTAL(x);
704 }
705
706 if (slot2 != NULL) {
707 PyObject *x = slot2(operand1, operand2);
708
709 if (x != Py_NotImplemented) {
710 obj_result = x;
711 goto exit_binary_result_object;
712 }
713
714 Py_DECREF_IMMORTAL(x);
715 }
716
717#if PYTHON_VERSION < 0x300
718 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
719 coercion c1 =
720 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
721
722 if (c1 != NULL) {
723 PyObject *coerced1 = operand1;
724 PyObject *coerced2 = operand2;
725
726 int err = c1(&coerced1, &coerced2);
727
728 if (unlikely(err < 0)) {
729 goto exit_binary_exception;
730 }
731
732 if (err == 0) {
733 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
734
735 if (likely(mv == NULL)) {
736 binaryfunc slot = mv->nb_multiply;
737
738 if (likely(slot != NULL)) {
739 PyObject *x = slot(coerced1, coerced2);
740
741 Py_DECREF(coerced1);
742 Py_DECREF(coerced2);
743
744 obj_result = x;
745 goto exit_binary_result_object;
746 }
747 }
748
749 // nb_coerce took a reference.
750 Py_DECREF(coerced1);
751 Py_DECREF(coerced2);
752 }
753 }
754 coercion c2 = PyInt_Type.tp_as_number->nb_coerce;
755
756 if (c2 != NULL) {
757 PyObject *coerced1 = operand1;
758 PyObject *coerced2 = operand2;
759
760 int err = c2(&coerced2, &coerced1);
761
762 if (unlikely(err < 0)) {
763 goto exit_binary_exception;
764 }
765
766 if (err == 0) {
767 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
768
769 if (likely(mv == NULL)) {
770 binaryfunc slot = mv->nb_multiply;
771
772 if (likely(slot != NULL)) {
773 PyObject *x = slot(coerced1, coerced2);
774
775 Py_DECREF(coerced1);
776 Py_DECREF(coerced2);
777
778 obj_result = x;
779 goto exit_binary_result_object;
780 }
781 }
782
783 // nb_coerce took a reference.
784 Py_DECREF(coerced1);
785 Py_DECREF(coerced2);
786 }
787 }
788 }
789#endif
790
791 {
792 // Special case for "+" and "*", also works as sequence concat/repeat.
793 ssizeargfunc sq_slot = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_repeat : NULL;
794
795 if (sq_slot != NULL) {
796 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand1, operand2);
797
798 obj_result = result;
799 goto exit_binary_result_object;
800 }
801 }
802 // No sequence repeat slot sq_repeat available for this type.
803
804 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: '%s' and 'int'", type1->tp_name);
805 goto exit_binary_exception;
806
807exit_binary_result_object:
808 if (unlikely(obj_result == NULL)) {
809 return NUITKA_BOOL_EXCEPTION;
810 }
811
812 {
813 nuitka_bool r = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
814 Py_DECREF(obj_result);
815 return r;
816 }
817
818exit_binary_exception:
819 return NUITKA_BOOL_EXCEPTION;
820}
821static nuitka_bool _BINARY_OPERATION_MULT_NBOOL_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
822 CHECK_OBJECT(operand1);
823 CHECK_OBJECT(operand2);
824 assert(PyInt_CheckExact(operand2));
825
826 PyTypeObject *type1 = Py_TYPE(operand1);
827
828 if (type1 == &PyInt_Type) {
829 nuitka_bool result;
830
831 // return _BINARY_OPERATION_MULT_NBOOL_INT_INT(operand1, operand2);
832
833 // Not every code path will make use of all possible results.
834#if defined(_MSC_VER)
835#pragma warning(push)
836#pragma warning(disable : 4101)
837#endif
838 NUITKA_MAY_BE_UNUSED bool cbool_result;
839 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
840 NUITKA_MAY_BE_UNUSED long clong_result;
841 NUITKA_MAY_BE_UNUSED double cfloat_result;
842#if defined(_MSC_VER)
843#pragma warning(pop)
844#endif
845
846 CHECK_OBJECT(operand1);
847 assert(PyInt_CheckExact(operand1));
848 CHECK_OBJECT(operand2);
849 assert(PyInt_CheckExact(operand2));
850
851 const long a = PyInt_AS_LONG(operand1);
852 const long b = PyInt_AS_LONG(operand2);
853
854 const long longprod = (long)((unsigned long)a * b);
855 const double doubleprod = (double)a * (double)b;
856 const double doubled_longprod = (double)longprod;
857
858 if (likely(doubled_longprod == doubleprod)) {
859 clong_result = longprod;
860 goto exit_result_ok_clong;
861 } else {
862 const double diff = doubled_longprod - doubleprod;
863 const double absdiff = diff >= 0.0 ? diff : -diff;
864 const double absprod = doubleprod >= 0.0 ? doubleprod : -doubleprod;
865
866 if (likely(32.0 * absdiff <= absprod)) {
867 clong_result = longprod;
868 goto exit_result_ok_clong;
869 }
870 }
871
872 {
873 PyObject *operand1_object = operand1;
874 PyObject *operand2_object = operand2;
875
876 PyObject *r = PyLong_Type.tp_as_number->nb_multiply(operand1_object, operand2_object);
877 assert(r != Py_NotImplemented);
878
879 obj_result = r;
880 goto exit_result_object;
881 }
882
883 exit_result_ok_clong:
884 result = clong_result != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
885 goto exit_result_ok;
886
887 exit_result_object:
888 if (unlikely(obj_result == NULL)) {
889 goto exit_result_exception;
890 }
891 result = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
892 Py_DECREF(obj_result);
893 goto exit_result_ok;
894
895 exit_result_ok:
896 return result;
897
898 exit_result_exception:
899 return NUITKA_BOOL_EXCEPTION;
900 }
901
902 return __BINARY_OPERATION_MULT_NBOOL_OBJECT_INT(operand1, operand2);
903}
904
905nuitka_bool BINARY_OPERATION_MULT_NBOOL_OBJECT_INT(PyObject *operand1, PyObject *operand2) {
906 return _BINARY_OPERATION_MULT_NBOOL_OBJECT_INT(operand1, operand2);
907}
908#endif
909
910#if PYTHON_VERSION < 0x300
911/* Code referring to "INT" corresponds to Python2 'int' and "OBJECT" to any Python object. */
912static HEDLEY_NEVER_INLINE nuitka_bool __BINARY_OPERATION_MULT_NBOOL_INT_OBJECT(PyObject *operand1,
913 PyObject *operand2) {
914 PyTypeObject *type2 = Py_TYPE(operand2);
915
916#if defined(_MSC_VER)
917#pragma warning(push)
918#pragma warning(disable : 4101)
919#endif
920 NUITKA_MAY_BE_UNUSED bool cbool_result;
921 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
922#if defined(_MSC_VER)
923#pragma warning(pop)
924#endif
925
926 binaryfunc slot1 = PyInt_Type.tp_as_number->nb_multiply;
927 binaryfunc slot2 = NULL;
928
929 if (!(&PyInt_Type == type2)) {
930 // Different types, need to consider second value slot.
931
932 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_multiply : NULL;
933
934 if (slot1 == slot2) {
935 slot2 = NULL;
936 }
937 }
938
939 if (slot1 != NULL) {
940 if (slot2 != NULL) {
941 if (Nuitka_Type_IsSubtype(type2, &PyInt_Type)) {
942 PyObject *x = slot2(operand1, operand2);
943
944 if (x != Py_NotImplemented) {
945 obj_result = x;
946 goto exit_binary_result_object;
947 }
948
949 Py_DECREF_IMMORTAL(x);
950 slot2 = NULL;
951 }
952 }
953
954 PyObject *x = slot1(operand1, operand2);
955
956 if (x != Py_NotImplemented) {
957 obj_result = x;
958 goto exit_binary_result_object;
959 }
960
961 Py_DECREF_IMMORTAL(x);
962 }
963
964 if (slot2 != NULL) {
965 PyObject *x = slot2(operand1, operand2);
966
967 if (x != Py_NotImplemented) {
968 obj_result = x;
969 goto exit_binary_result_object;
970 }
971
972 Py_DECREF_IMMORTAL(x);
973 }
974
975#if PYTHON_VERSION < 0x300
976 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
977 coercion c1 = PyInt_Type.tp_as_number->nb_coerce;
978
979 if (c1 != NULL) {
980 PyObject *coerced1 = operand1;
981 PyObject *coerced2 = operand2;
982
983 int err = c1(&coerced1, &coerced2);
984
985 if (unlikely(err < 0)) {
986 goto exit_binary_exception;
987 }
988
989 if (err == 0) {
990 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
991
992 if (likely(mv == NULL)) {
993 binaryfunc slot = mv->nb_multiply;
994
995 if (likely(slot != NULL)) {
996 PyObject *x = slot(coerced1, coerced2);
997
998 Py_DECREF(coerced1);
999 Py_DECREF(coerced2);
1000
1001 obj_result = x;
1002 goto exit_binary_result_object;
1003 }
1004 }
1005
1006 // nb_coerce took a reference.
1007 Py_DECREF(coerced1);
1008 Py_DECREF(coerced2);
1009 }
1010 }
1011 coercion c2 =
1012 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
1013
1014 if (c2 != NULL) {
1015 PyObject *coerced1 = operand1;
1016 PyObject *coerced2 = operand2;
1017
1018 int err = c2(&coerced2, &coerced1);
1019
1020 if (unlikely(err < 0)) {
1021 goto exit_binary_exception;
1022 }
1023
1024 if (err == 0) {
1025 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1026
1027 if (likely(mv == NULL)) {
1028 binaryfunc slot = mv->nb_multiply;
1029
1030 if (likely(slot != NULL)) {
1031 PyObject *x = slot(coerced1, coerced2);
1032
1033 Py_DECREF(coerced1);
1034 Py_DECREF(coerced2);
1035
1036 obj_result = x;
1037 goto exit_binary_result_object;
1038 }
1039 }
1040
1041 // nb_coerce took a reference.
1042 Py_DECREF(coerced1);
1043 Py_DECREF(coerced2);
1044 }
1045 }
1046 }
1047#endif
1048
1049 {
1050 // No sequence repeat slot sq_repeat available for this type.
1051 }
1052 // Special case for "*", also work with sequence repeat from right argument.
1053 {
1054 ssizeargfunc sq_slot = type2->tp_as_sequence != NULL ? type2->tp_as_sequence->sq_repeat : NULL;
1055
1056 if (sq_slot != NULL) {
1057 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand2, operand1);
1058
1059 obj_result = result;
1060 goto exit_binary_result_object;
1061 }
1062 }
1063
1064 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: 'int' and '%s'", type2->tp_name);
1065 goto exit_binary_exception;
1066
1067exit_binary_result_object:
1068 if (unlikely(obj_result == NULL)) {
1069 return NUITKA_BOOL_EXCEPTION;
1070 }
1071
1072 {
1073 nuitka_bool r = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1074 Py_DECREF(obj_result);
1075 return r;
1076 }
1077
1078exit_binary_exception:
1079 return NUITKA_BOOL_EXCEPTION;
1080}
1081static nuitka_bool _BINARY_OPERATION_MULT_NBOOL_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
1082 CHECK_OBJECT(operand1);
1083 assert(PyInt_CheckExact(operand1));
1084 CHECK_OBJECT(operand2);
1085
1086 PyTypeObject *type2 = Py_TYPE(operand2);
1087
1088 if (&PyInt_Type == type2) {
1089 nuitka_bool result;
1090
1091 // return _BINARY_OPERATION_MULT_NBOOL_INT_INT(operand1, operand2);
1092
1093 // Not every code path will make use of all possible results.
1094#if defined(_MSC_VER)
1095#pragma warning(push)
1096#pragma warning(disable : 4101)
1097#endif
1098 NUITKA_MAY_BE_UNUSED bool cbool_result;
1099 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1100 NUITKA_MAY_BE_UNUSED long clong_result;
1101 NUITKA_MAY_BE_UNUSED double cfloat_result;
1102#if defined(_MSC_VER)
1103#pragma warning(pop)
1104#endif
1105
1106 CHECK_OBJECT(operand1);
1107 assert(PyInt_CheckExact(operand1));
1108 CHECK_OBJECT(operand2);
1109 assert(PyInt_CheckExact(operand2));
1110
1111 const long a = PyInt_AS_LONG(operand1);
1112 const long b = PyInt_AS_LONG(operand2);
1113
1114 const long longprod = (long)((unsigned long)a * b);
1115 const double doubleprod = (double)a * (double)b;
1116 const double doubled_longprod = (double)longprod;
1117
1118 if (likely(doubled_longprod == doubleprod)) {
1119 clong_result = longprod;
1120 goto exit_result_ok_clong;
1121 } else {
1122 const double diff = doubled_longprod - doubleprod;
1123 const double absdiff = diff >= 0.0 ? diff : -diff;
1124 const double absprod = doubleprod >= 0.0 ? doubleprod : -doubleprod;
1125
1126 if (likely(32.0 * absdiff <= absprod)) {
1127 clong_result = longprod;
1128 goto exit_result_ok_clong;
1129 }
1130 }
1131
1132 {
1133 PyObject *operand1_object = operand1;
1134 PyObject *operand2_object = operand2;
1135
1136 PyObject *r = PyLong_Type.tp_as_number->nb_multiply(operand1_object, operand2_object);
1137 assert(r != Py_NotImplemented);
1138
1139 obj_result = r;
1140 goto exit_result_object;
1141 }
1142
1143 exit_result_ok_clong:
1144 result = clong_result != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1145 goto exit_result_ok;
1146
1147 exit_result_object:
1148 if (unlikely(obj_result == NULL)) {
1149 goto exit_result_exception;
1150 }
1151 result = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1152 Py_DECREF(obj_result);
1153 goto exit_result_ok;
1154
1155 exit_result_ok:
1156 return result;
1157
1158 exit_result_exception:
1159 return NUITKA_BOOL_EXCEPTION;
1160 }
1161
1162 return __BINARY_OPERATION_MULT_NBOOL_INT_OBJECT(operand1, operand2);
1163}
1164
1165nuitka_bool BINARY_OPERATION_MULT_NBOOL_INT_OBJECT(PyObject *operand1, PyObject *operand2) {
1166 return _BINARY_OPERATION_MULT_NBOOL_INT_OBJECT(operand1, operand2);
1167}
1168#endif
1169
1170/* Code referring to "LONG" corresponds to Python2 'long', Python3 'int' and "LONG" to Python2 'long', Python3 'int'. */
1171static PyObject *_BINARY_OPERATION_MULT_OBJECT_LONG_LONG(PyObject *operand1, PyObject *operand2) {
1172 CHECK_OBJECT(operand1);
1173 assert(PyLong_CheckExact(operand1));
1174 CHECK_OBJECT(operand2);
1175 assert(PyLong_CheckExact(operand2));
1176
1177 PyObject *result;
1178
1179 // Not every code path will make use of all possible results.
1180#if defined(_MSC_VER)
1181#pragma warning(push)
1182#pragma warning(disable : 4101)
1183#endif
1184 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1185 NUITKA_MAY_BE_UNUSED long clong_result;
1186#if defined(_MSC_VER)
1187#pragma warning(pop)
1188#endif
1189
1190 PyObject *x = PyLong_Type.tp_as_number->nb_multiply(operand1, operand2);
1191 assert(x != Py_NotImplemented);
1192
1193 obj_result = x;
1194 goto exit_result_object;
1195
1196exit_result_object:
1197 if (unlikely(obj_result == NULL)) {
1198 goto exit_result_exception;
1199 }
1200 result = obj_result;
1201 goto exit_result_ok;
1202
1203exit_result_ok:
1204 return result;
1205
1206exit_result_exception:
1207 return NULL;
1208}
1209
1210PyObject *BINARY_OPERATION_MULT_OBJECT_LONG_LONG(PyObject *operand1, PyObject *operand2) {
1211 return _BINARY_OPERATION_MULT_OBJECT_LONG_LONG(operand1, operand2);
1212}
1213
1214/* Code referring to "OBJECT" corresponds to any Python object and "LONG" to Python2 'long', Python3 'int'. */
1215static HEDLEY_NEVER_INLINE PyObject *__BINARY_OPERATION_MULT_OBJECT_OBJECT_LONG(PyObject *operand1,
1216 PyObject *operand2) {
1217 PyTypeObject *type1 = Py_TYPE(operand1);
1218
1219#if defined(_MSC_VER)
1220#pragma warning(push)
1221#pragma warning(disable : 4101)
1222#endif
1223 NUITKA_MAY_BE_UNUSED bool cbool_result;
1224 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1225#if defined(_MSC_VER)
1226#pragma warning(pop)
1227#endif
1228
1229 binaryfunc slot1 =
1230 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_multiply : NULL;
1231 binaryfunc slot2 = NULL;
1232
1233 if (!(type1 == &PyLong_Type)) {
1234 // Different types, need to consider second value slot.
1235
1236 slot2 = PyLong_Type.tp_as_number->nb_multiply;
1237
1238 if (slot1 == slot2) {
1239 slot2 = NULL;
1240 }
1241 }
1242
1243 if (slot1 != NULL) {
1244 PyObject *x = slot1(operand1, operand2);
1245
1246 if (x != Py_NotImplemented) {
1247 obj_result = x;
1248 goto exit_binary_result_object;
1249 }
1250
1251 Py_DECREF_IMMORTAL(x);
1252 }
1253
1254 if (slot2 != NULL) {
1255 PyObject *x = slot2(operand1, operand2);
1256
1257 if (x != Py_NotImplemented) {
1258 obj_result = x;
1259 goto exit_binary_result_object;
1260 }
1261
1262 Py_DECREF_IMMORTAL(x);
1263 }
1264
1265#if PYTHON_VERSION < 0x300
1266 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
1267 coercion c1 =
1268 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
1269
1270 if (c1 != NULL) {
1271 PyObject *coerced1 = operand1;
1272 PyObject *coerced2 = operand2;
1273
1274 int err = c1(&coerced1, &coerced2);
1275
1276 if (unlikely(err < 0)) {
1277 goto exit_binary_exception;
1278 }
1279
1280 if (err == 0) {
1281 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1282
1283 if (likely(mv == NULL)) {
1284 binaryfunc slot = mv->nb_multiply;
1285
1286 if (likely(slot != NULL)) {
1287 PyObject *x = slot(coerced1, coerced2);
1288
1289 Py_DECREF(coerced1);
1290 Py_DECREF(coerced2);
1291
1292 obj_result = x;
1293 goto exit_binary_result_object;
1294 }
1295 }
1296
1297 // nb_coerce took a reference.
1298 Py_DECREF(coerced1);
1299 Py_DECREF(coerced2);
1300 }
1301 }
1302 coercion c2 = PyLong_Type.tp_as_number->nb_coerce;
1303
1304 if (c2 != NULL) {
1305 PyObject *coerced1 = operand1;
1306 PyObject *coerced2 = operand2;
1307
1308 int err = c2(&coerced2, &coerced1);
1309
1310 if (unlikely(err < 0)) {
1311 goto exit_binary_exception;
1312 }
1313
1314 if (err == 0) {
1315 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1316
1317 if (likely(mv == NULL)) {
1318 binaryfunc slot = mv->nb_multiply;
1319
1320 if (likely(slot != NULL)) {
1321 PyObject *x = slot(coerced1, coerced2);
1322
1323 Py_DECREF(coerced1);
1324 Py_DECREF(coerced2);
1325
1326 obj_result = x;
1327 goto exit_binary_result_object;
1328 }
1329 }
1330
1331 // nb_coerce took a reference.
1332 Py_DECREF(coerced1);
1333 Py_DECREF(coerced2);
1334 }
1335 }
1336 }
1337#endif
1338
1339 {
1340 // Special case for "+" and "*", also works as sequence concat/repeat.
1341 ssizeargfunc sq_slot = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_repeat : NULL;
1342
1343 if (sq_slot != NULL) {
1344 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand1, operand2);
1345
1346 obj_result = result;
1347 goto exit_binary_result_object;
1348 }
1349 }
1350 // No sequence repeat slot sq_repeat available for this type.
1351
1352#if PYTHON_VERSION < 0x300
1353 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: '%s' and 'long'", type1->tp_name);
1354#else
1355 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: '%s' and 'int'", type1->tp_name);
1356#endif
1357 goto exit_binary_exception;
1358
1359exit_binary_result_object:
1360 return obj_result;
1361
1362exit_binary_exception:
1363 return NULL;
1364}
1365static PyObject *_BINARY_OPERATION_MULT_OBJECT_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
1366 CHECK_OBJECT(operand1);
1367 CHECK_OBJECT(operand2);
1368 assert(PyLong_CheckExact(operand2));
1369
1370 PyTypeObject *type1 = Py_TYPE(operand1);
1371
1372 if (type1 == &PyLong_Type) {
1373 PyObject *result;
1374
1375 // return _BINARY_OPERATION_MULT_OBJECT_LONG_LONG(operand1, operand2);
1376
1377 // Not every code path will make use of all possible results.
1378#if defined(_MSC_VER)
1379#pragma warning(push)
1380#pragma warning(disable : 4101)
1381#endif
1382 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1383 NUITKA_MAY_BE_UNUSED long clong_result;
1384#if defined(_MSC_VER)
1385#pragma warning(pop)
1386#endif
1387
1388 PyObject *x = PyLong_Type.tp_as_number->nb_multiply(operand1, operand2);
1389 assert(x != Py_NotImplemented);
1390
1391 obj_result = x;
1392 goto exit_result_object;
1393
1394 exit_result_object:
1395 if (unlikely(obj_result == NULL)) {
1396 goto exit_result_exception;
1397 }
1398 result = obj_result;
1399 goto exit_result_ok;
1400
1401 exit_result_ok:
1402 return result;
1403
1404 exit_result_exception:
1405 return NULL;
1406 }
1407
1408 return __BINARY_OPERATION_MULT_OBJECT_OBJECT_LONG(operand1, operand2);
1409}
1410
1411PyObject *BINARY_OPERATION_MULT_OBJECT_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
1412 return _BINARY_OPERATION_MULT_OBJECT_OBJECT_LONG(operand1, operand2);
1413}
1414
1415/* Code referring to "LONG" corresponds to Python2 'long', Python3 'int' and "OBJECT" to any Python object. */
1416static HEDLEY_NEVER_INLINE PyObject *__BINARY_OPERATION_MULT_OBJECT_LONG_OBJECT(PyObject *operand1,
1417 PyObject *operand2) {
1418 PyTypeObject *type2 = Py_TYPE(operand2);
1419
1420#if defined(_MSC_VER)
1421#pragma warning(push)
1422#pragma warning(disable : 4101)
1423#endif
1424 NUITKA_MAY_BE_UNUSED bool cbool_result;
1425 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1426#if defined(_MSC_VER)
1427#pragma warning(pop)
1428#endif
1429
1430 binaryfunc slot1 = PyLong_Type.tp_as_number->nb_multiply;
1431 binaryfunc slot2 = NULL;
1432
1433 if (!(&PyLong_Type == type2)) {
1434 // Different types, need to consider second value slot.
1435
1436 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_multiply : NULL;
1437
1438 if (slot1 == slot2) {
1439 slot2 = NULL;
1440 }
1441 }
1442
1443 if (slot1 != NULL) {
1444 if (slot2 != NULL) {
1445 if (Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
1446 PyObject *x = slot2(operand1, operand2);
1447
1448 if (x != Py_NotImplemented) {
1449 obj_result = x;
1450 goto exit_binary_result_object;
1451 }
1452
1453 Py_DECREF_IMMORTAL(x);
1454 slot2 = NULL;
1455 }
1456 }
1457
1458 PyObject *x = slot1(operand1, operand2);
1459
1460 if (x != Py_NotImplemented) {
1461 obj_result = x;
1462 goto exit_binary_result_object;
1463 }
1464
1465 Py_DECREF_IMMORTAL(x);
1466 }
1467
1468 if (slot2 != NULL) {
1469 PyObject *x = slot2(operand1, operand2);
1470
1471 if (x != Py_NotImplemented) {
1472 obj_result = x;
1473 goto exit_binary_result_object;
1474 }
1475
1476 Py_DECREF_IMMORTAL(x);
1477 }
1478
1479#if PYTHON_VERSION < 0x300
1480 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
1481 coercion c1 = PyLong_Type.tp_as_number->nb_coerce;
1482
1483 if (c1 != NULL) {
1484 PyObject *coerced1 = operand1;
1485 PyObject *coerced2 = operand2;
1486
1487 int err = c1(&coerced1, &coerced2);
1488
1489 if (unlikely(err < 0)) {
1490 goto exit_binary_exception;
1491 }
1492
1493 if (err == 0) {
1494 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1495
1496 if (likely(mv == NULL)) {
1497 binaryfunc slot = mv->nb_multiply;
1498
1499 if (likely(slot != NULL)) {
1500 PyObject *x = slot(coerced1, coerced2);
1501
1502 Py_DECREF(coerced1);
1503 Py_DECREF(coerced2);
1504
1505 obj_result = x;
1506 goto exit_binary_result_object;
1507 }
1508 }
1509
1510 // nb_coerce took a reference.
1511 Py_DECREF(coerced1);
1512 Py_DECREF(coerced2);
1513 }
1514 }
1515 coercion c2 =
1516 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
1517
1518 if (c2 != NULL) {
1519 PyObject *coerced1 = operand1;
1520 PyObject *coerced2 = operand2;
1521
1522 int err = c2(&coerced2, &coerced1);
1523
1524 if (unlikely(err < 0)) {
1525 goto exit_binary_exception;
1526 }
1527
1528 if (err == 0) {
1529 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1530
1531 if (likely(mv == NULL)) {
1532 binaryfunc slot = mv->nb_multiply;
1533
1534 if (likely(slot != NULL)) {
1535 PyObject *x = slot(coerced1, coerced2);
1536
1537 Py_DECREF(coerced1);
1538 Py_DECREF(coerced2);
1539
1540 obj_result = x;
1541 goto exit_binary_result_object;
1542 }
1543 }
1544
1545 // nb_coerce took a reference.
1546 Py_DECREF(coerced1);
1547 Py_DECREF(coerced2);
1548 }
1549 }
1550 }
1551#endif
1552
1553 {
1554 // No sequence repeat slot sq_repeat available for this type.
1555 }
1556 // Special case for "*", also work with sequence repeat from right argument.
1557 {
1558 ssizeargfunc sq_slot = type2->tp_as_sequence != NULL ? type2->tp_as_sequence->sq_repeat : NULL;
1559
1560 if (sq_slot != NULL) {
1561 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand2, operand1);
1562
1563 obj_result = result;
1564 goto exit_binary_result_object;
1565 }
1566 }
1567
1568#if PYTHON_VERSION < 0x300
1569 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: 'long' and '%s'", type2->tp_name);
1570#else
1571 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: 'int' and '%s'", type2->tp_name);
1572#endif
1573 goto exit_binary_exception;
1574
1575exit_binary_result_object:
1576 return obj_result;
1577
1578exit_binary_exception:
1579 return NULL;
1580}
1581static PyObject *_BINARY_OPERATION_MULT_OBJECT_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
1582 CHECK_OBJECT(operand1);
1583 assert(PyLong_CheckExact(operand1));
1584 CHECK_OBJECT(operand2);
1585
1586 PyTypeObject *type2 = Py_TYPE(operand2);
1587
1588 if (&PyLong_Type == type2) {
1589 PyObject *result;
1590
1591 // return _BINARY_OPERATION_MULT_OBJECT_LONG_LONG(operand1, operand2);
1592
1593 // Not every code path will make use of all possible results.
1594#if defined(_MSC_VER)
1595#pragma warning(push)
1596#pragma warning(disable : 4101)
1597#endif
1598 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1599 NUITKA_MAY_BE_UNUSED long clong_result;
1600#if defined(_MSC_VER)
1601#pragma warning(pop)
1602#endif
1603
1604 PyObject *x = PyLong_Type.tp_as_number->nb_multiply(operand1, operand2);
1605 assert(x != Py_NotImplemented);
1606
1607 obj_result = x;
1608 goto exit_result_object;
1609
1610 exit_result_object:
1611 if (unlikely(obj_result == NULL)) {
1612 goto exit_result_exception;
1613 }
1614 result = obj_result;
1615 goto exit_result_ok;
1616
1617 exit_result_ok:
1618 return result;
1619
1620 exit_result_exception:
1621 return NULL;
1622 }
1623
1624 return __BINARY_OPERATION_MULT_OBJECT_LONG_OBJECT(operand1, operand2);
1625}
1626
1627PyObject *BINARY_OPERATION_MULT_OBJECT_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
1628 return _BINARY_OPERATION_MULT_OBJECT_LONG_OBJECT(operand1, operand2);
1629}
1630
1631/* Code referring to "LONG" corresponds to Python2 'long', Python3 'int' and "LONG" to Python2 'long', Python3 'int'. */
1632static nuitka_bool _BINARY_OPERATION_MULT_NBOOL_LONG_LONG(PyObject *operand1, PyObject *operand2) {
1633 CHECK_OBJECT(operand1);
1634 assert(PyLong_CheckExact(operand1));
1635 CHECK_OBJECT(operand2);
1636 assert(PyLong_CheckExact(operand2));
1637
1638 nuitka_bool result;
1639
1640 // Not every code path will make use of all possible results.
1641#if defined(_MSC_VER)
1642#pragma warning(push)
1643#pragma warning(disable : 4101)
1644#endif
1645 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1646 NUITKA_MAY_BE_UNUSED long clong_result;
1647#if defined(_MSC_VER)
1648#pragma warning(pop)
1649#endif
1650
1651 PyObject *x = PyLong_Type.tp_as_number->nb_multiply(operand1, operand2);
1652 assert(x != Py_NotImplemented);
1653
1654 obj_result = x;
1655 goto exit_result_object;
1656
1657exit_result_object:
1658 if (unlikely(obj_result == NULL)) {
1659 goto exit_result_exception;
1660 }
1661 result = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1662 Py_DECREF(obj_result);
1663 goto exit_result_ok;
1664
1665exit_result_ok:
1666 return result;
1667
1668exit_result_exception:
1669 return NUITKA_BOOL_EXCEPTION;
1670}
1671
1672nuitka_bool BINARY_OPERATION_MULT_NBOOL_LONG_LONG(PyObject *operand1, PyObject *operand2) {
1673 return _BINARY_OPERATION_MULT_NBOOL_LONG_LONG(operand1, operand2);
1674}
1675
1676/* Code referring to "OBJECT" corresponds to any Python object and "LONG" to Python2 'long', Python3 'int'. */
1677static HEDLEY_NEVER_INLINE nuitka_bool __BINARY_OPERATION_MULT_NBOOL_OBJECT_LONG(PyObject *operand1,
1678 PyObject *operand2) {
1679 PyTypeObject *type1 = Py_TYPE(operand1);
1680
1681#if defined(_MSC_VER)
1682#pragma warning(push)
1683#pragma warning(disable : 4101)
1684#endif
1685 NUITKA_MAY_BE_UNUSED bool cbool_result;
1686 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1687#if defined(_MSC_VER)
1688#pragma warning(pop)
1689#endif
1690
1691 binaryfunc slot1 =
1692 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_multiply : NULL;
1693 binaryfunc slot2 = NULL;
1694
1695 if (!(type1 == &PyLong_Type)) {
1696 // Different types, need to consider second value slot.
1697
1698 slot2 = PyLong_Type.tp_as_number->nb_multiply;
1699
1700 if (slot1 == slot2) {
1701 slot2 = NULL;
1702 }
1703 }
1704
1705 if (slot1 != NULL) {
1706 PyObject *x = slot1(operand1, operand2);
1707
1708 if (x != Py_NotImplemented) {
1709 obj_result = x;
1710 goto exit_binary_result_object;
1711 }
1712
1713 Py_DECREF_IMMORTAL(x);
1714 }
1715
1716 if (slot2 != NULL) {
1717 PyObject *x = slot2(operand1, operand2);
1718
1719 if (x != Py_NotImplemented) {
1720 obj_result = x;
1721 goto exit_binary_result_object;
1722 }
1723
1724 Py_DECREF_IMMORTAL(x);
1725 }
1726
1727#if PYTHON_VERSION < 0x300
1728 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
1729 coercion c1 =
1730 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
1731
1732 if (c1 != NULL) {
1733 PyObject *coerced1 = operand1;
1734 PyObject *coerced2 = operand2;
1735
1736 int err = c1(&coerced1, &coerced2);
1737
1738 if (unlikely(err < 0)) {
1739 goto exit_binary_exception;
1740 }
1741
1742 if (err == 0) {
1743 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1744
1745 if (likely(mv == NULL)) {
1746 binaryfunc slot = mv->nb_multiply;
1747
1748 if (likely(slot != NULL)) {
1749 PyObject *x = slot(coerced1, coerced2);
1750
1751 Py_DECREF(coerced1);
1752 Py_DECREF(coerced2);
1753
1754 obj_result = x;
1755 goto exit_binary_result_object;
1756 }
1757 }
1758
1759 // nb_coerce took a reference.
1760 Py_DECREF(coerced1);
1761 Py_DECREF(coerced2);
1762 }
1763 }
1764 coercion c2 = PyLong_Type.tp_as_number->nb_coerce;
1765
1766 if (c2 != NULL) {
1767 PyObject *coerced1 = operand1;
1768 PyObject *coerced2 = operand2;
1769
1770 int err = c2(&coerced2, &coerced1);
1771
1772 if (unlikely(err < 0)) {
1773 goto exit_binary_exception;
1774 }
1775
1776 if (err == 0) {
1777 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1778
1779 if (likely(mv == NULL)) {
1780 binaryfunc slot = mv->nb_multiply;
1781
1782 if (likely(slot != NULL)) {
1783 PyObject *x = slot(coerced1, coerced2);
1784
1785 Py_DECREF(coerced1);
1786 Py_DECREF(coerced2);
1787
1788 obj_result = x;
1789 goto exit_binary_result_object;
1790 }
1791 }
1792
1793 // nb_coerce took a reference.
1794 Py_DECREF(coerced1);
1795 Py_DECREF(coerced2);
1796 }
1797 }
1798 }
1799#endif
1800
1801 {
1802 // Special case for "+" and "*", also works as sequence concat/repeat.
1803 ssizeargfunc sq_slot = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_repeat : NULL;
1804
1805 if (sq_slot != NULL) {
1806 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand1, operand2);
1807
1808 obj_result = result;
1809 goto exit_binary_result_object;
1810 }
1811 }
1812 // No sequence repeat slot sq_repeat available for this type.
1813
1814#if PYTHON_VERSION < 0x300
1815 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: '%s' and 'long'", type1->tp_name);
1816#else
1817 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: '%s' and 'int'", type1->tp_name);
1818#endif
1819 goto exit_binary_exception;
1820
1821exit_binary_result_object:
1822 if (unlikely(obj_result == NULL)) {
1823 return NUITKA_BOOL_EXCEPTION;
1824 }
1825
1826 {
1827 nuitka_bool r = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1828 Py_DECREF(obj_result);
1829 return r;
1830 }
1831
1832exit_binary_exception:
1833 return NUITKA_BOOL_EXCEPTION;
1834}
1835static nuitka_bool _BINARY_OPERATION_MULT_NBOOL_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
1836 CHECK_OBJECT(operand1);
1837 CHECK_OBJECT(operand2);
1838 assert(PyLong_CheckExact(operand2));
1839
1840 PyTypeObject *type1 = Py_TYPE(operand1);
1841
1842 if (type1 == &PyLong_Type) {
1843 nuitka_bool result;
1844
1845 // return _BINARY_OPERATION_MULT_NBOOL_LONG_LONG(operand1, operand2);
1846
1847 // Not every code path will make use of all possible results.
1848#if defined(_MSC_VER)
1849#pragma warning(push)
1850#pragma warning(disable : 4101)
1851#endif
1852 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1853 NUITKA_MAY_BE_UNUSED long clong_result;
1854#if defined(_MSC_VER)
1855#pragma warning(pop)
1856#endif
1857
1858 PyObject *x = PyLong_Type.tp_as_number->nb_multiply(operand1, operand2);
1859 assert(x != Py_NotImplemented);
1860
1861 obj_result = x;
1862 goto exit_result_object;
1863
1864 exit_result_object:
1865 if (unlikely(obj_result == NULL)) {
1866 goto exit_result_exception;
1867 }
1868 result = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
1869 Py_DECREF(obj_result);
1870 goto exit_result_ok;
1871
1872 exit_result_ok:
1873 return result;
1874
1875 exit_result_exception:
1876 return NUITKA_BOOL_EXCEPTION;
1877 }
1878
1879 return __BINARY_OPERATION_MULT_NBOOL_OBJECT_LONG(operand1, operand2);
1880}
1881
1882nuitka_bool BINARY_OPERATION_MULT_NBOOL_OBJECT_LONG(PyObject *operand1, PyObject *operand2) {
1883 return _BINARY_OPERATION_MULT_NBOOL_OBJECT_LONG(operand1, operand2);
1884}
1885
1886/* Code referring to "LONG" corresponds to Python2 'long', Python3 'int' and "OBJECT" to any Python object. */
1887static HEDLEY_NEVER_INLINE nuitka_bool __BINARY_OPERATION_MULT_NBOOL_LONG_OBJECT(PyObject *operand1,
1888 PyObject *operand2) {
1889 PyTypeObject *type2 = Py_TYPE(operand2);
1890
1891#if defined(_MSC_VER)
1892#pragma warning(push)
1893#pragma warning(disable : 4101)
1894#endif
1895 NUITKA_MAY_BE_UNUSED bool cbool_result;
1896 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
1897#if defined(_MSC_VER)
1898#pragma warning(pop)
1899#endif
1900
1901 binaryfunc slot1 = PyLong_Type.tp_as_number->nb_multiply;
1902 binaryfunc slot2 = NULL;
1903
1904 if (!(&PyLong_Type == type2)) {
1905 // Different types, need to consider second value slot.
1906
1907 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_multiply : NULL;
1908
1909 if (slot1 == slot2) {
1910 slot2 = NULL;
1911 }
1912 }
1913
1914 if (slot1 != NULL) {
1915 if (slot2 != NULL) {
1916 if (Nuitka_Type_IsSubtype(type2, &PyLong_Type)) {
1917 PyObject *x = slot2(operand1, operand2);
1918
1919 if (x != Py_NotImplemented) {
1920 obj_result = x;
1921 goto exit_binary_result_object;
1922 }
1923
1924 Py_DECREF_IMMORTAL(x);
1925 slot2 = NULL;
1926 }
1927 }
1928
1929 PyObject *x = slot1(operand1, operand2);
1930
1931 if (x != Py_NotImplemented) {
1932 obj_result = x;
1933 goto exit_binary_result_object;
1934 }
1935
1936 Py_DECREF_IMMORTAL(x);
1937 }
1938
1939 if (slot2 != NULL) {
1940 PyObject *x = slot2(operand1, operand2);
1941
1942 if (x != Py_NotImplemented) {
1943 obj_result = x;
1944 goto exit_binary_result_object;
1945 }
1946
1947 Py_DECREF_IMMORTAL(x);
1948 }
1949
1950#if PYTHON_VERSION < 0x300
1951 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
1952 coercion c1 = PyLong_Type.tp_as_number->nb_coerce;
1953
1954 if (c1 != NULL) {
1955 PyObject *coerced1 = operand1;
1956 PyObject *coerced2 = operand2;
1957
1958 int err = c1(&coerced1, &coerced2);
1959
1960 if (unlikely(err < 0)) {
1961 goto exit_binary_exception;
1962 }
1963
1964 if (err == 0) {
1965 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
1966
1967 if (likely(mv == NULL)) {
1968 binaryfunc slot = mv->nb_multiply;
1969
1970 if (likely(slot != NULL)) {
1971 PyObject *x = slot(coerced1, coerced2);
1972
1973 Py_DECREF(coerced1);
1974 Py_DECREF(coerced2);
1975
1976 obj_result = x;
1977 goto exit_binary_result_object;
1978 }
1979 }
1980
1981 // nb_coerce took a reference.
1982 Py_DECREF(coerced1);
1983 Py_DECREF(coerced2);
1984 }
1985 }
1986 coercion c2 =
1987 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
1988
1989 if (c2 != NULL) {
1990 PyObject *coerced1 = operand1;
1991 PyObject *coerced2 = operand2;
1992
1993 int err = c2(&coerced2, &coerced1);
1994
1995 if (unlikely(err < 0)) {
1996 goto exit_binary_exception;
1997 }
1998
1999 if (err == 0) {
2000 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2001
2002 if (likely(mv == NULL)) {
2003 binaryfunc slot = mv->nb_multiply;
2004
2005 if (likely(slot != NULL)) {
2006 PyObject *x = slot(coerced1, coerced2);
2007
2008 Py_DECREF(coerced1);
2009 Py_DECREF(coerced2);
2010
2011 obj_result = x;
2012 goto exit_binary_result_object;
2013 }
2014 }
2015
2016 // nb_coerce took a reference.
2017 Py_DECREF(coerced1);
2018 Py_DECREF(coerced2);
2019 }
2020 }
2021 }
2022#endif
2023
2024 {
2025 // No sequence repeat slot sq_repeat available for this type.
2026 }
2027 // Special case for "*", also work with sequence repeat from right argument.
2028 {
2029 ssizeargfunc sq_slot = type2->tp_as_sequence != NULL ? type2->tp_as_sequence->sq_repeat : NULL;
2030
2031 if (sq_slot != NULL) {
2032 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand2, operand1);
2033
2034 obj_result = result;
2035 goto exit_binary_result_object;
2036 }
2037 }
2038
2039#if PYTHON_VERSION < 0x300
2040 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: 'long' and '%s'", type2->tp_name);
2041#else
2042 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: 'int' and '%s'", type2->tp_name);
2043#endif
2044 goto exit_binary_exception;
2045
2046exit_binary_result_object:
2047 if (unlikely(obj_result == NULL)) {
2048 return NUITKA_BOOL_EXCEPTION;
2049 }
2050
2051 {
2052 nuitka_bool r = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2053 Py_DECREF(obj_result);
2054 return r;
2055 }
2056
2057exit_binary_exception:
2058 return NUITKA_BOOL_EXCEPTION;
2059}
2060static nuitka_bool _BINARY_OPERATION_MULT_NBOOL_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
2061 CHECK_OBJECT(operand1);
2062 assert(PyLong_CheckExact(operand1));
2063 CHECK_OBJECT(operand2);
2064
2065 PyTypeObject *type2 = Py_TYPE(operand2);
2066
2067 if (&PyLong_Type == type2) {
2068 nuitka_bool result;
2069
2070 // return _BINARY_OPERATION_MULT_NBOOL_LONG_LONG(operand1, operand2);
2071
2072 // Not every code path will make use of all possible results.
2073#if defined(_MSC_VER)
2074#pragma warning(push)
2075#pragma warning(disable : 4101)
2076#endif
2077 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2078 NUITKA_MAY_BE_UNUSED long clong_result;
2079#if defined(_MSC_VER)
2080#pragma warning(pop)
2081#endif
2082
2083 PyObject *x = PyLong_Type.tp_as_number->nb_multiply(operand1, operand2);
2084 assert(x != Py_NotImplemented);
2085
2086 obj_result = x;
2087 goto exit_result_object;
2088
2089 exit_result_object:
2090 if (unlikely(obj_result == NULL)) {
2091 goto exit_result_exception;
2092 }
2093 result = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2094 Py_DECREF(obj_result);
2095 goto exit_result_ok;
2096
2097 exit_result_ok:
2098 return result;
2099
2100 exit_result_exception:
2101 return NUITKA_BOOL_EXCEPTION;
2102 }
2103
2104 return __BINARY_OPERATION_MULT_NBOOL_LONG_OBJECT(operand1, operand2);
2105}
2106
2107nuitka_bool BINARY_OPERATION_MULT_NBOOL_LONG_OBJECT(PyObject *operand1, PyObject *operand2) {
2108 return _BINARY_OPERATION_MULT_NBOOL_LONG_OBJECT(operand1, operand2);
2109}
2110
2111/* Code referring to "FLOAT" corresponds to Python 'float' and "FLOAT" to Python 'float'. */
2112static PyObject *_BINARY_OPERATION_MULT_OBJECT_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
2113 CHECK_OBJECT(operand1);
2114 assert(PyFloat_CheckExact(operand1));
2115 CHECK_OBJECT(operand2);
2116 assert(PyFloat_CheckExact(operand2));
2117
2118 PyObject *result;
2119
2120#if defined(_MSC_VER)
2121#pragma warning(push)
2122#pragma warning(disable : 4101)
2123#endif
2124 // Not every code path will make use of all possible results.
2125 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2126 NUITKA_MAY_BE_UNUSED long clong_result;
2127 NUITKA_MAY_BE_UNUSED double cfloat_result;
2128#if defined(_MSC_VER)
2129#pragma warning(pop)
2130#endif
2131
2132 CHECK_OBJECT(operand1);
2133 assert(PyFloat_CheckExact(operand1));
2134 CHECK_OBJECT(operand2);
2135 assert(PyFloat_CheckExact(operand2));
2136
2137 const double a = PyFloat_AS_DOUBLE(operand1);
2138 const double b = PyFloat_AS_DOUBLE(operand2);
2139
2140 double r = a * b;
2141
2142 cfloat_result = r;
2143 goto exit_result_ok_cfloat;
2144
2145exit_result_ok_cfloat:
2146 result = MAKE_FLOAT_FROM_DOUBLE(cfloat_result);
2147 goto exit_result_ok;
2148
2149exit_result_ok:
2150 return result;
2151}
2152
2153PyObject *BINARY_OPERATION_MULT_OBJECT_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
2154 return _BINARY_OPERATION_MULT_OBJECT_FLOAT_FLOAT(operand1, operand2);
2155}
2156
2157/* Code referring to "OBJECT" corresponds to any Python object and "FLOAT" to Python 'float'. */
2158static HEDLEY_NEVER_INLINE PyObject *__BINARY_OPERATION_MULT_OBJECT_OBJECT_FLOAT(PyObject *operand1,
2159 PyObject *operand2) {
2160 PyTypeObject *type1 = Py_TYPE(operand1);
2161
2162#if defined(_MSC_VER)
2163#pragma warning(push)
2164#pragma warning(disable : 4101)
2165#endif
2166 NUITKA_MAY_BE_UNUSED bool cbool_result;
2167 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2168#if defined(_MSC_VER)
2169#pragma warning(pop)
2170#endif
2171
2172 binaryfunc slot1 =
2173 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_multiply : NULL;
2174 binaryfunc slot2 = NULL;
2175
2176 if (!(type1 == &PyFloat_Type)) {
2177 // Different types, need to consider second value slot.
2178
2179 slot2 = PyFloat_Type.tp_as_number->nb_multiply;
2180
2181 if (slot1 == slot2) {
2182 slot2 = NULL;
2183 }
2184 }
2185
2186 if (slot1 != NULL) {
2187 PyObject *x = slot1(operand1, operand2);
2188
2189 if (x != Py_NotImplemented) {
2190 obj_result = x;
2191 goto exit_binary_result_object;
2192 }
2193
2194 Py_DECREF_IMMORTAL(x);
2195 }
2196
2197 if (slot2 != NULL) {
2198 PyObject *x = slot2(operand1, operand2);
2199
2200 if (x != Py_NotImplemented) {
2201 obj_result = x;
2202 goto exit_binary_result_object;
2203 }
2204
2205 Py_DECREF_IMMORTAL(x);
2206 }
2207
2208#if PYTHON_VERSION < 0x300
2209 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
2210 coercion c1 =
2211 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
2212
2213 if (c1 != NULL) {
2214 PyObject *coerced1 = operand1;
2215 PyObject *coerced2 = operand2;
2216
2217 int err = c1(&coerced1, &coerced2);
2218
2219 if (unlikely(err < 0)) {
2220 goto exit_binary_exception;
2221 }
2222
2223 if (err == 0) {
2224 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2225
2226 if (likely(mv == NULL)) {
2227 binaryfunc slot = mv->nb_multiply;
2228
2229 if (likely(slot != NULL)) {
2230 PyObject *x = slot(coerced1, coerced2);
2231
2232 Py_DECREF(coerced1);
2233 Py_DECREF(coerced2);
2234
2235 obj_result = x;
2236 goto exit_binary_result_object;
2237 }
2238 }
2239
2240 // nb_coerce took a reference.
2241 Py_DECREF(coerced1);
2242 Py_DECREF(coerced2);
2243 }
2244 }
2245 coercion c2 = PyFloat_Type.tp_as_number->nb_coerce;
2246
2247 if (c2 != NULL) {
2248 PyObject *coerced1 = operand1;
2249 PyObject *coerced2 = operand2;
2250
2251 int err = c2(&coerced2, &coerced1);
2252
2253 if (unlikely(err < 0)) {
2254 goto exit_binary_exception;
2255 }
2256
2257 if (err == 0) {
2258 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2259
2260 if (likely(mv == NULL)) {
2261 binaryfunc slot = mv->nb_multiply;
2262
2263 if (likely(slot != NULL)) {
2264 PyObject *x = slot(coerced1, coerced2);
2265
2266 Py_DECREF(coerced1);
2267 Py_DECREF(coerced2);
2268
2269 obj_result = x;
2270 goto exit_binary_result_object;
2271 }
2272 }
2273
2274 // nb_coerce took a reference.
2275 Py_DECREF(coerced1);
2276 Py_DECREF(coerced2);
2277 }
2278 }
2279 }
2280#endif
2281
2282 {
2283 // Special case for "+" and "*", also works as sequence concat/repeat.
2284 ssizeargfunc sq_slot = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_repeat : NULL;
2285
2286 if (sq_slot != NULL) {
2287 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand1, operand2);
2288
2289 obj_result = result;
2290 goto exit_binary_result_object;
2291 }
2292 }
2293 // No sequence repeat slot sq_repeat available for this type.
2294
2295 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: '%s' and 'float'", type1->tp_name);
2296 goto exit_binary_exception;
2297
2298exit_binary_result_object:
2299 return obj_result;
2300
2301exit_binary_exception:
2302 return NULL;
2303}
2304static PyObject *_BINARY_OPERATION_MULT_OBJECT_OBJECT_FLOAT(PyObject *operand1, PyObject *operand2) {
2305 CHECK_OBJECT(operand1);
2306 CHECK_OBJECT(operand2);
2307 assert(PyFloat_CheckExact(operand2));
2308
2309 PyTypeObject *type1 = Py_TYPE(operand1);
2310
2311 if (type1 == &PyFloat_Type) {
2312 PyObject *result;
2313
2314 // return _BINARY_OPERATION_MULT_OBJECT_FLOAT_FLOAT(operand1, operand2);
2315
2316#if defined(_MSC_VER)
2317#pragma warning(push)
2318#pragma warning(disable : 4101)
2319#endif
2320 // Not every code path will make use of all possible results.
2321 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2322 NUITKA_MAY_BE_UNUSED long clong_result;
2323 NUITKA_MAY_BE_UNUSED double cfloat_result;
2324#if defined(_MSC_VER)
2325#pragma warning(pop)
2326#endif
2327
2328 CHECK_OBJECT(operand1);
2329 assert(PyFloat_CheckExact(operand1));
2330 CHECK_OBJECT(operand2);
2331 assert(PyFloat_CheckExact(operand2));
2332
2333 const double a = PyFloat_AS_DOUBLE(operand1);
2334 const double b = PyFloat_AS_DOUBLE(operand2);
2335
2336 double r = a * b;
2337
2338 cfloat_result = r;
2339 goto exit_result_ok_cfloat;
2340
2341 exit_result_ok_cfloat:
2342 result = MAKE_FLOAT_FROM_DOUBLE(cfloat_result);
2343 goto exit_result_ok;
2344
2345 exit_result_ok:
2346 return result;
2347 }
2348
2349 return __BINARY_OPERATION_MULT_OBJECT_OBJECT_FLOAT(operand1, operand2);
2350}
2351
2352PyObject *BINARY_OPERATION_MULT_OBJECT_OBJECT_FLOAT(PyObject *operand1, PyObject *operand2) {
2353 return _BINARY_OPERATION_MULT_OBJECT_OBJECT_FLOAT(operand1, operand2);
2354}
2355
2356/* Code referring to "FLOAT" corresponds to Python 'float' and "OBJECT" to any Python object. */
2357static HEDLEY_NEVER_INLINE PyObject *__BINARY_OPERATION_MULT_OBJECT_FLOAT_OBJECT(PyObject *operand1,
2358 PyObject *operand2) {
2359 PyTypeObject *type2 = Py_TYPE(operand2);
2360
2361#if defined(_MSC_VER)
2362#pragma warning(push)
2363#pragma warning(disable : 4101)
2364#endif
2365 NUITKA_MAY_BE_UNUSED bool cbool_result;
2366 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2367#if defined(_MSC_VER)
2368#pragma warning(pop)
2369#endif
2370
2371 binaryfunc slot1 = PyFloat_Type.tp_as_number->nb_multiply;
2372 binaryfunc slot2 = NULL;
2373
2374 if (!(&PyFloat_Type == type2)) {
2375 // Different types, need to consider second value slot.
2376
2377 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_multiply : NULL;
2378
2379 if (slot1 == slot2) {
2380 slot2 = NULL;
2381 }
2382 }
2383
2384 if (slot1 != NULL) {
2385 if (slot2 != NULL) {
2386 if (Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
2387 PyObject *x = slot2(operand1, operand2);
2388
2389 if (x != Py_NotImplemented) {
2390 obj_result = x;
2391 goto exit_binary_result_object;
2392 }
2393
2394 Py_DECREF_IMMORTAL(x);
2395 slot2 = NULL;
2396 }
2397 }
2398
2399 PyObject *x = slot1(operand1, operand2);
2400
2401 if (x != Py_NotImplemented) {
2402 obj_result = x;
2403 goto exit_binary_result_object;
2404 }
2405
2406 Py_DECREF_IMMORTAL(x);
2407 }
2408
2409 if (slot2 != NULL) {
2410 PyObject *x = slot2(operand1, operand2);
2411
2412 if (x != Py_NotImplemented) {
2413 obj_result = x;
2414 goto exit_binary_result_object;
2415 }
2416
2417 Py_DECREF_IMMORTAL(x);
2418 }
2419
2420#if PYTHON_VERSION < 0x300
2421 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
2422 coercion c1 = PyFloat_Type.tp_as_number->nb_coerce;
2423
2424 if (c1 != NULL) {
2425 PyObject *coerced1 = operand1;
2426 PyObject *coerced2 = operand2;
2427
2428 int err = c1(&coerced1, &coerced2);
2429
2430 if (unlikely(err < 0)) {
2431 goto exit_binary_exception;
2432 }
2433
2434 if (err == 0) {
2435 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2436
2437 if (likely(mv == NULL)) {
2438 binaryfunc slot = mv->nb_multiply;
2439
2440 if (likely(slot != NULL)) {
2441 PyObject *x = slot(coerced1, coerced2);
2442
2443 Py_DECREF(coerced1);
2444 Py_DECREF(coerced2);
2445
2446 obj_result = x;
2447 goto exit_binary_result_object;
2448 }
2449 }
2450
2451 // nb_coerce took a reference.
2452 Py_DECREF(coerced1);
2453 Py_DECREF(coerced2);
2454 }
2455 }
2456 coercion c2 =
2457 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
2458
2459 if (c2 != NULL) {
2460 PyObject *coerced1 = operand1;
2461 PyObject *coerced2 = operand2;
2462
2463 int err = c2(&coerced2, &coerced1);
2464
2465 if (unlikely(err < 0)) {
2466 goto exit_binary_exception;
2467 }
2468
2469 if (err == 0) {
2470 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2471
2472 if (likely(mv == NULL)) {
2473 binaryfunc slot = mv->nb_multiply;
2474
2475 if (likely(slot != NULL)) {
2476 PyObject *x = slot(coerced1, coerced2);
2477
2478 Py_DECREF(coerced1);
2479 Py_DECREF(coerced2);
2480
2481 obj_result = x;
2482 goto exit_binary_result_object;
2483 }
2484 }
2485
2486 // nb_coerce took a reference.
2487 Py_DECREF(coerced1);
2488 Py_DECREF(coerced2);
2489 }
2490 }
2491 }
2492#endif
2493
2494 {
2495 // No sequence repeat slot sq_repeat available for this type.
2496 }
2497 // Special case for "*", also work with sequence repeat from right argument.
2498 {
2499 ssizeargfunc sq_slot = type2->tp_as_sequence != NULL ? type2->tp_as_sequence->sq_repeat : NULL;
2500
2501 if (sq_slot != NULL) {
2502 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand2, operand1);
2503
2504 obj_result = result;
2505 goto exit_binary_result_object;
2506 }
2507 }
2508
2509 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: 'float' and '%s'", type2->tp_name);
2510 goto exit_binary_exception;
2511
2512exit_binary_result_object:
2513 return obj_result;
2514
2515exit_binary_exception:
2516 return NULL;
2517}
2518static PyObject *_BINARY_OPERATION_MULT_OBJECT_FLOAT_OBJECT(PyObject *operand1, PyObject *operand2) {
2519 CHECK_OBJECT(operand1);
2520 assert(PyFloat_CheckExact(operand1));
2521 CHECK_OBJECT(operand2);
2522
2523 PyTypeObject *type2 = Py_TYPE(operand2);
2524
2525 if (&PyFloat_Type == type2) {
2526 PyObject *result;
2527
2528 // return _BINARY_OPERATION_MULT_OBJECT_FLOAT_FLOAT(operand1, operand2);
2529
2530#if defined(_MSC_VER)
2531#pragma warning(push)
2532#pragma warning(disable : 4101)
2533#endif
2534 // Not every code path will make use of all possible results.
2535 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2536 NUITKA_MAY_BE_UNUSED long clong_result;
2537 NUITKA_MAY_BE_UNUSED double cfloat_result;
2538#if defined(_MSC_VER)
2539#pragma warning(pop)
2540#endif
2541
2542 CHECK_OBJECT(operand1);
2543 assert(PyFloat_CheckExact(operand1));
2544 CHECK_OBJECT(operand2);
2545 assert(PyFloat_CheckExact(operand2));
2546
2547 const double a = PyFloat_AS_DOUBLE(operand1);
2548 const double b = PyFloat_AS_DOUBLE(operand2);
2549
2550 double r = a * b;
2551
2552 cfloat_result = r;
2553 goto exit_result_ok_cfloat;
2554
2555 exit_result_ok_cfloat:
2556 result = MAKE_FLOAT_FROM_DOUBLE(cfloat_result);
2557 goto exit_result_ok;
2558
2559 exit_result_ok:
2560 return result;
2561 }
2562
2563 return __BINARY_OPERATION_MULT_OBJECT_FLOAT_OBJECT(operand1, operand2);
2564}
2565
2566PyObject *BINARY_OPERATION_MULT_OBJECT_FLOAT_OBJECT(PyObject *operand1, PyObject *operand2) {
2567 return _BINARY_OPERATION_MULT_OBJECT_FLOAT_OBJECT(operand1, operand2);
2568}
2569
2570/* Code referring to "FLOAT" corresponds to Python 'float' and "FLOAT" to Python 'float'. */
2571static nuitka_bool _BINARY_OPERATION_MULT_NBOOL_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
2572 CHECK_OBJECT(operand1);
2573 assert(PyFloat_CheckExact(operand1));
2574 CHECK_OBJECT(operand2);
2575 assert(PyFloat_CheckExact(operand2));
2576
2577 nuitka_bool result;
2578
2579#if defined(_MSC_VER)
2580#pragma warning(push)
2581#pragma warning(disable : 4101)
2582#endif
2583 // Not every code path will make use of all possible results.
2584 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2585 NUITKA_MAY_BE_UNUSED long clong_result;
2586 NUITKA_MAY_BE_UNUSED double cfloat_result;
2587#if defined(_MSC_VER)
2588#pragma warning(pop)
2589#endif
2590
2591 CHECK_OBJECT(operand1);
2592 assert(PyFloat_CheckExact(operand1));
2593 CHECK_OBJECT(operand2);
2594 assert(PyFloat_CheckExact(operand2));
2595
2596 const double a = PyFloat_AS_DOUBLE(operand1);
2597 const double b = PyFloat_AS_DOUBLE(operand2);
2598
2599 double r = a * b;
2600
2601 cfloat_result = r;
2602 goto exit_result_ok_cfloat;
2603
2604exit_result_ok_cfloat:
2605 result = cfloat_result != 0.0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2606 goto exit_result_ok;
2607
2608exit_result_ok:
2609 return result;
2610}
2611
2612nuitka_bool BINARY_OPERATION_MULT_NBOOL_FLOAT_FLOAT(PyObject *operand1, PyObject *operand2) {
2613 return _BINARY_OPERATION_MULT_NBOOL_FLOAT_FLOAT(operand1, operand2);
2614}
2615
2616/* Code referring to "OBJECT" corresponds to any Python object and "FLOAT" to Python 'float'. */
2617static HEDLEY_NEVER_INLINE nuitka_bool __BINARY_OPERATION_MULT_NBOOL_OBJECT_FLOAT(PyObject *operand1,
2618 PyObject *operand2) {
2619 PyTypeObject *type1 = Py_TYPE(operand1);
2620
2621#if defined(_MSC_VER)
2622#pragma warning(push)
2623#pragma warning(disable : 4101)
2624#endif
2625 NUITKA_MAY_BE_UNUSED bool cbool_result;
2626 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2627#if defined(_MSC_VER)
2628#pragma warning(pop)
2629#endif
2630
2631 binaryfunc slot1 =
2632 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_multiply : NULL;
2633 binaryfunc slot2 = NULL;
2634
2635 if (!(type1 == &PyFloat_Type)) {
2636 // Different types, need to consider second value slot.
2637
2638 slot2 = PyFloat_Type.tp_as_number->nb_multiply;
2639
2640 if (slot1 == slot2) {
2641 slot2 = NULL;
2642 }
2643 }
2644
2645 if (slot1 != NULL) {
2646 PyObject *x = slot1(operand1, operand2);
2647
2648 if (x != Py_NotImplemented) {
2649 obj_result = x;
2650 goto exit_binary_result_object;
2651 }
2652
2653 Py_DECREF_IMMORTAL(x);
2654 }
2655
2656 if (slot2 != NULL) {
2657 PyObject *x = slot2(operand1, operand2);
2658
2659 if (x != Py_NotImplemented) {
2660 obj_result = x;
2661 goto exit_binary_result_object;
2662 }
2663
2664 Py_DECREF_IMMORTAL(x);
2665 }
2666
2667#if PYTHON_VERSION < 0x300
2668 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
2669 coercion c1 =
2670 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
2671
2672 if (c1 != NULL) {
2673 PyObject *coerced1 = operand1;
2674 PyObject *coerced2 = operand2;
2675
2676 int err = c1(&coerced1, &coerced2);
2677
2678 if (unlikely(err < 0)) {
2679 goto exit_binary_exception;
2680 }
2681
2682 if (err == 0) {
2683 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2684
2685 if (likely(mv == NULL)) {
2686 binaryfunc slot = mv->nb_multiply;
2687
2688 if (likely(slot != NULL)) {
2689 PyObject *x = slot(coerced1, coerced2);
2690
2691 Py_DECREF(coerced1);
2692 Py_DECREF(coerced2);
2693
2694 obj_result = x;
2695 goto exit_binary_result_object;
2696 }
2697 }
2698
2699 // nb_coerce took a reference.
2700 Py_DECREF(coerced1);
2701 Py_DECREF(coerced2);
2702 }
2703 }
2704 coercion c2 = PyFloat_Type.tp_as_number->nb_coerce;
2705
2706 if (c2 != NULL) {
2707 PyObject *coerced1 = operand1;
2708 PyObject *coerced2 = operand2;
2709
2710 int err = c2(&coerced2, &coerced1);
2711
2712 if (unlikely(err < 0)) {
2713 goto exit_binary_exception;
2714 }
2715
2716 if (err == 0) {
2717 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2718
2719 if (likely(mv == NULL)) {
2720 binaryfunc slot = mv->nb_multiply;
2721
2722 if (likely(slot != NULL)) {
2723 PyObject *x = slot(coerced1, coerced2);
2724
2725 Py_DECREF(coerced1);
2726 Py_DECREF(coerced2);
2727
2728 obj_result = x;
2729 goto exit_binary_result_object;
2730 }
2731 }
2732
2733 // nb_coerce took a reference.
2734 Py_DECREF(coerced1);
2735 Py_DECREF(coerced2);
2736 }
2737 }
2738 }
2739#endif
2740
2741 {
2742 // Special case for "+" and "*", also works as sequence concat/repeat.
2743 ssizeargfunc sq_slot = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_repeat : NULL;
2744
2745 if (sq_slot != NULL) {
2746 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand1, operand2);
2747
2748 obj_result = result;
2749 goto exit_binary_result_object;
2750 }
2751 }
2752 // No sequence repeat slot sq_repeat available for this type.
2753
2754 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: '%s' and 'float'", type1->tp_name);
2755 goto exit_binary_exception;
2756
2757exit_binary_result_object:
2758 if (unlikely(obj_result == NULL)) {
2759 return NUITKA_BOOL_EXCEPTION;
2760 }
2761
2762 {
2763 nuitka_bool r = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2764 Py_DECREF(obj_result);
2765 return r;
2766 }
2767
2768exit_binary_exception:
2769 return NUITKA_BOOL_EXCEPTION;
2770}
2771static nuitka_bool _BINARY_OPERATION_MULT_NBOOL_OBJECT_FLOAT(PyObject *operand1, PyObject *operand2) {
2772 CHECK_OBJECT(operand1);
2773 CHECK_OBJECT(operand2);
2774 assert(PyFloat_CheckExact(operand2));
2775
2776 PyTypeObject *type1 = Py_TYPE(operand1);
2777
2778 if (type1 == &PyFloat_Type) {
2779 nuitka_bool result;
2780
2781 // return _BINARY_OPERATION_MULT_NBOOL_FLOAT_FLOAT(operand1, operand2);
2782
2783#if defined(_MSC_VER)
2784#pragma warning(push)
2785#pragma warning(disable : 4101)
2786#endif
2787 // Not every code path will make use of all possible results.
2788 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2789 NUITKA_MAY_BE_UNUSED long clong_result;
2790 NUITKA_MAY_BE_UNUSED double cfloat_result;
2791#if defined(_MSC_VER)
2792#pragma warning(pop)
2793#endif
2794
2795 CHECK_OBJECT(operand1);
2796 assert(PyFloat_CheckExact(operand1));
2797 CHECK_OBJECT(operand2);
2798 assert(PyFloat_CheckExact(operand2));
2799
2800 const double a = PyFloat_AS_DOUBLE(operand1);
2801 const double b = PyFloat_AS_DOUBLE(operand2);
2802
2803 double r = a * b;
2804
2805 cfloat_result = r;
2806 goto exit_result_ok_cfloat;
2807
2808 exit_result_ok_cfloat:
2809 result = cfloat_result != 0.0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2810 goto exit_result_ok;
2811
2812 exit_result_ok:
2813 return result;
2814 }
2815
2816 return __BINARY_OPERATION_MULT_NBOOL_OBJECT_FLOAT(operand1, operand2);
2817}
2818
2819nuitka_bool BINARY_OPERATION_MULT_NBOOL_OBJECT_FLOAT(PyObject *operand1, PyObject *operand2) {
2820 return _BINARY_OPERATION_MULT_NBOOL_OBJECT_FLOAT(operand1, operand2);
2821}
2822
2823/* Code referring to "FLOAT" corresponds to Python 'float' and "OBJECT" to any Python object. */
2824static HEDLEY_NEVER_INLINE nuitka_bool __BINARY_OPERATION_MULT_NBOOL_FLOAT_OBJECT(PyObject *operand1,
2825 PyObject *operand2) {
2826 PyTypeObject *type2 = Py_TYPE(operand2);
2827
2828#if defined(_MSC_VER)
2829#pragma warning(push)
2830#pragma warning(disable : 4101)
2831#endif
2832 NUITKA_MAY_BE_UNUSED bool cbool_result;
2833 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
2834#if defined(_MSC_VER)
2835#pragma warning(pop)
2836#endif
2837
2838 binaryfunc slot1 = PyFloat_Type.tp_as_number->nb_multiply;
2839 binaryfunc slot2 = NULL;
2840
2841 if (!(&PyFloat_Type == type2)) {
2842 // Different types, need to consider second value slot.
2843
2844 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_multiply : NULL;
2845
2846 if (slot1 == slot2) {
2847 slot2 = NULL;
2848 }
2849 }
2850
2851 if (slot1 != NULL) {
2852 if (slot2 != NULL) {
2853 if (Nuitka_Type_IsSubtype(type2, &PyFloat_Type)) {
2854 PyObject *x = slot2(operand1, operand2);
2855
2856 if (x != Py_NotImplemented) {
2857 obj_result = x;
2858 goto exit_binary_result_object;
2859 }
2860
2861 Py_DECREF_IMMORTAL(x);
2862 slot2 = NULL;
2863 }
2864 }
2865
2866 PyObject *x = slot1(operand1, operand2);
2867
2868 if (x != Py_NotImplemented) {
2869 obj_result = x;
2870 goto exit_binary_result_object;
2871 }
2872
2873 Py_DECREF_IMMORTAL(x);
2874 }
2875
2876 if (slot2 != NULL) {
2877 PyObject *x = slot2(operand1, operand2);
2878
2879 if (x != Py_NotImplemented) {
2880 obj_result = x;
2881 goto exit_binary_result_object;
2882 }
2883
2884 Py_DECREF_IMMORTAL(x);
2885 }
2886
2887#if PYTHON_VERSION < 0x300
2888 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
2889 coercion c1 = PyFloat_Type.tp_as_number->nb_coerce;
2890
2891 if (c1 != NULL) {
2892 PyObject *coerced1 = operand1;
2893 PyObject *coerced2 = operand2;
2894
2895 int err = c1(&coerced1, &coerced2);
2896
2897 if (unlikely(err < 0)) {
2898 goto exit_binary_exception;
2899 }
2900
2901 if (err == 0) {
2902 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2903
2904 if (likely(mv == NULL)) {
2905 binaryfunc slot = mv->nb_multiply;
2906
2907 if (likely(slot != NULL)) {
2908 PyObject *x = slot(coerced1, coerced2);
2909
2910 Py_DECREF(coerced1);
2911 Py_DECREF(coerced2);
2912
2913 obj_result = x;
2914 goto exit_binary_result_object;
2915 }
2916 }
2917
2918 // nb_coerce took a reference.
2919 Py_DECREF(coerced1);
2920 Py_DECREF(coerced2);
2921 }
2922 }
2923 coercion c2 =
2924 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
2925
2926 if (c2 != NULL) {
2927 PyObject *coerced1 = operand1;
2928 PyObject *coerced2 = operand2;
2929
2930 int err = c2(&coerced2, &coerced1);
2931
2932 if (unlikely(err < 0)) {
2933 goto exit_binary_exception;
2934 }
2935
2936 if (err == 0) {
2937 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
2938
2939 if (likely(mv == NULL)) {
2940 binaryfunc slot = mv->nb_multiply;
2941
2942 if (likely(slot != NULL)) {
2943 PyObject *x = slot(coerced1, coerced2);
2944
2945 Py_DECREF(coerced1);
2946 Py_DECREF(coerced2);
2947
2948 obj_result = x;
2949 goto exit_binary_result_object;
2950 }
2951 }
2952
2953 // nb_coerce took a reference.
2954 Py_DECREF(coerced1);
2955 Py_DECREF(coerced2);
2956 }
2957 }
2958 }
2959#endif
2960
2961 {
2962 // No sequence repeat slot sq_repeat available for this type.
2963 }
2964 // Special case for "*", also work with sequence repeat from right argument.
2965 {
2966 ssizeargfunc sq_slot = type2->tp_as_sequence != NULL ? type2->tp_as_sequence->sq_repeat : NULL;
2967
2968 if (sq_slot != NULL) {
2969 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand2, operand1);
2970
2971 obj_result = result;
2972 goto exit_binary_result_object;
2973 }
2974 }
2975
2976 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: 'float' and '%s'", type2->tp_name);
2977 goto exit_binary_exception;
2978
2979exit_binary_result_object:
2980 if (unlikely(obj_result == NULL)) {
2981 return NUITKA_BOOL_EXCEPTION;
2982 }
2983
2984 {
2985 nuitka_bool r = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
2986 Py_DECREF(obj_result);
2987 return r;
2988 }
2989
2990exit_binary_exception:
2991 return NUITKA_BOOL_EXCEPTION;
2992}
2993static nuitka_bool _BINARY_OPERATION_MULT_NBOOL_FLOAT_OBJECT(PyObject *operand1, PyObject *operand2) {
2994 CHECK_OBJECT(operand1);
2995 assert(PyFloat_CheckExact(operand1));
2996 CHECK_OBJECT(operand2);
2997
2998 PyTypeObject *type2 = Py_TYPE(operand2);
2999
3000 if (&PyFloat_Type == type2) {
3001 nuitka_bool result;
3002
3003 // return _BINARY_OPERATION_MULT_NBOOL_FLOAT_FLOAT(operand1, operand2);
3004
3005#if defined(_MSC_VER)
3006#pragma warning(push)
3007#pragma warning(disable : 4101)
3008#endif
3009 // Not every code path will make use of all possible results.
3010 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
3011 NUITKA_MAY_BE_UNUSED long clong_result;
3012 NUITKA_MAY_BE_UNUSED double cfloat_result;
3013#if defined(_MSC_VER)
3014#pragma warning(pop)
3015#endif
3016
3017 CHECK_OBJECT(operand1);
3018 assert(PyFloat_CheckExact(operand1));
3019 CHECK_OBJECT(operand2);
3020 assert(PyFloat_CheckExact(operand2));
3021
3022 const double a = PyFloat_AS_DOUBLE(operand1);
3023 const double b = PyFloat_AS_DOUBLE(operand2);
3024
3025 double r = a * b;
3026
3027 cfloat_result = r;
3028 goto exit_result_ok_cfloat;
3029
3030 exit_result_ok_cfloat:
3031 result = cfloat_result != 0.0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3032 goto exit_result_ok;
3033
3034 exit_result_ok:
3035 return result;
3036 }
3037
3038 return __BINARY_OPERATION_MULT_NBOOL_FLOAT_OBJECT(operand1, operand2);
3039}
3040
3041nuitka_bool BINARY_OPERATION_MULT_NBOOL_FLOAT_OBJECT(PyObject *operand1, PyObject *operand2) {
3042 return _BINARY_OPERATION_MULT_NBOOL_FLOAT_OBJECT(operand1, operand2);
3043}
3044
3045/* Code referring to "FLOAT" corresponds to Python 'float' and "LONG" to Python2 'long', Python3 'int'. */
3046static PyObject *_BINARY_OPERATION_MULT_OBJECT_FLOAT_LONG(PyObject *operand1, PyObject *operand2) {
3047 CHECK_OBJECT(operand1);
3048 assert(PyFloat_CheckExact(operand1));
3049 CHECK_OBJECT(operand2);
3050 assert(PyLong_CheckExact(operand2));
3051
3052#if defined(_MSC_VER)
3053#pragma warning(push)
3054#pragma warning(disable : 4101)
3055#endif
3056 NUITKA_MAY_BE_UNUSED bool cbool_result;
3057 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
3058#if defined(_MSC_VER)
3059#pragma warning(pop)
3060#endif
3061
3062 binaryfunc slot1 = PyFloat_Type.tp_as_number->nb_multiply;
3063 // Slot2 ignored on purpose, type1 takes precedence.
3064
3065 if (slot1 != NULL) {
3066 PyObject *x = slot1(operand1, operand2);
3067
3068 if (x != Py_NotImplemented) {
3069 obj_result = x;
3070 goto exit_binary_result_object;
3071 }
3072
3073 Py_DECREF_IMMORTAL(x);
3074 }
3075
3076 // Statically recognized that coercion is not possible with these types
3077
3078 {
3079 // No sequence repeat slot sq_repeat available for this type.
3080 }
3081 // No sequence repeat slot sq_repeat available for this type.
3082
3083#if PYTHON_VERSION < 0x300
3084 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: 'float' and 'long'");
3085#else
3086 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: 'float' and 'int'");
3087#endif
3088 goto exit_binary_exception;
3089
3090exit_binary_result_object:
3091 return obj_result;
3092
3093exit_binary_exception:
3094 return NULL;
3095}
3096
3097PyObject *BINARY_OPERATION_MULT_OBJECT_FLOAT_LONG(PyObject *operand1, PyObject *operand2) {
3098 return _BINARY_OPERATION_MULT_OBJECT_FLOAT_LONG(operand1, operand2);
3099}
3100
3101/* Code referring to "FLOAT" corresponds to Python 'float' and "LONG" to Python2 'long', Python3 'int'. */
3102static nuitka_bool _BINARY_OPERATION_MULT_NBOOL_FLOAT_LONG(PyObject *operand1, PyObject *operand2) {
3103 CHECK_OBJECT(operand1);
3104 assert(PyFloat_CheckExact(operand1));
3105 CHECK_OBJECT(operand2);
3106 assert(PyLong_CheckExact(operand2));
3107
3108#if defined(_MSC_VER)
3109#pragma warning(push)
3110#pragma warning(disable : 4101)
3111#endif
3112 NUITKA_MAY_BE_UNUSED bool cbool_result;
3113 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
3114#if defined(_MSC_VER)
3115#pragma warning(pop)
3116#endif
3117
3118 binaryfunc slot1 = PyFloat_Type.tp_as_number->nb_multiply;
3119 // Slot2 ignored on purpose, type1 takes precedence.
3120
3121 if (slot1 != NULL) {
3122 PyObject *x = slot1(operand1, operand2);
3123
3124 if (x != Py_NotImplemented) {
3125 obj_result = x;
3126 goto exit_binary_result_object;
3127 }
3128
3129 Py_DECREF_IMMORTAL(x);
3130 }
3131
3132 // Statically recognized that coercion is not possible with these types
3133
3134 {
3135 // No sequence repeat slot sq_repeat available for this type.
3136 }
3137 // No sequence repeat slot sq_repeat available for this type.
3138
3139#if PYTHON_VERSION < 0x300
3140 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: 'float' and 'long'");
3141#else
3142 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: 'float' and 'int'");
3143#endif
3144 goto exit_binary_exception;
3145
3146exit_binary_result_object:
3147 if (unlikely(obj_result == NULL)) {
3148 return NUITKA_BOOL_EXCEPTION;
3149 }
3150
3151 {
3152 nuitka_bool r = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3153 Py_DECREF(obj_result);
3154 return r;
3155 }
3156
3157exit_binary_exception:
3158 return NUITKA_BOOL_EXCEPTION;
3159}
3160
3161nuitka_bool BINARY_OPERATION_MULT_NBOOL_FLOAT_LONG(PyObject *operand1, PyObject *operand2) {
3162 return _BINARY_OPERATION_MULT_NBOOL_FLOAT_LONG(operand1, operand2);
3163}
3164
3165#if PYTHON_VERSION < 0x300
3166/* Code referring to "FLOAT" corresponds to Python 'float' and "INT" to Python2 'int'. */
3167static PyObject *_BINARY_OPERATION_MULT_OBJECT_FLOAT_INT(PyObject *operand1, PyObject *operand2) {
3168 CHECK_OBJECT(operand1);
3169 assert(PyFloat_CheckExact(operand1));
3170 CHECK_OBJECT(operand2);
3171 assert(PyInt_CheckExact(operand2));
3172
3173#if defined(_MSC_VER)
3174#pragma warning(push)
3175#pragma warning(disable : 4101)
3176#endif
3177 NUITKA_MAY_BE_UNUSED bool cbool_result;
3178 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
3179#if defined(_MSC_VER)
3180#pragma warning(pop)
3181#endif
3182
3183 binaryfunc slot1 = PyFloat_Type.tp_as_number->nb_multiply;
3184 // Slot2 ignored on purpose, type1 takes precedence.
3185
3186 if (slot1 != NULL) {
3187 PyObject *x = slot1(operand1, operand2);
3188
3189 if (x != Py_NotImplemented) {
3190 obj_result = x;
3191 goto exit_binary_result_object;
3192 }
3193
3194 Py_DECREF_IMMORTAL(x);
3195 }
3196
3197 // Statically recognized that coercion is not possible with these types
3198
3199 {
3200 // No sequence repeat slot sq_repeat available for this type.
3201 }
3202 // No sequence repeat slot sq_repeat available for this type.
3203
3204 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: 'float' and 'int'");
3205 goto exit_binary_exception;
3206
3207exit_binary_result_object:
3208 return obj_result;
3209
3210exit_binary_exception:
3211 return NULL;
3212}
3213
3214PyObject *BINARY_OPERATION_MULT_OBJECT_FLOAT_INT(PyObject *operand1, PyObject *operand2) {
3215 return _BINARY_OPERATION_MULT_OBJECT_FLOAT_INT(operand1, operand2);
3216}
3217#endif
3218
3219#if PYTHON_VERSION < 0x300
3220/* Code referring to "FLOAT" corresponds to Python 'float' and "INT" to Python2 'int'. */
3221static nuitka_bool _BINARY_OPERATION_MULT_NBOOL_FLOAT_INT(PyObject *operand1, PyObject *operand2) {
3222 CHECK_OBJECT(operand1);
3223 assert(PyFloat_CheckExact(operand1));
3224 CHECK_OBJECT(operand2);
3225 assert(PyInt_CheckExact(operand2));
3226
3227#if defined(_MSC_VER)
3228#pragma warning(push)
3229#pragma warning(disable : 4101)
3230#endif
3231 NUITKA_MAY_BE_UNUSED bool cbool_result;
3232 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
3233#if defined(_MSC_VER)
3234#pragma warning(pop)
3235#endif
3236
3237 binaryfunc slot1 = PyFloat_Type.tp_as_number->nb_multiply;
3238 // Slot2 ignored on purpose, type1 takes precedence.
3239
3240 if (slot1 != NULL) {
3241 PyObject *x = slot1(operand1, operand2);
3242
3243 if (x != Py_NotImplemented) {
3244 obj_result = x;
3245 goto exit_binary_result_object;
3246 }
3247
3248 Py_DECREF_IMMORTAL(x);
3249 }
3250
3251 // Statically recognized that coercion is not possible with these types
3252
3253 {
3254 // No sequence repeat slot sq_repeat available for this type.
3255 }
3256 // No sequence repeat slot sq_repeat available for this type.
3257
3258 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: 'float' and 'int'");
3259 goto exit_binary_exception;
3260
3261exit_binary_result_object:
3262 if (unlikely(obj_result == NULL)) {
3263 return NUITKA_BOOL_EXCEPTION;
3264 }
3265
3266 {
3267 nuitka_bool r = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3268 Py_DECREF(obj_result);
3269 return r;
3270 }
3271
3272exit_binary_exception:
3273 return NUITKA_BOOL_EXCEPTION;
3274}
3275
3276nuitka_bool BINARY_OPERATION_MULT_NBOOL_FLOAT_INT(PyObject *operand1, PyObject *operand2) {
3277 return _BINARY_OPERATION_MULT_NBOOL_FLOAT_INT(operand1, operand2);
3278}
3279#endif
3280
3281#if PYTHON_VERSION < 0x300
3282/* Code referring to "LONG" corresponds to Python2 'long', Python3 'int' and "INT" to Python2 'int'. */
3283static PyObject *_BINARY_OPERATION_MULT_OBJECT_LONG_INT(PyObject *operand1, PyObject *operand2) {
3284 CHECK_OBJECT(operand1);
3285 assert(PyLong_CheckExact(operand1));
3286 CHECK_OBJECT(operand2);
3287 assert(PyInt_CheckExact(operand2));
3288
3289#if defined(_MSC_VER)
3290#pragma warning(push)
3291#pragma warning(disable : 4101)
3292#endif
3293 NUITKA_MAY_BE_UNUSED bool cbool_result;
3294 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
3295#if defined(_MSC_VER)
3296#pragma warning(pop)
3297#endif
3298
3299 binaryfunc slot1 = PyLong_Type.tp_as_number->nb_multiply;
3300 // Slot2 ignored on purpose, type1 takes precedence.
3301
3302 if (slot1 != NULL) {
3303 PyObject *x = slot1(operand1, operand2);
3304
3305 if (x != Py_NotImplemented) {
3306 obj_result = x;
3307 goto exit_binary_result_object;
3308 }
3309
3310 Py_DECREF_IMMORTAL(x);
3311 }
3312
3313 // Statically recognized that coercion is not possible with these types
3314
3315 {
3316 // No sequence repeat slot sq_repeat available for this type.
3317 }
3318 // No sequence repeat slot sq_repeat available for this type.
3319
3320 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: 'long' and 'int'");
3321 goto exit_binary_exception;
3322
3323exit_binary_result_object:
3324 return obj_result;
3325
3326exit_binary_exception:
3327 return NULL;
3328}
3329
3330PyObject *BINARY_OPERATION_MULT_OBJECT_LONG_INT(PyObject *operand1, PyObject *operand2) {
3331 return _BINARY_OPERATION_MULT_OBJECT_LONG_INT(operand1, operand2);
3332}
3333#endif
3334
3335#if PYTHON_VERSION < 0x300
3336/* Code referring to "LONG" corresponds to Python2 'long', Python3 'int' and "INT" to Python2 'int'. */
3337static nuitka_bool _BINARY_OPERATION_MULT_NBOOL_LONG_INT(PyObject *operand1, PyObject *operand2) {
3338 CHECK_OBJECT(operand1);
3339 assert(PyLong_CheckExact(operand1));
3340 CHECK_OBJECT(operand2);
3341 assert(PyInt_CheckExact(operand2));
3342
3343#if defined(_MSC_VER)
3344#pragma warning(push)
3345#pragma warning(disable : 4101)
3346#endif
3347 NUITKA_MAY_BE_UNUSED bool cbool_result;
3348 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
3349#if defined(_MSC_VER)
3350#pragma warning(pop)
3351#endif
3352
3353 binaryfunc slot1 = PyLong_Type.tp_as_number->nb_multiply;
3354 // Slot2 ignored on purpose, type1 takes precedence.
3355
3356 if (slot1 != NULL) {
3357 PyObject *x = slot1(operand1, operand2);
3358
3359 if (x != Py_NotImplemented) {
3360 obj_result = x;
3361 goto exit_binary_result_object;
3362 }
3363
3364 Py_DECREF_IMMORTAL(x);
3365 }
3366
3367 // Statically recognized that coercion is not possible with these types
3368
3369 {
3370 // No sequence repeat slot sq_repeat available for this type.
3371 }
3372 // No sequence repeat slot sq_repeat available for this type.
3373
3374 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: 'long' and 'int'");
3375 goto exit_binary_exception;
3376
3377exit_binary_result_object:
3378 if (unlikely(obj_result == NULL)) {
3379 return NUITKA_BOOL_EXCEPTION;
3380 }
3381
3382 {
3383 nuitka_bool r = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3384 Py_DECREF(obj_result);
3385 return r;
3386 }
3387
3388exit_binary_exception:
3389 return NUITKA_BOOL_EXCEPTION;
3390}
3391
3392nuitka_bool BINARY_OPERATION_MULT_NBOOL_LONG_INT(PyObject *operand1, PyObject *operand2) {
3393 return _BINARY_OPERATION_MULT_NBOOL_LONG_INT(operand1, operand2);
3394}
3395#endif
3396
3397#if PYTHON_VERSION < 0x300
3398/* Code referring to "INT" corresponds to Python2 'int' and "CLONG" to C platform long value. */
3399static PyObject *_BINARY_OPERATION_MULT_OBJECT_INT_CLONG(PyObject *operand1, long operand2) {
3400 CHECK_OBJECT(operand1);
3401 assert(PyInt_CheckExact(operand1));
3402
3403 PyObject *result;
3404
3405 // Not every code path will make use of all possible results.
3406#if defined(_MSC_VER)
3407#pragma warning(push)
3408#pragma warning(disable : 4101)
3409#endif
3410 NUITKA_MAY_BE_UNUSED bool cbool_result;
3411 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
3412 NUITKA_MAY_BE_UNUSED long clong_result;
3413 NUITKA_MAY_BE_UNUSED double cfloat_result;
3414#if defined(_MSC_VER)
3415#pragma warning(pop)
3416#endif
3417
3418 CHECK_OBJECT(operand1);
3419 assert(PyInt_CheckExact(operand1));
3420
3421 const long a = PyInt_AS_LONG(operand1);
3422 const long b = operand2;
3423
3424 const long longprod = (long)((unsigned long)a * b);
3425 const double doubleprod = (double)a * (double)b;
3426 const double doubled_longprod = (double)longprod;
3427
3428 if (likely(doubled_longprod == doubleprod)) {
3429 clong_result = longprod;
3430 goto exit_result_ok_clong;
3431 } else {
3432 const double diff = doubled_longprod - doubleprod;
3433 const double absdiff = diff >= 0.0 ? diff : -diff;
3434 const double absprod = doubleprod >= 0.0 ? doubleprod : -doubleprod;
3435
3436 if (likely(32.0 * absdiff <= absprod)) {
3437 clong_result = longprod;
3438 goto exit_result_ok_clong;
3439 }
3440 }
3441
3442 {
3443 PyObject *operand1_object = operand1;
3444 PyObject *operand2_object = Nuitka_PyLong_FromLong(operand2);
3445
3446 PyObject *r = PyLong_Type.tp_as_number->nb_multiply(operand1_object, operand2_object);
3447 assert(r != Py_NotImplemented);
3448
3449 Py_DECREF(operand2_object);
3450
3451 obj_result = r;
3452 goto exit_result_object;
3453 }
3454
3455exit_result_ok_clong:
3456 result = Nuitka_PyInt_FromLong(clong_result);
3457 goto exit_result_ok;
3458
3459exit_result_object:
3460 if (unlikely(obj_result == NULL)) {
3461 goto exit_result_exception;
3462 }
3463 result = obj_result;
3464 goto exit_result_ok;
3465
3466exit_result_ok:
3467 return result;
3468
3469exit_result_exception:
3470 return NULL;
3471}
3472
3473PyObject *BINARY_OPERATION_MULT_OBJECT_INT_CLONG(PyObject *operand1, long operand2) {
3474 return _BINARY_OPERATION_MULT_OBJECT_INT_CLONG(operand1, operand2);
3475}
3476#endif
3477
3478#if PYTHON_VERSION < 0x300
3479/* Code referring to "INT" corresponds to Python2 'int' and "CLONG" to C platform long value. */
3480static nuitka_bool _BINARY_OPERATION_MULT_NBOOL_INT_CLONG(PyObject *operand1, long operand2) {
3481 CHECK_OBJECT(operand1);
3482 assert(PyInt_CheckExact(operand1));
3483
3484 nuitka_bool result;
3485
3486 // Not every code path will make use of all possible results.
3487#if defined(_MSC_VER)
3488#pragma warning(push)
3489#pragma warning(disable : 4101)
3490#endif
3491 NUITKA_MAY_BE_UNUSED bool cbool_result;
3492 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
3493 NUITKA_MAY_BE_UNUSED long clong_result;
3494 NUITKA_MAY_BE_UNUSED double cfloat_result;
3495#if defined(_MSC_VER)
3496#pragma warning(pop)
3497#endif
3498
3499 CHECK_OBJECT(operand1);
3500 assert(PyInt_CheckExact(operand1));
3501
3502 const long a = PyInt_AS_LONG(operand1);
3503 const long b = operand2;
3504
3505 const long longprod = (long)((unsigned long)a * b);
3506 const double doubleprod = (double)a * (double)b;
3507 const double doubled_longprod = (double)longprod;
3508
3509 if (likely(doubled_longprod == doubleprod)) {
3510 clong_result = longprod;
3511 goto exit_result_ok_clong;
3512 } else {
3513 const double diff = doubled_longprod - doubleprod;
3514 const double absdiff = diff >= 0.0 ? diff : -diff;
3515 const double absprod = doubleprod >= 0.0 ? doubleprod : -doubleprod;
3516
3517 if (likely(32.0 * absdiff <= absprod)) {
3518 clong_result = longprod;
3519 goto exit_result_ok_clong;
3520 }
3521 }
3522
3523 {
3524 PyObject *operand1_object = operand1;
3525 PyObject *operand2_object = Nuitka_PyLong_FromLong(operand2);
3526
3527 PyObject *r = PyLong_Type.tp_as_number->nb_multiply(operand1_object, operand2_object);
3528 assert(r != Py_NotImplemented);
3529
3530 Py_DECREF(operand2_object);
3531
3532 obj_result = r;
3533 goto exit_result_object;
3534 }
3535
3536exit_result_ok_clong:
3537 result = clong_result != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3538 goto exit_result_ok;
3539
3540exit_result_object:
3541 if (unlikely(obj_result == NULL)) {
3542 goto exit_result_exception;
3543 }
3544 result = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3545 Py_DECREF(obj_result);
3546 goto exit_result_ok;
3547
3548exit_result_ok:
3549 return result;
3550
3551exit_result_exception:
3552 return NUITKA_BOOL_EXCEPTION;
3553}
3554
3555nuitka_bool BINARY_OPERATION_MULT_NBOOL_INT_CLONG(PyObject *operand1, long operand2) {
3556 return _BINARY_OPERATION_MULT_NBOOL_INT_CLONG(operand1, operand2);
3557}
3558#endif
3559
3560/* Code referring to "FLOAT" corresponds to Python 'float' and "CFLOAT" to C platform float value. */
3561static PyObject *_BINARY_OPERATION_MULT_OBJECT_FLOAT_CFLOAT(PyObject *operand1, double operand2) {
3562 CHECK_OBJECT(operand1);
3563 assert(PyFloat_CheckExact(operand1));
3564
3565 PyObject *result;
3566
3567#if defined(_MSC_VER)
3568#pragma warning(push)
3569#pragma warning(disable : 4101)
3570#endif
3571 // Not every code path will make use of all possible results.
3572 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
3573 NUITKA_MAY_BE_UNUSED long clong_result;
3574 NUITKA_MAY_BE_UNUSED double cfloat_result;
3575#if defined(_MSC_VER)
3576#pragma warning(pop)
3577#endif
3578
3579 CHECK_OBJECT(operand1);
3580 assert(PyFloat_CheckExact(operand1));
3581
3582 const double a = PyFloat_AS_DOUBLE(operand1);
3583 const double b = operand2;
3584
3585 double r = a * b;
3586
3587 cfloat_result = r;
3588 goto exit_result_ok_cfloat;
3589
3590exit_result_ok_cfloat:
3591 result = MAKE_FLOAT_FROM_DOUBLE(cfloat_result);
3592 goto exit_result_ok;
3593
3594exit_result_ok:
3595 return result;
3596}
3597
3598PyObject *BINARY_OPERATION_MULT_OBJECT_FLOAT_CFLOAT(PyObject *operand1, double operand2) {
3599 return _BINARY_OPERATION_MULT_OBJECT_FLOAT_CFLOAT(operand1, operand2);
3600}
3601
3602/* Code referring to "FLOAT" corresponds to Python 'float' and "CFLOAT" to C platform float value. */
3603static nuitka_bool _BINARY_OPERATION_MULT_NBOOL_FLOAT_CFLOAT(PyObject *operand1, double operand2) {
3604 CHECK_OBJECT(operand1);
3605 assert(PyFloat_CheckExact(operand1));
3606
3607 nuitka_bool result;
3608
3609#if defined(_MSC_VER)
3610#pragma warning(push)
3611#pragma warning(disable : 4101)
3612#endif
3613 // Not every code path will make use of all possible results.
3614 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
3615 NUITKA_MAY_BE_UNUSED long clong_result;
3616 NUITKA_MAY_BE_UNUSED double cfloat_result;
3617#if defined(_MSC_VER)
3618#pragma warning(pop)
3619#endif
3620
3621 CHECK_OBJECT(operand1);
3622 assert(PyFloat_CheckExact(operand1));
3623
3624 const double a = PyFloat_AS_DOUBLE(operand1);
3625 const double b = operand2;
3626
3627 double r = a * b;
3628
3629 cfloat_result = r;
3630 goto exit_result_ok_cfloat;
3631
3632exit_result_ok_cfloat:
3633 result = cfloat_result != 0.0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
3634 goto exit_result_ok;
3635
3636exit_result_ok:
3637 return result;
3638}
3639
3640nuitka_bool BINARY_OPERATION_MULT_NBOOL_FLOAT_CFLOAT(PyObject *operand1, double operand2) {
3641 return _BINARY_OPERATION_MULT_NBOOL_FLOAT_CFLOAT(operand1, operand2);
3642}
3643
3644#if PYTHON_VERSION < 0x300
3645/* Code referring to "STR" corresponds to Python2 'str' and "INT" to Python2 'int'. */
3646static PyObject *_BINARY_OPERATION_MULT_OBJECT_STR_INT(PyObject *operand1, PyObject *operand2) {
3647 CHECK_OBJECT(operand1);
3648 assert(PyString_CheckExact(operand1));
3649 CHECK_OBJECT(operand2);
3650 assert(PyInt_CheckExact(operand2));
3651
3652#if defined(_MSC_VER)
3653#pragma warning(push)
3654#pragma warning(disable : 4101)
3655#endif
3656 NUITKA_MAY_BE_UNUSED bool cbool_result;
3657 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
3658#if defined(_MSC_VER)
3659#pragma warning(pop)
3660#endif
3661
3662 // Slot2 ignored on purpose, type1 takes precedence.
3663
3664 // Statically recognized that coercion is not possible with these types
3665
3666 if (unlikely(!1)) {
3667 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand2);
3668
3669 goto exit_binary_exception;
3670 }
3671
3672 {
3673 PyObject *index_value = operand2;
3674
3675 {
3676 Py_ssize_t count = PyInt_AS_LONG(index_value);
3677 {
3678 ssizeargfunc repeatfunc = PyString_Type.tp_as_sequence->sq_repeat;
3679 PyObject *r = (*repeatfunc)(operand1, count);
3680
3681 obj_result = r;
3682 goto exit_binary_result_object;
3683 }
3684 }
3685 }
3686
3687 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
3688
3689exit_binary_result_object:
3690 return obj_result;
3691
3692exit_binary_exception:
3693 return NULL;
3694}
3695
3696PyObject *BINARY_OPERATION_MULT_OBJECT_STR_INT(PyObject *operand1, PyObject *operand2) {
3697 return _BINARY_OPERATION_MULT_OBJECT_STR_INT(operand1, operand2);
3698}
3699#endif
3700
3701#if PYTHON_VERSION < 0x300
3702/* Code referring to "INT" corresponds to Python2 'int' and "STR" to Python2 'str'. */
3703static PyObject *_BINARY_OPERATION_MULT_OBJECT_INT_STR(PyObject *operand1, PyObject *operand2) {
3704 CHECK_OBJECT(operand1);
3705 assert(PyInt_CheckExact(operand1));
3706 CHECK_OBJECT(operand2);
3707 assert(PyString_CheckExact(operand2));
3708
3709#if defined(_MSC_VER)
3710#pragma warning(push)
3711#pragma warning(disable : 4101)
3712#endif
3713 NUITKA_MAY_BE_UNUSED bool cbool_result;
3714 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
3715#if defined(_MSC_VER)
3716#pragma warning(pop)
3717#endif
3718
3719 // Slot1 ignored on purpose, type2 takes precedence.
3720
3721 // Statically recognized that coercion is not possible with these types
3722
3723 {
3724 // No sequence repeat slot sq_repeat available for this type.
3725 }
3726 if (unlikely(!1)) {
3727 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand1);
3728
3729 goto exit_binary_exception;
3730 }
3731
3732 {
3733 PyObject *index_value = operand1;
3734
3735 {
3736 Py_ssize_t count = PyInt_AS_LONG(index_value);
3737 {
3738 ssizeargfunc repeatfunc = PyString_Type.tp_as_sequence->sq_repeat;
3739 PyObject *r = (*repeatfunc)(operand2, count);
3740
3741 obj_result = r;
3742 goto exit_binary_result_object;
3743 }
3744 }
3745 }
3746
3747 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
3748
3749exit_binary_result_object:
3750 return obj_result;
3751
3752exit_binary_exception:
3753 return NULL;
3754}
3755
3756PyObject *BINARY_OPERATION_MULT_OBJECT_INT_STR(PyObject *operand1, PyObject *operand2) {
3757 return _BINARY_OPERATION_MULT_OBJECT_INT_STR(operand1, operand2);
3758}
3759#endif
3760
3761#if PYTHON_VERSION < 0x300
3762/* Code referring to "UNICODE" corresponds to Python2 'unicode', Python3 'str' and "INT" to Python2 'int'. */
3763static PyObject *_BINARY_OPERATION_MULT_OBJECT_UNICODE_INT(PyObject *operand1, PyObject *operand2) {
3764 CHECK_OBJECT(operand1);
3765 assert(PyUnicode_CheckExact(operand1));
3766 CHECK_OBJECT(operand2);
3767 assert(PyInt_CheckExact(operand2));
3768
3769#if defined(_MSC_VER)
3770#pragma warning(push)
3771#pragma warning(disable : 4101)
3772#endif
3773 NUITKA_MAY_BE_UNUSED bool cbool_result;
3774 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
3775#if defined(_MSC_VER)
3776#pragma warning(pop)
3777#endif
3778
3779 // Slot2 ignored on purpose, type1 takes precedence.
3780
3781 // Statically recognized that coercion is not possible with these types
3782
3783 if (unlikely(!1)) {
3784 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand2);
3785
3786 goto exit_binary_exception;
3787 }
3788
3789 {
3790 PyObject *index_value = operand2;
3791
3792 {
3793 Py_ssize_t count = PyInt_AS_LONG(index_value);
3794 {
3795 ssizeargfunc repeatfunc = PyUnicode_Type.tp_as_sequence->sq_repeat;
3796 PyObject *r = (*repeatfunc)(operand1, count);
3797
3798 obj_result = r;
3799 goto exit_binary_result_object;
3800 }
3801 }
3802 }
3803
3804 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
3805
3806exit_binary_result_object:
3807 return obj_result;
3808
3809exit_binary_exception:
3810 return NULL;
3811}
3812
3813PyObject *BINARY_OPERATION_MULT_OBJECT_UNICODE_INT(PyObject *operand1, PyObject *operand2) {
3814 return _BINARY_OPERATION_MULT_OBJECT_UNICODE_INT(operand1, operand2);
3815}
3816#endif
3817
3818#if PYTHON_VERSION < 0x300
3819/* Code referring to "INT" corresponds to Python2 'int' and "UNICODE" to Python2 'unicode', Python3 'str'. */
3820static PyObject *_BINARY_OPERATION_MULT_OBJECT_INT_UNICODE(PyObject *operand1, PyObject *operand2) {
3821 CHECK_OBJECT(operand1);
3822 assert(PyInt_CheckExact(operand1));
3823 CHECK_OBJECT(operand2);
3824 assert(PyUnicode_CheckExact(operand2));
3825
3826#if defined(_MSC_VER)
3827#pragma warning(push)
3828#pragma warning(disable : 4101)
3829#endif
3830 NUITKA_MAY_BE_UNUSED bool cbool_result;
3831 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
3832#if defined(_MSC_VER)
3833#pragma warning(pop)
3834#endif
3835
3836 // Slot1 ignored on purpose, type2 takes precedence.
3837
3838 // Statically recognized that coercion is not possible with these types
3839
3840 {
3841 // No sequence repeat slot sq_repeat available for this type.
3842 }
3843 if (unlikely(!1)) {
3844 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand1);
3845
3846 goto exit_binary_exception;
3847 }
3848
3849 {
3850 PyObject *index_value = operand1;
3851
3852 {
3853 Py_ssize_t count = PyInt_AS_LONG(index_value);
3854 {
3855 ssizeargfunc repeatfunc = PyUnicode_Type.tp_as_sequence->sq_repeat;
3856 PyObject *r = (*repeatfunc)(operand2, count);
3857
3858 obj_result = r;
3859 goto exit_binary_result_object;
3860 }
3861 }
3862 }
3863
3864 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
3865
3866exit_binary_result_object:
3867 return obj_result;
3868
3869exit_binary_exception:
3870 return NULL;
3871}
3872
3873PyObject *BINARY_OPERATION_MULT_OBJECT_INT_UNICODE(PyObject *operand1, PyObject *operand2) {
3874 return _BINARY_OPERATION_MULT_OBJECT_INT_UNICODE(operand1, operand2);
3875}
3876#endif
3877
3878#if PYTHON_VERSION < 0x300
3879/* Code referring to "TUPLE" corresponds to Python 'tuple' and "INT" to Python2 'int'. */
3880static PyObject *_BINARY_OPERATION_MULT_OBJECT_TUPLE_INT(PyObject *operand1, PyObject *operand2) {
3881 CHECK_OBJECT(operand1);
3882 assert(PyTuple_CheckExact(operand1));
3883 CHECK_OBJECT(operand2);
3884 assert(PyInt_CheckExact(operand2));
3885
3886#if defined(_MSC_VER)
3887#pragma warning(push)
3888#pragma warning(disable : 4101)
3889#endif
3890 NUITKA_MAY_BE_UNUSED bool cbool_result;
3891 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
3892#if defined(_MSC_VER)
3893#pragma warning(pop)
3894#endif
3895
3896 // Slot2 ignored on purpose, type1 takes precedence.
3897
3898 // Statically recognized that coercion is not possible with these types
3899
3900 if (unlikely(!1)) {
3901 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand2);
3902
3903 goto exit_binary_exception;
3904 }
3905
3906 {
3907 PyObject *index_value = operand2;
3908
3909 {
3910 Py_ssize_t count = PyInt_AS_LONG(index_value);
3911 {
3912 ssizeargfunc repeatfunc = PyTuple_Type.tp_as_sequence->sq_repeat;
3913 PyObject *r = (*repeatfunc)(operand1, count);
3914
3915 obj_result = r;
3916 goto exit_binary_result_object;
3917 }
3918 }
3919 }
3920
3921 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
3922
3923exit_binary_result_object:
3924 return obj_result;
3925
3926exit_binary_exception:
3927 return NULL;
3928}
3929
3930PyObject *BINARY_OPERATION_MULT_OBJECT_TUPLE_INT(PyObject *operand1, PyObject *operand2) {
3931 return _BINARY_OPERATION_MULT_OBJECT_TUPLE_INT(operand1, operand2);
3932}
3933#endif
3934
3935#if PYTHON_VERSION < 0x300
3936/* Code referring to "INT" corresponds to Python2 'int' and "TUPLE" to Python 'tuple'. */
3937static PyObject *_BINARY_OPERATION_MULT_OBJECT_INT_TUPLE(PyObject *operand1, PyObject *operand2) {
3938 CHECK_OBJECT(operand1);
3939 assert(PyInt_CheckExact(operand1));
3940 CHECK_OBJECT(operand2);
3941 assert(PyTuple_CheckExact(operand2));
3942
3943#if defined(_MSC_VER)
3944#pragma warning(push)
3945#pragma warning(disable : 4101)
3946#endif
3947 NUITKA_MAY_BE_UNUSED bool cbool_result;
3948 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
3949#if defined(_MSC_VER)
3950#pragma warning(pop)
3951#endif
3952
3953 // Slot1 ignored on purpose, type2 takes precedence.
3954
3955 // Statically recognized that coercion is not possible with these types
3956
3957 {
3958 // No sequence repeat slot sq_repeat available for this type.
3959 }
3960 if (unlikely(!1)) {
3961 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand1);
3962
3963 goto exit_binary_exception;
3964 }
3965
3966 {
3967 PyObject *index_value = operand1;
3968
3969 {
3970 Py_ssize_t count = PyInt_AS_LONG(index_value);
3971 {
3972 ssizeargfunc repeatfunc = PyTuple_Type.tp_as_sequence->sq_repeat;
3973 PyObject *r = (*repeatfunc)(operand2, count);
3974
3975 obj_result = r;
3976 goto exit_binary_result_object;
3977 }
3978 }
3979 }
3980
3981 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
3982
3983exit_binary_result_object:
3984 return obj_result;
3985
3986exit_binary_exception:
3987 return NULL;
3988}
3989
3990PyObject *BINARY_OPERATION_MULT_OBJECT_INT_TUPLE(PyObject *operand1, PyObject *operand2) {
3991 return _BINARY_OPERATION_MULT_OBJECT_INT_TUPLE(operand1, operand2);
3992}
3993#endif
3994
3995#if PYTHON_VERSION < 0x300
3996/* Code referring to "LIST" corresponds to Python 'list' and "INT" to Python2 'int'. */
3997static PyObject *_BINARY_OPERATION_MULT_OBJECT_LIST_INT(PyObject *operand1, PyObject *operand2) {
3998 CHECK_OBJECT(operand1);
3999 assert(PyList_CheckExact(operand1));
4000 CHECK_OBJECT(operand2);
4001 assert(PyInt_CheckExact(operand2));
4002
4003#if defined(_MSC_VER)
4004#pragma warning(push)
4005#pragma warning(disable : 4101)
4006#endif
4007 NUITKA_MAY_BE_UNUSED bool cbool_result;
4008 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
4009#if defined(_MSC_VER)
4010#pragma warning(pop)
4011#endif
4012
4013 // Slot2 ignored on purpose, type1 takes precedence.
4014
4015 // Statically recognized that coercion is not possible with these types
4016
4017 if (unlikely(!1)) {
4018 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand2);
4019
4020 goto exit_binary_exception;
4021 }
4022
4023 {
4024 PyObject *index_value = operand2;
4025
4026 {
4027 Py_ssize_t count = PyInt_AS_LONG(index_value);
4028 {
4029 ssizeargfunc repeatfunc = PyList_Type.tp_as_sequence->sq_repeat;
4030 PyObject *r = (*repeatfunc)(operand1, count);
4031
4032 obj_result = r;
4033 goto exit_binary_result_object;
4034 }
4035 }
4036 }
4037
4038 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
4039
4040exit_binary_result_object:
4041 return obj_result;
4042
4043exit_binary_exception:
4044 return NULL;
4045}
4046
4047PyObject *BINARY_OPERATION_MULT_OBJECT_LIST_INT(PyObject *operand1, PyObject *operand2) {
4048 return _BINARY_OPERATION_MULT_OBJECT_LIST_INT(operand1, operand2);
4049}
4050#endif
4051
4052#if PYTHON_VERSION < 0x300
4053/* Code referring to "INT" corresponds to Python2 'int' and "LIST" to Python 'list'. */
4054static PyObject *_BINARY_OPERATION_MULT_OBJECT_INT_LIST(PyObject *operand1, PyObject *operand2) {
4055 CHECK_OBJECT(operand1);
4056 assert(PyInt_CheckExact(operand1));
4057 CHECK_OBJECT(operand2);
4058 assert(PyList_CheckExact(operand2));
4059
4060#if defined(_MSC_VER)
4061#pragma warning(push)
4062#pragma warning(disable : 4101)
4063#endif
4064 NUITKA_MAY_BE_UNUSED bool cbool_result;
4065 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
4066#if defined(_MSC_VER)
4067#pragma warning(pop)
4068#endif
4069
4070 // Slot1 ignored on purpose, type2 takes precedence.
4071
4072 // Statically recognized that coercion is not possible with these types
4073
4074 {
4075 // No sequence repeat slot sq_repeat available for this type.
4076 }
4077 if (unlikely(!1)) {
4078 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand1);
4079
4080 goto exit_binary_exception;
4081 }
4082
4083 {
4084 PyObject *index_value = operand1;
4085
4086 {
4087 Py_ssize_t count = PyInt_AS_LONG(index_value);
4088 {
4089 ssizeargfunc repeatfunc = PyList_Type.tp_as_sequence->sq_repeat;
4090 PyObject *r = (*repeatfunc)(operand2, count);
4091
4092 obj_result = r;
4093 goto exit_binary_result_object;
4094 }
4095 }
4096 }
4097
4098 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
4099
4100exit_binary_result_object:
4101 return obj_result;
4102
4103exit_binary_exception:
4104 return NULL;
4105}
4106
4107PyObject *BINARY_OPERATION_MULT_OBJECT_INT_LIST(PyObject *operand1, PyObject *operand2) {
4108 return _BINARY_OPERATION_MULT_OBJECT_INT_LIST(operand1, operand2);
4109}
4110#endif
4111
4112/* Code referring to "UNICODE" corresponds to Python2 'unicode', Python3 'str' and "LONG" to Python2 'long', Python3
4113 * 'int'. */
4114static PyObject *_BINARY_OPERATION_MULT_OBJECT_UNICODE_LONG(PyObject *operand1, PyObject *operand2) {
4115 CHECK_OBJECT(operand1);
4116 assert(PyUnicode_CheckExact(operand1));
4117 CHECK_OBJECT(operand2);
4118 assert(PyLong_CheckExact(operand2));
4119
4120#if defined(_MSC_VER)
4121#pragma warning(push)
4122#pragma warning(disable : 4101)
4123#endif
4124 NUITKA_MAY_BE_UNUSED bool cbool_result;
4125 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
4126#if defined(_MSC_VER)
4127#pragma warning(pop)
4128#endif
4129
4130 // Slot2 ignored on purpose, type1 takes precedence.
4131
4132 // Statically recognized that coercion is not possible with these types
4133
4134 if (unlikely(!1)) {
4135 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand2);
4136
4137 goto exit_binary_exception;
4138 }
4139
4140 {
4141 PyObject *index_value = operand2;
4142
4143 {
4144 Py_ssize_t count = CONVERT_LONG_TO_REPEAT_FACTOR(index_value);
4145
4146 /* Above conversion indicates an error as -1 */
4147 if (unlikely(count == -1)) {
4148#if PYTHON_VERSION < 0x300
4149 PyErr_Format(PyExc_OverflowError, "cannot fit 'long' into an index-sized integer");
4150#else
4151 PyErr_Format(PyExc_OverflowError, "cannot fit 'int' into an index-sized integer");
4152#endif
4153 goto exit_binary_exception;
4154 }
4155 {
4156 ssizeargfunc repeatfunc = PyUnicode_Type.tp_as_sequence->sq_repeat;
4157 PyObject *r = (*repeatfunc)(operand1, count);
4158
4159 obj_result = r;
4160 goto exit_binary_result_object;
4161 }
4162 }
4163 }
4164
4165 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
4166
4167exit_binary_result_object:
4168 return obj_result;
4169
4170exit_binary_exception:
4171 return NULL;
4172}
4173
4174PyObject *BINARY_OPERATION_MULT_OBJECT_UNICODE_LONG(PyObject *operand1, PyObject *operand2) {
4175 return _BINARY_OPERATION_MULT_OBJECT_UNICODE_LONG(operand1, operand2);
4176}
4177
4178/* Code referring to "LONG" corresponds to Python2 'long', Python3 'int' and "UNICODE" to Python2 'unicode', Python3
4179 * 'str'. */
4180static PyObject *_BINARY_OPERATION_MULT_OBJECT_LONG_UNICODE(PyObject *operand1, PyObject *operand2) {
4181 CHECK_OBJECT(operand1);
4182 assert(PyLong_CheckExact(operand1));
4183 CHECK_OBJECT(operand2);
4184 assert(PyUnicode_CheckExact(operand2));
4185
4186#if defined(_MSC_VER)
4187#pragma warning(push)
4188#pragma warning(disable : 4101)
4189#endif
4190 NUITKA_MAY_BE_UNUSED bool cbool_result;
4191 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
4192#if defined(_MSC_VER)
4193#pragma warning(pop)
4194#endif
4195
4196 // Slot1 ignored on purpose, type2 takes precedence.
4197
4198 // Statically recognized that coercion is not possible with these types
4199
4200 {
4201 // No sequence repeat slot sq_repeat available for this type.
4202 }
4203 if (unlikely(!1)) {
4204 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand1);
4205
4206 goto exit_binary_exception;
4207 }
4208
4209 {
4210 PyObject *index_value = operand1;
4211
4212 {
4213 Py_ssize_t count = CONVERT_LONG_TO_REPEAT_FACTOR(index_value);
4214
4215 /* Above conversion indicates an error as -1 */
4216 if (unlikely(count == -1)) {
4217#if PYTHON_VERSION < 0x300
4218 PyErr_Format(PyExc_OverflowError, "cannot fit 'long' into an index-sized integer");
4219#else
4220 PyErr_Format(PyExc_OverflowError, "cannot fit 'int' into an index-sized integer");
4221#endif
4222 goto exit_binary_exception;
4223 }
4224 {
4225 ssizeargfunc repeatfunc = PyUnicode_Type.tp_as_sequence->sq_repeat;
4226 PyObject *r = (*repeatfunc)(operand2, count);
4227
4228 obj_result = r;
4229 goto exit_binary_result_object;
4230 }
4231 }
4232 }
4233
4234 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
4235
4236exit_binary_result_object:
4237 return obj_result;
4238
4239exit_binary_exception:
4240 return NULL;
4241}
4242
4243PyObject *BINARY_OPERATION_MULT_OBJECT_LONG_UNICODE(PyObject *operand1, PyObject *operand2) {
4244 return _BINARY_OPERATION_MULT_OBJECT_LONG_UNICODE(operand1, operand2);
4245}
4246
4247#if PYTHON_VERSION >= 0x300
4248/* Code referring to "BYTES" corresponds to Python3 'bytes' and "LONG" to Python2 'long', Python3 'int'. */
4249static PyObject *_BINARY_OPERATION_MULT_OBJECT_BYTES_LONG(PyObject *operand1, PyObject *operand2) {
4250 CHECK_OBJECT(operand1);
4251 assert(PyBytes_CheckExact(operand1));
4252 CHECK_OBJECT(operand2);
4253 assert(PyLong_CheckExact(operand2));
4254
4255#if defined(_MSC_VER)
4256#pragma warning(push)
4257#pragma warning(disable : 4101)
4258#endif
4259 NUITKA_MAY_BE_UNUSED bool cbool_result;
4260 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
4261#if defined(_MSC_VER)
4262#pragma warning(pop)
4263#endif
4264
4265 // Slot2 ignored on purpose, type1 takes precedence.
4266
4267 // Statically recognized that coercion is not possible with these types
4268
4269 if (unlikely(!1)) {
4270 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand2);
4271
4272 goto exit_binary_exception;
4273 }
4274
4275 {
4276 PyObject *index_value = operand2;
4277
4278 {
4279 Py_ssize_t count = CONVERT_LONG_TO_REPEAT_FACTOR(index_value);
4280
4281 /* Above conversion indicates an error as -1 */
4282 if (unlikely(count == -1)) {
4283 PyErr_Format(PyExc_OverflowError, "cannot fit 'int' into an index-sized integer");
4284 goto exit_binary_exception;
4285 }
4286 {
4287 ssizeargfunc repeatfunc = PyBytes_Type.tp_as_sequence->sq_repeat;
4288 PyObject *r = (*repeatfunc)(operand1, count);
4289
4290 obj_result = r;
4291 goto exit_binary_result_object;
4292 }
4293 }
4294 }
4295
4296 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
4297
4298exit_binary_result_object:
4299 return obj_result;
4300
4301exit_binary_exception:
4302 return NULL;
4303}
4304
4305PyObject *BINARY_OPERATION_MULT_OBJECT_BYTES_LONG(PyObject *operand1, PyObject *operand2) {
4306 return _BINARY_OPERATION_MULT_OBJECT_BYTES_LONG(operand1, operand2);
4307}
4308#endif
4309
4310#if PYTHON_VERSION >= 0x300
4311/* Code referring to "LONG" corresponds to Python2 'long', Python3 'int' and "BYTES" to Python3 'bytes'. */
4312static PyObject *_BINARY_OPERATION_MULT_OBJECT_LONG_BYTES(PyObject *operand1, PyObject *operand2) {
4313 CHECK_OBJECT(operand1);
4314 assert(PyLong_CheckExact(operand1));
4315 CHECK_OBJECT(operand2);
4316 assert(PyBytes_CheckExact(operand2));
4317
4318#if defined(_MSC_VER)
4319#pragma warning(push)
4320#pragma warning(disable : 4101)
4321#endif
4322 NUITKA_MAY_BE_UNUSED bool cbool_result;
4323 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
4324#if defined(_MSC_VER)
4325#pragma warning(pop)
4326#endif
4327
4328 // Slot1 ignored on purpose, type2 takes precedence.
4329
4330 // Statically recognized that coercion is not possible with these types
4331
4332 {
4333 // No sequence repeat slot sq_repeat available for this type.
4334 }
4335 if (unlikely(!1)) {
4336 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand1);
4337
4338 goto exit_binary_exception;
4339 }
4340
4341 {
4342 PyObject *index_value = operand1;
4343
4344 {
4345 Py_ssize_t count = CONVERT_LONG_TO_REPEAT_FACTOR(index_value);
4346
4347 /* Above conversion indicates an error as -1 */
4348 if (unlikely(count == -1)) {
4349 PyErr_Format(PyExc_OverflowError, "cannot fit 'int' into an index-sized integer");
4350 goto exit_binary_exception;
4351 }
4352 {
4353 ssizeargfunc repeatfunc = PyBytes_Type.tp_as_sequence->sq_repeat;
4354 PyObject *r = (*repeatfunc)(operand2, count);
4355
4356 obj_result = r;
4357 goto exit_binary_result_object;
4358 }
4359 }
4360 }
4361
4362 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
4363
4364exit_binary_result_object:
4365 return obj_result;
4366
4367exit_binary_exception:
4368 return NULL;
4369}
4370
4371PyObject *BINARY_OPERATION_MULT_OBJECT_LONG_BYTES(PyObject *operand1, PyObject *operand2) {
4372 return _BINARY_OPERATION_MULT_OBJECT_LONG_BYTES(operand1, operand2);
4373}
4374#endif
4375
4376/* Code referring to "TUPLE" corresponds to Python 'tuple' and "LONG" to Python2 'long', Python3 'int'. */
4377static PyObject *_BINARY_OPERATION_MULT_OBJECT_TUPLE_LONG(PyObject *operand1, PyObject *operand2) {
4378 CHECK_OBJECT(operand1);
4379 assert(PyTuple_CheckExact(operand1));
4380 CHECK_OBJECT(operand2);
4381 assert(PyLong_CheckExact(operand2));
4382
4383#if defined(_MSC_VER)
4384#pragma warning(push)
4385#pragma warning(disable : 4101)
4386#endif
4387 NUITKA_MAY_BE_UNUSED bool cbool_result;
4388 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
4389#if defined(_MSC_VER)
4390#pragma warning(pop)
4391#endif
4392
4393 // Slot2 ignored on purpose, type1 takes precedence.
4394
4395 // Statically recognized that coercion is not possible with these types
4396
4397 if (unlikely(!1)) {
4398 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand2);
4399
4400 goto exit_binary_exception;
4401 }
4402
4403 {
4404 PyObject *index_value = operand2;
4405
4406 {
4407 Py_ssize_t count = CONVERT_LONG_TO_REPEAT_FACTOR(index_value);
4408
4409 /* Above conversion indicates an error as -1 */
4410 if (unlikely(count == -1)) {
4411#if PYTHON_VERSION < 0x300
4412 PyErr_Format(PyExc_OverflowError, "cannot fit 'long' into an index-sized integer");
4413#else
4414 PyErr_Format(PyExc_OverflowError, "cannot fit 'int' into an index-sized integer");
4415#endif
4416 goto exit_binary_exception;
4417 }
4418 {
4419 ssizeargfunc repeatfunc = PyTuple_Type.tp_as_sequence->sq_repeat;
4420 PyObject *r = (*repeatfunc)(operand1, count);
4421
4422 obj_result = r;
4423 goto exit_binary_result_object;
4424 }
4425 }
4426 }
4427
4428 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
4429
4430exit_binary_result_object:
4431 return obj_result;
4432
4433exit_binary_exception:
4434 return NULL;
4435}
4436
4437PyObject *BINARY_OPERATION_MULT_OBJECT_TUPLE_LONG(PyObject *operand1, PyObject *operand2) {
4438 return _BINARY_OPERATION_MULT_OBJECT_TUPLE_LONG(operand1, operand2);
4439}
4440
4441/* Code referring to "LONG" corresponds to Python2 'long', Python3 'int' and "TUPLE" to Python 'tuple'. */
4442static PyObject *_BINARY_OPERATION_MULT_OBJECT_LONG_TUPLE(PyObject *operand1, PyObject *operand2) {
4443 CHECK_OBJECT(operand1);
4444 assert(PyLong_CheckExact(operand1));
4445 CHECK_OBJECT(operand2);
4446 assert(PyTuple_CheckExact(operand2));
4447
4448#if defined(_MSC_VER)
4449#pragma warning(push)
4450#pragma warning(disable : 4101)
4451#endif
4452 NUITKA_MAY_BE_UNUSED bool cbool_result;
4453 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
4454#if defined(_MSC_VER)
4455#pragma warning(pop)
4456#endif
4457
4458 // Slot1 ignored on purpose, type2 takes precedence.
4459
4460 // Statically recognized that coercion is not possible with these types
4461
4462 {
4463 // No sequence repeat slot sq_repeat available for this type.
4464 }
4465 if (unlikely(!1)) {
4466 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand1);
4467
4468 goto exit_binary_exception;
4469 }
4470
4471 {
4472 PyObject *index_value = operand1;
4473
4474 {
4475 Py_ssize_t count = CONVERT_LONG_TO_REPEAT_FACTOR(index_value);
4476
4477 /* Above conversion indicates an error as -1 */
4478 if (unlikely(count == -1)) {
4479#if PYTHON_VERSION < 0x300
4480 PyErr_Format(PyExc_OverflowError, "cannot fit 'long' into an index-sized integer");
4481#else
4482 PyErr_Format(PyExc_OverflowError, "cannot fit 'int' into an index-sized integer");
4483#endif
4484 goto exit_binary_exception;
4485 }
4486 {
4487 ssizeargfunc repeatfunc = PyTuple_Type.tp_as_sequence->sq_repeat;
4488 PyObject *r = (*repeatfunc)(operand2, count);
4489
4490 obj_result = r;
4491 goto exit_binary_result_object;
4492 }
4493 }
4494 }
4495
4496 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
4497
4498exit_binary_result_object:
4499 return obj_result;
4500
4501exit_binary_exception:
4502 return NULL;
4503}
4504
4505PyObject *BINARY_OPERATION_MULT_OBJECT_LONG_TUPLE(PyObject *operand1, PyObject *operand2) {
4506 return _BINARY_OPERATION_MULT_OBJECT_LONG_TUPLE(operand1, operand2);
4507}
4508
4509/* Code referring to "LIST" corresponds to Python 'list' and "LONG" to Python2 'long', Python3 'int'. */
4510static PyObject *_BINARY_OPERATION_MULT_OBJECT_LIST_LONG(PyObject *operand1, PyObject *operand2) {
4511 CHECK_OBJECT(operand1);
4512 assert(PyList_CheckExact(operand1));
4513 CHECK_OBJECT(operand2);
4514 assert(PyLong_CheckExact(operand2));
4515
4516#if defined(_MSC_VER)
4517#pragma warning(push)
4518#pragma warning(disable : 4101)
4519#endif
4520 NUITKA_MAY_BE_UNUSED bool cbool_result;
4521 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
4522#if defined(_MSC_VER)
4523#pragma warning(pop)
4524#endif
4525
4526 // Slot2 ignored on purpose, type1 takes precedence.
4527
4528 // Statically recognized that coercion is not possible with these types
4529
4530 if (unlikely(!1)) {
4531 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand2);
4532
4533 goto exit_binary_exception;
4534 }
4535
4536 {
4537 PyObject *index_value = operand2;
4538
4539 {
4540 Py_ssize_t count = CONVERT_LONG_TO_REPEAT_FACTOR(index_value);
4541
4542 /* Above conversion indicates an error as -1 */
4543 if (unlikely(count == -1)) {
4544#if PYTHON_VERSION < 0x300
4545 PyErr_Format(PyExc_OverflowError, "cannot fit 'long' into an index-sized integer");
4546#else
4547 PyErr_Format(PyExc_OverflowError, "cannot fit 'int' into an index-sized integer");
4548#endif
4549 goto exit_binary_exception;
4550 }
4551 {
4552 ssizeargfunc repeatfunc = PyList_Type.tp_as_sequence->sq_repeat;
4553 PyObject *r = (*repeatfunc)(operand1, count);
4554
4555 obj_result = r;
4556 goto exit_binary_result_object;
4557 }
4558 }
4559 }
4560
4561 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
4562
4563exit_binary_result_object:
4564 return obj_result;
4565
4566exit_binary_exception:
4567 return NULL;
4568}
4569
4570PyObject *BINARY_OPERATION_MULT_OBJECT_LIST_LONG(PyObject *operand1, PyObject *operand2) {
4571 return _BINARY_OPERATION_MULT_OBJECT_LIST_LONG(operand1, operand2);
4572}
4573
4574/* Code referring to "LONG" corresponds to Python2 'long', Python3 'int' and "LIST" to Python 'list'. */
4575static PyObject *_BINARY_OPERATION_MULT_OBJECT_LONG_LIST(PyObject *operand1, PyObject *operand2) {
4576 CHECK_OBJECT(operand1);
4577 assert(PyLong_CheckExact(operand1));
4578 CHECK_OBJECT(operand2);
4579 assert(PyList_CheckExact(operand2));
4580
4581#if defined(_MSC_VER)
4582#pragma warning(push)
4583#pragma warning(disable : 4101)
4584#endif
4585 NUITKA_MAY_BE_UNUSED bool cbool_result;
4586 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
4587#if defined(_MSC_VER)
4588#pragma warning(pop)
4589#endif
4590
4591 // Slot1 ignored on purpose, type2 takes precedence.
4592
4593 // Statically recognized that coercion is not possible with these types
4594
4595 {
4596 // No sequence repeat slot sq_repeat available for this type.
4597 }
4598 if (unlikely(!1)) {
4599 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand1);
4600
4601 goto exit_binary_exception;
4602 }
4603
4604 {
4605 PyObject *index_value = operand1;
4606
4607 {
4608 Py_ssize_t count = CONVERT_LONG_TO_REPEAT_FACTOR(index_value);
4609
4610 /* Above conversion indicates an error as -1 */
4611 if (unlikely(count == -1)) {
4612#if PYTHON_VERSION < 0x300
4613 PyErr_Format(PyExc_OverflowError, "cannot fit 'long' into an index-sized integer");
4614#else
4615 PyErr_Format(PyExc_OverflowError, "cannot fit 'int' into an index-sized integer");
4616#endif
4617 goto exit_binary_exception;
4618 }
4619 {
4620 ssizeargfunc repeatfunc = PyList_Type.tp_as_sequence->sq_repeat;
4621 PyObject *r = (*repeatfunc)(operand2, count);
4622
4623 obj_result = r;
4624 goto exit_binary_result_object;
4625 }
4626 }
4627 }
4628
4629 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
4630
4631exit_binary_result_object:
4632 return obj_result;
4633
4634exit_binary_exception:
4635 return NULL;
4636}
4637
4638PyObject *BINARY_OPERATION_MULT_OBJECT_LONG_LIST(PyObject *operand1, PyObject *operand2) {
4639 return _BINARY_OPERATION_MULT_OBJECT_LONG_LIST(operand1, operand2);
4640}
4641
4642#if PYTHON_VERSION < 0x300
4643/* Code referring to "OBJECT" corresponds to any Python object and "STR" to Python2 'str'. */
4644static PyObject *_BINARY_OPERATION_MULT_OBJECT_OBJECT_STR(PyObject *operand1, PyObject *operand2) {
4645 CHECK_OBJECT(operand1);
4646 CHECK_OBJECT(operand2);
4647 assert(PyString_CheckExact(operand2));
4648
4649 PyTypeObject *type1 = Py_TYPE(operand1);
4650
4651#if defined(_MSC_VER)
4652#pragma warning(push)
4653#pragma warning(disable : 4101)
4654#endif
4655 NUITKA_MAY_BE_UNUSED bool cbool_result;
4656 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
4657#if defined(_MSC_VER)
4658#pragma warning(pop)
4659#endif
4660
4661 binaryfunc slot1 =
4662 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_multiply : NULL;
4663
4664 if (slot1 != NULL) {
4665 PyObject *x = slot1(operand1, operand2);
4666
4667 if (x != Py_NotImplemented) {
4668 obj_result = x;
4669 goto exit_binary_result_object;
4670 }
4671
4672 Py_DECREF_IMMORTAL(x);
4673 }
4674
4675#if PYTHON_VERSION < 0x300
4676 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
4677 coercion c1 =
4678 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
4679
4680 if (c1 != NULL) {
4681 PyObject *coerced1 = operand1;
4682 PyObject *coerced2 = operand2;
4683
4684 int err = c1(&coerced1, &coerced2);
4685
4686 if (unlikely(err < 0)) {
4687 goto exit_binary_exception;
4688 }
4689
4690 if (err == 0) {
4691 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
4692
4693 if (likely(mv == NULL)) {
4694 binaryfunc slot = mv->nb_multiply;
4695
4696 if (likely(slot != NULL)) {
4697 PyObject *x = slot(coerced1, coerced2);
4698
4699 Py_DECREF(coerced1);
4700 Py_DECREF(coerced2);
4701
4702 obj_result = x;
4703 goto exit_binary_result_object;
4704 }
4705 }
4706
4707 // nb_coerce took a reference.
4708 Py_DECREF(coerced1);
4709 Py_DECREF(coerced2);
4710 }
4711 }
4712 }
4713#endif
4714
4715 {
4716 // Special case for "+" and "*", also works as sequence concat/repeat.
4717 ssizeargfunc sq_slot = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_repeat : NULL;
4718
4719 if (sq_slot != NULL) {
4720 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand1, operand2);
4721
4722 obj_result = result;
4723 goto exit_binary_result_object;
4724 }
4725 }
4726 if (unlikely(!Nuitka_Index_Check(operand1))) {
4727 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand1);
4728
4729 goto exit_binary_exception;
4730 }
4731
4732 {
4733 PyObject *index_value = Nuitka_Number_Index(operand1);
4734
4735 if (unlikely(index_value == NULL)) {
4736 goto exit_binary_exception;
4737 }
4738
4739 {
4740 Py_ssize_t count = CONVERT_TO_REPEAT_FACTOR(index_value);
4741
4742 Py_DECREF(index_value);
4743
4744 /* Above conversion indicates an error as -1 */
4745 if (unlikely(count == -1)) {
4746 PyErr_Format(PyExc_OverflowError, "cannot fit '%s' into an index-sized integer", type1->tp_name);
4747 goto exit_binary_exception;
4748 }
4749 {
4750 ssizeargfunc repeatfunc = PyString_Type.tp_as_sequence->sq_repeat;
4751 PyObject *r = (*repeatfunc)(operand2, count);
4752
4753 obj_result = r;
4754 goto exit_binary_result_object;
4755 }
4756 }
4757 }
4758
4759 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
4760
4761exit_binary_result_object:
4762 return obj_result;
4763
4764exit_binary_exception:
4765 return NULL;
4766}
4767
4768PyObject *BINARY_OPERATION_MULT_OBJECT_OBJECT_STR(PyObject *operand1, PyObject *operand2) {
4769 return _BINARY_OPERATION_MULT_OBJECT_OBJECT_STR(operand1, operand2);
4770}
4771#endif
4772
4773#if PYTHON_VERSION < 0x300
4774/* Code referring to "STR" corresponds to Python2 'str' and "OBJECT" to any Python object. */
4775static PyObject *_BINARY_OPERATION_MULT_OBJECT_STR_OBJECT(PyObject *operand1, PyObject *operand2) {
4776 CHECK_OBJECT(operand1);
4777 assert(PyString_CheckExact(operand1));
4778 CHECK_OBJECT(operand2);
4779
4780 PyTypeObject *type2 = Py_TYPE(operand2);
4781
4782#if defined(_MSC_VER)
4783#pragma warning(push)
4784#pragma warning(disable : 4101)
4785#endif
4786 NUITKA_MAY_BE_UNUSED bool cbool_result;
4787 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
4788#if defined(_MSC_VER)
4789#pragma warning(pop)
4790#endif
4791
4792 binaryfunc slot2 = NULL;
4793
4794 if (!(&PyString_Type == type2)) {
4795 // Different types, need to consider second value slot.
4796
4797 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_multiply : NULL;
4798 }
4799
4800 if (slot2 != NULL) {
4801 PyObject *x = slot2(operand1, operand2);
4802
4803 if (x != Py_NotImplemented) {
4804 obj_result = x;
4805 goto exit_binary_result_object;
4806 }
4807
4808 Py_DECREF_IMMORTAL(x);
4809 }
4810
4811#if PYTHON_VERSION < 0x300
4812 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
4813 coercion c2 =
4814 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
4815
4816 if (c2 != NULL) {
4817 PyObject *coerced1 = operand1;
4818 PyObject *coerced2 = operand2;
4819
4820 int err = c2(&coerced2, &coerced1);
4821
4822 if (unlikely(err < 0)) {
4823 goto exit_binary_exception;
4824 }
4825
4826 if (err == 0) {
4827 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
4828
4829 if (likely(mv == NULL)) {
4830 binaryfunc slot = mv->nb_multiply;
4831
4832 if (likely(slot != NULL)) {
4833 PyObject *x = slot(coerced1, coerced2);
4834
4835 Py_DECREF(coerced1);
4836 Py_DECREF(coerced2);
4837
4838 obj_result = x;
4839 goto exit_binary_result_object;
4840 }
4841 }
4842
4843 // nb_coerce took a reference.
4844 Py_DECREF(coerced1);
4845 Py_DECREF(coerced2);
4846 }
4847 }
4848 }
4849#endif
4850
4851 if (unlikely(!Nuitka_Index_Check(operand2))) {
4852 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand2);
4853
4854 goto exit_binary_exception;
4855 }
4856
4857 {
4858 PyObject *index_value = Nuitka_Number_Index(operand2);
4859
4860 if (unlikely(index_value == NULL)) {
4861 goto exit_binary_exception;
4862 }
4863
4864 {
4865 Py_ssize_t count = CONVERT_TO_REPEAT_FACTOR(index_value);
4866
4867 Py_DECREF(index_value);
4868
4869 /* Above conversion indicates an error as -1 */
4870 if (unlikely(count == -1)) {
4871 PyErr_Format(PyExc_OverflowError, "cannot fit '%s' into an index-sized integer", type2->tp_name);
4872 goto exit_binary_exception;
4873 }
4874 {
4875 ssizeargfunc repeatfunc = PyString_Type.tp_as_sequence->sq_repeat;
4876 PyObject *r = (*repeatfunc)(operand1, count);
4877
4878 obj_result = r;
4879 goto exit_binary_result_object;
4880 }
4881 }
4882 }
4883
4884 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
4885
4886exit_binary_result_object:
4887 return obj_result;
4888
4889exit_binary_exception:
4890 return NULL;
4891}
4892
4893PyObject *BINARY_OPERATION_MULT_OBJECT_STR_OBJECT(PyObject *operand1, PyObject *operand2) {
4894 return _BINARY_OPERATION_MULT_OBJECT_STR_OBJECT(operand1, operand2);
4895}
4896#endif
4897
4898/* Code referring to "OBJECT" corresponds to any Python object and "UNICODE" to Python2 'unicode', Python3 'str'. */
4899static PyObject *_BINARY_OPERATION_MULT_OBJECT_OBJECT_UNICODE(PyObject *operand1, PyObject *operand2) {
4900 CHECK_OBJECT(operand1);
4901 CHECK_OBJECT(operand2);
4902 assert(PyUnicode_CheckExact(operand2));
4903
4904 PyTypeObject *type1 = Py_TYPE(operand1);
4905
4906#if defined(_MSC_VER)
4907#pragma warning(push)
4908#pragma warning(disable : 4101)
4909#endif
4910 NUITKA_MAY_BE_UNUSED bool cbool_result;
4911 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
4912#if defined(_MSC_VER)
4913#pragma warning(pop)
4914#endif
4915
4916 binaryfunc slot1 =
4917 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_multiply : NULL;
4918
4919 if (slot1 != NULL) {
4920 PyObject *x = slot1(operand1, operand2);
4921
4922 if (x != Py_NotImplemented) {
4923 obj_result = x;
4924 goto exit_binary_result_object;
4925 }
4926
4927 Py_DECREF_IMMORTAL(x);
4928 }
4929
4930#if PYTHON_VERSION < 0x300
4931 if (!NEW_STYLE_NUMBER_TYPE(type1) || !1) {
4932 coercion c1 =
4933 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
4934
4935 if (c1 != NULL) {
4936 PyObject *coerced1 = operand1;
4937 PyObject *coerced2 = operand2;
4938
4939 int err = c1(&coerced1, &coerced2);
4940
4941 if (unlikely(err < 0)) {
4942 goto exit_binary_exception;
4943 }
4944
4945 if (err == 0) {
4946 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
4947
4948 if (likely(mv == NULL)) {
4949 binaryfunc slot = mv->nb_multiply;
4950
4951 if (likely(slot != NULL)) {
4952 PyObject *x = slot(coerced1, coerced2);
4953
4954 Py_DECREF(coerced1);
4955 Py_DECREF(coerced2);
4956
4957 obj_result = x;
4958 goto exit_binary_result_object;
4959 }
4960 }
4961
4962 // nb_coerce took a reference.
4963 Py_DECREF(coerced1);
4964 Py_DECREF(coerced2);
4965 }
4966 }
4967 }
4968#endif
4969
4970 {
4971 // Special case for "+" and "*", also works as sequence concat/repeat.
4972 ssizeargfunc sq_slot = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_repeat : NULL;
4973
4974 if (sq_slot != NULL) {
4975 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand1, operand2);
4976
4977 obj_result = result;
4978 goto exit_binary_result_object;
4979 }
4980 }
4981 if (unlikely(!Nuitka_Index_Check(operand1))) {
4982 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand1);
4983
4984 goto exit_binary_exception;
4985 }
4986
4987 {
4988 PyObject *index_value = Nuitka_Number_Index(operand1);
4989
4990 if (unlikely(index_value == NULL)) {
4991 goto exit_binary_exception;
4992 }
4993
4994 {
4995 Py_ssize_t count = CONVERT_TO_REPEAT_FACTOR(index_value);
4996
4997 Py_DECREF(index_value);
4998
4999 /* Above conversion indicates an error as -1 */
5000 if (unlikely(count == -1)) {
5001 PyErr_Format(PyExc_OverflowError, "cannot fit '%s' into an index-sized integer", type1->tp_name);
5002 goto exit_binary_exception;
5003 }
5004 {
5005 ssizeargfunc repeatfunc = PyUnicode_Type.tp_as_sequence->sq_repeat;
5006 PyObject *r = (*repeatfunc)(operand2, count);
5007
5008 obj_result = r;
5009 goto exit_binary_result_object;
5010 }
5011 }
5012 }
5013
5014 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
5015
5016exit_binary_result_object:
5017 return obj_result;
5018
5019exit_binary_exception:
5020 return NULL;
5021}
5022
5023PyObject *BINARY_OPERATION_MULT_OBJECT_OBJECT_UNICODE(PyObject *operand1, PyObject *operand2) {
5024 return _BINARY_OPERATION_MULT_OBJECT_OBJECT_UNICODE(operand1, operand2);
5025}
5026
5027/* Code referring to "UNICODE" corresponds to Python2 'unicode', Python3 'str' and "OBJECT" to any Python object. */
5028static PyObject *_BINARY_OPERATION_MULT_OBJECT_UNICODE_OBJECT(PyObject *operand1, PyObject *operand2) {
5029 CHECK_OBJECT(operand1);
5030 assert(PyUnicode_CheckExact(operand1));
5031 CHECK_OBJECT(operand2);
5032
5033 PyTypeObject *type2 = Py_TYPE(operand2);
5034
5035#if defined(_MSC_VER)
5036#pragma warning(push)
5037#pragma warning(disable : 4101)
5038#endif
5039 NUITKA_MAY_BE_UNUSED bool cbool_result;
5040 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
5041#if defined(_MSC_VER)
5042#pragma warning(pop)
5043#endif
5044
5045 binaryfunc slot2 = NULL;
5046
5047 if (!(&PyUnicode_Type == type2)) {
5048 // Different types, need to consider second value slot.
5049
5050 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_multiply : NULL;
5051 }
5052
5053 if (slot2 != NULL) {
5054 PyObject *x = slot2(operand1, operand2);
5055
5056 if (x != Py_NotImplemented) {
5057 obj_result = x;
5058 goto exit_binary_result_object;
5059 }
5060
5061 Py_DECREF_IMMORTAL(x);
5062 }
5063
5064#if PYTHON_VERSION < 0x300
5065 if (!1 || !NEW_STYLE_NUMBER_TYPE(type2)) {
5066 coercion c2 =
5067 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
5068
5069 if (c2 != NULL) {
5070 PyObject *coerced1 = operand1;
5071 PyObject *coerced2 = operand2;
5072
5073 int err = c2(&coerced2, &coerced1);
5074
5075 if (unlikely(err < 0)) {
5076 goto exit_binary_exception;
5077 }
5078
5079 if (err == 0) {
5080 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
5081
5082 if (likely(mv == NULL)) {
5083 binaryfunc slot = mv->nb_multiply;
5084
5085 if (likely(slot != NULL)) {
5086 PyObject *x = slot(coerced1, coerced2);
5087
5088 Py_DECREF(coerced1);
5089 Py_DECREF(coerced2);
5090
5091 obj_result = x;
5092 goto exit_binary_result_object;
5093 }
5094 }
5095
5096 // nb_coerce took a reference.
5097 Py_DECREF(coerced1);
5098 Py_DECREF(coerced2);
5099 }
5100 }
5101 }
5102#endif
5103
5104 if (unlikely(!Nuitka_Index_Check(operand2))) {
5105 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand2);
5106
5107 goto exit_binary_exception;
5108 }
5109
5110 {
5111 PyObject *index_value = Nuitka_Number_Index(operand2);
5112
5113 if (unlikely(index_value == NULL)) {
5114 goto exit_binary_exception;
5115 }
5116
5117 {
5118 Py_ssize_t count = CONVERT_TO_REPEAT_FACTOR(index_value);
5119
5120 Py_DECREF(index_value);
5121
5122 /* Above conversion indicates an error as -1 */
5123 if (unlikely(count == -1)) {
5124 PyErr_Format(PyExc_OverflowError, "cannot fit '%s' into an index-sized integer", type2->tp_name);
5125 goto exit_binary_exception;
5126 }
5127 {
5128 ssizeargfunc repeatfunc = PyUnicode_Type.tp_as_sequence->sq_repeat;
5129 PyObject *r = (*repeatfunc)(operand1, count);
5130
5131 obj_result = r;
5132 goto exit_binary_result_object;
5133 }
5134 }
5135 }
5136
5137 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
5138
5139exit_binary_result_object:
5140 return obj_result;
5141
5142exit_binary_exception:
5143 return NULL;
5144}
5145
5146PyObject *BINARY_OPERATION_MULT_OBJECT_UNICODE_OBJECT(PyObject *operand1, PyObject *operand2) {
5147 return _BINARY_OPERATION_MULT_OBJECT_UNICODE_OBJECT(operand1, operand2);
5148}
5149
5150#if PYTHON_VERSION >= 0x300
5151/* Code referring to "OBJECT" corresponds to any Python object and "BYTES" to Python3 'bytes'. */
5152static PyObject *_BINARY_OPERATION_MULT_OBJECT_OBJECT_BYTES(PyObject *operand1, PyObject *operand2) {
5153 CHECK_OBJECT(operand1);
5154 CHECK_OBJECT(operand2);
5155 assert(PyBytes_CheckExact(operand2));
5156
5157 PyTypeObject *type1 = Py_TYPE(operand1);
5158
5159#if defined(_MSC_VER)
5160#pragma warning(push)
5161#pragma warning(disable : 4101)
5162#endif
5163 NUITKA_MAY_BE_UNUSED bool cbool_result;
5164 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
5165#if defined(_MSC_VER)
5166#pragma warning(pop)
5167#endif
5168
5169 binaryfunc slot1 =
5170 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_multiply : NULL;
5171
5172 if (slot1 != NULL) {
5173 PyObject *x = slot1(operand1, operand2);
5174
5175 if (x != Py_NotImplemented) {
5176 obj_result = x;
5177 goto exit_binary_result_object;
5178 }
5179
5180 Py_DECREF_IMMORTAL(x);
5181 }
5182
5183#if PYTHON_VERSION < 0x300
5184 if (!NEW_STYLE_NUMBER_TYPE(type1) || !0) {
5185 coercion c1 =
5186 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
5187
5188 if (c1 != NULL) {
5189 PyObject *coerced1 = operand1;
5190 PyObject *coerced2 = operand2;
5191
5192 int err = c1(&coerced1, &coerced2);
5193
5194 if (unlikely(err < 0)) {
5195 goto exit_binary_exception;
5196 }
5197
5198 if (err == 0) {
5199 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
5200
5201 if (likely(mv == NULL)) {
5202 binaryfunc slot = mv->nb_multiply;
5203
5204 if (likely(slot != NULL)) {
5205 PyObject *x = slot(coerced1, coerced2);
5206
5207 Py_DECREF(coerced1);
5208 Py_DECREF(coerced2);
5209
5210 obj_result = x;
5211 goto exit_binary_result_object;
5212 }
5213 }
5214
5215 // nb_coerce took a reference.
5216 Py_DECREF(coerced1);
5217 Py_DECREF(coerced2);
5218 }
5219 }
5220 }
5221#endif
5222
5223 {
5224 // Special case for "+" and "*", also works as sequence concat/repeat.
5225 ssizeargfunc sq_slot = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_repeat : NULL;
5226
5227 if (sq_slot != NULL) {
5228 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand1, operand2);
5229
5230 obj_result = result;
5231 goto exit_binary_result_object;
5232 }
5233 }
5234 if (unlikely(!Nuitka_Index_Check(operand1))) {
5235 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand1);
5236
5237 goto exit_binary_exception;
5238 }
5239
5240 {
5241 PyObject *index_value = Nuitka_Number_Index(operand1);
5242
5243 if (unlikely(index_value == NULL)) {
5244 goto exit_binary_exception;
5245 }
5246
5247 {
5248 Py_ssize_t count = CONVERT_TO_REPEAT_FACTOR(index_value);
5249
5250 Py_DECREF(index_value);
5251
5252 /* Above conversion indicates an error as -1 */
5253 if (unlikely(count == -1)) {
5254 PyErr_Format(PyExc_OverflowError, "cannot fit '%s' into an index-sized integer", type1->tp_name);
5255 goto exit_binary_exception;
5256 }
5257 {
5258 ssizeargfunc repeatfunc = PyBytes_Type.tp_as_sequence->sq_repeat;
5259 PyObject *r = (*repeatfunc)(operand2, count);
5260
5261 obj_result = r;
5262 goto exit_binary_result_object;
5263 }
5264 }
5265 }
5266
5267 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
5268
5269exit_binary_result_object:
5270 return obj_result;
5271
5272exit_binary_exception:
5273 return NULL;
5274}
5275
5276PyObject *BINARY_OPERATION_MULT_OBJECT_OBJECT_BYTES(PyObject *operand1, PyObject *operand2) {
5277 return _BINARY_OPERATION_MULT_OBJECT_OBJECT_BYTES(operand1, operand2);
5278}
5279#endif
5280
5281#if PYTHON_VERSION >= 0x300
5282/* Code referring to "BYTES" corresponds to Python3 'bytes' and "OBJECT" to any Python object. */
5283static PyObject *_BINARY_OPERATION_MULT_OBJECT_BYTES_OBJECT(PyObject *operand1, PyObject *operand2) {
5284 CHECK_OBJECT(operand1);
5285 assert(PyBytes_CheckExact(operand1));
5286 CHECK_OBJECT(operand2);
5287
5288 PyTypeObject *type2 = Py_TYPE(operand2);
5289
5290#if defined(_MSC_VER)
5291#pragma warning(push)
5292#pragma warning(disable : 4101)
5293#endif
5294 NUITKA_MAY_BE_UNUSED bool cbool_result;
5295 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
5296#if defined(_MSC_VER)
5297#pragma warning(pop)
5298#endif
5299
5300 binaryfunc slot2 = NULL;
5301
5302 if (!(&PyBytes_Type == type2)) {
5303 // Different types, need to consider second value slot.
5304
5305 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_multiply : NULL;
5306 }
5307
5308 if (slot2 != NULL) {
5309 PyObject *x = slot2(operand1, operand2);
5310
5311 if (x != Py_NotImplemented) {
5312 obj_result = x;
5313 goto exit_binary_result_object;
5314 }
5315
5316 Py_DECREF_IMMORTAL(x);
5317 }
5318
5319#if PYTHON_VERSION < 0x300
5320 if (!0 || !NEW_STYLE_NUMBER_TYPE(type2)) {
5321 coercion c2 =
5322 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
5323
5324 if (c2 != NULL) {
5325 PyObject *coerced1 = operand1;
5326 PyObject *coerced2 = operand2;
5327
5328 int err = c2(&coerced2, &coerced1);
5329
5330 if (unlikely(err < 0)) {
5331 goto exit_binary_exception;
5332 }
5333
5334 if (err == 0) {
5335 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
5336
5337 if (likely(mv == NULL)) {
5338 binaryfunc slot = mv->nb_multiply;
5339
5340 if (likely(slot != NULL)) {
5341 PyObject *x = slot(coerced1, coerced2);
5342
5343 Py_DECREF(coerced1);
5344 Py_DECREF(coerced2);
5345
5346 obj_result = x;
5347 goto exit_binary_result_object;
5348 }
5349 }
5350
5351 // nb_coerce took a reference.
5352 Py_DECREF(coerced1);
5353 Py_DECREF(coerced2);
5354 }
5355 }
5356 }
5357#endif
5358
5359 if (unlikely(!Nuitka_Index_Check(operand2))) {
5360 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand2);
5361
5362 goto exit_binary_exception;
5363 }
5364
5365 {
5366 PyObject *index_value = Nuitka_Number_Index(operand2);
5367
5368 if (unlikely(index_value == NULL)) {
5369 goto exit_binary_exception;
5370 }
5371
5372 {
5373 Py_ssize_t count = CONVERT_TO_REPEAT_FACTOR(index_value);
5374
5375 Py_DECREF(index_value);
5376
5377 /* Above conversion indicates an error as -1 */
5378 if (unlikely(count == -1)) {
5379 PyErr_Format(PyExc_OverflowError, "cannot fit '%s' into an index-sized integer", type2->tp_name);
5380 goto exit_binary_exception;
5381 }
5382 {
5383 ssizeargfunc repeatfunc = PyBytes_Type.tp_as_sequence->sq_repeat;
5384 PyObject *r = (*repeatfunc)(operand1, count);
5385
5386 obj_result = r;
5387 goto exit_binary_result_object;
5388 }
5389 }
5390 }
5391
5392 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
5393
5394exit_binary_result_object:
5395 return obj_result;
5396
5397exit_binary_exception:
5398 return NULL;
5399}
5400
5401PyObject *BINARY_OPERATION_MULT_OBJECT_BYTES_OBJECT(PyObject *operand1, PyObject *operand2) {
5402 return _BINARY_OPERATION_MULT_OBJECT_BYTES_OBJECT(operand1, operand2);
5403}
5404#endif
5405
5406/* Code referring to "OBJECT" corresponds to any Python object and "TUPLE" to Python 'tuple'. */
5407static PyObject *_BINARY_OPERATION_MULT_OBJECT_OBJECT_TUPLE(PyObject *operand1, PyObject *operand2) {
5408 CHECK_OBJECT(operand1);
5409 CHECK_OBJECT(operand2);
5410 assert(PyTuple_CheckExact(operand2));
5411
5412 PyTypeObject *type1 = Py_TYPE(operand1);
5413
5414#if defined(_MSC_VER)
5415#pragma warning(push)
5416#pragma warning(disable : 4101)
5417#endif
5418 NUITKA_MAY_BE_UNUSED bool cbool_result;
5419 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
5420#if defined(_MSC_VER)
5421#pragma warning(pop)
5422#endif
5423
5424 binaryfunc slot1 =
5425 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_multiply : NULL;
5426
5427 if (slot1 != NULL) {
5428 PyObject *x = slot1(operand1, operand2);
5429
5430 if (x != Py_NotImplemented) {
5431 obj_result = x;
5432 goto exit_binary_result_object;
5433 }
5434
5435 Py_DECREF_IMMORTAL(x);
5436 }
5437
5438#if PYTHON_VERSION < 0x300
5439 if (!NEW_STYLE_NUMBER_TYPE(type1) || !0) {
5440 coercion c1 =
5441 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
5442
5443 if (c1 != NULL) {
5444 PyObject *coerced1 = operand1;
5445 PyObject *coerced2 = operand2;
5446
5447 int err = c1(&coerced1, &coerced2);
5448
5449 if (unlikely(err < 0)) {
5450 goto exit_binary_exception;
5451 }
5452
5453 if (err == 0) {
5454 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
5455
5456 if (likely(mv == NULL)) {
5457 binaryfunc slot = mv->nb_multiply;
5458
5459 if (likely(slot != NULL)) {
5460 PyObject *x = slot(coerced1, coerced2);
5461
5462 Py_DECREF(coerced1);
5463 Py_DECREF(coerced2);
5464
5465 obj_result = x;
5466 goto exit_binary_result_object;
5467 }
5468 }
5469
5470 // nb_coerce took a reference.
5471 Py_DECREF(coerced1);
5472 Py_DECREF(coerced2);
5473 }
5474 }
5475 }
5476#endif
5477
5478 {
5479 // Special case for "+" and "*", also works as sequence concat/repeat.
5480 ssizeargfunc sq_slot = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_repeat : NULL;
5481
5482 if (sq_slot != NULL) {
5483 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand1, operand2);
5484
5485 obj_result = result;
5486 goto exit_binary_result_object;
5487 }
5488 }
5489 if (unlikely(!Nuitka_Index_Check(operand1))) {
5490 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand1);
5491
5492 goto exit_binary_exception;
5493 }
5494
5495 {
5496 PyObject *index_value = Nuitka_Number_Index(operand1);
5497
5498 if (unlikely(index_value == NULL)) {
5499 goto exit_binary_exception;
5500 }
5501
5502 {
5503 Py_ssize_t count = CONVERT_TO_REPEAT_FACTOR(index_value);
5504
5505 Py_DECREF(index_value);
5506
5507 /* Above conversion indicates an error as -1 */
5508 if (unlikely(count == -1)) {
5509 PyErr_Format(PyExc_OverflowError, "cannot fit '%s' into an index-sized integer", type1->tp_name);
5510 goto exit_binary_exception;
5511 }
5512 {
5513 ssizeargfunc repeatfunc = PyTuple_Type.tp_as_sequence->sq_repeat;
5514 PyObject *r = (*repeatfunc)(operand2, count);
5515
5516 obj_result = r;
5517 goto exit_binary_result_object;
5518 }
5519 }
5520 }
5521
5522 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
5523
5524exit_binary_result_object:
5525 return obj_result;
5526
5527exit_binary_exception:
5528 return NULL;
5529}
5530
5531PyObject *BINARY_OPERATION_MULT_OBJECT_OBJECT_TUPLE(PyObject *operand1, PyObject *operand2) {
5532 return _BINARY_OPERATION_MULT_OBJECT_OBJECT_TUPLE(operand1, operand2);
5533}
5534
5535/* Code referring to "TUPLE" corresponds to Python 'tuple' and "OBJECT" to any Python object. */
5536static PyObject *_BINARY_OPERATION_MULT_OBJECT_TUPLE_OBJECT(PyObject *operand1, PyObject *operand2) {
5537 CHECK_OBJECT(operand1);
5538 assert(PyTuple_CheckExact(operand1));
5539 CHECK_OBJECT(operand2);
5540
5541 PyTypeObject *type2 = Py_TYPE(operand2);
5542
5543#if defined(_MSC_VER)
5544#pragma warning(push)
5545#pragma warning(disable : 4101)
5546#endif
5547 NUITKA_MAY_BE_UNUSED bool cbool_result;
5548 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
5549#if defined(_MSC_VER)
5550#pragma warning(pop)
5551#endif
5552
5553 binaryfunc slot2 = NULL;
5554
5555 if (!(&PyTuple_Type == type2)) {
5556 // Different types, need to consider second value slot.
5557
5558 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_multiply : NULL;
5559 }
5560
5561 if (slot2 != NULL) {
5562 PyObject *x = slot2(operand1, operand2);
5563
5564 if (x != Py_NotImplemented) {
5565 obj_result = x;
5566 goto exit_binary_result_object;
5567 }
5568
5569 Py_DECREF_IMMORTAL(x);
5570 }
5571
5572#if PYTHON_VERSION < 0x300
5573 if (!0 || !NEW_STYLE_NUMBER_TYPE(type2)) {
5574 coercion c2 =
5575 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
5576
5577 if (c2 != NULL) {
5578 PyObject *coerced1 = operand1;
5579 PyObject *coerced2 = operand2;
5580
5581 int err = c2(&coerced2, &coerced1);
5582
5583 if (unlikely(err < 0)) {
5584 goto exit_binary_exception;
5585 }
5586
5587 if (err == 0) {
5588 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
5589
5590 if (likely(mv == NULL)) {
5591 binaryfunc slot = mv->nb_multiply;
5592
5593 if (likely(slot != NULL)) {
5594 PyObject *x = slot(coerced1, coerced2);
5595
5596 Py_DECREF(coerced1);
5597 Py_DECREF(coerced2);
5598
5599 obj_result = x;
5600 goto exit_binary_result_object;
5601 }
5602 }
5603
5604 // nb_coerce took a reference.
5605 Py_DECREF(coerced1);
5606 Py_DECREF(coerced2);
5607 }
5608 }
5609 }
5610#endif
5611
5612 if (unlikely(!Nuitka_Index_Check(operand2))) {
5613 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand2);
5614
5615 goto exit_binary_exception;
5616 }
5617
5618 {
5619 PyObject *index_value = Nuitka_Number_Index(operand2);
5620
5621 if (unlikely(index_value == NULL)) {
5622 goto exit_binary_exception;
5623 }
5624
5625 {
5626 Py_ssize_t count = CONVERT_TO_REPEAT_FACTOR(index_value);
5627
5628 Py_DECREF(index_value);
5629
5630 /* Above conversion indicates an error as -1 */
5631 if (unlikely(count == -1)) {
5632 PyErr_Format(PyExc_OverflowError, "cannot fit '%s' into an index-sized integer", type2->tp_name);
5633 goto exit_binary_exception;
5634 }
5635 {
5636 ssizeargfunc repeatfunc = PyTuple_Type.tp_as_sequence->sq_repeat;
5637 PyObject *r = (*repeatfunc)(operand1, count);
5638
5639 obj_result = r;
5640 goto exit_binary_result_object;
5641 }
5642 }
5643 }
5644
5645 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
5646
5647exit_binary_result_object:
5648 return obj_result;
5649
5650exit_binary_exception:
5651 return NULL;
5652}
5653
5654PyObject *BINARY_OPERATION_MULT_OBJECT_TUPLE_OBJECT(PyObject *operand1, PyObject *operand2) {
5655 return _BINARY_OPERATION_MULT_OBJECT_TUPLE_OBJECT(operand1, operand2);
5656}
5657
5658/* Code referring to "OBJECT" corresponds to any Python object and "LIST" to Python 'list'. */
5659static PyObject *_BINARY_OPERATION_MULT_OBJECT_OBJECT_LIST(PyObject *operand1, PyObject *operand2) {
5660 CHECK_OBJECT(operand1);
5661 CHECK_OBJECT(operand2);
5662 assert(PyList_CheckExact(operand2));
5663
5664 PyTypeObject *type1 = Py_TYPE(operand1);
5665
5666#if defined(_MSC_VER)
5667#pragma warning(push)
5668#pragma warning(disable : 4101)
5669#endif
5670 NUITKA_MAY_BE_UNUSED bool cbool_result;
5671 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
5672#if defined(_MSC_VER)
5673#pragma warning(pop)
5674#endif
5675
5676 binaryfunc slot1 =
5677 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_multiply : NULL;
5678
5679 if (slot1 != NULL) {
5680 PyObject *x = slot1(operand1, operand2);
5681
5682 if (x != Py_NotImplemented) {
5683 obj_result = x;
5684 goto exit_binary_result_object;
5685 }
5686
5687 Py_DECREF_IMMORTAL(x);
5688 }
5689
5690#if PYTHON_VERSION < 0x300
5691 if (!NEW_STYLE_NUMBER_TYPE(type1) || !0) {
5692 coercion c1 =
5693 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
5694
5695 if (c1 != NULL) {
5696 PyObject *coerced1 = operand1;
5697 PyObject *coerced2 = operand2;
5698
5699 int err = c1(&coerced1, &coerced2);
5700
5701 if (unlikely(err < 0)) {
5702 goto exit_binary_exception;
5703 }
5704
5705 if (err == 0) {
5706 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
5707
5708 if (likely(mv == NULL)) {
5709 binaryfunc slot = mv->nb_multiply;
5710
5711 if (likely(slot != NULL)) {
5712 PyObject *x = slot(coerced1, coerced2);
5713
5714 Py_DECREF(coerced1);
5715 Py_DECREF(coerced2);
5716
5717 obj_result = x;
5718 goto exit_binary_result_object;
5719 }
5720 }
5721
5722 // nb_coerce took a reference.
5723 Py_DECREF(coerced1);
5724 Py_DECREF(coerced2);
5725 }
5726 }
5727 }
5728#endif
5729
5730 {
5731 // Special case for "+" and "*", also works as sequence concat/repeat.
5732 ssizeargfunc sq_slot = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_repeat : NULL;
5733
5734 if (sq_slot != NULL) {
5735 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand1, operand2);
5736
5737 obj_result = result;
5738 goto exit_binary_result_object;
5739 }
5740 }
5741 if (unlikely(!Nuitka_Index_Check(operand1))) {
5742 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand1);
5743
5744 goto exit_binary_exception;
5745 }
5746
5747 {
5748 PyObject *index_value = Nuitka_Number_Index(operand1);
5749
5750 if (unlikely(index_value == NULL)) {
5751 goto exit_binary_exception;
5752 }
5753
5754 {
5755 Py_ssize_t count = CONVERT_TO_REPEAT_FACTOR(index_value);
5756
5757 Py_DECREF(index_value);
5758
5759 /* Above conversion indicates an error as -1 */
5760 if (unlikely(count == -1)) {
5761 PyErr_Format(PyExc_OverflowError, "cannot fit '%s' into an index-sized integer", type1->tp_name);
5762 goto exit_binary_exception;
5763 }
5764 {
5765 ssizeargfunc repeatfunc = PyList_Type.tp_as_sequence->sq_repeat;
5766 PyObject *r = (*repeatfunc)(operand2, count);
5767
5768 obj_result = r;
5769 goto exit_binary_result_object;
5770 }
5771 }
5772 }
5773
5774 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
5775
5776exit_binary_result_object:
5777 return obj_result;
5778
5779exit_binary_exception:
5780 return NULL;
5781}
5782
5783PyObject *BINARY_OPERATION_MULT_OBJECT_OBJECT_LIST(PyObject *operand1, PyObject *operand2) {
5784 return _BINARY_OPERATION_MULT_OBJECT_OBJECT_LIST(operand1, operand2);
5785}
5786
5787/* Code referring to "LIST" corresponds to Python 'list' and "OBJECT" to any Python object. */
5788static PyObject *_BINARY_OPERATION_MULT_OBJECT_LIST_OBJECT(PyObject *operand1, PyObject *operand2) {
5789 CHECK_OBJECT(operand1);
5790 assert(PyList_CheckExact(operand1));
5791 CHECK_OBJECT(operand2);
5792
5793 PyTypeObject *type2 = Py_TYPE(operand2);
5794
5795#if defined(_MSC_VER)
5796#pragma warning(push)
5797#pragma warning(disable : 4101)
5798#endif
5799 NUITKA_MAY_BE_UNUSED bool cbool_result;
5800 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
5801#if defined(_MSC_VER)
5802#pragma warning(pop)
5803#endif
5804
5805 binaryfunc slot2 = NULL;
5806
5807 if (!(&PyList_Type == type2)) {
5808 // Different types, need to consider second value slot.
5809
5810 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_multiply : NULL;
5811 }
5812
5813 if (slot2 != NULL) {
5814 PyObject *x = slot2(operand1, operand2);
5815
5816 if (x != Py_NotImplemented) {
5817 obj_result = x;
5818 goto exit_binary_result_object;
5819 }
5820
5821 Py_DECREF_IMMORTAL(x);
5822 }
5823
5824#if PYTHON_VERSION < 0x300
5825 if (!0 || !NEW_STYLE_NUMBER_TYPE(type2)) {
5826 coercion c2 =
5827 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
5828
5829 if (c2 != NULL) {
5830 PyObject *coerced1 = operand1;
5831 PyObject *coerced2 = operand2;
5832
5833 int err = c2(&coerced2, &coerced1);
5834
5835 if (unlikely(err < 0)) {
5836 goto exit_binary_exception;
5837 }
5838
5839 if (err == 0) {
5840 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
5841
5842 if (likely(mv == NULL)) {
5843 binaryfunc slot = mv->nb_multiply;
5844
5845 if (likely(slot != NULL)) {
5846 PyObject *x = slot(coerced1, coerced2);
5847
5848 Py_DECREF(coerced1);
5849 Py_DECREF(coerced2);
5850
5851 obj_result = x;
5852 goto exit_binary_result_object;
5853 }
5854 }
5855
5856 // nb_coerce took a reference.
5857 Py_DECREF(coerced1);
5858 Py_DECREF(coerced2);
5859 }
5860 }
5861 }
5862#endif
5863
5864 if (unlikely(!Nuitka_Index_Check(operand2))) {
5865 SET_CURRENT_EXCEPTION_TYPE_COMPLAINT("can't multiply sequence by non-int of type '%s'", operand2);
5866
5867 goto exit_binary_exception;
5868 }
5869
5870 {
5871 PyObject *index_value = Nuitka_Number_Index(operand2);
5872
5873 if (unlikely(index_value == NULL)) {
5874 goto exit_binary_exception;
5875 }
5876
5877 {
5878 Py_ssize_t count = CONVERT_TO_REPEAT_FACTOR(index_value);
5879
5880 Py_DECREF(index_value);
5881
5882 /* Above conversion indicates an error as -1 */
5883 if (unlikely(count == -1)) {
5884 PyErr_Format(PyExc_OverflowError, "cannot fit '%s' into an index-sized integer", type2->tp_name);
5885 goto exit_binary_exception;
5886 }
5887 {
5888 ssizeargfunc repeatfunc = PyList_Type.tp_as_sequence->sq_repeat;
5889 PyObject *r = (*repeatfunc)(operand1, count);
5890
5891 obj_result = r;
5892 goto exit_binary_result_object;
5893 }
5894 }
5895 }
5896
5897 NUITKA_CANNOT_GET_HERE("missing error exit annotation");
5898
5899exit_binary_result_object:
5900 return obj_result;
5901
5902exit_binary_exception:
5903 return NULL;
5904}
5905
5906PyObject *BINARY_OPERATION_MULT_OBJECT_LIST_OBJECT(PyObject *operand1, PyObject *operand2) {
5907 return _BINARY_OPERATION_MULT_OBJECT_LIST_OBJECT(operand1, operand2);
5908}
5909
5910/* Code referring to "OBJECT" corresponds to any Python object and "OBJECT" to any Python object. */
5911static PyObject *_BINARY_OPERATION_MULT_OBJECT_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
5912 CHECK_OBJECT(operand1);
5913 CHECK_OBJECT(operand2);
5914
5915#if PYTHON_VERSION < 0x300
5916 if (PyInt_CheckExact(operand1) && PyInt_CheckExact(operand2)) {
5917 PyObject *result;
5918
5919 // Not every code path will make use of all possible results.
5920#if defined(_MSC_VER)
5921#pragma warning(push)
5922#pragma warning(disable : 4101)
5923#endif
5924 NUITKA_MAY_BE_UNUSED bool cbool_result;
5925 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
5926 NUITKA_MAY_BE_UNUSED long clong_result;
5927 NUITKA_MAY_BE_UNUSED double cfloat_result;
5928#if defined(_MSC_VER)
5929#pragma warning(pop)
5930#endif
5931
5932 CHECK_OBJECT(operand1);
5933 assert(PyInt_CheckExact(operand1));
5934 CHECK_OBJECT(operand2);
5935 assert(PyInt_CheckExact(operand2));
5936
5937 const long a = PyInt_AS_LONG(operand1);
5938 const long b = PyInt_AS_LONG(operand2);
5939
5940 const long longprod = (long)((unsigned long)a * b);
5941 const double doubleprod = (double)a * (double)b;
5942 const double doubled_longprod = (double)longprod;
5943
5944 if (likely(doubled_longprod == doubleprod)) {
5945 clong_result = longprod;
5946 goto exit_result_ok_clong;
5947 } else {
5948 const double diff = doubled_longprod - doubleprod;
5949 const double absdiff = diff >= 0.0 ? diff : -diff;
5950 const double absprod = doubleprod >= 0.0 ? doubleprod : -doubleprod;
5951
5952 if (likely(32.0 * absdiff <= absprod)) {
5953 clong_result = longprod;
5954 goto exit_result_ok_clong;
5955 }
5956 }
5957
5958 {
5959 PyObject *operand1_object = operand1;
5960 PyObject *operand2_object = operand2;
5961
5962 PyObject *r = PyLong_Type.tp_as_number->nb_multiply(operand1_object, operand2_object);
5963 assert(r != Py_NotImplemented);
5964
5965 obj_result = r;
5966 goto exit_result_object;
5967 }
5968
5969 exit_result_ok_clong:
5970 result = Nuitka_PyInt_FromLong(clong_result);
5971 goto exit_result_ok;
5972
5973 exit_result_object:
5974 if (unlikely(obj_result == NULL)) {
5975 goto exit_result_exception;
5976 }
5977 result = obj_result;
5978 goto exit_result_ok;
5979
5980 exit_result_ok:
5981 return result;
5982
5983 exit_result_exception:
5984 return NULL;
5985 }
5986#endif
5987
5988 PyTypeObject *type1 = Py_TYPE(operand1);
5989 PyTypeObject *type2 = Py_TYPE(operand2);
5990
5991#if defined(_MSC_VER)
5992#pragma warning(push)
5993#pragma warning(disable : 4101)
5994#endif
5995 NUITKA_MAY_BE_UNUSED bool cbool_result;
5996 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
5997#if defined(_MSC_VER)
5998#pragma warning(pop)
5999#endif
6000
6001 binaryfunc slot1 =
6002 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_multiply : NULL;
6003 binaryfunc slot2 = NULL;
6004
6005 if (!(type1 == type2)) {
6006 // Different types, need to consider second value slot.
6007
6008 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_multiply : NULL;
6009
6010 if (slot1 == slot2) {
6011 slot2 = NULL;
6012 }
6013 }
6014
6015 if (slot1 != NULL) {
6016 if (slot2 != NULL) {
6017 if (Nuitka_Type_IsSubtype(type2, type1)) {
6018 PyObject *x = slot2(operand1, operand2);
6019
6020 if (x != Py_NotImplemented) {
6021 obj_result = x;
6022 goto exit_binary_result_object;
6023 }
6024
6025 Py_DECREF_IMMORTAL(x);
6026 slot2 = NULL;
6027 }
6028 }
6029
6030 PyObject *x = slot1(operand1, operand2);
6031
6032 if (x != Py_NotImplemented) {
6033 obj_result = x;
6034 goto exit_binary_result_object;
6035 }
6036
6037 Py_DECREF_IMMORTAL(x);
6038 }
6039
6040 if (slot2 != NULL) {
6041 PyObject *x = slot2(operand1, operand2);
6042
6043 if (x != Py_NotImplemented) {
6044 obj_result = x;
6045 goto exit_binary_result_object;
6046 }
6047
6048 Py_DECREF_IMMORTAL(x);
6049 }
6050
6051#if PYTHON_VERSION < 0x300
6052 if (!NEW_STYLE_NUMBER_TYPE(type1) || !NEW_STYLE_NUMBER_TYPE(type2)) {
6053 coercion c1 =
6054 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
6055
6056 if (c1 != NULL) {
6057 PyObject *coerced1 = operand1;
6058 PyObject *coerced2 = operand2;
6059
6060 int err = c1(&coerced1, &coerced2);
6061
6062 if (unlikely(err < 0)) {
6063 goto exit_binary_exception;
6064 }
6065
6066 if (err == 0) {
6067 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
6068
6069 if (likely(mv == NULL)) {
6070 binaryfunc slot = mv->nb_multiply;
6071
6072 if (likely(slot != NULL)) {
6073 PyObject *x = slot(coerced1, coerced2);
6074
6075 Py_DECREF(coerced1);
6076 Py_DECREF(coerced2);
6077
6078 obj_result = x;
6079 goto exit_binary_result_object;
6080 }
6081 }
6082
6083 // nb_coerce took a reference.
6084 Py_DECREF(coerced1);
6085 Py_DECREF(coerced2);
6086 }
6087 }
6088 coercion c2 =
6089 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
6090
6091 if (c2 != NULL) {
6092 PyObject *coerced1 = operand1;
6093 PyObject *coerced2 = operand2;
6094
6095 int err = c2(&coerced2, &coerced1);
6096
6097 if (unlikely(err < 0)) {
6098 goto exit_binary_exception;
6099 }
6100
6101 if (err == 0) {
6102 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
6103
6104 if (likely(mv == NULL)) {
6105 binaryfunc slot = mv->nb_multiply;
6106
6107 if (likely(slot != NULL)) {
6108 PyObject *x = slot(coerced1, coerced2);
6109
6110 Py_DECREF(coerced1);
6111 Py_DECREF(coerced2);
6112
6113 obj_result = x;
6114 goto exit_binary_result_object;
6115 }
6116 }
6117
6118 // nb_coerce took a reference.
6119 Py_DECREF(coerced1);
6120 Py_DECREF(coerced2);
6121 }
6122 }
6123 }
6124#endif
6125
6126 {
6127 // Special case for "+" and "*", also works as sequence concat/repeat.
6128 ssizeargfunc sq_slot = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_repeat : NULL;
6129
6130 if (sq_slot != NULL) {
6131 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand1, operand2);
6132
6133 obj_result = result;
6134 goto exit_binary_result_object;
6135 }
6136 }
6137 // Special case for "*", also work with sequence repeat from right argument.
6138 {
6139 ssizeargfunc sq_slot = type2->tp_as_sequence != NULL ? type2->tp_as_sequence->sq_repeat : NULL;
6140
6141 if (sq_slot != NULL) {
6142 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand2, operand1);
6143
6144 obj_result = result;
6145 goto exit_binary_result_object;
6146 }
6147 }
6148
6149 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: '%s' and '%s'", type1->tp_name, type2->tp_name);
6150 goto exit_binary_exception;
6151
6152exit_binary_result_object:
6153 return obj_result;
6154
6155exit_binary_exception:
6156 return NULL;
6157}
6158
6159PyObject *BINARY_OPERATION_MULT_OBJECT_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
6160 return _BINARY_OPERATION_MULT_OBJECT_OBJECT_OBJECT(operand1, operand2);
6161}
6162
6163/* Code referring to "OBJECT" corresponds to any Python object and "OBJECT" to any Python object. */
6164static nuitka_bool _BINARY_OPERATION_MULT_NBOOL_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
6165 CHECK_OBJECT(operand1);
6166 CHECK_OBJECT(operand2);
6167
6168#if PYTHON_VERSION < 0x300
6169 if (PyInt_CheckExact(operand1) && PyInt_CheckExact(operand2)) {
6170 nuitka_bool result;
6171
6172 // Not every code path will make use of all possible results.
6173#if defined(_MSC_VER)
6174#pragma warning(push)
6175#pragma warning(disable : 4101)
6176#endif
6177 NUITKA_MAY_BE_UNUSED bool cbool_result;
6178 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
6179 NUITKA_MAY_BE_UNUSED long clong_result;
6180 NUITKA_MAY_BE_UNUSED double cfloat_result;
6181#if defined(_MSC_VER)
6182#pragma warning(pop)
6183#endif
6184
6185 CHECK_OBJECT(operand1);
6186 assert(PyInt_CheckExact(operand1));
6187 CHECK_OBJECT(operand2);
6188 assert(PyInt_CheckExact(operand2));
6189
6190 const long a = PyInt_AS_LONG(operand1);
6191 const long b = PyInt_AS_LONG(operand2);
6192
6193 const long longprod = (long)((unsigned long)a * b);
6194 const double doubleprod = (double)a * (double)b;
6195 const double doubled_longprod = (double)longprod;
6196
6197 if (likely(doubled_longprod == doubleprod)) {
6198 clong_result = longprod;
6199 goto exit_result_ok_clong;
6200 } else {
6201 const double diff = doubled_longprod - doubleprod;
6202 const double absdiff = diff >= 0.0 ? diff : -diff;
6203 const double absprod = doubleprod >= 0.0 ? doubleprod : -doubleprod;
6204
6205 if (likely(32.0 * absdiff <= absprod)) {
6206 clong_result = longprod;
6207 goto exit_result_ok_clong;
6208 }
6209 }
6210
6211 {
6212 PyObject *operand1_object = operand1;
6213 PyObject *operand2_object = operand2;
6214
6215 PyObject *r = PyLong_Type.tp_as_number->nb_multiply(operand1_object, operand2_object);
6216 assert(r != Py_NotImplemented);
6217
6218 obj_result = r;
6219 goto exit_result_object;
6220 }
6221
6222 exit_result_ok_clong:
6223 result = clong_result != 0 ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6224 goto exit_result_ok;
6225
6226 exit_result_object:
6227 if (unlikely(obj_result == NULL)) {
6228 goto exit_result_exception;
6229 }
6230 result = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6231 Py_DECREF(obj_result);
6232 goto exit_result_ok;
6233
6234 exit_result_ok:
6235 return result;
6236
6237 exit_result_exception:
6238 return NUITKA_BOOL_EXCEPTION;
6239 }
6240#endif
6241
6242 PyTypeObject *type1 = Py_TYPE(operand1);
6243 PyTypeObject *type2 = Py_TYPE(operand2);
6244
6245#if defined(_MSC_VER)
6246#pragma warning(push)
6247#pragma warning(disable : 4101)
6248#endif
6249 NUITKA_MAY_BE_UNUSED bool cbool_result;
6250 NUITKA_MAY_BE_UNUSED PyObject *obj_result;
6251#if defined(_MSC_VER)
6252#pragma warning(pop)
6253#endif
6254
6255 binaryfunc slot1 =
6256 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_multiply : NULL;
6257 binaryfunc slot2 = NULL;
6258
6259 if (!(type1 == type2)) {
6260 // Different types, need to consider second value slot.
6261
6262 slot2 = (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_multiply : NULL;
6263
6264 if (slot1 == slot2) {
6265 slot2 = NULL;
6266 }
6267 }
6268
6269 if (slot1 != NULL) {
6270 if (slot2 != NULL) {
6271 if (Nuitka_Type_IsSubtype(type2, type1)) {
6272 PyObject *x = slot2(operand1, operand2);
6273
6274 if (x != Py_NotImplemented) {
6275 obj_result = x;
6276 goto exit_binary_result_object;
6277 }
6278
6279 Py_DECREF_IMMORTAL(x);
6280 slot2 = NULL;
6281 }
6282 }
6283
6284 PyObject *x = slot1(operand1, operand2);
6285
6286 if (x != Py_NotImplemented) {
6287 obj_result = x;
6288 goto exit_binary_result_object;
6289 }
6290
6291 Py_DECREF_IMMORTAL(x);
6292 }
6293
6294 if (slot2 != NULL) {
6295 PyObject *x = slot2(operand1, operand2);
6296
6297 if (x != Py_NotImplemented) {
6298 obj_result = x;
6299 goto exit_binary_result_object;
6300 }
6301
6302 Py_DECREF_IMMORTAL(x);
6303 }
6304
6305#if PYTHON_VERSION < 0x300
6306 if (!NEW_STYLE_NUMBER_TYPE(type1) || !NEW_STYLE_NUMBER_TYPE(type2)) {
6307 coercion c1 =
6308 (type1->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type1)) ? type1->tp_as_number->nb_coerce : NULL;
6309
6310 if (c1 != NULL) {
6311 PyObject *coerced1 = operand1;
6312 PyObject *coerced2 = operand2;
6313
6314 int err = c1(&coerced1, &coerced2);
6315
6316 if (unlikely(err < 0)) {
6317 goto exit_binary_exception;
6318 }
6319
6320 if (err == 0) {
6321 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
6322
6323 if (likely(mv == NULL)) {
6324 binaryfunc slot = mv->nb_multiply;
6325
6326 if (likely(slot != NULL)) {
6327 PyObject *x = slot(coerced1, coerced2);
6328
6329 Py_DECREF(coerced1);
6330 Py_DECREF(coerced2);
6331
6332 obj_result = x;
6333 goto exit_binary_result_object;
6334 }
6335 }
6336
6337 // nb_coerce took a reference.
6338 Py_DECREF(coerced1);
6339 Py_DECREF(coerced2);
6340 }
6341 }
6342 coercion c2 =
6343 (type2->tp_as_number != NULL && NEW_STYLE_NUMBER_TYPE(type2)) ? type2->tp_as_number->nb_coerce : NULL;
6344
6345 if (c2 != NULL) {
6346 PyObject *coerced1 = operand1;
6347 PyObject *coerced2 = operand2;
6348
6349 int err = c2(&coerced2, &coerced1);
6350
6351 if (unlikely(err < 0)) {
6352 goto exit_binary_exception;
6353 }
6354
6355 if (err == 0) {
6356 PyNumberMethods *mv = Py_TYPE(coerced1)->tp_as_number;
6357
6358 if (likely(mv == NULL)) {
6359 binaryfunc slot = mv->nb_multiply;
6360
6361 if (likely(slot != NULL)) {
6362 PyObject *x = slot(coerced1, coerced2);
6363
6364 Py_DECREF(coerced1);
6365 Py_DECREF(coerced2);
6366
6367 obj_result = x;
6368 goto exit_binary_result_object;
6369 }
6370 }
6371
6372 // nb_coerce took a reference.
6373 Py_DECREF(coerced1);
6374 Py_DECREF(coerced2);
6375 }
6376 }
6377 }
6378#endif
6379
6380 {
6381 // Special case for "+" and "*", also works as sequence concat/repeat.
6382 ssizeargfunc sq_slot = type1->tp_as_sequence != NULL ? type1->tp_as_sequence->sq_repeat : NULL;
6383
6384 if (sq_slot != NULL) {
6385 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand1, operand2);
6386
6387 obj_result = result;
6388 goto exit_binary_result_object;
6389 }
6390 }
6391 // Special case for "*", also work with sequence repeat from right argument.
6392 {
6393 ssizeargfunc sq_slot = type2->tp_as_sequence != NULL ? type2->tp_as_sequence->sq_repeat : NULL;
6394
6395 if (sq_slot != NULL) {
6396 PyObject *result = SEQUENCE_REPEAT(sq_slot, operand2, operand1);
6397
6398 obj_result = result;
6399 goto exit_binary_result_object;
6400 }
6401 }
6402
6403 PyErr_Format(PyExc_TypeError, "unsupported operand type(s) for *: '%s' and '%s'", type1->tp_name, type2->tp_name);
6404 goto exit_binary_exception;
6405
6406exit_binary_result_object:
6407 if (unlikely(obj_result == NULL)) {
6408 return NUITKA_BOOL_EXCEPTION;
6409 }
6410
6411 {
6412 nuitka_bool r = CHECK_IF_TRUE(obj_result) ? NUITKA_BOOL_TRUE : NUITKA_BOOL_FALSE;
6413 Py_DECREF(obj_result);
6414 return r;
6415 }
6416
6417exit_binary_exception:
6418 return NUITKA_BOOL_EXCEPTION;
6419}
6420
6421nuitka_bool BINARY_OPERATION_MULT_NBOOL_OBJECT_OBJECT(PyObject *operand1, PyObject *operand2) {
6422 return _BINARY_OPERATION_MULT_NBOOL_OBJECT_OBJECT(operand1, operand2);
6423}
6424
6425// Part of "Nuitka", an optimizing Python compiler that is compatible and
6426// integrates with CPython, but also works on its own.
6427//
6428// Licensed under the Apache License, Version 2.0 (the "License");
6429// you may not use this file except in compliance with the License.
6430// You may obtain a copy of the License at
6431//
6432// http://www.apache.org/licenses/LICENSE-2.0
6433//
6434// Unless required by applicable law or agreed to in writing, software
6435// distributed under the License is distributed on an "AS IS" BASIS,
6436// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6437// See the License for the specific language governing permissions and
6438// limitations under the License.