// File: /workspace/github_c_makefile_star2_O3/pyk[P]simple-nn/deps/pcg/sample/pcg32-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.

    pcg32_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).
    //
    // 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_r(&rng, seeds[0], seeds[1]);
    } else {
        // Seed with a fixed constant

        pcg32_srandom_r(&rng, 42u, 54u);
    }

    printf("pcg32_random_r:\n"
           "      -  result:      32-bit unsigned int (uint32_t)\n"
           "      -  period:      2^64   (* 2^63 streams)\n"
           "      -  state type:  pcg32_random_t (%zu bytes)\n"
           "      -  output func: XSH-RR\n"
           "\n",
           sizeof(pcg32_random_t));

    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_r(&rng));
        printf("\n");

        printf("  Again:");
        pcg32_advance_r(&rng, -6);
        for (int i = 0; i < 6; ++i)
            printf(" 0x%08x", pcg32_random_r(&rng));
        printf("\n");

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

        /* Roll some dice */
        printf("  Rolls:");
        for (int i = 0; i < 33; ++i)
            printf(" %d", (int)pcg32_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 = pcg32_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 0x11fe
movq 0x8(%rsi), %rax
cmpb $0x2d, (%rax)
jne 0x11c8
cmpb $0x72, 0x1(%rax)
jne 0x11c8
cmpb $0x0, 0x2(%rax)
je 0x156a
movabsq $0x185706b82c2e03f8, %r14 # imm = 0x185706B82C2E03F8
movq %rax, %rdi
callq 0x1090
movl %eax, %ebp
movl $0x6d, %r15d
leaq 0xe67(%rip), %rdi       # 0x2050
movl $0x10, %esi
xorl %eax, %eax
callq 0x1040
testl %ebp, %ebp
jg 0x1226
jmp 0x1559
movabsq $0x185706b82c2e03f8, %r14 # imm = 0x185706B82C2E03F8
leaq 0xe41(%rip), %rdi       # 0x2050
movl $0x10, %esi
xorl %eax, %eax
callq 0x1040
movl $0x5, %ebp
movl $0x6d, %r15d
movl $0x1, %esi
movabsq $0x5851f42d4c957f2d, %r12 # imm = 0x5851F42D4C957F2D
leaq 0xeeb(%rip), %r13       # 0x2127
pshufd $0xf5, 0xdeb(%rip), %xmm0 # xmm0 = mem[1,1,3,3]
movdqa %xmm0, 0x50(%rsp)
movl %ebp, 0x4(%rsp)
leaq 0xebd(%rip), %rdi       # 0x2113
movq %rsi, 0x8(%rsp)
xorl %eax, %eax
callq 0x1040
leaq 0xeb5(%rip), %rdi       # 0x211e
xorl %eax, %eax
callq 0x1040
movl $0x6, %ebx
movq %r14, %rcx
imulq %r12, %r14
addq %r15, %r14
movq %rcx, %rsi
shrq $0x2d, %rsi
movq %rcx, %rax
shrq $0x1b, %rax
xorl %eax, %esi
shrq $0x3b, %rcx
rorl %cl, %esi
movq %r13, %rdi
xorl %eax, %eax
callq 0x1040
decl %ebx
jne 0x1275
movl $0xa, %edi
callq 0x1030
leaq 0xe7b(%rip), %rdi       # 0x212f
xorl %eax, %eax
callq 0x1040
movq %r14, %rdi
movq $-0x6, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x16e8
movq %rax, %r14
movl $0x6, %ebx
movq %r14, %rcx
imulq %r12, %r14
addq %r15, %r14
movq %rcx, %rsi
shrq $0x2d, %rsi
movq %rcx, %rax
shrq $0x1b, %rax
xorl %eax, %esi
shrq $0x3b, %rcx
rorl %cl, %esi
movq %r13, %rdi
xorl %eax, %eax
callq 0x1040
decl %ebx
jne 0x12d8
movl $0xa, %edi
callq 0x1030
leaq 0xe21(%rip), %rdi       # 0x2138
xorl %eax, %eax
callq 0x1040
movl $0x41, %ebx
movl $0xaaaaaaab, %r13d      # imm = 0xAAAAAAAB
movq %r14, %rax
shrq $0x2d, %rax
movq %r14, %rcx
shrq $0x1b, %rcx
xorl %ecx, %eax
movq %r14, %rcx
shrq $0x3b, %rcx
rorl %cl, %eax
movl $0x54, %edi
testb $0x1, %al
je 0x1350
movl $0x48, %edi
imulq %r12, %r14
addq %r15, %r14
callq 0x1030
decl %ebx
jne 0x1329
movl $0xa, %edi
callq 0x1030
xorl %ebx, %ebx
leaq 0xdcf(%rip), %rdi       # 0x2142
xorl %eax, %eax
callq 0x1040
movq %r14, %rcx
imulq %r12, %r14
addq %r15, %r14
movq %rcx, %rax
shrq $0x2d, %rax
movq %rcx, %rdx
shrq $0x1b, %rdx
xorl %edx, %eax
shrq $0x3b, %rcx
rorl %cl, %eax
cmpl $0x4, %eax
jb 0x137a
movl %eax, %ecx
imulq %r13, %rcx
shrq $0x22, %rcx
addl %ecx, %ecx
leal (%rcx,%rcx,2), %ecx
negl %ecx
leal (%rax,%rcx), %esi
incl %esi
leaq 0xd8f(%rip), %rdi       # 0x214b
xorl %eax, %eax
callq 0x1040
incl %ebx
cmpl $0x21, %ebx
jne 0x137a
movl $0xa, %edi
callq 0x1030
xorl %eax, %eax
movdqa 0xc32(%rip), %xmm0      # 0x2010
movdqa 0xc3a(%rip), %xmm3      # 0x2020
movdqa 0xc42(%rip), %xmm4      # 0x2030
movdqa 0x50(%rsp), %xmm5
movdqa 0xc44(%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 0x1426
movb %al, 0x10(%rsp,%rax)
pextrw $0x4, %xmm1, %ecx
testb $0x1, %cl
je 0x1437
leal 0x1(%rax), %ecx
movb %cl, 0x11(%rsp,%rax)
addq $0x2, %rax
paddq %xmm6, %xmm0
cmpq $0x34, %rax
jne 0x13fc
movl $0x34, %esi
movl %esi, %eax
negl %eax
xorl %edx, %edx
divl %esi
movq %r14, %rcx
imulq %r12, %r14
addq %r15, %r14
movq %rcx, %rax
shrq $0x2d, %rax
movq %rcx, %rdi
shrq $0x1b, %rdi
xorl %edi, %eax
shrq $0x3b, %rcx
rorl %cl, %eax
cmpl %edx, %eax
jb 0x1452
xorl %edx, %edx
divl %esi
movb 0x10(%rsp,%rdx), %al
movb 0xf(%rsp,%rsi), %cl
movb %cl, 0x10(%rsp,%rdx)
movb %al, 0xf(%rsp,%rsi)
leaq -0x1(%rsi), %rax
cmpq $0x2, %rsi
movq %rax, %rsi
ja 0x144a
leaq 0xcb1(%rip), %rdi       # 0x214f
xorl %eax, %eax
callq 0x1040
movb $0x1, %bl
xorl %r13d, %r13d
movl %ebx, %eax
shrb %al
movzbl %al, %eax
imull $0xbb, %eax, %eax
shrl $0xb, %eax
leal (%rax,%rax,4), %ecx
leal (%rax,%rcx,4), %ebp
addl %eax, %ebp
movb 0x10(%rsp,%r13), %al
movl %eax, %ecx
sarb $0x7, %cl
shrb $0x6, %cl
addb %al, %cl
movl %ecx, %edx
sarb $0x2, %dl
movsbq %dl, %rdx
leaq 0xc80(%rip), %rsi       # 0x2161
movsbl (%rdx,%rsi), %esi
andb $-0x4, %cl
subb %cl, %al
movsbq %al, %rax
leaq 0xc79(%rip), %rcx       # 0x216e
movsbl (%rax,%rcx), %edx
leaq 0xc58(%rip), %rdi       # 0x2158
xorl %eax, %eax
callq 0x1040
decb %bpl
cmpb %r13b, %bpl
jne 0x151d
leaq 0xc48(%rip), %rdi       # 0x215e
xorl %eax, %eax
callq 0x1040
incq %r13
incb %bl
cmpq $0x34, %r13
jne 0x14aa
movl $0xa, %edi
callq 0x1030
movl $0xa, %edi
callq 0x1030
movq 0x8(%rsp), %rcx
leal 0x1(%rcx), %eax
movl 0x4(%rsp), %ebp
cmpl %ebp, %ecx
movl %eax, %esi
leaq 0xbd4(%rip), %r13       # 0x2127
jne 0x124f
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x5, %ebp
cmpl $0x2, %edi
je 0x157f
movq 0x10(%rsi), %rdi
callq 0x1090
movl %eax, %ebp
leaq 0x10(%rsp), %rbx
movl $0x10, %esi
movq %rbx, %rdi
callq 0x15c0
movq 0x8(%rbx), %rax
leaq 0x1(,%rax,2), %r15
movq (%rbx), %rcx
addq %r15, %rcx
movabsq $0x5851f42d4c957f2d, %rdx # imm = 0x5851F42D4C957F2D
imulq %rcx, %rdx
leaq (%rdx,%rax,2), %r14
incq %r14
jmp 0x11e2
nopl (%rax)