// File: /workspace/github_c_makefile_star2_O0/wjmelements[P]evm/src/dio.c
// Function: runTests
static uint64_t runTests(const entry_t *entry, testEntry_t *test) {
    if (test == NULL) {
        return 0;
    }
    uint64_t testsRun = runTests(entry, test->prev);
    if (!testsRun) {
        fputs("# ", stderr);
        if (entry->constructPath) {
            fputs(entry->constructPath, stderr);
        } else {
            fprintAddress(stderr, (*entry->address));
        }
        fputc('\n', stderr);
    }

    evmSetDebug(test->debug);
    if (test->blockNumber) {
        evmSetBlockNumber(*test->blockNumber);
        free(test->blockNumber);
    }
    if (test->timestamp) {
        evmSetTimestamp(*test->timestamp);
        free(test->timestamp);
    }
    uint64_t gas = 0xffffffffffffffff;
    if (test->gas) {
        gas = test->gas;
    }
    // TODO support evmStaticCall
    result_t result = txCall(test->from, gas, test->to ? *test->to : *entry->address, test->value, test->input, test->accessList);
    uint64_t gasUsed = gas - result.gasRemaining;
    test->result.gasUsed = gasUsed;

    if (test->name) {
        fputs(test->name, stderr);
    } else {
        fprintf(stderr, "%" PRIu64, testsRun);
    }
    fputs(": ", stderr);
    int testFailure = 0;
    if (!equal256(&result.status, &test->status) || test->op == CREATE) {
        if (zero256(&result.status)) {
            if (result.returnData.size) {
                fputs("\033[0;31mreverted: ", stderr);
                fprintData(stderr, result.returnData);
                fputs("\033[0m\n", stderr);
            } else {
                fputs("\033[0;31mreverted\033[0m\n", stderr);
            }
        } else {
            fputs("\033[0;31mshould revert\033[0m\n", stderr);
        }
        testFailure = anyTestFailure = 1;
    } else {
        const logsEntry_t *expectedLogs = test->logs;
        while (expectedLogs) {
            // find corresponding acccount
            const stateChanges_t *actualLogs = result.stateChanges;
            while (actualLogs) {
                if (AddressEqual(&actualLogs->account, &expectedLogs->address)) {
                    break;
                }
                actualLogs = actualLogs->next;
            }
            if (actualLogs) {
                // compare all logs
                const logChanges_t *expectedLog = expectedLogs->logs;
                const logChanges_t *actualLog = actualLogs->logChanges;
                if (!LogsEqual(expectedLog, actualLog)) {
                    // mismatch
                    fputs("logs expected:\n", stderr);
                    fprintLog(stderr, expectedLog, false);
                    fputc('\n', stderr);
                    fputs("logs actual:\n", stderr);
                    fprintLogDiff(stderr, actualLog, expectedLog, false);
                    fputc('\n', stderr);
                    testFailure = anyTestFailure = 1;
                }
            } else {
                // Missing!
                fputs("expected logs missing:\n", stderr);
                fprintLog(stderr, expectedLogs->logs, false);
                fputc('\n', stderr);
                testFailure = anyTestFailure = 1;
            }
            expectedLogs = expectedLogs->prev;
        }
    }

    if (test->outputSpecified && (result.returnData.size != test->output.size || memcmp(result.returnData.content, test->output.content, test->output.size))) {
        fputs("Output data mismatch\nactual:\n", stderr);

        fprintData(stderr, result.returnData);
        fputs("\nexpected:\n", stderr);
        fprintData(stderr, test->output);
        fputc('\n', stderr);
        testFailure = anyTestFailure = 1;
    } else if (test->gasUsed) {
        if (test->gasUsed < gasUsed) {
            // more actual gasUsed than expected
            fprintf(stderr, "gasUsed \033[0;31m%" PRIu64 "\033[0m expected %" PRIu64 " (\033[0;31m+%" PRIu64 "\033[0m)\n", gasUsed, test->gasUsed, gasUsed - test->gasUsed);
        } else if (test->gasUsed > gas - result.gasRemaining) {
            // less actual gasUsed than expected
            fprintf(stderr, "gasUsed \033[0;32m%" PRIu64 "\033[0m expected %" PRIu64 " (\033[0;32m-%" PRIu64 "\033[0m)\n", gasUsed, test->gasUsed, test->gasUsed - gasUsed);
        } else if (testFailure) {
            fprintf(stderr, "\033[0;31mfail\033[0m\n");
        } else {
            fprintf(stderr, "\033[0;32mpass\033[0m\n");
        }
    } else if (testFailure) {
        fprintf(stderr, "\033[0;31mfail\033[0m\n");
    } else {
        fprintf(stderr, "\033[0;32mpass\033[0m\n");
    }

    return ++testsRun;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rdi, -0x38(%rbp)
movq %rsi, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x6f80
movq $0x0, -0x30(%rbp)
jmp 0x7873
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rax
movq 0xd8(%rax), %rsi
callq 0x6f50
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x7194
movq 0x1904e(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
leaq 0x1347a(%rip), %rdi     # 0x1a42e
callq 0x3130
movq -0x38(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0x6fe0
movq -0x38(%rbp), %rax
movq 0x58(%rax), %rdi
movq 0x19025(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
callq 0x3130
jmp 0x7180
movq 0x19011(%rip), %rax     # 0x1fff8
movq (%rax), %rdi
movq -0x38(%rbp), %rax
movq (%rax), %rax
movzbl (%rax), %edx
movq -0x38(%rbp), %rax
movq (%rax), %rax
movzbl 0x1(%rax), %ecx
movq -0x38(%rbp), %rax
movq (%rax), %rax
movzbl 0x2(%rax), %r8d
movq -0x38(%rbp), %rax
movq (%rax), %rax
movzbl 0x3(%rax), %r9d
movq -0x38(%rbp), %rax
movq (%rax), %rax
movzbl 0x4(%rax), %eax
movq -0x38(%rbp), %rsi
movq (%rsi), %rsi
movzbl 0x5(%rsi), %esi
movl %esi, -0x110(%rbp)
movq -0x38(%rbp), %rsi
movq (%rsi), %rsi
movzbl 0x6(%rsi), %esi
movl %esi, -0x10c(%rbp)
movq -0x38(%rbp), %rsi
movq (%rsi), %rsi
movzbl 0x7(%rsi), %esi
movl %esi, -0x108(%rbp)
movq -0x38(%rbp), %rsi
movq (%rsi), %rsi
movzbl 0x8(%rsi), %esi
movl %esi, -0x104(%rbp)
movq -0x38(%rbp), %rsi
movq (%rsi), %rsi
movzbl 0x9(%rsi), %esi
movl %esi, -0x100(%rbp)
movq -0x38(%rbp), %rsi
movq (%rsi), %rsi
movzbl 0xa(%rsi), %esi
movl %esi, -0xfc(%rbp)
movq -0x38(%rbp), %rsi
movq (%rsi), %rsi
movzbl 0xb(%rsi), %esi
movl %esi, -0xf8(%rbp)
movq -0x38(%rbp), %rsi
movq (%rsi), %rsi
movzbl 0xc(%rsi), %r13d
movq -0x38(%rbp), %rsi
movq (%rsi), %rsi
movzbl 0xd(%rsi), %r12d
movq -0x38(%rbp), %rsi
movq (%rsi), %rsi
movzbl 0xe(%rsi), %r15d
movq -0x38(%rbp), %rsi
movq (%rsi), %rsi
movzbl 0xf(%rsi), %r14d
movq -0x38(%rbp), %rsi
movq (%rsi), %rsi
movzbl 0x10(%rsi), %ebx
movq -0x38(%rbp), %rsi
movq (%rsi), %rsi
movzbl 0x11(%rsi), %r11d
movq -0x38(%rbp), %rsi
movq (%rsi), %rsi
movzbl 0x12(%rsi), %r10d
movq -0x38(%rbp), %rsi
movq (%rsi), %rsi
movzbl 0x13(%rsi), %esi
movl %esi, -0xf4(%rbp)
leaq 0x132bc(%rip), %rsi     # 0x1a3c0
movl %eax, (%rsp)
movl -0x110(%rbp), %eax
movl %eax, 0x8(%rsp)
movl -0x10c(%rbp), %eax
movl %eax, 0x10(%rsp)
movl -0x108(%rbp), %eax
movl %eax, 0x18(%rsp)
movl -0x104(%rbp), %eax
movl %eax, 0x20(%rsp)
movl -0x100(%rbp), %eax
movl %eax, 0x28(%rsp)
movl -0xfc(%rbp), %eax
movl %eax, 0x30(%rsp)
movl -0xf8(%rbp), %eax
movl %eax, 0x38(%rsp)
movl -0xf4(%rbp), %eax
movl %r13d, 0x40(%rsp)
movl %r12d, 0x48(%rsp)
movl %r15d, 0x50(%rsp)
movl %r14d, 0x58(%rsp)
movl %ebx, 0x60(%rsp)
movl %r11d, 0x68(%rsp)
movl %r10d, 0x70(%rsp)
movl %eax, 0x78(%rsp)
movb $0x0, %al
callq 0x31e0
movq 0x18e71(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
movl $0xa, %edi
callq 0x3180
movq -0x40(%rbp), %rax
movq 0xb0(%rax), %rdi
callq 0x8850
movq -0x40(%rbp), %rax
cmpq $0x0, 0xa0(%rax)
je 0x71d5
movq -0x40(%rbp), %rax
movq 0xa0(%rax), %rax
movq (%rax), %rdi
callq 0x8810
movq -0x40(%rbp), %rax
movq 0xa0(%rax), %rdi
callq 0x3040
movq -0x40(%rbp), %rax
cmpq $0x0, 0xa8(%rax)
je 0x7206
movq -0x40(%rbp), %rax
movq 0xa8(%rax), %rax
movq (%rax), %rdi
callq 0x8830
movq -0x40(%rbp), %rax
movq 0xa8(%rax), %rdi
callq 0x3040
movq $-0x1, -0x50(%rbp)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x60(%rax)
je 0x7225
movq -0x40(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x40(%rbp), %rax
addq $0x9, %rax
movq %rax, -0x120(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x118(%rbp)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x7272
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movq (%rax), %rcx
movq %rcx, -0xa8(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0xa0(%rbp)
movl 0x10(%rax), %eax
movl %eax, -0x98(%rbp)
jmp 0x7297
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rcx
movq %rcx, -0xa8(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0xa0(%rbp)
movl 0x10(%rax), %eax
movl %eax, -0x98(%rbp)
movq -0x118(%rbp), %rsi
movq -0x120(%rbp), %rcx
movq -0x40(%rbp), %rdx
addq $0x28, %rdx
movq -0x40(%rbp), %rax
movq -0x40(%rbp), %rdi
movq 0x68(%rdi), %r9
movq (%rcx), %rdi
movq %rdi, -0xc0(%rbp)
movq 0x8(%rcx), %rdi
movq %rdi, -0xb8(%rbp)
movl 0x10(%rcx), %ecx
movl %ecx, -0xb0(%rbp)
movq 0x38(%rax), %rcx
movq 0x40(%rax), %r8
leaq -0x90(%rbp), %rdi
leaq -0xc0(%rbp), %r10
leaq -0xa8(%rbp), %rax
movq (%r10), %r11
movq %r11, (%rsp)
movq 0x8(%r10), %r11
movq %r11, 0x8(%rsp)
movl 0x10(%r10), %r10d
movl %r10d, 0x10(%rsp)
movq (%rax), %r10
movq %r10, 0x18(%rsp)
movq 0x8(%rax), %r10
movq %r10, 0x20(%rsp)
movl 0x10(%rax), %eax
movl %eax, 0x28(%rsp)
callq 0x9350
movq -0x50(%rbp), %rax
subq -0x60(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0xc0(%rax)
movq -0x40(%rbp), %rax
cmpq $0x0, (%rax)
je 0x736d
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movq 0x18c95(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
callq 0x3130
jmp 0x7389
movq 0x18c84(%rip), %rax     # 0x1fff8
movq (%rax), %rdi
movq -0x48(%rbp), %rdx
leaq 0x137fe(%rip), %rsi     # 0x1ab80
movb $0x0, %al
callq 0x31e0
movq 0x18c68(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
leaq 0x130a6(%rip), %rdi     # 0x1a440
callq 0x3130
movl $0x0, -0xcc(%rbp)
leaq -0x90(%rbp), %rdi
addq $0x10, %rdi
movq -0x40(%rbp), %rsi
addq $0x70, %rsi
callq 0x10410
testb $0x1, %al
jne 0x73c7
jmp 0x73da
movq -0x40(%rbp), %rax
movzbl 0x8(%rax), %eax
cmpl $0xf0, %eax
jne 0x748c
leaq -0x90(%rbp), %rdi
addq $0x10, %rdi
callq 0xf7b0
testb $0x1, %al
jne 0x73f0
jmp 0x745d
cmpq $0x0, -0x90(%rbp)
je 0x7445
movq 0x18bf7(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
leaq 0x13026(%rip), %rdi     # 0x1a431
callq 0x3130
movq 0x18be1(%rip), %rax     # 0x1fff8
movq (%rax), %rdi
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
callq 0x7a80
movq 0x18bc4(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
leaq 0x13014(%rip), %rdi     # 0x1a452
callq 0x3130
jmp 0x745b
movq 0x18bac(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
leaq 0x12fed(%rip), %rdi     # 0x1a443
callq 0x3130
jmp 0x7473
movq 0x18b94(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
leaq 0x12fea(%rip), %rdi     # 0x1a458
callq 0x3130
movl $0x1, 0x215c3(%rip)     # 0x28a40
movl $0x1, -0xcc(%rbp)
jmp 0x7651
movq -0x40(%rbp), %rax
movq 0x98(%rax), %rax
movq %rax, -0xd8(%rbp)
cmpq $0x0, -0xd8(%rbp)
je 0x764f
movq -0x58(%rbp), %rax
movq %rax, -0xe0(%rbp)
cmpq $0x0, -0xe0(%rbp)
je 0x74ef
movq -0xe0(%rbp), %rdi
movq -0xd8(%rbp), %rsi
callq 0x7ae0
cmpl $0x0, %eax
je 0x74db
jmp 0x74ef
movq -0xe0(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0xe0(%rbp)
jmp 0x74b7
cmpq $0x0, -0xe0(%rbp)
je 0x75de
movq -0xd8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xe8(%rbp)
movq -0xe0(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0xf0(%rbp)
movq -0xe8(%rbp), %rdi
movq -0xf0(%rbp), %rsi
callq 0x7b40
cmpl $0x0, %eax
jne 0x75dc
movq 0x18ab4(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
leaq 0x12f24(%rip), %rdi     # 0x1a472
callq 0x3130
movq 0x18a9e(%rip), %rax     # 0x1fff8
movq (%rax), %rdi
movq -0xe8(%rbp), %rsi
xorl %edx, %edx
callq 0x7dc0
movq 0x18a86(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
movl $0xa, %edi
callq 0x3180
movq 0x18a72(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
leaq 0x12ef2(%rip), %rdi     # 0x1a482
callq 0x3130
movq 0x18a5c(%rip), %rax     # 0x1fff8
movq (%rax), %rdi
movq -0xf0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
xorl %ecx, %ecx
callq 0x7f70
movq 0x18a3d(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
movl $0xa, %edi
callq 0x3180
movl $0x1, 0x2146e(%rip)     # 0x28a40
movl $0x1, -0xcc(%rbp)
jmp 0x7638
movq 0x18a13(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
leaq 0x12ea1(%rip), %rdi     # 0x1a490
callq 0x3130
movq 0x189fd(%rip), %rax     # 0x1fff8
movq (%rax), %rdi
movq -0xd8(%rbp), %rax
movq 0x18(%rax), %rsi
xorl %edx, %edx
callq 0x7dc0
movq 0x189e1(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
movl $0xa, %edi
callq 0x3180
movl $0x1, 0x21412(%rip)     # 0x28a40
movl $0x1, -0xcc(%rbp)
movq -0xd8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0xd8(%rbp)
jmp 0x749e
jmp 0x7651
movq -0x40(%rbp), %rax
testb $0x1, 0x58(%rax)
je 0x7726
movq -0x90(%rbp), %rax
movq -0x40(%rbp), %rcx
cmpq 0x48(%rcx), %rax
jne 0x7695
movq -0x88(%rbp), %rdi
movq -0x40(%rbp), %rax
movq 0x50(%rax), %rsi
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rdx
callq 0x31a0
cmpl $0x0, %eax
je 0x7726
movq 0x1895c(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
leaq 0x12e02(%rip), %rdi     # 0x1a4a8
callq 0x3130
movq 0x18946(%rip), %rax     # 0x1fff8
movq (%rax), %rdi
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rdx
callq 0x7a80
movq 0x18929(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
leaq 0x12d49(%rip), %rdi     # 0x1a422
callq 0x3130
movq 0x18913(%rip), %rax     # 0x1fff8
movq (%rax), %rdi
movq -0x40(%rbp), %rax
movq 0x48(%rax), %rsi
movq 0x50(%rax), %rdx
callq 0x7a80
movq 0x188f8(%rip), %rax     # 0x1fff8
movq (%rax), %rsi
movl $0xa, %edi
callq 0x3180
movl $0x1, 0x21329(%rip)     # 0x28a40
movl $0x1, -0xcc(%rbp)
jmp 0x7863
movq -0x40(%rbp), %rax
cmpq $0x0, 0x90(%rax)
je 0x7824
movq -0x40(%rbp), %rax
movq 0x90(%rax), %rax
cmpq -0xc8(%rbp), %rax
jae 0x778d
movq 0x188a5(%rip), %rax     # 0x1fff8
movq (%rax), %rdi
movq -0xc8(%rbp), %rdx
movq -0x40(%rbp), %rax
movq 0x90(%rax), %rcx
movq -0xc8(%rbp), %r8
movq -0x40(%rbp), %rax
subq 0x90(%rax), %r8
leaq 0x12d45(%rip), %rsi     # 0x1a4c6
movb $0x0, %al
callq 0x31e0
jmp 0x7822
movq -0x40(%rbp), %rax
movq 0x90(%rax), %rax
movq -0x50(%rbp), %rcx
subq -0x60(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x77e3
movq 0x1884c(%rip), %rax     # 0x1fff8
movq (%rax), %rdi
movq -0xc8(%rbp), %rdx
movq -0x40(%rbp), %rax
movq 0x90(%rax), %rcx
movq -0x40(%rbp), %rax
movq 0x90(%rax), %r8
subq -0xc8(%rbp), %r8
leaq 0x12d23(%rip), %rsi     # 0x1a4fd
movb $0x0, %al
callq 0x31e0
jmp 0x7820
cmpl $0x0, -0xcc(%rbp)
je 0x7806
movq 0x18805(%rip), %rax     # 0x1fff8
movq (%rax), %rdi
leaq 0x12d37(%rip), %rsi     # 0x1a534
movb $0x0, %al
callq 0x31e0
jmp 0x781e
movq 0x187eb(%rip), %rax     # 0x1fff8
movq (%rax), %rdi
leaq 0x12d2e(%rip), %rsi     # 0x1a545
movb $0x0, %al
callq 0x31e0
jmp 0x7820
jmp 0x7822
jmp 0x7861
cmpl $0x0, -0xcc(%rbp)
je 0x7847
movq 0x187c4(%rip), %rax     # 0x1fff8
movq (%rax), %rdi
leaq 0x12cf6(%rip), %rsi     # 0x1a534
movb $0x0, %al
callq 0x31e0
jmp 0x785f
movq 0x187aa(%rip), %rax     # 0x1fff8
movq (%rax), %rdi
leaq 0x12ced(%rip), %rsi     # 0x1a545
movb $0x0, %al
callq 0x31e0
jmp 0x7861
jmp 0x7863
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)