// File: /workspace/github_c_makefile_star2_O2/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, 0x13282(%rip)     # 0x16a28
jne 0x37af
xorl %eax, %eax
callq 0x6955
movq %rbx, %rdi
callq 0x30c0
movq %rax, %r14
testb $0x1, %r14b
je 0x37cc
cmpb $0xa, -0x1(%rbx,%r14)
jne 0x39c5
cmpq $0x3, %r14
jb 0x37e5
cmpb $0x30, (%rbx)
jne 0x37e5
cmpb $0x78, 0x1(%rbx)
jne 0x37e5
addq $-0x2, %r14
addq $0x2, %rbx
shrq %r14
movq %r14, %rdi
callq 0x3200
movq %rax, %r15
xorl %r12d, %r12d
cmpq %r12, %r14
je 0x3822
movzbl (%rbx,%r12,2), %edi
callq 0x3bbc
movl %eax, %ebp
shlb $0x4, %bpl
movzbl 0x1(%rbx,%r12,2), %edi
callq 0x3bbc
addb %bpl, %al
movb %al, (%r15,%r12)
incq %r12
jmp 0x37f6
leaq 0x4c(%rsp), %rdx
andq $0x0, (%rdx)
andl $0x0, 0x8(%rdx)
movl 0x48(%rsp), %eax
movl %eax, 0x10(%rsp)
movups 0x38(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x58(%rsp), %r13
pushq $-0x1
popq %rsi
movq %r13, %rdi
movq %r14, %rcx
movq %r15, %r8
callq 0x7557
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 0x6c70
cmpb $0x0, 0x1318a(%rip)     # 0x16a18
je 0x393b
movq %rbx, 0x20(%rsp)
movq 0x12728(%rip), %rbx     # 0x15fc8
movq (%rbx), %rsi
leaq 0xb8b2(%rip), %rdi      # 0xf15c
callq 0x3130
cmpb $0x1, 0x13162(%rip)     # 0x16a18
jne 0x38cc
notq %rbp
leaq 0xb89d(%rip), %rdi      # 0xf15f
movq %rbp, %rsi
xorl %eax, %eax
callq 0x3100
cmpb $0x1, 0x1314d(%rip)     # 0x16a20
jne 0x3901
movq (%rbx), %rsi
leaq 0xb88f(%rip), %rdi      # 0xf16e
callq 0x3130
movq (%rbx), %rdi
pushq $0x1
popq %rdx
movq %r13, %rsi
callq 0x66b0
movq (%rbx), %rsi
leaq 0xb899(%rip), %rdi      # 0xf195
callq 0x3130
cmpb $0x1, 0x13114(%rip)     # 0x16a1c
jne 0x392a
leaq 0xb864(%rip), %rdi      # 0xf175
movq %r12, %rsi
movq 0x20(%rsp), %rdx
movq 0x30(%rsp), %rcx
movq 0x28(%rsp), %r8
xorl %eax, %eax
callq 0x3100
movq (%rbx), %rsi
leaq 0xb864(%rip), %rdi      # 0xf198
callq 0x3130
jmp 0x3955
cmpb $0x0, 0x130da(%rip)     # 0x16a1c
jne 0x3894
testb $0x1, 0x130d1(%rip)     # 0x16a20
jne 0x3894
leaq 0xba22(%rip), %rbx      # 0xf37e
xorl %r12d, %r12d
cmpq %r12, %r14
je 0x3978
movzbl (%r15,%r12), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3100
incq %r12
jmp 0x395f
cmpb $0x0, 0x13099(%rip)     # 0x16a18
je 0x3999
movq 0x12640(%rip), %rax     # 0x15fc8
movq (%rax), %rsi
leaq 0xb816(%rip), %rdi      # 0xf1a8
callq 0x3130
jmp 0x39ab
cmpb $0x0, 0x1307c(%rip)     # 0x16a1c
jne 0x3981
testb $0x1, 0x13077(%rip)     # 0x16a20
jne 0x3981
pushq $0xa
popq %rdi
callq 0x3050
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1262c(%rip), %rax     # 0x15ff8
movq (%rax), %rsi
leaq 0xb773(%rip), %rdi      # 0xf149
callq 0x3130
pushq $0x1
popq %rdi
callq 0x3080