Skip to content

Instantly share code, notes, and snippets.

@TruncatedDinoSour
Last active November 6, 2023 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TruncatedDinoSour/19f92820713b7b0b5770ea4d9e888519 to your computer and use it in GitHub Desktop.
Save TruncatedDinoSour/19f92820713b7b0b5770ea4d9e888519 to your computer and use it in GitHub Desktop.
cody .
#include <time.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#define MIN_VAL 5
#define MAX_VAL 50
static void swap(char *x, char *y) {
char c = *x;
*x = *y;
*y = c;
}
static void slowsort(char *buf, size_t left, size_t right) {
size_t mid;
if (left >= right)
return;
mid = left + (right - left) / 2;
slowsort(buf, left, mid);
slowsort(buf, mid + 1, right);
if (buf[mid] > buf[right])
swap(&buf[mid], &buf[right]);
slowsort(buf, left, right - 1);
}
static void sort(char *buf, size_t len) { slowsort(buf, 0, len - 1); }
static char *cody_by_size(size_t len) {
if (len <= MIN_VAL)
return "^w^";
else if (len <= (MAX_VAL / 3))
return "^-^";
else if (len <= (MAX_VAL / 2))
return "O~O";
else
return "x~x";
}
int main(void) {
char *buf;
size_t len, total = 0;
srand(time(NULL));
setbuf(stdout, NULL);
puts("\\(^-^) Hey, I'm cody!");
sleep(3);
puts(",(o~o), Soon, I won't be so well... Gigabytes of data will go "
"through me...");
sleep(2);
puts("(,-,) Here we go I guess.");
sleep(1);
do {
len = (rand() % (MAX_VAL - MIN_VAL + 1)) + MIN_VAL;
total += len;
buf = malloc(len);
printf("\r~(%s)~ There's currently %zu bytes being fed through me. In "
"total %zu bytes were fed through me.",
cody_by_size(len), len, total);
sort(buf, len);
free(buf);
} while (1);
return 0;
}
#include <time.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#define MIN_VAL 5000
#define MAX_VAL 50000
static void bullshit_sort(char *buf, size_t len) {
size_t idx, jdx, kdx;
char tmp;
for (kdx = 0; kdx < len; ++kdx) {
for (idx = 0; idx < len; ++idx) {
for (jdx = 0; jdx < len - idx; ++idx) {
if (buf[jdx] > buf[jdx + 1]) {
tmp = buf[jdx];
buf[jdx] = buf[jdx + 1];
buf[jdx + 1] = tmp;
}
}
}
}
}
static char *cody_by_size(size_t len) {
if (len <= MIN_VAL)
return "^w^";
else if (len <= (MAX_VAL / 3))
return "^-^";
else if (len <= (MAX_VAL / 2))
return "O~O";
else
return "x~x";
}
int main(void) {
char *buf;
size_t len, total = 0;
srand(time(NULL));
setbuf(stdout, NULL);
puts("\\(^-^) Hey, I'm cody!");
sleep(3);
puts(",(o~o), Soon, I won't be so well... Gigabytes of data will go "
"through me...");
sleep(2);
puts("(,-,) Here we go I guess.");
sleep(1);
do {
len = (rand() % (MAX_VAL - MIN_VAL + 1)) + MIN_VAL;
total += len;
buf = malloc(len);
printf("\r~(%s)~ There's currently %zu bytes being fed through me. In "
"total %zu bytes were fed through me.",
cody_by_size(len), len, total);
bullshit_sort(buf, len);
free(buf);
} while (1);
return 0;
}
@TruncatedDinoSour
Copy link
Author

its too fast, this is why c sucks, use rust, 10 mb hello world ftw

@TruncatedDinoSour
Copy link
Author

this is why i hate c, its too fast and too small, fuck c, use rust, i need my binaries to b 10 mb AT LEAST
( custom cflags and stripflags using llvm toolchain )
image

@TruncatedDinoSour
Copy link
Author

export STRIP=llvm-strip
export STRIPFLAGS='--strip-debug --strip-sections --strip-unneeded -T --remove-section=.note.gnu.gold-version --remove-section=.note --strip-all --discard-locals --remove-section=.gnu.version --remove-section=.eh_frame --remove-section=.note.gnu.build-id --remove-section=.note.ABI-tag --strip-symbol=__gmon_start__ --strip-all-gnu --remove-section=.comment --remove-section=.eh_frame_ptr --discard-all'
export CC=clang
export CFLAGS='-Wpedantic -flto=full -Wl,--no-allow-shlib-undefined -fno-trapping-math -fstrict-aliasing -fno-math-errno -fno-stack-check -fno-strict-overflow -Wl,--gc-sections -fno-rtti -funroll-loops -Wl,--no-whole-archive -fno-stack-protector -fvisibility-inlines-hidden -mfancy-math-387 -Wl,--sort-section=alignment -fomit-frame-pointer -Wl,--strip-all -Wl,--strip-debug -fstrict-overflow -Wshadow -fuse-ld=lld -s -fno-exceptions -D_FORTIFY_SOURCE=0 -Wall -Wl,--no-as-needed -Wl,--discard-all -Wextra -fno-signed-zeros -fno-strict-aliasing -pedantic -Ofast -fvisibility=hidden -ffast-math -funsafe-math-optimizations -Wl,--icf=all -std=c89 -fno-asynchronous-unwind-tables -Werror -Wl,--build-id=none -fdiscard-value-names -femit-all-decls -fmerge-all-constants -fno-use-cxa-atexit -fno-use-init-array -march=native -mtune=native'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment