Download examples.json from radix16/pramen-498m: direct link, hf CLI and curl.
- Browser
- Download file 57.5 kB
-
https://huggingface.co/radix16/pramen-498m/resolve/main/examples.json
- Command line
-
hf download hf://radix16/pramen-498m/examples.json
-
curl -L -o examples.json https://huggingface.co/radix16/pramen-498m/resolve/main/examples.json
57.5 kB
| { | |
| "step": 5000, | |
| "created": "2026-11-18 15:38", | |
| "summary": { | |
| "msvc-x64-Od": { | |
| "pass": 8, | |
| "n": 12 | |
| }, | |
| "msvc-x64-O2": { | |
| "pass": 9, | |
| "n": 12 | |
| }, | |
| "msvc-x86-Od": { | |
| "pass": 10, | |
| "n": 12 | |
| }, | |
| "msvc-x86-O2": { | |
| "pass": 9, | |
| "n": 12 | |
| }, | |
| "dos16-small-od": { | |
| "pass": 11, | |
| "n": 12 | |
| }, | |
| "dos16-large-ox": { | |
| "pass": 9, | |
| "n": 12 | |
| } | |
| }, | |
| "examples": [ | |
| { | |
| "id": "count_words", | |
| "title": "Word count", | |
| "desc": "walking a string with a state flag", | |
| "source": "int count_words(const char *s) {\n int n = 0, in_word = 0;\n for (; *s; s++) {\n if (*s == ' ') in_word = 0;\n else if (!in_word) { in_word = 1; n++; }\n }\n return n;\n}", | |
| "variants": { | |
| "msvc-x64-Od": { | |
| "asm": "MOV qword ptr [RSP + 8],RCX\nSUB RSP,0x18\nMOV dword ptr [RSP + 4],0\nMOV dword ptr [RSP],0\nJMP LAB_1\nLAB_5:\nMOV RAX,qword ptr [RSP + 0x20]\nINC RAX\nMOV qword ptr [RSP + 0x20],RAX\nLAB_1:\nMOV RAX,qword ptr [RSP + 0x20]\nMOVSX EAX,byte ptr [RAX]\nTEST EAX,EAX\nJE LAB_2\nMOV RAX,qword ptr [RSP + 0x20]\nMOVSX EAX,byte ptr [RAX]\nCMP EAX,0x20\nJNE LAB_3\nMOV dword ptr [RSP],0\nJMP LAB_4\nLAB_3:\nCMP dword ptr [RSP],0\nJNE LAB_4\nMOV dword ptr [RSP],1\nMOV EAX,dword ptr [RSP + 4]\nINC EAX\nMOV dword ptr [RSP + 4],EAX\nLAB_4:\nJMP LAB_5\nLAB_2:\nMOV EAX,dword ptr [RSP + 4]\nADD RSP,0x18\nRET", | |
| "c": "int countspaces(const char *s)\n{\n int count = 0;\n bool space = false;\n\n for (; *s != '\\0'; s++) {\n if (*s == ' ') {\n space = false;\n } else if (space == false) {\n space = true;\n count++;\n }\n }\n\n return count;\n}", | |
| "status": "pass", | |
| "seconds": 4.06 | |
| }, | |
| "msvc-x64-O2": { | |
| "asm": "MOVZX EDX,byte ptr [RCX]\nXOR R8D,R8D\nXOR EAX,EAX\nTEST DL,DL\nJE LAB_1\nNOP dword ptr [RAX]\nLAB_4:\nCMP DL,0x20\nJNE LAB_2\nXOR EAX,EAX\nJMP LAB_3\nLAB_2:\nTEST EAX,EAX\nJNE LAB_3\nMOV EAX,1\nINC R8D\nLAB_3:\nMOVZX EDX,byte ptr [RCX + 1]\nINC RCX\nTEST DL,DL\nJNE LAB_4\nMOV EAX,R8D\nLAB_1:\nRET", | |
| "c": "int countspaces(const char *s)\n{\n int count = 0;\n int state = 0;\n while (*s) {\n if (*s == ' ') {\n state = 0;\n } else if (state == 0) {\n state = 1;\n count++;\n }\n s++;\n }\n return count;\n}", | |
| "status": "pass", | |
| "seconds": 1.61 | |
| }, | |
| "msvc-x86-Od": { | |
| "asm": "PUSH EBP\nMOV EBP,ESP\nSUB ESP,8\nMOV dword ptr [EBP + -8],0\nMOV dword ptr [EBP + -4],0\nJMP LAB_1\nLAB_5:\nMOV EAX,dword ptr [EBP + 8]\nADD EAX,1\nMOV dword ptr [EBP + 8],EAX\nLAB_1:\nMOV ECX,dword ptr [EBP + 8]\nMOVSX EDX,byte ptr [ECX]\nTEST EDX,EDX\nJE LAB_2\nMOV EAX,dword ptr [EBP + 8]\nMOVSX ECX,byte ptr [EAX]\nCMP ECX,0x20\nJNE LAB_3\nMOV dword ptr [EBP + -4],0\nJMP LAB_4\nLAB_3:\nCMP dword ptr [EBP + -4],0\nJNE LAB_4\nMOV dword ptr [EBP + -4],1\nMOV EDX,dword ptr [EBP + -8]\nADD EDX,1\nMOV dword ptr [EBP + -8],EDX\nLAB_4:\nJMP LAB_5\nLAB_2:\nMOV EAX,dword ptr [EBP + -8]\nMOV ESP,EBP\nPOP EBP\nRET", | |
| "c": "int countspaces(const char *s)\n{\n int count = 0;\n bool space = false;\n\n for (; *s != '\\0'; s++) {\n if (*s == ' ') {\n space = false;\n } else if (space == false) {\n space = true;\n count++;\n }\n }\n\n return count;\n}", | |
| "status": "pass", | |
| "seconds": 1.69 | |
| }, | |
| "msvc-x86-O2": { | |
| "asm": "PUSH ESI\nMOV ESI,dword ptr [ESP + 8]\nXOR EDX,EDX\nXOR EAX,EAX\nMOV CL,byte ptr [ESI]\nTEST CL,CL\nJE LAB_1\nNOP\nLAB_4:\nCMP CL,0x20\nJNE LAB_2\nXOR EAX,EAX\nJMP LAB_3\nLAB_2:\nTEST EAX,EAX\nJNE LAB_3\nMOV EAX,1\nINC EDX\nLAB_3:\nMOV CL,byte ptr [ESI + 1]\nINC ESI\nTEST CL,CL\nJNE LAB_4\nMOV EAX,EDX\nLAB_1:\nPOP ESI\nRET", | |
| "c": "int countspaces(const char *s)\n{\n int count = 0;\n int space = 0;\n while (*s) {\n if (*s == ' ') {\n space = 0;\n } else if (space == 0) {\n space = 1;\n ++count;\n }\n ++s;\n }\n return count;\n}", | |
| "status": "pass", | |
| "seconds": 1.66 | |
| }, | |
| "dos16-small-od": { | |
| "asm": "PUSH SI\nPUSH DI\nPUSH BP\nMOV BP,SP\nSUB SP,6\nMOV word ptr [BP + + -4],0\nMOV word ptr [BP + + -2],0\nLAB_1:\nMOV BX,word ptr [BP + 8]\nCMP byte ptr [BX],0\nJE LAB_2\nJMP LAB_3\nLAB_2:\nJMP LAB_4\nLAB_3:\nMOV BX,word ptr [BP + 8]\nCMP byte ptr [BX],0x20\nJNE LAB_5\nMOV word ptr [BP + + -2],0\nJMP LAB_6\nLAB_5:\nCMP word ptr [BP + + -2],0\nJNE LAB_6\nMOV word ptr [BP + + -2],1\nINC word ptr [BP + + -4]\nLAB_6:\nINC word ptr [BP + 8]\nJMP LAB_1\nLAB_4:\nMOV AX,word ptr [BP + + -4]\nMOV word ptr [BP + + -6],AX\nMOV AX,word ptr [BP + + -6]\nMOV SP,BP\nPOP BP\nPOP DI\nPOP SI\nRET", | |
| "c": "int countspaces(const char *s)\n{\n int count = 0;\n bool space = false;\n\n while (*s != '\\0') {\n if (*s == ' ') {\n space = false;\n } else if (space == false) {\n space = true;\n count++;\n }\n s++;\n }\n\n return count;\n}", | |
| "status": "pass", | |
| "seconds": 1.69 | |
| }, | |
| "dos16-large-ox": { | |
| "asm": "PUSH BP\nMOV BP,SP\nLDS BX,dword ptr [BP + 6]\nXOR DX,DX\nXOR AX,AX\nLAB_1:\nCMP byte ptr [BX],0\nJE LAB_2\nCMP byte ptr [BX],0x20\nJNE LAB_3\nXOR AX,AX\nLAB_4:\nINC BX\nJMP LAB_1\nLAB_3:\nTEST AX,AX\nJNE LAB_4\nMOV AX,1\nADD DX,AX\nJMP LAB_4\nLAB_2:\nMOV AX,DX\nPOP BP\nRETF", | |
| "c": "int countspaces(const char *str)\n{\n int spaces = 0;\n bool first = true;\n\n while (*str) {\n if (*str == ' ') {\n first = false;\n } else if (!first) {\n ++spaces;\n first = true;\n }\n ++str;\n }\n\n return spaces;\n}", | |
| "status": "fail", | |
| "seconds": 1.65 | |
| } | |
| } | |
| }, | |
| { | |
| "id": "sum_array", | |
| "title": "Sum of an array into long", | |
| "desc": "loop, 32-bit sum (a DX:AX register pair on DOS)", | |
| "source": "long sum_array(const int *a, int n) {\n long total = 0;\n int i;\n for (i = 0; i < n; i++) total += a[i];\n return total;\n}", | |
| "variants": { | |
| "msvc-x64-Od": { | |
| "asm": "MOV dword ptr [RSP + 0x10],EDX\nMOV qword ptr [RSP + 8],RCX\nSUB RSP,0x18\nMOV dword ptr [RSP + 4],0\nMOV dword ptr [RSP],0\nJMP LAB_1\nLAB_3:\nMOV EAX,dword ptr [RSP]\nINC EAX\nMOV dword ptr [RSP],EAX\nLAB_1:\nMOV EAX,dword ptr [RSP + 0x28]\nCMP dword ptr [RSP],EAX\nJGE LAB_2\nMOVSXD RAX,dword ptr [RSP]\nMOV RCX,qword ptr [RSP + 0x20]\nMOV EAX,dword ptr [RCX + RAX*4]\nMOV ECX,dword ptr [RSP + 4]\nADD ECX,EAX\nMOV EAX,ECX\nMOV dword ptr [RSP + 4],EAX\nJMP LAB_3\nLAB_2:\nMOV EAX,dword ptr [RSP + 4]\nADD RSP,0x18\nRET", | |
| "c": "int getSum(struct CElem m[], int n)\n{\n int sum = 0;\n int i;\n for (i = 0; i < n; i++)\n sum += m[i].key;\n return sum;\n}", | |
| "status": "compile_error", | |
| "seconds": 1.18 | |
| }, | |
| "msvc-x64-O2": { | |
| "asm": "SUB RSP,8\nXOR R8D,R8D\nMOVSXD R11,EDX\nMOV R9,RCX\nMOV R10D,R8D\nMOV ECX,R8D\nTEST EDX,EDX\nJLE LAB_1\nCMP R11D,8\nJB LAB_1\nMOV RDX,R11\nXORPS XMM2,XMM2\nAND RDX,0xfffffffffffffff8\nXORPS XMM1,XMM1\nMOV EAX,R8D\nNOP dword ptr [RAX]\nLAB_2:\nMOVDQU XMM0,xmmword ptr [R9 + RAX*4]\nADD ECX,8\nPADDD XMM2,XMM0\nMOVDQU XMM0,xmmword ptr [R9 + RAX*4 + 0x10]\nADD RAX,8\nPADDD XMM1,XMM0\nCMP RAX,RDX\nJL LAB_2\nPADDD XMM1,XMM2\nMOVDQA XMM0,XMM1\nPSRLDQ XMM0,8\nPADDD XMM1,XMM0\nMOVDQA XMM0,XMM1\nPSRLDQ XMM0,4\nPADDD XMM1,XMM0\nMOVD R10D,XMM1\nLAB_1:\nMOVSXD RAX,ECX\nMOV EDX,R8D\nCMP RAX,R11\nJGE LAB_3\nMOV RCX,R11\nSUB RCX,RAX\nCMP RCX,2\nJL LAB_4\nMOV qword ptr [RSP],RBX\nLEA RBX,[R11 + -1]\nNOP dword ptr [RAX]\nNOP word ptr [RAX + RAX + 0x0]\nLAB_5:\nADD R8D,dword ptr [R9 + RAX*4]\nADD EDX,dword ptr [R9 + RAX*4 + 4]\nADD RAX,2\nCMP RAX,RBX\nJL LAB_5\nMOV RBX,qword ptr [RSP]\nCMP RAX,R11\nJGE LAB_6\nLAB_4:\nADD R10D,dword ptr [R9 + RAX*4]\nLAB_6:\nLEA EAX,[RDX + R8]\nADD EAX,R10D\nADD RSP,8\nRET\nLAB_3:\nMOV EAX,R10D\nADD RSP,8\nRET", | |
| "c": "int sum(int arr[], int n)\n{\n int i;\n int sum = 0;\n for (i = 0; i < n; i++)\n sum = sum + arr[i];\n return sum;\n}", | |
| "status": "pass", | |
| "seconds": 1.08 | |
| }, | |
| "msvc-x86-Od": { | |
| "asm": "PUSH EBP\nMOV EBP,ESP\nSUB ESP,8\nMOV dword ptr [EBP + -8],0\nMOV dword ptr [EBP + -4],0\nJMP LAB_1\nLAB_3:\nMOV EAX,dword ptr [EBP + -4]\nADD EAX,1\nMOV dword ptr [EBP + -4],EAX\nLAB_1:\nMOV ECX,dword ptr [EBP + -4]\nCMP ECX,dword ptr [EBP + 0xc]\nJGE LAB_2\nMOV EDX,dword ptr [EBP + -4]\nMOV EAX,dword ptr [EBP + 8]\nMOV ECX,dword ptr [EBP + -8]\nADD ECX,dword ptr [EAX + EDX*4]\nMOV dword ptr [EBP + -8],ECX\nJMP LAB_3\nLAB_2:\nMOV EAX,dword ptr [EBP + -8]\nMOV ESP,EBP\nPOP EBP\nRET", | |
| "c": "int sum_array(const int *a, int n)\n{\n int sum = 0, i;\n for(i = 0; i < n; ++i)\n {\n sum += a[i];\n }\n return sum;\n}", | |
| "status": "pass", | |
| "seconds": 1.16 | |
| }, | |
| "msvc-x86-O2": { | |
| "asm": "MOV EDX,dword ptr [ESP + 4]\nXOR EAX,EAX\nPUSH EBX\nPUSH EBP\nMOV EBP,dword ptr [ESP + 0x10]\nXOR EBX,EBX\nPUSH ESI\nPUSH EDI\nTEST EBP,EBP\nJLE LAB_1\nCMP EBP,8\nJB LAB_1\nMOV ECX,EBP\nXORPS XMM2,XMM2\nAND ECX,0xfffffff8\nXORPS XMM1,XMM1\nNOP dword ptr [EAX]\nNOP dword ptr [EAX + EAX + 0x0]\nLAB_2:\nMOVUPS XMM0,xmmword ptr [EDX + EAX*4]\nPADDD XMM2,XMM0\nMOVUPS XMM0,xmmword ptr [EDX + EAX*4 + 0x10]\nADD EAX,8\nPADDD XMM1,XMM0\nCMP EAX,ECX\nJL LAB_2\nPADDD XMM1,XMM2\nMOVAPS XMM0,XMM1\nPSRLDQ XMM0,8\nPADDD XMM1,XMM0\nMOVUPS XMM0,XMM1\nPSRLDQ XMM0,4\nPADDD XMM1,XMM0\nMOVD EBX,XMM1\nLAB_1:\nXOR ESI,ESI\nXOR EDI,EDI\nCMP EAX,EBP\nJGE LAB_3\nMOV ECX,EBP\nSUB ECX,EAX\nCMP ECX,2\nJL LAB_4\nLEA ECX,[EBP + -1]\nMOV dword ptr [ESP + 0x18],ECX\nLAB_5:\nADD ESI,dword ptr [EDX + EAX*4]\nADD EDI,dword ptr [EDX + EAX*4 + 4]\nADD EAX,2\nMOV ECX,EAX\nCMP EAX,dword ptr [ESP + 0x18]\nJL LAB_5\nCMP ECX,EBP\nJGE LAB_6\nLAB_4:\nADD EBX,dword ptr [EDX + EAX*4]\nLAB_6:\nLEA EAX,[EDI + ESI]\nPOP EDI\nPOP ESI\nPOP EBP\nADD EAX,EBX\nPOP EBX\nRET\nLAB_3:\nPOP EDI\nPOP ESI\nPOP EBP\nMOV EAX,EBX\nPOP EBX\nRET", | |
| "c": "int sum_array(int *a, int n)\n{\n int sum = 0;\n for (int i = 0; i < n; ++i)\n sum += a[i];\n return sum;\n}", | |
| "status": "pass", | |
| "seconds": 1.04 | |
| }, | |
| "dos16-small-od": { | |
| "asm": "PUSH SI\nPUSH DI\nPUSH BP\nMOV BP,SP\nSUB SP,0xa\nMOV word ptr [BP + + -0xa],0\nMOV word ptr [BP + + -8],0\nMOV word ptr [BP + + -2],0\nLAB_1:\nMOV AX,word ptr [BP + + -2]\nCMP AX,word ptr [BP + 0xa]\nJGE LAB_2\nJMP LAB_3\nLAB_2:\nJMP LAB_4\nLAB_3:\nMOV BX,word ptr [BP + + -2]\nSHL BX,1\nADD BX,word ptr [BP + 8]\nMOV AX,word ptr [BX]\nCWD\nMOV BX,AX\nMOV AX,DX\nADD word ptr [BP + + -0xa],BX\nADC word ptr [BP + + -8],AX\nINC word ptr [BP + + -2]\nJMP LAB_1\nLAB_4:\nMOV AX,word ptr [BP + + -0xa]\nMOV word ptr [BP + + -6],AX\nMOV AX,word ptr [BP + + -8]\nMOV word ptr [BP + + -4],AX\nMOV AX,word ptr [BP + + -6]\nMOV DX,word ptr [BP + + -4]\nMOV SP,BP\nPOP BP\nPOP DI\nPOP SI\nRET", | |
| "c": "size_t sum_array(int *a, int n)\n{\n size_t sum = 0;\n for (int i = 0; i < n; ++i)\n {\n sum += a[i];\n }\n return sum;\n}", | |
| "status": "pass", | |
| "seconds": 1.11 | |
| }, | |
| "dos16-large-ox": { | |
| "asm": "PUSH SI\nPUSH DI\nPUSH BP\nMOV BP,SP\nLDS BX,dword ptr [BP + 0xa]\nXOR DI,DI\nXOR SI,SI\nXOR CX,CX\nLAB_1:\nCMP CX,word ptr [BP + 0xe]\nJGE LAB_2\nMOV AX,word ptr [BX]\nCWD\nADD DI,AX\nADC SI,DX\nADD BX,2\nINC CX\nJMP LAB_1\nLAB_2:\nMOV AX,DI\nMOV DX,SI\nPOP BP\nPOP DI\nPOP SI\nRETF", | |
| "c": "size_t sum_array(int *a, int n)\n{\n size_t sum = 0;\n for (int i = 0; i < n; ++i)\n {\n sum += a[i];\n }\n return sum;\n}", | |
| "status": "pass", | |
| "seconds": 1.14 | |
| } | |
| } | |
| }, | |
| { | |
| "id": "my_strlen", | |
| "title": "String length", | |
| "desc": "pointer arithmetic", | |
| "source": "unsigned my_strlen(const char *s) {\n const char *p = s;\n while (*p) p++;\n return (unsigned)(p - s);\n}", | |
| "variants": { | |
| "msvc-x64-Od": { | |
| "asm": "MOV qword ptr [RSP + 8],RCX\nSUB RSP,0x18\nMOV RAX,qword ptr [RSP + 0x20]\nMOV qword ptr [RSP],RAX\nLAB_2:\nMOV RAX,qword ptr [RSP]\nMOVSX EAX,byte ptr [RAX]\nTEST EAX,EAX\nJE LAB_1\nMOV RAX,qword ptr [RSP]\nINC RAX\nMOV qword ptr [RSP],RAX\nJMP LAB_2\nLAB_1:\nMOV RAX,qword ptr [RSP + 0x20]\nMOV RCX,qword ptr [RSP]\nSUB RCX,RAX\nMOV RAX,RCX\nADD RSP,0x18\nRET", | |
| "c": "size_t strlen(const char *s)\n{\n const char *sc = s;\n\n while (*sc != '\\0')\n {\n sc++;\n }\n\n return sc - s;\n}", | |
| "status": "pass", | |
| "seconds": 0.91 | |
| }, | |
| "msvc-x64-O2": { | |
| "asm": "CMP byte ptr [RCX],0\nMOV RAX,RCX\nJE LAB_1\nLAB_2:\nINC RAX\nCMP byte ptr [RAX],0\nJNE LAB_2\nLAB_1:\nSUB EAX,ECX\nRET", | |
| "c": "size_t strlen(const char *s)\n{\n const char *sc = s;\n\n while (*sc != '\\0')\n {\n sc++;\n }\n\n return sc - s;\n}", | |
| "status": "pass", | |
| "seconds": 0.92 | |
| }, | |
| "msvc-x86-Od": { | |
| "asm": "PUSH EBP\nMOV EBP,ESP\nPUSH ECX\nMOV EAX,dword ptr [EBP + 8]\nMOV dword ptr [EBP + -4],EAX\nLAB_2:\nMOV ECX,dword ptr [EBP + -4]\nMOVSX EDX,byte ptr [ECX]\nTEST EDX,EDX\nJE LAB_1\nMOV EAX,dword ptr [EBP + -4]\nADD EAX,1\nMOV dword ptr [EBP + -4],EAX\nJMP LAB_2\nLAB_1:\nMOV EAX,dword ptr [EBP + -4]\nSUB EAX,dword ptr [EBP + 8]\nMOV ESP,EBP\nPOP EBP\nRET", | |
| "c": "size_t strlen(const char *s)\n{\n const char *sc = s;\n\n while (*sc != '\\0')\n {\n sc++;\n }\n\n return sc - s;\n}", | |
| "status": "pass", | |
| "seconds": 0.91 | |
| }, | |
| "msvc-x86-O2": { | |
| "asm": "MOV ECX,dword ptr [ESP + 4]\nMOV EAX,ECX\nCMP byte ptr [ECX],0\nJE LAB_1\nNOP dword ptr [EAX + EAX]\nLAB_2:\nINC EAX\nCMP byte ptr [EAX],0\nJNE LAB_2\nLAB_1:\nSUB EAX,ECX\nRET", | |
| "c": "size_t strlen(const char *s)\n{\n const char *sc = s;\n\n while (*sc != '\\0')\n {\n sc++;\n }\n\n return sc - s;\n}", | |
| "status": "pass", | |
| "seconds": 0.91 | |
| }, | |
| "dos16-small-od": { | |
| "asm": "PUSH SI\nPUSH DI\nPUSH BP\nMOV BP,SP\nSUB SP,4\nMOV AX,word ptr [BP + 8]\nMOV word ptr [BP + + -2],AX\nLAB_1:\nMOV BX,word ptr [BP + + -2]\nCMP byte ptr [BX],0\nJE LAB_2\nJMP LAB_3\nLAB_2:\nJMP LAB_4\nLAB_3:\nINC word ptr [BP + + -2]\nJMP LAB_1\nLAB_4:\nMOV BX,word ptr [BP + + -2]\nSUB BX,word ptr [BP + 8]\nMOV word ptr [BP + + -4],BX\nMOV AX,word ptr [BP + + -4]\nMOV SP,BP\nPOP BP\nPOP DI\nPOP SI\nRET", | |
| "c": "int strlen(const char *s)\n{\n const char *sc = s;\n\n while (*sc != '\\0')\n {\n sc++;\n }\n\n return sc - s;\n}", | |
| "status": "pass", | |
| "seconds": 0.9 | |
| }, | |
| "dos16-large-ox": { | |
| "asm": "PUSH BP\nMOV BP,SP\nMOV AX,word ptr [BP + 6]\nMOV DS,word ptr [BP + 8]\nMOV BX,AX\nLAB_1:\nCMP byte ptr [BX],0\nJE LAB_2\nINC BX\nJMP LAB_1\nLAB_2:\nSUB BX,AX\nMOV AX,BX\nPOP BP\nRETF", | |
| "c": "int strlen(const char *s)\n{\n const char *p = s;\n\n while (*p != '\\0')\n p++;\n\n return p - s;\n}", | |
| "status": "pass", | |
| "seconds": 0.81 | |
| } | |
| } | |
| }, | |
| { | |
| "id": "max_index", | |
| "title": "Index of maximum", | |
| "desc": "finding the maximum in an array", | |
| "source": "int max_index(const int *a, int n) {\n int best = 0, i;\n for (i = 1; i < n; i++)\n if (a[i] > a[best]) best = i;\n return best;\n}", | |
| "variants": { | |
| "msvc-x64-Od": { | |
| "asm": "MOV dword ptr [RSP + 0x10],EDX\nMOV qword ptr [RSP + 8],RCX\nSUB RSP,0x18\nMOV dword ptr [RSP + 4],0\nMOV dword ptr [RSP],1\nJMP LAB_1\nLAB_4:\nMOV EAX,dword ptr [RSP]\nINC EAX\nMOV dword ptr [RSP],EAX\nLAB_1:\nMOV EAX,dword ptr [RSP + 0x28]\nCMP dword ptr [RSP],EAX\nJGE LAB_2\nMOVSXD RAX,dword ptr [RSP]\nMOVSXD RCX,dword ptr [RSP + 4]\nMOV RDX,qword ptr [RSP + 0x20]\nMOV R8,qword ptr [RSP + 0x20]\nMOV ECX,dword ptr [R8 + RCX*4]\nCMP dword ptr [RDX + RAX*4],ECX\nJLE LAB_3\nMOV EAX,dword ptr [RSP]\nMOV dword ptr [RSP + 4],EAX\nLAB_3:\nJMP LAB_4\nLAB_2:\nMOV EAX,dword ptr [RSP + 4]\nADD RSP,0x18\nRET", | |
| "c": "int max(int *a, int n)\n{\n int i, maxi;\n maxi = 0;\n for (i = 1; i < n; ++i)\n if (a[i] > a[maxi])\n maxi = i;\n return maxi;\n}", | |
| "status": "pass", | |
| "seconds": 1.42 | |
| }, | |
| "msvc-x64-O2": { | |
| "asm": "MOV qword ptr [RSP + 8],RBX\nMOV qword ptr [RSP + 0x10],RDI\nXOR R11D,R11D\nMOV R10D,1\nMOV EDI,EDX\nCMP EDX,R10D\nJLE LAB_1\nMOV R9D,4\nMOV EAX,R11D\nNOP dword ptr [RAX]\nNOP word ptr [RAX + RAX + 0x0]\nLAB_2:\nMOV R8D,dword ptr [RAX + RCX]\nMOV EDX,R10D\nCMP dword ptr [R9 + RCX],R8D\nCMOVLE EDX,R11D\nCMOVG RAX,R9\nINC R10D\nADD R9,4\nMOV R11D,EDX\nCMP R10D,EDI\nJL LAB_2\nMOV EAX,EDX\nMOV RBX,qword ptr [RSP + 8]\nMOV RDI,qword ptr [RSP + 0x10]\nRET\nLAB_1:\nMOV RBX,qword ptr [RSP + 8]\nMOV EAX,R11D\nMOV RDI,qword ptr [RSP + 0x10]\nRET", | |
| "c": "int max(int *nums, int sz)\n{\n int i;\n int n_max = 0;\n for (i = 1; i < sz; i++) {\n if (nums[i] > nums[i - 1]) {\n n_max = i;\n }\n }\n return n_max;\n}", | |
| "status": "fail", | |
| "seconds": 1.51 | |
| }, | |
| "msvc-x86-Od": { | |
| "asm": "PUSH EBP\nMOV EBP,ESP\nSUB ESP,8\nPUSH ESI\nMOV dword ptr [EBP + -8],0\nMOV dword ptr [EBP + -4],1\nJMP LAB_1\nLAB_4:\nMOV EAX,dword ptr [EBP + -4]\nADD EAX,1\nMOV dword ptr [EBP + -4],EAX\nLAB_1:\nMOV ECX,dword ptr [EBP + -4]\nCMP ECX,dword ptr [EBP + 0xc]\nJGE LAB_2\nMOV EDX,dword ptr [EBP + -4]\nMOV EAX,dword ptr [EBP + 8]\nMOV ECX,dword ptr [EBP + -8]\nMOV ESI,dword ptr [EBP + 8]\nMOV EDX,dword ptr [EAX + EDX*4]\nCMP EDX,dword ptr [ESI + ECX*4]\nJLE LAB_3\nMOV EAX,dword ptr [EBP + -4]\nMOV dword ptr [EBP + -8],EAX\nLAB_3:\nJMP LAB_4\nLAB_2:\nMOV EAX,dword ptr [EBP + -8]\nPOP ESI\nMOV ESP,EBP\nPOP EBP\nRET", | |
| "c": "int max(int *a, int n)\n{\n int i, maxi;\n maxi = 0;\n for (i = 1; i < n; ++i)\n if (a[i] > a[maxi])\n maxi = i;\n return maxi;\n}", | |
| "status": "pass", | |
| "seconds": 1.44 | |
| }, | |
| "msvc-x86-O2": { | |
| "asm": "XOR EAX,EAX\nPUSH EBP\nMOV EBP,dword ptr [ESP + 0xc]\nPUSH EDI\nLEA EDI,[EAX + 1]\nCMP EBP,EDI\nJLE LAB_1\nPUSH EBX\nPUSH ESI\nXOR EBX,EBX\nLAB_2:\nMOV ECX,dword ptr [ESP + 0x14]\nMOV ESI,EAX\nLEA EAX,[EDI*4 + 0x0]\nMOV EDX,dword ptr [EAX + ECX]\nCMP EDX,dword ptr [EBX + ECX]\nCMOVG EBX,EAX\nMOV EAX,EDI\nCMOVLE EAX,ESI\nINC EDI\nCMP EDI,EBP\nJL LAB_2\nPOP ESI\nPOP EBX\nLAB_1:\nPOP EDI\nPOP EBP\nRET", | |
| "c": "int find_max(int a[], int len) {\n int max = 0;\n for (int i = 1; i < len; i++) {\n if (a[i] > a[max]) {\n max = i;\n }\n }\n return max;\n}", | |
| "status": "pass", | |
| "seconds": 1.34 | |
| }, | |
| "dos16-small-od": { | |
| "asm": "PUSH SI\nPUSH DI\nPUSH BP\nMOV BP,SP\nSUB SP,6\nMOV word ptr [BP + + -4],0\nMOV word ptr [BP + + -2],1\nLAB_1:\nMOV AX,word ptr [BP + + -2]\nCMP AX,word ptr [BP + 0xa]\nJGE LAB_2\nJMP LAB_3\nLAB_2:\nJMP LAB_4\nLAB_3:\nMOV BX,word ptr [BP + + -2]\nSHL BX,1\nADD BX,word ptr [BP + 8]\nMOV SI,word ptr [BP + + -4]\nSHL SI,1\nADD SI,word ptr [BP + 8]\nMOV BX,word ptr [BX]\nCMP BX,word ptr [SI]\nJLE LAB_5\nJMP LAB_6\nLAB_5:\nJMP LAB_7\nLAB_6:\nMOV AX,word ptr [BP + + -2]\nMOV word ptr [BP + + -4],AX\nLAB_7:\nINC word ptr [BP + + -2]\nJMP LAB_1\nLAB_4:\nMOV AX,word ptr [BP + + -4]\nMOV word ptr [BP + + -6],AX\nMOV AX,word ptr [BP + + -6]\nMOV SP,BP\nPOP BP\nPOP DI\nPOP SI\nRET", | |
| "c": "int max(int *a, int n)\n{\n int i, max_i = 0;\n for (i = 1; i < n; ++i)\n if (a[i] > a[max_i])\n max_i = i;\n return max_i;\n}", | |
| "status": "pass", | |
| "seconds": 1.33 | |
| }, | |
| "dos16-large-ox": { | |
| "asm": "PUSH SI\nPUSH DI\nPUSH BP\nMOV BP,SP\nMOV DI,word ptr [BP + 0xc]\nMOV AX,1\nMOV BX,word ptr [BP + 0xa]\nMOV ES,DI\nMOV DS,DI\nXOR DX,DX\nADD BX,2\nLAB_1:\nCMP AX,word ptr [BP + 0xe]\nJGE LAB_2\nMOV SI,DX\nADD SI,DX\nADD SI,word ptr [BP + 0xa]\nMOV CX,word ptr ES:[BX]\nCMP CX,word ptr [SI]\nJG LAB_3\nLAB_4:\nADD BX,2\nINC AX\nJMP LAB_1\nLAB_3:\nMOV DX,AX\nJMP LAB_4\nLAB_2:\nMOV AX,DX\nPOP BP\nPOP DI\nPOP SI\nRETF", | |
| "c": "int get_max(data array[], int len) {\n int i, max = 0;\n for (i = 1; i < len; i++) {\n if (array[i] > array[max])\n max = i;\n }\n return max;\n}", | |
| "status": "compile_error", | |
| "seconds": 1.28 | |
| } | |
| } | |
| }, | |
| { | |
| "id": "factorial", | |
| "title": "Factorial", | |
| "desc": "recursion", | |
| "source": "unsigned long factorial(unsigned n) {\n if (n <= 1) return 1;\n return n * factorial(n - 1);\n}", | |
| "variants": { | |
| "msvc-x64-Od": { | |
| "asm": "MOV dword ptr [RSP + 8],ECX\nSUB RSP,0x28\nCMP dword ptr [RSP + 0x30],1\nJA LAB_1\nMOV EAX,1\nJMP LAB_2\nLAB_1:\nMOV EAX,dword ptr [RSP + 0x30]\nDEC EAX\nMOV ECX,EAX\nCALL factorial\nMOV ECX,dword ptr [RSP + 0x30]\nIMUL ECX,EAX\nMOV EAX,ECX\nLAB_2:\nADD RSP,0x28\nRET", | |
| "c": "unsigned factorial(unsigned n)\n{ if (n <= 1) return 1;\n return n * factorial(n - 1);\n}", | |
| "status": "pass", | |
| "seconds": 0.64 | |
| }, | |
| "msvc-x64-O2": { | |
| "asm": "PUSH RBX\nSUB RSP,0x20\nMOV EBX,ECX\nCMP ECX,1\nJA LAB_1\nMOV EAX,1\nADD RSP,0x20\nPOP RBX\nRET\nLAB_1:\nDEC ECX\nCALL factorial\nIMUL EAX,EBX\nADD RSP,0x20\nPOP RBX\nRET", | |
| "c": "uint64_t factorial(uint64_t n) {\n if (n <= 1) return 1;\n return n * factorial(n-1);\n}", | |
| "status": "pass", | |
| "seconds": 0.65 | |
| }, | |
| "msvc-x86-Od": { | |
| "asm": "PUSH EBP\nMOV EBP,ESP\nCMP dword ptr [EBP + 8],1\nJA LAB_1\nMOV EAX,1\nJMP LAB_2\nLAB_1:\nMOV EAX,dword ptr [EBP + 8]\nSUB EAX,1\nPUSH EAX\nCALL _factorial\nADD ESP,4\nIMUL EAX,dword ptr [EBP + 8]\nLAB_2:\nPOP EBP\nRET", | |
| "c": "unsigned int factorial(unsigned int n)\n{\n if (n <= 1) {\n return 1;\n }\n\n return n * factorial(n-1);\n}", | |
| "status": "pass", | |
| "seconds": 0.8 | |
| }, | |
| "msvc-x86-O2": { | |
| "asm": "PUSH ESI\nMOV ESI,dword ptr [ESP + 8]\nCMP ESI,1\nJA LAB_1\nMOV EAX,1\nPOP ESI\nRET\nLAB_1:\nLEA EAX,[ESI + -1]\nPUSH EAX\nCALL _factorial\nADD ESP,4\nIMUL EAX,ESI\nPOP ESI\nRET", | |
| "c": "uint64_t factorial (uint64_t n)\n{\n if (n <= 1) return 1;\n\n return n * factorial(n-1);\n}", | |
| "status": "pass", | |
| "seconds": 0.71 | |
| }, | |
| "dos16-small-od": { | |
| "asm": "PUSH SI\nPUSH DI\nPUSH BP\nMOV BP,SP\nSUB SP,4\nCMP word ptr [BP + 8],1\nJBE LAB_1\nJMP LAB_2\nLAB_1:\nMOV word ptr [BP + + -4],1\nMOV word ptr [BP + + -2],0\nJMP LAB_3\nLAB_2:\nMOV AX,word ptr [BP + 8]\nDEC AX\nPUSH AX\nCALL _factorial\nMOV SI,AX\nMOV CX,DX\nADD SP,2\nMOV AX,word ptr [BP + 8]\nXOR DX,DX\nMOV BX,AX\nMOV AX,BX\nMOV BX,SI\nCALL __U4M\nMOV word ptr [BP + + -4],AX\nMOV word ptr [BP + + -2],DX\nJMP LAB_3\nLAB_3:\nMOV AX,word ptr [BP + + -4]\nMOV DX,word ptr [BP + + -2]\nMOV SP,BP\nPOP BP\nPOP DI\nPOP SI\nRET", | |
| "c": "size_t factorial(unsigned int n)\n{\n if (n <= 1) {\n return 1;\n } else {\n return n * factorial(n-1);\n }\n}", | |
| "status": "pass", | |
| "seconds": 0.88 | |
| }, | |
| "dos16-large-ox": { | |
| "asm": "PUSH SI\nPUSH BP\nMOV BP,SP\nMOV SI,word ptr [BP + 8]\nCMP SI,1\nJA LAB_1\nMOV AX,1\nXOR DX,DX\nPOP BP\nPOP SI\nRETF\nLAB_1:\nLEA AX,[SI + + -1]\nPUSH AX\nMOV AX,SS\nMOV DS,AX\nPUSH CS\nCALL _factorial\nMOV BX,AX\nMOV CX,DX\nADD SP,2\nMOV AX,SI\nXOR DX,DX\nCALL __U4M\nPOP BP\nPOP SI\nRETF", | |
| "c": "size_t factorial(unsigned int n)\n{\n if (n <= 1) {\n return 1;\n } else {\n return n * factorial(n-1);\n }\n}", | |
| "status": "pass", | |
| "seconds": 0.87 | |
| } | |
| } | |
| }, | |
| { | |
| "id": "gcd", | |
| "title": "Greatest common divisor", | |
| "desc": "Euclid's algorithm, division with remainder", | |
| "source": "int gcd(int a, int b) {\n while (b != 0) {\n int t = a % b;\n a = b;\n b = t;\n }\n return a;\n}", | |
| "variants": { | |
| "msvc-x64-Od": { | |
| "asm": "MOV dword ptr [RSP + 0x10],EDX\nMOV dword ptr [RSP + 8],ECX\nSUB RSP,0x18\nLAB_2:\nCMP dword ptr [RSP + 0x28],0\nJE LAB_1\nMOV EAX,dword ptr [RSP + 0x20]\nCDQ\nIDIV EAX,dword ptr [RSP + 0x28]\nMOV EAX,EDX\nMOV dword ptr [RSP],EAX\nMOV EAX,dword ptr [RSP + 0x28]\nMOV dword ptr [RSP + 0x20],EAX\nMOV EAX,dword ptr [RSP]\nMOV dword ptr [RSP + 0x28],EAX\nJMP LAB_2\nLAB_1:\nMOV EAX,dword ptr [RSP + 0x20]\nADD RSP,0x18\nRET", | |
| "c": "int64_t gcd(int64_t x, int64_t y)\n{\n int64_t t;\n\n while (y != 0) {\n t = x % y; x = y; y = t;\n }\n return x;\n}", | |
| "status": "pass", | |
| "seconds": 1.02 | |
| }, | |
| "msvc-x64-O2": { | |
| "asm": "MOV R8D,EDX\nTEST EDX,EDX\nJE LAB_1\nNOP word ptr [RAX + RAX + 0x0]\nLAB_2:\nMOV EAX,ECX\nMOV ECX,R8D\nCDQ\nIDIV EAX,R8D\nMOV R8D,EDX\nTEST EDX,EDX\nJNE LAB_2\nLAB_1:\nMOV EAX,ECX\nRET", | |
| "c": "int64_t gcd(int64_t a, int64_t b)\n{\n int64_t t;\n\n while (b != 0) {\n t = a;\n a = b;\n b = t % b;\n }\n return a;\n}", | |
| "status": "pass", | |
| "seconds": 1.05 | |
| }, | |
| "msvc-x86-Od": { | |
| "asm": "PUSH EBP\nMOV EBP,ESP\nPUSH ECX\nLAB_2:\nCMP dword ptr [EBP + 0xc],0\nJE LAB_1\nMOV EAX,dword ptr [EBP + 8]\nCDQ\nIDIV EAX,dword ptr [EBP + 0xc]\nMOV dword ptr [EBP + -4],EDX\nMOV EAX,dword ptr [EBP + 0xc]\nMOV dword ptr [EBP + 8],EAX\nMOV ECX,dword ptr [EBP + -4]\nMOV dword ptr [EBP + 0xc],ECX\nJMP LAB_2\nLAB_1:\nMOV EAX,dword ptr [EBP + 8]\nMOV ESP,EBP\nPOP EBP\nRET", | |
| "c": "int64_t gcd(int64_t a, int64_t b)\n{\n int64_t t;\n\n while (b != 0) {\n t = a % b; a = b; b = t;\n }\n return a;\n}", | |
| "status": "pass", | |
| "seconds": 1.01 | |
| }, | |
| "msvc-x86-O2": { | |
| "asm": "MOV ECX,dword ptr [ESP + 8]\nMOV EAX,dword ptr [ESP + 4]\nTEST ECX,ECX\nJE LAB_1\nNOP dword ptr [EAX]\nLAB_2:\nCDQ\nIDIV EAX,ECX\nMOV EAX,ECX\nMOV ECX,EDX\nTEST EDX,EDX\nJNE LAB_2\nLAB_1:\nRET", | |
| "c": "int64_t gcd(int64_t a, int64_t b)\n{\n int64_t t;\n\n while (b != 0) {\n t = a % b; a = b; b = t;\n }\n return a;\n}", | |
| "status": "pass", | |
| "seconds": 1.02 | |
| }, | |
| "dos16-small-od": { | |
| "asm": "PUSH SI\nPUSH DI\nPUSH BP\nMOV BP,SP\nSUB SP,4\nLAB_1:\nCMP word ptr [BP + 0xa],0\nJNE LAB_2\nJMP LAB_3\nLAB_2:\nMOV AX,word ptr [BP + 8]\nCWD\nIDIV word ptr [BP + 0xa]\nMOV word ptr [BP + + -4],DX\nMOV AX,word ptr [BP + 0xa]\nMOV word ptr [BP + 8],AX\nMOV AX,word ptr [BP + + -4]\nMOV word ptr [BP + 0xa],AX\nJMP LAB_1\nLAB_3:\nMOV AX,word ptr [BP + 8]\nMOV word ptr [BP + + -2],AX\nMOV AX,word ptr [BP + + -2]\nMOV SP,BP\nPOP BP\nPOP DI\nPOP SI\nRET", | |
| "c": "int64_t gcd(int64_t a, int64_t b)\n{\n int64_t t;\n\n while(b != 0)\n {\n\n t = a % b;\n a = b;\n b = t;\n }\n return a;\n}", | |
| "status": "pass", | |
| "seconds": 1.07 | |
| }, | |
| "dos16-large-ox": { | |
| "asm": "PUSH BP\nMOV BP,SP\nMOV AX,word ptr [BP + 6]\nMOV BX,word ptr [BP + 8]\nLAB_1:\nTEST BX,BX\nJE LAB_2\nCWD\nIDIV BX\nMOV AX,BX\nMOV BX,DX\nJMP LAB_1\nLAB_2:\nPOP BP\nRETF", | |
| "c": "uint64_t gcd(uint64_t a, uint64_t b) {\n uint64_t tmp;\n\n while (b != 0) {\n tmp = b;\n b = a % b;\n a = tmp;\n }\n\n return a;\n}", | |
| "status": "pass", | |
| "seconds": 1.03 | |
| } | |
| } | |
| }, | |
| { | |
| "id": "bubble_sort", | |
| "title": "Bubble sort", | |
| "desc": "two nested loops, swapping elements", | |
| "source": "void bubble_sort(int *a, int n) {\n int i, j, t;\n for (i = 0; i < n - 1; i++)\n for (j = 0; j < n - 1 - i; j++)\n if (a[j] > a[j + 1]) { t = a[j]; a[j] = a[j + 1]; a[j + 1] = t; }\n}", | |
| "variants": { | |
| "msvc-x64-Od": { | |
| "asm": "MOV dword ptr [RSP + 0x10],EDX\nMOV qword ptr [RSP + 8],RCX\nSUB RSP,0x18\nMOV dword ptr [RSP + 4],0\nJMP LAB_1\nLAB_7:\nMOV EAX,dword ptr [RSP + 4]\nINC EAX\nMOV dword ptr [RSP + 4],EAX\nLAB_1:\nMOV EAX,dword ptr [RSP + 0x28]\nDEC EAX\nCMP dword ptr [RSP + 4],EAX\nJGE LAB_2\nMOV dword ptr [RSP],0\nJMP LAB_3\nLAB_6:\nMOV EAX,dword ptr [RSP]\nINC EAX\nMOV dword ptr [RSP],EAX\nLAB_3:\nMOV EAX,dword ptr [RSP + 0x28]\nDEC EAX\nSUB EAX,dword ptr [RSP + 4]\nCMP dword ptr [RSP],EAX\nJGE LAB_4\nMOVSXD RAX,dword ptr [RSP]\nMOV ECX,dword ptr [RSP]\nINC ECX\nMOVSXD RCX,ECX\nMOV RDX,qword ptr [RSP + 0x20]\nMOV R8,qword ptr [RSP + 0x20]\nMOV ECX,dword ptr [R8 + RCX*4]\nCMP dword ptr [RDX + RAX*4],ECX\nJLE LAB_5\nMOVSXD RAX,dword ptr [RSP]\nMOV RCX,qword ptr [RSP + 0x20]\nMOV EAX,dword ptr [RCX + RAX*4]\nMOV dword ptr [RSP + 8],EAX\nMOV EAX,dword ptr [RSP]\nINC EAX\nCDQE\nMOVSXD RCX,dword ptr [RSP]\nMOV RDX,qword ptr [RSP + 0x20]\nMOV R8,qword ptr [RSP + 0x20]\nMOV EAX,dword ptr [R8 + RAX*4]\nMOV dword ptr [RDX + RCX*4],EAX\nMOV EAX,dword ptr [RSP]\nINC EAX\nCDQE\nMOV RCX,qword ptr [RSP + 0x20]\nMOV EDX,dword ptr [RSP + 8]\nMOV dword ptr [RCX + RAX*4],EDX\nLAB_5:\nJMP LAB_6\nLAB_4:\nJMP LAB_7\nLAB_2:\nADD RSP,0x18\nRET", | |
| "c": "void bubbleSort(int *sortMe ,(int size)\n{\n int i,j,temp;\n for(i=0;i<size-1;i++)\n {\n for(j=0;j<size-1-i;j++)\n {\n if(sortMe[j] > sortMe[j+1])\n {\n temp = sortMe[j];\n sortMe[j] = sortMe[j+1];\n sortMe[j+1] = temp;\n }\n }\n }\n}", | |
| "status": "compile_error", | |
| "seconds": 2.59 | |
| }, | |
| "msvc-x64-O2": { | |
| "asm": "MOV qword ptr [RSP + 8],RBX\nMOV qword ptr [RSP + 0x10],RDI\nLEA EBX,[RDX + -1]\nXOR R10D,R10D\nMOV EDI,EDX\nMOV R11,RCX\nTEST EBX,EBX\nJLE LAB_1\nNOP dword ptr [RAX + 0x0]\nLAB_5:\nMOV EAX,EDI\nSUB EAX,R10D\nDEC EAX\nTEST EAX,EAX\nJLE LAB_2\nMOV ECX,dword ptr [R11]\nMOV RDX,R11\nMOV R9D,EAX\nLAB_4:\nMOV R8D,ECX\nMOV ECX,dword ptr [RDX + 4]\nCMP R8D,ECX\nJLE LAB_3\nMOV dword ptr [RDX],ECX\nMOV ECX,R8D\nMOV dword ptr [RDX + 4],R8D\nLAB_3:\nADD RDX,4\nSUB R9,1\nJNE LAB_4\nLAB_2:\nINC R10D\nCMP R10D,EBX\nJL LAB_5\nLAB_1:\nMOV RBX,qword ptr [RSP + 8]\nMOV RDI,qword ptr [RSP + 0x10]\nRET", | |
| "c": "void bubbleSort(int *sortMe ,(int size)\n{\n int i ,j ,k ,tmp;\n for(i=0;i<size-1;i++)\n {\n for(j=0;j<size-i-1;j++)\n {\n if(sortMe[j] > sortMe[j+1])\n {\n tmp = sortMe[j];\n sortMe[j] = sortMe[j+1];\n sortMe[j+1] = tmp;\n }\n }\n }\n}", | |
| "status": "compile_error", | |
| "seconds": 2.61 | |
| }, | |
| "msvc-x86-Od": { | |
| "asm": "PUSH EBP\nMOV EBP,ESP\nSUB ESP,0xc\nPUSH ESI\nMOV dword ptr [EBP + -8],0\nJMP LAB_1\nLAB_7:\nMOV EAX,dword ptr [EBP + -8]\nADD EAX,1\nMOV dword ptr [EBP + -8],EAX\nLAB_1:\nMOV ECX,dword ptr [EBP + 0xc]\nSUB ECX,1\nCMP dword ptr [EBP + -8],ECX\nJGE LAB_2\nMOV dword ptr [EBP + -4],0\nJMP LAB_3\nLAB_6:\nMOV EDX,dword ptr [EBP + -4]\nADD EDX,1\nMOV dword ptr [EBP + -4],EDX\nLAB_3:\nMOV EAX,dword ptr [EBP + 0xc]\nSUB EAX,1\nSUB EAX,dword ptr [EBP + -8]\nCMP dword ptr [EBP + -4],EAX\nJGE LAB_4\nMOV ECX,dword ptr [EBP + -4]\nMOV EDX,dword ptr [EBP + 8]\nMOV EAX,dword ptr [EBP + -4]\nMOV ESI,dword ptr [EBP + 8]\nMOV ECX,dword ptr [EDX + ECX*4]\nCMP ECX,dword ptr [ESI + EAX*4 + 4]\nJLE LAB_5\nMOV EDX,dword ptr [EBP + -4]\nMOV EAX,dword ptr [EBP + 8]\nMOV ECX,dword ptr [EAX + EDX*4]\nMOV dword ptr [EBP + -0xc],ECX\nMOV EDX,dword ptr [EBP + -4]\nMOV EAX,dword ptr [EBP + 8]\nMOV ECX,dword ptr [EBP + -4]\nMOV ESI,dword ptr [EBP + 8]\nMOV ECX,dword ptr [ESI + ECX*4 + 4]\nMOV dword ptr [EAX + EDX*4],ECX\nMOV EDX,dword ptr [EBP + -4]\nMOV EAX,dword ptr [EBP + 8]\nMOV ECX,dword ptr [EBP + -0xc]\nMOV dword ptr [EAX + EDX*4 + 4],ECX\nLAB_5:\nJMP LAB_6\nLAB_4:\nJMP LAB_7\nLAB_2:\nPOP ESI\nMOV ESP,EBP\nPOP EBP\nRET", | |
| "c": "void bubble_sort(int a[], int n)\n{\n int i, j;\n for (i = 0; i < n - 1; i++) {\n for (j = 0; j < n - 1 - i; j++) {\n if (a[j] > a[j + 1]) {\n int tmp = a[j];\n a[j] = a[j + 1];\n a[j + 1] = tmp;\n }\n }\n }\n}", | |
| "status": "pass", | |
| "seconds": 2.27 | |
| }, | |
| "msvc-x86-O2": { | |
| "asm": "MOV ECX,dword ptr [ESP + 8]\nDEC ECX\nTEST ECX,ECX\nJLE LAB_1\nPUSH EBX\nPUSH ESI\nPUSH EDI\nMOV EDI,dword ptr [ESP + 0x10]\nMOV EBX,ECX\nLAB_5:\nXOR EAX,EAX\nTEST ECX,ECX\nJLE LAB_2\nNOP dword ptr [EAX + EAX + 0x0]\nLAB_4:\nMOV EDX,dword ptr [EDI + EAX*4]\nMOV ESI,dword ptr [EDI + EAX*4 + 4]\nCMP EDX,ESI\nJLE LAB_3\nMOV dword ptr [EDI + EAX*4],ESI\nMOV dword ptr [EDI + EAX*4 + 4],EDX\nLAB_3:\nINC EAX\nCMP EAX,ECX\nJL LAB_4\nLAB_2:\nDEC ECX\nSUB EBX,1\nJNE LAB_5\nPOP EDI\nPOP ESI\nPOP EBX\nLAB_1:\nRET", | |
| "c": "void bubbleSort(int arr[], int n)\n{\n int i, j, temp;\n for (i = 0; i < n-1; i++)\n {\n for (j = 0; j < n-i-1; j++)\n {\n if (arr[j] > arr[j+1])\n {\n temp = arr[j];\n arr[j] = arr[j+1];\n arr[j+1] = temp;\n }\n }\n }\n}", | |
| "status": "pass", | |
| "seconds": 2.37 | |
| }, | |
| "dos16-small-od": { | |
| "asm": "PUSH SI\nPUSH DI\nPUSH BP\nMOV BP,SP\nSUB SP,8\nMOV word ptr [BP + + -6],0\nLAB_1:\nMOV AX,word ptr [BP + 0xa]\nDEC AX\nCMP AX,word ptr [BP + + -6]\nJLE LAB_2\nJMP LAB_3\nLAB_2:\nJMP LAB_4\nLAB_3:\nMOV word ptr [BP + + -4],0\nLAB_5:\nMOV AX,word ptr [BP + 0xa]\nDEC AX\nSUB AX,word ptr [BP + + -6]\nCMP AX,word ptr [BP + + -4]\nJG LAB_6\nJMP LAB_7\nLAB_6:\nMOV SI,word ptr [BP + + -4]\nSHL SI,1\nADD SI,word ptr [BP + 8]\nMOV BX,word ptr [BP + + -4]\nSHL BX,1\nADD BX,word ptr [BP + 8]\nMOV BX,word ptr [BX]\nCMP BX,word ptr [SI + 2]\nJLE LAB_8\nJMP LAB_9\nLAB_8:\nJMP LAB_10\nLAB_9:\nMOV BX,word ptr [BP + + -4]\nSHL BX,1\nADD BX,word ptr [BP + 8]\nMOV AX,word ptr [BX]\nMOV word ptr [BP + + -2],AX\nMOV BX,word ptr [BP + + -4]\nSHL BX,1\nADD BX,word ptr [BP + 8]\nMOV SI,word ptr [BP + + -4]\nSHL SI,1\nADD SI,word ptr [BP + 8]\nMOV AX,word ptr [BX + 2]\nMOV word ptr [SI],AX\nMOV BX,word ptr [BP + + -4]\nSHL BX,1\nADD BX,word ptr [BP + 8]\nMOV AX,word ptr [BP + + -2]\nMOV word ptr [BX + 2],AX\nJMP LAB_10\nLAB_10:\nINC word ptr [BP + + -4]\nJMP LAB_5\nLAB_7:\nINC word ptr [BP + + -6]\nJMP LAB_1\nLAB_4:\nMOV SP,BP\nPOP BP\nPOP DI\nPOP SI\nRET", | |
| "c": "void bubbleSort(int *sortMe , short size)\n{\n int i,j,temp;\n for(i=0;i<size-1;i++)\n {\n for(j=0;j<size-1-i;j++)\n {\n if(sortMe[j]>sortMe[j+1])\n {\n temp=sortMe[j];\n sortMe[j]=sortMe[j+1];\n sortMe[j+1]=temp;\n }\n }\n }\n}", | |
| "status": "pass", | |
| "seconds": 2.48 | |
| }, | |
| "dos16-large-ox": { | |
| "asm": "PUSH SI\nPUSH DI\nPUSH BP\nMOV BP,SP\nSUB SP,6\nMOV AX,word ptr [BP + 0xe]\nDEC AX\nMOV ES,word ptr [BP + 0xc]\nMOV word ptr [BP + + -4],AX\nMOV word ptr [BP + + -2],AX\nMOV AX,word ptr [BP + 0xa]\nXOR DI,DI\nMOV word ptr [BP + + -6],AX\nLAB_1:\nCMP DI,word ptr [BP + + -4]\nJGE LAB_2\nMOV SI,word ptr [BP + + -2]\nMOV BX,word ptr [BP + + -6]\nMOV DX,ES\nXOR AX,AX\nMOV DS,DX\nLAB_3:\nCMP AX,SI\nJL LAB_4\nDEC word ptr [BP + + -2]\nINC DI\nJMP LAB_1\nLAB_4:\nMOV DX,word ptr [BX]\nCMP DX,word ptr [BX + 2]\nJG LAB_5\nLAB_6:\nADD BX,2\nINC AX\nJMP LAB_3\nLAB_5:\nMOV CX,word ptr [BX + 2]\nMOV word ptr [BX],CX\nMOV word ptr [BX + 2],DX\nJMP LAB_6\nLAB_2:\nLEAVE\nPOP DI\nPOP SI\nRETF", | |
| "c": "void bubbleSort(int arr[], int n)\n{\n int i, j, temp;\n for (i = 0; i < n-1; i++)\n {\n for (j = 0; j < n-i-1; j++)\n {\n if (arr[j] > arr[j+1])\n {\n temp = arr[j];\n arr[j] = arr[j+1];\n arr[j+1] = temp;\n }\n }\n }\n}", | |
| "status": "pass", | |
| "seconds": 2.37 | |
| } | |
| } | |
| }, | |
| { | |
| "id": "reverse", | |
| "title": "Reverse a string", | |
| "desc": "two pointers moving towards each other", | |
| "source": "void reverse(char *s) {\n char *e = s + strlen(s) - 1, t;\n while (s < e) { t = *s; *s++ = *e; *e-- = t; }\n}", | |
| "variants": { | |
| "msvc-x64-Od": { | |
| "asm": "MOV qword ptr [RSP + 8],RCX\nSUB RSP,0x38\nMOV RCX,qword ptr [RSP + 0x40]\nCALL strlen\nMOV RCX,qword ptr [RSP + 0x40]\nLEA RAX,[RCX + RAX + -1]\nMOV qword ptr [RSP + 0x28],RAX\nLAB_2:\nMOV RAX,qword ptr [RSP + 0x28]\nCMP qword ptr [RSP + 0x40],RAX\nJAE LAB_1\nMOV RAX,qword ptr [RSP + 0x40]\nMOVZX EAX,byte ptr [RAX]\nMOV byte ptr [RSP + 0x20],AL\nMOV RAX,qword ptr [RSP + 0x40]\nMOV RCX,qword ptr [RSP + 0x28]\nMOVZX ECX,byte ptr [RCX]\nMOV byte ptr [RAX],CL\nMOV RAX,qword ptr [RSP + 0x40]\nINC RAX\nMOV qword ptr [RSP + 0x40],RAX\nMOV RAX,qword ptr [RSP + 0x28]\nMOVZX ECX,byte ptr [RSP + 0x20]\nMOV byte ptr [RAX],CL\nMOV RAX,qword ptr [RSP + 0x28]\nDEC RAX\nMOV qword ptr [RSP + 0x28],RAX\nJMP LAB_2\nLAB_1:\nADD RSP,0x38\nRET", | |
| "c": "void reverse(char *s)\n{\n char *end = s + strlen(s) - 1;\n while (s < end) {\n char tmp = *s;\n *s++ = *end;\n *end-- = tmp;\n }\n}", | |
| "status": "pass", | |
| "seconds": 1.24 | |
| }, | |
| "msvc-x64-O2": { | |
| "asm": "MOV RAX,0xffffffffffffffff\nLAB_1:\nINC RAX\nCMP byte ptr [RCX + RAX],0\nJNE LAB_1\nLEA R8,[RCX + -1]\nADD R8,RAX\nCMP RCX,R8\nJAE LAB_2\nNOP dword ptr [RAX]\nLAB_3:\nMOVZX EAX,byte ptr [R8]\nMOVZX EDX,byte ptr [RCX]\nMOV byte ptr [RCX],AL\nINC RCX\nMOV byte ptr [R8],DL\nDEC R8\nCMP RCX,R8\nJB LAB_3\nLAB_2:\nRET", | |
| "c": "void reverse(char *s)\n{\n char *c,tmp;\n\n for(c=s+strlen(s)-1; s < c ;s++, c--){\n tmp=*s;\n *s=*c;\n *c=tmp;\n }\n}", | |
| "status": "pass", | |
| "seconds": 1.27 | |
| }, | |
| "msvc-x86-Od": { | |
| "asm": "PUSH EBP\nMOV EBP,ESP\nSUB ESP,8\nMOV EAX,dword ptr [EBP + 8]\nPUSH EAX\nCALL _strlen\nADD ESP,4\nMOV ECX,dword ptr [EBP + 8]\nLEA EDX,[ECX + EAX + -1]\nMOV dword ptr [EBP + -8],EDX\nLAB_2:\nMOV EAX,dword ptr [EBP + 8]\nCMP EAX,dword ptr [EBP + -8]\nJAE LAB_1\nMOV ECX,dword ptr [EBP + 8]\nMOV DL,byte ptr [ECX]\nMOV byte ptr [EBP + -1],DL\nMOV EAX,dword ptr [EBP + 8]\nMOV ECX,dword ptr [EBP + -8]\nMOV DL,byte ptr [ECX]\nMOV byte ptr [EAX],DL\nMOV EAX,dword ptr [EBP + 8]\nADD EAX,1\nMOV dword ptr [EBP + 8],EAX\nMOV ECX,dword ptr [EBP + -8]\nMOV DL,byte ptr [EBP + -1]\nMOV byte ptr [ECX],DL\nMOV EAX,dword ptr [EBP + -8]\nSUB EAX,1\nMOV dword ptr [EBP + -8],EAX\nJMP LAB_2\nLAB_1:\nMOV ESP,EBP\nPOP EBP\nRET", | |
| "c": "void reverse(char *s)\n{\n char *end = s + strlen(s) - 1;\n while (s < end) {\n char tmp = *s;\n *s++ = *end;\n *end-- = tmp;\n }\n}", | |
| "status": "pass", | |
| "seconds": 1.25 | |
| }, | |
| "msvc-x86-O2": { | |
| "asm": "MOV EAX,dword ptr [ESP + 4]\nMOV EDX,EAX\nPUSH ESI\nLEA ESI,[EDX + 1]\nNOP word ptr [EAX + EAX]\nLAB_1:\nMOV CL,byte ptr [EDX]\nINC EDX\nTEST CL,CL\nJNE LAB_1\nSUB EDX,ESI\nLEA ESI,[EAX + -1]\nADD ESI,EDX\nCMP EAX,ESI\nJAE LAB_2\nLAB_3:\nMOV CL,byte ptr [ESI]\nMOV DL,byte ptr [EAX]\nMOV byte ptr [EAX],CL\nINC EAX\nMOV byte ptr [ESI],DL\nDEC ESI\nCMP EAX,ESI\nJB LAB_3\nLAB_2:\nPOP ESI\nRET", | |
| "c": "void reverse(char *s)\n{\n int c, i, j;\n char *p;\n i = 0;\n j = strlen(s);\n p = s + i - 1;\n while (s < p) {\n c = *s;\n *s = *p;\n *p = c;\n s++;\n p--;\n }\n}", | |
| "status": "fail", | |
| "seconds": 1.74 | |
| }, | |
| "dos16-small-od": { | |
| "asm": "PUSH SI\nPUSH DI\nPUSH BP\nMOV BP,SP\nSUB SP,6\nMOV AX,word ptr [BP + 8]\nCALL strlen_\nADD AX,word ptr [BP + 8]\nDEC AX\nMOV word ptr [BP + + -4],AX\nJMP LAB_1\nLAB_1:\nMOV BX,word ptr [BP + 8]\nCMP BX,word ptr [BP + + -4]\nJB LAB_2\nJMP LAB_3\nLAB_2:\nMOV BX,word ptr [BP + 8]\nMOV AL,byte ptr [BX]\nMOV byte ptr [BP + + -2],AL\nMOV SI,word ptr [BP + 8]\nINC word ptr [BP + 8]\nMOV BX,word ptr [BP + + -4]\nMOV AL,byte ptr [BX]\nMOV byte ptr [SI],AL\nMOV BX,word ptr [BP + + -4]\nDEC word ptr [BP + + -4]\nMOV AL,byte ptr [BP + + -2]\nMOV byte ptr [BX],AL\nJMP LAB_1\nLAB_3:\nMOV SP,BP\nPOP BP\nPOP DI\nPOP SI\nRET", | |
| "c": "void reverse(char *s)\n{\n char *p = s + strlen(s) - 1;\n char c;\n while (s < p) {\n c = *s;\n *s++ = *p;\n *p-- = c;\n }\n}", | |
| "status": "pass", | |
| "seconds": 1.34 | |
| }, | |
| "dos16-large-ox": { | |
| "asm": "PUSH SI\nPUSH DI\nPUSH BP\nMOV BP,SP\nLDS BX,dword ptr [BP + 0xa]\nMOV AX,DS\nMOV DI,BX\nMOV ES,AX\nOR CX,0xffff\nXOR AX,AX\nREPNE scasb\nNOT CX\nDEC CX\nMOV SI,CX\nADD SI,BX\nDEC SI\nLAB_1:\nCMP BX,SI\nJAE LAB_2\nMOV AL,byte ptr [BX]\nMOV AH,byte ptr ES:[SI]\nMOV byte ptr [BX],AH\nINC BX\nMOV byte ptr ES:[SI],AL\nADD SI,0xffff\nJMP LAB_1\nLAB_2:\nPOP BP\nPOP DI\nPOP SI\nRETF", | |
| "c": "void reverse(char* str)\n{\n char* end = str + strlen(str) - 1;\n char tmp;\n for (char* start = str; start < end; start++, end--)\n {\n tmp = *start;\n *start = *end;\n *end = tmp;\n }\n}", | |
| "status": "pass", | |
| "seconds": 1.51 | |
| } | |
| } | |
| }, | |
| { | |
| "id": "is_prime", | |
| "title": "Primality test", | |
| "desc": "trial division up to the square root", | |
| "source": "int is_prime(int n) {\n int d;\n if (n < 2) return 0;\n for (d = 2; d * d <= n; d++)\n if (n % d == 0) return 0;\n return 1;\n}", | |
| "variants": { | |
| "msvc-x64-Od": { | |
| "asm": "MOV dword ptr [RSP + 8],ECX\nSUB RSP,0x18\nCMP dword ptr [RSP + 0x20],2\nJGE LAB_1\nXOR EAX,EAX\nJMP LAB_2\nLAB_1:\nMOV dword ptr [RSP],2\nJMP LAB_3\nLAB_6:\nMOV EAX,dword ptr [RSP]\nINC EAX\nMOV dword ptr [RSP],EAX\nLAB_3:\nMOV EAX,dword ptr [RSP]\nIMUL EAX,dword ptr [RSP]\nCMP EAX,dword ptr [RSP + 0x20]\nJG LAB_4\nMOV EAX,dword ptr [RSP + 0x20]\nCDQ\nIDIV EAX,dword ptr [RSP]\nMOV EAX,EDX\nTEST EAX,EAX\nJNE LAB_5\nXOR EAX,EAX\nJMP LAB_2\nLAB_5:\nJMP LAB_6\nLAB_4:\nMOV EAX,1\nLAB_2:\nADD RSP,0x18\nRET", | |
| "c": "bool is_prime(int n) {\n int i;\n\n if (n < 2)\n return false;\n\n for (i = 2; i * i <= n; i++) {\n if (n % i == 0)\n return false;\n }\n\n return true;\n}", | |
| "status": "pass", | |
| "seconds": 1.31 | |
| }, | |
| "msvc-x64-O2": { | |
| "asm": "CMP ECX,2\nJL LAB_1\nMOV R8D,2\nCMP ECX,4\nJL LAB_2\nLAB_3:\nMOV EAX,ECX\nCDQ\nIDIV EAX,R8D\nTEST EDX,EDX\nJE LAB_1\nINC R8D\nMOV EAX,R8D\nIMUL EAX,R8D\nCMP EAX,ECX\nJLE LAB_3\nLAB_2:\nMOV EAX,1\nRET\nLAB_1:\nXOR EAX,EAX\nRET", | |
| "c": "bool is_prime(int n) {\n int i;\n\n if (n < 2)\n return false;\n\n for (i = 2; i * i <= n; i++) {\n if (n % i == 0)\n return false;\n }\n\n return true;\n}", | |
| "status": "pass", | |
| "seconds": 1.31 | |
| }, | |
| "msvc-x86-Od": { | |
| "asm": "PUSH EBP\nMOV EBP,ESP\nPUSH ECX\nCMP dword ptr [EBP + 8],2\nJGE LAB_1\nXOR EAX,EAX\nJMP LAB_2\nLAB_1:\nMOV dword ptr [EBP + -4],2\nJMP LAB_3\nLAB_6:\nMOV EAX,dword ptr [EBP + -4]\nADD EAX,1\nMOV dword ptr [EBP + -4],EAX\nLAB_3:\nMOV ECX,dword ptr [EBP + -4]\nIMUL ECX,dword ptr [EBP + -4]\nCMP ECX,dword ptr [EBP + 8]\nJG LAB_4\nMOV EAX,dword ptr [EBP + 8]\nCDQ\nIDIV EAX,dword ptr [EBP + -4]\nTEST EDX,EDX\nJNE LAB_5\nXOR EAX,EAX\nJMP LAB_2\nLAB_5:\nJMP LAB_6\nLAB_4:\nMOV EAX,1\nLAB_2:\nMOV ESP,EBP\nPOP EBP\nRET", | |
| "c": "bool is_prime(int n) {\n int i;\n\n if (n < 2)\n return false;\n\n for (i = 2; i * i <= n; i++) {\n if (n % i == 0)\n return false;\n }\n\n return true;\n}", | |
| "status": "pass", | |
| "seconds": 1.32 | |
| }, | |
| "msvc-x86-O2": { | |
| "asm": "PUSH ESI\nMOV ESI,dword ptr [ESP + 8]\nCMP ESI,2\nJL LAB_1\nMOV ECX,2\nCMP ESI,4\nJL LAB_2\nLAB_3:\nMOV EAX,ESI\nCDQ\nIDIV EAX,ECX\nTEST EDX,EDX\nJE LAB_1\nINC ECX\nMOV EAX,ECX\nIMUL EAX,ECX\nCMP EAX,ESI\nJLE LAB_3\nLAB_2:\nMOV EAX,1\nPOP ESI\nRET\nLAB_1:\nXOR EAX,EAX\nPOP ESI\nRET", | |
| "c": "bool is_prime(int n) {\n int i;\n if (n < 2) return false;\n for (i = 2; i * i <= n; ++i)\n if (n % i == 0) return false;\n return true;\n}", | |
| "status": "pass", | |
| "seconds": 1.22 | |
| }, | |
| "dos16-small-od": { | |
| "asm": "PUSH SI\nPUSH DI\nPUSH BP\nMOV BP,SP\nSUB SP,4\nCMP word ptr [BP + 8],2\nJL LAB_1\nJMP LAB_2\nLAB_1:\nMOV word ptr [BP + + -4],0\nJMP LAB_3\nLAB_2:\nMOV word ptr [BP + + -2],2\nLAB_4:\nMOV AX,word ptr [BP + + -2]\nIMUL word ptr [BP + + -2]\nCMP AX,word ptr [BP + 8]\nJLE LAB_5\nJMP LAB_6\nLAB_5:\nMOV AX,word ptr [BP + 8]\nCWD\nIDIV word ptr [BP + + -2]\nTEST DX,DX\nJNE LAB_7\nMOV word ptr [BP + + -4],0\nJMP LAB_3\nLAB_7:\nINC word ptr [BP + + -2]\nJMP LAB_4\nLAB_6:\nMOV word ptr [BP + + -4],1\nLAB_3:\nMOV AX,word ptr [BP + + -4]\nMOV SP,BP\nPOP BP\nPOP DI\nPOP SI\nRET", | |
| "c": "bool is_prime(int n) {\n int divisor;\n\n if (n < 2)\n return false;\n\n for (divisor = 2; divisor * divisor <= n; divisor++)\n if (n % divisor == 0)\n return false;\n return true;\n}", | |
| "status": "pass", | |
| "seconds": 1.29 | |
| }, | |
| "dos16-large-ox": { | |
| "asm": "PUSH BP\nMOV BP,SP\nMOV CX,word ptr [BP + 6]\nCMP CX,2\nJL LAB_1\nMOV BX,2\nLAB_2:\nMOV AX,BX\nIMUL BX\nCMP AX,CX\nJG LAB_3\nMOV AX,CX\nCWD\nIDIV BX\nTEST DX,DX\nJE LAB_1\nINC BX\nJMP LAB_2\nLAB_1:\nXOR AX,AX\nPOP BP\nRETF\nLAB_3:\nMOV AX,1\nPOP BP\nRETF", | |
| "c": "bool is_prime(int n)\n{\n int i;\n\n if (n < 2)\n return false;\n\n for (i = 2; i * i <= n; i++)\n if (n % i == 0)\n return false;\n\n return true;\n}", | |
| "status": "pass", | |
| "seconds": 1.28 | |
| } | |
| } | |
| }, | |
| { | |
| "id": "checksum", | |
| "title": "XOR checksum", | |
| "desc": "bit operations and rotation", | |
| "source": "unsigned char checksum(const unsigned char *p, int n) {\n unsigned char c = 0;\n while (n--) c = (unsigned char)(((c << 1) | (c >> 7)) ^ *p++);\n return c;\n}", | |
| "variants": { | |
| "msvc-x64-Od": { | |
| "asm": "MOV dword ptr [RSP + 0x10],EDX\nMOV qword ptr [RSP + 8],RCX\nSUB RSP,0x18\nMOV byte ptr [RSP],0\nLAB_2:\nMOV EAX,dword ptr [RSP + 0x28]\nMOV dword ptr [RSP + 4],EAX\nMOV EAX,dword ptr [RSP + 0x28]\nDEC EAX\nMOV dword ptr [RSP + 0x28],EAX\nCMP dword ptr [RSP + 4],0\nJE LAB_1\nMOVZX EAX,byte ptr [RSP]\nSHL EAX,1\nMOVZX ECX,byte ptr [RSP]\nSAR ECX,7\nOR EAX,ECX\nMOV RCX,qword ptr [RSP + 0x20]\nMOVZX ECX,byte ptr [RCX]\nXOR EAX,ECX\nMOV byte ptr [RSP],AL\nMOV RAX,qword ptr [RSP + 0x20]\nINC RAX\nMOV qword ptr [RSP + 0x20],RAX\nJMP LAB_2\nLAB_1:\nMOVZX EAX,byte ptr [RSP]\nADD RSP,0x18\nRET", | |
| "c": "uint32_t\ncrc32(const unsigned char *buf, unsigned int len)\n{\n uint32_t crc = 0;\n while (len--)\n crc = (crc << 1) | (crc >> 7) ^ *buf++;\n return crc;\n}", | |
| "status": "fail", | |
| "seconds": 1.15 | |
| }, | |
| "msvc-x64-O2": { | |
| "asm": "XOR AL,AL\nTEST EDX,EDX\nJE LAB_1\nNOP word ptr [RAX + RAX + 0x0]\nLAB_2:\nROL AL,1\nXOR AL,byte ptr [RCX]\nLEA RCX,[RCX + 1]\nSUB EDX,1\nJNE LAB_2\nLAB_1:\nRET", | |
| "c": "unsigned char\ncrc8(const unsigned char *buf, int len)\n{\n unsigned char crc = 0;\n\n while (len--)\n crc = crc >> 1 ^ *buf++;\n return crc;\n}", | |
| "status": "fail", | |
| "seconds": 1.0 | |
| }, | |
| "msvc-x86-Od": { | |
| "asm": "PUSH EBP\nMOV EBP,ESP\nSUB ESP,8\nMOV byte ptr [EBP + -1],0\nLAB_2:\nMOV EAX,dword ptr [EBP + 0xc]\nMOV dword ptr [EBP + -8],EAX\nMOV ECX,dword ptr [EBP + 0xc]\nSUB ECX,1\nMOV dword ptr [EBP + 0xc],ECX\nCMP dword ptr [EBP + -8],0\nJE LAB_1\nMOVZX EDX,byte ptr [EBP + -1]\nSHL EDX,1\nMOVZX EAX,byte ptr [EBP + -1]\nSAR EAX,7\nOR EDX,EAX\nMOV ECX,dword ptr [EBP + 8]\nMOVZX EAX,byte ptr [ECX]\nXOR EDX,EAX\nMOV byte ptr [EBP + -1],DL\nMOV ECX,dword ptr [EBP + 8]\nADD ECX,1\nMOV dword ptr [EBP + 8],ECX\nJMP LAB_2\nLAB_1:\nMOVZX EAX,byte ptr [EBP + -1]\nMOV ESP,EBP\nPOP EBP\nRET", | |
| "c": "uint32_t\ncrc32(unsigned char *buf, size_t len)\n{\n uint32_t crc = 0;\n\n while (len--) {\n crc = (crc << 1) | (crc >> 7);\n buf++;\n }\n\n return crc;\n}", | |
| "status": "fail", | |
| "seconds": 1.17 | |
| }, | |
| "msvc-x86-O2": { | |
| "asm": "MOV ECX,dword ptr [ESP + 8]\nXOR AL,AL\nTEST ECX,ECX\nJE LAB_1\nMOV EDX,dword ptr [ESP + 4]\nNOP\nLAB_2:\nROL AL,1\nLEA EDX,[EDX + 1]\nXOR AL,byte ptr [EDX + -1]\nSUB ECX,1\nJNE LAB_2\nLAB_1:\nRET", | |
| "c": "unsigned char\ncrc8(const unsigned char *buf, size_t len)\n{\n unsigned char crc = 0;\n\n while (len--)\n crc = crc >> 1 ^ *buf++;\n return crc;\n}", | |
| "status": "fail", | |
| "seconds": 1.01 | |
| }, | |
| "dos16-small-od": { | |
| "asm": "PUSH SI\nPUSH DI\nPUSH BP\nMOV BP,SP\nSUB SP,4\nMOV byte ptr [BP + + -2],0\nLAB_1:\nDEC word ptr [BP + 0xa]\nCMP word ptr [BP + 0xa],0xffff\nJE LAB_2\nJMP LAB_3\nLAB_2:\nJMP LAB_4\nLAB_3:\nMOV AL,byte ptr [BP + + -2]\nXOR AH,AH\nSHL AX,1\nMOV BX,AX\nMOV AL,byte ptr [BP + + -2]\nXOR AH,AH\nMOV CL,7\nSAR AX,CL\nOR BX,AX\nMOV DX,BX\nMOV BX,word ptr [BP + 8]\nINC word ptr [BP + 8]\nMOV AL,byte ptr [BX]\nXOR AH,AH\nXOR AX,DX\nMOV byte ptr [BP + + -2],AL\nJMP LAB_1\nLAB_4:\nMOV AL,byte ptr [BP + + -2]\nMOV byte ptr [BP + + -4],AL\nMOV AL,byte ptr [BP + + -4]\nMOV SP,BP\nPOP BP\nPOP DI\nPOP SI\nRET", | |
| "c": "uint32_t\ncrc32(const unsigned char *buf, unsigned int len)\n{\n uint32_t crc = 0;\n while (len--)\n crc = (crc << 1) | (crc >> 7);\n return crc;\n}", | |
| "status": "fail", | |
| "seconds": 1.08 | |
| }, | |
| "dos16-large-ox": { | |
| "asm": "PUSH BP\nMOV BP,SP\nLDS BX,dword ptr [BP + 6]\nMOV DX,word ptr [BP + 0xa]\nXOR AL,AL\nLAB_1:\nDEC DX\nCMP DX,0xffff\nJE LAB_2\nXOR AH,AH\nMOV CX,AX\nADD CX,AX\nSAR AX,7\nOR CX,AX\nMOV AL,byte ptr [BX]\nXOR AH,AH\nINC BX\nXOR AX,CX\nJMP LAB_1\nLAB_2:\nPOP BP\nRETF", | |
| "c": "uint16_t crc16(const unsigned char *data, unsigned int length)\n{\n uint16_t crc = 0;\n\n while (length--)\n crc = (crc << 1) | (crc >> 7);\n\n return crc;\n}", | |
| "status": "fail", | |
| "seconds": 1.04 | |
| } | |
| } | |
| }, | |
| { | |
| "id": "classify", | |
| "title": "Character class", | |
| "desc": "switch / branching on ranges", | |
| "source": "int classify(int c) {\n if (c >= '0' && c <= '9') return 1;\n if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) return 2;\n switch (c) {\n case ' ': case '\\t': case '\\n': return 3;\n default: return 0;\n }\n}", | |
| "variants": { | |
| "msvc-x64-Od": { | |
| "asm": "MOV dword ptr [RSP + 8],ECX\nSUB RSP,0x18\nCMP dword ptr [RSP + 0x20],0x30\nJL LAB_1\nCMP dword ptr [RSP + 0x20],0x39\nJG LAB_1\nMOV EAX,1\nJMP LAB_2\nLAB_1:\nCMP dword ptr [RSP + 0x20],0x61\nJL LAB_3\nCMP dword ptr [RSP + 0x20],0x7a\nJLE LAB_4\nLAB_3:\nCMP dword ptr [RSP + 0x20],0x41\nJL LAB_5\nCMP dword ptr [RSP + 0x20],0x5a\nJG LAB_5\nLAB_4:\nMOV EAX,2\nJMP LAB_2\nLAB_5:\nMOV EAX,dword ptr [RSP + 0x20]\nMOV dword ptr [RSP],EAX\nCMP dword ptr [RSP],9\nJE LAB_6\nCMP dword ptr [RSP],0xa\nJE LAB_6\nCMP dword ptr [RSP],0x20\nJE LAB_6\nJMP LAB_7\nLAB_6:\nMOV EAX,3\nJMP LAB_2\nLAB_7:\nXOR EAX,EAX\nLAB_2:\nADD RSP,0x18\nRET", | |
| "c": "int\nam_util_isspace (int c)\n{\n if (c >= '0' && c <= '9')\n return 1;\n if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')\n return 2;\n\n switch (c)\n {\n case '\\n':\n case '\\t':\n case '\\v':\n return 3;\n }\n\n return 0;\n}", | |
| "status": "fail", | |
| "seconds": 2.04 | |
| }, | |
| "msvc-x64-O2": { | |
| "asm": "LEA EAX,[RCX + -0x30]\nCMP EAX,9\nJA LAB_1\nMOV EAX,1\nRET\nLAB_1:\nLEA EAX,[RCX + -0x61]\nCMP EAX,0x19\nJBE LAB_2\nLEA EAX,[RCX + -0x41]\nCMP EAX,0x19\nJBE LAB_2\nSUB ECX,9\nJE LAB_3\nSUB ECX,1\nJE LAB_3\nCMP ECX,0x16\nJE LAB_3\nXOR EAX,EAX\nRET\nLAB_3:\nMOV EAX,3\nRET\nLAB_2:\nMOV EAX,2\nRET", | |
| "c": "int\nam_util_char_to_num(int c)\n{\n if ((c >= '0') && (c <= '9')) {\n return 1;\n }\n if ((c >= 'a') && (c <= 'z')) {\n return 2;\n }\n if ((c >= 'A') && (c <= 'Z')) {\n return 2;\n }\n switch (c) {\n case ' ':\n case '\\t':\n case '\\n':\n case '\\r':\n case '\\0':\n return 3;\n }\n return 0;\n}", | |
| "status": "pass", | |
| "seconds": 2.63 | |
| }, | |
| "msvc-x86-Od": { | |
| "asm": "PUSH EBP\nMOV EBP,ESP\nPUSH ECX\nCMP dword ptr [EBP + 8],0x30\nJL LAB_1\nCMP dword ptr [EBP + 8],0x39\nJG LAB_1\nMOV EAX,1\nJMP LAB_2\nLAB_1:\nCMP dword ptr [EBP + 8],0x61\nJL LAB_3\nCMP dword ptr [EBP + 8],0x7a\nJLE LAB_4\nLAB_3:\nCMP dword ptr [EBP + 8],0x41\nJL LAB_5\nCMP dword ptr [EBP + 8],0x5a\nJG LAB_5\nLAB_4:\nMOV EAX,2\nJMP LAB_2\nLAB_5:\nMOV EAX,dword ptr [EBP + 8]\nMOV dword ptr [EBP + -4],EAX\nCMP dword ptr [EBP + -4],9\nJE LAB_6\nCMP dword ptr [EBP + -4],0xa\nJE LAB_6\nCMP dword ptr [EBP + -4],0x20\nJE LAB_6\nJMP LAB_7\nLAB_6:\nMOV EAX,3\nJMP LAB_2\nLAB_7:\nXOR EAX,EAX\nLAB_2:\nMOV ESP,EBP\nPOP EBP\nRET", | |
| "c": "int\nam_util_isspace(int c)\n{\n if (c >= '0' && c <= '9') {\n return 1;\n }\n if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z') {\n return 2;\n }\n switch (c) {\n case '\\n':\n case '\\t':\n case '\\v':\n return 3;\n }\n return 0;\n}", | |
| "status": "fail", | |
| "seconds": 2.14 | |
| }, | |
| "msvc-x86-O2": { | |
| "asm": "MOV ECX,dword ptr [ESP + 4]\nLEA EAX,[ECX + -0x30]\nCMP EAX,9\nJA LAB_1\nMOV EAX,1\nRET\nLAB_1:\nCMP ECX,0x61\nJL LAB_2\nCMP ECX,0x7a\nJLE LAB_3\nLAB_2:\nLEA EAX,[ECX + -0x41]\nCMP EAX,0x19\nJA LAB_4\nLAB_3:\nMOV EAX,2\nRET\nLAB_4:\nSUB ECX,9\nJE LAB_5\nSUB ECX,1\nJE LAB_5\nSUB ECX,0x16\nJE LAB_5\nXOR EAX,EAX\nRET\nLAB_5:\nMOV EAX,3\nRET", | |
| "c": "int\nam_util_char_to_num(int c)\n{\n if ((c >= '0') && (c <= '9')) {\n return 1;\n }\n if ((c >= 'a') && (c <= 'z')) {\n return 2;\n }\n if ((c >= 'A') && (c <= 'Z')) {\n return 2;\n }\n switch (c) {\n case ' ':\n case '\\t':\n case '\\n':\n case '\\a':\n case '\\r':\n case '\\v':\n case '\\f':\n case '\\v':\n return 3;\n }\n return 0;\n}", | |
| "status": "compile_error", | |
| "seconds": 2.95 | |
| }, | |
| "dos16-small-od": { | |
| "asm": "PUSH SI\nPUSH DI\nPUSH BP\nMOV BP,SP\nSUB SP,2\nCMP word ptr [BP + 8],0x30\nJGE LAB_1\nJMP LAB_2\nLAB_1:\nCMP word ptr [BP + 8],0x39\nJLE LAB_3\nLAB_2:\nJMP LAB_4\nLAB_3:\nMOV word ptr [BP + + -2],1\nJMP LAB_5\nLAB_4:\nCMP word ptr [BP + 8],0x61\nJL LAB_6\nCMP word ptr [BP + 8],0x7a\nJG LAB_6\nJMP LAB_7\nLAB_6:\nCMP word ptr [BP + 8],0x41\nJL LAB_8\nCMP word ptr [BP + 8],0x5a\nJLE LAB_7\nLAB_8:\nJMP LAB_9\nLAB_7:\nMOV word ptr [BP + + -2],2\nJMP LAB_5\nLAB_9:\nCMP word ptr [BP + 8],0x20\nJNE LAB_10\nJMP LAB_11\nLAB_10:\nCMP word ptr [BP + 8],9\nJB LAB_12\nCMP word ptr [BP + 8],0xa\nJA LAB_13\nJMP LAB_11\nLAB_13:\nJMP LAB_14\nLAB_12:\nJMP LAB_14\nLAB_11:\nMOV word ptr [BP + + -2],3\nJMP LAB_5\nLAB_14:\nMOV word ptr [BP + + -2],0\nLAB_5:\nMOV AX,word ptr [BP + + -2]\nMOV SP,BP\nPOP BP\nPOP DI\nPOP SI\nRET", | |
| "c": "int\nam_util_isspace(int c)\n{\n if (c >= '0' && c <= '9') {\n return 1;\n }\n if (c >= 'a' && c <= 'z') {\n return 2;\n }\n if (c >= 'A' && c <= 'Z') {\n return 2;\n }\n if (c == ' ') {\n return 3;\n }\n if (c >= '\\t' && c <= '\\n') {\n return 3;\n }\n return 0;\n}", | |
| "status": "pass", | |
| "seconds": 2.53 | |
| }, | |
| "dos16-large-ox": { | |
| "asm": "PUSH BP\nMOV BP,SP\nMOV AX,word ptr [BP + 6]\nCMP AX,0x30\nJL LAB_1\nCMP AX,0x39\nJLE LAB_2\nLAB_1:\nCMP AX,0x61\nJL LAB_3\nCMP AX,0x7a\nJLE LAB_4\nLAB_3:\nCMP AX,0x41\nJL LAB_5\nCMP AX,0x5a\nJLE LAB_4\nLAB_5:\nCMP AX,0x20\nJE LAB_6\nCMP AX,9\nJB LAB_7\nCMP AX,0xa\nJA LAB_7\nLAB_6:\nMOV AX,3\nPOP BP\nRETF\nLAB_2:\nMOV AX,1\nPOP BP\nRETF\nLAB_4:\nMOV AX,2\nPOP BP\nRETF\nLAB_7:\nXOR AX,AX\nPOP BP\nRETF", | |
| "c": "int\nam_util_isspace(int c)\n{\n if (c >= '0' && c <= '9') {\n return 1;\n }\n if (c >= 'a' && c <= 'z') {\n return 2;\n }\n if (c >= 'A' && c <= 'Z') {\n return 2;\n }\n if (c == ' ' || (c >= '\\t' && c <= '\\n')) {\n return 3;\n }\n return 0;\n}", | |
| "status": "pass", | |
| "seconds": 2.34 | |
| } | |
| } | |
| }, | |
| { | |
| "id": "count_bits", | |
| "title": "Count set bits", | |
| "desc": "shifts and masking", | |
| "source": "int count_bits(unsigned x) {\n int n = 0;\n while (x) { n += x & 1; x >>= 1; }\n return n;\n}", | |
| "variants": { | |
| "msvc-x64-Od": { | |
| "asm": "MOV dword ptr [RSP + 8],ECX\nSUB RSP,0x18\nMOV dword ptr [RSP],0\nLAB_2:\nCMP dword ptr [RSP + 0x20],0\nJE LAB_1\nMOV EAX,dword ptr [RSP + 0x20]\nAND EAX,1\nMOV ECX,dword ptr [RSP]\nADD ECX,EAX\nMOV EAX,ECX\nMOV dword ptr [RSP],EAX\nMOV EAX,dword ptr [RSP + 0x20]\nSHR EAX,1\nMOV dword ptr [RSP + 0x20],EAX\nJMP LAB_2\nLAB_1:\nMOV EAX,dword ptr [RSP]\nADD RSP,0x18\nRET", | |
| "c": "int hammingWeight(unsigned n) {\n int result = 0;\n while (n) {\n result += n & 0x01;\n n >>= 1;\n }\n return result;\n}", | |
| "status": "pass", | |
| "seconds": 0.94 | |
| }, | |
| "msvc-x64-O2": { | |
| "asm": "XOR EAX,EAX\nTEST ECX,ECX\nJE LAB_1\nNOP word ptr [RAX + RAX + 0x0]\nLAB_2:\nMOV EDX,ECX\nAND EDX,1\nADD EAX,EDX\nSHR ECX,1\nJNE LAB_2\nLAB_1:\nRET", | |
| "c": "int hammingWeight(uint32_t n) {\n\n int count = 0;\n for (; n; n >>= 1) {\n count += n & 1;\n }\n return count;\n}", | |
| "status": "pass", | |
| "seconds": 0.9 | |
| }, | |
| "msvc-x86-Od": { | |
| "asm": "PUSH EBP\nMOV EBP,ESP\nPUSH ECX\nMOV dword ptr [EBP + -4],0\nLAB_2:\nCMP dword ptr [EBP + 8],0\nJE LAB_1\nMOV EAX,dword ptr [EBP + 8]\nAND EAX,1\nADD EAX,dword ptr [EBP + -4]\nMOV dword ptr [EBP + -4],EAX\nMOV ECX,dword ptr [EBP + 8]\nSHR ECX,1\nMOV dword ptr [EBP + 8],ECX\nJMP LAB_2\nLAB_1:\nMOV EAX,dword ptr [EBP + -4]\nMOV ESP,EBP\nPOP EBP\nRET", | |
| "c": "int bits_32( uint32_t i )\n{\n int r = 0;\n while (i) {\n r += i & 1;\n i >>= 1;\n }\n return r;\n}", | |
| "status": "pass", | |
| "seconds": 0.93 | |
| }, | |
| "msvc-x86-O2": { | |
| "asm": "MOV EDX,dword ptr [ESP + 4]\nXOR EAX,EAX\nTEST EDX,EDX\nJE LAB_1\nNOP word ptr [EAX + EAX]\nLAB_2:\nMOV ECX,EDX\nAND ECX,1\nADD EAX,ECX\nSHR EDX,1\nJNE LAB_2\nLAB_1:\nRET", | |
| "c": "int hammingWeight(uint32_t n) {\n\n int count = 0;\n for (; n; n >>= 1) {\n count += n & 1;\n }\n return count;\n}", | |
| "status": "pass", | |
| "seconds": 0.9 | |
| }, | |
| "dos16-small-od": { | |
| "asm": "PUSH SI\nPUSH DI\nPUSH BP\nMOV BP,SP\nSUB SP,4\nMOV word ptr [BP + + -2],0\nLAB_1:\nCMP word ptr [BP + 8],0\nJE LAB_2\nJMP LAB_3\nLAB_2:\nJMP LAB_4\nLAB_3:\nMOV AX,word ptr [BP + 8]\nAND AX,1\nADD word ptr [BP + + -2],AX\nSHR word ptr [BP + 8],1\nJMP LAB_1\nLAB_4:\nMOV AX,word ptr [BP + + -2]\nMOV word ptr [BP + + -4],AX\nMOV AX,word ptr [BP + + -4]\nMOV SP,BP\nPOP BP\nPOP DI\nPOP SI\nRET", | |
| "c": "int bit_count(unsigned int x)\n{\n int count = 0;\n while (x)\n {\n count += x & 1;\n x >>= 1;\n }\n return count;\n}", | |
| "status": "pass", | |
| "seconds": 0.94 | |
| }, | |
| "dos16-large-ox": { | |
| "asm": "PUSH BP\nMOV BP,SP\nMOV AX,word ptr [BP + 6]\nXOR DX,DX\nLAB_1:\nTEST AX,AX\nJE LAB_2\nMOV BX,AX\nXOR BH,AH\nAND BL,1\nSHR AX,1\nADD DX,BX\nJMP LAB_1\nLAB_2:\nMOV AX,DX\nPOP BP\nRETF", | |
| "c": "int hammingWeight(uint32_t n) {\n\n int count = 0;\n while (n) {\n count += n & 0x01;\n n >>= 1;\n }\n return count;\n}", | |
| "status": "pass", | |
| "seconds": 0.92 | |
| } | |
| } | |
| } | |
| ] | |
| } |