#include <stdio.h>



int main(void) {
	printf("{7, 5, 4, 3, 1}: %d\r\n", f(5, (int[]) {7, 5, 4, 3, 1}));
	printf("{42, 41}: %d\r\n", f(2, (int[]) {42, 41}));
	printf("{5}: %d\r\n", f(1, (int[]) {5}));
	printf("{27, 19, 19, 10, 3}: %d\r\n", f(5, (int[]) {27, 19, 19, 10, 3}));
	printf("{6, 4, 2, 2, 2}: %d\r\n", f(5, (int[]) {6, 4, 2, 2, 2}));
	printf("{9, 9, 9, 9}: %d\r\n", f(4, (int[]) {9, 9, 9, 9}));
	printf("{1, 2, 3, 2}: %d\r\n", f(4, (int[]) {1, 2, 3, 2}));
	printf("{10, 9, 8, 7, 12}: %d\r\n", f(5, (int[]) {10, 9, 8, 7, 12}));
	printf("{4, 6, 4, 4, 2}: %d\r\n", f(5, (int[]) {4, 6, 4, 4, 2}));
	return 0;
}

f(int n,int*l){return n<2?3:((l[0]>l[1])*2|l[0]>=l[1])&f(n-1,l+1);}

int f_semiungolfed(int n, int* l) {
	 return (n < 2) ? 3 : ((l[0] > l[1]) * 2 | l[0] >= l[1]) & f(n - 1, l + 1);
}

int f_ungolfed(int n, int* l) {
	int case1 = 0, case2 = 0, recursion = 0;
	if (n < 2) { // Analogous to the ternary conditional I used - n < 2 means we have a single-element/empty list
		return 3; // Handles the vacuous-truth scenario for single lists
	} else {
		case1 = l[0] > l[1]; // The first case - are the two numbers in the list strictly decreasing? (case1 is 1 if so)
		case2 = l[0] >= l[1]; // The second case - are the two numbers strictly non-increasing (case2 is 1 if so)
		recursion = f_ungolfed(n - 1, l + 1); // Recursively call ourselves on the "rest" of the list (that is, everything other than the first element). Consider that comparison is transitive, and that we already have a vacuous-truth scenario covered.
		case1 *= 2; // Shift case1's value over to the left by one bit by multiplying by 2. If case1 was 1 (0b01), it's now 2 (0b10) - otherwise it's still 0 (0b00)
		return (case1 | case2) & recursion; 
		// The bitwise OR operator (|) will combine any 1-bits from case1's value (either 0b10 or 0b00) or case2's value (either 0b01 or 0b00) into either 3, 2, 1, or 0 (0b11, 0b10, 0b01, or 0b00 respectively).
		// The bitwise AND operator (&) will combine only matching 1-bits from (case1|case2) and the return value of the recursive call - if recursion = 0b11 and case1|case2 = 0b01, then the return value will be 0b01.
	}
}