// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %edi, %ebx
leaq 0x8(%rsi), %r15
leal -0x1(%rbx), %r12d
cmpl $0x2, %edi
jl 0x133b
movq %rsi, %r14
movq (%r15), %rdi
leaq 0xcd6(%rip), %rsi       # 0x2004
callq 0x1070
testl %eax, %eax
je 0x185a
xorl %ebp, %ebp
testl %r12d, %r12d
jle 0x1350
movq (%r15), %rdi
callq 0x10a0
movl %eax, 0x10(%rsp)
jmp 0x1358
movl $0x5, 0x10(%rsp)
movabsq $0x5851f42d4c957f2d, %r14 # imm = 0x5851F42D4C957F2D
testb %bpl, %bpl
je 0x13cd
leaq 0x20(%rsp), %rbx
movl $0x20, %esi
movq %rbx, %rdi
callq 0x1870
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rcx
movq %rcx, %rdx
xorq %rax, %rdx
btrq $0x3f, %rdx
xorl %esi, %esi
cmpq $0x1, %rdx
sbbq %rsi, %rsi
xorq %rcx, %rsi
leaq 0x1(,%rax,2), %r15
movq (%rbx), %rcx
addq %r15, %rcx
imulq %r14, %rcx
leaq (%rcx,%rax,2), %rbp
incq %rbp
leaq 0x1(,%rsi,2), %r12
movq 0x8(%rbx), %rax
addq %r12, %rax
imulq %r14, %rax
leaq (%rax,%rsi,2), %r13
incq %r13
jmp 0x13ee
movabsq $0x185706b82c2e03f8, %rbp # imm = 0x185706B82C2E03F8
movl $0x6d, %r15d
movabsq $-0x1d72e7db0b204934, %r13 # imm = 0xE28D1824F4DFB6CC
movq $-0x6d, %r12
leaq 0xc12(%rip), %rdi       # 0x2007
movl $0x20, %esi
xorl %eax, %eax
callq 0x1040
cmpl $0x0, 0x10(%rsp)
jle 0x1849
movl $0x1, %esi
leaq 0xcee(%rip), %rdi       # 0x2106
movq %rsi, 0x18(%rsp)
xorl %eax, %eax
callq 0x1040
leaq 0xce6(%rip), %rdi       # 0x2111
xorl %eax, %eax
callq 0x1040
xorl %edx, %edx
movl $0x0, 0xc(%rsp)
movq %r13, %rbx
movq %rbp, %r13
testl %edx, %edx
je 0x1472
movl 0xc(%rsp), %eax
movl $0xaaaaaaab, %ecx       # imm = 0xAAAAAAAB
imulq %rcx, %rax
shrq $0x21, %rax
leal (%rax,%rax,2), %eax
negl %eax
cmpl %edx, %eax
jne 0x1472
leaq 0xcb3(%rip), %rdi       # 0x211a
xorl %eax, %eax
movl %edx, %ebp
callq 0x1040
movl %ebp, %edx
movq %r13, %rbp
imulq %r14, %rbp
movq %r13, %rax
shrq $0x2d, %rax
movq %r13, %rcx
shrq $0x1b, %rcx
xorl %ecx, %eax
shrq $0x3b, %r13
movl %r13d, %ecx
rorl %cl, %eax
addq %r15, %rbp
shlq $0x20, %rax
movq %rbx, %r13
imulq %r14, %r13
addq %r12, %r13
movq %rbx, %rsi
shrq $0x2d, %rsi
movq %rbx, %rcx
shrq $0x1b, %rcx
xorl %ecx, %esi
shrq $0x3b, %rbx
movl %ebx, %ecx
rorl %cl, %esi
orq %rax, %rsi
leaq 0xc58(%rip), %rdi       # 0x211d
xorl %eax, %eax
movl %edx, %ebx
callq 0x1040
movl %ebx, %edx
incl 0xc(%rsp)
decl %edx
cmpl $-0x6, %edx
jne 0x143c
movl $0xa, %edi
callq 0x1030
leaq 0xc38(%rip), %rdi       # 0x2128
xorl %eax, %eax
callq 0x1040
movq %rbp, %rdi
movq $-0x6, %rsi
movq %r14, %rdx
movq %r15, %rcx
callq 0x1998
movq %rax, %rbp
movq %r13, %rdi
movq $-0x6, %rsi
movq %r14, %rdx
movq %r12, %rcx
callq 0x1998
xorl %edx, %edx
movq %rax, %r13
movl $0x0, 0xc(%rsp)
movq %r13, %rbx
movq %rbp, %r13
testl %edx, %edx
je 0x1567
movl 0xc(%rsp), %eax
movl $0xaaaaaaab, %ecx       # imm = 0xAAAAAAAB
imulq %rcx, %rax
shrq $0x21, %rax
leal (%rax,%rax,2), %eax
negl %eax
cmpl %edx, %eax
jne 0x1567
leaq 0xbbe(%rip), %rdi       # 0x211a
xorl %eax, %eax
movl %edx, %ebp
callq 0x1040
movl %ebp, %edx
movq %r13, %rbp
imulq %r14, %rbp
movq %r13, %rax
shrq $0x2d, %rax
movq %r13, %rcx
shrq $0x1b, %rcx
xorl %ecx, %eax
shrq $0x3b, %r13
movl %r13d, %ecx
rorl %cl, %eax
addq %r15, %rbp
shlq $0x20, %rax
movq %rbx, %r13
imulq %r14, %r13
addq %r12, %r13
movq %rbx, %rsi
shrq $0x2d, %rsi
movq %rbx, %rcx
shrq $0x1b, %rcx
xorl %ecx, %esi
shrq $0x3b, %rbx
movl %ebx, %ecx
rorl %cl, %esi
orq %rax, %rsi
leaq 0xb63(%rip), %rdi       # 0x211d
xorl %eax, %eax
movl %edx, %ebx
callq 0x1040
movl %ebx, %edx
incl 0xc(%rsp)
decl %edx
cmpl $-0x6, %edx
jne 0x1531
movl $0xa, %edi
callq 0x1030
leaq 0xb4c(%rip), %rdi       # 0x2131
xorl %eax, %eax
callq 0x1040
movl $0x41, %ebx
movq %r13, %rax
shrq $0x2d, %rax
movq %r13, %rcx
shrq $0x1b, %rcx
xorl %ecx, %eax
movq %r13, %rcx
shrq $0x3b, %rcx
rorl %cl, %eax
movl $0x54, %edi
testb $0x1, %al
je 0x1618
movl $0x48, %edi
imulq %r14, %rbp
addq %r15, %rbp
imulq %r14, %r13
addq %r12, %r13
callq 0x1030
decl %ebx
jne 0x15f1
movl $0xa, %edi
callq 0x1030
xorl %ebx, %ebx
leaq 0xaf9(%rip), %rdi       # 0x213b
xorl %eax, %eax
callq 0x1040
movabsq $-0x5555555555555555, %r8 # imm = 0xAAAAAAAAAAAAAAAB
movq %rbp, %rcx
movq %r13, %rax
movq %rbp, %rdx
shrq $0x2d, %rdx
movq %rbp, %rdi
shrq $0x1b, %rdi
xorl %edi, %edx
shrq $0x3b, %rcx
rorl %cl, %edx
imulq %r14, %rbp
addq %r15, %rbp
shlq $0x20, %rdx
imulq %r14, %r13
addq %r12, %r13
movq %rax, %rdi
shrq $0x2d, %rdi
movq %rax, %rcx
shrq $0x1b, %rcx
xorl %ecx, %edi
shrq $0x3b, %rax
movl %eax, %ecx
rorl %cl, %edi
orq %rdx, %rdi
movq %rdi, %rax
mulq %r8
shrq %rdx
andq $-0x2, %rdx
leaq (%rdx,%rdx,2), %rax
movq %rdi, %rcx
subq %rax, %rcx
cmpq $0x4, %rdi
cmovaeq %rcx, %rsi
jb 0x1653
incl %esi
leaq 0xa7e(%rip), %rdi       # 0x2144
xorl %eax, %eax
callq 0x1040
incl %ebx
cmpl $0x21, %ebx
jne 0x1649
movl $0xa, %edi
callq 0x1030
xorl %eax, %eax
movb %al, 0x20(%rsp,%rax)
incq %rax
cmpq $0x34, %rax
jne 0x16e4
movl $0x34, %r8d
movq %r8, %rax
negq %rax
xorl %edx, %edx
divq %r8
movq %rdx, %rsi
movq %rbp, %rax
shrq $0x2d, %rax
movq %rbp, %rcx
shrq $0x1b, %rcx
xorl %ecx, %eax
movq %rbp, %rcx
shrq $0x3b, %rcx
rorl %cl, %eax
movq %r13, %rdi
shrq $0x2d, %rdi
movq %r13, %rcx
shrq $0x1b, %rcx
xorl %ecx, %edi
movq %r13, %rcx
shrq $0x3b, %rcx
rorl %cl, %edi
shlq $0x20, %rax
orq %rax, %rdi
cmpq %rsi, %rdi
jb 0x174b
movq %rdi, %rax
xorl %edx, %edx
divq %r8
imulq %r14, %rbp
addq %r15, %rbp
imulq %r14, %r13
addq %r12, %r13
cmpq %rsi, %rdi
jb 0x1705
movslq %edx, %rax
movb 0x20(%rsp,%rax), %cl
movb 0x1f(%rsp,%r8), %dl
movb %dl, 0x20(%rsp,%rax)
movb %cl, 0x1f(%rsp,%r8)
leaq -0x1(%r8), %rax
cmpq $0x2, %r8
movq %rax, %r8
ja 0x16f7
leaq 0x9bd(%rip), %rdi       # 0x2148
xorl %eax, %eax
callq 0x1040
movl $0x1, %eax
xorl %ebx, %ebx
movl %eax, 0xc(%rsp)
movl %eax, %eax
movl $0xba2e8ba3, %ecx       # imm = 0xBA2E8BA3
imulq %rcx, %rax
shrq $0x24, %rax
leal (%rax,%rax,4), %ecx
leal (%rax,%rcx,4), %ecx
addl %ecx, %eax
decl %eax
movl %eax, 0x14(%rsp)
movsbl 0x20(%rsp,%rbx), %eax
leal 0x3(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
movl %ecx, %edx
sarl $0x2, %edx
movslq %edx, %rdx
leaq 0x981(%rip), %rsi       # 0x2157
movsbl (%rdx,%rsi), %esi
andl $-0x4, %ecx
subl %ecx, %eax
cltq
leaq 0x97c(%rip), %rcx       # 0x2164
movsbl (%rax,%rcx), %edx
leaq 0x95e(%rip), %rdi       # 0x2151
xorl %eax, %eax
callq 0x1040
cmpl %ebx, 0x14(%rsp)
jne 0x180e
leaq 0x913(%rip), %rdi       # 0x211a
xorl %eax, %eax
callq 0x1040
incq %rbx
movl 0xc(%rsp), %eax
incl %eax
cmpq $0x34, %rbx
jne 0x1799
movl $0xa, %edi
callq 0x1030
movl $0xa, %edi
callq 0x1030
movq 0x18(%rsp), %rcx
leal 0x1(%rcx), %eax
cmpl 0x10(%rsp), %ecx
movl %eax, %esi
jne 0x1411
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x10, %r14
addl $-0x2, %ebx
movb $0x1, %bpl
movq %r14, %r15
movl %ebx, %r12d
jmp 0x133d
nop