// File: /workspace/github_c_makefile_star2_O2/wjmelements[P]evm/src/uint256.c
// Function: divmod256
void divmod256(const uint256_t *l, const uint256_t *r, uint256_t *retDiv, uint256_t *retMod) {
    if (gt256(r, l)) {
        copy256(retMod, l);
        clear256(retDiv);
    } else {
        uint256_t copyd, adder, resDiv, resMod;
        uint256_t one;
        clear256(&one);
        LOWER(LOWER(one)) = 1;
        uint32_t diffBits = bits256(l) - bits256(r);
        copy256(&resMod, l);
        shiftl256(r, diffBits, &copyd);
        shiftl256(&one, diffBits, &adder);
        if (gt256(&copyd, &resMod)) {
            shiftr256(&copyd, 1, &copyd);
            shiftr256(&adder, 1, &adder);
        }
        clear256(&resDiv);
        while (gte256(&resMod, r)) {
            if (gte256(&resMod, &copyd)) {
                minus256(&resMod, &copyd, &resMod);
                or256(&resDiv, &adder, &resDiv);
            }
            shiftr256(&copyd, 1, &copyd);
            shiftr256(&adder, 1, &adder);
        }
        copy256(retDiv, &resDiv);
        copy256(retMod, &resMod);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r14
movq %rsi, %rdi
movq %r14, %rsi
callq 0x3a36
testb %al, %al
je 0x47c4
movq (%r14), %rax
movq %rax, (%rbx)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rbx)
movq 0x10(%r14), %rax
movq %rax, 0x10(%rbx)
movq 0x18(%r14), %rax
movq %rax, 0x18(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r12)
movups %xmm0, (%r12)
jmp 0x4910
movq %r12, 0x28(%rsp)
xorps %xmm1, %xmm1
leaq 0x90(%rsp), %r12
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movaps %xmm1, (%r12)
andq $0x0, 0x10(%r12)
movq $0x1, 0x18(%r12)
movq %r14, %rdi
callq 0x395f
movl %eax, %ebp
movq %r15, %rdi
callq 0x395f
subl %eax, %ebp
movups (%r14), %xmm0
leaq 0x50(%rsp), %r13
movaps %xmm0, (%r13)
movups 0x10(%r14), %xmm0
movaps %xmm0, 0x10(%r13)
leaq 0x70(%rsp), %r14
movq %r15, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0x3342
leaq 0x30(%rsp), %rdx
movq %r12, %rdi
movl %ebp, %esi
callq 0x3342
movq %r14, %rdi
movq %r13, %rsi
callq 0x3a36
testb %al, %al
je 0x486d
pushq $0x1
popq %rbp
leaq 0x70(%rsp), %rdi
movl %ebp, %esi
movq %rdi, %rdx
callq 0x35f2
leaq 0x30(%rsp), %rdi
movl %ebp, %esi
movq %rdi, %rdx
callq 0x35f2
leaq 0x50(%rsp), %r12
leaq 0x70(%rsp), %r13
pushq $0x1
popq %rbp
leaq 0x30(%rsp), %r14
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq %r12, %rdi
movq %r15, %rsi
callq 0x3aa3
testb %al, %al
je 0x48ea
movq %r12, %rdi
movq %r13, %rsi
callq 0x3aa3
testb %al, %al
je 0x48ce
movq %r12, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x3bbe
movaps 0x10(%rsp), %xmm0
orps 0x30(%rsp), %xmm0
movaps %xmm0, 0x10(%rsp)
movaps (%rsp), %xmm0
orps 0x40(%rsp), %xmm0
movaps %xmm0, (%rsp)
movq %r13, %rdi
movl %ebp, %esi
movq %r13, %rdx
callq 0x35f2
movq %r14, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0x35f2
jmp 0x4886
movq 0x28(%rsp), %rax
movaps 0x10(%rsp), %xmm0
movups %xmm0, (%rax)
movaps (%rsp), %xmm0
movups %xmm0, 0x10(%rax)
movaps 0x50(%rsp), %xmm0
movups %xmm0, (%rbx)
movaps 0x60(%rsp), %xmm0
movups %xmm0, 0x10(%rbx)
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq