// File: /workspace/github_c_makefile_star2_O2/wjmelements[P]evm/src/evm.c
// Function: evmCall
static result_t evmCall(address_t from, uint64_t gas, address_t to, val_t value, data_t input) {
    account_t *fromAccount = getAccount(from);
    if (!BalanceSub(fromAccount->balance, value)) {
        fprintf(stderr, "Insufficient balance [0x%08x%08x%08x] for call (need [0x%08x%08x%08x])\n",
            fromAccount->balance[0], fromAccount->balance[1], fromAccount->balance[2],
            value[0], value[1], value[2]
        );

        result_t result;
        result.gasRemaining = 0;
        result.stateChanges = NULL;
        clear256(&result.status);
        result.returnData.size = 0;
        return result;
    }

    context_t *callContext = callstack.next;
    callContext->gas = gas;
    if (callstack.next == callstack.bottom) {
        callContext->readonly = false;
    } else {
        callContext->readonly = callContext[-1].readonly;
    }

    BalanceCopy(callContext->callValue, value);
    AddressCopy(callContext->caller, from);
    callContext->account = getAccount(to);
    BalanceAdd(callContext->account->balance, value);
    callContext->code = callContext->account->code;
    callContext->callData = input;

    return _evmCall(callContext);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, %rbp
movq %rcx, %r12
movq %rdx, %r15
movq %rsi, 0x20(%rsp)
movq %rdi, %rbx
leaq 0x88(%rsp), %r13
leaq 0x70(%rsp), %r14
movl 0x10(%r14), %eax
movl %eax, 0x10(%rsp)
movaps (%r14), %xmm0
movups %xmm0, (%rsp)
callq 0x6a99
xorl %edx, %edx
pushq $0x2
popq %rcx
cmpq $-0x1, %rcx
je 0x7283
movzbl %cl, %esi
shll $0x2, %esi
movl 0x14(%rax,%rsi), %edi
addl (%r15,%rsi), %edx
xorl %r8d, %r8d
subl %edx, %edi
setb %r8b
movl %edi, 0x28(%rsp,%rsi)
decq %rcx
movl %r8d, %edx
jmp 0x725a
testl %edx, %edx
jne 0x735c
movq %r13, %rdx
movq %rbx, %r13
movq %rbp, %rbx
movq 0x28(%rsp), %rcx
movq %rcx, 0x14(%rax)
movl 0x30(%rsp), %ecx
movl %ecx, 0x1c(%rax)
leaq 0x177b5(%rip), %rax     # 0x1ea60
movq 0x2024000(%rax), %rbp
movq 0x20(%rsp), %rcx
movq %rcx, 0x8080(%rbp)
cmpq %rax, %rbp
je 0x72c8
movb -0x8(%rbp), %al
jmp 0x72ca
xorl %eax, %eax
movb %al, 0x8088(%rbp)
movq (%r15), %rax
movq %rax, 0x8038(%rbp)
movl 0x8(%r15), %eax
movl %eax, 0x8040(%rbp)
movups (%r14), %xmm0
movups %xmm0, 0x8010(%rbp)
movl 0x10(%r14), %eax
movl %eax, 0x8020(%rbp)
movl 0x10(%rdx), %eax
movl %eax, 0x10(%rsp)
movups (%rdx), %xmm0
movups %xmm0, (%rsp)
callq 0x6a99
movq %rax, 0x8008(%rbp)
leaq 0x14(%rax), %rdi
movq %r15, %rsi
callq 0x765d
movq 0x8008(%rbp), %rax
movups 0x20(%rax), %xmm0
movups %xmm0, 0x8028(%rbp)
movq %r12, 0x8070(%rbp)
movq %rbx, 0x8078(%rbp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x7687
movq %r13, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xec95(%rip), %rcx      # 0x15ff8
movq (%rcx), %rdi
movl 0x14(%rax), %edx
movl 0x18(%rax), %ecx
movl 0x1c(%rax), %r8d
movl (%r15), %r9d
movl 0x4(%r15), %eax
movl 0x8(%r15), %esi
movl %esi, 0x8(%rsp)
movl %eax, (%rsp)
leaq 0x8907(%rip), %rsi      # 0xfc90
xorl %eax, %eax
callq 0x31d0
leaq 0x10(%rbx), %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rbx)
callq 0x9f49
andq $0x0, (%rbx)
movq %rbx, %rax
jmp 0x734d