#include <unistd.h>
#include <time.h>

// Helper function to convert a long long integer to a string
int int_to_str(long long num, char *buf, int max_len) {
	if (max_len <= 0) return 0;

    // Handle 0 explicitly
	if (num == 0) {
		buf[0] = '0';
		return 1;
	}

    	char temp[32];
    	int i = 0;

    	while (num > 0 && i < sizeof(temp)) {
        	temp[i++] = (num % 10) + '0';
        	num /= 10;
    	}

    // Reverse the string into the buffer
    	int len = 0;
    	while (i > 0 && len < max_len - 1) {
        	buf[len++] = temp[--i];
    	}
    	buf[len] = '\0';
    	return len;
}

int main() {
	time_t result = time(NULL);
    	char buffer[128];

    // Build the output string manually
    	char *p = buffer;

    // Copy prefix "\nUnix Timestamp: "
    	const char *prefix = "\nUnix Timestamp: ";
    	while (*prefix) {
        	*p++ = *prefix++;
    	}

    // Convert timestamp to string and append
    	int num_len = int_to_str((long long)result, p, sizeof(buffer) - (p - buffer));
    	p += num_len;

    // Copy suffix "\n\n"
    	const char *suffix = "\n\n";
    	while (*suffix) {
        	*p++ = *suffix++;
    	}

    // Calculate total length and write to stdout (fd 1)
    	write(1, buffer, p - buffer);

    	return 0;
}
