1. Си / Говнокод #27420

    +2

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    #include <stdio.h>
    #include <stdlib.h>
    #define RW(a, c) for(src = (a);src < (c); src++, dst++){*dst=*src;} 
    void *pairscan(char *p)
    {
      size_t p_count = 1;
      do {
        if(*p == 'P') {
          p_count++;
        }
        else {
          p_count--;
        }
        p++;
      } while(p_count != 0);
      return p;
    }
    
    
    void rewrite(char *src, char *dst)
    {
      int p_r = 0;
      while(*src == 'P') {
        *dst = *src;
        src++; dst++;
        if (p_r < 3)
        {
          p_r++;
        }
      }
      if(*src == 'I') {
        if(p_r < 1) {
          while(*src != 0) {
            *dst = *src;
            src++; dst++;
          }
          *dst = 0;
          return;
        }
        dst--;
        src++;
        //src = pairscan(src+1);
        while(*src != 0) {
          *dst = *src;
          src++; dst++;
        }
        *dst = 0;
        return;
      }
      if(*src == 'K') {
        if(p_r < 2)
        {
          while(*src != 0) {
            *dst = *src;
            src++; dst++;
          }
          *dst = 0;
          return;
        }
        dst-=2;
        char *exp1 = pairscan(src+1);
        char *exp2 = pairscan(exp1);
        RW(src+1,exp1);
        for(; src < exp2; src++){}
        while(*src != 0) {
          *dst = *src;
          src++; dst++;
        }
        *dst = 0;
        return;
      }
      if(*src == 'S') {
        if(p_r < 3) {
          while(*src != 0){
            *dst = *src;
            src++; dst++;
          }
          *dst = 0;
          return;
        }
        dst-=1;
        char *exp1 = pairscan(src+1);
        char *exp2 = pairscan(exp1);
        char *exp3 = pairscan(exp2);
        RW(src+1,exp1);
        RW(exp2,exp3);    
        *dst = 'P';
        dst++;
        RW(exp1,exp2);
        RW(exp2,exp3);
        while(*src != 0) {
          *dst = *src;
          src++; dst++;
        }
        *dst = 0;
        return;
      }
      *dst = 0;
      return;
    }

    Кобенаторная логика
    SKI combinator calculus

    j123123, 11 Мая 2021

    Комментарии (35)
  2. Си / Говнокод #27407

    0

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    // https://github.com/sergev/bkunix/blob/master/src/bin/pwd.c
    void
    cat(name)
    	char *name;
    {
    	register int i, j;
    
    	i = -1;
    	while (name[++i] != 0);
    	if ((off+i+2) > 511) {
    		write(2, "pwd: too long path\n", 19);
    		exit(1);
    	}
    	for (j=off+1; j>=0; --j)
    		path[j+i+1] = path[j];
    	off=i+off+1;
    	path[i] = '/';
    	for (--i; i>=0; --i)
    		path[i] = name[i];
    }
    
    char * ckroot(dev, ino)
    int dev, ino;
    {
    	DIR * dir;
    	struct stat st;
    	register struct dirent * d;
    	chdir("/");
    	dir = opendir("/");
    	do {
    		d = readdir(dir);
    		if (! d) {
    			return "[mount point]";
    		}
    		stat(d->d_name, &st);
    	} while (st.st_dev != dev || st.st_ino != ino);
    	closedir(dir);
    	return d->d_name;
    }
    
    int
    main()
    {
    	int rdev, rino;
    	DIR *dir;
    	struct stat dot, dotdot;
    	register struct dirent *d;
    
    	stat("/", &dot);
    	rdev = dot.st_dev;
    	rino = dot.st_ino;
    /*printf ("/ dev=%d ino=%d\n", rdev, (int) rino);*/
    	for (;;) {
    		stat(".", &dot);
    /*printf (". dev=%d ino=%d\n", (int) dot.st_dev, (int) dot.st_ino);*/
    		if (dot.st_ino == rino && dot.st_dev == rdev)
    			break;
    		dir = opendir("..");
    		if (! dir) {
    			write(2, "pwd: cannot open ..\n", 20);
    			return 1;
    		}
    		stat("..", &dotdot);
    /*printf (".. dev=%d ino=%d\n", (int) dotdot.st_dev, (int) dotdot.st_ino);*/
    		chdir("..");
    		if (dot.st_dev == dotdot.st_dev) {
    			if (dot.st_ino == dotdot.st_ino) {
    				cat(ckroot(dot.st_dev, dot.st_ino));
    				break;
    			}
    			do {
    				d = readdir(dir);
    				if (! d) {
    					write(2, "read error in ..\n", 17);
    					return 1;
    				}
    			} while (d->d_ino != dot.st_ino);
    		} else {
    			do {
    				d = readdir(dir);
    				if (! d) {
    					write(2, "read error in ..\n", 17);
    					return 1;
    				}
    				stat(d->d_name, &dotdot);
    /*printf ("%.14s dev=%d ino=%d\n", d->d_name, (int) dotdot.st_dev, (int) dotdot.st_ino);*/
    			} while (dotdot.st_ino != dot.st_ino ||
    				dotdot.st_dev != dot.st_dev);
    		}
    		closedir(dir);
    		cat(d->d_name);
    /*path[off] = 0; printf ("pwd %s\n", path);*/
    	}
    	write(1, "/", 1);
    	if (off < 0)
    		off = 0;
    	path[off] = '\n';
    	write(1, path, off + 1);
    	return 0;
    }

    какой pwd )))

    j123123, 09 Мая 2021

    Комментарии (15)
  3. Си / Говнокод #27393

    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
    //glsl vertex shader
    attribute float mass;
    uniform vec3 center;
    
    #define RAD 10.0
    const float D = RAD * 2.0;
    
    ///////////////////THIS///////////////////
    float repeat(float x, float z) {
      float dx = distance(x, z);
      while(dx > RAD) {
        if (x > z) {
          x -= D;
        } else {
          x += D;
        }
        dx = distance(x, z);
      }
      return x;
    }
    ///////////////////////////////////////////
    
    vec3 repeat(vec3 x, vec3 y) {
      return vec3(dr(x.x, y.x), dr(x.y, y.y), dr(x.z, y.z));
    }
    
    void main() {
      vec3 pos = position;
      pos.z += time;
      pos = repeat(pos, center);
      
      vec4 mvPosition = modelViewMatrix * vec4(pos, 1.0);
      gl_PointSize = 70.0 * mass;
      gl_Position = projectionMatrix * mvPosition;
    }

    По сути функция repeat должна повторять текстуру (как background-repeat: repeat в css) в зависимости от положения точки центра, короче: двигается центр, двигается и текстура за ним. Мне даже ума не хватает описать это, поэтому формулу сам искал, хватило ума только на это говно. Спустя несколько недель додумался до следующего говна, уже без цикла:
    float repeat(float x, float z) {
    float mp = x > z ? -1.0 : 1.0;
    z += RAD * mp;
    float dx = distance(x, z);
    float n = floor(dx / D) * D;
    x += n*mp;
    return x;
    }
    Тяжело не знать математики. Может местные шизы подскажут как называется такое поведение и как нормальную формулу?

    sobakapavlova, 06 Мая 2021

    Комментарии (15)
  4. Си / Говнокод #27370

    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
    #define l '!'
    main(int I){int _[]={[0]=01740,[10]=010[_
    ]>>4,[010]=0xf00,[0x10]=0,[011]=_[7]/0x10
    ,[013]=_[0011]/16,[13]=7,[014]=016,[14]=_
    [7]>>12,[15]=001,[01]=0x03fFC,[2]=0x781F,
    [3]=0x6E003,[4]=49152,[5]=_[04],['\a']=_[
    6]>>1,['\''-l]=074000,};for(I=0;I<l*17-l/
    2;++I,putchar((I%l<l/2)&&(_[I/(l)]&1<<15-
    (I%l))?0x23:(I%l>(l/2))&&((I/(l))[_]&1<<(
    15-((l-1)-(I%l))))?l|2:I*2==(((l/2)*_[13]
    +3)*4)>>!!1?(((!l)["Fuck you!"])*(_[0x0f]
    ))>>1:!(I^((l/2)*9+004))?042+1:I-(l/2)*30
    +02==!l?0x24^13[_]:!((I|((l/2)*32-1))^I)?
    35:I+(l/2)*34==I<<1?l+_[14]-(_[4]/5[_]):!
    !!!I*040),(I+1)%l==0?putchar(012):l+!l);}

    Я покакал

    Narsharab, 22 Апреля 2021

    Комментарии (0)
  5. Си / Говнокод #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)
  6. Си / Говнокод #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)
  7. Си / Говнокод #27302

    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
    if (LD3_state == 0 || LD2_state == 0 || LD1_state == 0)
    {
        GPIO_SetBits(GPIOB, LED1); //RED ON
        LD_Status = NO_LOCK;
    }
    else
    {
        LD_Status = LOCK_OK;
    }
    
    if (LD4_state == 0 && LD_Status == LOCK_OK)
    {
        GPIO_SetBits(GPIOB, LED1); //RED ON
    }
    else
    {
        GPIO_ResetBits(GPIOB, LED1); //RED OF
    }
    
    if (LD4_state == 0 && LD_Status == LOCK_OK)
    {
        GPIO_ResetBits(GPIOB, LED1); //RED OFF
    }
    
    /* Ну можно же было сделать по-человечески, а? */
    /* Эквивалентный код: */
    
    LD_Status = LD1_state && LD2_state && LD3_state && LD4_state;
    if (LD_Status)
    {
        GPIO_ResetBits(GPIOB, LED1); //RED OFF
    }
    else
    {
        GPIO_SetBits(GPIOB, LED1); //RED ON
    }

    Как же я ненавижу чье-то легаси...

    viteo, 18 Марта 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. Си / Говнокод #27292

    +2

    1. 1
    2. 2
    3. 3
    unsigned three = 1;
    unsigned five = 5;
    unsigned seven = 7;

    https://github.com/torvalds/linux/blob/d158fc7f36a25e19791d25a55da5623399a2644f/fs/ext4/resize.c#L698

    MAKAKA, 12 Марта 2021

    Комментарии (210)
  10. Си / Говнокод #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)