// File: /workspace/github_c_makefile_star2_O0/pyk[P]simple-nn/deps/pcg/sample/pcg64-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.

    pcg64_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).
    //
    // pcg64_srandom_r takes two 128-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

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

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

    printf("pcg64_random_r:\n"
           "      -  result:      64-bit unsigned int (uint64_t)\n"
           "      -  period:      2^128   (* 2^127 streams)\n"
           "      -  state type:  pcg64_random_t (%zu bytes)\n"
           "      -  output func: XSL-RR\n"
           "\n",
           sizeof(pcg64_random_t));

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

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

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

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

        /* Roll some dice */
        printf("  Rolls:");
        for (int i = 0; i < 33; ++i)
            printf(" %d", (int)pcg64_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 = pcg64_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 $0x120, %rsp            # imm = 0x120
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 0x1210
movq -0x10(%rbp), %rax
movq (%rax), %rdi
leaq 0x3e17(%rip), %rsi      # 0x5004
callq 0x1060
cmpl $0x0, %eax
jne 0x1210
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 0x1225
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x1090
movl %eax, -0x14(%rbp)
testb $0x1, -0x15(%rbp)
je 0x1274
leaq -0x60(%rbp), %rdi
movl $0x20, %esi
callq 0x16d0
movq -0x60(%rbp), %rdx
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rsi, -0x68(%rbp)
movq %rdx, -0x70(%rbp)
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq %rcx, -0x78(%rbp)
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rcx
movq -0x78(%rbp), %r8
leaq -0x40(%rbp), %rdi
callq 0x2a00
jmp 0x12c5
movq $0x0, -0x88(%rbp)
movq $0x2a, -0x90(%rbp)
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
movq $0x0, -0x98(%rbp)
movq $0x36, -0xa0(%rbp)
movq -0xa0(%rbp), %rcx
movq -0x98(%rbp), %r8
leaq -0x40(%rbp), %rdi
callq 0x2a00
leaq 0x3d3b(%rip), %rdi      # 0x5007
movl $0x20, %esi
movb $0x0, %al
callq 0x1030
movl $0x1, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x16bc
movl -0xa4(%rbp), %esi
leaq 0x3dce(%rip), %rdi      # 0x50cc
movb $0x0, %al
callq 0x1030
leaq 0x3dcb(%rip), %rdi      # 0x50d7
movb $0x0, %al
callq 0x1030
movl $0x0, -0xa8(%rbp)
cmpl $0x6, -0xa8(%rbp)
jge 0x137b
cmpl $0x0, -0xa8(%rbp)
jle 0x1350
movl -0xa8(%rbp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x1350
leaq 0x3d97(%rip), %rdi      # 0x50e0
movb $0x0, %al
callq 0x1030
leaq -0x40(%rbp), %rdi
callq 0x3380
movq %rax, %rsi
leaq 0x3d80(%rip), %rdi      # 0x50e3
movb $0x0, %al
callq 0x1030
movl -0xa8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa8(%rbp)
jmp 0x131d
leaq 0x3d48(%rip), %rdi      # 0x50ca
xorl %eax, %eax
movb %al, -0x115(%rbp)
callq 0x1030
movb -0x115(%rbp), %al
leaq 0x3d52(%rip), %rdi      # 0x50ee
callq 0x1030
movq $-0x1, -0xb8(%rbp)
movq $-0x6, -0xc0(%rbp)
movq -0xc0(%rbp), %rsi
movq -0xb8(%rbp), %rdx
leaq -0x40(%rbp), %rdi
callq 0x2820
movl $0x0, -0xc4(%rbp)
cmpl $0x6, -0xc4(%rbp)
jge 0x1436
cmpl $0x0, -0xc4(%rbp)
jle 0x140b
movl -0xc4(%rbp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x140b
leaq 0x3cdc(%rip), %rdi      # 0x50e0
movb $0x0, %al
callq 0x1030
leaq -0x40(%rbp), %rdi
callq 0x3380
movq %rax, %rsi
leaq 0x3cc5(%rip), %rdi      # 0x50e3
movb $0x0, %al
callq 0x1030
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x13d8
leaq 0x3c8d(%rip), %rdi      # 0x50ca
movb $0x0, %al
callq 0x1030
leaq 0x3cac(%rip), %rdi      # 0x50f7
movb $0x0, %al
callq 0x1030
movl $0x0, -0xc8(%rbp)
cmpl $0x41, -0xc8(%rbp)
jge 0x14a6
leaq -0x40(%rbp), %rdi
movl $0x2, %esi
callq 0x33c0
movq %rax, %rcx
movl $0x54, %esi
movl $0x48, %eax
cmpq $0x0, %rcx
cmovnel %eax, %esi
leaq 0x3c8c(%rip), %rdi      # 0x511a
movb $0x0, %al
callq 0x1030
movl -0xc8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc8(%rbp)
jmp 0x145c
leaq 0x3c1d(%rip), %rdi      # 0x50ca
movb $0x0, %al
callq 0x1030
leaq 0x3c46(%rip), %rdi      # 0x5101
movb $0x0, %al
callq 0x1030
movl $0x0, -0xcc(%rbp)
cmpl $0x21, -0xcc(%rbp)
jge 0x1507
leaq -0x40(%rbp), %rdi
movl $0x6, %esi
callq 0x33c0
movl %eax, %esi
addl $0x1, %esi
leaq 0x3c1b(%rip), %rdi      # 0x510a
movb $0x0, %al
callq 0x1030
movl -0xcc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xcc(%rbp)
jmp 0x14cc
leaq 0x3bbc(%rip), %rdi      # 0x50ca
movb $0x0, %al
callq 0x1030
movl $0x0, -0x104(%rbp)
cmpl $0x34, -0x104(%rbp)
jge 0x154f
movl -0x104(%rbp), %eax
movb %al, %cl
movslq -0x104(%rbp), %rax
movb %cl, -0x100(%rbp,%rax)
movl -0x104(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x104(%rbp)
jmp 0x151f
movl $0x34, -0x108(%rbp)
cmpl $0x1, -0x108(%rbp)
jle 0x15d5
movslq -0x108(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x33c0
movl %eax, -0x10c(%rbp)
movslq -0x10c(%rbp), %rax
movb -0x100(%rbp,%rax), %al
movb %al, -0x10d(%rbp)
movl -0x108(%rbp), %eax
subl $0x1, %eax
cltq
movb -0x100(%rbp,%rax), %cl
movslq -0x10c(%rbp), %rax
movb %cl, -0x100(%rbp,%rax)
movb -0x10d(%rbp), %cl
movl -0x108(%rbp), %eax
subl $0x1, %eax
cltq
movb %cl, -0x100(%rbp,%rax)
movl -0x108(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x108(%rbp)
jmp 0x1559
leaq 0x3b32(%rip), %rdi      # 0x510e
movb $0x0, %al
callq 0x1030
movl $0x0, -0x114(%rbp)
cmpl $0x34, -0x114(%rbp)
jge 0x168c
movslq -0x114(%rbp), %rax
movsbl -0x100(%rbp,%rax), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movslq %eax, %rcx
leaq 0x3b02(%rip), %rax      # 0x511d
movsbl (%rax,%rcx), %esi
movslq -0x114(%rbp), %rax
movsbl -0x100(%rbp,%rax), %eax
movl $0x4, %ecx
cltd
idivl %ecx
movslq %edx, %rcx
leaq 0x3aea(%rip), %rax      # 0x512a
movsbl (%rax,%rcx), %edx
leaq 0x3acc(%rip), %rdi      # 0x5117
movb $0x0, %al
callq 0x1030
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl $0x16, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x1676
leaq 0x3a71(%rip), %rdi      # 0x50e0
movb $0x0, %al
callq 0x1030
jmp 0x1678
movl -0x114(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x114(%rbp)
jmp 0x15ed
leaq 0x3a37(%rip), %rdi      # 0x50ca
movb $0x0, %al
callq 0x1030
leaq 0x3a29(%rip), %rdi      # 0x50ca
movb $0x0, %al
callq 0x1030
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x12e2
xorl %eax, %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw (%rax,%rax)