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

    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
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    int IsEven(long long int number){
    	if (number == 0) return 0; 
    	long long int loc_num = 0;
    	update: 
    	
    	if (number == loc_num+1) {return 1;
    	} else if (number == (loc_num+1)*(-1)) { return 1;
    	} else {
    		if (number == loc_num+2) {return 0;
    		} else if (number == (loc_num+2)*(-1)) { return 0;
    		} else {
    			if (number == loc_num+3) {return 1;
    			} else if (number == (loc_num+3)*(-1)) { return 1;
    			} else {
    				if (number == loc_num+4) {return 0;
    				} else if (number == (loc_num+4)*(-1)) { return 0;
    				} else {
    					if (number == loc_num+5) {return 1;
    					} else if (number == (loc_num+5)*(-1)) { return 1;
    					} else {
    						if (number == loc_num+6) {return 0;
    						} else if (number == (loc_num+6)*(-1)) { return 0;
    						} else {
    							if (number == loc_num+7) {return 1;
    							} else if (number == (loc_num+7)*(-1)) { return 1;
    							} else {
    								if (number == loc_num+8) {return 0;
    								} else if (number == (loc_num+8)*(-1)) { return 0;
    								} else {
    									if (number == loc_num+9) {return 1;
    									} else if (number == (loc_num+9)*(-1)) { return 1;
    									} else {
    										if (number == loc_num+10) {return 0;
    										} else if (number == (loc_num+10)*(-1)) { return 0;
    										} else {
    												loc_num+=10; 
    												goto update;
    											}
    										}
    									}
    								}
    							}
    						}
    					}
    				}
    			}
    		}
    	}

    TurboLyudoed, 14 Ноября 2024

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

    0

    1. 1
    Админ - уебок, хранивший пароли открытым текстом

    Чекайте свои мыла в утечках, ебланы

    aleksusklim, 26 Октября 2024

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

    −2

    1. 1
    Удалите мой аккаунт

    Удалите мой аккаунт

    aleksusklim, 25 Октября 2024

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

    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
    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
    // https://github.com/micropython/micropython/blob/1b89c503db690967d50699abe0bfa942f6f6b15e/ports/qemu/mcu/rv32/interrupts.c#L131
    
    const char *lookup_cause(uint32_t mcause) {
        if (mcause & 0x80000000) {
            switch (mcause & 0x7FFFFFFF) {
                case 1:
                    return exception_causes[1];
                case 3:
                    return exception_causes[2];
                case 5:
                    return exception_causes[3];
                case 7:
                    return exception_causes[4];
                case 9:
                    return exception_causes[5];
                case 11:
                    return exception_causes[6];
                default:
                    return (mcause >= 16) ?
                           exception_causes[7] :
                           exception_causes[0];
            }
        }
    
        switch (mcause) {
            case 0:
                return exception_causes[8];
            case 1:
                return exception_causes[9];
            case 2:
                return exception_causes[10];
            case 3:
                return exception_causes[11];
            case 4:
                return exception_causes[12];
            case 5:
                return exception_causes[13];
            case 6:
                return exception_causes[14];
            case 7:
                return exception_causes[15];
            case 8:
                return exception_causes[16];
            case 9:
                return exception_causes[17];
            case 11:
                return exception_causes[18];
            case 12:
                return exception_causes[19];
            case 13:
                return exception_causes[20];
            case 15:
                return exception_causes[21];
            default: {
                if ((mcause >= 24 && mcause <= 31) ||
                    (mcause >= 48 && mcause <= 63)) {
                    return exception_causes[22];
                }
    
                return exception_causes[0];
            }
        }
    }

    Микропитухон

    j123123, 18 Октября 2024

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

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    int iseven(long long int number)
    {
    	struct Num {
    		unsigned int x:1;
    		unsigned int y:31;
    		unsigned int z:32;
    	} num = (*(struct Num*)(&number));
    	return num.x; //Если результат 1, то нечётное.
    }

    Функция определения чётности числа посредством возврата младшего бита.

    TurboLyudoed, 11 Октября 2024

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

    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
    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
    longlong ** FUN_14000e5a0(longlong **param_1,LPCWSTR param_2,int param_3,uint param_4)
    
    {
      uint uVar1;
      longlong **pplVar2;
      longlong **hFile;
      longlong *plVar3;
      longlong **pplVar4;
      DWORD DVar5;
      LONG local_38;
      undefined4 uStack_34;
      
      pplVar4 = (longlong **)0x0;
      uVar1 = param_4 & 0x1f;
      if ((param_4 & 0x1f) == 0) {
        uVar1 = 2;
      }
      pplVar2 = FUN_1400119f8(DAT_1400213a0,(longlong)param_1);
      if (pplVar2 == (longlong **)0x0) {
        return (longlong **)0x0;
      }
      if (param_3 == 1) {
        DVar5 = (DWORD)((param_4 >> 0x11 & 1) != 0);
        if ((param_4 >> 0x12 & 1) != 0) {
          DVar5 = 7;
        }
        hFile = (longlong **)
                CreateFileW(param_2,0x80000000,DVar5,(LPSECURITY_ATTRIBUTES)0x0,3,0x80,(HANDLE)0x0);
    LAB_14000e70c:
        if (hFile == (longlong **)0xffffffffffffffff) goto LAB_14000e7ad;
      }
      else {
        if (param_3 == 2) {
          DVar5 = (DWORD)((param_4 >> 0x11 & 1) != 0);
          if ((param_4 >> 0x12 & 1) != 0) {
            DVar5 = 7;
          }
          hFile = (longlong **)
                  CreateFileW(param_2,0xc0000000,DVar5,(LPSECURITY_ATTRIBUTES)0x0,4,0x80,(HANDLE)0x0);
          goto LAB_14000e70c;
        }
        if (param_3 != 3) {
          hFile = (longlong **)CONCAT44(uStack_34,local_38);
          goto LAB_14000e70c;
        }
        DVar5 = (DWORD)((param_4 >> 0x11 & 1) != 0);
        if ((param_4 >> 0x12 & 1) != 0) {
          DVar5 = 7;
        }
        hFile = (longlong **)
                CreateFileW(param_2,0xc0000000,DVar5,(LPSECURITY_ATTRIBUTES)0x0,2,0x80,(HANDLE)0x0);
        if (hFile == (longlong **)0xffffffffffffffff) {
          hFile = (longlong **)
                  CreateFileW(param_2,0x40000000,DVar5,(LPSECURITY_ATTRIBUTES)0x0,5,0,(HANDLE)0x0);
          goto LAB_14000e70c;
        }
      }
      if (hFile != (longlong **)0x0) {
        if ((DAT_14001f140 == 0) || ((param_4 >> 0x13 & 1) != 0)) {
          pplVar2[1] = (longlong *)0x0;
        }
        else {
          plVar3 = (longlong *)HeapAlloc(DAT_1400204cc,0,(longlong)DAT_14001f140);
          pplVar2[1] = plVar3;
        }
        *pplVar2 = (longlong *)hFile;
        *(int *)(pplVar2 + 2) = DAT_14001f140;
        *(undefined4 *)((longlong)pplVar2 + 0x14) = 0;
        *(uint *)(pplVar2 + 4) = uVar1;
        *(uint *)((longlong)pplVar2 + 0x24) = (uint)(param_3 == 1);
        *(undefined4 *)((longlong)pplVar2 + 0x1c) = 1;
        if ((param_3 == 2) && ((param_4 >> 0x14 & 1) != 0)) {
          local_38 = 0;
          SetFilePointer(hFile,0,&local_38,2);
        }
        pplVar4 = hFile;
        if (param_1 == (longlong **)0xffffffffffffffff) {
          pplVar4 = pplVar2;
        }
        if (pplVar4 != (longlong **)0x0) {
          return pplVar4;
        }
      }
    LAB_14000e7ad:
      if (param_1 == (longlong **)0xffffffffffffffff) {
        param_1 = pplVar2;
      }
      FUN_14001192c(DAT_1400213a0,(longlong)param_1);
      return pplVar4;
    }

    BelCodeMonkey, 06 Октября 2024

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

    0

    1. 1
    char main[] = { 0xf0, 0x0f, 0xc7, 0xc8 };

    DartPower, 10 Сентября 2024

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

    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
    /*
     Brainfuck-C ( http://github.com/kgabis/brainfuck-c )
     Copyright (c) 2012 Krzysztof Gabis
     
     Permission is hereby granted, free of charge, to any person obtaining a copy
     of this software and associated documentation files (the "Software"), to deal
     in the Software without restriction, including without limitation the rights
     to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     copies of the Software, and to permit persons to whom the Software is
     furnished to do so, subject to the following conditions:
     
     The above copyright notice and this permission notice shall be included in
     all copies or substantial portions of the Software.
     
     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     THE SOFTWARE.
    */
    
    #include <stdio.h>
    
    #define OP_END          0
    #define OP_INC_DP       1
    #define OP_DEC_DP       2
    #define OP_INC_VAL      3
    #define OP_DEC_VAL      4
    #define OP_OUT          5
    #define OP_IN           6
    #define OP_JMP_FWD      7
    #define OP_JMP_BCK      8
    
    #define SUCCESS         0
    #define FAILURE         1
    
    #define PROGRAM_SIZE    4096
    #define STACK_SIZE      512
    #define DATA_SIZE       65535
    
    #define STACK_PUSH(A)   (STACK[SP++] = A)
    #define STACK_POP()     (STACK[--SP])
    #define STACK_EMPTY()   (SP == 0)
    #define STACK_FULL()    (SP == STACK_SIZE)
    
    struct instruction_t {
        unsigned short operator;
        unsigned short operand;
    };
    
    static struct instruction_t PROGRAM[PROGRAM_SIZE];
    static unsigned short STACK[STACK_SIZE];
    static unsigned int SP = 0;
    
    int compile_bf(FILE* fp) {
        unsigned short pc = 0, jmp_pc;
        int c;
        while ((c = getc(fp)) != EOF && pc < PROGRAM_SIZE) {
            switch (c) {
                case '>': PROGRAM[pc].operator = OP_INC_DP; break;
                case '<': PROGRAM[pc].operator = OP_DEC_DP; break;
                case '+': PROGRAM[pc].operator = OP_INC_VAL; break;
                case '-': PROGRAM[pc].operator = OP_DEC_VAL; break;
                case '.': PROGRAM[pc].operator = OP_OUT; break;
                case ',': PROGRAM[pc].operator = OP_IN; break;
                case '[':
                    PROGRAM[pc].operator = OP_JMP_FWD;
                    if (STACK_FULL()) {
                        return FAILURE;
                    }
                    STACK_PUSH(pc);
                    break;
                case ']':
                    if (STACK_EMPTY()) {
                        return FAILURE;
                    }
                    jmp_pc = STACK_POP();
                    PROGRAM[pc].operator =  OP_JMP_BCK;
                    PROGRAM[pc].operand = jmp_pc;
                    PROGRAM[jmp_pc].operand = pc;
                    break;
                default: pc--; break;
            }
            pc++;
        }
        if (!STACK_EMPTY() || pc == PROGRAM_SIZE) {
            return FAILURE;
        }
        PROGRAM[pc].operator = OP_END;
        return SUCCESS;
    }
    
    int execute_bf() {
        unsigned short data[DATA_SIZE], pc = 0;
        unsigned int ptr = DATA_SIZE;
        while (--ptr) { data[ptr] = 0; }
        while (PROGRAM[pc].operator != OP_END && ptr < DATA_SIZE) {
    // (...)

    Интерпретатор Brainfuck.

    Полный код можно посмотреть тута:
    https://github.com/kgabis/brainfuck-c/blob/master/brainfuck.c

    kNode, 02 Июля 2024

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

    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
    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
    98. 98
    99. 99
    template <typename Key, typename Value, size_t TblPower = 2>
    struct HashMap {
    	struct Node
    	{
    		Key k;
    		Value v;
    		Node *n;
    
    		Node(const Key &key, const Value &value) :
    			k(key), v(value), n(NULL) {}
    
    		Node(const Key &key) :
    			k(key), v(), n(NULL) {}
    	};
    
    	constexpr static size_t TblSize = 1U << TblPower;
    	Node *table[TblSize] = {nullptr};
    
    	HashMap() {
    	}
    
    	~HashMap() {
    		for(size_t i = 0; i < TblSize; i++)
    		{
    			Node *entry = table[i];
    			while(entry)
    			{
    				Node *prev = entry;
    				entry = entry->n;
    				delete prev;
    			}
    			table[i] = NULL;
    		}
    	}
    
    	size_t HashFunc(const Key &key) const
    	{
    		/// TODO: string hash?
    		// handle hash: handle pointers usually aligned
    		return (((size_t) key) >> 8)  & (TblSize - 1);
    	}
    
    	// just in case: check existance or constant access
    	forceinline Value *GetPtr(const Key &key) const
    	{
    		size_t hashValue = HashFunc(key);
    		Node *entry = table[hashValue];
    		while(likely(entry))
    		{
    			if(entry->k == key)
    				return &entry->v;
    			entry = entry->n;
    		}
    		return nullptr;
    	}
    
    	Value &operator [] (const Key &key)
    	{
    		return GetOrAllocate(key);
    	}
    
    #define HASHFIND(key) \
    		size_t hashValue = HashFunc(key); \
    		Node *prev = NULL; \
    		Node *entry = table[hashValue]; \
    	\
    		while(entry && entry->k != key) \
    		{ \
    			prev = entry; \
    			entry = entry->n; \
    		}
    
    	Node * noinline _Allocate(Key key, size_t hashValue, Node *prev, Node *entry)
    	{
    		entry = new Node(key);
    		if(unlikely(!entry))
    		{
    			static Node error(key);
    			return &error;
    		}
    
    		if(prev == NULL)
    			table[hashValue] = entry;
    		else
    			prev->n = entry;
    		return entry;
    	}
    
    	Value& GetOrAllocate(const Key &key)
    	{
    		HASHFIND(key);
    
    		if(unlikely(!entry))
    			entry = _Allocate(key,hashValue, prev, entry);
    
    		return entry->v;
    	}
    // тут был ещё один метод, но в говнокод не влез
    }

    когда СГОРЕЛО от STL

    mittorn, 04 Марта 2024

    Комментарии (0)
  10. Си / Говнокод #28922

    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
    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
    struct HashArrayMap {
    
    	struct Node
    	{
    		Key k;
    		Value v;
    
    		Node(const Key &key, const Value &value) :
    			k(key), v(value){}
    		Node(const Key &key) :
    			k(key), v(){}
    	};
    
    	constexpr static size_t TblSize = 1U << TblPower;
    	GrowArray<Node> table[TblSize];
    
    	HashArrayMap() {
    	}
    
    	~HashArrayMap() {
    	}
    
    	size_t HashFunc(const Key &key) const
    	{
    		/// TODO: string hash?
    		// handle hash: handle pointers usually aligned
    		return (((size_t) key) >> 8)  & (TblSize - 1);
    	}
    
    	// just in case: check existance or constant access
    	Value *GetPtr(const Key &key) const
    	{
    		size_t hashValue = HashFunc(key);
    		const GrowArray<Node> &entry = table[hashValue];
    		for(int i = 0; i < entry.count; i++)
    		{
    			if(entry[i].k == key)
    				return &entry[i].v;
    		}
    		return nullptr;
    	}
    
    	Value &operator [] (const Key &key)
    	{
    		return GetOrAllocate(key);
    	}
    
    #define HASHFIND(key) \
    	GrowArray<Node> &entry = table[HashFunc(key)]; \
    	int i; \
    	for(i = 0; i < entry.count; i++) \
    		if( entry[i].k == key ) \
    			break;
    
    	Value& GetOrAllocate(const Key &key)
    	{
    		HASHFIND(key);
    		if(i == entry.count )
    			entry.Add(Node(key));
    
    		return entry[i].v;
    	}
    
    	bool Remove(const Key &key)
    	{
    		HASHFIND(key);
    		if(i != entry.count)
    		{
    			entry.RemoveAt(i);
    			return true;
    		}
    		return false;
    	}
    #undef HASHFIND
    };

    когда СГОРЕЛО от STL

    mittorn, 04 Марта 2024

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