1. Список говнокодов пользователя j123123

    Всего: 338

  2. C++ / Говнокод #27397

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    // https://habr.com/ru/company/yandex_praktikum/blog/555704/
    // Стандарт C++20: обзор новых возможностей C++. Часть 2 «Операция ''Космический Корабль''»
    
    // Предположим, вы определили структуру, содержащую одно число:
    
    struct X {
        int a;
    };
    
    // Мы хотим сделать так, чтобы значения этой структуры можно было сравнивать друг с другом.
    // Для этого придётся написать шесть операций:
    
    bool operator== (X l, X r) { return l.a == r.a; }
    bool operator!= (X l, X r) { return l.a != r.a; }
    bool operator>= (X l, X r) { return l.a >= r.a; }
    bool operator<= (X l, X r) { return l.a <= r.a; }
    bool operator< (X l, X r) { return l.a < r.a; }
    bool operator> (X l, X r) { return l.a > r.a; }
    
    // А теперь представьте, что мы хотим сравнивать элементы этой структуры не только между собой,
    // но также с числами int. Количество операций возрастает с шести до 18:
    
    bool operator== (X l, int r) { return l.a == r; }
    bool operator!= (X l, int r) { return l.a != r; }
    bool operator>= (X l, int r) { return l.a >= r; }
    bool operator<= (X l, int r) { return l.a <= r; }
    bool operator< (X l, int r) { return l.a < r; }
    bool operator> (X l, int r) { return l.a > r; }
    
    bool operator== (int l, X r) { return l == r.a; }
    bool operator!= (int l, X r) { return l != r.a; }
    bool operator>= (int l, X r) { return l >= r.a; }
    bool operator<= (int l, X r) { return l <= r.a; }
    bool operator< (int l, X r) { return l < r.a; }
    bool operator> (int l, X r) { return l > r.a; }
    
    // Что делать? Можно позвать штурмовиков. Их много, и они быстро напишут 18 операций.
    
    // Или воспользоваться «космическим кораблём». Эту новую операцию в C++ называют
    // «космический корабль», потому что она на него похожа: <=>. Более формальное название
    // «трёхстороннее сравнение» фигурирует в документах Стандарта.

    А можно добавить гомоиконность, которой можно наметушить не только какой-то там космический корабль (ради которого в крестокомпиляторах надо синтаксический анализатор менять, чтоб добавить новое синтаксиальное говно для этого <=>), а хоть целую, блядь, эскадрилью космических кораблей, которая работает не только для "больше меньше равно", но и для любой вообразимой поебени

    Но крестушкам конечно привычней добавить какой-то ad-hoc хуиты для частных случаев.

    j123123, 07 Мая 2021

    Комментарии (9)
  3. Куча / Говнокод #27379

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    (set-logic UF)
    ; https://smtlib.cs.uiowa.edu/logics.shtml
    ; UF for the extension allowing free sort and function symbols 
    
    (set-option :produce-proofs true)
    
    (declare-sort M_wff)
    
    
    ; AND2
    (declare-fun M_a2 (M_wff M_wff) M_wff)
    
    ; AND3
    (declare-fun M_a3 (M_wff M_wff M_wff) M_wff)
    
    
    
    ; (AND2 a b) <=> (AND2 b a)
    
    (assert 
      (forall ( (a M_wff) (b M_wff) )
        (=
          (M_a2 a b)
          (M_a2 b a)
        )
      )
    )
    
    
    
    ; (AND2 a a) <=> a
    
    (assert 
      (forall ( (a M_wff) )
        (=
          (M_a2 a a)
          a
        )
      )
    )
    
    
    
    ; (AND2 a (AND2 b c)) <=> (AND3 a b c)
    
    (assert 
      (forall ( (a M_wff) (b M_wff) (c M_wff) )
        (=
          (M_a2 a (M_a2 b c))
          (M_a3 a b c)
        )
      )
    )
    
    
    
    ; (AND3 a b c) <=> (AND3 b a c)
    
    (assert
      (forall ( (a M_wff) (b M_wff) (c M_wff) )
        (=
          (M_a3 a b c)
          (M_a3 b a c)
        )
      )
    )
    
    
    
    ; IMPL - implication
    (declare-fun M_impl (M_wff M_wff) M_wff)
    
    
    
    ; http://us.metamath.org/ileuni/ax-1.html
    ; Axiom Simp
    ; (IMPL a (IMPL b a)) <=> (AND2 a b)
    
    (assert
      (forall ( (a M_wff) (b M_wff) )
        (=
          (M_impl a (M_impl b a))
          (M_a2 a b)
        )
      )
    )
    
    ...

    Весь код не влазит.

    https://rise4fun.com/Z3/GnfIH
    https://paste.debian.net/hidden/38ef8493/ (запасная ссылка)

    Переписывал Metamath на язык из SMT солверов https://smtlib.cs.uiowa.edu/language.shtml
    Z3 даже умеет доказывать какую-то питушню там.

    j123123, 28 Апреля 2021

    Комментарии (72)
  4. C++ / Говнокод #27364

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    // А какие-нибудь IDE с интегрированными отладчиками (или
    // отладчики сами по себе) умеют нахрен выкидывать всякую
    // там компилтайм-метушню из кода, оставляя лишь то, что
    // реально исполняется в рантайме?
    
    // Ну например, чтобы хуйня вида
    if constexpr(хуйня1)
    {
      bagor1();
      if constexpr(хуйня2)
      {
        bagor11();
      }
      else
      {
        bagor12();
      }
    }
    else
    {
      bagor2();
      if constexpr (хуйня3)
      {
        bagor21();
      }
      bagor();
    }
    
    // и если хуйня1 == true и хуйня2 == false то чтоб в отладчике
    // в какой-то там говноIDE я увидел бы не эту пидоросню с if consexpr
    // а только лишь
    
    bagor1();
    bagor12();

    Есть ли такое?

    j123123, 18 Апреля 2021

    Комментарии (203)
  5. C++ / Говнокод #27349

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    // https://govnokod.ru/27340#comment621647
    
    #include <iostream>
    #include <cstdlib>
    
    #define SPLICE(a,b) SPLICE_1(a,b)
    #define SPLICE_1(a,b) SPLICE_2(a,b)
    #define SPLICE_2(a,b) a##b
    
    
    #define PP_ARG_N( \
              _1,  _2,  _3,  _4,  _5,  _6,  _7,  _8,  _9, _10, \
             _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \
             _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, \
             _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, \
             _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, \
             _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, \
             _61, _62, _63, N, ...) N
    
    /* Note 63 is removed */
    #define PP_RSEQ_N()                                        \
             62, 61, 60,                                       \
             59, 58, 57, 56, 55, 54, 53, 52, 51, 50,           \
             49, 48, 47, 46, 45, 44, 43, 42, 41, 40,           \
             39, 38, 37, 36, 35, 34, 33, 32, 31, 30,           \
             29, 28, 27, 26, 25, 24, 23, 22, 21, 20,           \
             19, 18, 17, 16, 15, 14, 13, 12, 11, 10,           \
              9,  8,  7,  6,  5,  4,  3,  2,  1,  0
    
    #define PP_NARG_(...)    PP_ARG_N(__VA_ARGS__)    
    
    /* Note dummy first argument _ and ##__VA_ARGS__ instead of __VA_ARGS__ */
    // note: using __VA_OPT__ shit instead ##__VA_ARGS__
    #define PP_NARG(...)     PP_NARG_(_ __VA_OPT__(,) __VA_ARGS__, PP_RSEQ_N())
    
    #define MK_VAR_T(type, name) \
    typeof(type) name
    
    #define TYPE_ADD_0()
    
    #define TYPE_ADD_1(VAR) \
      MK_VAR_T VAR;
    #define TYPE_ADD_2(VAR, ...) \
      MK_VAR_T VAR; TYPE_ADD_1(__VA_ARGS__)
    #define TYPE_ADD_3(VAR, ...) \
      MK_VAR_T VAR; TYPE_ADD_2(__VA_ARGS__)
    #define TYPE_ADD_4(VAR, ...) \
      MK_VAR_T VAR; TYPE_ADD_3(__VA_ARGS__)
    #define TYPE_ADD_5(VAR, ...) \
      MK_VAR_T VAR; TYPE_ADD_4(__VA_ARGS__)
    #define TYPE_ADD_6(VAR, ...) \
      MK_VAR_T VAR; TYPE_ADD_5(__VA_ARGS__)
    #define TYPE_ADD_7(VAR, ...) \
      MK_VAR_T VAR; TYPE_ADD_6(__VA_ARGS__)
    #define TYPE_ADD_8(VAR, ...) \
      MK_VAR_T VAR; TYPE_ADD_7(__VA_ARGS__)
    #define TYPE_ADD_9(VAR, ...) \
      MK_VAR_T VAR; TYPE_ADD_8(__VA_ARGS__)
    #define TYPE_ADD_10(VAR, ...) \
      MK_VAR_T VAR; TYPE_ADD_9(__VA_ARGS__)
    #define TYPE_ADD_11(VAR, ...) \
      MK_VAR_T VAR; TYPE_ADD_10(__VA_ARGS__)
    
    
    #define TYPE_ADD_(N, ...) \
      SPLICE(TYPE_ADD_, N)(__VA_ARGS__)
    
    #define TYPE_ADD(...) \
      TYPE_ADD_(PP_NARG(__VA_ARGS__), __VA_ARGS__)
    
    #define REM_BRACKET(...) __VA_ARGS__
    
    #define LAMBDA(name, vars, code) \
    struct name {TYPE_ADD vars void operator()() const REM_BRACKET code}
    
    int main()
    {
      LAMBDA
      (
        some_type_name,
        ((int, a), (float, b), (double, c)),
        ({
          std::cout << "Hello, world! " << a << " " << b << " " << c << std::endl;
        })
      );
      
      auto lambda = some_type_name(1, 3.14f, 0.25);
      lambda();
    }

    Вот вам говнолямбда на препроцессоре.

    j123123, 11 Апреля 2021

    Комментарии (9)
  6. Си / Говнокод #27345

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    #include <stdio.h>
    #include <stdlib.h>
    
    #define SPLICE(a,b) SPLICE_1(a,b)
    #define SPLICE_1(a,b) SPLICE_2(a,b)
    #define SPLICE_2(a,b) a##b
    
    
    #define PP_ARG_N( \
              _1,  _2,  _3,  _4,  _5,  _6,  _7,  _8,  _9, _10, \
             _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, \
             _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, \
             _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, \
             _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, \
             _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, \
             _61, _62, _63, N, ...) N
    
    /* Note 63 is removed */
    #define PP_RSEQ_N()                                        \
             62, 61, 60,                                       \
             59, 58, 57, 56, 55, 54, 53, 52, 51, 50,           \
             49, 48, 47, 46, 45, 44, 43, 42, 41, 40,           \
             39, 38, 37, 36, 35, 34, 33, 32, 31, 30,           \
             29, 28, 27, 26, 25, 24, 23, 22, 21, 20,           \
             19, 18, 17, 16, 15, 14, 13, 12, 11, 10,           \
              9,  8,  7,  6,  5,  4,  3,  2,  1,  0
    
    #define PP_NARG_(...)    PP_ARG_N(__VA_ARGS__)    
    
    /* Note dummy first argument _ and ##__VA_ARGS__ instead of __VA_ARGS__ */
    #define PP_NARG(...)     PP_NARG_(_, ##__VA_ARGS__, PP_RSEQ_N())
    
    #define FIND_NONNULL_1(RES) \
      ((RES = (char *)(NULL)))
    
    #define FIND_NONNULL_2(RES, VAR) \
      ((RES = (char *)(VAR)))
    
    #define FIND_NONNULL_3(RES, VAR, ...) \
      (((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_2(RES,__VA_ARGS__))
    
    #define FIND_NONNULL_4(RES, VAR, ...) \
      (((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_3(RES,__VA_ARGS__))
    
    #define FIND_NONNULL_5(RES, VAR, ...) \
      (((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_4(RES,__VA_ARGS__))
    
    #define FIND_NONNULL_6(RES, VAR, ...) \
      (((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_5(RES,__VA_ARGS__))
    
    #define FIND_NONNULL_7(RES, VAR, ...) \
      (((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_6(RES,__VA_ARGS__))
    
    #define FIND_NONNULL_8(RES, VAR, ...) \
      (((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_7(RES,__VA_ARGS__))
    
    #define FIND_NONNULL_9(RES, VAR, ...) \
      (((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_8(RES,__VA_ARGS__))
    
    #define FIND_NONNULL_10(RES, VAR, ...) \
      (((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_9(RES,__VA_ARGS__))
    
    #define FIND_NONNULL_11(RES, VAR, ...) \
      (((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_10(RES,__VA_ARGS__))
    
    #define FIND_NONNULL_12(RES, VAR, ...) \
      (((RES = (char *)(VAR)) != NULL)?RES:FIND_NONNULL_11(RES,__VA_ARGS__))
    
    // etc ...
    
    #define FIND_NONNULLS_(N, ...) \
      SPLICE(FIND_NONNULL_, N)(__VA_ARGS__)
    
    #define FIND_NONNULLS(...) \
    ({ \
      char *FIND_NONNULLS; \
      FIND_NONNULLS_(PP_NARG(FIND_NONNULLS, __VA_ARGS__), FIND_NONNULLS, __VA_ARGS__); \
      FIND_NONNULLS; \
    })
    
    char *side_effect_null(void)
    {
      printf("!!null!!\n");
      return NULL;
    }
    
    char *side_effect_test(void)
    {
      printf("!!test!!\n");
      return "test";
    }
    
    int main(void)
    {
      printf( "result:%s\n", FIND_NONNULLS(0,side_effect_null(),0,side_effect_test(),0,0,side_effect_test(),"govno", side_effect_test()) );
      return EXIT_SUCCESS;
    }

    Это типа как short-circuit evaluation чтоб по цепочке хрень возвращающую строку вызывать, и там те функции хуйпойми сколько аргументов могут принимать (но там может быть константа, тогда естественно нихрена не надо вызывать) пока оно не вернет не-NULL. Как только вернуло не-NULL то вернуть это и дальше ничего не вызывать, а то там сайд эффекты всякие ненужные будут. А если не-NULL так и не нашло, вернуть NULL

    j123123, 09 Апреля 2021

    Комментарии (24)
  7. Си / Говнокод #27344

    +3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    // https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <stdbool.h>
    
    
    
    int main(void)
    {
      char *a = "petuh";
      if(({bool ret = 0;if(a[0]=='p')if(a[1]=='e')if(a[2]=='t')if(a[3]=='u')if(a[4]=='h')ret=1;ret;}))
      {
        puts(a);
      }
      return EXIT_SUCCESS;
    }

    Интересное расширение.

    j123123, 09 Апреля 2021

    Комментарии (33)
  8. Си / Говнокод #27294

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    // https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Common-Function-Attributes.html
    
    access
    access (access-mode, ref-index)
    access (access-mode, ref-index, size-index)
    
    // примеры:
    
    __attribute__ ((access (read_only, 1))) int puts (const char*);
    __attribute__ ((access (read_only, 1, 2))) void* memcpy (void*, const void*, size_t);
    
    __attribute__ ((access (read_write, 1), access (read_only, 2))) char* strcat (char*, const char*);
    
    __attribute__ ((access (write_only, 1), access (read_only, 2))) char* strcpy (char*, const char*);
    __attribute__ ((access (write_only, 1, 2), access (read_write, 3))) int fgets (char*, int, FILE*);

    В GCC 10 какой-то новый атрибут access появился, чтоб более строго что-то там гарантировать:

    The access attribute enables the detection of invalid or unsafe accesses by functions to which they apply or their callers, as well as write-only accesses to objects that are never read from. Such accesses may be diagnosed by warnings such as -Wstringop-overflow, -Wuninitialized, -Wunused, and others.

    The access attribute specifies that a function to whose by-reference arguments the attribute applies accesses the referenced object according to access-mode. The access-mode argument is required and must be one of three names: read_only, read_write, or write_only. The remaining two are positional arguments.

    The required ref-index positional argument denotes a function argument of pointer (or in C++, reference) type that is subject to the access. The same pointer argument can be referenced by at most one distinct access attribute.

    The optional size-index positional argument denotes a function argument of integer type that specifies the maximum size of the access. The size is the number of elements of the type referenced by ref-index, or the number of bytes when the pointer type is void*. When no size-index argument is specified, the pointer argument must be either null or point to a space that is suitably aligned and large for at least one object of the referenced type (this implies that a past-the-end pointer is not a valid argument). The actual size of the access may be less but it must not be more.

    j123123, 14 Марта 2021

    Комментарии (242)
  9. Си / Говнокод #27285

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    #include <stdio.h>
    #include <string.h>
    
    double emit_fmadd(double a, double b, double c) __attribute ((noinline));
    
    double emit_fmadd(double a, double b, double c)
    {
      return a*b+c;
    }
    
    
    int main(void)
    {
      double a = 10.0000;
      double b = 1.00001;
      double c = 1.001;
      double res = emit_fmadd(a,b,c);
      unsigned char arr[sizeof(res)];
      memcpy(arr, &res, sizeof(res));
      for (int i = 0; i < sizeof(res); i++)
      {
        printf("%.2x ", arr[i]);
      }
      printf("\n");
    }
    
    /*
    gcc -O3 -march=skylake
    emit_fmadd:
            vfmadd132sd     xmm0, xmm2, xmm1
            ret
    
    
    gcc -O3 -march=x86-64
    emit_fmadd:
            mulsd   xmm0, xmm1
            addsd   xmm0, xmm2
            ret
    */

    Вот к чему плавучий питух приводит!
    https://godbolt.org/z/sP19zP

    j123123, 06 Марта 2021

    Комментарии (11)
  10. Куча / Говнокод #27276

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    (set-logic UF)
    ; https://smtlib.cs.uiowa.edu/logics.shtml
    ; UF for the extension allowing free sort and function symbols 
    
    (set-option :produce-proofs true)
    
    (declare-sort M_list)
    
    (declare-fun m_node (M_list M_list) M_list)
    
    ; один хер какой порядок, можно переписать (a, b) на (b, a)
    (assert
      (forall ( (a M_list) (b M_list) )
        (=
          (m_node a b)
          (m_node b a)
        )
      )
    )
    
    ; если есть (a (b c)) то можно переписать на (с (a b))
    (assert
      (forall ( (a M_list) (b M_list) (c M_list) )
        (=
          (m_node a (m_node b c) )
          (m_node c (m_node a b) )
        )
      )
    )
    
    ; Можно создавать или удалять повторы, (a a) <=> a
    (assert
      (forall ( (a M_list))
        (=
          (m_node a a)
          a
        )
      )
    )
    
    
    ; Чтоб узнать, выводима ли такая-то хернь
    (declare-fun m_node_select (M_list M_list) Bool)
    
    
    (assert
      (forall ( (a M_list) (b M_list) )
        (m_node_select
          a (m_node a b)
        )
      )
    )
    
    ; проверяем, можно ли сконструировать (a a) из (c ((b d) a))
    (assert
      (not (forall ( (a M_list) (b M_list) (c M_list) (d M_list) )
        (m_node_select
          (m_node a a)
          (m_node c (m_node (m_node b d) a) )
        )
      ))
    )
    
    
    (check-sat)
    (get-proof)

    Вот вам немного гомоикон SMT-солвера. Эта вот хренотень сама доказывает, не то что какой-то там Coq.

    Понятно что по тем вот говноправилам можно чтоб всплыло 'a' и потом его удвоить "(a a) <=> a"
    потом через m_node_select вытащить этот дубликат

    j123123, 01 Марта 2021

    Комментарии (71)
  11. Си / Говнокод #27266

    +3

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    // https://deadlockempire.github.io/
    // Игра, где надо играть за планировщик чтоб вызвать дедлок
    
    // https://deadlockempire.github.io/#2-flags
    
    // First Army
    
    while (true) {
      while (flag != false) {
        ;
      }
      flag = true;
      critical_section();
      flag = false;
    }
    
    // Second Army
    
    while (true) {
      while (flag != false) {
        ;
      }
      flag = true;
      critical_section();
      flag = false;
    }

    The day finally came. The Deadlock Empire opened its gates and from them surged massive amounts of soldiers, loyal servants of the evil Parallel Wizard. The Wizard has many strengths - his armies are fast, and he can do a lot of stuff that we can't. But now he set out to conquer the world, and we cannot have that.

    You are our best Scheduler, commander! We have fewer troops and simpler ones, so we will need your help. Already two armies of the Deadlock Empire are approaching our border keeps. They are poorly equipped and poorly trained, however. You might be able to desync them and break their morale.

    j123123, 20 Февраля 2021

    Комментарии (60)