This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open Core | |
| let () = | |
| let unit_str = "y\n" and unit_str_len = 2 in | |
| let buf = Buffer.create 0 in | |
| let rec print_endlessly () = | |
| Out_channel.output_buffer stdout buf; | |
| print_endlessly () | |
| in | |
| let rec grow_buf () = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * gcc -Wall -Wextra -fstack-protector-explicit k.c | |
| * | |
| * lix@ipass-lix01 /tmp % time ./a.out 0 | |
| * ./a.out 0 4.73s user 0.02s system 99% cpu 4.763 total | |
| * lix@ipass-lix01 /tmp % time ./a.out 1 | |
| * ./a.out 1 5.60s user 0.02s system 99% cpu 5.648 total | |
| * | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <limits.h> | |
| void array_access0(void) | |
| { | |
| int a[10]; | |
| int i; | |
| for (i = 0; i < 10; ++i) { | |
| a[i] = 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (use-modules (ice-9 binary-ports) | |
| (rnrs bytevectors)) | |
| (define (build-string s n) | |
| (let* ((s2 (string-append s "\n")) | |
| (s2len (string-length s2))) | |
| (let A ((s3 (string-copy s2)) | |
| (s3len s2len)) | |
| (if (> (+ s3len s2len) n) | |
| s3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdbool.h> | |
| #include <ctype.h> | |
| #include <string.h> | |
| typedef struct { | |
| char hr1; | |
| char hr2; | |
| char delim1; | |
| char min1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #define SWAP(a, b) \ | |
| do { \ | |
| typeof(a) SWAP = a; \ | |
| a = b; \ | |
| b = SWAP; \ | |
| } while (0) | |
| void dump_array(FILE *stream, int *arr, int arr_size) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| class A { | |
| public: | |
| A(){print();} | |
| virtual print(){cout << "in A"<<endl;} | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // With sub %rsp, 0x10, because plus1() called min1(). | |
| int min1(int a, int b) { | |
| return (a - b); | |
| } | |
| int plus1(int a, int b, int c) { | |
| return (a + min1(b, c)); | |
| } | |
| // Without sub %rsp, 0x10, because plus1() doesn't call any procedure. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| int main(void) { | |
| int criedForLesMiserables = 0; | |
| for (int i = 1; i < 10; i++) { | |
| printf("criedForLesMiserables = %d\n", criedForLesMiserables); | |
| criedForLesMiserables += i; | |
| } | |
| return 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .text | |
| .globl _start | |
| _start: | |
| mov $1, %eax | |
| mov $5, %ebx | |
| int $0x80 | |
| # as -o /tmp/hello.o hello.s && ld -o /tmp/hello /tmp/hello.o |