// File: /workspace/github_c_makefile_star2_O2/wjmelements[P]evm/src/evm.c
// Function: fprintLogDiff
uint16_t fprintLogDiff(FILE *file, const logChanges_t *log, const logChanges_t *expected, int showLogIndex) {
    if (log == NULL) {
        return 0;
    }
    if (expected == NULL) {
        return fprintLog(file, log, showLogIndex);
    }
    uint16_t items = fprintLogDiff(file, log->prev, expected->prev, showLogIndex);
    if (items) {
        fputc(',', file);
    }
    if (showLogIndex) {
        fprintf(file, "{\"logIndex\":\"0x%x\",\"data\":\"0x", log->logIndex);
    } else {
        fprintf(file, "{\"data\":\"0x");
    }
    if (log->data.size == expected->data.size) {
        for (size_t i = 0; i < log->data.size; i++) {
            if (log->data.content[i] == expected->data.content[i]) {
                fprintf(file, "%02x", log->data.content[i]);
            } else {
                fprintf(file, "\033[0;31m%02x\033[0m", log->data.content[i]);
            }
        }
    } else {
        for (size_t i = 0; i < log->data.size; i++) {
            fprintf(file, "%02x", log->data.content[i]);
        }
    }
    fputs("\",\"topics\":[", file);
    if (log->topicCount == expected->topicCount) {
        for (uint8_t i = log->topicCount; i-->0;) {
            fputs("\"0x", file);
            for (uint16_t j = 0; j < 32; j++) {
                uint64_t topicPart = log->topics[i].elements[j / 16].elements[(j % 16) / 8];
                topicPart >>= (56 - 8 * (j % 8));
                topicPart &= 0xff;
                uint64_t expectedPart = expected->topics[i].elements[j / 16].elements[(j % 16) / 8];
                expectedPart >>= (56 - 8 * (j % 8));
                expectedPart &= 0xff;
                if (topicPart == expectedPart) {
                    fprintf(file, "%02" PRIx64, topicPart);
                } else {
                    fprintf(file, "\033[0;31m%02" PRIx64 "\033[0m", topicPart);
                }
            }
            fputc('"', file);
            if (i) {
                fputc(',', file);
            }
        }
    } else {
        for (uint8_t i = log->topicCount; i-->0;) {
            fprintf(file, "\"0x%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "\"",
                UPPER(UPPER(log->topics[i])),
                LOWER(UPPER(log->topics[i])),
                UPPER(LOWER(log->topics[i])),
                LOWER(LOWER(log->topics[i]))
            );
            if (i) {
                fputc(',', file);
            }
        }
    }
    fputs("]}", file);
    return items + 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, (%rsp)
testq %rsi, %rsi
je 0x6497
movl %ecx, %ebp
movq %rdx, %r12
movq %rdi, %r13
testq %rdx, %rdx
je 0x649e
movq (%rsp), %rax
movq 0x20(%rax), %rsi
movq 0x20(%r12), %rdx
movq %r13, %rdi
movl %ebp, %ecx
callq 0x6429
movl %eax, 0xc(%rsp)
testw %ax, %ax
je 0x6478
pushq $0x2c
popq %rdi
movq %r13, %rsi
callq 0x3180
testl %ebp, %ebp
je 0x64ba
movq (%rsp), %rbp
movzwl 0xa(%rbp), %edx
leaq 0x94b1(%rip), %rsi      # 0xf93c
movq %r13, %rdi
xorl %eax, %eax
callq 0x31d0
jmp 0x64d3
xorl %eax, %eax
jmp 0x66a1
movq %r13, %rdi
movq (%rsp), %rsi
movl %ebp, %edx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6310
leaq 0x9499(%rip), %rdi      # 0xf95a
pushq $0xb
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rcx
callq 0x3290
movq (%rsp), %rbp
movq 0x10(%rbp), %rax
cmpq 0x10(%r12), %rax
jne 0x6521
leaq 0x8e99(%rip), %rbx      # 0xf37e
leaq 0x94a7(%rip), %r14      # 0xf993
xorl %r15d, %r15d
cmpq %rax, %r15
jae 0x654d
movq 0x18(%rbp), %rax
movzbl (%rax,%r15), %edx
movq 0x18(%r12), %rax
movq %rbx, %rsi
cmpb (%rax,%r15), %dl
je 0x650e
movq %r14, %rsi
movq %r13, %rdi
xorl %eax, %eax
callq 0x31d0
incq %r15
movq 0x10(%rbp), %rax
jmp 0x64ef
leaq 0x8e56(%rip), %r14      # 0xf37e
xorl %ebx, %ebx
cmpq %rax, %rbx
jae 0x654d
movq 0x18(%rbp), %rax
movzbl (%rax,%rbx), %edx
movq %r13, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x31d0
incq %rbx
movq 0x10(%rbp), %rax
jmp 0x652a
leaq 0x9412(%rip), %rdi      # 0xf966
movq %r13, %rbx
movq %r13, %rsi
callq 0x3130
movzbl 0x8(%rbp), %r14d
cmpb 0x8(%r12), %r14b
jne 0x663b
movl $0xff, %ebp
subq $0x1, %r14
jb 0x668c
leaq 0x8c1f(%rip), %rdi      # 0xf1a4
movq %rbx, %r13
movq %rbx, %rsi
callq 0x3130
movq %r14, %rbx
xorl %r14d, %r14d
movq %rbx, 0x10(%rsp)
shlq $0x5, %rbx
xorl %r15d, %r15d
cmpl $0x20, %r15d
je 0x660f
movq (%rsp), %rax
movq (%rax), %rax
addq %rbx, %rax
movl %r15d, %esi
andl $-0x10, %esi
addq %rsi, %rax
movl %r15d, %edi
andl $0x8, %edi
movq (%rdi,%rax), %rdx
movl %r14d, %ecx
notb %cl
andb $0x38, %cl
shrq %cl, %rdx
andq %rbp, %rdx
movq (%r12), %rax
addq %rbx, %rax
addq %rsi, %rax
movq (%rdi,%rax), %rax
shrq %cl, %rax
andq %rbp, %rax
cmpq %rax, %rdx
leaq 0x93b8(%rip), %rsi      # 0xf9a9
leaq 0x93ab(%rip), %rax      # 0xf9a3
cmoveq %rax, %rsi
movq %r13, %rdi
xorl %eax, %eax
callq 0x31d0
incl %r15d
addl $0x8, %r14d
jmp 0x65a2
pushq $0x22
popq %rdi
movq %r13, %rbx
movq %r13, %rsi
callq 0x3180
movq 0x10(%rsp), %r14
testq %r14, %r14
je 0x6574
pushq $0x2c
popq %rdi
movq %rbx, %rsi
callq 0x3180
jmp 0x6574
shll $0x5, %r14d
leaq 0x932d(%rip), %r15      # 0xf973
pushq $0x2c
popq %rbp
testq %r14, %r14
je 0x668c
movq (%rsp), %rax
movq (%rax), %rax
movq -0x20(%rax,%r14), %rdx
movq -0x18(%rax,%r14), %rcx
movq -0x10(%rax,%r14), %r8
movq -0x8(%rax,%r14), %r9
movq %rbx, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x31d0
cmpq $0x20, %r14
je 0x6686
movl %ebp, %edi
movq %rbx, %rsi
callq 0x3180
addq $-0x20, %r14
jmp 0x6649
leaq 0x92fd(%rip), %rdi      # 0xf990
movq %rbx, %rsi
callq 0x3130
movl 0xc(%rsp), %eax
incl %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq