// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
cmpq $0x0, 0x1d091(%rip)     # 0x20a18
jne 0x3990
movb $0x0, %al
callq 0x8870
movq -0x8(%rbp), %rdi
callq 0x30c0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0x39e0
movq -0x8(%rbp), %rax
movq -0x10(%rbp), %rcx
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
je 0x39e0
movq 0x1c631(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
leaq 0x16808(%rip), %rdi     # 0x1a1d9
callq 0x3130
movl $0x1, %edi
callq 0x3080
cmpq $0x2, -0x10(%rbp)
jbe 0x3a18
movq -0x8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jne 0x3a18
movq -0x8(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x78, %eax
jne 0x3a18
movq -0x10(%rbp), %rax
subq $0x2, %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
addq $0x2, %rax
movq %rax, -0x8(%rbp)
movq -0x10(%rbp), %rax
shrq %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x3210
movq %rax, -0x18(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x3a70
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
shlq %rax
addq %rax, %rdi
callq 0x3eb0
movb %al, %dl
movq -0x18(%rbp), %rax
movq -0x28(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x3a38
movq $-0x1, -0x48(%rbp)
movl $0x0, -0x54(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x4c(%rbp)
movq -0x48(%rbp), %rsi
leaq -0x54(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %r8
leaq -0xd8(%rbp), %rdi
leaq -0x40(%rbp), %rax
movq (%rax), %r9
movq %r9, (%rsp)
movq 0x8(%rax), %r9
movq %r9, 0x8(%rsp)
movl 0x10(%rax), %eax
movl %eax, 0x10(%rsp)
callq 0x9b20
leaq -0x98(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
movl $0x40, %edx
callq 0x3200
movb $0x0, %al
callq 0x8d80
cmpl $0x0, 0x1cf1e(%rip)     # 0x20a08
jne 0x3b01
movl 0x1cf1a(%rip), %eax     # 0x20a0c
orl 0x1cf18(%rip), %eax     # 0x20a10
cmpl $0x0, %eax
je 0x3bc3
movq 0x1c4c0(%rip), %rax     # 0x1ffc8
movq (%rax), %rsi
leaq 0x166da(%rip), %rdi     # 0x1a1ec
callq 0x3130
cmpl $0x0, 0x1ceea(%rip)     # 0x20a08
je 0x3b36
movq -0x48(%rbp), %rsi
subq -0x68(%rbp), %rsi
leaq 0x166c0(%rip), %rdi     # 0x1a1ef
movb $0x0, %al
callq 0x3100
cmpl $0x0, 0x1ced3(%rip)     # 0x20a10
je 0x3b83
movq 0x1c482(%rip), %rax     # 0x1ffc8
movq (%rax), %rsi
leaq 0x166ae(%rip), %rdi     # 0x1a1fe
callq 0x3130
movq 0x1c46c(%rip), %rax     # 0x1ffc8
movq (%rax), %rdi
movq -0x60(%rbp), %rsi
movl $0x1, %edx
callq 0x83f0
movq 0x1c454(%rip), %rax     # 0x1ffc8
movq (%rax), %rsi
leaq 0x166a7(%rip), %rdi     # 0x1a225
callq 0x3130
cmpl $0x0, 0x1ce82(%rip)     # 0x20a0c
je 0x3bad
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
movq -0x78(%rbp), %rcx
movq -0x70(%rbp), %r8
leaq 0x1665f(%rip), %rdi     # 0x1a205
movb $0x0, %al
callq 0x3100
movq 0x1c414(%rip), %rax     # 0x1ffc8
movq (%rax), %rsi
leaq 0x1666a(%rip), %rdi     # 0x1a228
callq 0x3130
jmp 0x3bc5
movq -0x98(%rbp), %rax
movq %rax, %rcx
addq $-0x1, %rcx
movq %rcx, -0x98(%rbp)
cmpq $0x0, %rax
je 0x3c08
movq -0x90(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x90(%rbp)
movzbl (%rax), %esi
leaq 0x1680f(%rip), %rdi     # 0x1a40e
movb $0x0, %al
callq 0x3100
jmp 0x3bc5
cmpl $0x0, 0x1cdf9(%rip)     # 0x20a08
jne 0x3c22
movl 0x1cdf5(%rip), %eax     # 0x20a0c
orl 0x1cdf3(%rip), %eax     # 0x20a10
cmpl $0x0, %eax
je 0x3c38
movq 0x1c39f(%rip), %rax     # 0x1ffc8
movq (%rax), %rsi
leaq 0x16605(%rip), %rdi     # 0x1a238
callq 0x3130
movl $0xa, %edi
callq 0x3050
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax,%rax)