// File: /workspace/github_c_makefile_star2_O1/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 $0xa8, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movq %rsi, %rdi
movq %r12, %rsi
callq 0x3c78
testb %al, %al
je 0x4bf5
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 0x4dc1
movq %r14, 0x30(%rsp)
movq %rbx, 0x38(%rsp)
xorps %xmm0, %xmm0
leaq 0x80(%rsp), %r13
movaps %xmm0, 0x10(%r13)
movaps %xmm0, (%r13)
movq $0x1, 0x18(%r13)
movq %r12, %rdi
callq 0x3b35
movl %eax, %ebp
movq %r15, %rdi
callq 0x3b35
subl %eax, %ebp
movq (%r12), %rbx
movq %rbx, 0x10(%rsp)
movq %r15, %rdi
movq 0x8(%r12), %r15
movq %r15, 0x18(%rsp)
movq 0x10(%r12), %r14
movq %r14, 0x20(%rsp)
movq 0x18(%r12), %r12
movq %r12, 0x28(%rsp)
leaq 0x60(%rsp), %rdx
movq %rdi, 0x8(%rsp)
movl %ebp, %esi
callq 0x3452
leaq 0x40(%rsp), %rdx
movq %r13, %rdi
movl %ebp, %esi
callq 0x3452
leaq 0x60(%rsp), %rax
cmpq %rbx, (%rax)
jne 0x4ca1
cmpq %r15, 0x68(%rsp)
jne 0x4ca1
cmpq %r14, 0x70(%rsp)
movq 0x8(%rsp), %rbx
jne 0x4c9c
cmpq %r12, 0x78(%rsp)
seta %al
jmp 0x4ca9
seta %al
movq 0x8(%rsp), %rbx
testb %al, %al
je 0x4cd1
leaq 0x60(%rsp), %rdi
movl $0x1, %esi
movq %rdi, %rdx
callq 0x375c
leaq 0x40(%rsp), %rdi
movl $0x1, %esi
movq %rdi, %rdx
callq 0x375c
leaq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x3d26
testb %al, %al
je 0x4d71
movq $0x0, (%rsp)
leaq 0x10(%rsp), %r12
leaq 0x60(%rsp), %r13
leaq 0x40(%rsp), %rbp
xorl %ebx, %ebx
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %r12, %rdi
movq %r13, %rsi
callq 0x3d26
testb %al, %al
je 0x4d3e
movq %r12, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x3e8b
orq 0x40(%rsp), %r15
orq 0x48(%rsp), %r14
orq 0x50(%rsp), %rbx
movq (%rsp), %rax
orq 0x58(%rsp), %rax
movq %rax, (%rsp)
movq %r13, %rdi
movl $0x1, %esi
movq %r13, %rdx
callq 0x375c
movq %rbp, %rdi
movl $0x1, %esi
movq %rbp, %rdx
callq 0x375c
movq %r12, %rdi
movq 0x8(%rsp), %rsi
callq 0x3d26
testb %al, %al
jne 0x4d05
jmp 0x4d81
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %ebx, %ebx
movq $0x0, (%rsp)
movq 0x30(%rsp), %rax
movq %r15, (%rax)
movq %r14, 0x8(%rax)
movq %rbx, 0x10(%rax)
movq (%rsp), %rcx
movq %rcx, 0x18(%rax)
movq 0x10(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rax, (%rcx)
movq 0x18(%rsp), %rax
movq %rax, 0x8(%rcx)
movq 0x20(%rsp), %rax
movq %rax, 0x10(%rcx)
movq 0x28(%rsp), %rax
movq %rax, 0x18(%rcx)
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq