// File: /workspace/github_c_makefile_star2_O0/pyk[P]simple-nn/deps/pcg/sample/pcg32x2-demo.c
// Function: main
int main(int argc, char** argv)
{
    // Read command-line options

    int rounds = 5;
    bool nondeterministic_seed = false;

    ++argv;
    --argc;
    if (argc > 0 && strcmp(argv[0], "-r") == 0) {
        nondeterministic_seed = true;
        ++argv;
        --argc;
    }
    if (argc > 0) {
        rounds = atoi(argv[0]);
    }

    // In this version of the code, we'll use a local rng, rather than the
    // global one.

    pcg32x2_random_t rng;

    // You should *always* seed the RNG.  The usual time to do it is the
    // point in time when you create RNG (typically at the beginning of the
    // program).
    //
    // pcg32x2_srandom_r takes four 64-bit constants (the initial state, and 
    // the rng sequence selector; rngs with different sequence selectors will
    // *never* have random sequences that coincide, at all) - the code below
    // shows three possible ways to do so.

    if (nondeterministic_seed) {
        // Seed with external entropy

        uint64_t seeds[4];
        entropy_getbytes((void*)seeds, sizeof(seeds));
        pcg32x2_srandom_r(&rng, seeds[0], seeds[1], seeds[2], seeds[3]);
    } else {
        // Seed with a fixed constant

        pcg32x2_srandom_r(&rng, 42u, 42u, 54u, 54u);
    }

    printf("pcg32x2_random_r:\n"
           "      -  result:      64-bit unsigned int (uint64_t)\n"
           "      -  period:      2^64   (* ~2^126 streams)\n"
           "      -  state space: 2^128  (* ~2^126 streams)\n"
           "      -  state type:  pcg32x2_random_t (%zu bytes)\n"
           "      -  output func: XSH-RR (x 2)\n"
           "\n",
           sizeof(pcg32x2_random_t));

    for (int round = 1; round <= rounds; ++round) {
        printf("Round %d:\n", round);

        /* Make some RngTypebit numbers */
        printf("  64bit:");
        for (int i = 0; i < 6; ++i) {
            if (i > 0 && i % 3 == 0)
                printf("\n\t");
            printf(" 0x%016llx", pcg32x2_random_r(&rng));
        }
        printf("\n");

        printf("  Again:");
        pcg32x2_advance_r(&rng, -6);
        for (int i = 0; i < 6; ++i) {
            if (i > 0 && i % 3 == 0)
                printf("\n\t");
            printf(" 0x%016llx", pcg32x2_random_r(&rng));
        }
        printf("\n");

        /* Toss some coins */
        printf("  Coins: ");
        for (int i = 0; i < 65; ++i)
            printf("%c", pcg32x2_boundedrand_r(&rng, 2) ? 'H' : 'T');
        printf("\n");

        /* Roll some dice */
        printf("  Rolls:");
        for (int i = 0; i < 33; ++i)
            printf(" %d", (int)pcg32x2_boundedrand_r(&rng, 6) + 1);
        printf("\n");

        /* Deal some cards */
        enum { SUITS = 4, NUMBERS = 13, CARDS = 52 };
        char cards[CARDS];

        for (int i = 0; i < CARDS; ++i)
            cards[i] = i;

        for (int i = CARDS; i > 1; --i) {
            int chosen = pcg32x2_boundedrand_r(&rng, i);
            char card = cards[chosen];
            cards[chosen] = cards[i - 1];
            cards[i - 1] = card;
        }

        printf("  Cards:");
        static const char number[] = {'A', '2', '3', '4', '5', '6', '7',
                                      '8', '9', 'T', 'J', 'Q', 'K'};
        static const char suit[] = {'h', 'c', 'd', 's'};
        for (int i = 0; i < CARDS; ++i) {
            printf(" %c%c", number[cards[i] / SUITS], suit[cards[i] % SUITS]);
            if ((i + 1) % 22 == 0)
                printf("\n\t");
        }
        printf("\n");

        printf("\n");
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x5, -0x14(%rbp)
movb $0x0, -0x15(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
cmpl $0x0, -0x8(%rbp)
jle 0x1360
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x1cc7(%rip), %rsi      # 0x3004
callq 0x1060
cmpl $0x0, %eax
jne 0x1360
movb $0x1, -0x15(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x10(%rbp)
movl -0x8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x8(%rbp)
cmpl $0x0, -0x8(%rbp)
jle 0x1375
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x1090
movl %eax, -0x14(%rbp)
testb $0x1, -0x15(%rbp)
je 0x13a4
leaq -0x60(%rbp), %rdi
movl $0x20, %esi
callq 0x1750
movq -0x60(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %r8
leaq -0x38(%rbp), %rdi
callq 0x11a0
jmp 0x13be
leaq -0x38(%rbp), %rdi
movl $0x2a, %edx
movl $0x36, %r8d
movq %rdx, %rsi
movq %r8, %rcx
callq 0x11a0
leaq 0x1c42(%rip), %rdi      # 0x3007
movl $0x20, %esi
movb $0x0, %al
callq 0x1030
movl $0x1, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x1743
movl -0x64(%rbp), %esi
leaq 0x1d18(%rip), %rdi      # 0x3106
movb $0x0, %al
callq 0x1030
leaq 0x1d15(%rip), %rdi      # 0x3111
movb $0x0, %al
callq 0x1030
movl $0x0, -0x68(%rbp)
cmpl $0x6, -0x68(%rbp)
jge 0x1459
cmpl $0x0, -0x68(%rbp)
jle 0x1434
movl -0x68(%rbp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x1434
leaq 0x1ced(%rip), %rdi      # 0x311a
movb $0x0, %al
callq 0x1030
leaq -0x38(%rbp), %rdi
callq 0x1220
movq %rax, %rsi
leaq 0x1cd6(%rip), %rdi      # 0x311d
movb $0x0, %al
callq 0x1030
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x140a
leaq 0x1ca4(%rip), %rdi      # 0x3104
movb $0x0, %al
callq 0x1030
leaq 0x1cba(%rip), %rdi      # 0x3128
movb $0x0, %al
callq 0x1030
leaq -0x38(%rbp), %rdi
movq $-0x6, %rsi
callq 0x1260
movl $0x0, -0x6c(%rbp)
cmpl $0x6, -0x6c(%rbp)
jge 0x14db
cmpl $0x0, -0x6c(%rbp)
jle 0x14b6
movl -0x6c(%rbp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x14b6
leaq 0x1c6b(%rip), %rdi      # 0x311a
movb $0x0, %al
callq 0x1030
leaq -0x38(%rbp), %rdi
callq 0x1220
movq %rax, %rsi
leaq 0x1c54(%rip), %rdi      # 0x311d
movb $0x0, %al
callq 0x1030
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x148c
leaq 0x1c22(%rip), %rdi      # 0x3104
movb $0x0, %al
callq 0x1030
leaq 0x1c41(%rip), %rdi      # 0x3131
movb $0x0, %al
callq 0x1030
movl $0x0, -0x70(%rbp)
cmpl $0x41, -0x70(%rbp)
jge 0x153f
leaq -0x38(%rbp), %rdi
movl $0x2, %esi
callq 0x12a0
movq %rax, %rcx
movl $0x54, %esi
movl $0x48, %eax
cmpq $0x0, %rcx
cmovnel %eax, %esi
leaq 0x1c27(%rip), %rdi      # 0x3154
movb $0x0, %al
callq 0x1030
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x14fe
leaq 0x1bbe(%rip), %rdi      # 0x3104
movb $0x0, %al
callq 0x1030
leaq 0x1be7(%rip), %rdi      # 0x313b
movb $0x0, %al
callq 0x1030
movl $0x0, -0x74(%rbp)
cmpl $0x21, -0x74(%rbp)
jge 0x1594
leaq -0x38(%rbp), %rdi
movl $0x6, %esi
callq 0x12a0
movl %eax, %esi
addl $0x1, %esi
leaq 0x1bc2(%rip), %rdi      # 0x3144
movb $0x0, %al
callq 0x1030
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x1562
leaq 0x1b69(%rip), %rdi      # 0x3104
movb $0x0, %al
callq 0x1030
movl $0x0, -0xb4(%rbp)
cmpl $0x34, -0xb4(%rbp)
jge 0x15dc
movl -0xb4(%rbp), %eax
movb %al, %cl
movslq -0xb4(%rbp), %rax
movb %cl, -0xb0(%rbp,%rax)
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0x15ac
movl $0x34, -0xb8(%rbp)
cmpl $0x1, -0xb8(%rbp)
jle 0x1662
movslq -0xb8(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x12a0
movl %eax, -0xbc(%rbp)
movslq -0xbc(%rbp), %rax
movb -0xb0(%rbp,%rax), %al
movb %al, -0xbd(%rbp)
movl -0xb8(%rbp), %eax
subl $0x1, %eax
cltq
movb -0xb0(%rbp,%rax), %cl
movslq -0xbc(%rbp), %rax
movb %cl, -0xb0(%rbp,%rax)
movb -0xbd(%rbp), %cl
movl -0xb8(%rbp), %eax
subl $0x1, %eax
cltq
movb %cl, -0xb0(%rbp,%rax)
movl -0xb8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xb8(%rbp)
jmp 0x15e6
leaq 0x1adf(%rip), %rdi      # 0x3148
movb $0x0, %al
callq 0x1030
movl $0x0, -0xc4(%rbp)
cmpl $0x34, -0xc4(%rbp)
jge 0x1719
movslq -0xc4(%rbp), %rax
movsbl -0xb0(%rbp,%rax), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movslq %eax, %rcx
leaq 0x1aaf(%rip), %rax      # 0x3157
movsbl (%rax,%rcx), %esi
movslq -0xc4(%rbp), %rax
movsbl -0xb0(%rbp,%rax), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movslq %edx, %rcx
leaq 0x1a97(%rip), %rax      # 0x3164
movsbl (%rax,%rcx), %edx
leaq 0x1a79(%rip), %rdi      # 0x3151
movb $0x0, %al
callq 0x1030
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl $0x16, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x1703
leaq 0x1a1e(%rip), %rdi      # 0x311a
movb $0x0, %al
callq 0x1030
jmp 0x1705
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x167a
leaq 0x19e4(%rip), %rdi      # 0x3104
movb $0x0, %al
callq 0x1030
leaq 0x19d6(%rip), %rdi      # 0x3104
movb $0x0, %al
callq 0x1030
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x13d8
xorl %eax, %eax
addq $0xd0, %rsp
popq %rbp
retq
nop