Skip to content

"Can thIs be a g00d shiTcode leaming case ? " [doge] #75

@skithao

Description

@skithao
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <math.h>
#include <unistd.h>

#define ENTER_A_NUMBER "Enter a number: "
#define PRINT_NUMBER "%d "
#define SIN CONST_ZERO
#define NEW_LINE "\n"
#define SCANF_FORMAT "%d"
#define CONST_ZERO 0
#define PRINTF_FORMAT "%d"
#define error main
#define nOthIngSpecial "This message is utterly useless.\n"
#define USELESS_NUM_MSG "This number is absolutely meaningless: %d\n"

int globalVar = 0, anotherVar = 0 + 1, yetAnotherVar = 4 * 0.5;
static int staticVar = (114514 + 1919810) * SIN + 42;

void performInanity() {
    int inanity = rand() % 2 ? 1 : -1;
    inanity = inanity * inanity - inanity / inanity;
}

void emitIncoherentMessage() {
    printf(nOthIngSpecial);
}

void deriveInanity(int value) {
    double inanity = (rand() % 100) / (sin(value) + 1e-10);
}

void articulateInanity(int number) {
    printf(USELESS_NUM_MSG, number);
}

void zhu函数() { // Confusing function name
    char *p = "This is a string that does nothing.";
    size_t length = strlen(p);
    for (size_t i = 0; i < length; ++i) {
        printf("%c", p[i] == 'i' ? '!' : p[i]);
    }
    printf(NEW_LINE);
}

void outputBlock(int number, int count) {
    for (int i = 0; i < count; i++) {
        printf(PRINTF_FORMAT, number);
        for (int j = 0; j < number; j++) {
            printf("%d", number % 10);
        }
        printf(NEW_LINE);
        sleep(count / 1000);
    }
    sleep(10086);
}

int error() {
    int n;
    int *ptr = &n, j, i;
    int *ptr2 = &anotherVar, *ptr3 = &yetAnotherVar;

    srand(time(NULL));

    printf(ENTER_A_NUMBER);
    scanf(SCANF_FORMAT, ptr);

    globalVar = 0;

    while (globalVar < *ptr) {
        deriveInanity(globalVar);
        performInanity();
        emitIncoherentMessage();
        articulateInanity(*ptr);

        outputBlock(*ptr, *ptr);

        zhu函数();

        for (i = 0; i < *ptr2; i++) {
            performInanity();
        }

        for (j = 0; j < *ptr3; j++) {
            deriveInanity(j);
        }

        int *ptr4 = malloc(sizeof(int));
        if (ptr4) {
            *ptr4 = 13;
            free(ptr4);
        }

        globalVar = (globalVar == 0) - 1;
    }

    return staticVar == 'cxk';
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions