// File: /workspace/github_c_makefile_star2_O1/wjmelements[P]evm/evm.c
// Function: execute
static void execute(const char *contents) {
    if (configFile == NULL) {
        evmInit();
    }
    size_t len = strlen(contents);
    if (len & 1 && contents[len - 1] != '\n') {
        fputs("odd-lengthed input", stderr);
        _exit(1);
    }
    if (len > 2 && contents[0] == '0' && contents[1] == 'x') {
        // allow 0x prefix
        len -= 2;
        contents += 2;
    }
    data_t input;
    input.size = len / 2;
    input.content = malloc(input.size);

    for (size_t i = 0; i < input.size; i++) {
        input.content[i] = hexString16ToUint8(contents + i * 2);
    }

    // TODO support these eth_call parameters
    address_t from;
    uint64_t gas = 0xffffffffffffffff;
    val_t value;
    value[0] = 0;
    value[1] = 0;
    value[2] = 0;
    result_t result;
    if (false) {
        address_t to; // TODO support this parameter
        result = txCall(from, gas, to, value, input, NULL);
    } else {
        result = txCreate(from, gas, value, input);
    }
    evmFinalize();

    if (outputJson) {
        fputs("{\"", stdout);
        if (includeGas) {
            printf("gasUsed\":%" PRIu64 ",\"", gas - result.gasRemaining);
        }
        if (includeLogs) {
            fputs("logs\":", stdout);
            fprintLogs(stdout, result.stateChanges, true);
            fputs(",\"", stdout);
        }
        if (includeStatus) {
            printf(
                "status\":\"0x%08" PRIx64 "%08" PRIx64 "%08" PRIx64 "%08" PRIx64 "\",\"",
                UPPER(UPPER(result.status)),
                LOWER(UPPER(result.status)),
                UPPER(LOWER(result.status)),
                LOWER(LOWER(result.status))
            );
        }
        fputs("returnData\":\"0x", stdout);
    }
    for (;result.returnData.size--;) printf("%02x", *result.returnData.content++);
    if (outputJson) {
        fputs("\"}", stdout);
    }
    putchar('\n');

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
cmpq $0x0, 0x1520b(%rip)     # 0x19a28
jne 0x4826
xorl %eax, %eax
callq 0x80ff
movq %rbx, %rdi
callq 0x30c0
movq %rax, %r12
testb $0x1, %r12b
je 0x4843
cmpb $0xa, -0x1(%rbx,%r12)
jne 0x4adb
cmpq $0x3, %r12
jb 0x485c
cmpb $0x30, (%rbx)
jne 0x485c
cmpb $0x78, 0x1(%rbx)
jne 0x485c
addq $-0x2, %r12
addq $0x2, %rbx
movq %r12, %r14
shrq %r14
movq %r14, %rdi
callq 0x3200
movq %rax, %r15
cmpq $0x2, %r12
jae 0x499f
leaq 0x4c(%rsp), %rdx
movq $0x0, (%rdx)
movl $0x0, 0x8(%rdx)
movl 0x48(%rsp), %eax
movl %eax, 0x10(%rsp)
movups 0x38(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x58(%rsp), %r13
movq %r13, %rdi
movq $-0x1, %rsi
movq %r14, %rcx
movq %r15, %r8
callq 0x8ec9
movq (%r13), %r14
movq 0x8(%r13), %r15
movq 0x10(%r13), %r12
movq 0x18(%r13), %rbx
movq 0x20(%r13), %rax
movq %rax, 0x30(%rsp)
movq 0x28(%r13), %rax
movq %rax, 0x28(%rsp)
movq 0x30(%r13), %rbp
movq 0x38(%r13), %r13
xorl %eax, %eax
callq 0x85ad
cmpb $0x0, 0x1512b(%rip)     # 0x19a18
je 0x4a4c
movq %rbx, 0x20(%rsp)
movq 0x146c9(%rip), %rbx     # 0x18fc8
movq (%rbx), %rsi
leaq 0xd853(%rip), %rdi      # 0x1215c
callq 0x3130
cmpb $0x1, 0x15103(%rip)     # 0x19a18
jne 0x492b
notq %rbp
leaq 0xd83e(%rip), %rdi      # 0x1215f
movq %rbp, %rsi
xorl %eax, %eax
callq 0x3100
cmpb $0x1, 0x150ee(%rip)     # 0x19a20
jne 0x4962
movq (%rbx), %rsi
leaq 0xd830(%rip), %rdi      # 0x1216e
callq 0x3130
movq (%rbx), %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0x7e4e
movq (%rbx), %rsi
leaq 0xd838(%rip), %rdi      # 0x12195
callq 0x3130
cmpb $0x1, 0x150b3(%rip)     # 0x19a1c
jne 0x498b
leaq 0xd803(%rip), %rdi      # 0x12175
movq %r12, %rsi
movq 0x20(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq 0x28(%rsp), %r8
xorl %eax, %eax
callq 0x3100
movq (%rbx), %rsi
leaq 0xd803(%rip), %rdi      # 0x12198
callq 0x3130
jmp 0x4a66
movq 0x14652(%rip), %rdx     # 0x18ff8
leaq 0xd7fe(%rip), %r12      # 0x121ab
xorl %ebp, %ebp
movzbl (%rbx,%rbp,2), %ecx
leal -0x30(%rcx), %r13d
cmpb $0xa, %r13b
jb 0x49d6
leal -0x61(%rcx), %eax
cmpb $0x5, %al
ja 0x49c9
addb $-0x57, %cl
jmp 0x49d3
leal -0x41(%rcx), %eax
cmpb $0x5, %al
ja 0x4a12
addb $-0x37, %cl
movl %ecx, %r13d
movzbl 0x1(%rbx,%rbp,2), %ecx
leal -0x30(%rcx), %eax
cmpb $0xa, %al
jb 0x49fa
leal -0x61(%rcx), %eax
cmpb $0x5, %al
ja 0x49ee
addb $-0x57, %cl
jmp 0x49f8
leal -0x41(%rcx), %eax
cmpb $0x5, %al
ja 0x4a2c
addb $-0x37, %cl
movl %ecx, %eax
shlb $0x4, %r13b
addb %al, %r13b
movb %r13b, (%r15,%rbp)
incq %rbp
cmpq %rbp, %r14
jne 0x49af
jmp 0x4877
movq (%rdx), %rdi
movq %r12, %rsi
movq %rdx, %r13
movl %ecx, %edx
xorl %eax, %eax
callq 0x31d0
movq %r13, %rdx
movb $-0x1, %r13b
jmp 0x49d6
movq (%rdx), %rdi
movq %r12, %rsi
movq %rdx, %r12
movl %ecx, %edx
xorl %eax, %eax
callq 0x31d0
movq %r12, %rdx
leaq 0xd763(%rip), %r12      # 0x121ab
movb $-0x1, %al
jmp 0x49fa
cmpb $0x0, 0x14fc9(%rip)     # 0x19a1c
jne 0x48f3
testb $0x1, 0x14fc0(%rip)     # 0x19a20
jne 0x48f3
testq %r14, %r14
je 0x4a8c
leaq 0xd90c(%rip), %rbx      # 0x1237e
xorl %r12d, %r12d
movzbl (%r15,%r12), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3100
incq %r12
cmpq %r12, %r14
jne 0x4a75
cmpb $0x0, 0x14f85(%rip)     # 0x19a18
je 0x4aad
movq 0x1452c(%rip), %rax     # 0x18fc8
movq (%rax), %rsi
leaq 0xd702(%rip), %rdi      # 0x121a8
callq 0x3130
jmp 0x4abf
cmpb $0x0, 0x14f68(%rip)     # 0x19a1c
jne 0x4a95
testb $0x1, 0x14f63(%rip)     # 0x19a20
jne 0x4a95
movl $0xa, %edi
callq 0x3050
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x33db