// File: /workspace/github_c_makefile_star2_O3/pyk[P]simple-nn/deps/pcg/sample/pcg32-global-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 the global rng, rather than a
    // local one.

    // 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).
    //
    // pcg32_srandom_r takes two 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[2];
        entropy_getbytes((void*)seeds, sizeof(seeds));
        pcg32_srandom(seeds[0], seeds[1]);
    } else {
        // Seed with a fixed constant

        pcg32_srandom(42u, 54u);
    }

    printf("pcg32_random:\n"
           "      -  result:      32-bit unsigned int (uint32_t)\n"
           "      -  period:      2^64   (* 2^63 streams)\n"
           "      -  state type:  N/A (private global)\n"
           "      -  output func: XSH-RR\n"
           "\n");

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

        /* Make some 32-bit numbers */
        printf("  32bit:");
        for (int i = 0; i < 6; ++i)
            printf(" 0x%08x", pcg32_random());
        printf("\n");

        printf("  Again:");
        pcg32_advance(-6);
        for (int i = 0; i < 6; ++i)
            printf(" 0x%08x", pcg32_random());
        printf("\n");

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

        /* Roll some dice */
        printf("  Rolls:");
        for (int i = 0; i < 33; ++i)
            printf(" %d", (int)pcg32_boundedrand(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 = pcg32_boundedrand(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
movl $0x5, 0x4(%rsp)
cmpl $0x2, %edi
jl 0x11ec
movq 0x8(%rsi), %rax
cmpb $0x2d, (%rax)
jne 0x11e0
cmpb $0x72, 0x1(%rax)
jne 0x11e0
cmpb $0x0, 0x2(%rax)
je 0x14ab
movq %rax, %rdi
callq 0x10a0
movl %eax, 0x4(%rsp)
movl $0x2a, %edi
movl $0x36, %esi
callq 0x1699
leaq 0xe9c(%rip), %rdi       # 0x209e
callq 0x1040
cmpl $0x0, 0x4(%rsp)
jle 0x149a
movl $0x1, %esi
leaq 0xe46(%rip), %r13       # 0x2064
movl $0x54, %ebp
leaq 0xe5e(%rip), %r14       # 0x2088
pshufd $0xf5, 0xdfd(%rip), %xmm0 # xmm0 = mem[1,1,3,3]
movdqa %xmm0, 0x50(%rsp)
leaq 0xf25(%rip), %r15       # 0x2165
leaq 0xe4e(%rip), %r12       # 0x2095
leaq 0xe02(%rip), %rdi       # 0x2050
movq %rsi, 0x8(%rsp)
xorl %eax, %eax
callq 0x1050
leaq 0xdfa(%rip), %rdi       # 0x205b
xorl %eax, %eax
callq 0x1050
movl $0x6, %ebx
xorl %eax, %eax
callq 0x160c
movq %r13, %rdi
movl %eax, %esi
xorl %eax, %eax
callq 0x1050
decl %ebx
jne 0x126d
movl $0xa, %edi
callq 0x1030
leaq 0xdd7(%rip), %rdi       # 0x206c
xorl %eax, %eax
callq 0x1050
movq $-0x6, %rdi
callq 0x16cc
movl $0x6, %ebx
xorl %eax, %eax
callq 0x160c
movq %r13, %rdi
movl %eax, %esi
xorl %eax, %eax
callq 0x1050
decl %ebx
jne 0x12ad
movl $0xa, %edi
callq 0x1030
leaq 0xda0(%rip), %rdi       # 0x2075
xorl %eax, %eax
callq 0x1050
movl $0x41, %ebx
movl $0x2, %edi
callq 0x1646
testl %eax, %eax
movl $0x48, %edi
cmovel %ebp, %edi
callq 0x1030
decl %ebx
jne 0x12e1
movl $0xa, %edi
callq 0x1030
leaq 0xd70(%rip), %rdi       # 0x207f
xorl %eax, %eax
callq 0x1050
movl $0x21, %ebx
movl $0x6, %edi
callq 0x1646
leal 0x1(%rax), %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x1050
decl %ebx
jne 0x131b
movl $0xa, %edi
callq 0x1030
xorl %eax, %eax
movdqa 0xcc6(%rip), %xmm0      # 0x2010
movdqa 0xcce(%rip), %xmm3      # 0x2020
movdqa 0xcd6(%rip), %xmm4      # 0x2030
movdqa 0x50(%rsp), %xmm5
movdqa 0xcd8(%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 0x1392
movb %al, 0x10(%rsp,%rax)
pextrw $0x4, %xmm1, %ecx
testb $0x1, %cl
je 0x13a3
leal 0x1(%rax), %ecx
movb %cl, 0x11(%rsp,%rax)
addq $0x2, %rax
paddq %xmm6, %xmm0
cmpq $0x34, %rax
jne 0x1368
movl $0x35, %r14d
leaq -0x1(%r14), %rbx
movl %ebx, %edi
callq 0x1646
cltq
movb 0x10(%rsp,%rax), %cl
movb 0xe(%rsp,%r14), %dl
movb %dl, 0x10(%rsp,%rax)
movb %cl, 0xe(%rsp,%r14)
movq %rbx, %r14
cmpq $0x2, %rbx
ja 0x13b7
leaq 0xca6(%rip), %rdi       # 0x208c
xorl %eax, %eax
callq 0x1050
movb $0x1, %bl
xorl %ebp, %ebp
movl %ebx, %eax
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 0x10(%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 0xd2f(%rip), %rsi       # 0x2158
movsbl (%rdx,%rsi), %esi
andb $-0x4, %cl
subb %cl, %al
movsbq %al, %rax
movsbl (%rax,%r15), %edx
movq %r12, %rdi
xorl %eax, %eax
callq 0x1050
decb %r14b
cmpb %bpl, %r14b
jne 0x145b
leaq 0xc47(%rip), %rdi       # 0x209b
xorl %eax, %eax
callq 0x1050
incq %rbp
incb %bl
cmpq $0x34, %rbp
jne 0x13f1
movl $0xa, %edi
callq 0x1030
movl $0xa, %edi
callq 0x1030
movq 0x8(%rsp), %rcx
leal 0x1(%rcx), %eax
cmpl 0x4(%rsp), %ecx
movl %eax, %esi
movl $0x54, %ebp
leaq 0xbf4(%rip), %r14       # 0x2088
jne 0x1247
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x5, 0x4(%rsp)
cmpl $0x2, %edi
je 0x14c5
movq 0x10(%rsi), %rdi
callq 0x10a0
movl %eax, 0x4(%rsp)
leaq 0x10(%rsp), %r14
movl $0x10, %esi
movq %r14, %rdi
callq 0x14e4
movq (%r14), %rdi
movq 0x8(%r14), %rsi
jmp 0x11f6
nop