// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movl %edi, %r14d
leaq 0x8(%rsi), %r15
leal -0x1(%r14), %r12d
cmpl $0x2, %edi
jl 0x11e4
movq %rsi, %rbx
movq (%r15), %rdi
leaq 0xe2d(%rip), %rsi       # 0x2004
callq 0x1070
testl %eax, %eax
je 0x169d
xorl %ebp, %ebp
testl %r12d, %r12d
jle 0x11f9
movq (%r15), %rdi
callq 0x10a0
movl %eax, 0x10(%rsp)
jmp 0x1201
movl $0x5, 0x10(%rsp)
movabsq $0x2360ed051fc65da4, %rax # imm = 0x2360ED051FC65DA4
movabsq $0x4385df649fccf645, %r13 # imm = 0x4385DF649FCCF645
testb %bpl, %bpl
je 0x1270
leaq 0x20(%rsp), %r14
movl $0x20, %esi
movq %r14, %rdi
movq %rax, %rbx
callq 0x16b4
movq 0x10(%r14), %rax
movq 0x18(%r14), %r12
shldq $0x1, %rax, %r12
leaq 0x1(,%rax,2), %rbp
movq (%r14), %rax
addq %rbp, %rax
movq 0x8(%r14), %r14
adcq %r12, %r14
movq %rax, %rcx
imulq %rbx, %rcx
mulq %r13
movq %rax, %r15
addq %rcx, %rdx
imulq %r13, %r14
addq %rdx, %r14
addq %rbp, %r15
adcq %r12, %r14
jmp 0x128c
movabsq $-0x21d431fa41fec41d, %r14 # imm = 0xDE2BCE05BE013BE3
movabsq $-0x2c093ba5be1abce0, %r15 # imm = 0xD3F6C45A41E54320
movl $0x6d, %ebp
xorl %r12d, %r12d
leaq 0xd74(%rip), %rdi       # 0x2007
movl $0x20, %esi
xorl %eax, %eax
callq 0x1040
cmpl $0x0, 0x10(%rsp)
jle 0x168c
movl $0x1, %esi
leaq 0xe16(%rip), %rdi       # 0x20cc
movq %rsi, 0x18(%rsp)
xorl %eax, %eax
callq 0x1040
leaq 0xe0e(%rip), %rdi       # 0x20d7
xorl %eax, %eax
callq 0x1040
xorl %ebx, %ebx
movl $0x0, 0xc(%rsp)
testl %ebx, %ebx
je 0x1306
movl 0xc(%rsp), %eax
movl $0xaaaaaaab, %ecx       # imm = 0xAAAAAAAB
imulq %rcx, %rax
shrq $0x21, %rax
leal (%rax,%rax,2), %eax
negl %eax
cmpl %ebx, %eax
jne 0x1306
leaq 0xde1(%rip), %rdi       # 0x20e0
xorl %eax, %eax
callq 0x1040
movq %r15, %rax
mulq %r13
movabsq $0x2360ed051fc65da4, %rcx # imm = 0x2360ED051FC65DA4
imulq %rcx, %r15
addq %rdx, %r15
imulq %r13, %r14
addq %r15, %r14
movq %rax, %r15
addq %rbp, %r15
adcq %r12, %r14
movq %r14, %rsi
xorq %r15, %rsi
movq %r14, %rcx
shrq $0x3a, %rcx
rorq %cl, %rsi
leaq 0xd9f(%rip), %rdi       # 0x20e3
xorl %eax, %eax
callq 0x1040
incl 0xc(%rsp)
decl %ebx
cmpl $-0x6, %ebx
jne 0x12da
movl $0xa, %edi
callq 0x1030
xorl %ebx, %ebx
leaq 0xd85(%rip), %rdi       # 0x20ee
xorl %eax, %eax
callq 0x1040
movq %r15, %rdi
movq %r14, %rsi
movq $-0x6, %rdx
movq $-0x1, %rcx
movabsq $0x4385df649fccf645, %r8 # imm = 0x4385DF649FCCF645
movabsq $0x2360ed051fc65da4, %r9 # imm = 0x2360ED051FC65DA4
pushq %r12
pushq %rbp
callq 0x17dc
addq $0x10, %rsp
movq %rax, %r15
movq %rdx, %r14
movl $0x0, 0xc(%rsp)
testl %ebx, %ebx
je 0x13de
movl 0xc(%rsp), %eax
movl $0xaaaaaaab, %ecx       # imm = 0xAAAAAAAB
imulq %rcx, %rax
shrq $0x21, %rax
leal (%rax,%rax,2), %eax
negl %eax
cmpl %ebx, %eax
jne 0x13de
leaq 0xd09(%rip), %rdi       # 0x20e0
xorl %eax, %eax
callq 0x1040
movq %r15, %rax
mulq %r13
movabsq $0x2360ed051fc65da4, %rcx # imm = 0x2360ED051FC65DA4
imulq %rcx, %r15
addq %rdx, %r15
imulq %r13, %r14
addq %r15, %r14
movq %rax, %r15
addq %rbp, %r15
adcq %r12, %r14
movq %r14, %rsi
xorq %r15, %rsi
movq %r14, %rcx
shrq $0x3a, %rcx
rorq %cl, %rsi
leaq 0xcc7(%rip), %rdi       # 0x20e3
xorl %eax, %eax
callq 0x1040
incl 0xc(%rsp)
decl %ebx
cmpl $-0x6, %ebx
jne 0x13b2
movl $0xa, %edi
callq 0x1030
leaq 0xcb8(%rip), %rdi       # 0x20f7
xorl %eax, %eax
callq 0x1040
movl $0x41, %ebx
movq %r15, %rax
mulq %r13
movabsq $0x2360ed051fc65da4, %rcx # imm = 0x2360ED051FC65DA4
imulq %rcx, %r15
addq %rdx, %r15
imulq %r13, %r14
addq %r15, %r14
movq %rax, %r15
addq %rbp, %r15
adcq %r12, %r14
movq %r14, %rax
xorq %r15, %rax
movq %r14, %rcx
shrq $0x3a, %rcx
rorq %cl, %rax
movl $0x54, %edi
testb $0x1, %al
je 0x1490
movl $0x48, %edi
callq 0x1030
decl %ebx
jne 0x144b
movl $0xa, %edi
callq 0x1030
xorl %ebx, %ebx
leaq 0xc55(%rip), %rdi       # 0x2101
xorl %eax, %eax
callq 0x1040
movabsq $0x2360ed051fc65da4, %r8 # imm = 0x2360ED051FC65DA4
movabsq $-0x5555555555555555, %r9 # imm = 0xAAAAAAAAAAAAAAAB
movq %r15, %rax
mulq %r13
imulq %r8, %r15
addq %rdx, %r15
imulq %r13, %r14
addq %r15, %r14
movq %rax, %r15
addq %rbp, %r15
adcq %r12, %r14
movq %r14, %rdi
xorq %r15, %rdi
movq %r14, %rcx
shrq $0x3a, %rcx
rorq %cl, %rdi
movq %rdi, %rax
mulq %r9
shrq %rdx
andq $-0x2, %rdx
leaq (%rdx,%rdx,2), %rax
movq %rdi, %rcx
subq %rax, %rcx
cmpq $0x4, %rdi
cmovaeq %rcx, %rsi
jb 0x14c7
incl %esi
leaq 0xbec(%rip), %rdi       # 0x210a
xorl %eax, %eax
callq 0x1040
incl %ebx
cmpl $0x21, %ebx
jne 0x14b3
movl $0xa, %edi
callq 0x1030
xorl %eax, %eax
movb %al, 0x20(%rsp,%rax)
incq %rax
cmpq $0x34, %rax
jne 0x1538
movl $0x34, %r9d
movabsq $0x2360ed051fc65da4, %r10 # imm = 0x2360ED051FC65DA4
movq %r9, %rax
negq %rax
xorl %edx, %edx
divq %r9
movq %rdx, %rsi
movq %r15, %rax
mulq %r13
imulq %r10, %r15
addq %rdx, %r15
imulq %r13, %r14
addq %r15, %r14
movq %rax, %r15
addq %rbp, %r15
adcq %r12, %r14
movq %r14, %r8
xorq %r15, %r8
movq %r14, %rcx
shrq $0x3a, %rcx
rorq %cl, %r8
cmpq %rsi, %r8
jb 0x15a0
movq %r8, %rax
xorl %edx, %edx
divq %r9
movq %rdx, %rdi
cmpq %rsi, %r8
jb 0x1563
movslq %edi, %rax
movb 0x20(%rsp,%rax), %cl
movb 0x1f(%rsp,%r9), %dl
movb %dl, 0x20(%rsp,%rax)
movb %cl, 0x1f(%rsp,%r9)
leaq -0x1(%r9), %rax
cmpq $0x2, %r9
movq %rax, %r9
ja 0x1555
leaq 0xb40(%rip), %rdi       # 0x210e
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 0xb04(%rip), %rsi       # 0x211d
movsbl (%rdx,%rsi), %esi
andl $-0x4, %ecx
subl %ecx, %eax
cltq
leaq 0xaff(%rip), %rcx       # 0x212a
movsbl (%rax,%rcx), %edx
leaq 0xae1(%rip), %rdi       # 0x2117
xorl %eax, %eax
callq 0x1040
cmpl %ebx, 0x14(%rsp)
jne 0x1651
leaq 0xa96(%rip), %rdi       # 0x20e0
xorl %eax, %eax
callq 0x1040
incq %rbx
movl 0xc(%rsp), %eax
incl %eax
cmpq $0x34, %rbx
jne 0x15dc
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 0x12af
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq $0x10, %rbx
addl $-0x2, %r14d
movb $0x1, %bpl
movq %rbx, %r15
movl %r14d, %r12d
jmp 0x11e6
nop