// File: /workspace/github_c_makefile_star2_O1/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, %r13
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %rbp
movq %rdi, %rbx
leaq 0x70(%rsp), %r12
movl 0x10(%r12), %eax
movl %eax, 0x10(%rsp)
movaps (%r12), %xmm0
movups %xmm0, (%rsp)
callq 0x82ed
xorl %edx, %edx
movl $0x3, %ecx
movl 0x10(%rax,%rcx,4), %esi
movl %edx, %edi
addl -0x4(%r14,%rcx,4), %edi
xorl %edx, %edx
movl %esi, %r8d
subl %edi, %r8d
setb %dl
movl %r8d, 0x20(%rsp,%rcx,4)
decq %rcx
jne 0x8bbb
cmpl %edi, %esi
jb 0x8cd6
movq %rbx, 0x30(%rsp)
movq %r13, %rbx
movl 0x24(%rsp), %ecx
movl %ecx, 0x14(%rax)
movl 0x28(%rsp), %ecx
movl %ecx, 0x18(%rax)
movl 0x2c(%rsp), %ecx
movl %ecx, 0x1c(%rax)
leaq 0x18e59(%rip), %rax     # 0x21a60
movq 0x2024000(%rax), %r13
movq %rbp, 0x8080(%r13)
xorl %ebp, %ebp
cmpq %rax, %r13
je 0x8c22
movb -0x8(%r13), %al
jmp 0x8c24
xorl %eax, %eax
movb %al, 0x8088(%r13)
movq (%r14), %rax
movq %rax, 0x8038(%r13)
movl 0x8(%r14), %eax
movl %eax, 0x8040(%r13)
movups (%r12), %xmm0
movups %xmm0, 0x8010(%r13)
movl 0x10(%r12), %eax
movl %eax, 0x8020(%r13)
leaq 0x88(%rsp), %rcx
movl 0x10(%rcx), %eax
movl %eax, 0x10(%rsp)
movups (%rcx), %xmm0
movups %xmm0, (%rsp)
callq 0x82ed
movq %rax, 0x8008(%r13)
xorl %ecx, %ecx
addl 0x1c(%rax,%rcx,4), %ebp
xorl %edx, %edx
addl 0x8(%r14,%rcx,4), %ebp
setb %dl
movl %ebp, 0x1c(%rax,%rcx,4)
decq %rcx
movl %edx, %ebp
cmpq $-0x3, %rcx
jne 0x8c7d
movups 0x20(%rax), %xmm0
movups %xmm0, 0x8028(%r13)
movq %r15, 0x8070(%r13)
movq %rbx, 0x8078(%r13)
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x8f5f
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1031b(%rip), %rcx     # 0x18ff8
movq (%rcx), %rdi
movl 0x14(%rax), %edx
movl 0x18(%rax), %ecx
movl 0x1c(%rax), %r8d
movl (%r14), %r9d
movl 0x4(%r14), %eax
movl 0x8(%r14), %esi
movl %esi, 0x8(%rsp)
movl %eax, (%rsp)
leaq 0x9f8d(%rip), %rsi      # 0x12c90
xorl %eax, %eax
callq 0x31d0
leaq 0x10(%rbx), %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rbx)
callq 0xca1a
movq $0x0, (%rbx)
jmp 0x8cc4