Repository: raspberrypi/pico-sdk
File: test/pico_divider_test/pico_divider_nesting_test.c (C)

Code before:
            }
            aa = -zz / -11;
            bb = -zz % -11;
            if (-zz != aa * -11 + bb) {
                FAILED();
            }
            aa = -zz / 11;
            bb = -zz % 11;
            if (-zz != aa * 11 + bb) {
                FAILED();
            }
            a = 0xffffffffu / 11;
            b = 0xffffffffu % 11;
            if (0xffffffffu != a * 11 + b) {
                FAILED();
            }
        }
        // these use the divider
        for(uint i=0;i<=100;i+=20) {
            // both in and out bootrom range (we perform mod in wrapper code if necessarry)
            f0t = tanf(i * 50);
            f0c = cosf(i * 50);
            f0s = sinf(i * 50);
            d0t = tan(i * 1000);
            d0c = cos(i * 1000);
            d0s = sin(i * 1000);
        }
        count_local++;
    }
    done = true;
    cancel_repeating_timer(&timer);
    printf("%d: %d %d %d\n", count_local, (int)count[0], (int)count[1], (int)count[2]);

    // make sure all the IRQs ran
    if (!(count_local && count[0] && count[1] && count[2])) {
        printf("DID NOT RUN\n");
        exit(1);
    }
    if (failed) {
        printf("FAILED\n");
        exit(1);
    }
}

int main() {
#ifndef uart_default
#warning test/pico_divider requires a default uart
#else
    stdio_init_all();
#endif
    test_nesting();

Review comment (suggestion):
I dunno if it'd be "nicer" (more readable?) to declare these outside the `for` loop (like you did with `uint z = 0;`), rather than declaring them as `static` inside the `for` loop? :shrug: 

The first time I saw
```
static uint32_t cd = 1;
a64 = c64 / cd;
```
I thought "Huh, what's the point of testing divide-by-one?" :wink:  (it was only later that I spotted the `cd++;` further down)

(but then I'm not a regular C programmer, so perhaps this is just a common idiom that I'm not familiar with?)

Code after:
            }
            aa = -zz / -11;
            bb = -zz % -11;
            if (-zz != aa * -11 + bb) {
                FAILED();
            }
            aa = -zz / 11;
            bb = -zz % 11;
            if (-zz != aa * 11 + bb) {
                FAILED();
            }
            a = 0xffffffffu / 11;
            b = 0xffffffffu % 11;
            if (0xffffffffu != a * 11 + b) {
                FAILED();
            }
            static uint64_t z64;
            z64 -= 47;
            uint64_t a64 = z64 / -13635;
            uint64_t b64 = z64 % -13635;
            if (z64 != a64 * -13635 + b64) {
                FAILED();
            }
            // specifically check 64/32 divide
            static uint64_t c64 = 0x13ffffffffull;
            static uint32_t cd = 1;
            a64 = c64 / cd;
            b64 = c64 % cd;
            if (c64 != a64 * cd + b64) {
                FAILED();
            }
            cd++;

        }
        // these use the divider
        for(uint i=0;i<=100;i+=20) {
            // both in and out bootrom range (we perform mod in wrapper code if necessarry)
            f0t = tanf(i * 50);
            f0c = cosf(i * 50);
            f0s = sinf(i * 50);
            d0t = tan(i * 1000);
            d0c = cos(i * 1000);
            d0s = sin(i * 1000);
        }
        count_local++;
    }
    done = true;
    cancel_repeating_timer(&timer);
    printf("%d: %d %d %d\n", count_local, (int)count[0], (int)count[1], (int)count[2]);

    // make sure all the IRQs ran