// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
cmpl $0x1, %edi
jle 0x1201
movl %edi, %eax
movq 0x8(%rsi), %rdi
cmpb $0x2d, (%rdi)
jne 0x11ca
cmpb $0x72, 0x1(%rdi)
jne 0x11ca
cmpb $0x0, 0x2(%rdi)
je 0x14ff
xorl %ebx, %ebx
callq 0x1090
movl %eax, %r14d
testb %bl, %bl
je 0x1205
leaq 0x30(%rsp), %rbx
pushq $0x20
popq %rsi
movq %rbx, %rdi
callq 0x1518
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movq 0x18(%rbx), %r8
movq 0x10(%rbx), %rcx
movq %rsp, %rdi
callq 0x2126
jmp 0x1231
pushq $0x5
popq %r14
andq $0x0, 0x18(%rsp)
movq $0x6d, 0x10(%rsp)
movabsq $-0x21d431fa41fec41d, %rax # imm = 0xDE2BCE05BE013BE3
movq %rax, 0x8(%rsp)
movabsq $-0x2c093ba5be1abce0, %rax # imm = 0xD3F6C45A41E54320
movq %rax, (%rsp)
movabsq $0x2360ed051fc65da4, %r12 # imm = 0x2360ED051FC65DA4
movabsq $0x4385df649fccf645, %rbp # imm = 0x4385DF649FCCF645
leaq 0x2db8(%rip), %rdi      # 0x4004
xorl %ebx, %ebx
pushq $0x20
popq %rsi
xorl %eax, %eax
callq 0x1040
testl %r14d, %r14d
cmovlel %ebx, %r14d
incl %r14d
movl %r14d, 0x28(%rsp)
pushq $0x1
popq %rsi
movq %rsp, %r14
leaq 0x2e6c(%rip), %r15      # 0x40e0
cmpl 0x28(%rsp), %esi
je 0x14ee
xorl %ebx, %ebx
leaq 0x2e42(%rip), %rdi      # 0x40c9
movl %esi, 0x2c(%rsp)
xorl %eax, %eax
callq 0x1040
leaq 0x2e3b(%rip), %rdi      # 0x40d4
xorl %eax, %eax
callq 0x1040
pushq $0x6
popq %r13
subl $0x1, %r13d
jb 0x1313
movl %ebx, %eax
subl $0x3, %eax
cmovbl %ebx, %eax
testl %ebx, %ebx
je 0x12c8
testl %eax, %eax
jne 0x12c8
leaq 0x2e1c(%rip), %rdi      # 0x40dd
xorl %eax, %eax
callq 0x1040
movq (%rsp), %rsi
movq %rsi, %rax
mulq %rbp
imulq %r12, %rsi
addq %rdx, %rsi
movq 0x8(%rsp), %rcx
imulq %rbp, %rcx
addq %rsi, %rcx
addq 0x10(%rsp), %rax
adcq 0x18(%rsp), %rcx
movq %rax, (%rsp)
movq %rcx, 0x8(%rsp)
xorq %rcx, %rax
shrq $0x3a, %rcx
rorq %cl, %rax
movq %r15, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0x1040
incl %ebx
jmp 0x12a4
pushq $0xa
popq %rdi
callq 0x1030
xorl %ebx, %ebx
leaq 0x2dc7(%rip), %rdi      # 0x40eb
xorl %eax, %eax
callq 0x1040
movq %r14, %rdi
pushq $-0x6
popq %rsi
pushq $-0x1
popq %rdx
callq 0x203d
pushq $0x6
popq %r13
subl $0x1, %r13d
jb 0x13ac
movl %ebx, %eax
subl $0x3, %eax
cmovbl %ebx, %eax
testl %ebx, %ebx
je 0x1361
testl %eax, %eax
jne 0x1361
leaq 0x2d83(%rip), %rdi      # 0x40dd
xorl %eax, %eax
callq 0x1040
movq (%rsp), %rsi
movq %rsi, %rax
mulq %rbp
imulq %r12, %rsi
addq %rdx, %rsi
movq 0x8(%rsp), %rcx
imulq %rbp, %rcx
addq %rsi, %rcx
addq 0x10(%rsp), %rax
adcq 0x18(%rsp), %rcx
movq %rax, (%rsp)
movq %rcx, 0x8(%rsp)
xorq %rcx, %rax
shrq $0x3a, %rcx
rorq %cl, %rax
movq %r15, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0x1040
incl %ebx
jmp 0x133d
pushq $0xa
popq %r13
movl %r13d, %edi
callq 0x1030
leaq 0x2d35(%rip), %rdi      # 0x40f4
xorl %eax, %eax
callq 0x1040
pushq $0x41
popq %rbx
subl $0x1, %ebx
jb 0x13ec
movq %r14, %rdi
pushq $0x2
popq %rsi
callq 0x2890
testq %rax, %rax
pushq $0x48
popq %rdi
pushq $0x54
popq %rax
cmovel %eax, %edi
callq 0x1030
jmp 0x13c9
movl %r13d, %edi
callq 0x1030
leaq 0x2d03(%rip), %rdi      # 0x40fe
xorl %eax, %eax
callq 0x1040
pushq $0x21
popq %rbx
subl $0x1, %ebx
jb 0x1428
movq %r14, %rdi
pushq $0x6
popq %rsi
callq 0x2890
leal 0x1(%rax), %esi
leaq 0x2ce8(%rip), %rdi      # 0x4107
xorl %eax, %eax
callq 0x1040
jmp 0x1405
movl %r13d, %edi
callq 0x1030
xorl %eax, %eax
cmpq $0x34, %rax
je 0x1441
movb %al, 0x30(%rsp,%rax)
incq %rax
jmp 0x1432
pushq $0x34
popq %rbx
cmpq $0x1, %rbx
jbe 0x146c
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2890
cltq
movb 0x30(%rsp,%rax), %cl
movb 0x2f(%rsp,%rbx), %dl
movb %dl, 0x30(%rsp,%rax)
movb %cl, 0x2f(%rsp,%rbx)
decq %rbx
jmp 0x1444
leaq 0x2c98(%rip), %rdi      # 0x410b
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x1040
cmpq $0x34, %rbx
je 0x14d3
movsbl 0x30(%rsp,%rbx), %eax
movb $0x4, %cl
idivb %cl
movsbl %ah, %ecx
movsbq %al, %rax
leaq 0x2c81(%rip), %rdx      # 0x411a
movsbl (%rax,%rdx), %esi
movslq %ecx, %rax
leaq 0x2c80(%rip), %rcx      # 0x4127
movsbl (%rax,%rcx), %edx
leaq 0x2c62(%rip), %rdi      # 0x4114
xorl %eax, %eax
callq 0x1040
incq %rbx
movzbl %bl, %eax
movb $0x16, %cl
divb %cl
movzbl %ah, %eax
testb %al, %al
jne 0x147c
leaq 0x2c0c(%rip), %rdi      # 0x40dd
jmp 0x1475
movl %r13d, %edi
callq 0x1030
movl %r13d, %edi
callq 0x1030
movl 0x2c(%rsp), %esi
incl %esi
jmp 0x1274
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x2, %eax
jne 0x150d
pushq $0x5
popq %r14
jmp 0x11d8
movq 0x10(%rsi), %rdi
movb $0x1, %bl
jmp 0x11cc