// File: /workspace/github_c_makefile_star2_O3/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, %r14
movq %rsi, %r15
movq %rdi, %r12
movq %rsi, %rdi
movq %r12, %rsi
callq 0x3c19
testb %al, %al
je 0x4a70
movq (%r12), %rax
movq %rax, (%rbx)
movq 0x8(%r12), %rax
movq %rax, 0x8(%rbx)
movq 0x10(%r12), %rax
movq %rax, 0x10(%rbx)
movq 0x18(%r12), %rax
movq %rax, 0x18(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
movups %xmm0, (%r14)
jmp 0x4c2c
movq %r14, 0x48(%rsp)
xorps %xmm0, %xmm0
leaq 0x90(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq $0x1, 0x18(%rax)
movq %r12, %rdi
callq 0x3adb
movl %eax, %ebp
movq %r15, %rdi
callq 0x3adb
subl %eax, %ebp
movq (%r12), %r13
movq %r13, 0x28(%rsp)
movq 0x8(%r12), %r14
movq %r14, 0x30(%rsp)
movq 0x10(%r12), %rax
movq %rax, 0x10(%rsp)
movq %rax, 0x38(%rsp)
movq 0x18(%r12), %rax
movq %rax, (%rsp)
movq %rax, 0x40(%rsp)
leaq 0x50(%rsp), %r12
movq %r15, %rdi
movl %ebp, %esi
movq %r12, %rdx
callq 0x3452
leaq 0x70(%rsp), %rdx
leaq 0x90(%rsp), %rdi
movl %ebp, %esi
callq 0x3452
cmpq %r13, (%r12)
jne 0x4b24
cmpq %r14, 0x58(%rsp)
movq %r14, %r12
jne 0x4b27
movq 0x10(%rsp), %r14
cmpq %r14, 0x60(%rsp)
movq (%rsp), %rbp
jne 0x4b30
cmpq %rbp, 0x68(%rsp)
jmp 0x4b30
movq %r14, %r12
movq 0x10(%rsp), %r14
movq (%rsp), %rbp
jbe 0x4b56
leaq 0x50(%rsp), %rdi
movl $0x1, %esi
movq %rdi, %rdx
callq 0x3731
leaq 0x70(%rsp), %rdi
movl $0x1, %esi
movq %rdi, %rdx
callq 0x3731
leaq 0x28(%rsp), %rdi
movq %r15, %rsi
callq 0x3c9c
xorps %xmm0, %xmm0
xorps %xmm1, %xmm1
testb %al, %al
je 0x4c11
movaps %xmm0, 0x10(%rsp)
leaq 0x28(%rsp), %r12
leaq 0x50(%rsp), %r13
leaq 0x70(%rsp), %rbp
movaps %xmm0, (%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x3c9c
testb %al, %al
je 0x4bc5
movq %r12, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x3df3
movaps 0x10(%rsp), %xmm0
orps 0x70(%rsp), %xmm0
movaps %xmm0, 0x10(%rsp)
movaps (%rsp), %xmm0
orps 0x80(%rsp), %xmm0
movaps %xmm0, (%rsp)
movq %r13, %rdi
movl $0x1, %esi
movq %r13, %rdx
callq 0x3731
movq %rbp, %rdi
movl $0x1, %esi
movq %rbp, %rdx
callq 0x3731
movq %r12, %rdi
movq %r15, %rsi
callq 0x3c9c
testb %al, %al
jne 0x4b89
movq 0x28(%rsp), %r13
movq 0x30(%rsp), %r12
movq 0x38(%rsp), %r14
movq 0x40(%rsp), %rbp
movaps 0x10(%rsp), %xmm0
movaps (%rsp), %xmm1
movq 0x48(%rsp), %rax
movups %xmm0, (%rax)
movups %xmm1, 0x10(%rax)
movq %r13, (%rbx)
movq %r12, 0x8(%rbx)
movq %r14, 0x10(%rbx)
movq %rbp, 0x18(%rbx)
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq