// File: /workspace/github_c_makefile_star2_O3/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, 0x14259(%rip)     # 0x18a28
jne 0x47d8
xorl %eax, %eax
callq 0x80ed
movq %rbx, %rdi
callq 0x30c0
movq %rax, %r12
testb $0x1, %r12b
je 0x47f5
cmpb $0xa, -0x1(%rbx,%r12)
jne 0x4aa3
cmpq $0x3, %r12
jb 0x4816
cmpb $0x30, (%rbx)
jne 0x49e5
cmpb $0x78, 0x1(%rbx)
jne 0x49e5
addq $-0x2, %r12
addq $0x2, %rbx
movq %r12, %r14
shrq %r14
movq %r14, %rdi
callq 0x3200
movq %rax, %r15
cmpq $0x2, %r12
jae 0x49f6
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 0x8d23
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 0x83e9
cmpb $0x0, 0x14171(%rip)     # 0x18a18
je 0x4956
movq %rbx, 0x20(%rsp)
movq 0x1370f(%rip), %rbx     # 0x17fc8
movq (%rbx), %rsi
leaq 0xd899(%rip), %rdi      # 0x1215c
callq 0x3130
cmpb $0x1, 0x14149(%rip)     # 0x18a18
jne 0x48e5
notq %rbp
leaq 0xd884(%rip), %rdi      # 0x1215f
movq %rbp, %rsi
xorl %eax, %eax
callq 0x3100
cmpb $0x1, 0x14134(%rip)     # 0x18a20
jne 0x491c
movq (%rbx), %rsi
leaq 0xd876(%rip), %rdi      # 0x1216e
callq 0x3130
movq (%rbx), %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0x7e3a
movq (%rbx), %rsi
leaq 0xd87e(%rip), %rdi      # 0x12195
callq 0x3130
cmpb $0x1, 0x140f9(%rip)     # 0x18a1c
jne 0x4945
leaq 0xd849(%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 0xd849(%rip), %rdi      # 0x12198
callq 0x3130
jmp 0x4970
cmpb $0x0, 0x140bf(%rip)     # 0x18a1c
jne 0x48ad
testb $0x1, 0x140b6(%rip)     # 0x18a20
jne 0x48ad
testq %r14, %r14
je 0x4996
leaq 0xda02(%rip), %rbx      # 0x1237e
xorl %r12d, %r12d
movzbl (%r15,%r12), %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3100
incq %r12
cmpq %r12, %r14
jne 0x497f
cmpb $0x0, 0x1407b(%rip)     # 0x18a18
je 0x49b7
movq 0x13622(%rip), %rax     # 0x17fc8
movq (%rax), %rsi
leaq 0xd7f8(%rip), %rdi      # 0x121a8
callq 0x3130
jmp 0x49c9
cmpb $0x0, 0x1405e(%rip)     # 0x18a1c
jne 0x499f
testb $0x1, 0x14059(%rip)     # 0x18a20
jne 0x499f
movl $0xa, %edi
callq 0x3050
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
shrq %r12
movq %r12, %rdi
callq 0x3200
movq %rax, %r15
movq %r12, %r14
movq 0x135fb(%rip), %rdx     # 0x17ff8
leaq 0xd7a7(%rip), %r12      # 0x121ab
xorl %ebp, %ebp
movzbl (%rbx,%rbp,2), %ecx
leal -0x30(%rcx), %r13d
cmpb $0xa, %r13b
jb 0x4a2d
leal -0x61(%rcx), %eax
cmpb $0x5, %al
ja 0x4a20
addb $-0x57, %cl
jmp 0x4a2a
leal -0x41(%rcx), %eax
cmpb $0x5, %al
ja 0x4a69
addb $-0x37, %cl
movl %ecx, %r13d
movzbl 0x1(%rbx,%rbp,2), %ecx
leal -0x30(%rcx), %eax
cmpb $0xa, %al
jb 0x4a51
leal -0x61(%rcx), %eax
cmpb $0x5, %al
ja 0x4a45
addb $-0x57, %cl
jmp 0x4a4f
leal -0x41(%rcx), %eax
cmpb $0x5, %al
ja 0x4a83
addb $-0x37, %cl
movl %ecx, %eax
shlb $0x4, %r13b
addb %al, %r13b
movb %r13b, (%r15,%rbp)
incq %rbp
cmpq %rbp, %r14
jne 0x4a06
jmp 0x4831
movq (%rdx), %rdi
movq %r12, %rsi
movq %rdx, %r13
movl %ecx, %edx
xorl %eax, %eax
callq 0x31d0
movq %r13, %rdx
movb $-0x1, %r13b
jmp 0x4a2d
movq (%rdx), %rdi
movq %r12, %rsi
movq %rdx, %r12
movl %ecx, %edx
xorl %eax, %eax
callq 0x31d0
movq %r12, %rdx
leaq 0xd70c(%rip), %r12      # 0x121ab
movb $-0x1, %al
jmp 0x4a51
callq 0x33db