// File: /workspace/github_c_makefile_star2_O3/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 $0x78, %rsp
cmpl $0x1, %edi
jle 0x1350
movq 0x8(%rsi), %rax
cmpb $0x2d, (%rax)
jne 0x1309
cmpb $0x72, 0x1(%rax)
jne 0x1309
cmpb $0x0, 0x2(%rax)
je 0x1825
movabsq $-0x1d72e7db0b204934, %rbx # imm = 0xE28D1824F4DFB6CC
movabsq $0x185706b82c2e03f8, %r12 # imm = 0x185706B82C2E03F8
movq %rax, %rdi
callq 0x1090
movl %eax, %ebp
movl $0x6d, %r14d
movq $-0x6d, %r15
leaq 0xd15(%rip), %rdi       # 0x2050
movl $0x20, %esi
xorl %eax, %eax
callq 0x1040
testl %ebp, %ebp
jg 0x1389
jmp 0x1814
movabsq $-0x1d72e7db0b204934, %rbx # imm = 0xE28D1824F4DFB6CC
movabsq $0x185706b82c2e03f8, %r12 # imm = 0x185706B82C2E03F8
leaq 0xce5(%rip), %rdi       # 0x2050
movl $0x20, %esi
xorl %eax, %eax
callq 0x1040
movl $0x5, %ebp
movq $-0x6d, %r15
movl $0x6d, %r14d
movl $0x1, %esi
movabsq $0x5851f42d4c957f2d, %r13 # imm = 0x5851F42D4C957F2D
pshufd $0xf5, 0xc8f(%rip), %xmm0 # xmm0 = mem[1,1,3,3]
movdqa %xmm0, 0x60(%rsp)
movl %ebp, 0xc(%rsp)
movq %r14, 0x10(%rsp)
leaq 0xd98(%rip), %rdi       # 0x214f
movq %rsi, 0x18(%rsp)
xorl %eax, %eax
callq 0x1040
leaq 0xd90(%rip), %rdi       # 0x215a
xorl %eax, %eax
callq 0x1040
xorl %ecx, %ecx
xorl %edx, %edx
movq %rbx, %rbp
movq %r12, %rbx
movl %edx, %eax
subl $0x3, %eax
movl %edx, 0x8(%rsp)
cmovbl %edx, %eax
addl $-0x1, %ecx
movl %ecx, 0x4(%rsp)
jae 0x1402
testl %eax, %eax
jne 0x1402
leaq 0xd68(%rip), %rdi       # 0x2163
xorl %eax, %eax
callq 0x1040
movq %rbx, %r12
imulq %r13, %r12
movq %rbx, %rax
shrq $0x2d, %rax
movq %rbx, %rcx
shrq $0x1b, %rcx
xorl %ecx, %eax
shrq $0x3b, %rbx
movl %ebx, %ecx
rorl %cl, %eax
addq %r14, %r12
shlq $0x20, %rax
movq %rbp, %rbx
imulq %r13, %rbx
addq %r15, %rbx
movq %rbp, %rsi
shrq $0x2d, %rsi
movq %rbp, %rcx
shrq $0x1b, %rcx
xorl %ecx, %esi
shrq $0x3b, %rbp
movl %ebp, %ecx
rorl %cl, %esi
orq %rax, %rsi
leaq 0xd12(%rip), %rdi       # 0x2166
xorl %eax, %eax
callq 0x1040
movl 0x8(%rsp), %edx
incl %edx
cmpl $0x6, %edx
movl 0x4(%rsp), %ecx
jne 0x13d5
movl $0xa, %edi
callq 0x1030
movl $0x0, 0x8(%rsp)
leaq 0xcea(%rip), %rdi       # 0x2171
xorl %eax, %eax
callq 0x1040
movq %r12, %rdi
movq $-0x6, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x19d8
movq %rax, %r12
movq %rbx, %rdi
movq $-0x6, %rsi
movq %r13, %rdx
movq %r15, %rcx
callq 0x19d8
movq %rax, %rbx
xorl %ecx, %ecx
movq %rbx, %rbp
movq %r12, %rbx
movl %ecx, %eax
subl $0x3, %eax
movl %ecx, 0x4(%rsp)
cmovbl %ecx, %eax
addl $-0x1, 0x8(%rsp)
jae 0x14eb
testl %eax, %eax
jne 0x14eb
leaq 0xc7f(%rip), %rdi       # 0x2163
xorl %eax, %eax
callq 0x1040
movq %rbx, %r12
imulq %r13, %r12
movq %rbx, %rax
shrq $0x2d, %rax
movq %rbx, %rcx
shrq $0x1b, %rcx
xorl %ecx, %eax
shrq $0x3b, %rbx
movl %ebx, %ecx
rorl %cl, %eax
addq %r14, %r12
shlq $0x20, %rax
movq %rbp, %rbx
imulq %r13, %rbx
addq %r15, %rbx
movq %rbp, %rsi
shrq $0x2d, %rsi
movq %rbp, %rcx
shrq $0x1b, %rcx
xorl %ecx, %esi
shrq $0x3b, %rbp
movl %ebp, %ecx
rorl %cl, %esi
orq %rax, %rsi
leaq 0xc29(%rip), %rdi       # 0x2166
xorl %eax, %eax
callq 0x1040
movl 0x4(%rsp), %ecx
incl %ecx
cmpl $0x6, %ecx
jne 0x14c0
movl $0xa, %edi
callq 0x1030
leaq 0xc16(%rip), %rdi       # 0x217a
xorl %eax, %eax
callq 0x1040
movl $0x41, %ebp
movq %rbx, %rax
shrq $0x2d, %rax
movq %rbx, %rcx
shrq $0x1b, %rcx
xorl %ecx, %eax
movq %rbx, %rcx
shrq $0x3b, %rcx
rorl %cl, %eax
movl $0x54, %edi
testb $0x1, %al
je 0x1597
movl $0x48, %edi
imulq %r13, %r12
addq %r14, %r12
imulq %r13, %rbx
addq %r15, %rbx
callq 0x1030
decl %ebp
jne 0x1570
movl $0xa, %edi
callq 0x1030
xorl %ebp, %ebp
leaq 0xbc3(%rip), %rdi       # 0x2184
xorl %eax, %eax
callq 0x1040
movq %r12, %rcx
movq %rbx, %rax
imulq %r13, %r12
movq %rcx, %rdx
shrq $0x2d, %rdx
movq %rcx, %rsi
shrq $0x1b, %rsi
xorl %esi, %edx
shrq $0x3b, %rcx
rorl %cl, %edx
addq %r14, %r12
shlq $0x20, %rdx
movq %rbx, %rsi
shrq $0x2d, %rsi
movq %rbx, %rcx
shrq $0x1b, %rcx
xorl %ecx, %esi
shrq $0x3b, %rax
movl %eax, %ecx
rorl %cl, %esi
imulq %r13, %rbx
addq %r15, %rbx
orq %rdx, %rsi
cmpq $0x4, %rsi
jb 0x15c8
movq %rsi, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
mulq %rcx
shrq $0x2, %rdx
addl %edx, %edx
leal (%rdx,%rdx,2), %eax
subl %eax, %esi
incl %esi
leaq 0xb52(%rip), %rdi       # 0x218d
xorl %eax, %eax
callq 0x1040
incl %ebp
cmpl $0x21, %ebp
jne 0x15c8
movl $0xa, %edi
callq 0x1030
xorl %eax, %eax
movdqa 0x9af(%rip), %xmm0      # 0x2010
movdqa 0x9b7(%rip), %xmm3      # 0x2020
movdqa 0x9bf(%rip), %xmm4      # 0x2030
movdqa 0x60(%rsp), %xmm5
movdqa 0x9c1(%rip), %xmm6      # 0x2040
movdqa %xmm0, %xmm1
pxor %xmm3, %xmm1
movdqa %xmm4, %xmm2
pcmpgtd %xmm1, %xmm2
pshufd $0xf5, %xmm1, %xmm1     # xmm1 = xmm1[1,1,3,3]
pcmpeqd %xmm5, %xmm1
pand %xmm2, %xmm1
movd %xmm1, %ecx
testb $0x1, %cl
je 0x16a9
movb %al, 0x20(%rsp,%rax)
pextrw $0x4, %xmm1, %ecx
testb $0x1, %cl
je 0x16ba
leal 0x1(%rax), %ecx
movb %cl, 0x21(%rsp,%rax)
addq $0x2, %rax
paddq %xmm6, %xmm0
cmpq $0x34, %rax
jne 0x167f
movl $0x34, %edi
movq %rdi, %rax
negq %rax
xorl %edx, %edx
divq %rdi
movq %r12, %rcx
movq %rbx, %rsi
imulq %r13, %r12
movq %rcx, %r8
shrq $0x2d, %r8
movq %rcx, %rax
shrq $0x1b, %rax
xorl %eax, %r8d
shrq $0x3b, %rcx
rorl %cl, %r8d
addq %r14, %r12
shlq $0x20, %r8
movq %rbx, %rax
shrq $0x2d, %rax
movq %rbx, %rcx
shrq $0x1b, %rcx
xorl %ecx, %eax
shrq $0x3b, %rsi
movl %esi, %ecx
rorl %cl, %eax
imulq %r13, %rbx
addq %r15, %rbx
orq %r8, %rax
cmpq %rdx, %rax
jb 0x16d8
xorl %edx, %edx
divq %rdi
movb 0x20(%rsp,%rdx), %al
movb 0x1f(%rsp,%rdi), %cl
movb %cl, 0x20(%rsp,%rdx)
movb %al, 0x1f(%rsp,%rdi)
leaq -0x1(%rdi), %rax
cmpq $0x2, %rdi
movq %rax, %rdi
ja 0x16cd
leaq 0xa40(%rip), %rdi       # 0x2191
xorl %eax, %eax
callq 0x1040
movb $0x1, %al
xorl %ebp, %ebp
movb %al, 0x4(%rsp)
shrb %al
movzbl %al, %eax
imull $0xbb, %eax, %eax
shrl $0xb, %eax
leal (%rax,%rax,4), %ecx
leal (%rax,%rcx,4), %r14d
addl %eax, %r14d
movb 0x20(%rsp,%rbp), %al
movl %eax, %ecx
sarb $0x7, %cl
shrb $0x6, %cl
addb %al, %cl
movl %ecx, %edx
sarb $0x2, %dl
movsbq %dl, %rdx
leaq 0xa0a(%rip), %rsi       # 0x21a0
movsbl (%rdx,%rsi), %esi
andb $-0x4, %cl
subb %cl, %al
movsbq %al, %rax
leaq 0xa03(%rip), %rcx       # 0x21ad
movsbl (%rax,%rcx), %edx
leaq 0x9e5(%rip), %rdi       # 0x219a
xorl %eax, %eax
callq 0x1040
decb %r14b
cmpb %bpl, %r14b
jne 0x17d2
leaq 0x998(%rip), %rdi       # 0x2163
xorl %eax, %eax
callq 0x1040
incq %rbp
movb 0x4(%rsp), %al
incb %al
cmpq $0x34, %rbp
jne 0x175c
movl $0xa, %edi
callq 0x1030
movl $0xa, %edi
callq 0x1030
movq 0x18(%rsp), %rcx
leal 0x1(%rcx), %eax
movl 0xc(%rsp), %ebp
cmpl %ebp, %ecx
movl %eax, %esi
movq 0x10(%rsp), %r14
jne 0x13b0
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x5, %ebp
cmpl $0x2, %edi
je 0x183a
movq 0x10(%rsi), %rdi
callq 0x1090
movl %eax, %ebp
leaq 0x20(%rsp), %rbx
movl $0x20, %esi
movq %rbx, %rdi
callq 0x18b0
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), %r14
movq (%rbx), %rcx
addq %r14, %rcx
movabsq $0x5851f42d4c957f2d, %rdx # imm = 0x5851F42D4C957F2D
imulq %rdx, %rcx
leaq (%rcx,%rax,2), %r12
incq %r12
leaq 0x1(,%rsi,2), %r15
movq 0x8(%rbx), %rax
addq %r15, %rax
imulq %rdx, %rax
leaq (%rax,%rsi,2), %rbx
incq %rbx
jmp 0x1334
nopl (%rax)