1. C++ / Говнокод #27289

    0

    1. 1
    Как крестьяне говна поели

    This function is defined as the RtlSecureZeroMemory function (see WinBase.h). The implementation of RtlSecureZeroMemory is provided inline and can be used on any version of Windows (see WinNT.h.)

    Use this function instead of ZeroMemory when you want to ensure that your data will be overwritten promptly, as some C++ compilers can optimize a call to ZeroMemory by removing it entirely.

    Petro-san, 10 Марта 2021

    Комментарии (80)
  2. JavaScript / Говнокод #27288

    +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
    function main() {
        print("Hello", 1, false, true, parseInt("01"), parseFloat("00.1"));
    }
    
    // ASM
    ; ModuleID = 'LLVMDialectModule'
    source_filename = "LLVMDialectModule"
    target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
    target triple = "x86_64-pc-windows-msvc"
    
    @__true__ = internal constant [5 x i8] c"true\00"
    @__false__ = internal constant [6 x i8] c"false\00"
    @frmt_9481649210695450612 = internal constant [19 x i8] c"%s %d %s %s %d %f\0A\00"
    @s_3144841719139014728 = internal constant [5 x i8] c"00.1\00"
    @s_12300967985959445949 = internal constant [3 x i8] c"01\00"
    @s_1772061916968062023 = internal constant [6 x i8] c"Hello\00"
    
    declare i8* @malloc(i64)
    
    declare void @free(i8*)
    
    declare i32 @printf(i8*, ...)
    
    declare float @atof(i8*)
    
    declare i32 @atoi(i8*)
    
    define void @main() !dbg !3 {
      %1 = call i32 @atoi(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @s_12300967985959445949, i64 0, i64 0)), !dbg !7
      %2 = call float @atof(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @s_3144841719139014728, i64 0, i64 0)), !dbg !9
      %3 = fpext float %2 to double, !dbg !10
      %4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @frmt_9481649210695450612, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @s_1772061916968062023, i64 0, i64 0), i32 1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @__false__, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @__true__, i64 0, i64 0), i32 %1, double %3), !dbg !10
      br label %5, !dbg !11
    
    5:                                                ; preds = %0
      ret void, !dbg !11
    }
    
    !llvm.dbg.cu = !{!0}
    !llvm.module.flags = !{!2}

    Продолжение писания уе..(зачеркнуто) супер компилятора с TypeScript (JavaScript) в нативный код.

    как обычно компилим просто

    set LIBPATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\SDK\ScopeCppSDK\vc 15\VC\lib
    set SDKPATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\SDK\ScopeCppSDK\vc 15\SDK\lib
    tsc.exe --emit=llvm C:\temp\1.ts 2>1.ll
    llc.exe --filetype=obj -o=out.o 1.ll
    lld.exe -flavor link out.o "%LIBPATH%\libcmt.lib" "%LIBPATH%\libvcruntime.lib" "%SDKPATH%\kernel32.lib" "%SDKPATH%\libucrt.lib" "%SDKPATH%\uuid.lib"

    получаетм Ехе и грузим его. и результат

    =====================================
    и выполнение

    C:\>out.exe
    Hello 1 false true 1 0.100000

    ASD_77, 09 Марта 2021

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

    −5

    1. 1
    С праздником, девочки! ʕ ᵔᴥᵔ ʔ

    moderat0r, 08 Марта 2021

    Комментарии (96)
  4. Си / Говнокод #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)
  5. Куча / Говнокод #27284

    0

    1. 1
    IT Оффтоп #82

    #52: https://govnokod.ru/26817 https://govnokod.xyz/_26817
    #53: https://govnokod.ru/26833 https://govnokod.xyz/_26833
    #54: https://govnokod.ru/26840 https://govnokod.xyz/_26840
    #55: https://govnokod.ru/26844 https://govnokod.xyz/_26844
    #56: https://govnokod.ru/26862 https://govnokod.xyz/_26862
    #57: https://govnokod.ru/26890 https://govnokod.xyz/_26890
    #58: https://govnokod.ru/26916 https://govnokod.xyz/_26916
    #59: https://govnokod.ru/26934 https://govnokod.xyz/_26934
    #60: https://govnokod.ru/26949 https://govnokod.xyz/_26949
    #61: https://govnokod.ru/26980 https://govnokod.xyz/_26980
    #62: https://govnokod.ru/26999 https://govnokod.xyz/_26999
    #63: https://govnokod.ru/27004 https://govnokod.xyz/_27004
    #64: https://govnokod.ru/27020 https://govnokod.xyz/_27020
    #65: https://govnokod.ru/27027 https://govnokod.xyz/_27027
    #66: https://govnokod.ru/27040 https://govnokod.xyz/_27040
    #67: https://govnokod.ru/27049 https://govnokod.xyz/_27049
    #68: https://govnokod.ru/27061 https://govnokod.xyz/_27061
    #69: https://govnokod.ru/27071 https://govnokod.xyz/_27071
    #70: https://govnokod.ru/27097 https://govnokod.xyz/_27097
    #71: https://govnokod.ru/27115 https://govnokod.xyz/_27115
    #72: https://govnokod.ru/27120 https://govnokod.xyz/_27120
    #73: https://govnokod.ru/27136 https://govnokod.xyz/_27136
    #74: https://govnokod.ru/27160 https://govnokod.xyz/_27160
    #75: https://govnokod.ru/27166 https://govnokod.xyz/_27166
    #76: https://govnokod.ru/27168 https://govnokod.xyz/_27168
    #77: https://govnokod.ru/27186 https://govnokod.xyz/_27186
    #78: https://govnokod.ru/27219 https://govnokod.xyz/_27219
    #79: https://govnokod.ru/27254 https://govnokod.xyz/_27254
    #80: https://govnokod.ru/27270 https://govnokod.xyz/_27270
    #81: https://govnokod.ru/27280 https://govnokod.xyz/_27280

    nepeKamHblu_nemyx, 06 Марта 2021

    Комментарии (2018)
  6. C++ / Говнокод #27283

    +2

    1. 1
    2. 2
    3. 3
    int i = 42;
    foo(i); //не компилируется
    foo(static_cast<int>(i)); //компилируется

    raMagPuJI, 05 Марта 2021

    Комментарии (136)
  7. Куча / Говнокод #27282

    +1

    1. 1
    Просто оффтоп #16

    #1: https://govnokod.ru/20162 https://govnokod.xyz/_20162
    #2: https://govnokod.ru/25329 https://govnokod.xyz/_25329
    #3: https://govnokod.ru/25415 https://govnokod.xyz/_25415
    #4: (vanished) https://govnokod.xyz/_25472
    #5: https://govnokod.ru/25693 https://govnokod.xyz/_25693
    #6: (vanished) https://govnokod.xyz/_26649
    #7: https://govnokod.ru/26672 https://govnokod.xyz/_26672
    #8: https://govnokod.ru/26924 https://govnokod.xyz/_26924
    #9: https://govnokod.ru/27072 https://govnokod.xyz/_27072
    #10: https://govnokod.ru/27086 https://govnokod.xyz/_27086
    #11: https://govnokod.ru/27122 https://govnokod.xyz/_27122
    #12: https://govnokod.ru/27153 https://govnokod.xyz/_27153
    #13: https://govnokod.ru/27159 https://govnokod.xyz/_27159
    #14: https://govnokod.ru/27200 https://govnokod.xyz/_27200
    #15: https://govnokod.ru/27237 https://govnokod.xyz/_27237

    nepeKamHblu_nemyx, 03 Марта 2021

    Комментарии (3504)
  8. Куча / Говнокод #27281

    +5

    1. 1
    2. 2
    3. 3
    inkanus-gray
    gost
    syoma

    Вернитесь.

    OCETuHCKuu_nemyx, 03 Марта 2021

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

    0

    1. 1
    IT Оффтоп #81

    #51: https://govnokod.ru/26809 https://govnokod.xyz/_26809
    #52: https://govnokod.ru/26817 https://govnokod.xyz/_26817
    #53: https://govnokod.ru/26833 https://govnokod.xyz/_26833
    #54: https://govnokod.ru/26840 https://govnokod.xyz/_26840
    #55: https://govnokod.ru/26844 https://govnokod.xyz/_26844
    #56: https://govnokod.ru/26862 https://govnokod.xyz/_26862
    #57: https://govnokod.ru/26890 https://govnokod.xyz/_26890
    #58: https://govnokod.ru/26916 https://govnokod.xyz/_26916
    #59: https://govnokod.ru/26934 https://govnokod.xyz/_26934
    #60: https://govnokod.ru/26949 https://govnokod.xyz/_26949
    #61: https://govnokod.ru/26980 https://govnokod.xyz/_26980
    #62: https://govnokod.ru/26999 https://govnokod.xyz/_26999
    #63: https://govnokod.ru/27004 https://govnokod.xyz/_27004
    #64: https://govnokod.ru/27020 https://govnokod.xyz/_27020
    #65: https://govnokod.ru/27027 https://govnokod.xyz/_27027
    #66: https://govnokod.ru/27040 https://govnokod.xyz/_27040
    #67: https://govnokod.ru/27049 https://govnokod.xyz/_27049
    #68: https://govnokod.ru/27061 https://govnokod.xyz/_27061
    #69: https://govnokod.ru/27071 https://govnokod.xyz/_27071
    #70: https://govnokod.ru/27097 https://govnokod.xyz/_27097
    #71: https://govnokod.ru/27115 https://govnokod.xyz/_27115
    #72: https://govnokod.ru/27120 https://govnokod.xyz/_27120
    #73: https://govnokod.ru/27136 https://govnokod.xyz/_27136
    #74: https://govnokod.ru/27160 https://govnokod.xyz/_27160
    #75: https://govnokod.ru/27166 https://govnokod.xyz/_27166
    #76: https://govnokod.ru/27168 https://govnokod.xyz/_27168
    #77: https://govnokod.ru/27186 https://govnokod.xyz/_27186
    #78: https://govnokod.ru/27219 https://govnokod.xyz/_27219
    #79: https://govnokod.ru/27254 https://govnokod.xyz/_27254
    #80: https://govnokod.ru/27270 https://govnokod.xyz/_27270

    nepeKamHblu_nemyx, 03 Марта 2021

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

    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
    -define(snk_int_match_arg(ARG),
            fun(__SnkArg) ->
                case __SnkArg of
                  ARG -> true;
                  _   -> false
                end
            end).
    
    -define(snk_int_match_arg2(M1, M2, GUARD),
            fun(__SnkArg1, __SnkArg2) ->
                case __SnkArg1 of
                  M1 ->
                    case __SnkArg2 of
                      M2 -> (GUARD);
                      _  -> false
                    end;
                  _ -> false
                end
            end).
    
    
    ....
    
    -spec maybe_delay(map()) -> ok.
    maybe_delay(Event) ->
      [{_, Delays}] = ets:lookup(?DELAY_TAB, ?SINGLETON_KEY),
      [snabbkaffe_collector:block_until( fun(WU) -> ContP(Event, WU) end
                                       , infinity
                                       , infinity
                                       )
       || #delay{ continue_predicate = ContP
                , delay_predicate    = DelayP
                } <- Delays, DelayP(Event)],
      ok.

    Наметушил.

    CHayT, 02 Марта 2021

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