// File: /workspace/github_c_makefile_star2_O1/BernardTatin[P]s7sh/s7.c
// Function: s7_random_state
s7_pointer s7_random_state(s7_scheme *sc, s7_pointer args)
    {
#define H_random_state "(random-state seed (carry plausible-default)) returns a new random number state initialized with 'seed'. \
        Pass this as the second argument to 'random' to get a repeatable random number sequence:\n\
        (let ((seed (random-state 1234))) (random 1.0 seed))"
#define Q_random_state s7_make_circular_signature(sc, 1, 2, sc->is_random_state_symbol, sc->is_integer_symbol)

        s7_pointer r1, r2, p;
        s7_int i1, i2;

        r1 = car(args);
        if (!s7_is_integer(r1))
            return(method_or_bust(sc, r1, sc->random_state_symbol, args, T_INTEGER, 1));
        i1 = integer(r1);
        if (i1 < 0)
            return(out_of_range(sc, sc->random_state_symbol, small_int(1), r1, its_negative_string));

        if (is_null(cdr(args)))
        {
            new_cell(sc, p, T_RANDOM_STATE);
            random_seed(p) = (uint64_t)i1;
            random_carry(p) = 1675393560;                          /* should this be dependent on the seed? */
            return(p);
        }

        r2 = cadr(args);
        if (!s7_is_integer(r2))
            return(method_or_bust(sc, r2, sc->random_state_symbol, args, T_INTEGER, 2));
        i2 = integer(r2);
        if (i2 < 0)
            return(out_of_range(sc, sc->random_state_symbol, small_int(2), r2, its_negative_string));

        new_cell(sc, p, T_RANDOM_STATE);
        random_seed(p) = (uint64_t)i1;
        random_carry(p) = (uint64_t)i2;
        return(p);
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rcx
movq %rdi, %rbx
movq 0x8(%rsi), %rsi
cmpb $0xb, (%rsi)
jne 0xf0ab
movq 0x8(%rsi), %r15
testq %r15, %r15
js 0xf0d1
movq 0x10(%rcx), %rax
cmpq 0x110(%rbx), %rax
je 0xf12c
movq 0x8(%rax), %rsi
cmpb $0xb, (%rsi)
jne 0xf17c
movq 0x8(%rsi), %r12
testq %r12, %r12
js 0xf197
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xf081
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r14
movq $0x24, (%r14)
movq %r15, 0x8(%r14)
movq %r12, 0x10(%r14)
jmp 0xf16d
movq 0x1420(%rbx), %rdx
movq %rbx, %rdi
movl $0xb, %r8d
movl $0x1, %r9d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0xf1ae
movq 0x1420(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x13f875(%rip), %rcx    # 0x14e958
movq 0x14395e(%rip), %rdx    # 0x152a48
movq 0x1ee8(%rbx), %rdi
movq 0x10(%rdi), %rdi
movq %rax, 0x8(%rdi)
movq 0x10(%rdi), %rax
movq %rcx, 0x8(%rax)
movq 0x10(%rax), %rax
movq %rsi, 0x8(%rax)
movq 0x10(%rax), %rax
movq %rdx, 0x8(%rax)
movq 0x1948(%rbx), %r14
movq 0x1ee8(%rbx), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3b366
jmp 0xf16d
movq 0x90(%rbx), %rax
cmpq 0x98(%rbx), %rax
ja 0xf144
movq %rbx, %rdi
callq 0xb389
movq 0x90(%rbx), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x90(%rbx)
movq -0x8(%rax), %r14
movq $0x24, (%r14)
movq %r15, 0x8(%r14)
movq $0x63dc7a18, 0x10(%r14) # imm = 0x63DC7A18
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq 0x1420(%rbx), %rdx
movq %rbx, %rdi
movl $0xb, %r8d
movl $0x2, %r9d
jmp 0xf0c1
movq 0x1420(%rbx), %rax
movq 0x8(%rax), %rax
movq 0x13f7b7(%rip), %rcx    # 0x14e960
jmp 0xf0e3